|
@@ -229,7 +229,7 @@ public class GUI implements CategoryListener {
|
|
|
control.initListener(this);
|
|
|
controller.setCanvas(canvas);
|
|
|
model.setConsole(console);
|
|
|
- algorithmMenu = new AlgorithmMenu(model, control);
|
|
|
+ algorithmMenu = new AlgorithmMenu(model, control, this);
|
|
|
initialize();
|
|
|
updateCategories(model.getCategories());
|
|
|
updCon = new UpdateController(model, controller);
|
|
@@ -463,7 +463,7 @@ public class GUI implements CategoryListener {
|
|
|
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
- SearchPopUp dialog = new SearchPopUp(controller, canvas);
|
|
|
+ SearchPopUp dialog = new SearchPopUp(controller, canvas, frmCyberPhysical);
|
|
|
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
|
|
dialog.setVisible(true);
|
|
|
}
|
|
@@ -526,7 +526,7 @@ public class GUI implements CategoryListener {
|
|
|
}
|
|
|
} catch (HeadlessException | JsonParseException | UnsupportedFlavorException | IOException e1) {
|
|
|
JLabel message = new JLabel("The Clipboard information cannot be pasted into Application.");
|
|
|
- JOptionPane.showMessageDialog(null, message, "", JOptionPane.ERROR_MESSAGE);
|
|
|
+ JOptionPane.showMessageDialog(frmCyberPhysical, message, "", JOptionPane.ERROR_MESSAGE);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -596,7 +596,7 @@ public class GUI implements CategoryListener {
|
|
|
|
|
|
mntmFindReplace.addActionListener(actionEvent -> {
|
|
|
try {
|
|
|
- SearchPopUp dialog = new SearchPopUp(controller, canvas);
|
|
|
+ SearchPopUp dialog = new SearchPopUp(controller, canvas, frmCyberPhysical);
|
|
|
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
|
|
dialog.setVisible(true);
|
|
|
controller.getObjectsInDepth();
|
|
@@ -608,7 +608,7 @@ public class GUI implements CategoryListener {
|
|
|
mnNewMenuEdit.add(mntmFindReplace);
|
|
|
mntmEditShowedInformation.addActionListener(actionEvent -> {
|
|
|
try {
|
|
|
- DisplayedInformationPopUp dialog = new DisplayedInformationPopUp(canvas, contentPane, controller);
|
|
|
+ DisplayedInformationPopUp dialog = new DisplayedInformationPopUp(canvas, contentPane, controller, frmCyberPhysical);
|
|
|
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
|
|
dialog.setVisible(true);
|
|
|
} catch (Exception ex) {
|
|
@@ -619,7 +619,7 @@ public class GUI implements CategoryListener {
|
|
|
mnNewMenuEdit.add(mntmEditShowedInformation);
|
|
|
mnNewMenuEdit.add(mntmEditEdges);
|
|
|
mntmEditEdges.addActionListener(actionEvent -> {
|
|
|
- EditEdgesPopUp edgePopUp = new EditEdgesPopUp();
|
|
|
+ EditEdgesPopUp edgePopUp = new EditEdgesPopUp(frmCyberPhysical);
|
|
|
edgePopUp.setCanvas(canvas);
|
|
|
edgePopUp.setController(controller);
|
|
|
edgePopUp.setVisible(true);
|
|
@@ -654,7 +654,7 @@ public class GUI implements CategoryListener {
|
|
|
|
|
|
mnNewMenuView.add(mntmCanvasSize);
|
|
|
mntmCanvasSize.addActionListener(actionEvent -> {
|
|
|
- CanvasResizePopUp popUp = new CanvasResizePopUp(model, controller, canvas, tabbedPaneOriginal, tabbedPaneSplit);
|
|
|
+ CanvasResizePopUp popUp = new CanvasResizePopUp(model, controller, canvas, tabbedPaneOriginal, tabbedPaneSplit, frmCyberPhysical);
|
|
|
popUp.setVisible(true);
|
|
|
});
|
|
|
|
|
@@ -724,13 +724,13 @@ public class GUI implements CategoryListener {
|
|
|
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, frmCyberPhysical);
|
|
|
backgroundDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
|
|
backgroundDialog.setVisible(true);
|
|
|
} else if (scrollPane.getViewport().getComponent(0) instanceof UpperNodeCanvas) {
|
|
|
UpperNodeCanvas uNodeCanvas = (UpperNodeCanvas) (scrollPane.getViewport().getComponent(0));
|
|
|
BackgroundPopUp backgroundDialog = new BackgroundPopUp(model, controller, null,
|
|
|
- uNodeCanvas.upperNode);
|
|
|
+ uNodeCanvas.upperNode, frmCyberPhysical);
|
|
|
backgroundDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
|
|
backgroundDialog.setVisible(true);
|
|
|
uNodeCanvas.repaint();
|
|
@@ -866,7 +866,7 @@ public class GUI implements CategoryListener {
|
|
|
AbstractCpsObject tempCpsObject = updCon.getActualCps();
|
|
|
if (tempCpsObject != null && tempCpsObject.getClass() == HolonObject.class
|
|
|
&& tempCpsObject.getId() != 0) {
|
|
|
- addElementPopUp = new AddElementPopUp();
|
|
|
+ addElementPopUp = new AddElementPopUp(frmCyberPhysical);
|
|
|
addElementPopUp.setActualCps(updCon.getActualCps());
|
|
|
addElementPopUp.setVisible(true);
|
|
|
HolonElement ele = addElementPopUp.getElement();
|
|
@@ -1412,7 +1412,7 @@ public class GUI implements CategoryListener {
|
|
|
});
|
|
|
editItem.addActionListener(actionEvent -> {
|
|
|
// Remove the selected Object object
|
|
|
- addObjectPopUP = new AddObjectPopUp(true, tempCps, catOfObjToBeEdited);
|
|
|
+ addObjectPopUP = new AddObjectPopUp(true, tempCps, catOfObjToBeEdited, frmCyberPhysical);
|
|
|
addObjectPopUP.setCategory(catOfObjToBeEdited);
|
|
|
addObjectPopUP.setController(controller);
|
|
|
addObjectPopUP.setVisible(true);
|
|
@@ -1438,19 +1438,19 @@ public class GUI implements CategoryListener {
|
|
|
switch (selectedOption) {
|
|
|
|
|
|
case "Category":
|
|
|
- String catName = JOptionPane.showInputDialog(Languages.getLanguage()[56]);
|
|
|
+ String catName = JOptionPane.showInputDialog(frmCyberPhysical, Languages.getLanguage()[56]);
|
|
|
if (catName.length() != 0) {
|
|
|
controller.addCategory(catName);
|
|
|
}
|
|
|
break;
|
|
|
case "Object":
|
|
|
if (selectedNode == null) {
|
|
|
- JOptionPane.showMessageDialog(new JFrame(),
|
|
|
+ JOptionPane.showMessageDialog(frmCyberPhysical,
|
|
|
Languages.getLanguage()[57] + selectedOption + ".");
|
|
|
}
|
|
|
if (selectedNode != null && selectedNode.getLevel() == 1) {
|
|
|
AbstractCpsObject tmp = new HolonObject("");
|
|
|
- addObjectPopUP = new AddObjectPopUp(false, tmp, null);
|
|
|
+ addObjectPopUP = new AddObjectPopUp(false, tmp, null, frmCyberPhysical);
|
|
|
addObjectPopUP.setVisible(true);
|
|
|
addObjectPopUP.setController(controller);
|
|
|
addObjectPopUP.setCategory(selectedNode.toString());
|
|
@@ -1472,7 +1472,7 @@ public class GUI implements CategoryListener {
|
|
|
mntmAboutUs.addMouseListener(new MouseAdapter() {
|
|
|
@Override
|
|
|
public void mousePressed(MouseEvent e) {
|
|
|
- aboutUsPopUp = new AboutUsPopUp();
|
|
|
+ aboutUsPopUp = new AboutUsPopUp(frmCyberPhysical);
|
|
|
aboutUsPopUp.setVisible(true);
|
|
|
}
|
|
|
});
|
|
@@ -1566,7 +1566,7 @@ public class GUI implements CategoryListener {
|
|
|
try {
|
|
|
switch (depthOfNode) {
|
|
|
case 1:
|
|
|
- int dialogResult = JOptionPane.showConfirmDialog(null, eraseCategory + nodeName + "?",
|
|
|
+ int dialogResult = JOptionPane.showConfirmDialog(frmCyberPhysical, eraseCategory + nodeName + "?",
|
|
|
warningText, JOptionPane.YES_NO_OPTION);
|
|
|
if (dialogResult == JOptionPane.YES_OPTION) {
|
|
|
controller.deleteCategory(nodeName);
|
|
@@ -1578,13 +1578,13 @@ public class GUI implements CategoryListener {
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
- JOptionPane.showMessageDialog(new JFrame(), selectObjBeforeErase);
|
|
|
+ JOptionPane.showMessageDialog(frmCyberPhysical, selectObjBeforeErase);
|
|
|
}
|
|
|
} catch (Exception e2) {
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- JOptionPane.showMessageDialog(new JFrame(), selectObjBeforeErase);
|
|
|
+ JOptionPane.showMessageDialog(frmCyberPhysical, selectObjBeforeErase);
|
|
|
}
|
|
|
tree.repaint();
|
|
|
});
|
|
@@ -1595,7 +1595,7 @@ public class GUI implements CategoryListener {
|
|
|
mntmNew.addActionListener(actionEvent -> {
|
|
|
if (model.getObjectsOnCanvas().size() != 0) {
|
|
|
int newWarning = JOptionPane.YES_NO_OPTION;
|
|
|
- int dialogForNewWarning = JOptionPane.showConfirmDialog(null, saveBeforeNew, warningText,
|
|
|
+ int dialogForNewWarning = JOptionPane.showConfirmDialog(frmCyberPhysical, saveBeforeNew, warningText,
|
|
|
newWarning);
|
|
|
if (dialogForNewWarning == JOptionPane.YES_OPTION) {
|
|
|
mntmSave.doClick();
|
|
@@ -1623,11 +1623,10 @@ public class GUI implements CategoryListener {
|
|
|
|
|
|
private void menuFileExitActionPerformed() {
|
|
|
JFileChooser fileChooser = new JFileChooser();
|
|
|
- JFrame test = new JFrame();
|
|
|
FileNameExtensionFilter holonFilter = new FileNameExtensionFilter("Holon Save File(*.holon)", "holon");
|
|
|
fileChooser.setFileFilter(holonFilter);
|
|
|
|
|
|
- if (fileChooser.showOpenDialog(test) == JFileChooser.APPROVE_OPTION) {
|
|
|
+ if (fileChooser.showOpenDialog(frmCyberPhysical) == JFileChooser.APPROVE_OPTION) {
|
|
|
File file = fileChooser.getSelectedFile();
|
|
|
|
|
|
try {
|
|
@@ -1641,7 +1640,7 @@ public class GUI implements CategoryListener {
|
|
|
} catch (IOException | ArchiveException e) {
|
|
|
e.printStackTrace();
|
|
|
JLabel message = new JLabel("The savefile is corrupt and cannot be opened.");
|
|
|
- JOptionPane.showMessageDialog(null, message, "", JOptionPane.ERROR_MESSAGE);
|
|
|
+ JOptionPane.showMessageDialog(frmCyberPhysical, message, "", JOptionPane.ERROR_MESSAGE);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1655,11 +1654,10 @@ public class GUI implements CategoryListener {
|
|
|
|
|
|
private void menuSaveActionPerformed() {
|
|
|
JFileChooser fileChooser = new JFileChooser();
|
|
|
- JFrame test = new JFrame();
|
|
|
FileNameExtensionFilter holonFilter = new FileNameExtensionFilter("Holon Save File(*.holon)", "holon");
|
|
|
fileChooser.setFileFilter(holonFilter);
|
|
|
|
|
|
- if (fileChooser.showSaveDialog(test) == JFileChooser.APPROVE_OPTION) {
|
|
|
+ if (fileChooser.showSaveDialog(frmCyberPhysical) == JFileChooser.APPROVE_OPTION) {
|
|
|
String file = fileChooser.getSelectedFile().getPath();
|
|
|
if (fileChooser.getFileFilter().equals(holonFilter)) {
|
|
|
if (!file.contains("."))
|
|
@@ -1672,7 +1670,7 @@ public class GUI implements CategoryListener {
|
|
|
JLabel message = new JLabel(
|
|
|
"Are you sure to use the extension \"" + suffix + "\" instead of \".holon\"?");
|
|
|
|
|
|
- int response = JOptionPane.showOptionDialog(null, message, "", JOptionPane.DEFAULT_OPTION,
|
|
|
+ int response = JOptionPane.showOptionDialog(frmCyberPhysical, message, "", JOptionPane.DEFAULT_OPTION,
|
|
|
JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
|
|
|
|
|
|
if (response == 0)
|
|
@@ -1833,7 +1831,7 @@ public class GUI implements CategoryListener {
|
|
|
|
|
|
if (nrOfOldSaves > 0) {
|
|
|
int dialogButton = JOptionPane.YES_NO_OPTION;
|
|
|
- int dialogResult = JOptionPane.showConfirmDialog(null, "Old autosave file was found, should it be loaded?",
|
|
|
+ int dialogResult = JOptionPane.showConfirmDialog(frmCyberPhysical, "Old autosave file was found, should it be loaded?",
|
|
|
warningText, dialogButton);
|
|
|
if (dialogResult == JOptionPane.YES_OPTION) {
|
|
|
if (dest.exists()) {
|
|
@@ -1918,13 +1916,13 @@ public class GUI implements CategoryListener {
|
|
|
*/
|
|
|
private void addObjectAction(String objType, DefaultMutableTreeNode selectedNode) {
|
|
|
if (selectedNode == null) {
|
|
|
- JOptionPane.showMessageDialog(new JFrame(),
|
|
|
+ JOptionPane.showMessageDialog(frmCyberPhysical,
|
|
|
"Please select a Category first before adding " + objType + ".");
|
|
|
}
|
|
|
// if selected node is a directory for Categories
|
|
|
else {
|
|
|
if (selectedNode.getLevel() == 1) {
|
|
|
- String objname = JOptionPane.showInputDialog("Please enter a Name for the " + objType);
|
|
|
+ String objname = JOptionPane.showInputDialog(frmCyberPhysical, "Please enter a Name for the " + objType);
|
|
|
Category cat = controller.searchCategory(selectedNode.getUserObject().toString());
|
|
|
|
|
|
if (objname.length() != 0) {
|
|
@@ -1940,7 +1938,7 @@ public class GUI implements CategoryListener {
|
|
|
|
|
|
}
|
|
|
} else {
|
|
|
- JOptionPane.showMessageDialog(new JFrame(),
|
|
|
+ JOptionPane.showMessageDialog(frmCyberPhysical,
|
|
|
"Objects can not be added to Objects. Please select a Category.");
|
|
|
}
|
|
|
}
|