1 /*******************************************************************************
\r
2 * Copyright (c) 2011 Association for Decentralized Information Management in
\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.diagram.profile;
\r
14 import org.simantics.db.ReadGraph;
\r
15 import org.simantics.db.Resource;
\r
16 import org.simantics.db.exception.DatabaseException;
\r
17 import org.simantics.diagram.content.ConnectionUtil;
\r
18 import org.simantics.diagram.flag.FlagUtil;
\r
19 import org.simantics.diagram.stubs.DiagramResource;
\r
20 import org.simantics.modeling.ModelingResources;
\r
23 * @author Tuukka Lehtonen
\r
25 public abstract class ComponentTextStyle extends TextStyle {
\r
27 public ComponentTextStyle() {
\r
31 public ComponentTextStyle(double xOffset, double yOffset) {
\r
32 super(xOffset, yOffset);
\r
36 protected Resource getConfigurationComponent(ReadGraph graph, Resource element) throws DatabaseException {
\r
37 ModelingResources MOD = ModelingResources.getInstance(graph);
\r
38 Resource component = graph.getPossibleObject(element, MOD.ElementToComponent);
\r
39 if (component != null)
\r
42 DiagramResource DIA = DiagramResource.getInstance(graph);
\r
43 if (graph.isInstanceOf(element, DIA.Flag) && FlagUtil.isExternal(graph, element)) {
\r
44 for (Resource connector : graph.getObjects(element, DIA.Flag_ConnectionPoint)) {
\r
45 Resource connection = ConnectionUtil.getConnection(graph, connector);
\r
46 component = graph.getPossibleObject(connection, MOD.ElementToComponent);
\r
47 if (component != null)
\r