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

added visible/invisible support for connections

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