]> gerrit.simantics Code Review - simantics/interop.git/commitdiff
Support for symbol removes. 53/3753/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Fri, 20 Dec 2019 13:53:52 +0000 (15:53 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Fri, 20 Dec 2019 13:53:52 +0000 (15:53 +0200)
Note. the code has not been tested, your results may vary.

gitlab #7

Change-Id: If367c11099fdf3bcf793ef948a1637bd1d6e0d77

org.simantics.interop.diagram/src/org/simantics/interop/diagram/Symbol.java

index c52bfa451df4b5dd869718c2538b213e4372f0ab..b2f7c30d05edbcdbaef33425f3b492a08ee0dbe8 100644 (file)
@@ -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<Statement> 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;