From 230bd2059a621a7ca66ff9532f8629eb04f69108 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Fri, 20 Dec 2019 15:53:52 +0200 Subject: [PATCH] Support for symbol removes. Note. the code has not been tested, your results may vary. gitlab #7 Change-Id: If367c11099fdf3bcf793ef948a1637bd1d6e0d77 --- .../org/simantics/interop/diagram/Symbol.java | 70 ++++++++----------- 1 file changed, 29 insertions(+), 41 deletions(-) diff --git a/org.simantics.interop.diagram/src/org/simantics/interop/diagram/Symbol.java b/org.simantics.interop.diagram/src/org/simantics/interop/diagram/Symbol.java index c52bfa4..b2f7c30 100644 --- a/org.simantics.interop.diagram/src/org/simantics/interop/diagram/Symbol.java +++ b/org.simantics.interop.diagram/src/org/simantics/interop/diagram/Symbol.java @@ -726,6 +726,35 @@ public abstract class Symbol { return symbols.iterator().next(); } + public void remove(WriteGraph g) throws DatabaseException{ + Layer0 L0 = Layer0.getInstance(g); + StructuralResource2 STR = StructuralResource2.getInstance(g); + DiagramResource DIA = DiagramResource.getInstance(g); + OrderedSetUtils.remove(g, diagram.getDiagram(), element); + if (component != null) + g.deny(component, L0.PartOf); + Collection statements = g.getStatements(element, STR.IsConnectedTo); + for (Statement s : statements) { + if (g.isInstanceOf(s.getObject(),DIA.Connector)) { + Resource connectedConnector = g.getPossibleObject(s.getObject(), DIA.AreConnected); + if (connectedConnector != null) + g.deny(connectedConnector); + g.deny(s.getObject()); + } + } + if (component != null) { + statements = g.getStatements(component, STR.IsConnectedTo); + for (Statement s : statements) { + if (g.isInstanceOf(s.getObject(),STR.Connection)) { + g.deny(s.getObject()); + } + } + } + g.deny(element); + if (component != null) + g.deny(component); + } + public void dispose() { diagram = null; component = null; @@ -835,47 +864,6 @@ public abstract class Symbol { } } - private static class PointConnectionDataImpl implements PointConnectionData { - - private Symbol point; - - public PointConnectionDataImpl(Symbol point) { - this.point = point; - } - - @Override - public Symbol getPoint() { - return point; - } - } - - private static class SignalConnectionDataImpl implements SignalConnectionData, DiagramConnectionData{ - - private Resource signalComponent; - private Resource[] connectors; - - public SignalConnectionDataImpl(Resource signalComponent, Resource... connectors) { - this.signalComponent = signalComponent; - this.connectors = connectors; - } - - @Override - public Resource getSignalComponent() { - return signalComponent; - } - - @Override - public Resource getConnection(int index) { - return connectors[index]; - } - - @Override - public int getConnectionCount() { - return connectors.length; - } - - } - private static class FlagConnectionDataImpl implements FlagConnectionData, DiagramConnectionData { private Symbol firstFlag; -- 2.47.1