Skip to content

Commit

Permalink
Added reconnecting of output connections for MoveThroughHierarchy
Browse files Browse the repository at this point in the history
Works if MoveElementFromSubAppCommand does not handle connections
  • Loading branch information
sebHollersbacher authored and oberlehner committed May 7, 2024
1 parent 3129237 commit 2564958
Showing 1 changed file with 16 additions and 10 deletions.
Expand Up @@ -60,7 +60,6 @@ public Object execute(final ExecutionEvent event) throws ExecutionException {
final List<FBNetworkElement> fbelements = HandlerHelper.getSelectedFBNElements(selection);

if (!fbelements.isEmpty()) {

// get selected FBNetwork
final SubAppHierarchyDialog dialog = new SubAppHierarchyDialog(fbelements.get(0));
final FBNetwork destinationNetwork = dialog.open();
Expand All @@ -73,16 +72,23 @@ public Object execute(final ExecutionEvent event) throws ExecutionException {
destinationNetwork); // TODO Merge with this command
getCommandStack(editor).execute(cmd);

// reconnect the input connections
final CompoundCommand reconCmd = new CompoundCommand();
fbelements.get(0).getInterface().getAllInterfaceElements().forEach(ie -> {
if (ie.isIsInput()) {
ie.getInputConnections().forEach(conn -> {
reconCmd.add(new BorderCrossingReconnectCommand(conn.getDestination(),
conn.getDestination(), conn, false));
});
}
});
for (final FBNetworkElement fbElement : fbelements) {
// reconnect the input connections
fbElement.getInterface().getAllInterfaceElements().forEach(ie -> {
if (ie.isIsInput()) {
ie.getInputConnections().forEach(conn -> {
reconCmd.add(new BorderCrossingReconnectCommand(conn.getDestination(),
conn.getDestination(), conn, false));
});
} else {
ie.getOutputConnections().forEach(conn -> {
reconCmd.add(new BorderCrossingReconnectCommand(conn.getSource(), conn.getSource(),
conn, true));
});
}
});
}
getCommandStack(editor).execute(reconCmd); // TODO handle reconnect to same Input

// Update editor view
Expand Down

0 comments on commit 2564958

Please sign in to comment.