|
@@ -26,7 +26,6 @@ import java.awt.event.MouseMotionAdapter;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.net.URI;
|
|
|
-import java.net.URISyntaxException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.ListIterator;
|
|
@@ -157,8 +156,6 @@ public class GUI {
|
|
|
// the original tabbed Pane (containing tabs for view, statistics, holon,
|
|
|
// flexibility)
|
|
|
private final JTabbedPane tabbedPaneOriginal = new JTabbedPane(JTabbedPane.TOP);
|
|
|
- // the same tabbed Pane that appears once the view is split
|
|
|
- private final JTabbedPane tabbedPaneSplit = new JTabbedPane(JTabbedPane.TOP);
|
|
|
private final JPopupMenu popmenuEdit = new JPopupMenu();
|
|
|
private final JMenuItem editItem = new JMenuItem("Edit Object");
|
|
|
private final JLabel maxGraph = new JLabel("100%");
|
|
@@ -275,7 +272,7 @@ public class GUI {
|
|
|
GUI(Control control) {
|
|
|
this.controller = control;
|
|
|
this.model = control.getModel();
|
|
|
- inspector = new Inspector(control);
|
|
|
+ inspector = new Inspector(control);
|
|
|
control.setGui(this);
|
|
|
control.calculateStateAndVisualForCurrentTimeStep();
|
|
|
this.unitGraph = new UnitGraph(model, control);
|
|
@@ -389,7 +386,7 @@ public class GUI {
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
chooseTabTemp();
|
|
|
|
|
|
- model.getSelectedCpsObjects().clear();
|
|
|
+ model.getSelectedObjects().clear();
|
|
|
|
|
|
// Uppernode Canvas?
|
|
|
JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
@@ -397,19 +394,14 @@ public class GUI {
|
|
|
|
|
|
if (canvasOrUpperNodeCanvas instanceof GroupNodeCanvas) {
|
|
|
GroupNodeCanvas uNC = (GroupNodeCanvas) canvasOrUpperNodeCanvas;
|
|
|
- for (AbstractCanvasObject cps : uNC.getGroupNode().getNodes()) {
|
|
|
- controller.addSelectedObject(cps);
|
|
|
- }
|
|
|
+ controller.addSelectedObjects(uNC.getGroupNode().getNodes());
|
|
|
uNC.repaint();
|
|
|
// or Canvas?
|
|
|
} else if (canvasOrUpperNodeCanvas instanceof Canvas) {
|
|
|
- for (AbstractCanvasObject cps : model.getObjectsOnCanvas()) {
|
|
|
- controller.addSelectedObject(cps);
|
|
|
- }
|
|
|
+ controller.addSelectedObjects(model.getObjectsOnCanvas());
|
|
|
canvas.repaint();
|
|
|
}
|
|
|
controller.getObjectsInDepth();
|
|
|
-
|
|
|
}
|
|
|
};
|
|
|
actionMap.put(cntrlADown, controlA);
|
|
@@ -434,7 +426,7 @@ public class GUI {
|
|
|
|
|
|
if (canvasOrUpperNodeCanvas instanceof GroupNodeCanvas) {
|
|
|
GroupNodeCanvas uNC = (GroupNodeCanvas) canvasOrUpperNodeCanvas;
|
|
|
- for (AbstractCanvasObject cps : model.getSelectedCpsObjects()) {
|
|
|
+ for (AbstractCanvasObject cps : model.getSelectedObjects()) {
|
|
|
if (uNC.getGroupNode().getNodes().contains(cps)) {
|
|
|
controller.delObjUpperNode(cps, uNC.getGroupNode());
|
|
|
unc.setToolTip(false);
|
|
@@ -444,26 +436,24 @@ public class GUI {
|
|
|
}
|
|
|
}
|
|
|
uNC.repaint();
|
|
|
+ controller.clearSelection();
|
|
|
|
|
|
// or Canvas?
|
|
|
} else if (canvasOrUpperNodeCanvas instanceof Canvas) {
|
|
|
- boolean save = false;
|
|
|
// Edge Deleting
|
|
|
Edge edgeHighlight = model.getSelectedEdge();
|
|
|
if (edgeHighlight != null) {
|
|
|
controller.removeEdgesOnCanvas(edgeHighlight);
|
|
|
((Canvas) canvasOrUpperNodeCanvas).edgeHighlight = null;
|
|
|
}
|
|
|
- for (int j = 0; j < model.getSelectedCpsObjects().size(); j++) {
|
|
|
- AbstractCanvasObject cps = model.getSelectedCpsObjects().get(j);
|
|
|
- if (j < model.getSelectedCpsObjects().size() - 1)
|
|
|
- save = true;
|
|
|
- controller.delCanvasObject(cps, save);
|
|
|
- canvas.setToolTip(false);
|
|
|
-
|
|
|
+ canvas.setToolTip(false);
|
|
|
+ for (AbstractCanvasObject cps : model.getSelectedObjects()) {
|
|
|
+ controller.delCanvasObject(cps, false);
|
|
|
// remove UpperNodeTab if UpperNode deleted
|
|
|
removeUpperNodeTab(cps);
|
|
|
}
|
|
|
+ controller.clearSelection();
|
|
|
+ controller.tryAutoSave();
|
|
|
canvas.repaint();
|
|
|
}
|
|
|
|
|
@@ -473,7 +463,7 @@ public class GUI {
|
|
|
controller.calculateStateAndVisualForCurrentTimeStep();
|
|
|
}
|
|
|
|
|
|
- model.getSelectedCpsObjects().clear();
|
|
|
+ model.getSelectedObjects().clear();
|
|
|
hideScrollGraph();
|
|
|
}
|
|
|
});
|
|
@@ -502,7 +492,7 @@ public class GUI {
|
|
|
chooseTabTemp();
|
|
|
System.out.println("heiCopy - control C");
|
|
|
JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
|
- if (!model.getSelectedCpsObjects().isEmpty()) {
|
|
|
+ if (!model.getSelectedObjects().isEmpty()) {
|
|
|
if (scrollPane.getViewport().getComponent(0) instanceof GroupNodeCanvas)
|
|
|
controller.copy(((GroupNodeCanvas) scrollPane.getViewport().getComponent(0)).getGroupNode());
|
|
|
else
|
|
@@ -527,9 +517,6 @@ public class GUI {
|
|
|
if (tabbedPaneOriginal.getMousePosition() != null) {
|
|
|
tabTemp = tabbedPaneOriginal;
|
|
|
} else {
|
|
|
- if (!initSplit) {
|
|
|
- tabTemp = tabbedPaneSplit;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
if (tabTemp == null)
|
|
@@ -565,9 +552,8 @@ public class GUI {
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
chooseTabTemp();
|
|
|
-
|
|
|
JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
|
- if (!model.getSelectedCpsObjects().isEmpty()) {
|
|
|
+ if (!model.getSelectedObjects().isEmpty()) {
|
|
|
if (scrollPane.getViewport().getComponent(0) instanceof GroupNodeCanvas) {
|
|
|
controller.cut(((GroupNodeCanvas) scrollPane.getViewport().getComponent(0)).getGroupNode());
|
|
|
controller.calculateStateAndVisualForCurrentTimeStep();
|
|
@@ -701,6 +687,9 @@ public class GUI {
|
|
|
popUp.setVisible(true);
|
|
|
});
|
|
|
|
|
|
+ tabbedPaneInnerOriginal.addChangeListener(change -> {
|
|
|
+ controller.clearSelection();
|
|
|
+ });
|
|
|
mnNewMenuView.add(mntmCanvasSize);
|
|
|
|
|
|
/*
|
|
@@ -754,44 +743,6 @@ public class GUI {
|
|
|
mnHelp.add(mntmCodeDoc);
|
|
|
mnHelp.add(mntmAboutUs);
|
|
|
|
|
|
- tabbedPaneOriginal.addChangeListener(changeEvent -> {
|
|
|
- if (tabbedPaneOriginal.getSelectedComponent() == null) {
|
|
|
- Component tempC = tabbedPaneSplit.getSelectedComponent();
|
|
|
- tabbedPaneSplit.setComponentAt(tabbedPaneOriginal.getSelectedIndex(), null);
|
|
|
- tabbedPaneOriginal.setComponentAt(tabbedPaneOriginal.getSelectedIndex(), tempC);
|
|
|
- tempC = tabbedPaneOriginal.getComponentAt(
|
|
|
- (tabbedPaneOriginal.getSelectedIndex() + 1) % (tabbedPaneOriginal.getTabCount()));
|
|
|
- tabbedPaneOriginal.setComponentAt(
|
|
|
- (tabbedPaneOriginal.getSelectedIndex() + 1) % (tabbedPaneOriginal.getTabCount()), null);
|
|
|
- tabbedPaneSplit.setComponentAt(
|
|
|
- (tabbedPaneOriginal.getSelectedIndex() + 1) % (tabbedPaneOriginal.getTabCount()), tempC);
|
|
|
- tabbedPaneSplit.setSelectedIndex(
|
|
|
- (tabbedPaneOriginal.getSelectedIndex() + 1) % (tabbedPaneOriginal.getTabCount()));
|
|
|
- contentPane.updateUI();
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- tabbedPaneSplit.addChangeListener(changeEvent -> {
|
|
|
- if (tabbedPaneSplit.getSelectedComponent() == null && !initSplit) {
|
|
|
- Component tempC = tabbedPaneOriginal.getComponentAt(tabbedPaneSplit.getSelectedIndex());
|
|
|
- tabbedPaneOriginal.setComponentAt(tabbedPaneSplit.getSelectedIndex(), null);
|
|
|
- tabbedPaneSplit.setComponentAt(tabbedPaneSplit.getSelectedIndex(), tempC);
|
|
|
-
|
|
|
- for (int i = 0; i < tabbedPaneOriginal.getTabCount(); i++) {
|
|
|
- if (tabbedPaneSplit.getComponentAt(i) != null && tabbedPaneSplit.getComponentAt(i) != tempC) {
|
|
|
- tempC = tabbedPaneSplit.getComponentAt(i);
|
|
|
- tabbedPaneSplit.setComponentAt(i, null);
|
|
|
- tabbedPaneOriginal.setComponentAt(i, tempC);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (tabbedPaneOriginal.getSelectedIndex() == tabbedPaneSplit.getSelectedIndex()) {
|
|
|
- tabbedPaneOriginal.setSelectedIndex(
|
|
|
- (tabbedPaneSplit.getSelectedIndex() + 1) % tabbedPaneOriginal.getTabCount());
|
|
|
- }
|
|
|
- contentPane.updateUI();
|
|
|
- }
|
|
|
- });
|
|
|
canvas.setBackground(Color.WHITE);
|
|
|
canvas.setPreferredSize(new Dimension(model.getCanvasX(), model.getCanvasY()));
|
|
|
/********************
|
|
@@ -854,7 +805,7 @@ public class GUI {
|
|
|
* Add HolonElement to given HolonObject
|
|
|
*/
|
|
|
btnAddHolEL.addActionListener(actionEvent -> {
|
|
|
- if (model.getSelectedCpsObjects().size() == 1) {
|
|
|
+ if (model.getSelectedObjects().size() == 1) {
|
|
|
AbstractCanvasObject tempCpsObject = updCon.getActualCps();
|
|
|
if (tempCpsObject != null && tempCpsObject.getClass() == HolonObject.class
|
|
|
&& tempCpsObject.getId() != 0) {
|
|
@@ -863,8 +814,8 @@ public class GUI {
|
|
|
addElementPopUp.setVisible(true);
|
|
|
HolonElement ele = addElementPopUp.getElement();
|
|
|
if (ele != null) {
|
|
|
- controller.addElementCanvasObject(tempCpsObject.getId(), ele.getEleName(), ele.getAmount(),
|
|
|
- ele.getEnergyPerElement(), ele.getId());
|
|
|
+ controller.addElementCanvasObject(tempCpsObject.getId(), ele.getEleName(), ele.getEnergy(),
|
|
|
+ ele.getId());
|
|
|
}
|
|
|
controller.calculateStateAndVisualForTimeStep(model.getCurIteration());
|
|
|
triggerUpdateController(null);
|
|
@@ -884,7 +835,7 @@ public class GUI {
|
|
|
*/
|
|
|
btnDelHolEL.addActionListener(actionEvent -> {
|
|
|
// For Single Selection of CpsObject
|
|
|
- if (model.getSelectedCpsObjects().size() == 1) {
|
|
|
+ if (model.getSelectedObjects().size() == 1) {
|
|
|
if (updCon.getActualCps().getClass() == HolonObject.class) {
|
|
|
HolonObject obj = (HolonObject) updCon.getActualCps();
|
|
|
if (selectedElements.isEmpty()) {
|
|
@@ -894,7 +845,7 @@ public class GUI {
|
|
|
}
|
|
|
for (HolonElement e : selectedElements) {
|
|
|
controller.deleteElementCanvas(obj.getId(), e.getId());
|
|
|
- controller.calculateStateAndVisualForTimeStep(model.getCurIteration());
|
|
|
+ controller.calculateStateAndVisualForCurrentTimeStep();
|
|
|
triggerUpdateController(null);
|
|
|
contentPane.updateUI();
|
|
|
// Names displayed in graph are not updated
|
|
@@ -903,7 +854,7 @@ public class GUI {
|
|
|
selectedElements.clear();
|
|
|
}
|
|
|
// For MultiSelection of CpsObject
|
|
|
- } else if (model.getSelectedCpsObjects().size() > 1) {
|
|
|
+ } else if (model.getSelectedObjects().size() > 1) {
|
|
|
for (Integer i : model.getEleToDelete().keySet()) {
|
|
|
for (HolonElement e : model.getEleToDelete().get(i)) {
|
|
|
controller.deleteElementCanvas(i, e.getId());
|
|
@@ -974,7 +925,7 @@ public class GUI {
|
|
|
if (leaf) {
|
|
|
for (Category cat : model.getCategories()) {
|
|
|
for (AbstractCanvasObject cps : cat.getObjects()) {
|
|
|
- if (value.toString().compareTo(cps.getObjName()) == 0) {
|
|
|
+ if (value.toString().compareTo(cps.getName()) == 0) {
|
|
|
imgR = ImageImport.loadImage(cps.getImage(), 50, 50);
|
|
|
if (imgR != null) {
|
|
|
label.setIcon(new ImageIcon(imgR));
|
|
@@ -1091,35 +1042,31 @@ public class GUI {
|
|
|
int x = (int) unc.getMousePosition().getX() + 16;
|
|
|
int y = (int) unc.getMousePosition().getY() + 16;
|
|
|
|
|
|
- if (x > unc.getGroupNode().getLeftBorder()) {
|
|
|
-
|
|
|
- AbstractCanvasObject h = null;
|
|
|
- if (tempCps instanceof HolonObject) {
|
|
|
- h = new HolonObject((HolonObject) tempCps);
|
|
|
- }
|
|
|
- if (tempCps instanceof HolonSwitch) {
|
|
|
- h = new HolonSwitch(tempCps);
|
|
|
- }
|
|
|
- h.setPosition(x, y);
|
|
|
+ AbstractCanvasObject h = null;
|
|
|
+ if (tempCps instanceof HolonObject) {
|
|
|
+ h = new HolonObject((HolonObject) tempCps);
|
|
|
+ }
|
|
|
+ if (tempCps instanceof HolonSwitch) {
|
|
|
+ h = new HolonSwitch(tempCps);
|
|
|
+ }
|
|
|
+ h.setPosition(x, y);
|
|
|
|
|
|
- /**
|
|
|
- * close UpperNodeTabs of replaced UpperNode
|
|
|
- */
|
|
|
- if (unc.mayBeReplaced != null && unc.mayBeReplaced instanceof GroupNode) {
|
|
|
- unc.closeUpperNodeTab(unc.mayBeReplaced.getId());
|
|
|
- }
|
|
|
- controller.addObjUpperNode(h, unc.getGroupNode());
|
|
|
-
|
|
|
- /**
|
|
|
- * object would be replaced
|
|
|
- */
|
|
|
- unc.mayBeReplaced = null;
|
|
|
- unc.invalidate();
|
|
|
- controller.calculateStateAndVisualForCurrentTimeStep();
|
|
|
- unc.repaint();
|
|
|
- unc.setXY((int) canvas.getMousePosition().getX(),
|
|
|
- (int) canvas.getMousePosition().getY());
|
|
|
+ /**
|
|
|
+ * close UpperNodeTabs of replaced UpperNode
|
|
|
+ */
|
|
|
+ if (unc.mayBeReplaced != null && unc.mayBeReplaced instanceof GroupNode) {
|
|
|
+ unc.closeUpperNodeTab(unc.mayBeReplaced.getId());
|
|
|
}
|
|
|
+ controller.addObjUpperNode(h, unc.getGroupNode());
|
|
|
+
|
|
|
+ /**
|
|
|
+ * object would be replaced
|
|
|
+ */
|
|
|
+ unc.mayBeReplaced = null;
|
|
|
+ unc.invalidate();
|
|
|
+ controller.calculateStateAndVisualForCurrentTimeStep();
|
|
|
+ unc.repaint();
|
|
|
+ unc.setXY((int) canvas.getMousePosition().getX(), (int) canvas.getMousePosition().getY());
|
|
|
} else {
|
|
|
int x = (int) canvas.getMousePosition().getX() + 16;
|
|
|
int y = (int) canvas.getMousePosition().getY() + 16;
|
|
@@ -1189,7 +1136,7 @@ public class GUI {
|
|
|
if (SwingUtilities.isRightMouseButton(e)) {
|
|
|
for (Category cat : model.getCategories()) {
|
|
|
for (AbstractCanvasObject cps : cat.getObjects()) {
|
|
|
- if (actualObjectClicked.compareTo(cps.getObjName()) == 0
|
|
|
+ if (actualObjectClicked.compareTo(cps.getName()) == 0
|
|
|
&& !(cps instanceof HolonSwitch)) {
|
|
|
editItem.setEnabled(true);
|
|
|
popmenuEdit.show(e.getComponent(), e.getX(), e.getY());
|
|
@@ -1201,7 +1148,7 @@ public class GUI {
|
|
|
} else {
|
|
|
for (Category cat : model.getCategories()) {
|
|
|
for (AbstractCanvasObject cps : cat.getObjects()) {
|
|
|
- if (actualObjectClicked.compareTo(cps.getObjName()) == 0) {
|
|
|
+ if (actualObjectClicked.compareTo(cps.getName()) == 0) {
|
|
|
File checkPath = new File(cps.getImage());
|
|
|
if (checkPath.exists()) {
|
|
|
img = new ImageIcon(cps.getImage()).getImage().getScaledInstance(32, 32,
|
|
@@ -1323,61 +1270,6 @@ public class GUI {
|
|
|
aboutUsPopUp.setVisible(true);
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
- /**
|
|
|
- * Update of every interaction between the user and the canvas (only on the
|
|
|
- * canvas). Basically the update of all the information concerning the clicked
|
|
|
- * HolonObject. For multi-selection, the propertyTable would be disabled
|
|
|
- */
|
|
|
- canvas.addMouseListener(new MouseAdapter() {
|
|
|
- @Override
|
|
|
- public void mousePressed(MouseEvent e) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void mouseReleased(MouseEvent e) {
|
|
|
- holonEleNamesDisplayed = "None";
|
|
|
- // If any empty space is clicked
|
|
|
- if (temp == null || temp.getId() != model.getSelectedObjectID()) {
|
|
|
- hideScrollGraph();
|
|
|
- elementGraph.setText("None");
|
|
|
- }
|
|
|
- temp = updCon.getActualCps();
|
|
|
- // Erase old data in the PropertyTable
|
|
|
- if (model.getPropertyTable().getRowCount() > 0) {
|
|
|
- for (int i = model.getPropertyTable().getRowCount() - 1; i > -1; i--) {
|
|
|
- model.getPropertyTable().removeRow(i);
|
|
|
- }
|
|
|
- }
|
|
|
- if (e.isControlDown() && temp != null) {
|
|
|
- if (model.getSelectedCpsObjects().contains(temp)) {
|
|
|
- controller.deleteSelectedObject(temp);
|
|
|
- } else {
|
|
|
- controller.addSelectedObject(temp);
|
|
|
- }
|
|
|
- }
|
|
|
- if (temp instanceof HolonSwitch) {
|
|
|
- showScrollGraph();
|
|
|
- updateUnitGraph((GraphEditable) temp);
|
|
|
- }
|
|
|
- // Write new data in the PropertyTable
|
|
|
- triggerUpdateController(temp);
|
|
|
-
|
|
|
- // New Tab with NodeOfNode
|
|
|
- if (doubleClick() && MouseEvent.BUTTON3 != e.getButton() && temp instanceof GroupNode) {
|
|
|
- openNewUpperNodeTab();
|
|
|
- try {
|
|
|
- controller.autoSave();
|
|
|
- } catch (IOException e1) {
|
|
|
- e1.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
// Del Button
|
|
|
btnDel.addActionListener(actionEvent -> {
|
|
|
Object nodeInfo = categoryTree.getLastSelectedPathComponent();
|
|
@@ -1429,9 +1321,10 @@ public class GUI {
|
|
|
while (tabbedPaneInnerOriginal.getTabCount() > 1) {
|
|
|
tabbedPaneInnerOriginal.remove(1);
|
|
|
}
|
|
|
- model.getSelectedCpsObjects().clear();
|
|
|
- model.getEdgesOnCanvas().removeAll(model.getEdgesOnCanvas());
|
|
|
- model.getObjectsOnCanvas().removeAll(model.getObjectsOnCanvas());
|
|
|
+ controller.clearSelection();
|
|
|
+ model.getEdgesOnCanvas().clear();
|
|
|
+ model.getObjectsOnCanvas().clear();
|
|
|
+ controller.OnSelectionChanged.broadcast();
|
|
|
controller.setSelectedObjectID(0);
|
|
|
controller.setSelecteEdge(null);
|
|
|
controller.setCurIteration(0);
|
|
@@ -1463,7 +1356,7 @@ public class GUI {
|
|
|
while (tabbedPaneInnerOriginal.getTabCount() > 1) {
|
|
|
tabbedPaneInnerOriginal.remove(1);
|
|
|
}
|
|
|
- model.getSelectedCpsObjects().clear();
|
|
|
+ model.getSelectedObjects().clear();
|
|
|
controller.loadFile(file.getAbsolutePath());
|
|
|
canvas.repaint();
|
|
|
categoryTree.repaint();
|
|
@@ -1770,7 +1663,7 @@ public class GUI {
|
|
|
node1 = new DefaultMutableTreeNode(c.getName());
|
|
|
|
|
|
for (AbstractCanvasObject obj : c.getObjects()) {
|
|
|
- node1.add(new DefaultMutableTreeNode(obj.getObjName()));
|
|
|
+ node1.add(new DefaultMutableTreeNode(obj.getName()));
|
|
|
}
|
|
|
add(node1);
|
|
|
}
|
|
@@ -1820,16 +1713,16 @@ public class GUI {
|
|
|
/*
|
|
|
* Open a new Tab with an UpperNodeCanvas
|
|
|
*/
|
|
|
- private void openNewUpperNodeTab() {
|
|
|
+ public void openNewUpperNodeTab(GroupNode node) {
|
|
|
chooseTabTemp();
|
|
|
|
|
|
JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
|
if (scrollPane.getViewport().getComponent(0) instanceof Canvas) {
|
|
|
- unc = new GroupNodeCanvas(model, controller, unitGraph, (GroupNode) temp, "",
|
|
|
+ unc = new GroupNodeCanvas(model, controller, unitGraph, node, "",
|
|
|
scrollPane.getViewport().getComponent(0));
|
|
|
|
|
|
} else {
|
|
|
- unc = new GroupNodeCanvas(model, controller, unitGraph, (GroupNode) temp,
|
|
|
+ unc = new GroupNodeCanvas(model, controller, unitGraph, node,
|
|
|
((GroupNodeCanvas) scrollPane.getViewport().getComponent(0)).getParentPath() + " -> ",
|
|
|
scrollPane.getViewport().getComponent(0));
|
|
|
}
|
|
@@ -1840,7 +1733,7 @@ public class GUI {
|
|
|
for (int i = 1; i < tabbedPaneInnerOriginal.getTabCount(); i++) {
|
|
|
JScrollPane paneOriginal = (JScrollPane) tabbedPaneInnerOriginal.getComponentAt(i);
|
|
|
if (paneOriginal != null && ((GroupNodeCanvas) paneOriginal.getViewport().getComponent(0)).getGroupNode()
|
|
|
- .getId() == temp.getId()) {
|
|
|
+ .getId() == node.getId()) {
|
|
|
dupl = true;
|
|
|
// set selected component to view
|
|
|
tabbedPaneOriginal.setSelectedComponent(tabbedPaneInnerOriginal);
|
|
@@ -1848,80 +1741,27 @@ public class GUI {
|
|
|
tabbedPaneInnerOriginal.setSelectedComponent(tabbedPaneInnerOriginal.getComponentAt(i));
|
|
|
}
|
|
|
|
|
|
- if (tabbedPaneSplit.getTabCount() > 0) {
|
|
|
- JTabbedPane tabbedPaneInnerSplit = (JTabbedPane) tabbedPaneSplit.getComponentAt(0);
|
|
|
- if (tabbedPaneInnerSplit != null) {
|
|
|
- JScrollPane paneSplit = (JScrollPane) tabbedPaneInnerSplit.getComponentAt(i);
|
|
|
- if (!initSplit && paneSplit != null && ((GroupNodeCanvas) paneSplit.getViewport().getComponent(0))
|
|
|
- .getGroupNode().getId() == temp.getId()) {
|
|
|
- dupl = true;
|
|
|
- // set selected component to view
|
|
|
- tabbedPaneSplit.setSelectedComponent(tabbedPaneInnerSplit);
|
|
|
- // set selected tab in view to found upper-node-canvas
|
|
|
- tabbedPaneInnerSplit.setSelectedComponent(tabbedPaneInnerSplit.getComponentAt(i));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
// if we found a duplicate, break
|
|
|
if (dupl) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (!dupl) {
|
|
|
- unc.setBorder(null);
|
|
|
- unc.setBackground(Color.WHITE);
|
|
|
- unc.setPreferredSize(new Dimension(model.getCanvasX(), model.getCanvasY()));
|
|
|
-
|
|
|
- unc.addMouseListener(new MouseAdapter() {
|
|
|
- @Override
|
|
|
- public void mousePressed(MouseEvent e) {
|
|
|
- hideScrollGraph();
|
|
|
- holonEleNamesDisplayed = "None";
|
|
|
- elementGraph.setText(holonEleNamesDisplayed);
|
|
|
-
|
|
|
- chooseTabTemp();
|
|
|
-
|
|
|
- JScrollPane scrollPane1 = getScrollPaneFromTabbedPane();
|
|
|
- temp = ((GroupNodeCanvas) scrollPane1.getViewport().getComponent(0)).tempCps;
|
|
|
- if (doubleClick() && MouseEvent.BUTTON3 != e.getButton() && temp instanceof GroupNode) {
|
|
|
- openNewUpperNodeTab();
|
|
|
- }
|
|
|
- if (temp instanceof HolonSwitch) {
|
|
|
- updateUnitGraph((GraphEditable) temp);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
JScrollPane sp = new JScrollPane(unc);
|
|
|
sp.setBorder(null);
|
|
|
|
|
|
// Selected tabbed Pane = tabbedPaneOriginal or tabbedPaneSplit
|
|
|
if (tabTemp == tabbedPaneOriginal) {
|
|
|
- this.tabbedPaneInnerOriginal.add(temp.getName(), sp);
|
|
|
+ this.tabbedPaneInnerOriginal.add(node.getName(), sp);
|
|
|
this.tabbedPaneInnerOriginal.setSelectedComponent(sp);
|
|
|
this.tabbedPaneInnerOriginal.setTabComponentAt(this.tabbedPaneInnerOriginal.getTabCount() - 1,
|
|
|
- new ButtonTabComponent(this.tabbedPaneInnerOriginal, tabbedPaneSplit));
|
|
|
+ new ButtonTabComponent(this.tabbedPaneInnerOriginal));
|
|
|
|
|
|
- } else {
|
|
|
- JTabbedPane tabbedPaneInnerSplit = (JTabbedPane) tabbedPaneSplit.getComponentAt(0);
|
|
|
- tabbedPaneInnerSplit.add(temp.getName(), sp);
|
|
|
- Component tempC = tabbedPaneInnerSplit.getSelectedComponent();
|
|
|
- tabbedPaneInnerSplit.setComponentAt(tabbedPaneInnerSplit.getSelectedIndex(), null);
|
|
|
- tabbedPaneOriginal.setComponentAt(tabbedPaneInnerSplit.getSelectedIndex(), tempC);
|
|
|
- tabbedPaneInnerSplit.setSelectedComponent(sp);
|
|
|
-
|
|
|
- tabbedPaneInnerOriginal.add(temp.getName(), null);
|
|
|
- tabbedPaneInnerOriginal.setTabComponentAt(tabbedPaneInnerOriginal.getTabCount() - 1,
|
|
|
- new ButtonTabComponent(tabbedPaneInnerOriginal, tabbedPaneInnerSplit));
|
|
|
}
|
|
|
-
|
|
|
- temp = null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // TODO remove me
|
|
|
+ // TODO refactor tabbedPane and access to groupNodeViews
|
|
|
private void updateUpperNodes() {
|
|
|
for (Component c : tabbedPaneInnerOriginal.getComponents()) {
|
|
|
if (!(c instanceof JScrollPane)) {
|
|
@@ -1942,29 +1782,16 @@ public class GUI {
|
|
|
*/
|
|
|
private void removeUpperNodeTab(AbstractCanvasObject cps) {
|
|
|
if (cps instanceof GroupNode) {
|
|
|
- boolean splitView = false;
|
|
|
for (int i = 1; i < tabbedPaneInnerOriginal.getTabCount(); i++) {
|
|
|
JScrollPane scrollPaneOriginal = (JScrollPane) tabbedPaneInnerOriginal.getComponentAt(i);
|
|
|
|
|
|
if (scrollPaneOriginal == null) {
|
|
|
- splitView = true;
|
|
|
} else if (((GroupNodeCanvas) scrollPaneOriginal.getViewport().getComponent(0)).getGroupNode()
|
|
|
.getId() == cps.getId()) {
|
|
|
((ButtonTabComponent) tabbedPaneInnerOriginal.getTabComponentAt(i)).removeTabs();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- // If SplitView is on and the view on
|
|
|
- // tabbedPaneSplit is the deleted upperNode
|
|
|
- if (splitView && tabbedPaneSplit.getComponentCount() > 0) {
|
|
|
- JTabbedPane tabbedPaneInnerSplit = (JTabbedPane) tabbedPaneSplit.getComponentAt(0);
|
|
|
-
|
|
|
- if (((GroupNodeCanvas) ((JScrollPane) tabbedPaneInnerSplit.getSelectedComponent()).getViewport()
|
|
|
- .getComponent(0)).getGroupNode().getId() == cps.getId()) {
|
|
|
- ((ButtonTabComponent) tabbedPaneInnerOriginal
|
|
|
- .getTabComponentAt(tabbedPaneInnerSplit.getSelectedIndex())).removeTabs();
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1972,7 +1799,7 @@ public class GUI {
|
|
|
* chooses whether to set the tabTemp to tabbedPaneOriginal or tabbedPaneSplit
|
|
|
*/
|
|
|
private void chooseTabTemp() {
|
|
|
- // TODO Remove me when not needed
|
|
|
+ // TODO Remove tabTabbed
|
|
|
tabTemp = tabbedPaneOriginal;
|
|
|
}
|
|
|
|
|
@@ -2011,7 +1838,6 @@ public class GUI {
|
|
|
if (temp != null) {
|
|
|
updCon.paintProperties(temp);
|
|
|
}
|
|
|
- updCon.refreshTableHolonElement(model.getMultiTable(), model.getSingleTable());
|
|
|
updCon.refreshTableProperties(model.getPropertyTable());
|
|
|
}
|
|
|
|