1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.structural.ui.modelBrowser.contributions;
14 import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;
15 import org.simantics.databoard.Bindings;
16 import org.simantics.db.ReadGraph;
17 import org.simantics.db.Resource;
18 import org.simantics.db.exception.DatabaseException;
19 import org.simantics.layer0.Layer0;
20 import org.simantics.structural.stubs.StructuralResource2;
21 import org.simantics.structural.ui.modelBrowser.nodes.ConnectionNode;
22 import org.simantics.structural2.utils.StructuralUtils;
24 public class ConnectionLabeler extends LabelerContributor<ConnectionNode> {
27 public String getLabel(ReadGraph graph, ConnectionNode node) throws DatabaseException {
28 StructuralResource2 sr = StructuralResource2.getInstance(graph);
29 StringBuilder sb = new StringBuilder();
30 Layer0 b = Layer0.getInstance(graph);
34 for(Resource component : graph.getObjects(node.connection, sr.Connects)) {
39 sb.append(graph.<String>getRelatedValue(component, b.HasName, Bindings.STRING));
45 for(Resource relatedConnection : StructuralUtils.getRelatedConnections(graph, node.connection)) {
46 if(relatedConnection.equals(node.connection))
48 for(Resource component : graph.getObjects(relatedConnection, sr.Connects)) {
53 sb.append(graph.<String>getRelatedValue(component, b.HasName, Bindings.STRING));
62 public int getCategory(ReadGraph graph, ConnectionNode node) throws DatabaseException {