diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Switch.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Switch.java index f0e2d376f2b19db4078dbe300b8934ade2c65fd6..80da6c3dce01c1ad3e0c1f70958600eb8eb2dccf 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Switch.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Switch.java @@ -9,6 +9,7 @@ package de.bmotionstudio.gef.editor.model; import org.eclipse.draw2d.geometry.Rectangle; import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; import de.bmotionstudio.gef.editor.attribute.AttributeSwitchDirection; import de.bmotionstudio.gef.editor.attribute.AttributeSwitchPosition; import de.bmotionstudio.gef.editor.command.CreateCommand; @@ -58,11 +59,30 @@ public class Switch extends BControl { track2.setAttributeValue(AttributeConstants.ATTRIBUTE_LABEL, ""); track1.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "LEFT"); + track1.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM).setEditable( + false); + track2.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "RIGHT"); + track2.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM).setEditable( + false); tracknode1.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "1"); + tracknode1.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM) + .setEditable(false); + tracknode1.getAttribute(AttributeConstants.ATTRIBUTE_COORDINATES) + .setShow(false); + tracknode2.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "2"); + tracknode2.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM) + .setEditable(false); + tracknode2.getAttribute(AttributeConstants.ATTRIBUTE_COORDINATES) + .setShow(false); + tracknode3.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "3"); + tracknode3.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM) + .setEditable(false); + tracknode3.getAttribute(AttributeConstants.ATTRIBUTE_COORDINATES) + .setShow(false); } @@ -91,6 +111,35 @@ public class Switch extends BControl { } + // We have to set the two tracks of the switch, since their are set to + // transient + protected Object readResolve() { + super.readResolve(); + for (BControl control : getChildrenArray()) { + for (Track n : ((TrackNode) control).getSourceTracks()) { + AbstractAttribute a2 = n + .getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM); + a2.setEditable(false); + if (a2.getValue().equals("LEFT")) { + track1 = n; + } else if (a2.getValue().equals("RIGHT")) { + track2 = n; + } + } + for (Track n : ((TrackNode) control).getTargetTracks()) { + AbstractAttribute a2 = n + .getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM); + a2.setEditable(false); + if (a2.getValue().equals("LEFT")) { + track1 = n; + } else if (a2.getValue().equals("RIGHT")) { + track2 = n; + } + } + } + return this; + } + @Override public String getType() { return TYPE; diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/TrackNode.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/TrackNode.java index 98cf3ed02a122ebd48c2f7b5a56db6d15593fb80..d72a116652e281360d20555f0012dcc4bf0e8f2c 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/TrackNode.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/TrackNode.java @@ -11,6 +11,7 @@ import java.util.List; import org.eclipse.draw2d.ColorConstants; +import de.bmotionstudio.gef.editor.Animation; import de.bmotionstudio.gef.editor.AttributeConstants; import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; import de.bmotionstudio.gef.editor.attribute.BAttributeLineStyle; @@ -117,4 +118,18 @@ public class TrackNode extends BControl { super.populateVisualization(visualization); } + @Override + public void checkObserver(Animation animation) { + super.checkObserver(animation); + // TODO: Currently connection observer are checked twice (source + + // target) => change this, so that observer are checked only on time per + // state!!! + for (Track t : getTargetTracks()) { + t.checkObserver(animation); + } + for (Track t : getSourceTracks()) { + t.checkObserver(animation); + } + } + } diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/SwitchPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/SwitchPart.java index be0242c8dd69808ccf2e2c838bee4f1f71293da4..aacb1b509d09b019af55357f0d93bc6ee0e49228 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/SwitchPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/SwitchPart.java @@ -89,7 +89,7 @@ public class SwitchPart extends BMSAbstractEditPart { switch (Integer.valueOf(trackNode.getAttributeValue( AttributeConstants.ATTRIBUTE_CUSTOM).toString())) { - case 1: // top left + case 1: // top left (1) if (dir == AttributeSwitchDirection.RIGHT_SOUTH) { pt.y = 0; pt.x = 5; @@ -104,7 +104,7 @@ public class SwitchPart extends BMSAbstractEditPart { pt.x = width - 25; } break; - case 2: // top right + case 2: // top right (2) if (dir == AttributeSwitchDirection.RIGHT_SOUTH) { pt.y = 0; pt.x = width - 25; @@ -119,7 +119,7 @@ public class SwitchPart extends BMSAbstractEditPart { pt.x = 5; } break; - case 3: // left right + case 3: // left right (3) if (dir == AttributeSwitchDirection.RIGHT_SOUTH) { pt.y = height - 20; pt.x = width - 25;