From: Antti Villberg Date: Mon, 24 Aug 2020 16:21:18 +0000 (+0300) Subject: Customisation for connection creation X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=1bf8ef86326815b7b4dee3f606437920805c76d5;p=simantics%2Fplatform.git Customisation for connection creation Change-Id: I4d333b9e452e985e10d9e0a59bc3ac638b8c95a7 --- 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 index 000000000..851653ca1 --- /dev/null +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/ConnectionEvents.java @@ -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; + +} diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/content/ConnectionUtil.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/content/ConnectionUtil.java index c96b8fb94..abcc05377 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/content/ConnectionUtil.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/content/ConnectionUtil.java @@ -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; }