|
@@ -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);
|
|
@@ -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);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -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) {
|
|
@@ -1438,14 +1438,14 @@ 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) {
|
|
@@ -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.");
|
|
|
}
|
|
|
}
|