diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BConnectionEditPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BConnectionEditPart.java index 0771f7ce906dbd9edb440f697db98257e46439e6..3f09133d67eda64a8a70af64ed9d537c35c79cd0 100644 --- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BConnectionEditPart.java +++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/BConnectionEditPart.java @@ -13,6 +13,7 @@ import java.util.List; import org.eclipse.draw2d.ChopboxAnchor; import org.eclipse.draw2d.Connection; import org.eclipse.draw2d.ConnectionAnchor; +import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.Label; import org.eclipse.draw2d.MidpointLocator; @@ -21,6 +22,7 @@ import org.eclipse.draw2d.PolylineConnection; import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.XYAnchor; import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.gef.AccessibleAnchorProvider; import org.eclipse.gef.ConnectionEditPart; import org.eclipse.gef.DragTracker; @@ -42,8 +44,11 @@ import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; import de.bmotionstudio.gef.editor.AttributeConstants; +import de.bmotionstudio.gef.editor.BMotionStudioImage; +import de.bmotionstudio.gef.editor.EditorImageRegistry; import de.bmotionstudio.gef.editor.attribute.BAttributeConnectionSourceDecoration; import de.bmotionstudio.gef.editor.command.ConnectionDeleteCommand; +import de.bmotionstudio.gef.editor.figure.AbstractBMotionFigure; import de.bmotionstudio.gef.editor.model.BConnection; import de.bmotionstudio.gef.editor.model.BControl; @@ -89,7 +94,34 @@ public class BConnectionEditPart extends BMSAbstractEditPart implements @Override protected IFigure createEditFigure() { - PolylineConnection connection = new PolylineConnection(); + PolylineConnection connection = new PolylineConnection() { + + private boolean visible; + + @Override + public void paint(Graphics g) { + if (!visible && !isRunning()) { + Rectangle clientArea = getClientArea(); + g.drawImage( + BMotionStudioImage + .getImage(EditorImageRegistry.IMG_ICON_CONTROL_HIDDEN), + clientArea.x, clientArea.y); + g.setAlpha(AbstractBMotionFigure.HIDDEN_ALPHA_VALUE); + } + super.paint(g); + } + + @Override + public void setVisible(boolean visible) { + if (!isRunning()) { + this.visible = visible; + repaint(); + } else { + super.setVisible(visible); + } + } + + }; conLabel = new Label(); MidpointLocator locator = new MidpointLocator(connection, 0); locator.setRelativePosition(PositionConstants.NORTH); 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 cb28c2111e4f9f9e8bf8b630e481616ff8c70e18..61ee4e3d19be85984ee7355d274f21b36ba2d8e6 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 @@ -34,11 +34,10 @@ public class SwitchPart extends BMSAbstractEditPart { Object value = evt.getNewValue(); String aID = evt.getPropertyName(); - + Switch sw = (Switch) model; + if (aID.equals(AttributeConstants.ATTRIBUTE_SWITCH_POSITION)) { - Switch sw = (Switch) model; - Track track1 = sw.getTrack1(); Track track2 = sw.getTrack2(); @@ -64,9 +63,14 @@ public class SwitchPart extends BMSAbstractEditPart { if (aID.equals(AttributeConstants.ATTRIBUTE_SWITCH_DIRECTION)) refreshEditLayout(figure, model); - if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) - ((SwitchFigure) figure) - .setVisible(Boolean.valueOf(value.toString())); + if (aID.equals(AttributeConstants.ATTRIBUTE_VISIBLE)) { + Boolean visible = Boolean.valueOf(value.toString()); + ((SwitchFigure) figure).setVisible(visible); + sw.getTrack1().setAttributeValue( + AttributeConstants.ATTRIBUTE_VISIBLE, visible); + sw.getTrack2().setAttributeValue( + AttributeConstants.ATTRIBUTE_VISIBLE, visible); + } }