Skip to content
Snippets Groups Projects
Commit 22a4ba79 authored by Lukas Ladenberger's avatar Lukas Ladenberger
Browse files

some minor fixes

parent 26b583d5
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
package de.bmotionstudio.gef.editor.model; package de.bmotionstudio.gef.editor.model;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.draw2d.geometry.Rectangle;
import de.bmotionstudio.gef.editor.AttributeConstants; import de.bmotionstudio.gef.editor.AttributeConstants;
...@@ -59,28 +62,37 @@ public class Switch extends BControl { ...@@ -59,28 +62,37 @@ public class Switch extends BControl {
track2.setAttributeValue(AttributeConstants.ATTRIBUTE_LABEL, ""); track2.setAttributeValue(AttributeConstants.ATTRIBUTE_LABEL, "");
track1.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "LEFT"); track1.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "LEFT");
track1.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM).setEditable( AbstractAttribute a1 = track1
false); .getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM);
a1.setEditable(false);
a1.setShow(false);
track2.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "RIGHT"); track2.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "RIGHT");
track2.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM).setEditable( AbstractAttribute a2 = track2.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM);
false); a2.setEditable(false);
a2.setShow(false);
tracknode1.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "1"); tracknode1.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "1");
tracknode1.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM) tracknode1.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM)
.setEditable(false); .setEditable(false);
tracknode1.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM).setShow(
false);
tracknode1.getAttribute(AttributeConstants.ATTRIBUTE_COORDINATES) tracknode1.getAttribute(AttributeConstants.ATTRIBUTE_COORDINATES)
.setShow(false); .setShow(false);
tracknode2.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "2"); tracknode2.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "2");
tracknode2.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM) tracknode2.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM)
.setEditable(false); .setEditable(false);
tracknode2.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM).setShow(
false);
tracknode2.getAttribute(AttributeConstants.ATTRIBUTE_COORDINATES) tracknode2.getAttribute(AttributeConstants.ATTRIBUTE_COORDINATES)
.setShow(false); .setShow(false);
tracknode3.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "3"); tracknode3.setAttributeValue(AttributeConstants.ATTRIBUTE_CUSTOM, "3");
tracknode3.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM) tracknode3.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM)
.setEditable(false); .setEditable(false);
tracknode3.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM).setShow(
false);
tracknode3.getAttribute(AttributeConstants.ATTRIBUTE_COORDINATES) tracknode3.getAttribute(AttributeConstants.ATTRIBUTE_COORDINATES)
.setShow(false); .setShow(false);
...@@ -99,45 +111,38 @@ public class Switch extends BControl { ...@@ -99,45 +111,38 @@ public class Switch extends BControl {
initAttribute(AttributeConstants.ATTRIBUTE_SWITCH_POSITION, initAttribute(AttributeConstants.ATTRIBUTE_SWITCH_POSITION,
AttributeSwitchPosition.UNKNOWN); AttributeSwitchPosition.UNKNOWN);
for (BControl c : getChildrenArray()) {
c.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM).setShow(false);
c.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM).setEditable(
false);
c.getAttribute(AttributeConstants.ATTRIBUTE_COORDINATES).setShow(
false);
c.getAttribute(AttributeConstants.ATTRIBUTE_COORDINATES)
.setEditable(false);
}
} }
// We have to set the two tracks of the switch, since their are set to // We have to set the two tracks of the switch, since their are set to
// transient // transient
protected Object readResolve() { protected Object readResolve() {
super.readResolve(); super.readResolve();
for (BControl control : getChildrenArray()) { for (BControl control : getChildrenArray()) {
for (Track n : ((TrackNode) control).getSourceTracks()) {
List<Track> tracks = new ArrayList<Track>();
tracks.addAll(((TrackNode) control).getSourceTracks());
tracks.addAll(((TrackNode) control).getTargetTracks());
for (Track n : tracks) {
AbstractAttribute a2 = n AbstractAttribute a2 = n
.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM); .getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM);
a2.setEditable(false);
if (a2.getValue().equals("LEFT")) { 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); a2.setEditable(false);
if (a2.getValue().equals("LEFT")) { a2.setShow(false);
track1 = n; track1 = n;
} else if (a2.getValue().equals("RIGHT")) { } else if (a2.getValue().equals("RIGHT")) {
track2 = n; track2 = n;
a2.setEditable(false);
a2.setShow(false);
} }
} }
} }
return this; return this;
} }
@Override @Override
......
...@@ -19,6 +19,7 @@ import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; ...@@ -19,6 +19,7 @@ import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy;
import de.bmotionstudio.gef.editor.figure.SwitchFigure; import de.bmotionstudio.gef.editor.figure.SwitchFigure;
import de.bmotionstudio.gef.editor.model.BControl; import de.bmotionstudio.gef.editor.model.BControl;
import de.bmotionstudio.gef.editor.model.Switch; import de.bmotionstudio.gef.editor.model.Switch;
import de.bmotionstudio.gef.editor.model.Track;
public class SwitchPart extends BMSAbstractEditPart { public class SwitchPart extends BMSAbstractEditPart {
...@@ -38,21 +39,28 @@ public class SwitchPart extends BMSAbstractEditPart { ...@@ -38,21 +39,28 @@ public class SwitchPart extends BMSAbstractEditPart {
Switch sw = (Switch) model; Switch sw = (Switch) model;
sw.getTrack1().setAttributeValue( Track track1 = sw.getTrack1();
AttributeConstants.ATTRIBUTE_VISIBLE, true); Track track2 = sw.getTrack2();
sw.getTrack2().setAttributeValue(
AttributeConstants.ATTRIBUTE_VISIBLE, true); if (track1 != null && track2 != null) {
track1.setAttributeValue(AttributeConstants.ATTRIBUTE_VISIBLE,
true);
track2.setAttributeValue(AttributeConstants.ATTRIBUTE_VISIBLE,
true);
if (value.equals(AttributeSwitchPosition.LEFT)) { if (value.equals(AttributeSwitchPosition.LEFT)) {
sw.getTrack1().setAttributeValue( track1.setAttributeValue(
AttributeConstants.ATTRIBUTE_VISIBLE, false); AttributeConstants.ATTRIBUTE_VISIBLE, false);
} else if (value.equals(AttributeSwitchPosition.RIGHT)) { } else if (value.equals(AttributeSwitchPosition.RIGHT)) {
sw.getTrack2().setAttributeValue( track2.setAttributeValue(
AttributeConstants.ATTRIBUTE_VISIBLE, false); AttributeConstants.ATTRIBUTE_VISIBLE, false);
} }
} }
}
if (aID.equals(AttributeConstants.ATTRIBUTE_SWITCH_DIRECTION)) if (aID.equals(AttributeConstants.ATTRIBUTE_SWITCH_DIRECTION))
refreshEditLayout(figure, model); refreshEditLayout(figure, model);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment