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

cleanup paste command

parent bb2cd6fa
Branches
Tags
No related merge requests found
......@@ -93,68 +93,43 @@ public class PasteCommand extends Command {
HashMap<BControl, BControl> helpMap = new HashMap<BControl, BControl>();
helpMap.putAll(cHelper.getAlreadyClonedMap());
helpMap.putAll(mappingControl);
Iterator<BControl> it2 = helpMap.keySet().iterator();
while (it2.hasNext()) {
BControl control = it2.next();
// Clone connections
for (BConnection c : control.getSourceConnections()) {
BConnection newConnection = mappingConnection.get(c);
if (newConnection == null) {
newConnection = (BConnection) c.clone();
newConnection.disconnect();
mappingConnection.put(c, newConnection);
for (BConnection c : control.getSourceConnections())
copyPasteConnection(c, helpMap);
for (BConnection c : control.getTargetConnections())
copyPasteConnection(c, helpMap);
}
BControl s = helpMap.get(newConnection
.getSource());
if (s == null)
s = newConnection.getSource();
BControl t = helpMap.get(newConnection
.getTarget());
if (t == null)
t = newConnection.getTarget();
redo();
newConnection.setTarget(t);
newConnection.setSource(s);
}
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
for (BConnection c : control.getTargetConnections()) {
}
private void copyPasteConnection(BConnection c,
HashMap<BControl, BControl> controlMap)
throws CloneNotSupportedException {
BConnection newConnection = mappingConnection.get(c);
if (newConnection == null) {
newConnection = (BConnection) c.clone();
newConnection.disconnect();
mappingConnection.put(c, newConnection);
}
BControl t = helpMap.get(newConnection
.getTarget());
BControl t = controlMap.get(newConnection.getTarget());
if (t == null)
t = newConnection.getTarget();
BControl s = helpMap.get(newConnection
.getSource());
BControl s = controlMap.get(newConnection.getSource());
if (s == null)
s = newConnection.getSource();
newConnection.setTarget(t);
newConnection.setSource(s);
}
}
redo();
}
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
}
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment