From ff085e5ecd509887808cdad0f189d3cd0458b445 Mon Sep 17 00:00:00 2001
From: Lukas Ladenberger <lukas.ladenberger@googlemail.com>
Date: Wed, 7 Nov 2012 11:35:25 +0100
Subject: [PATCH] fixed some bugs in railway plugin

---
 .../editor/command/TrackCreateCommand.java    | 129 -------------
 .../editor/command/TrackDeleteCommand.java    |  44 -----
 .../command/TrackNodeCreateCommand.java       |  63 -------
 .../editor/command/TrackReconnectCommand.java | 177 ------------------
 .../editor/editpolicy/TrackEditPolicy.java    |  22 +--
 .../gef/editor/model/Switch.java              |  22 ++-
 .../bmotionstudio/gef/editor/model/Track.java |  80 +-------
 .../gef/editor/model/TrackNode.java           |  88 ---------
 .../gef/editor/part/TrackNodePart.java        |  19 --
 .../gef/editor/part/TrackPart.java            |   4 +-
 10 files changed, 30 insertions(+), 618 deletions(-)
 delete mode 100644 de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/TrackCreateCommand.java
 delete mode 100644 de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/TrackDeleteCommand.java
 delete mode 100644 de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/TrackNodeCreateCommand.java
 delete mode 100644 de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/TrackReconnectCommand.java

diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/TrackCreateCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/TrackCreateCommand.java
deleted file mode 100644
index d2432fe3..00000000
--- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/TrackCreateCommand.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/** 
- * (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;
-	}
-
-}
diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/TrackDeleteCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/TrackDeleteCommand.java
deleted file mode 100644
index b690451d..00000000
--- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/TrackDeleteCommand.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/** 
- * (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();
-	}
-
-}
diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/TrackNodeCreateCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/TrackNodeCreateCommand.java
deleted file mode 100644
index 2d1cff65..00000000
--- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/TrackNodeCreateCommand.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/** 
- * (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();
-
-	}
-
-}
diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/TrackReconnectCommand.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/TrackReconnectCommand.java
deleted file mode 100644
index 361b11b9..00000000
--- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/command/TrackReconnectCommand.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/** 
- * (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;
-	}
-
-}
diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/TrackEditPolicy.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/TrackEditPolicy.java
index 7fd5d1b3..9756e26f 100644
--- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/TrackEditPolicy.java
+++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/editpolicy/TrackEditPolicy.java
@@ -12,8 +12,8 @@ import org.eclipse.gef.requests.CreateConnectionRequest;
 import org.eclipse.gef.requests.DropRequest;
 import org.eclipse.gef.requests.ReconnectRequest;
 
-import de.bmotionstudio.gef.editor.command.TrackCreateCommand;
-import de.bmotionstudio.gef.editor.command.TrackReconnectCommand;
+import de.bmotionstudio.gef.editor.command.ConnectionCreateCommand;
+import de.bmotionstudio.gef.editor.command.ConnectionReconnectCommand;
 import de.bmotionstudio.gef.editor.model.BConnection;
 import de.bmotionstudio.gef.editor.model.Track;
 import de.bmotionstudio.gef.editor.model.TrackNode;
@@ -34,9 +34,9 @@ public class TrackEditPolicy extends BMSConnectionEditPolicy {
 
 				Track track = (Track) newObject;
 				TrackNode trackNode = (TrackNode) model;
-				cmd = new TrackCreateCommand(trackNode);
+				cmd = new ConnectionCreateCommand(trackNode);
 				track.setVisualization(trackNode.getVisualization());
-				((TrackCreateCommand) cmd).setTrack(track);
+				((ConnectionCreateCommand) cmd).setConnection(track);
 				request.setStartCommand(cmd);
 
 			}
@@ -59,7 +59,7 @@ public class TrackEditPolicy extends BMSConnectionEditPolicy {
 		if (newObject instanceof Track) {
 
 			cmd = request.getStartCommand();
-			((TrackCreateCommand) cmd).setTarget((TrackNode) getHost()
+			((ConnectionCreateCommand) cmd).setTarget((TrackNode) getHost()
 					.getModel());
 
 		} else if (newObject instanceof BConnection) {
@@ -80,9 +80,9 @@ public class TrackEditPolicy extends BMSConnectionEditPolicy {
 
 			Track track = (Track) newObject;
 			TrackNode newSource = (TrackNode) getHost().getModel();
-			cmd = new TrackReconnectCommand();
-			((TrackReconnectCommand) cmd).setNewSource(newSource);
-			((TrackReconnectCommand) cmd).setConnection(track);
+			cmd = new ConnectionReconnectCommand();
+			((ConnectionReconnectCommand) cmd).setNewSource(newSource);
+			((ConnectionReconnectCommand) cmd).setConnection(track);
 
 		} else if (newObject instanceof BConnection) {
 			cmd = super.getReconnectSourceCommand(request);
@@ -102,9 +102,9 @@ public class TrackEditPolicy extends BMSConnectionEditPolicy {
 
 			Track track = (Track) newObject;
 			TrackNode newTarget = (TrackNode) getHost().getModel();
-			cmd = new TrackReconnectCommand();
-			((TrackReconnectCommand) cmd).setNewTarget(newTarget);
-			((TrackReconnectCommand) cmd).setConnection(track);
+			cmd = new ConnectionReconnectCommand();
+			((ConnectionReconnectCommand) cmd).setNewTarget(newTarget);
+			((ConnectionReconnectCommand) cmd).setConnection(track);
 
 		} else if (newObject instanceof BConnection) {
 			cmd = super.getReconnectTargetCommand(request);
diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Switch.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Switch.java
index 918b7823..1fa35bd1 100644
--- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Switch.java
+++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Switch.java
@@ -18,8 +18,8 @@ import de.bmotionstudio.gef.editor.attribute.AttributeSwitchPosition;
 import de.bmotionstudio.gef.editor.attribute.BAttributeHeight;
 import de.bmotionstudio.gef.editor.attribute.BAttributeSize;
 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.TrackCreateCommand;
 
 public class Switch extends BControl {
 
@@ -49,16 +49,17 @@ public class Switch extends BControl {
 		cmd.setLayout(new Rectangle(70, 70, 50, 20));
 		cmd.execute();
 
-		TrackCreateCommand trackCreateCmd = new TrackCreateCommand(tracknode1);
+		ConnectionCreateCommand trackCreateCmd = new ConnectionCreateCommand(
+				tracknode1);
 		trackCreateCmd.setTarget(tracknode2);
 		track1 = new Track(getVisualization());
-		trackCreateCmd.setTrack(track1);
+		trackCreateCmd.setConnection(track1);
 		trackCreateCmd.execute();
 
-		trackCreateCmd = new TrackCreateCommand(tracknode1);
+		trackCreateCmd = new ConnectionCreateCommand(tracknode1);
 		trackCreateCmd.setTarget(tracknode3);
 		track2 = new Track(getVisualization());
-		trackCreateCmd.setTrack(track2);
+		trackCreateCmd.setConnection(track2);
 		trackCreateCmd.execute();
 
 		track1.setAttributeValue(AttributeConstants.ATTRIBUTE_LABEL, "");
@@ -128,9 +129,14 @@ public class Switch extends BControl {
 		for (BControl control : getChildrenArray()) {
 
 			List<Track> tracks = new ArrayList<Track>();
-			tracks.addAll(((TrackNode) control).getSourceTracks());
-			tracks.addAll(((TrackNode) control).getTargetTracks());
-
+			for (BConnection c : ((TrackNode) control).getSourceConnections()) {
+				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) {
 				AbstractAttribute a2 = n
 						.getAttribute(AttributeConstants.ATTRIBUTE_CUSTOM);
diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Track.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Track.java
index efc34288..e56e990b 100644
--- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Track.java
+++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/Track.java
@@ -8,6 +8,7 @@ package de.bmotionstudio.gef.editor.model;
 
 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.BAttributeConnectionSourceDecoration;
 import de.bmotionstudio.gef.editor.attribute.BAttributeConnectionTargetDecoration;
@@ -20,17 +21,10 @@ import de.bmotionstudio.gef.editor.attribute.BAttributeLineWidth;
  * @author Lukas Ladenberger
  * 
  */
-public class Track extends BControl {
+public class Track extends BConnection {
 
 	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) {
 		super(visualization);
 	}
@@ -44,6 +38,7 @@ public class Track extends BControl {
 	protected void initAttributes() {
 
 		BAttributeConnection aConnection = new BAttributeConnection(null);
+		aConnection.setGroup(AbstractAttribute.ROOT);
 		initAttribute(aConnection);
 
 		BAttributeLineWidth aLineWidth = new BAttributeLineWidth(1);
@@ -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;
-		}
-	}
-
 }
diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/TrackNode.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/TrackNode.java
index 1dc0156d..a71845d7 100644
--- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/TrackNode.java
+++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/model/TrackNode.java
@@ -6,12 +6,8 @@
 
 package de.bmotionstudio.gef.editor.model;
 
-import java.util.ArrayList;
-import java.util.List;
-
 import org.eclipse.draw2d.ColorConstants;
 
-import de.bmotionstudio.gef.editor.Animation;
 import de.bmotionstudio.gef.editor.attribute.AbstractAttribute;
 import de.bmotionstudio.gef.editor.attribute.BAttributeForegroundColor;
 import de.bmotionstudio.gef.editor.attribute.BAttributeHeight;
@@ -28,14 +24,8 @@ public class TrackNode extends BControl {
 
 	public static transient String TYPE = "de.bmotionstudio.gef.editor.tracknode";
 
-	private List<Track> sourceTracks;
-
-	private List<Track> targetTracks;
-
 	public TrackNode(Visualization visualization) {
 		super(visualization);
-		this.sourceTracks = new ArrayList<Track>();
-		this.targetTracks = new ArrayList<Track>();
 	}
 
 	@Override
@@ -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);
-		}
-	}
-
 }
diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TrackNodePart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TrackNodePart.java
index d6d00f5c..061329b3 100644
--- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TrackNodePart.java
+++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TrackNodePart.java
@@ -7,8 +7,6 @@
 package de.bmotionstudio.gef.editor.part;
 
 import java.beans.PropertyChangeEvent;
-import java.util.ArrayList;
-import java.util.List;
 
 import org.eclipse.draw2d.IFigure;
 import org.eclipse.gef.EditPolicy;
@@ -21,7 +19,6 @@ import de.bmotionstudio.gef.editor.editpolicy.BMSDeletePolicy;
 import de.bmotionstudio.gef.editor.editpolicy.TrackEditPolicy;
 import de.bmotionstudio.gef.editor.figure.TrackNodeFigure;
 import de.bmotionstudio.gef.editor.model.BControl;
-import de.bmotionstudio.gef.editor.model.TrackNode;
 
 public class TrackNodePart extends BMSAbstractEditPart {
 
@@ -67,20 +64,4 @@ public class TrackNodePart extends BMSAbstractEditPart {
 	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;
-	}
-
 }
diff --git a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TrackPart.java b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TrackPart.java
index 73d2c14d..270aa489 100644
--- a/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TrackPart.java
+++ b/de.bmotionstudio.gef.editor/src/de/bmotionstudio/gef/editor/part/TrackPart.java
@@ -18,7 +18,7 @@ import org.eclipse.gef.editpolicies.ConnectionEditPolicy;
 import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy;
 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;
 
 public class TrackPart extends BConnectionEditPart {
@@ -34,7 +34,7 @@ public class TrackPart extends BConnectionEditPart {
 		installEditPolicy(EditPolicy.CONNECTION_ROLE,
 				new ConnectionEditPolicy() {
 					protected Command getDeleteCommand(GroupRequest request) {
-						return new TrackDeleteCommand((Track) getModel());
+						return new ConnectionDeleteCommand((Track) getModel());
 					}
 				});
 	}
-- 
GitLab