From: Marko Luukkainen Date: Fri, 29 Nov 2019 11:44:12 +0000 (+0200) Subject: Processing DB changes could leave control points unsynchronized X-Git-Tag: v1.43.0~108 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=ba83a8b8c95b94a035d20e458880beec68b9c450;p=simantics%2F3d.git Processing DB changes could leave control points unsynchronized When processing DB changes, component connections could be created before control points (especially Nozzle). This could cause a situation, where components were connected, but control points were not. gitlab #35 Change-Id: Ida35c3222dbc706c7cb0e481af41feeca0949809 (cherry picked from commit 944164586441e68cd62073de3995a2455be9680a) --- diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/EndComponent.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/EndComponent.java index 5df76c0f..fbcc7764 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/EndComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/EndComponent.java @@ -26,6 +26,9 @@ public class EndComponent extends PipelineComponent { public void setType(String type) throws Exception { this.type = type; controlPoint = ControlPointFactory.create(this); + syncNext(); + syncPrevious(); + syncBranch0(); } diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java index a94303ef..ca4ba836 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java @@ -36,6 +36,9 @@ public class InlineComponent extends PipelineComponent { public void setType(String type) throws Exception{ this.type = type; controlPoint = ControlPointFactory.create(this); + syncNext(); + syncPrevious(); + syncBranch0(); } diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Nozzle.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Nozzle.java index 55773f0f..cbdecc1c 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Nozzle.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Nozzle.java @@ -72,12 +72,12 @@ public class Nozzle extends PipelineComponent { private void _createCP() throws Exception{ if (controlPoint != null) return; - if (getPipeRun() != null) { - controlPoint = ControlPointFactory.create(this); - // TODO : these should not be needed. - controlPoint.setDeletable(false); - controlPoint.setFixed(true); - } + controlPoint = ControlPointFactory.create(this); + // TODO : these should not be needed. + controlPoint.setDeletable(false); + controlPoint.setFixed(true); + syncNext(); + syncPrevious(); } @RelatedSetObj(Plant3D.URIs.HasPipeRun) diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java index ad1c2b7a..7726b203 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java @@ -145,8 +145,10 @@ public abstract class PipelineComponent extends GeometryNode { @RelatedSetObj(Plant3D.URIs.HasNext) public void setNext(PipelineComponent comp) { - if (next == comp) + if (next == comp) { + syncNext(); return; + } if (this.next != null) this.next._removeRef(this); _setNext(comp); @@ -170,8 +172,10 @@ public abstract class PipelineComponent extends GeometryNode { @RelatedSetObj(Plant3D.URIs.HasPrevious) public void setPrevious(PipelineComponent comp) { - if (previous == comp) + if (previous == comp) { + syncPrevious(); return; + } if (this.previous != null) this.previous._removeRef(this); _setPrevious(comp); @@ -196,8 +200,10 @@ public abstract class PipelineComponent extends GeometryNode { @RelatedSetObj(Plant3D.URIs.HasBranch0) public void setBranch0(PipelineComponent comp) { - if (branch0 == comp) + if (branch0 == comp) { + syncBranch0(); return; + } if (this.branch0 != null) this.branch0._removeRef(this); this.branch0 = comp; @@ -305,7 +311,7 @@ public abstract class PipelineComponent extends GeometryNode { } boolean syncnext = false; - private void syncNext() { + protected void syncNext() { if (syncnext) return; syncnext = _syncNext(); @@ -344,7 +350,7 @@ public abstract class PipelineComponent extends GeometryNode { } boolean syncprev = false; - private void syncPrevious() { + protected void syncPrevious() { if (syncprev) return; syncprev = _syncPrevious(); @@ -381,7 +387,7 @@ public abstract class PipelineComponent extends GeometryNode { } boolean syncbr0 = false; - private void syncBranch0() { + protected void syncBranch0() { if (syncbr0) return; syncbr0 = _syncBranch0(); diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/TurnComponent.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/TurnComponent.java index 1bf67441..5c3a1e98 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/TurnComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/TurnComponent.java @@ -42,6 +42,9 @@ public class TurnComponent extends PipelineComponent { public void setType(String type) throws Exception{ this.type = type; controlPoint = ControlPointFactory.create(this); + syncNext(); + syncPrevious(); + syncBranch0(); } @Override