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

fixed some bugs in railway plugin

parent 800c9ee2
No related branches found
No related tags found
No related merge requests found
Showing
with 30 additions and 618 deletions
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package de.bmotionstudio.gef.editor.command;
import java.util.Iterator;
import org.eclipse.gef.commands.Command;
import de.bmotionstudio.gef.editor.model.Track;
import de.bmotionstudio.gef.editor.model.TrackNode;
public class TrackCreateCommand extends Command {
/** The track instance. */
private Track track;
/** Start endpoint for the track. */
private final TrackNode source;
/** Target endpoint for the track. */
private TrackNode target;
/**
* Instantiate a command that can create a {@link Track} between two
* {@link TrackNode}s.
*
* @param source
* the source {@link TrackNode}
* @param lineStyle
* the desired line style. See Connection#setLineStyle(int) for
* details
* @throws IllegalArgumentException
* if source is null
* @see Connection#setLineStyle(int)
*/
public TrackCreateCommand(TrackNode source) {
if (source == null) {
throw new IllegalArgumentException();
}
setLabel("track creation");
this.source = source;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.commands.Command#canExecute()
*/
public boolean canExecute() {
// disallow source -> source connections
if (source.equals(target)) {
return false;
}
// return false, if the source -> target connection exists already
for (Iterator<Track> iter = source.getSourceTracks().iterator(); iter
.hasNext();) {
Track conn = (Track) iter.next();
if (conn.getTarget().equals(target)) {
return false;
}
}
return true;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.commands.Command#execute()
*/
public void execute() {
// create a new connection between source and target
track.setSource(source);
track.setTarget(target);
track.reconnect();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.commands.Command#redo()
*/
public void redo() {
track.reconnect();
}
/**
* Set the target endpoint for the connection.
*
* @param target
* that target endpoint (a non-null Shape instance)
* @throws IllegalArgumentException
* if target is null
*/
public void setTarget(TrackNode target) {
if (target == null) {
throw new IllegalArgumentException();
}
this.target = target;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.commands.Command#undo()
*/
public void undo() {
track.disconnect();
}
public void setTrack(Track track) {
this.track = track;
}
public Track getTrack() {
return this.track;
}
public TrackNode getSource() {
return this.source;
}
public TrackNode getTarget() {
return this.target;
}
}
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package de.bmotionstudio.gef.editor.command;
import org.eclipse.gef.commands.Command;
import de.bmotionstudio.gef.editor.model.Track;
public class TrackDeleteCommand extends Command {
/** Connection instance to disconnect. */
private final Track track;
public TrackDeleteCommand(Track track) {
if (track == null) {
throw new IllegalArgumentException();
}
setLabel("connection deletion");
this.track = track;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.commands.Command#execute()
*/
public void execute() {
track.disconnect();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.commands.Command#undo()
*/
public void undo() {
track.reconnect();
}
}
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package de.bmotionstudio.gef.editor.command;
import org.eclipse.draw2d.geometry.Rectangle;
import de.bmotionstudio.gef.editor.model.Track;
import de.bmotionstudio.gef.editor.model.TrackNode;
public class TrackNodeCreateCommand extends TrackCreateCommand {
/**
* Instantiate a command that can create a {@link Track} between two
* {@link TrackNode}s.
*
* @param source
* the source {@link TrackNode}
* @param lineStyle
* the desired line style. See Connection#setLineStyle(int) for
* details
* @throws IllegalArgumentException
* if source is null
* @see Connection#setLineStyle(int)
*/
public TrackNodeCreateCommand(TrackNode source) {
super(source);
}
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.commands.Command#execute()
*/
public void execute() {
System.out.println("EXECUTE: ");
CreateCommand createCmd1 = new CreateCommand(getSource(), getSource()
.getVisualization());
createCmd1.setLayout(new Rectangle(getSource().getLocation().x - 10,
getSource()
.getLocation().y - 10, 50, 20));
createCmd1.execute();
createCmd1 = new CreateCommand(getTarget(), getTarget().getVisualization());
createCmd1.setLayout(new Rectangle(getTarget().getLocation().x - 10, getTarget()
.getLocation().y - 10, 50, 20));
createCmd1.execute();
// create a new connection between source and target
getTrack().setSource(getSource());
getTrack().setTarget(getTarget());
getTrack().reconnect();
}
}
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package de.bmotionstudio.gef.editor.command;
import java.util.Iterator;
import org.eclipse.gef.commands.Command;
import de.bmotionstudio.gef.editor.model.BConnection;
import de.bmotionstudio.gef.editor.model.Track;
import de.bmotionstudio.gef.editor.model.TrackNode;
public class TrackReconnectCommand extends Command {
/** The connection instance to reconnect. */
private Track connection;
/** The new source endpoint. */
private TrackNode newSource;
/** The new target endpoint. */
private TrackNode newTarget;
/** The original source endpoint. */
private TrackNode oldSource;
/** The original target endpoint. */
private TrackNode oldTarget;
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.commands.Command#canExecute()
*/
public boolean canExecute() {
if (newSource != null) {
return checkSourceReconnection();
} else if (newTarget != null) {
return checkTargetReconnection();
}
return false;
}
/**
* Return true, if reconnecting the connection-instance to newSource is
* allowed.
*/
private boolean checkSourceReconnection() {
// connection endpoints must be different Shapes
if (newSource.equals(oldTarget)) {
return false;
}
// return false, if the connection exists already
for (Iterator<BConnection> iter = newSource.getSourceConnections()
.iterator(); iter.hasNext();) {
BConnection conn = (BConnection) iter.next();
// return false if a newSource -> oldTarget connection exists
// already
// and it is a different instance than the connection-field
if (conn.getTarget().equals(oldTarget) && !conn.equals(connection)) {
return false;
}
}
return true;
}
/**
* Return true, if reconnecting the connection-instance to newTarget is
* allowed.
*/
private boolean checkTargetReconnection() {
// connection endpoints must be different Shapes
if (newTarget.equals(oldSource)) {
return false;
}
// return false, if the connection exists already
for (Iterator<BConnection> iter = newTarget.getTargetConnections()
.iterator(); iter.hasNext();) {
BConnection conn = (BConnection) iter.next();
// return false if a oldSource -> newTarget connection exists
// already
// and it is a differenct instance that the connection-field
if (conn.getSource().equals(oldSource) && !conn.equals(connection)) {
return false;
}
}
return true;
}
/**
* Reconnect the connection to newSource (if setNewSource(...) was invoked
* before) or newTarget (if setNewTarget(...) was invoked before).
*/
public void execute() {
if (newSource != null) {
connection.reconnect(newSource, oldTarget);
} else if (newTarget != null) {
connection.reconnect(oldSource, newTarget);
} else {
throw new IllegalStateException("Should not happen");
}
}
/**
* Set a new source endpoint for this connection. When execute() is invoked,
* the source endpoint of the connection will be attached to the supplied
* Shape instance.
* <p>
* Note: Calling this method, deactivates reconnection of the <i>target</i>
* endpoint. A single instance of this command can only reconnect either the
* source or the target endpoint.
* </p>
*
* @param connectionSource
* a non-null Shape instance, to be used as a new source endpoint
* @throws IllegalArgumentException
* if connectionSource is null
*/
public void setNewSource(TrackNode connectionSource) {
if (connectionSource == null) {
throw new IllegalArgumentException();
}
setLabel("move connection startpoint");
newSource = connectionSource;
newTarget = null;
}
public TrackNode getNewSource() {
return this.newSource;
}
/**
* Set a new target endpoint for this connection When execute() is invoked,
* the target endpoint of the connection will be attached to the supplied
* Shape instance.
* <p>
* Note: Calling this method, deactivates reconnection of the <i>source</i>
* endpoint. A single instance of this command can only reconnect either the
* source or the target endpoint.
* </p>
*
* @param connectionTarget
* a non-null Shape instance, to be used as a new target endpoint
* @throws IllegalArgumentException
* if connectionTarget is null
*/
public void setNewTarget(TrackNode connectionTarget) {
if (connectionTarget == null) {
throw new IllegalArgumentException();
}
setLabel("move connection endpoint");
newSource = null;
newTarget = connectionTarget;
}
public TrackNode getNewTarget() {
return this.newTarget;
}
/**
* Reconnect the connection to its original source and target endpoints.
*/
public void undo() {
connection.reconnect(oldSource, oldTarget);
}
public void setConnection(Track conn) {
this.connection = conn;
this.oldSource = conn.getSource();
this.oldTarget = conn.getTarget();
}
public Track getConnection() {
return this.connection;
}
}
...@@ -12,8 +12,8 @@ import org.eclipse.gef.requests.CreateConnectionRequest; ...@@ -12,8 +12,8 @@ import org.eclipse.gef.requests.CreateConnectionRequest;
import org.eclipse.gef.requests.DropRequest; import org.eclipse.gef.requests.DropRequest;
import org.eclipse.gef.requests.ReconnectRequest; import org.eclipse.gef.requests.ReconnectRequest;
import de.bmotionstudio.gef.editor.command.TrackCreateCommand; import de.bmotionstudio.gef.editor.command.ConnectionCreateCommand;
import de.bmotionstudio.gef.editor.command.TrackReconnectCommand; import de.bmotionstudio.gef.editor.command.ConnectionReconnectCommand;
import de.bmotionstudio.gef.editor.model.BConnection; import de.bmotionstudio.gef.editor.model.BConnection;
import de.bmotionstudio.gef.editor.model.Track; import de.bmotionstudio.gef.editor.model.Track;
import de.bmotionstudio.gef.editor.model.TrackNode; import de.bmotionstudio.gef.editor.model.TrackNode;
...@@ -34,9 +34,9 @@ public class TrackEditPolicy extends BMSConnectionEditPolicy { ...@@ -34,9 +34,9 @@ public class TrackEditPolicy extends BMSConnectionEditPolicy {
Track track = (Track) newObject; Track track = (Track) newObject;
TrackNode trackNode = (TrackNode) model; TrackNode trackNode = (TrackNode) model;
cmd = new TrackCreateCommand(trackNode); cmd = new ConnectionCreateCommand(trackNode);
track.setVisualization(trackNode.getVisualization()); track.setVisualization(trackNode.getVisualization());
((TrackCreateCommand) cmd).setTrack(track); ((ConnectionCreateCommand) cmd).setConnection(track);
request.setStartCommand(cmd); request.setStartCommand(cmd);
} }
...@@ -59,7 +59,7 @@ public class TrackEditPolicy extends BMSConnectionEditPolicy { ...@@ -59,7 +59,7 @@ public class TrackEditPolicy extends BMSConnectionEditPolicy {
if (newObject instanceof Track) { if (newObject instanceof Track) {
cmd = request.getStartCommand(); cmd = request.getStartCommand();
((TrackCreateCommand) cmd).setTarget((TrackNode) getHost() ((ConnectionCreateCommand) cmd).setTarget((TrackNode) getHost()
.getModel()); .getModel());
} else if (newObject instanceof BConnection) { } else if (newObject instanceof BConnection) {
...@@ -80,9 +80,9 @@ public class TrackEditPolicy extends BMSConnectionEditPolicy { ...@@ -80,9 +80,9 @@ public class TrackEditPolicy extends BMSConnectionEditPolicy {
Track track = (Track) newObject; Track track = (Track) newObject;
TrackNode newSource = (TrackNode) getHost().getModel(); TrackNode newSource = (TrackNode) getHost().getModel();
cmd = new TrackReconnectCommand(); cmd = new ConnectionReconnectCommand();
((TrackReconnectCommand) cmd).setNewSource(newSource); ((ConnectionReconnectCommand) cmd).setNewSource(newSource);
((TrackReconnectCommand) cmd).setConnection(track); ((ConnectionReconnectCommand) cmd).setConnection(track);
} else if (newObject instanceof BConnection) { } else if (newObject instanceof BConnection) {
cmd = super.getReconnectSourceCommand(request); cmd = super.getReconnectSourceCommand(request);
...@@ -102,9 +102,9 @@ public class TrackEditPolicy extends BMSConnectionEditPolicy { ...@@ -102,9 +102,9 @@ public class TrackEditPolicy extends BMSConnectionEditPolicy {
Track track = (Track) newObject; Track track = (Track) newObject;
TrackNode newTarget = (TrackNode) getHost().getModel(); TrackNode newTarget = (TrackNode) getHost().getModel();
cmd = new TrackReconnectCommand(); cmd = new ConnectionReconnectCommand();
((TrackReconnectCommand) cmd).setNewTarget(newTarget); ((ConnectionReconnectCommand) cmd).setNewTarget(newTarget);
((TrackReconnectCommand) cmd).setConnection(track); ((ConnectionReconnectCommand) cmd).setConnection(track);
} else if (newObject instanceof BConnection) { } else if (newObject instanceof BConnection) {
cmd = super.getReconnectTargetCommand(request); cmd = super.getReconnectTargetCommand(request);
......
...@@ -18,8 +18,8 @@ import de.bmotionstudio.gef.editor.attribute.AttributeSwitchPosition; ...@@ -18,8 +18,8 @@ import de.bmotionstudio.gef.editor.attribute.AttributeSwitchPosition;
import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; import de.bmotionstudio.gef.editor.attribute.BAttributeHeight;
import de.bmotionstudio.gef.editor.attribute.BAttributeSize; import de.bmotionstudio.gef.editor.attribute.BAttributeSize;
import de.bmotionstudio.gef.editor.attribute.BAttributeWidth; import de.bmotionstudio.gef.editor.attribute.BAttributeWidth;
import de.bmotionstudio.gef.editor.command.ConnectionCreateCommand;
import de.bmotionstudio.gef.editor.command.CreateCommand; import de.bmotionstudio.gef.editor.command.CreateCommand;
import de.bmotionstudio.gef.editor.command.TrackCreateCommand;
public class Switch extends BControl { public class Switch extends BControl {
...@@ -49,16 +49,17 @@ public class Switch extends BControl { ...@@ -49,16 +49,17 @@ public class Switch extends BControl {
cmd.setLayout(new Rectangle(70, 70, 50, 20)); cmd.setLayout(new Rectangle(70, 70, 50, 20));
cmd.execute(); cmd.execute();
TrackCreateCommand trackCreateCmd = new TrackCreateCommand(tracknode1); ConnectionCreateCommand trackCreateCmd = new ConnectionCreateCommand(
tracknode1);
trackCreateCmd.setTarget(tracknode2); trackCreateCmd.setTarget(tracknode2);
track1 = new Track(getVisualization()); track1 = new Track(getVisualization());
trackCreateCmd.setTrack(track1); trackCreateCmd.setConnection(track1);
trackCreateCmd.execute(); trackCreateCmd.execute();
trackCreateCmd = new TrackCreateCommand(tracknode1); trackCreateCmd = new ConnectionCreateCommand(tracknode1);
trackCreateCmd.setTarget(tracknode3); trackCreateCmd.setTarget(tracknode3);
track2 = new Track(getVisualization()); track2 = new Track(getVisualization());
trackCreateCmd.setTrack(track2); trackCreateCmd.setConnection(track2);
trackCreateCmd.execute(); trackCreateCmd.execute();
track1.setAttributeValue(AttributeConstants.ATTRIBUTE_LABEL, ""); track1.setAttributeValue(AttributeConstants.ATTRIBUTE_LABEL, "");
...@@ -128,9 +129,14 @@ public class Switch extends BControl { ...@@ -128,9 +129,14 @@ public class Switch extends BControl {
for (BControl control : getChildrenArray()) { for (BControl control : getChildrenArray()) {
List<Track> tracks = new ArrayList<Track>(); List<Track> tracks = new ArrayList<Track>();
tracks.addAll(((TrackNode) control).getSourceTracks()); for (BConnection c : ((TrackNode) control).getSourceConnections()) {
tracks.addAll(((TrackNode) control).getTargetTracks()); if (c instanceof Track)
tracks.add((Track) c);
}
for (BConnection c : ((TrackNode) control).getTargetConnections()) {
if (c instanceof Track)
tracks.add((Track) c);
}
for (Track n : tracks) { for (Track n : tracks) {
AbstractAttribute a2 = n AbstractAttribute a2 = n
.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM); .getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM);
......
...@@ -8,6 +8,7 @@ package de.bmotionstudio.gef.editor.model; ...@@ -8,6 +8,7 @@ package de.bmotionstudio.gef.editor.model;
import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.RGB;
import de.bmotionstudio.gef.editor.attribute.AbstractAttribute;
import de.bmotionstudio.gef.editor.attribute.BAttributeConnection; import de.bmotionstudio.gef.editor.attribute.BAttributeConnection;
import de.bmotionstudio.gef.editor.attribute.BAttributeConnectionSourceDecoration; import de.bmotionstudio.gef.editor.attribute.BAttributeConnectionSourceDecoration;
import de.bmotionstudio.gef.editor.attribute.BAttributeConnectionTargetDecoration; import de.bmotionstudio.gef.editor.attribute.BAttributeConnectionTargetDecoration;
...@@ -20,17 +21,10 @@ import de.bmotionstudio.gef.editor.attribute.BAttributeLineWidth; ...@@ -20,17 +21,10 @@ import de.bmotionstudio.gef.editor.attribute.BAttributeLineWidth;
* @author Lukas Ladenberger * @author Lukas Ladenberger
* *
*/ */
public class Track extends BControl { public class Track extends BConnection {
public static transient String TYPE = "de.bmotionstudio.gef.editor.track"; public static transient String TYPE = "de.bmotionstudio.gef.editor.track";
/** True, if the connection is attached to its endpoints. */
private boolean isConnected;
/** Track's source endpoint. */
private TrackNode source;
/** Track's target endpoint. */
private TrackNode target;
public Track(Visualization visualization) { public Track(Visualization visualization) {
super(visualization); super(visualization);
} }
...@@ -44,6 +38,7 @@ public class Track extends BControl { ...@@ -44,6 +38,7 @@ public class Track extends BControl {
protected void initAttributes() { protected void initAttributes() {
BAttributeConnection aConnection = new BAttributeConnection(null); BAttributeConnection aConnection = new BAttributeConnection(null);
aConnection.setGroup(AbstractAttribute.ROOT);
initAttribute(aConnection); initAttribute(aConnection);
BAttributeLineWidth aLineWidth = new BAttributeLineWidth(1); BAttributeLineWidth aLineWidth = new BAttributeLineWidth(1);
...@@ -76,73 +71,4 @@ public class Track extends BControl { ...@@ -76,73 +71,4 @@ public class Track extends BControl {
} }
public boolean isConnected() {
return isConnected;
}
public void setConnected(boolean isConnected) {
this.isConnected = isConnected;
}
public TrackNode getSource() {
return source;
}
public void setSource(TrackNode source) {
this.source = source;
}
public TrackNode getTarget() {
return target;
}
public void setTarget(TrackNode target) {
this.target = target;
}
/**
* Reconnect this connection. The connection will reconnect with the shapes
* it was previously attached to.
*/
public void reconnect() {
if (!isConnected) {
source.addTrack(this);
target.addTrack(this);
isConnected = true;
}
}
/**
* Reconnect to a different source and/or target shape. The connection will
* disconnect from its current attachments and reconnect to the new source
* and target.
*
* @param newSource
* a new source endpoint for this connection (non null)
* @param newTarget
* a new target endpoint for this connection (non null)
* @throws IllegalArgumentException
* if any of the paramers are null or newSource == newTarget
*/
public void reconnect(TrackNode newSource, TrackNode newTarget) {
if (newSource == null || newTarget == null || newSource == newTarget) {
throw new IllegalArgumentException();
}
disconnect();
this.source = newSource;
this.target = newTarget;
reconnect();
}
/**
* Disconnect this connection from the shapes it is attached to.
*/
public void disconnect() {
if (isConnected) {
source.removeTrack(this);
target.removeTrack(this);
isConnected = false;
}
}
} }
...@@ -6,12 +6,8 @@ ...@@ -6,12 +6,8 @@
package de.bmotionstudio.gef.editor.model; package de.bmotionstudio.gef.editor.model;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.draw2d.ColorConstants; import org.eclipse.draw2d.ColorConstants;
import de.bmotionstudio.gef.editor.Animation;
import de.bmotionstudio.gef.editor.attribute.AbstractAttribute; import de.bmotionstudio.gef.editor.attribute.AbstractAttribute;
import de.bmotionstudio.gef.editor.attribute.BAttributeForegroundColor; import de.bmotionstudio.gef.editor.attribute.BAttributeForegroundColor;
import de.bmotionstudio.gef.editor.attribute.BAttributeHeight; import de.bmotionstudio.gef.editor.attribute.BAttributeHeight;
...@@ -28,14 +24,8 @@ public class TrackNode extends BControl { ...@@ -28,14 +24,8 @@ public class TrackNode extends BControl {
public static transient String TYPE = "de.bmotionstudio.gef.editor.tracknode"; public static transient String TYPE = "de.bmotionstudio.gef.editor.tracknode";
private List<Track> sourceTracks;
private List<Track> targetTracks;
public TrackNode(Visualization visualization) { public TrackNode(Visualization visualization) {
super(visualization); super(visualization);
this.sourceTracks = new ArrayList<Track>();
this.targetTracks = new ArrayList<Track>();
} }
@Override @Override
...@@ -72,82 +62,4 @@ public class TrackNode extends BControl { ...@@ -72,82 +62,4 @@ public class TrackNode extends BControl {
} }
public List<Track> getSourceTracks() {
return sourceTracks;
}
public List<Track> getTargetTracks() {
return targetTracks;
}
/**
* Add an incoming or outgoing connection to this shape.
*
* @param track
* a non-null connection instance
* @throws IllegalArgumentException
* if the connection is null or has not distinct endpoints
*/
public void addTrack(Track track) {
if (track == null || track.getSource() == track.getTarget()) {
throw new IllegalArgumentException();
}
track.setVisualization(getVisualization());
if (track.getSource() == this) {
getSourceTracks().add(track);
getListeners().firePropertyChange(SOURCE_CONNECTIONS_PROP, null,
track);
} else if (track.getTarget() == this) {
getTargetTracks().add(track);
getListeners().firePropertyChange(TARGET_CONNECTIONS_PROP, null,
track);
}
}
/**
* Remove an incoming or outgoing connection from this shape.
*
* @param track
* a non-null connection instance
* @throws IllegalArgumentException
* if the parameter is null
*/
public void removeTrack(Track track) {
if (track == null) {
throw new IllegalArgumentException();
}
if (track.getSource() == this) {
getSourceTracks().remove(track);
getListeners().firePropertyChange(SOURCE_CONNECTIONS_PROP, null,
track);
} else if (track.getTarget() == this) {
getTargetTracks().remove(track);
getListeners().firePropertyChange(TARGET_CONNECTIONS_PROP, null,
track);
}
}
@Override
protected void populateVisualization(Visualization visualization) {
for (Track t : getTargetTracks())
t.setVisualization(visualization);
for (Track t : getSourceTracks())
t.setVisualization(visualization);
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);
}
}
} }
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
package de.bmotionstudio.gef.editor.part; package de.bmotionstudio.gef.editor.part;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.EditPolicy; import org.eclipse.gef.EditPolicy;
...@@ -21,7 +19,6 @@ import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy; ...@@ -21,7 +19,6 @@ import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy;
import de.bmotionstudio.gef.editor.editpolicy.TrackEditPolicy; import de.bmotionstudio.gef.editor.editpolicy.TrackEditPolicy;
import de.bmotionstudio.gef.editor.figure.TrackNodeFigure; import de.bmotionstudio.gef.editor.figure.TrackNodeFigure;
import de.bmotionstudio.gef.editor.model.BControl; import de.bmotionstudio.gef.editor.model.BControl;
import de.bmotionstudio.gef.editor.model.TrackNode;
public class TrackNodePart extends BMSAbstractEditPart { public class TrackNodePart extends BMSAbstractEditPart {
...@@ -67,20 +64,4 @@ public class TrackNodePart extends BMSAbstractEditPart { ...@@ -67,20 +64,4 @@ public class TrackNodePart extends BMSAbstractEditPart {
protected void prepareRunPolicies() { protected void prepareRunPolicies() {
} }
@Override
protected List<?> getModelSourceConnections() {
List<BControl> all = new ArrayList<BControl>();
all.addAll(((TrackNode) getModel()).getSourceTracks());
all.addAll(((TrackNode) getModel()).getSourceConnections());
return all;
}
@Override
protected List<?> getModelTargetConnections() {
List<BControl> all = new ArrayList<BControl>();
all.addAll(((TrackNode) getModel()).getTargetTracks());
all.addAll(((TrackNode) getModel()).getTargetConnections());
return all;
}
} }
...@@ -18,7 +18,7 @@ import org.eclipse.gef.editpolicies.ConnectionEditPolicy; ...@@ -18,7 +18,7 @@ import org.eclipse.gef.editpolicies.ConnectionEditPolicy;
import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy; import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy;
import org.eclipse.gef.requests.GroupRequest; import org.eclipse.gef.requests.GroupRequest;
import de.bmotionstudio.gef.editor.command.TrackDeleteCommand; import de.bmotionstudio.gef.editor.command.ConnectionDeleteCommand;
import de.bmotionstudio.gef.editor.model.Track; import de.bmotionstudio.gef.editor.model.Track;
public class TrackPart extends BConnectionEditPart { public class TrackPart extends BConnectionEditPart {
...@@ -34,7 +34,7 @@ public class TrackPart extends BConnectionEditPart { ...@@ -34,7 +34,7 @@ public class TrackPart extends BConnectionEditPart {
installEditPolicy(EditPolicy.CONNECTION_ROLE, installEditPolicy(EditPolicy.CONNECTION_ROLE,
new ConnectionEditPolicy() { new ConnectionEditPolicy() {
protected Command getDeleteCommand(GroupRequest request) { protected Command getDeleteCommand(GroupRequest request) {
return new TrackDeleteCommand((Track) getModel()); return new ConnectionDeleteCommand((Track) getModel());
} }
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment