\r
// Do we need this?\r
element.setHint(DiagramHints.ROUTE_ALGORITHM, new Router4(false));\r
-\r
+ System.out.println(connection);\r
IModelingRules modelingRules = diagram.getHint(DiagramModelHints.KEY_MODELING_RULES);\r
\r
- IElement mappedElement = ElementUtils.getByData(diagram, connection);\r
- if (mappedElement == null)\r
- // FIXME: With undo this seems to happen, don't know why yet!\r
- return;\r
+// IElement mappedElement = ElementUtils.getByData(diagram, connection);\r
+// if (mappedElement == null) {\r
+// System.out.println("taalla ollaan mappedElement == null");\r
+// // FIXME: With undo this seems to happen, don't know why yet!\r
+// return;\r
+// }\r
\r
Color color = null;\r
DiagramResource DR = DiagramResource.getInstance(graph);\r
// Initialize ConnectionEntity in element\r
// NOTE: MUST use the mapped element with class CE, not the connection (element) were loading into.\r
// GDS will synchronize element into mappedElement in a controlled manner.\r
- element.setHint(ElementHints.KEY_CONNECTION_ENTITY, new CE(connection, mappedElement, backendonnections));\r
+ element.setHint(ElementHints.KEY_CONNECTION_ENTITY, new CE(diagram, connection, element, backendonnections));\r
\r
// Setup graph writeback support for route graph modifications\r
final Session session = graph.getSession();\r
*/\r
static class CE implements ConnectionEntity {\r
\r
+ \r
+ private IDiagram diagram;\r
+\r
+ private transient DataElementMap dataMap;\r
+ \r
/**\r
* The connection instance resource in the graph backend.\r
*/\r
/**\r
* The connection entity element which is a part of the diagram.\r
*/\r
- final IElement connectionElement;\r
+ IElement connectionElement;\r
\r
/**\r
* @see #getTerminalConnections(Collection)\r
*/\r
Set<Connection> terminalConnections;\r
\r
- CE(Resource connection, IElement connectionElement, Set<BackendConnection> backendConnections) {\r
+ \r
+ public CE(IDiagram diagram, Resource connection, IElement connectionElement, Set<BackendConnection> backendConnections) {\r
+ if (connectionElement == null)\r
+ throw new NullPointerException("null connection element");\r
+ this.diagram = diagram;\r
+ this.dataMap = diagram.getDiagramClass().getSingleItem(DataElementMap.class);\r
this.connection = connection;\r
this.connectionElement = connectionElement;\r
this.backendConnections = backendConnections;\r
+ IElement ce = getConnection0();\r
+ if (ce != null)\r
+ this.connectionElement = ce;\r
+ }\r
+\r
+ public IElement getConnection0() {\r
+ IElement connectionElement = dataMap.getElement(diagram, connection);\r
+ return connectionElement;\r
}\r
\r
@Override\r
public IElement getConnection() {\r
- return connectionElement;\r
+ IElement c = getConnection0();\r
+ if (c == null)\r
+ c = this.connectionElement;\r
+ return c;\r
}\r
\r
public Object getConnectionObject() {\r
}\r
\r
private Set<Connection> calculateTerminalConnections() {\r
- IDiagram diagram = connectionElement.getDiagram();\r
DataElementMap dem = diagram.getDiagramClass().getSingleItem(DataElementMap.class);\r
Set<Connection> result = new HashSet<Connection>();\r
ArrayList<Terminal> ts = new ArrayList<Terminal>();\r