]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Customisation for connection creation
authorAntti Villberg <antti.villberg@semantum.fi>
Mon, 24 Aug 2020 16:21:18 +0000 (19:21 +0300)
committerAntti Villberg <antti.villberg@semantum.fi>
Mon, 24 Aug 2020 16:21:18 +0000 (19:21 +0300)
Change-Id: I4d333b9e452e985e10d9e0a59bc3ac638b8c95a7

bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/ConnectionEvents.java [new file with mode: 0644]
bundles/org.simantics.diagram/src/org/simantics/diagram/content/ConnectionUtil.java

diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/ConnectionEvents.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/ConnectionEvents.java
new file mode 100644 (file)
index 0000000..851653c
--- /dev/null
@@ -0,0 +1,11 @@
+package org.simantics.diagram.adapter;
+
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.exception.DatabaseException;
+
+public interface ConnectionEvents {
+
+    public void connectionCreated(WriteGraph graph, Resource connection) throws DatabaseException;
+
+}
index c96b8fb94174e8411f5f4404fd4dd62526719741..abcc05377dd7e1a1699ae07392ec780dbc723f3b 100644 (file)
@@ -38,6 +38,7 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.exception.ValidationException;
 import org.simantics.db.layer0.adapter.impl.EntityRemover;
 import org.simantics.db.layer0.util.RemoverUtil;
+import org.simantics.diagram.adapter.ConnectionEvents;
 import org.simantics.diagram.connection.ConnectionSegmentEnd;
 import org.simantics.diagram.stubs.DiagramResource;
 import org.simantics.diagram.synchronization.graph.BasicResources;
@@ -119,6 +120,9 @@ public final class ConnectionUtil {
         OrderedSetUtils.addFirst(g, composite, connection);
         g.claim(composite, br.L0.ConsistsOf, br.L0.PartOf, connection);
         GraphLayerUtil.addToVisibleLayers(g, connection, composite);
+        ConnectionEvents events = g.getPossibleAdapter(composite, ConnectionEvents.class);
+        if(events != null)
+            events.connectionCreated(g, connection);
         return connection;
     }