|
@@ -126,16 +126,9 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
|
|
|
itemUngroup
|
|
|
.addActionListener(actionEvent -> {
|
|
|
// save old Position
|
|
|
- JTabbedPane tabbedPaneInner = (JTabbedPane) getParent()
|
|
|
- .getParent().getParent();
|
|
|
- for (int i = 1; i < tabbedPaneInner.getTabCount(); i++) {
|
|
|
- if (((UpperNodeCanvas) ((JScrollPane) tabbedPaneInner
|
|
|
- .getComponentAt(i)).getViewport().getComponent(
|
|
|
- 0)).upperNode.getId() == tempCps.getId()) {
|
|
|
- tabbedPaneInner.remove(i);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
+ int upperNodeId = tempCps.getId();
|
|
|
+
|
|
|
+ closeUpperNodeTab(upperNodeId);
|
|
|
|
|
|
savePos = new ArrayList<>();
|
|
|
animCps = ((CpsUpperNode) tempCps).getNodes();
|
|
@@ -376,9 +369,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
|
|
|
String maxCap = null;
|
|
|
super.paintComponent(g);
|
|
|
// Rendering
|
|
|
-
|
|
|
g2 = (Graphics2D) g;
|
|
|
-
|
|
|
RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
|
|
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
|
|
g2.setRenderingHints(rh);
|
|
@@ -626,6 +617,11 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
|
|
|
if(model.getSelectedCpsObjects().size()==1
|
|
|
&& checkForReplacement(model.getObjectsOnCanvas(), tempCps, tempCps.getPosition().x, tempCps.getPosition().y)){
|
|
|
/**
|
|
|
+ * if UpperNode would be replaced, close its tabs
|
|
|
+ */
|
|
|
+ if(mayBeReplaced instanceof CpsUpperNode)
|
|
|
+ closeUpperNodeTab(mayBeReplaced.getId());
|
|
|
+ /**
|
|
|
* replace on canvas (will save)
|
|
|
*/
|
|
|
controller.replaceCanvasObject(mayBeReplaced, tempCps);
|
|
@@ -998,4 +994,19 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void closeUpperNodeTab(int upperNodeId) {
|
|
|
+ JTabbedPane tabbedPaneInner = (JTabbedPane) getParent()
|
|
|
+ .getParent().getParent().getParent();
|
|
|
+ for (int i = 1; i < tabbedPaneInner.getTabCount(); i++) {
|
|
|
+ if (((UpperNodeCanvas) ((JScrollPane) tabbedPaneInner
|
|
|
+ .getComponentAt(i)).getViewport().getComponent(
|
|
|
+ 0)).upperNode.getId() == upperNodeId) {
|
|
|
+ tabbedPaneInner.remove(i);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|