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