]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/graph/AddBranchpoint.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / synchronization / graph / AddBranchpoint.java
index 8bb96d96acc2f8bc46b552cb62340265df643dee..00a84c89b80296071dd30badd34fe81bfa1d9fee 100644 (file)
@@ -1,62 +1,62 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.diagram.synchronization.graph;\r
-\r
-import java.awt.geom.AffineTransform;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.diagram.content.ConnectionUtil;\r
-import org.simantics.diagram.synchronization.ModificationAdapter;\r
-import org.simantics.g2d.diagram.DiagramHints;\r
-import org.simantics.g2d.diagram.DiagramMutator;\r
-import org.simantics.g2d.diagram.IDiagram;\r
-import org.simantics.g2d.element.ElementHints;\r
-import org.simantics.g2d.element.ElementUtils;\r
-import org.simantics.g2d.element.IElement;\r
-import org.simantics.g2d.elementclass.BranchPoint;\r
-import org.simantics.g2d.elementclass.BranchPoint.Direction;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class AddBranchpoint extends ModificationAdapter {\r
-\r
-    IDiagram diagram;\r
-    IElement connection;\r
-    IElement element;\r
-\r
-    public AddBranchpoint(IDiagram diagram, IElement connection, IElement element) {\r
-        super(ADD_BRANCH_PRIORITY);\r
-        this.diagram = diagram;\r
-        this.connection = connection;\r
-        this.element = element;\r
-    }\r
-\r
-    @Override\r
-    public void perform(WriteGraph g) throws DatabaseException {\r
-        ConnectionUtil cu = new ConnectionUtil(g);\r
-\r
-        DiagramMutator mutator = diagram.getHint(DiagramHints.KEY_MUTATOR);\r
-\r
-        Resource connectionResource = mutator.backendObject(connection);\r
-\r
-        AffineTransform tr = ElementUtils.getTransform(element);\r
-        Direction dir = element.getElementClass().getSingleItem(BranchPoint.class).getDirectionPreference(element, null);\r
-        Resource bp = cu.newBranchPoint(connectionResource, tr, dir);\r
-\r
-        element.setHint(ElementHints.KEY_OBJECT, bp);\r
-        mutator.register(element, bp);\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.diagram.synchronization.graph;
+
+import java.awt.geom.AffineTransform;
+
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.diagram.content.ConnectionUtil;
+import org.simantics.diagram.synchronization.ModificationAdapter;
+import org.simantics.g2d.diagram.DiagramHints;
+import org.simantics.g2d.diagram.DiagramMutator;
+import org.simantics.g2d.diagram.IDiagram;
+import org.simantics.g2d.element.ElementHints;
+import org.simantics.g2d.element.ElementUtils;
+import org.simantics.g2d.element.IElement;
+import org.simantics.g2d.elementclass.BranchPoint;
+import org.simantics.g2d.elementclass.BranchPoint.Direction;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class AddBranchpoint extends ModificationAdapter {
+
+    IDiagram diagram;
+    IElement connection;
+    IElement element;
+
+    public AddBranchpoint(IDiagram diagram, IElement connection, IElement element) {
+        super(ADD_BRANCH_PRIORITY);
+        this.diagram = diagram;
+        this.connection = connection;
+        this.element = element;
+    }
+
+    @Override
+    public void perform(WriteGraph g) throws DatabaseException {
+        ConnectionUtil cu = new ConnectionUtil(g);
+
+        DiagramMutator mutator = diagram.getHint(DiagramHints.KEY_MUTATOR);
+
+        Resource connectionResource = mutator.backendObject(connection);
+
+        AffineTransform tr = ElementUtils.getTransform(element);
+        Direction dir = element.getElementClass().getSingleItem(BranchPoint.class).getDirectionPreference(element, null);
+        Resource bp = cu.newBranchPoint(connectionResource, tr, dir);
+
+        element.setHint(ElementHints.KEY_OBJECT, bp);
+        mutator.register(element, bp);
+    }
+
+}