Skip to content
Snippets Groups Projects
Commit c28b8cb2 authored by Daniel Plagge's avatar Daniel Plagge
Browse files

Merge remote-tracking branch 'origin/develop' into feature/theory_plugin

parents 6913b9d8 c5d39e43
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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);
}
}
}
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment