|
@@ -98,7 +98,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
private JFrame frmCyberPhysical;
|
|
private JFrame frmCyberPhysical;
|
|
|
|
|
|
- private final SimulationMenu simMenu;
|
|
|
|
|
|
+ private final AlgorithmMenu simMenu;
|
|
|
|
|
|
private JTabbedPane tabTemp; // tabbedPane or tabbedPane2
|
|
private JTabbedPane tabTemp; // tabbedPane or tabbedPane2
|
|
private final JMenuBar menuBar = new JMenuBar();
|
|
private final JMenuBar menuBar = new JMenuBar();
|
|
@@ -107,12 +107,14 @@ public class GUI<E> implements CategoryListener {
|
|
private final JMenu mnNewMenuOptions = new JMenu("Options");
|
|
private final JMenu mnNewMenuOptions = new JMenu("Options");
|
|
private final JMenu mnNewMenuView = new JMenu("View");
|
|
private final JMenu mnNewMenuView = new JMenu("View");
|
|
private final JMenu mnHelp = new JMenu("Help");
|
|
private final JMenu mnHelp = new JMenu("Help");
|
|
|
|
+ private final JMenu mnAlgorithm = new JMenu("Algorithm");
|
|
private final JMenuItem mntmOpen = new JMenuItem("Open");
|
|
private final JMenuItem mntmOpen = new JMenuItem("Open");
|
|
private final JMenuItem mntmNew = new JMenuItem("New");
|
|
private final JMenuItem mntmNew = new JMenuItem("New");
|
|
private final JMenuItem mntmSave = new JMenuItem("Save");
|
|
private final JMenuItem mntmSave = new JMenuItem("Save");
|
|
- private final JMenuItem aboutUs = new JMenuItem("About Us");
|
|
|
|
- private final JMenuItem canvasSize = new JMenuItem("View Size");
|
|
|
|
- private final JMenuItem background = new JMenuItem("Background Image");
|
|
|
|
|
|
+ private final JMenuItem mntmAboutUs = new JMenuItem("About Us");
|
|
|
|
+ private final JMenuItem mntmCanvasSize = new JMenuItem("View Size");
|
|
|
|
+ private final JMenuItem mntmBackground = new JMenuItem("Background Image");
|
|
|
|
+ private final JMenuItem mntmSplitView = new JMenuItem("Split View");
|
|
private final JSplitPane splitPane = new JSplitPane();
|
|
private final JSplitPane splitPane = new JSplitPane();
|
|
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);
|
|
@@ -122,16 +124,12 @@ public class GUI<E> implements CategoryListener {
|
|
// 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);
|
|
private final JTabbedPane tabbedPane2 = new JTabbedPane(JTabbedPane.TOP);
|
|
private final JTabbedPane tabbedPane2 = new JTabbedPane(JTabbedPane.TOP);
|
|
- private final JButton splitButton = new JButton("Split View Test");
|
|
|
|
private JSplitPane tempSplit;
|
|
private JSplitPane tempSplit;
|
|
private boolean initSplit = true;
|
|
private boolean initSplit = true;
|
|
|
|
|
|
- private final JPanel panelTapped_SimMenu = new JPanel();
|
|
|
|
private JPopupMenu popmenuEdit = new JPopupMenu();
|
|
private JPopupMenu popmenuEdit = new JPopupMenu();
|
|
private JMenuItem editItem = new JMenuItem("Edit Object");
|
|
private JMenuItem editItem = new JMenuItem("Edit Object");
|
|
private String catOfObjToBeEdited;
|
|
private String catOfObjToBeEdited;
|
|
- private final JScrollPane statTab = new JScrollPane();
|
|
|
|
-
|
|
|
|
private FlexiblePane flexPane;
|
|
private FlexiblePane flexPane;
|
|
private StatPanel2 statSplitPane;
|
|
private StatPanel2 statSplitPane;
|
|
private JScrollPane statScrollPane;
|
|
private JScrollPane statScrollPane;
|
|
@@ -301,7 +299,7 @@ public class GUI<E> implements CategoryListener {
|
|
control.initListener(this);
|
|
control.initListener(this);
|
|
controller.setCanvas(canvas);
|
|
controller.setCanvas(canvas);
|
|
model.setConsole(console);
|
|
model.setConsole(console);
|
|
- simMenu = new SimulationMenu(model, control);
|
|
|
|
|
|
+ simMenu = new AlgorithmMenu(model, control);
|
|
initialize();
|
|
initialize();
|
|
updateCategories(model.getCategories());
|
|
updateCategories(model.getCategories());
|
|
updCon = new UpdateController(model, controller);
|
|
updCon = new UpdateController(model, controller);
|
|
@@ -416,22 +414,41 @@ 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;
|
|
|
|
+ }
|
|
// Uppernode Canvas?
|
|
// Uppernode Canvas?
|
|
- if (((JScrollPane) tabbedPane.getSelectedComponent()).getViewport()
|
|
|
|
|
|
+ if (((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
.getComponent(0) instanceof UpperNodeCanvas) {
|
|
.getComponent(0) instanceof UpperNodeCanvas) {
|
|
- UpperNodeCanvas uNC = (UpperNodeCanvas) ((JScrollPane) tabbedPane.getSelectedComponent())
|
|
|
|
- .getViewport().getComponent(0);
|
|
|
|
|
|
+ UpperNodeCanvas uNC = (UpperNodeCanvas) ((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
|
+ .getComponent(0);
|
|
for (AbstractCpsObject cps : model.getSelectedCpsObjects()) {
|
|
for (AbstractCpsObject cps : model.getSelectedCpsObjects()) {
|
|
if (uNC.upperNode.getNodes().contains(cps)) {
|
|
if (uNC.upperNode.getNodes().contains(cps)) {
|
|
controller.delObjUpperNode(cps, uNC.upperNode);
|
|
controller.delObjUpperNode(cps, uNC.upperNode);
|
|
// Remove UpperNodeTab if UpperNode deleted
|
|
// Remove UpperNodeTab if UpperNode deleted
|
|
if (cps instanceof CpsUpperNode) {
|
|
if (cps instanceof CpsUpperNode) {
|
|
|
|
+ boolean splitView = false;
|
|
for (int i = 4; i < tabbedPane.getTabCount(); i++) {
|
|
for (int i = 4; i < tabbedPane.getTabCount(); i++) {
|
|
- if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
|
|
|
|
- .getComponent(0)).upperNode.getId() == cps.getId()) {
|
|
|
|
- tabbedPane.remove(i);
|
|
|
|
- i = tabbedPane.getTabCount();
|
|
|
|
|
|
+ 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) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -439,7 +456,7 @@ public class GUI<E> implements CategoryListener {
|
|
uNC.repaint();
|
|
uNC.repaint();
|
|
|
|
|
|
// or Canvas?
|
|
// or Canvas?
|
|
- } else if (((JScrollPane) tabbedPane.getSelectedComponent()).getViewport()
|
|
|
|
|
|
+ } else if (((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
.getComponent(0) instanceof MyCanvas) {
|
|
.getComponent(0) 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++) {
|
|
@@ -449,13 +466,26 @@ public class GUI<E> implements CategoryListener {
|
|
controller.delCanvasObject(cps, save);
|
|
controller.delCanvasObject(cps, save);
|
|
// Remove UpperNodeTab if UpperNode deleted
|
|
// Remove UpperNodeTab if UpperNode deleted
|
|
if (cps instanceof CpsUpperNode) {
|
|
if (cps instanceof CpsUpperNode) {
|
|
|
|
+ boolean splitView = false;
|
|
for (int i = 4; i < tabbedPane.getTabCount(); i++) {
|
|
for (int i = 4; i < tabbedPane.getTabCount(); i++) {
|
|
- if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
|
|
|
|
|
|
+ if (tabbedPane.getComponentAt(i) == null) {
|
|
|
|
+ splitView = true;
|
|
|
|
+ } else if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
|
|
.getComponent(0)).upperNode.getId() == cps.getId()) {
|
|
.getComponent(0)).upperNode.getId() == cps.getId()) {
|
|
- tabbedPane.remove(i);
|
|
|
|
- i = tabbedPane.getTabCount();
|
|
|
|
|
|
+ ((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) {
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
canvas.repaint();
|
|
canvas.repaint();
|
|
@@ -654,19 +684,24 @@ public class GUI<E> implements CategoryListener {
|
|
@Override
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
ArrayList<Category> cat = model.getCategories();
|
|
ArrayList<Category> cat = model.getCategories();
|
|
- while (!cat.isEmpty()) {
|
|
|
|
- controller.deleteCategory(cat.get(0).getName());
|
|
|
|
- ;
|
|
|
|
|
|
+ try {
|
|
|
|
+ while (!cat.isEmpty()) {
|
|
|
|
+ controller.deleteCategory(cat.get(0).getName());
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ controller.resetCategorys();
|
|
|
|
+ } catch (Exception e2) {
|
|
|
|
+ // TODO: handle exception
|
|
}
|
|
}
|
|
- controller.resetCategorys();
|
|
|
|
|
|
+
|
|
tree.repaint();
|
|
tree.repaint();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
menuBar.add(mnNewMenuView);
|
|
menuBar.add(mnNewMenuView);
|
|
|
|
|
|
- mnNewMenuView.add(canvasSize);
|
|
|
|
- canvasSize.addActionListener(new ActionListener() {
|
|
|
|
|
|
+ mnNewMenuView.add(mntmCanvasSize);
|
|
|
|
+ mntmCanvasSize.addActionListener(new ActionListener() {
|
|
@Override
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
JPanel myPanel = new JPanel();
|
|
JPanel myPanel = new JPanel();
|
|
@@ -707,10 +742,53 @@ public class GUI<E> implements CategoryListener {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- mnNewMenuView.add(canvasSize);
|
|
|
|
|
|
+ mnNewMenuView.add(mntmCanvasSize);
|
|
|
|
+ mnNewMenuView.add(mntmSplitView);
|
|
|
|
+
|
|
|
|
+ // Split View
|
|
|
|
+ mntmSplitView.addActionListener(new ActionListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
|
+ if (splitPaneCanvasConsole.getLeftComponent() instanceof JSplitPane) {
|
|
|
|
+ initSplit = true;
|
|
|
|
+ Component tempC = tabbedPane2.getSelectedComponent();
|
|
|
|
+ tabbedPane.setComponentAt(tabbedPane2.getSelectedIndex(), tempC);
|
|
|
|
+ tabbedPane2.removeAll();
|
|
|
|
+ splitPaneCanvasConsole.setLeftComponent(tabbedPane);
|
|
|
|
+ } else {
|
|
|
|
+ for (int i = 0; i < tabbedPane.getTabCount(); i++) {
|
|
|
|
+ tabbedPane2.addTab(tabbedPane.getTitleAt(i), null);
|
|
|
|
+ if (i >= 4) {
|
|
|
|
+ // tabbedPane2.setTabComponentAt(tabbedPane.getTabCount()
|
|
|
|
+ // - 1,
|
|
|
|
+ // new ButtonTabComponent(tabbedPane, tabbedPane2));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (tabbedPane.getSelectedComponent() == statScrollPane) {
|
|
|
|
+ tabbedPane.setComponentAt(0, null);
|
|
|
|
+ tabbedPane2.setComponentAt(0, canvasSP);
|
|
|
|
+ tabbedPane2.setSelectedIndex(0);
|
|
|
|
+ } else {
|
|
|
|
+ tabbedPane.setComponentAt(1, null);
|
|
|
|
+ tabbedPane2.setComponentAt(1, statScrollPane);
|
|
|
|
+ tabbedPane2.setSelectedIndex(1);
|
|
|
|
+ }
|
|
|
|
+ tempSplit = new JSplitPane();
|
|
|
|
+ tempSplit.setBorder(null);
|
|
|
|
+ tempSplit.setRightComponent(tabbedPane2);
|
|
|
|
+ tempSplit.setLeftComponent(tabbedPane);
|
|
|
|
+ tempSplit.setDividerLocation(tabbedPane.getWidth() / 2);
|
|
|
|
+ tempSplit.setResizeWeight(0.9);
|
|
|
|
+ splitPaneCanvasConsole.setLeftComponent(tempSplit);
|
|
|
|
+ initSplit = false;
|
|
|
|
+ }
|
|
|
|
+ contentPane.updateUI();
|
|
|
|
+ }
|
|
|
|
|
|
- mnNewMenuView.add(background);
|
|
|
|
- background.addActionListener(new ActionListener() {
|
|
|
|
|
|
+ });
|
|
|
|
+ mnNewMenuView.add(mntmBackground);
|
|
|
|
+
|
|
|
|
+ mntmBackground.addActionListener(new ActionListener() {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
@@ -754,57 +832,15 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
splitPane_1.setLeftComponent(lblHolonBodySize);
|
|
splitPane_1.setLeftComponent(lblHolonBodySize);
|
|
|
|
|
|
- menuBar.add(mnHelp);
|
|
|
|
|
|
+ mnAlgorithm.add(simMenu);
|
|
|
|
|
|
- mnHelp.add(aboutUs);
|
|
|
|
|
|
+ menuBar.add(mnAlgorithm);
|
|
|
|
|
|
- // Testing
|
|
|
|
- menuBar.add(splitButton);
|
|
|
|
- // Split View
|
|
|
|
- splitButton.addActionListener(new ActionListener() {
|
|
|
|
- @Override
|
|
|
|
- public void actionPerformed(ActionEvent e) {
|
|
|
|
- if (panelTapped_SimMenu
|
|
|
|
- .getComponent(panelTapped_SimMenu.getComponentCount() - 1) instanceof JSplitPane) {
|
|
|
|
- initSplit = true;
|
|
|
|
- Component tempC = tabbedPane2.getSelectedComponent();
|
|
|
|
- tabbedPane.setComponentAt(tabbedPane2.getSelectedIndex(), tempC);
|
|
|
|
- tabbedPane2.removeAll();
|
|
|
|
- panelTapped_SimMenu
|
|
|
|
- .remove(panelTapped_SimMenu.getComponent(panelTapped_SimMenu.getComponentCount() - 1));
|
|
|
|
- panelTapped_SimMenu.add(tabbedPane);
|
|
|
|
- } else {
|
|
|
|
- for (int i = 0; i < tabbedPane.getTabCount(); i++) {
|
|
|
|
- tabbedPane2.addTab(tabbedPane.getTitleAt(i), null);
|
|
|
|
- if (i >= 4) {
|
|
|
|
- // tabbedPane2.setTabComponentAt(tabbedPane.getTabCount()
|
|
|
|
- // - 1,
|
|
|
|
- // new ButtonTabComponent(tabbedPane, tabbedPane2));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (tabbedPane.getSelectedComponent() == statScrollPane) {
|
|
|
|
- tabbedPane.setComponentAt(0, null);
|
|
|
|
- tabbedPane2.setComponentAt(0, canvasSP);
|
|
|
|
- tabbedPane2.setSelectedIndex(0);
|
|
|
|
- } else {
|
|
|
|
- tabbedPane.setComponentAt(1, null);
|
|
|
|
- tabbedPane2.setComponentAt(1, statScrollPane);
|
|
|
|
- tabbedPane2.setSelectedIndex(1);
|
|
|
|
- }
|
|
|
|
- tempSplit = new JSplitPane();
|
|
|
|
- tempSplit.setBorder(null);
|
|
|
|
- tempSplit.setRightComponent(tabbedPane2);
|
|
|
|
- tempSplit.setLeftComponent(tabbedPane);
|
|
|
|
- tempSplit.setDividerLocation(tabbedPane.getWidth() / 2);
|
|
|
|
- tempSplit.setResizeWeight(0.9);
|
|
|
|
- panelTapped_SimMenu.remove(tabbedPane);
|
|
|
|
- panelTapped_SimMenu.add(tempSplit);
|
|
|
|
- initSplit = false;
|
|
|
|
- }
|
|
|
|
- contentPane.updateUI();
|
|
|
|
- }
|
|
|
|
|
|
+ menuBar.add(mnHelp);
|
|
|
|
|
|
- });
|
|
|
|
|
|
+ mnHelp.add(mntmAboutUs);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
tabbedPane.addChangeListener(new ChangeListener() {
|
|
tabbedPane.addChangeListener(new ChangeListener() {
|
|
|
|
|
|
@@ -1497,7 +1533,7 @@ public class GUI<E> implements CategoryListener {
|
|
* Pop up - About Us with some important information about the
|
|
* Pop up - About Us with some important information about the
|
|
* developers, source and programming stuff
|
|
* developers, source and programming stuff
|
|
*/
|
|
*/
|
|
- aboutUs.addMouseListener(new MouseAdapter() {
|
|
|
|
|
|
+ mntmAboutUs.addMouseListener(new MouseAdapter() {
|
|
@Override
|
|
@Override
|
|
public void mousePressed(MouseEvent e) {
|
|
public void mousePressed(MouseEvent e) {
|
|
aboutUsPopUp = new AboutUsPopUp();
|
|
aboutUsPopUp = new AboutUsPopUp();
|
|
@@ -1586,23 +1622,27 @@ public class GUI<E> implements CategoryListener {
|
|
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) nodeInfo;
|
|
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) nodeInfo;
|
|
String nodeName = selectedNode.getUserObject().toString();
|
|
String nodeName = selectedNode.getUserObject().toString();
|
|
int depthOfNode = selectedNode.getLevel();
|
|
int depthOfNode = selectedNode.getLevel();
|
|
|
|
+ try {
|
|
|
|
+ switch (depthOfNode) {
|
|
|
|
+ case 1:
|
|
|
|
+ int dialogResult = JOptionPane.showConfirmDialog(null, eraseCategory + nodeName + "?",
|
|
|
|
+ warningText, JOptionPane.YES_NO_OPTION);
|
|
|
|
+ if (dialogResult == JOptionPane.YES_OPTION) {
|
|
|
|
+ controller.deleteCategory(nodeName);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 2:
|
|
|
|
+ DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selectedNode.getParent();
|
|
|
|
+ controller.delObjectCategory(parent.getUserObject().toString(), nodeName);
|
|
|
|
+ break;
|
|
|
|
|
|
- switch (depthOfNode) {
|
|
|
|
- case 1:
|
|
|
|
- int dialogResult = JOptionPane.showConfirmDialog(null, eraseCategory + nodeName + "?",
|
|
|
|
- warningText, JOptionPane.YES_NO_OPTION);
|
|
|
|
- if (dialogResult == JOptionPane.YES_OPTION) {
|
|
|
|
- controller.deleteCategory(nodeName);
|
|
|
|
|
|
+ default:
|
|
|
|
+ JOptionPane.showMessageDialog(new JFrame(), selectObjBeforeErase);
|
|
}
|
|
}
|
|
- break;
|
|
|
|
- case 2:
|
|
|
|
- DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selectedNode.getParent();
|
|
|
|
- controller.delObjectCategory(parent.getUserObject().toString(), nodeName);
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- default:
|
|
|
|
- JOptionPane.showMessageDialog(new JFrame(), selectObjBeforeErase);
|
|
|
|
|
|
+ } catch (Exception e2) {
|
|
|
|
+ // TODO: handle exception
|
|
}
|
|
}
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
JOptionPane.showMessageDialog(new JFrame(), selectObjBeforeErase);
|
|
JOptionPane.showMessageDialog(new JFrame(), selectObjBeforeErase);
|
|
}
|
|
}
|
|
@@ -1663,6 +1703,7 @@ public class GUI<E> implements CategoryListener {
|
|
tree.repaint();
|
|
tree.repaint();
|
|
} catch (IOException | ArchiveException e) {
|
|
} catch (IOException | ArchiveException e) {
|
|
// TODO Auto-generated catch block
|
|
// TODO Auto-generated catch block
|
|
|
|
+ e.printStackTrace();
|
|
JLabel message = new JLabel("The savefile is corrupt and cannot be opened.");
|
|
JLabel message = new JLabel("The savefile is corrupt and cannot be opened.");
|
|
JOptionPane.showMessageDialog(null, message, "", JOptionPane.ERROR_MESSAGE);
|
|
JOptionPane.showMessageDialog(null, message, "", JOptionPane.ERROR_MESSAGE);
|
|
}
|
|
}
|
|
@@ -1689,19 +1730,19 @@ public class GUI<E> implements CategoryListener {
|
|
if (fileChooser.getFileFilter().equals(holonFilter)) {
|
|
if (fileChooser.getFileFilter().equals(holonFilter)) {
|
|
if (!file.contains("."))
|
|
if (!file.contains("."))
|
|
file += ".holon";
|
|
file += ".holon";
|
|
- if (!file.endsWith(".holon")) {
|
|
|
|
- String suffix = file.substring(file.lastIndexOf("."), file.length());
|
|
|
|
- String[] options = new String[] { "keep .holon", "use " + suffix };
|
|
|
|
|
|
+ }
|
|
|
|
+ if (!file.endsWith(".holon")) {
|
|
|
|
+ String suffix = file.substring(file.lastIndexOf("."), file.length());
|
|
|
|
+ String[] options = new String[] { "keep .holon", "use " + suffix };
|
|
|
|
|
|
- JLabel message = new JLabel(
|
|
|
|
- "Are you sure to use the extension \"" + suffix + "\" instead of \".holon\"?");
|
|
|
|
|
|
+ JLabel message = new JLabel(
|
|
|
|
+ "Are you sure to use the extension \"" + suffix + "\" instead of \".holon\"?");
|
|
|
|
|
|
- int response = JOptionPane.showOptionDialog(null, message, "", JOptionPane.DEFAULT_OPTION,
|
|
|
|
- JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
|
|
|
|
|
|
+ int response = JOptionPane.showOptionDialog(null, message, "", JOptionPane.DEFAULT_OPTION,
|
|
|
|
+ JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
|
|
|
|
|
|
- if (response == 0)
|
|
|
|
- file = file.replace(suffix, ".holon");
|
|
|
|
- }
|
|
|
|
|
|
+ if (response == 0)
|
|
|
|
+ file = file.replace(suffix, ".holon");
|
|
}
|
|
}
|
|
|
|
|
|
try {
|
|
try {
|
|
@@ -1842,7 +1883,9 @@ public class GUI<E> implements CategoryListener {
|
|
controller.runAlgorithm(model, controller);
|
|
controller.runAlgorithm(model, controller);
|
|
controller.calculateStateForTimeStep(i);
|
|
controller.calculateStateForTimeStep(i);
|
|
unitGraph.repaint();
|
|
unitGraph.repaint();
|
|
- statSplitPane.repaintGraphs();
|
|
|
|
|
|
+ if (model.getIsSimRunning()) {
|
|
|
|
+ statSplitPane.repaintGraphs();
|
|
|
|
+ }
|
|
contentPane.updateUI();
|
|
contentPane.updateUI();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -1854,7 +1897,7 @@ public class GUI<E> implements CategoryListener {
|
|
splitPaneCanvasConsole.setResizeWeight(0.9);
|
|
splitPaneCanvasConsole.setResizeWeight(0.9);
|
|
|
|
|
|
splitPane.setLeftComponent(scrollPane1);
|
|
splitPane.setLeftComponent(scrollPane1);
|
|
- splitPaneCanvasConsole.setLeftComponent(panelTapped_SimMenu);
|
|
|
|
|
|
+ splitPaneCanvasConsole.setLeftComponent(tabbedPane);
|
|
tabbedPane.addTab("View", canvasSP);
|
|
tabbedPane.addTab("View", canvasSP);
|
|
tabbedPane.addTab("Statistics", statScrollPane);
|
|
tabbedPane.addTab("Statistics", statScrollPane);
|
|
tabbedPane.addTab("Holon", holonCanvas);
|
|
tabbedPane.addTab("Holon", holonCanvas);
|
|
@@ -1876,12 +1919,8 @@ public class GUI<E> implements CategoryListener {
|
|
splitGraphHolonEl.setBottomComponent(scrollElements);
|
|
splitGraphHolonEl.setBottomComponent(scrollElements);
|
|
canvasSP.setViewportView(canvas);
|
|
canvasSP.setViewportView(canvas);
|
|
// holonSP.setViewportView(holonCanvas);
|
|
// holonSP.setViewportView(holonCanvas);
|
|
- panelTapped_SimMenu.setLayout(new BorderLayout());
|
|
|
|
- panelTapped_SimMenu.add(simMenu, BorderLayout.NORTH);
|
|
|
|
- panelTapped_SimMenu.add(tabbedPane);
|
|
|
|
simMenu.setBackground(new Color(240, 240, 240));
|
|
simMenu.setBackground(new Color(240, 240, 240));
|
|
|
|
|
|
- panelTapped_SimMenu.setBorder(null);
|
|
|
|
tabbedPane.setBorder(null);
|
|
tabbedPane.setBorder(null);
|
|
scrollProperties.setBorder(null);
|
|
scrollProperties.setBorder(null);
|
|
scrollGraph.setBorder(null);
|
|
scrollGraph.setBorder(null);
|
|
@@ -1899,6 +1938,12 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
frmCyberPhysical.getContentPane().add(timePanel, BorderLayout.SOUTH);
|
|
frmCyberPhysical.getContentPane().add(timePanel, BorderLayout.SOUTH);
|
|
|
|
|
|
|
|
+ try {
|
|
|
|
+ controller.loadAutoSave(System.getProperty("user.home") + "/HolonGUI/Category/Category.json");
|
|
|
|
+ } catch (IOException e1) {
|
|
|
|
+ // TODO Auto-generated catch block
|
|
|
|
+ }
|
|
|
|
+
|
|
String autoPath = System.getProperty("user.home") + "/HolonGUI/Autosave/";
|
|
String autoPath = System.getProperty("user.home") + "/HolonGUI/Autosave/";
|
|
File dest = new File(autoPath);
|
|
File dest = new File(autoPath);
|
|
if (dest.listFiles().length > 1) {
|
|
if (dest.listFiles().length > 1) {
|
|
@@ -1917,6 +1962,7 @@ public class GUI<E> implements CategoryListener {
|
|
setUpAutoSave(dest);
|
|
setUpAutoSave(dest);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
canvasSP.addComponentListener(new ComponentAdapter() {
|
|
canvasSP.addComponentListener(new ComponentAdapter() {
|
|
@Override
|
|
@Override
|
|
public void componentResized(ComponentEvent e) {
|
|
public void componentResized(ComponentEvent e) {
|
|
@@ -1965,12 +2011,17 @@ public class GUI<E> implements CategoryListener {
|
|
Category cat = controller.searchCategory(selectedNode.getUserObject().toString());
|
|
Category cat = controller.searchCategory(selectedNode.getUserObject().toString());
|
|
|
|
|
|
if (objname.length() != 0) {
|
|
if (objname.length() != 0) {
|
|
- switch (objType) {
|
|
|
|
|
|
+ try {
|
|
|
|
+ switch (objType) {
|
|
|
|
|
|
- case "Switch":
|
|
|
|
- controller.addSwitch(cat, objname);
|
|
|
|
- break;
|
|
|
|
|
|
+ case "Switch":
|
|
|
|
+ controller.addSwitch(cat, objname);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ // TODO: handle exception
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
JOptionPane.showMessageDialog(new JFrame(),
|
|
JOptionPane.showMessageDialog(new JFrame(),
|
|
@@ -2071,9 +2122,9 @@ public class GUI<E> implements CategoryListener {
|
|
mnNewMenuOptions.setText(tempArray[9]);
|
|
mnNewMenuOptions.setText(tempArray[9]);
|
|
mntmResetCategory.setText(tempArray[10]);
|
|
mntmResetCategory.setText(tempArray[10]);
|
|
mnNewMenuView.setText(tempArray[11]);
|
|
mnNewMenuView.setText(tempArray[11]);
|
|
- canvasSize.setText(tempArray[12]);
|
|
|
|
|
|
+ mntmCanvasSize.setText(tempArray[12]);
|
|
mnHelp.setText(tempArray[13]);
|
|
mnHelp.setText(tempArray[13]);
|
|
- aboutUs.setText(tempArray[14]);
|
|
|
|
|
|
+ mntmAboutUs.setText(tempArray[14]);
|
|
mntmEditEdges.setText(tempArray[15]);
|
|
mntmEditEdges.setText(tempArray[15]);
|
|
mnLanguage.setText(tempArray[16]);
|
|
mnLanguage.setText(tempArray[16]);
|
|
canvas.updateLanguages();
|
|
canvas.updateLanguages();
|
|
@@ -2200,6 +2251,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
JScrollPane sp = new JScrollPane(unc);
|
|
JScrollPane sp = new JScrollPane(unc);
|
|
sp.setBorder(null);
|
|
sp.setBorder(null);
|
|
|
|
+ // Selected tabbed Pane = tabbedPane or tabbedPane2
|
|
if (tabTemp == tabbedPane) {
|
|
if (tabTemp == tabbedPane) {
|
|
tabbedPane.add(temp.getName(), sp);
|
|
tabbedPane.add(temp.getName(), sp);
|
|
tabbedPane.setSelectedComponent(sp);
|
|
tabbedPane.setSelectedComponent(sp);
|