Skip to content

Commit

Permalink
edges and connections get copied exactly when their source and destin…
Browse files Browse the repository at this point in the history
…ation is selected
  • Loading branch information
BenKenobie31415 committed Mar 10, 2024
1 parent 879b1da commit b9f5e9c
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ boolean run() throws GeckoException {
CopyPositionableViewModelElementVisitor visitor = new CopyPositionableViewModelElementVisitor(geckoViewModel);

Set<PositionableViewModelElement<?>> copyQueue = geckoViewModel.getCurrentEditor().getSelectionManager().getCurrentSelection();
Set<Element> elementToCopy = copyQueue.stream().map(PositionableViewModelElement::getTarget).collect(Collectors.toSet());
for (Edge edge : geckoViewModel.getCurrentEditor().getCurrentSystem().getTarget().getAutomaton().getEdges()) {
if (elementToCopy.contains(edge.getSource()) && elementToCopy.contains(edge.getDestination())) {
copyQueue.add(geckoViewModel.getViewModelElement(edge));
}
}
for (SystemConnection connection : geckoViewModel.getCurrentEditor().getCurrentSystem().getTarget().getConnections()) {
System sourceSystem = geckoViewModel.getGeckoModel().getSystemWithVariable(connection.getSource());
System destinationSystem = geckoViewModel.getGeckoModel().getSystemWithVariable(connection.getDestination());
if (elementToCopy.contains(sourceSystem) && elementToCopy.contains(destinationSystem)) {
copyQueue.add(geckoViewModel.getViewModelElement(connection));
}
}
do {
System.out.println("Trying to copy: " + copyQueue);
visitor.getFailedCopies().clear();
Expand Down

0 comments on commit b9f5e9c

Please sign in to comment.