|
@@ -57,6 +57,7 @@ public class GUI<E> implements CategoryListener {
|
|
private final JSplitPane splitPane1 = new JSplitPane();
|
|
private final JSplitPane splitPane1 = new JSplitPane();
|
|
private final JSplitPane splitPaneCanvasConsole = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
|
private final JSplitPane splitPaneCanvasConsole = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
|
private final JScrollPane canvasSP = new JScrollPane();
|
|
private final JScrollPane canvasSP = new JScrollPane();
|
|
|
|
+ private final JTabbedPane canvasTP = new JTabbedPane(JTabbedPane.TOP);
|
|
private final JScrollPane scrollPane1 = new JScrollPane();
|
|
private final JScrollPane scrollPane1 = new JScrollPane();
|
|
// private final JScrollPane holonSP = new JScrollPane();
|
|
// private final JScrollPane holonSP = new JScrollPane();
|
|
private final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
|
private final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
|
@@ -330,30 +331,26 @@ public class GUI<E> implements CategoryListener {
|
|
String cntrlADown = "controlA";
|
|
String cntrlADown = "controlA";
|
|
inputMap.put(KeyStroke.getKeyStroke("control A"), cntrlADown);
|
|
inputMap.put(KeyStroke.getKeyStroke("control A"), cntrlADown);
|
|
AbstractAction controlA = new AbstractAction() {
|
|
AbstractAction controlA = new AbstractAction() {
|
|
-
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
+ chooseTabTemp();
|
|
|
|
|
|
- if (tabbedPane.getMousePosition() != null) {
|
|
|
|
- tabTemp = tabbedPane;
|
|
|
|
- } else if (tabbedPane2.getMousePosition() != null) {
|
|
|
|
- tabTemp = tabbedPane2;
|
|
|
|
- }
|
|
|
|
model.getSelectedCpsObjects().clear();
|
|
model.getSelectedCpsObjects().clear();
|
|
|
|
+
|
|
// Uppernode Canvas?
|
|
// Uppernode Canvas?
|
|
- if (((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
|
- .getComponent(0) instanceof UpperNodeCanvas) {
|
|
|
|
- UpperNodeCanvas uNC = (UpperNodeCanvas) ((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
|
- .getComponent(0);
|
|
|
|
|
|
+ JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
|
|
+ Component canvasOrUpperNodeCanvas = scrollPane.getViewport().getComponent(0);
|
|
|
|
+
|
|
|
|
+ if (canvasOrUpperNodeCanvas instanceof UpperNodeCanvas) {
|
|
|
|
+ UpperNodeCanvas uNC = (UpperNodeCanvas) canvasOrUpperNodeCanvas;
|
|
for (AbstractCpsObject cps : uNC.upperNode.getNodes()) {
|
|
for (AbstractCpsObject cps : uNC.upperNode.getNodes()) {
|
|
controller.addSelectedObject(cps);
|
|
controller.addSelectedObject(cps);
|
|
}
|
|
}
|
|
uNC.repaint();
|
|
uNC.repaint();
|
|
// or Canvas?
|
|
// or Canvas?
|
|
- } else if (((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
|
- .getComponent(0) instanceof MyCanvas) {
|
|
|
|
|
|
+ } else if (canvasOrUpperNodeCanvas instanceof MyCanvas) {
|
|
for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
|
|
for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
|
|
controller.addSelectedObject(cps);
|
|
controller.addSelectedObject(cps);
|
|
}
|
|
}
|
|
@@ -373,52 +370,28 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
- if (tabbedPane.getMousePosition() != null) {
|
|
|
|
- tabTemp = tabbedPane;
|
|
|
|
- } else if (tabbedPane2.getMousePosition() != null) {
|
|
|
|
- tabTemp = tabbedPane2;
|
|
|
|
- }
|
|
|
|
|
|
+ chooseTabTemp();
|
|
|
|
+
|
|
// Uppernode Canvas?
|
|
// Uppernode Canvas?
|
|
- if (((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
|
- .getComponent(0) instanceof UpperNodeCanvas) {
|
|
|
|
- UpperNodeCanvas uNC = (UpperNodeCanvas) ((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
|
- .getComponent(0);
|
|
|
|
|
|
+ JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
|
|
+ Component canvasOrUpperNodeCanvas = scrollPane.getViewport().getComponent(0);
|
|
|
|
+
|
|
|
|
+ if (canvasOrUpperNodeCanvas instanceof UpperNodeCanvas) {
|
|
|
|
+ UpperNodeCanvas uNC = (UpperNodeCanvas) canvasOrUpperNodeCanvas;
|
|
for (AbstractCpsObject cps : model.getSelectedCpsObjects()) {
|
|
for (AbstractCpsObject cps : model.getSelectedCpsObjects()) {
|
|
controller.removeTrackingObj(cps);
|
|
controller.removeTrackingObj(cps);
|
|
if (uNC.upperNode.getNodes().contains(cps)) {
|
|
if (uNC.upperNode.getNodes().contains(cps)) {
|
|
controller.delObjUpperNode(cps, uNC.upperNode);
|
|
controller.delObjUpperNode(cps, uNC.upperNode);
|
|
unc.setToolTip(false);
|
|
unc.setToolTip(false);
|
|
- // Remove UpperNodeTab if UpperNode deleted
|
|
|
|
- if (cps instanceof CpsUpperNode) {
|
|
|
|
- boolean splitView = false;
|
|
|
|
- for (int i = 4; i < tabbedPane.getTabCount(); i++) {
|
|
|
|
- if (tabbedPane.getComponentAt(i) == null) {
|
|
|
|
- splitView = true;
|
|
|
|
- } else if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i))
|
|
|
|
- .getViewport().getComponent(0)).upperNode.getId() == cps.getId()) {
|
|
|
|
- ((ButtonTabComponent) tabbedPane.getTabComponentAt(i)).removeTabs();
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // If SplitView is on and the view on
|
|
|
|
- // tabbedPane2 is the deleted upperNode
|
|
|
|
- try {
|
|
|
|
- if (splitView
|
|
|
|
- && ((UpperNodeCanvas) ((JScrollPane) tabbedPane2.getSelectedComponent())
|
|
|
|
- .getViewport().getComponent(0)).upperNode.getId() == cps.getId()) {
|
|
|
|
- ((ButtonTabComponent) tabbedPane
|
|
|
|
- .getTabComponentAt(tabbedPane2.getSelectedIndex())).removeTabs();
|
|
|
|
- }
|
|
|
|
- } catch (Exception e2) {
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ // remove UpperNodeTab if UpperNode deleted
|
|
|
|
+ removeUpperNodeTab(cps);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
uNC.repaint();
|
|
uNC.repaint();
|
|
|
|
|
|
// or Canvas?
|
|
// or Canvas?
|
|
- } else if (((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
|
- .getComponent(0) instanceof MyCanvas) {
|
|
|
|
|
|
+ } else if (canvasOrUpperNodeCanvas instanceof MyCanvas) {
|
|
boolean save = false;
|
|
boolean save = false;
|
|
for (int j = 0; j < model.getSelectedCpsObjects().size(); j++) {
|
|
for (int j = 0; j < model.getSelectedCpsObjects().size(); j++) {
|
|
AbstractCpsObject cps = model.getSelectedCpsObjects().get(j);
|
|
AbstractCpsObject cps = model.getSelectedCpsObjects().get(j);
|
|
@@ -427,29 +400,9 @@ public class GUI<E> implements CategoryListener {
|
|
save = true;
|
|
save = true;
|
|
controller.delCanvasObject(cps, save);
|
|
controller.delCanvasObject(cps, save);
|
|
canvas.setToolTip(false);
|
|
canvas.setToolTip(false);
|
|
- // Remove UpperNodeTab if UpperNode deleted
|
|
|
|
- if (cps instanceof CpsUpperNode) {
|
|
|
|
- boolean splitView = false;
|
|
|
|
- for (int i = 4; i < tabbedPane.getTabCount(); i++) {
|
|
|
|
- if (tabbedPane.getComponentAt(i) == null) {
|
|
|
|
- splitView = true;
|
|
|
|
- } else if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
|
|
|
|
- .getComponent(0)).upperNode.getId() == cps.getId()) {
|
|
|
|
- ((ButtonTabComponent) tabbedPane.getTabComponentAt(i)).removeTabs();
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // If SplitView is on and the view on
|
|
|
|
- // tabbedPane2 is the deleted upperNode
|
|
|
|
- try {
|
|
|
|
- if (splitView && ((UpperNodeCanvas) ((JScrollPane) tabbedPane2.getSelectedComponent())
|
|
|
|
- .getViewport().getComponent(0)).upperNode.getId() == cps.getId()) {
|
|
|
|
- ((ButtonTabComponent) tabbedPane.getTabComponentAt(tabbedPane2.getSelectedIndex()))
|
|
|
|
- .removeTabs();
|
|
|
|
- }
|
|
|
|
- } catch (Exception e2) {
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ // remove UpperNodeTab if UpperNode deleted
|
|
|
|
+ removeUpperNodeTab(cps);
|
|
}
|
|
}
|
|
canvas.repaint();
|
|
canvas.repaint();
|
|
}
|
|
}
|
|
@@ -475,21 +428,16 @@ public class GUI<E> implements CategoryListener {
|
|
String cntrlCDown = "controlC";
|
|
String cntrlCDown = "controlC";
|
|
inputMap.put(KeyStroke.getKeyStroke("control C"), cntrlCDown);
|
|
inputMap.put(KeyStroke.getKeyStroke("control C"), cntrlCDown);
|
|
AbstractAction controlC = new AbstractAction() {
|
|
AbstractAction controlC = new AbstractAction() {
|
|
-
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
- if (tabbedPane.getMousePosition() != null) {
|
|
|
|
- tabTemp = tabbedPane;
|
|
|
|
- } else {
|
|
|
|
- tabTemp = tabbedPane2;
|
|
|
|
- }
|
|
|
|
|
|
+ chooseTabTemp();
|
|
|
|
+
|
|
|
|
+ JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
if (!model.getSelectedCpsObjects().isEmpty()) {
|
|
if (!model.getSelectedCpsObjects().isEmpty()) {
|
|
- if (((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
|
- .getComponent(0) instanceof UpperNodeCanvas)
|
|
|
|
- controller.copy(((UpperNodeCanvas) ((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
|
- .getComponent(0)).upperNode);
|
|
|
|
|
|
+ if (scrollPane.getViewport().getComponent(0) instanceof UpperNodeCanvas)
|
|
|
|
+ controller.copy(((UpperNodeCanvas) scrollPane.getViewport().getComponent(0)).upperNode);
|
|
else
|
|
else
|
|
controller.copy(null);
|
|
controller.copy(null);
|
|
if (!model.getClipboradObjects().isEmpty()) {
|
|
if (!model.getClipboradObjects().isEmpty()) {
|
|
@@ -503,7 +451,6 @@ public class GUI<E> implements CategoryListener {
|
|
String cntrlVDown = "controlV";
|
|
String cntrlVDown = "controlV";
|
|
inputMap.put(KeyStroke.getKeyStroke("control V"), cntrlVDown);
|
|
inputMap.put(KeyStroke.getKeyStroke("control V"), cntrlVDown);
|
|
AbstractAction controlV = new AbstractAction() {
|
|
AbstractAction controlV = new AbstractAction() {
|
|
-
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -517,16 +464,17 @@ public class GUI<E> implements CategoryListener {
|
|
tabTemp = tabbedPane2;
|
|
tabTemp = tabbedPane2;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (tabTemp != null && ((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
|
- .getComponent(0) instanceof UpperNodeCanvas) {
|
|
|
|
|
|
+
|
|
|
|
+ JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
|
|
+ Component canvasOrUpperNodeCanvas = scrollPane.getViewport().getComponent(0);
|
|
|
|
+
|
|
|
|
+ if (tabTemp != null && canvasOrUpperNodeCanvas instanceof UpperNodeCanvas) {
|
|
|
|
|
|
controller.paste(
|
|
controller.paste(
|
|
- ((UpperNodeCanvas) ((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
|
- .getComponent(0)).upperNode,
|
|
|
|
- ((JScrollPane) tabTemp.getSelectedComponent()).getViewport().getComponent(0)
|
|
|
|
- .getMousePosition());
|
|
|
|
|
|
+ ((UpperNodeCanvas) canvasOrUpperNodeCanvas).upperNode,
|
|
|
|
+ canvasOrUpperNodeCanvas.getMousePosition());
|
|
unitGraph.update(model.getSelectedCpsObjects());
|
|
unitGraph.update(model.getSelectedCpsObjects());
|
|
- ((JScrollPane) tabTemp.getSelectedComponent()).getViewport().getComponent(0).repaint();
|
|
|
|
|
|
+ scrollPane.getViewport().getComponent(0).repaint();
|
|
} else {
|
|
} else {
|
|
controller.paste(null, canvas.getMousePosition());
|
|
controller.paste(null, canvas.getMousePosition());
|
|
unitGraph.update(model.getSelectedCpsObjects());
|
|
unitGraph.update(model.getSelectedCpsObjects());
|
|
@@ -549,18 +497,15 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
- if (tabbedPane.getMousePosition() != null) {
|
|
|
|
- tabTemp = tabbedPane;
|
|
|
|
- } else {
|
|
|
|
- tabTemp = tabbedPane2;
|
|
|
|
- }
|
|
|
|
|
|
+ chooseTabTemp();
|
|
|
|
+
|
|
|
|
+ JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
if (!model.getSelectedCpsObjects().isEmpty()) {
|
|
if (!model.getSelectedCpsObjects().isEmpty()) {
|
|
- if (((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
|
- .getComponent(0) instanceof UpperNodeCanvas)
|
|
|
|
- controller.cut(((UpperNodeCanvas) ((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
|
- .getComponent(0)).upperNode);
|
|
|
|
- else
|
|
|
|
|
|
+ if (scrollPane.getViewport().getComponent(0) instanceof UpperNodeCanvas) {
|
|
|
|
+ controller.cut(((UpperNodeCanvas) scrollPane.getViewport().getComponent(0)).upperNode);
|
|
|
|
+ } else {
|
|
controller.cut(null);
|
|
controller.cut(null);
|
|
|
|
+ }
|
|
if (!model.getClipboradObjects().isEmpty()) {
|
|
if (!model.getClipboradObjects().isEmpty()) {
|
|
canvas.itemPaste.setEnabled(true);
|
|
canvas.itemPaste.setEnabled(true);
|
|
}
|
|
}
|
|
@@ -672,15 +617,17 @@ public class GUI<E> implements CategoryListener {
|
|
sizeSlider.setMaximum(115);
|
|
sizeSlider.setMaximum(115);
|
|
sizeSlider.addChangeListener(changeEvent -> {
|
|
sizeSlider.addChangeListener(changeEvent -> {
|
|
controller.setScale(sizeSlider.getValue());
|
|
controller.setScale(sizeSlider.getValue());
|
|
- if (((JScrollPane) tabbedPane.getSelectedComponent()).getViewport()
|
|
|
|
|
|
+
|
|
|
|
+ JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
|
|
+
|
|
|
|
+ if (scrollPane.getViewport()
|
|
.getComponent(0) instanceof UpperNodeCanvas) {
|
|
.getComponent(0) instanceof UpperNodeCanvas) {
|
|
- ((JScrollPane) tabbedPane.getSelectedComponent()).getViewport().getComponent(0).repaint();
|
|
|
|
|
|
+ scrollPane.getViewport().getComponent(0).repaint();
|
|
} else {
|
|
} else {
|
|
canvas.repaint();
|
|
canvas.repaint();
|
|
}
|
|
}
|
|
- if (!initSplit && ((JScrollPane) tabbedPane2.getSelectedComponent()).getViewport()
|
|
|
|
- .getComponent(0) instanceof UpperNodeCanvas) {
|
|
|
|
- ((JScrollPane) tabbedPane2.getSelectedComponent()).getViewport().getComponent(0).repaint();
|
|
|
|
|
|
+ if (!initSplit && scrollPane.getViewport().getComponent(0) instanceof UpperNodeCanvas) {
|
|
|
|
+ scrollPane.getViewport().getComponent(0).repaint();
|
|
} else {
|
|
} else {
|
|
canvas.repaint();
|
|
canvas.repaint();
|
|
}
|
|
}
|
|
@@ -729,15 +676,15 @@ public class GUI<E> implements CategoryListener {
|
|
mnNewMenuView.add(mntmBackground);
|
|
mnNewMenuView.add(mntmBackground);
|
|
|
|
|
|
mntmBackground.addActionListener(actionEvent -> {
|
|
mntmBackground.addActionListener(actionEvent -> {
|
|
- if (((JScrollPane) tabbedPane.getSelectedComponent()).getViewport()
|
|
|
|
- .getComponent(0) instanceof MyCanvas) {
|
|
|
|
|
|
+ tabTemp = tabbedPane;
|
|
|
|
+ JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
|
|
+
|
|
|
|
+ if (scrollPane.getViewport().getComponent(0) instanceof MyCanvas) {
|
|
BackgroundPopUp backgroundDialog = new BackgroundPopUp(model, controller, canvas, null);
|
|
BackgroundPopUp backgroundDialog = new BackgroundPopUp(model, controller, canvas, null);
|
|
backgroundDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
|
backgroundDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
|
backgroundDialog.setVisible(true);
|
|
backgroundDialog.setVisible(true);
|
|
- } else if (((JScrollPane) tabbedPane.getSelectedComponent()).getViewport()
|
|
|
|
- .getComponent(0) instanceof UpperNodeCanvas) {
|
|
|
|
- UpperNodeCanvas uNodeCanvas = (UpperNodeCanvas) (((JScrollPane) tabbedPane.getSelectedComponent())
|
|
|
|
- .getViewport().getComponent(0));
|
|
|
|
|
|
+ } else if (scrollPane.getViewport().getComponent(0) instanceof UpperNodeCanvas) {
|
|
|
|
+ UpperNodeCanvas uNodeCanvas = (UpperNodeCanvas) (scrollPane.getViewport().getComponent(0));
|
|
BackgroundPopUp backgroundDialog = new BackgroundPopUp(model, controller, null,
|
|
BackgroundPopUp backgroundDialog = new BackgroundPopUp(model, controller, null,
|
|
uNodeCanvas.upperNode);
|
|
uNodeCanvas.upperNode);
|
|
backgroundDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
|
backgroundDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
|
@@ -1162,8 +1109,11 @@ public class GUI<E> implements CategoryListener {
|
|
updCon.getActualCps().setName(temp.toString());
|
|
updCon.getActualCps().setName(temp.toString());
|
|
// Update of name on the tab in the tab section
|
|
// Update of name on the tab in the tab section
|
|
for (int index = 4; index < tabbedPane.getTabCount(); index++) {
|
|
for (int index = 4; index < tabbedPane.getTabCount(); index++) {
|
|
- UpperNodeCanvas unc = ((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponent(index))
|
|
|
|
- .getViewport().getComponent(0));
|
|
|
|
|
|
+ tabTemp = tabbedPane;
|
|
|
|
+ JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
|
|
+
|
|
|
|
+ UpperNodeCanvas unc = ((UpperNodeCanvas) scrollPane.getViewport().getComponent(0));
|
|
|
|
+
|
|
if (unc.upperNode.getId() == updCon.getActualCps().getId()) {
|
|
if (unc.upperNode.getId() == updCon.getActualCps().getId()) {
|
|
tabbedPane.setTitleAt(index, unc.upperNode.getName());
|
|
tabbedPane.setTitleAt(index, unc.upperNode.getName());
|
|
tabbedPane.updateUI();
|
|
tabbedPane.updateUI();
|
|
@@ -1276,15 +1226,13 @@ public class GUI<E> implements CategoryListener {
|
|
public void mouseReleased(MouseEvent e) {
|
|
public void mouseReleased(MouseEvent e) {
|
|
try {
|
|
try {
|
|
if (dragging) {
|
|
if (dragging) {
|
|
- if (tabbedPane.getMousePosition() != null) {
|
|
|
|
- tabTemp = tabbedPane;
|
|
|
|
- } else {
|
|
|
|
- tabTemp = tabbedPane2;
|
|
|
|
- }
|
|
|
|
- if (((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
|
- .getComponent(0) instanceof UpperNodeCanvas) {
|
|
|
|
- UpperNodeCanvas unc = ((UpperNodeCanvas) ((JScrollPane) tabTemp.getSelectedComponent())
|
|
|
|
- .getViewport().getComponent(0));
|
|
|
|
|
|
+ chooseTabTemp();
|
|
|
|
+
|
|
|
|
+ JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
|
|
+ Component canvasOrUpperNodeCanvas = scrollPane.getViewport().getComponent(0);
|
|
|
|
+
|
|
|
|
+ if (canvasOrUpperNodeCanvas instanceof UpperNodeCanvas) {
|
|
|
|
+ UpperNodeCanvas unc = (UpperNodeCanvas) canvasOrUpperNodeCanvas;
|
|
|
|
|
|
int x = (int) unc.getMousePosition().getX() + 16;
|
|
int x = (int) unc.getMousePosition().getX() + 16;
|
|
int y = (int) unc.getMousePosition().getY() + 16;
|
|
int y = (int) unc.getMousePosition().getY() + 16;
|
|
@@ -1798,7 +1746,8 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
splitPane.setLeftComponent(scrollPane1);
|
|
splitPane.setLeftComponent(scrollPane1);
|
|
splitPaneCanvasConsole.setLeftComponent(tabbedPane);
|
|
splitPaneCanvasConsole.setLeftComponent(tabbedPane);
|
|
- tabbedPane.addTab("View", canvasSP);
|
|
|
|
|
|
+ tabbedPane.addTab("View", canvasTP);
|
|
|
|
+ canvasTP.addTab("Main Grid", canvasSP);
|
|
tabbedPane.addTab("Statistics", statScrollPane);
|
|
tabbedPane.addTab("Statistics", statScrollPane);
|
|
tabbedPane.addTab("Holon", holonCanvas);
|
|
tabbedPane.addTab("Holon", holonCanvas);
|
|
flexPane = new FlexiblePane(controller);
|
|
flexPane = new FlexiblePane(controller);
|
|
@@ -2066,18 +2015,16 @@ public class GUI<E> implements CategoryListener {
|
|
*/
|
|
*/
|
|
private void openNewUpperNodeTab() {
|
|
private void openNewUpperNodeTab() {
|
|
// is the uppernode on tabbedPane or tabbedPane2
|
|
// is the uppernode on tabbedPane or tabbedPane2
|
|
- if (tabbedPane.getMousePosition() != null) {
|
|
|
|
- tabTemp = tabbedPane;
|
|
|
|
- } else {
|
|
|
|
- tabTemp = tabbedPane2;
|
|
|
|
- }
|
|
|
|
- if (((JScrollPane) tabTemp.getSelectedComponent()).getViewport().getComponent(0) instanceof MyCanvas) {
|
|
|
|
|
|
+ // TODO: hier upper node
|
|
|
|
+ chooseTabTemp();
|
|
|
|
+
|
|
|
|
+ JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
|
|
+ if (scrollPane.getViewport().getComponent(0) instanceof MyCanvas) {
|
|
unc = new UpperNodeCanvas(model, controller, unitGraph, (CpsUpperNode) temp, "");
|
|
unc = new UpperNodeCanvas(model, controller, unitGraph, (CpsUpperNode) temp, "");
|
|
|
|
|
|
} else {
|
|
} else {
|
|
unc = new UpperNodeCanvas(model, controller, unitGraph, (CpsUpperNode) temp,
|
|
unc = new UpperNodeCanvas(model, controller, unitGraph, (CpsUpperNode) temp,
|
|
- ((UpperNodeCanvas) ((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
|
- .getComponent(0)).path + " -> ");
|
|
|
|
|
|
+ ((UpperNodeCanvas) scrollPane.getViewport().getComponent(0)).path + " -> ");
|
|
}
|
|
}
|
|
unc.setShowedInformation(canvas.getShowedInformation());
|
|
unc.setShowedInformation(canvas.getShowedInformation());
|
|
|
|
|
|
@@ -2107,13 +2054,12 @@ public class GUI<E> implements CategoryListener {
|
|
hideScrollGraph();
|
|
hideScrollGraph();
|
|
holonEleNamesDisplayed = Languages.getLanguage()[25];
|
|
holonEleNamesDisplayed = Languages.getLanguage()[25];
|
|
elementGraph.setText(holonEleNamesDisplayed);
|
|
elementGraph.setText(holonEleNamesDisplayed);
|
|
- if (tabbedPane.getMousePosition() != null) {
|
|
|
|
- tabTemp = tabbedPane;
|
|
|
|
- } else {
|
|
|
|
- tabTemp = tabbedPane2;
|
|
|
|
- }
|
|
|
|
- temp = ((UpperNodeCanvas) ((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
|
- .getComponent(0)).tempCps;
|
|
|
|
|
|
+
|
|
|
|
+ chooseTabTemp();
|
|
|
|
+
|
|
|
|
+ // TODO: look into: why MyCanvas?
|
|
|
|
+ JScrollPane scrollPane1 = getScrollPaneFromTabbedPane();
|
|
|
|
+ temp = ((UpperNodeCanvas) scrollPane1.getViewport().getComponent(0)).tempCps;
|
|
if (doubleClick() && MouseEvent.BUTTON3 != e.getButton() && temp instanceof CpsUpperNode) {
|
|
if (doubleClick() && MouseEvent.BUTTON3 != e.getButton() && temp instanceof CpsUpperNode) {
|
|
openNewUpperNodeTab();
|
|
openNewUpperNodeTab();
|
|
}
|
|
}
|
|
@@ -2194,7 +2140,82 @@ public class GUI<E> implements CategoryListener {
|
|
((UpperNodeCanvas) pane).upperNode = (CpsUpperNode) temp;
|
|
((UpperNodeCanvas) pane).upperNode = (CpsUpperNode) temp;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Removes UpperNodeTab if UpperNode was deleted
|
|
|
|
+ *
|
|
|
|
+ * @param cps the CPS object that is currently selected
|
|
|
|
+ */
|
|
|
|
+ private void removeUpperNodeTab(AbstractCpsObject cps) {
|
|
|
|
+ // TODO: hier upper node
|
|
|
|
+ if (cps instanceof CpsUpperNode) {
|
|
|
|
+ boolean splitView = false;
|
|
|
|
+ for (int i = 4; i < tabbedPane.getTabCount(); i++) {
|
|
|
|
+ if (tabbedPane.getComponentAt(i) == null) {
|
|
|
|
+ splitView = true;
|
|
|
|
+ } else if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i))
|
|
|
|
+ .getViewport().getComponent(0)).upperNode.getId() == cps.getId()) {
|
|
|
|
+ ((ButtonTabComponent) tabbedPane.getTabComponentAt(i)).removeTabs();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // If SplitView is on and the view on
|
|
|
|
+ // tabbedPane2 is the deleted upperNode
|
|
|
|
+ try {
|
|
|
|
+ if (splitView
|
|
|
|
+ && ((UpperNodeCanvas) ((JScrollPane) tabbedPane2.getSelectedComponent())
|
|
|
|
+ .getViewport().getComponent(0)).upperNode.getId() == cps.getId()) {
|
|
|
|
+ ((ButtonTabComponent) tabbedPane
|
|
|
|
+ .getTabComponentAt(tabbedPane2.getSelectedIndex())).removeTabs();
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e2) {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * chooses whether to set the tabTemp to tabbedPane or tabbedPane2
|
|
|
|
+ */
|
|
|
|
+ private void chooseTabTemp() {
|
|
|
|
+ // is the uppernode on tabbedPane or tabbedPane2
|
|
|
|
+ if (tabbedPane.getMousePosition() != null) {
|
|
|
|
+ tabTemp = tabbedPane;
|
|
|
|
+ } else {
|
|
|
|
+ tabTemp = tabbedPane2;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private JScrollPane getScrollPaneFromTabbedPane(JTabbedPane tabbedPane, int index) {
|
|
|
|
+ tabTemp = tabbedPane;
|
|
|
|
+ return getScrollPaneFromTabbedPane(index);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private JScrollPane getScrollPaneFromTabbedPane(JTabbedPane tabbedPane) {
|
|
|
|
+ return getScrollPaneFromTabbedPane(tabbedPane, -1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private JScrollPane getScrollPaneFromTabbedPane() {
|
|
|
|
+ return getScrollPaneFromTabbedPane(-1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private JScrollPane getScrollPaneFromTabbedPane(int index) {
|
|
|
|
+ Component upperLevelSelectedComponent;
|
|
|
|
+ if (index == -1) {
|
|
|
|
+ upperLevelSelectedComponent = tabTemp.getSelectedComponent();
|
|
|
|
+ } else {
|
|
|
|
+ upperLevelSelectedComponent = tabTemp.getComponentAt(index);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (upperLevelSelectedComponent instanceof JTabbedPane) {
|
|
|
|
+ return (JScrollPane) ((JTabbedPane) upperLevelSelectedComponent).getSelectedComponent();
|
|
|
|
+ } else if (upperLevelSelectedComponent instanceof JScrollPane) {
|
|
|
|
+ return (JScrollPane) upperLevelSelectedComponent;
|
|
|
|
+ } else {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|