|
@@ -26,7 +26,6 @@ import java.awt.event.MouseMotionAdapter;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.net.URI;
|
|
import java.net.URI;
|
|
-import java.net.URISyntaxException;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.ListIterator;
|
|
import java.util.ListIterator;
|
|
@@ -157,8 +156,6 @@ public class GUI {
|
|
// the original tabbed Pane (containing tabs for view, statistics, holon,
|
|
// the original tabbed Pane (containing tabs for view, statistics, holon,
|
|
// flexibility)
|
|
// flexibility)
|
|
private final JTabbedPane tabbedPaneOriginal = new JTabbedPane(JTabbedPane.TOP);
|
|
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 JPopupMenu popmenuEdit = new JPopupMenu();
|
|
private final JMenuItem editItem = new JMenuItem("Edit Object");
|
|
private final JMenuItem editItem = new JMenuItem("Edit Object");
|
|
private final JLabel maxGraph = new JLabel("100%");
|
|
private final JLabel maxGraph = new JLabel("100%");
|
|
@@ -275,7 +272,7 @@ public class GUI {
|
|
GUI(Control control) {
|
|
GUI(Control control) {
|
|
this.controller = control;
|
|
this.controller = control;
|
|
this.model = control.getModel();
|
|
this.model = control.getModel();
|
|
- inspector = new Inspector(control);
|
|
|
|
|
|
+ inspector = new Inspector(control);
|
|
control.setGui(this);
|
|
control.setGui(this);
|
|
control.calculateStateAndVisualForCurrentTimeStep();
|
|
control.calculateStateAndVisualForCurrentTimeStep();
|
|
this.unitGraph = new UnitGraph(model, control);
|
|
this.unitGraph = new UnitGraph(model, control);
|
|
@@ -389,7 +386,7 @@ public class GUI {
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
chooseTabTemp();
|
|
chooseTabTemp();
|
|
|
|
|
|
- model.getSelectedCpsObjects().clear();
|
|
|
|
|
|
+ model.getSelectedObjects().clear();
|
|
|
|
|
|
// Uppernode Canvas?
|
|
// Uppernode Canvas?
|
|
JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
@@ -397,19 +394,14 @@ public class GUI {
|
|
|
|
|
|
if (canvasOrUpperNodeCanvas instanceof GroupNodeCanvas) {
|
|
if (canvasOrUpperNodeCanvas instanceof GroupNodeCanvas) {
|
|
GroupNodeCanvas uNC = (GroupNodeCanvas) canvasOrUpperNodeCanvas;
|
|
GroupNodeCanvas uNC = (GroupNodeCanvas) canvasOrUpperNodeCanvas;
|
|
- for (AbstractCanvasObject cps : uNC.getGroupNode().getNodes()) {
|
|
|
|
- controller.addSelectedObject(cps);
|
|
|
|
- }
|
|
|
|
|
|
+ controller.addSelectedObjects(uNC.getGroupNode().getNodes());
|
|
uNC.repaint();
|
|
uNC.repaint();
|
|
// or Canvas?
|
|
// or Canvas?
|
|
} else if (canvasOrUpperNodeCanvas instanceof Canvas) {
|
|
} else if (canvasOrUpperNodeCanvas instanceof Canvas) {
|
|
- for (AbstractCanvasObject cps : model.getObjectsOnCanvas()) {
|
|
|
|
- controller.addSelectedObject(cps);
|
|
|
|
- }
|
|
|
|
|
|
+ controller.addSelectedObjects(model.getObjectsOnCanvas());
|
|
canvas.repaint();
|
|
canvas.repaint();
|
|
}
|
|
}
|
|
controller.getObjectsInDepth();
|
|
controller.getObjectsInDepth();
|
|
-
|
|
|
|
}
|
|
}
|
|
};
|
|
};
|
|
actionMap.put(cntrlADown, controlA);
|
|
actionMap.put(cntrlADown, controlA);
|
|
@@ -434,7 +426,7 @@ public class GUI {
|
|
|
|
|
|
if (canvasOrUpperNodeCanvas instanceof GroupNodeCanvas) {
|
|
if (canvasOrUpperNodeCanvas instanceof GroupNodeCanvas) {
|
|
GroupNodeCanvas uNC = (GroupNodeCanvas) canvasOrUpperNodeCanvas;
|
|
GroupNodeCanvas uNC = (GroupNodeCanvas) canvasOrUpperNodeCanvas;
|
|
- for (AbstractCanvasObject cps : model.getSelectedCpsObjects()) {
|
|
|
|
|
|
+ for (AbstractCanvasObject cps : model.getSelectedObjects()) {
|
|
if (uNC.getGroupNode().getNodes().contains(cps)) {
|
|
if (uNC.getGroupNode().getNodes().contains(cps)) {
|
|
controller.delObjUpperNode(cps, uNC.getGroupNode());
|
|
controller.delObjUpperNode(cps, uNC.getGroupNode());
|
|
unc.setToolTip(false);
|
|
unc.setToolTip(false);
|
|
@@ -444,26 +436,24 @@ public class GUI {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
uNC.repaint();
|
|
uNC.repaint();
|
|
|
|
+ controller.clearSelection();
|
|
|
|
|
|
// or Canvas?
|
|
// or Canvas?
|
|
} else if (canvasOrUpperNodeCanvas instanceof Canvas) {
|
|
} else if (canvasOrUpperNodeCanvas instanceof Canvas) {
|
|
- boolean save = false;
|
|
|
|
// Edge Deleting
|
|
// Edge Deleting
|
|
Edge edgeHighlight = model.getSelectedEdge();
|
|
Edge edgeHighlight = model.getSelectedEdge();
|
|
if (edgeHighlight != null) {
|
|
if (edgeHighlight != null) {
|
|
controller.removeEdgesOnCanvas(edgeHighlight);
|
|
controller.removeEdgesOnCanvas(edgeHighlight);
|
|
((Canvas) canvasOrUpperNodeCanvas).edgeHighlight = null;
|
|
((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
|
|
// remove UpperNodeTab if UpperNode deleted
|
|
removeUpperNodeTab(cps);
|
|
removeUpperNodeTab(cps);
|
|
}
|
|
}
|
|
|
|
+ controller.clearSelection();
|
|
|
|
+ controller.tryAutoSave();
|
|
canvas.repaint();
|
|
canvas.repaint();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -473,7 +463,7 @@ public class GUI {
|
|
controller.calculateStateAndVisualForCurrentTimeStep();
|
|
controller.calculateStateAndVisualForCurrentTimeStep();
|
|
}
|
|
}
|
|
|
|
|
|
- model.getSelectedCpsObjects().clear();
|
|
|
|
|
|
+ model.getSelectedObjects().clear();
|
|
hideScrollGraph();
|
|
hideScrollGraph();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -502,7 +492,7 @@ public class GUI {
|
|
chooseTabTemp();
|
|
chooseTabTemp();
|
|
System.out.println("heiCopy - control C");
|
|
System.out.println("heiCopy - control C");
|
|
JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
- if (!model.getSelectedCpsObjects().isEmpty()) {
|
|
|
|
|
|
+ if (!model.getSelectedObjects().isEmpty()) {
|
|
if (scrollPane.getViewport().getComponent(0) instanceof GroupNodeCanvas)
|
|
if (scrollPane.getViewport().getComponent(0) instanceof GroupNodeCanvas)
|
|
controller.copy(((GroupNodeCanvas) scrollPane.getViewport().getComponent(0)).getGroupNode());
|
|
controller.copy(((GroupNodeCanvas) scrollPane.getViewport().getComponent(0)).getGroupNode());
|
|
else
|
|
else
|
|
@@ -527,9 +517,6 @@ public class GUI {
|
|
if (tabbedPaneOriginal.getMousePosition() != null) {
|
|
if (tabbedPaneOriginal.getMousePosition() != null) {
|
|
tabTemp = tabbedPaneOriginal;
|
|
tabTemp = tabbedPaneOriginal;
|
|
} else {
|
|
} else {
|
|
- if (!initSplit) {
|
|
|
|
- tabTemp = tabbedPaneSplit;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
if (tabTemp == null)
|
|
if (tabTemp == null)
|
|
@@ -565,9 +552,8 @@ public class GUI {
|
|
@Override
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
chooseTabTemp();
|
|
chooseTabTemp();
|
|
-
|
|
|
|
JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
- if (!model.getSelectedCpsObjects().isEmpty()) {
|
|
|
|
|
|
+ if (!model.getSelectedObjects().isEmpty()) {
|
|
if (scrollPane.getViewport().getComponent(0) instanceof GroupNodeCanvas) {
|
|
if (scrollPane.getViewport().getComponent(0) instanceof GroupNodeCanvas) {
|
|
controller.cut(((GroupNodeCanvas) scrollPane.getViewport().getComponent(0)).getGroupNode());
|
|
controller.cut(((GroupNodeCanvas) scrollPane.getViewport().getComponent(0)).getGroupNode());
|
|
controller.calculateStateAndVisualForCurrentTimeStep();
|
|
controller.calculateStateAndVisualForCurrentTimeStep();
|
|
@@ -701,6 +687,9 @@ public class GUI {
|
|
popUp.setVisible(true);
|
|
popUp.setVisible(true);
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ tabbedPaneInnerOriginal.addChangeListener(change -> {
|
|
|
|
+ controller.clearSelection();
|
|
|
|
+ });
|
|
mnNewMenuView.add(mntmCanvasSize);
|
|
mnNewMenuView.add(mntmCanvasSize);
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -754,44 +743,6 @@ public class GUI {
|
|
mnHelp.add(mntmCodeDoc);
|
|
mnHelp.add(mntmCodeDoc);
|
|
mnHelp.add(mntmAboutUs);
|
|
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.setBackground(Color.WHITE);
|
|
canvas.setPreferredSize(new Dimension(model.getCanvasX(), model.getCanvasY()));
|
|
canvas.setPreferredSize(new Dimension(model.getCanvasX(), model.getCanvasY()));
|
|
/********************
|
|
/********************
|
|
@@ -854,7 +805,7 @@ public class GUI {
|
|
* Add HolonElement to given HolonObject
|
|
* Add HolonElement to given HolonObject
|
|
*/
|
|
*/
|
|
btnAddHolEL.addActionListener(actionEvent -> {
|
|
btnAddHolEL.addActionListener(actionEvent -> {
|
|
- if (model.getSelectedCpsObjects().size() == 1) {
|
|
|
|
|
|
+ if (model.getSelectedObjects().size() == 1) {
|
|
AbstractCanvasObject tempCpsObject = updCon.getActualCps();
|
|
AbstractCanvasObject tempCpsObject = updCon.getActualCps();
|
|
if (tempCpsObject != null && tempCpsObject.getClass() == HolonObject.class
|
|
if (tempCpsObject != null && tempCpsObject.getClass() == HolonObject.class
|
|
&& tempCpsObject.getId() != 0) {
|
|
&& tempCpsObject.getId() != 0) {
|
|
@@ -863,8 +814,8 @@ public class GUI {
|
|
addElementPopUp.setVisible(true);
|
|
addElementPopUp.setVisible(true);
|
|
HolonElement ele = addElementPopUp.getElement();
|
|
HolonElement ele = addElementPopUp.getElement();
|
|
if (ele != null) {
|
|
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());
|
|
controller.calculateStateAndVisualForTimeStep(model.getCurIteration());
|
|
triggerUpdateController(null);
|
|
triggerUpdateController(null);
|
|
@@ -884,7 +835,7 @@ public class GUI {
|
|
*/
|
|
*/
|
|
btnDelHolEL.addActionListener(actionEvent -> {
|
|
btnDelHolEL.addActionListener(actionEvent -> {
|
|
// For Single Selection of CpsObject
|
|
// For Single Selection of CpsObject
|
|
- if (model.getSelectedCpsObjects().size() == 1) {
|
|
|
|
|
|
+ if (model.getSelectedObjects().size() == 1) {
|
|
if (updCon.getActualCps().getClass() == HolonObject.class) {
|
|
if (updCon.getActualCps().getClass() == HolonObject.class) {
|
|
HolonObject obj = (HolonObject) updCon.getActualCps();
|
|
HolonObject obj = (HolonObject) updCon.getActualCps();
|
|
if (selectedElements.isEmpty()) {
|
|
if (selectedElements.isEmpty()) {
|
|
@@ -894,7 +845,7 @@ public class GUI {
|
|
}
|
|
}
|
|
for (HolonElement e : selectedElements) {
|
|
for (HolonElement e : selectedElements) {
|
|
controller.deleteElementCanvas(obj.getId(), e.getId());
|
|
controller.deleteElementCanvas(obj.getId(), e.getId());
|
|
- controller.calculateStateAndVisualForTimeStep(model.getCurIteration());
|
|
|
|
|
|
+ controller.calculateStateAndVisualForCurrentTimeStep();
|
|
triggerUpdateController(null);
|
|
triggerUpdateController(null);
|
|
contentPane.updateUI();
|
|
contentPane.updateUI();
|
|
// Names displayed in graph are not updated
|
|
// Names displayed in graph are not updated
|
|
@@ -903,7 +854,7 @@ public class GUI {
|
|
selectedElements.clear();
|
|
selectedElements.clear();
|
|
}
|
|
}
|
|
// For MultiSelection of CpsObject
|
|
// For MultiSelection of CpsObject
|
|
- } else if (model.getSelectedCpsObjects().size() > 1) {
|
|
|
|
|
|
+ } else if (model.getSelectedObjects().size() > 1) {
|
|
for (Integer i : model.getEleToDelete().keySet()) {
|
|
for (Integer i : model.getEleToDelete().keySet()) {
|
|
for (HolonElement e : model.getEleToDelete().get(i)) {
|
|
for (HolonElement e : model.getEleToDelete().get(i)) {
|
|
controller.deleteElementCanvas(i, e.getId());
|
|
controller.deleteElementCanvas(i, e.getId());
|
|
@@ -974,7 +925,7 @@ public class GUI {
|
|
if (leaf) {
|
|
if (leaf) {
|
|
for (Category cat : model.getCategories()) {
|
|
for (Category cat : model.getCategories()) {
|
|
for (AbstractCanvasObject cps : cat.getObjects()) {
|
|
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);
|
|
imgR = ImageImport.loadImage(cps.getImage(), 50, 50);
|
|
if (imgR != null) {
|
|
if (imgR != null) {
|
|
label.setIcon(new ImageIcon(imgR));
|
|
label.setIcon(new ImageIcon(imgR));
|
|
@@ -1091,35 +1042,31 @@ public class GUI {
|
|
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;
|
|
|
|
|
|
- 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 {
|
|
} else {
|
|
int x = (int) canvas.getMousePosition().getX() + 16;
|
|
int x = (int) canvas.getMousePosition().getX() + 16;
|
|
int y = (int) canvas.getMousePosition().getY() + 16;
|
|
int y = (int) canvas.getMousePosition().getY() + 16;
|
|
@@ -1189,7 +1136,7 @@ public class GUI {
|
|
if (SwingUtilities.isRightMouseButton(e)) {
|
|
if (SwingUtilities.isRightMouseButton(e)) {
|
|
for (Category cat : model.getCategories()) {
|
|
for (Category cat : model.getCategories()) {
|
|
for (AbstractCanvasObject cps : cat.getObjects()) {
|
|
for (AbstractCanvasObject cps : cat.getObjects()) {
|
|
- if (actualObjectClicked.compareTo(cps.getObjName()) == 0
|
|
|
|
|
|
+ if (actualObjectClicked.compareTo(cps.getName()) == 0
|
|
&& !(cps instanceof HolonSwitch)) {
|
|
&& !(cps instanceof HolonSwitch)) {
|
|
editItem.setEnabled(true);
|
|
editItem.setEnabled(true);
|
|
popmenuEdit.show(e.getComponent(), e.getX(), e.getY());
|
|
popmenuEdit.show(e.getComponent(), e.getX(), e.getY());
|
|
@@ -1201,7 +1148,7 @@ public class GUI {
|
|
} else {
|
|
} else {
|
|
for (Category cat : model.getCategories()) {
|
|
for (Category cat : model.getCategories()) {
|
|
for (AbstractCanvasObject cps : cat.getObjects()) {
|
|
for (AbstractCanvasObject cps : cat.getObjects()) {
|
|
- if (actualObjectClicked.compareTo(cps.getObjName()) == 0) {
|
|
|
|
|
|
+ if (actualObjectClicked.compareTo(cps.getName()) == 0) {
|
|
File checkPath = new File(cps.getImage());
|
|
File checkPath = new File(cps.getImage());
|
|
if (checkPath.exists()) {
|
|
if (checkPath.exists()) {
|
|
img = new ImageIcon(cps.getImage()).getImage().getScaledInstance(32, 32,
|
|
img = new ImageIcon(cps.getImage()).getImage().getScaledInstance(32, 32,
|
|
@@ -1323,61 +1270,6 @@ public class GUI {
|
|
aboutUsPopUp.setVisible(true);
|
|
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
|
|
// Del Button
|
|
btnDel.addActionListener(actionEvent -> {
|
|
btnDel.addActionListener(actionEvent -> {
|
|
Object nodeInfo = categoryTree.getLastSelectedPathComponent();
|
|
Object nodeInfo = categoryTree.getLastSelectedPathComponent();
|
|
@@ -1429,9 +1321,10 @@ public class GUI {
|
|
while (tabbedPaneInnerOriginal.getTabCount() > 1) {
|
|
while (tabbedPaneInnerOriginal.getTabCount() > 1) {
|
|
tabbedPaneInnerOriginal.remove(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.setSelectedObjectID(0);
|
|
controller.setSelecteEdge(null);
|
|
controller.setSelecteEdge(null);
|
|
controller.setCurIteration(0);
|
|
controller.setCurIteration(0);
|
|
@@ -1463,7 +1356,7 @@ public class GUI {
|
|
while (tabbedPaneInnerOriginal.getTabCount() > 1) {
|
|
while (tabbedPaneInnerOriginal.getTabCount() > 1) {
|
|
tabbedPaneInnerOriginal.remove(1);
|
|
tabbedPaneInnerOriginal.remove(1);
|
|
}
|
|
}
|
|
- model.getSelectedCpsObjects().clear();
|
|
|
|
|
|
+ model.getSelectedObjects().clear();
|
|
controller.loadFile(file.getAbsolutePath());
|
|
controller.loadFile(file.getAbsolutePath());
|
|
canvas.repaint();
|
|
canvas.repaint();
|
|
categoryTree.repaint();
|
|
categoryTree.repaint();
|
|
@@ -1770,7 +1663,7 @@ public class GUI {
|
|
node1 = new DefaultMutableTreeNode(c.getName());
|
|
node1 = new DefaultMutableTreeNode(c.getName());
|
|
|
|
|
|
for (AbstractCanvasObject obj : c.getObjects()) {
|
|
for (AbstractCanvasObject obj : c.getObjects()) {
|
|
- node1.add(new DefaultMutableTreeNode(obj.getObjName()));
|
|
|
|
|
|
+ node1.add(new DefaultMutableTreeNode(obj.getName()));
|
|
}
|
|
}
|
|
add(node1);
|
|
add(node1);
|
|
}
|
|
}
|
|
@@ -1820,16 +1713,16 @@ public class GUI {
|
|
/*
|
|
/*
|
|
* Open a new Tab with an UpperNodeCanvas
|
|
* Open a new Tab with an UpperNodeCanvas
|
|
*/
|
|
*/
|
|
- private void openNewUpperNodeTab() {
|
|
|
|
|
|
+ public void openNewUpperNodeTab(GroupNode node) {
|
|
chooseTabTemp();
|
|
chooseTabTemp();
|
|
|
|
|
|
JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
if (scrollPane.getViewport().getComponent(0) instanceof Canvas) {
|
|
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));
|
|
scrollPane.getViewport().getComponent(0));
|
|
|
|
|
|
} else {
|
|
} else {
|
|
- unc = new GroupNodeCanvas(model, controller, unitGraph, (GroupNode) temp,
|
|
|
|
|
|
+ unc = new GroupNodeCanvas(model, controller, unitGraph, node,
|
|
((GroupNodeCanvas) scrollPane.getViewport().getComponent(0)).getParentPath() + " -> ",
|
|
((GroupNodeCanvas) scrollPane.getViewport().getComponent(0)).getParentPath() + " -> ",
|
|
scrollPane.getViewport().getComponent(0));
|
|
scrollPane.getViewport().getComponent(0));
|
|
}
|
|
}
|
|
@@ -1840,7 +1733,7 @@ public class GUI {
|
|
for (int i = 1; i < tabbedPaneInnerOriginal.getTabCount(); i++) {
|
|
for (int i = 1; i < tabbedPaneInnerOriginal.getTabCount(); i++) {
|
|
JScrollPane paneOriginal = (JScrollPane) tabbedPaneInnerOriginal.getComponentAt(i);
|
|
JScrollPane paneOriginal = (JScrollPane) tabbedPaneInnerOriginal.getComponentAt(i);
|
|
if (paneOriginal != null && ((GroupNodeCanvas) paneOriginal.getViewport().getComponent(0)).getGroupNode()
|
|
if (paneOriginal != null && ((GroupNodeCanvas) paneOriginal.getViewport().getComponent(0)).getGroupNode()
|
|
- .getId() == temp.getId()) {
|
|
|
|
|
|
+ .getId() == node.getId()) {
|
|
dupl = true;
|
|
dupl = true;
|
|
// set selected component to view
|
|
// set selected component to view
|
|
tabbedPaneOriginal.setSelectedComponent(tabbedPaneInnerOriginal);
|
|
tabbedPaneOriginal.setSelectedComponent(tabbedPaneInnerOriginal);
|
|
@@ -1848,80 +1741,27 @@ public class GUI {
|
|
tabbedPaneInnerOriginal.setSelectedComponent(tabbedPaneInnerOriginal.getComponentAt(i));
|
|
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 we found a duplicate, break
|
|
if (dupl) {
|
|
if (dupl) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!dupl) {
|
|
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);
|
|
JScrollPane sp = new JScrollPane(unc);
|
|
sp.setBorder(null);
|
|
sp.setBorder(null);
|
|
|
|
|
|
// Selected tabbed Pane = tabbedPaneOriginal or tabbedPaneSplit
|
|
// Selected tabbed Pane = tabbedPaneOriginal or tabbedPaneSplit
|
|
if (tabTemp == tabbedPaneOriginal) {
|
|
if (tabTemp == tabbedPaneOriginal) {
|
|
- this.tabbedPaneInnerOriginal.add(temp.getName(), sp);
|
|
|
|
|
|
+ this.tabbedPaneInnerOriginal.add(node.getName(), sp);
|
|
this.tabbedPaneInnerOriginal.setSelectedComponent(sp);
|
|
this.tabbedPaneInnerOriginal.setSelectedComponent(sp);
|
|
this.tabbedPaneInnerOriginal.setTabComponentAt(this.tabbedPaneInnerOriginal.getTabCount() - 1,
|
|
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() {
|
|
private void updateUpperNodes() {
|
|
for (Component c : tabbedPaneInnerOriginal.getComponents()) {
|
|
for (Component c : tabbedPaneInnerOriginal.getComponents()) {
|
|
if (!(c instanceof JScrollPane)) {
|
|
if (!(c instanceof JScrollPane)) {
|
|
@@ -1942,29 +1782,16 @@ public class GUI {
|
|
*/
|
|
*/
|
|
private void removeUpperNodeTab(AbstractCanvasObject cps) {
|
|
private void removeUpperNodeTab(AbstractCanvasObject cps) {
|
|
if (cps instanceof GroupNode) {
|
|
if (cps instanceof GroupNode) {
|
|
- boolean splitView = false;
|
|
|
|
for (int i = 1; i < tabbedPaneInnerOriginal.getTabCount(); i++) {
|
|
for (int i = 1; i < tabbedPaneInnerOriginal.getTabCount(); i++) {
|
|
JScrollPane scrollPaneOriginal = (JScrollPane) tabbedPaneInnerOriginal.getComponentAt(i);
|
|
JScrollPane scrollPaneOriginal = (JScrollPane) tabbedPaneInnerOriginal.getComponentAt(i);
|
|
|
|
|
|
if (scrollPaneOriginal == null) {
|
|
if (scrollPaneOriginal == null) {
|
|
- splitView = true;
|
|
|
|
} else if (((GroupNodeCanvas) scrollPaneOriginal.getViewport().getComponent(0)).getGroupNode()
|
|
} else if (((GroupNodeCanvas) scrollPaneOriginal.getViewport().getComponent(0)).getGroupNode()
|
|
.getId() == cps.getId()) {
|
|
.getId() == cps.getId()) {
|
|
((ButtonTabComponent) tabbedPaneInnerOriginal.getTabComponentAt(i)).removeTabs();
|
|
((ButtonTabComponent) tabbedPaneInnerOriginal.getTabComponentAt(i)).removeTabs();
|
|
break;
|
|
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
|
|
* chooses whether to set the tabTemp to tabbedPaneOriginal or tabbedPaneSplit
|
|
*/
|
|
*/
|
|
private void chooseTabTemp() {
|
|
private void chooseTabTemp() {
|
|
- // TODO Remove me when not needed
|
|
|
|
|
|
+ // TODO Remove tabTabbed
|
|
tabTemp = tabbedPaneOriginal;
|
|
tabTemp = tabbedPaneOriginal;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2011,7 +1838,6 @@ public class GUI {
|
|
if (temp != null) {
|
|
if (temp != null) {
|
|
updCon.paintProperties(temp);
|
|
updCon.paintProperties(temp);
|
|
}
|
|
}
|
|
- updCon.refreshTableHolonElement(model.getMultiTable(), model.getSingleTable());
|
|
|
|
updCon.refreshTableProperties(model.getPropertyTable());
|
|
updCon.refreshTableProperties(model.getPropertyTable());
|
|
}
|
|
}
|
|
|
|
|