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