From 1bf8ef86326815b7b4dee3f606437920805c76d5 Mon Sep 17 00:00:00 2001 From: Antti Villberg Date: Mon, 24 Aug 2020 19:21:18 +0300 Subject: [PATCH] Customisation for connection creation Change-Id: I4d333b9e452e985e10d9e0a59bc3ac638b8c95a7 --- .../simantics/diagram/adapter/ConnectionEvents.java | 11 +++++++++++ .../org/simantics/diagram/content/ConnectionUtil.java | 4 ++++ 2 files changed, 15 insertions(+) create mode 100644 bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/ConnectionEvents.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 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; } -- 2.47.1