|
@@ -373,7 +373,7 @@ public class GUI<E> implements CategoryListener {
|
|
unitGraph.empty();
|
|
unitGraph.empty();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
-
|
|
|
|
|
|
+
|
|
String cntrlFDown = "controlF";
|
|
String cntrlFDown = "controlF";
|
|
inputMap.put(KeyStroke.getKeyStroke("control F"), cntrlFDown);
|
|
inputMap.put(KeyStroke.getKeyStroke("control F"), cntrlFDown);
|
|
actionMap.put(cntrlFDown, new AbstractAction() {
|
|
actionMap.put(cntrlFDown, new AbstractAction() {
|
|
@@ -386,9 +386,6 @@ public class GUI<E> implements CategoryListener {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
String cntrlCDown = "controlC";
|
|
String cntrlCDown = "controlC";
|
|
inputMap.put(KeyStroke.getKeyStroke("control C"), cntrlCDown);
|
|
inputMap.put(KeyStroke.getKeyStroke("control C"), cntrlCDown);
|
|
actionMap.put(cntrlCDown, new AbstractAction() {
|
|
actionMap.put(cntrlCDown, new AbstractAction() {
|
|
@@ -888,12 +885,11 @@ public class GUI<E> implements CategoryListener {
|
|
if (value.toString().compareTo(cps.getObjName()) == 0) {
|
|
if (value.toString().compareTo(cps.getObjName()) == 0) {
|
|
File checkPath = new File(cps.getImage());
|
|
File checkPath = new File(cps.getImage());
|
|
if (checkPath.exists()) {
|
|
if (checkPath.exists()) {
|
|
- imgR = new ImageIcon(cps.getImage()).getImage().getScaledInstance(
|
|
|
|
- 50, 50, java.awt.Image.SCALE_SMOOTH);
|
|
|
|
|
|
+ imgR = new ImageIcon(cps.getImage()).getImage().getScaledInstance(50, 50,
|
|
|
|
+ java.awt.Image.SCALE_SMOOTH);
|
|
} else {
|
|
} else {
|
|
imgR = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage()
|
|
imgR = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage()
|
|
- .getScaledInstance(50, 50,
|
|
|
|
- java.awt.Image.SCALE_SMOOTH);
|
|
|
|
|
|
+ .getScaledInstance(50, 50, java.awt.Image.SCALE_SMOOTH);
|
|
}
|
|
}
|
|
if (imgR != null) {
|
|
if (imgR != null) {
|
|
label.setIcon(new ImageIcon(imgR));
|
|
label.setIcon(new ImageIcon(imgR));
|
|
@@ -995,13 +991,11 @@ public class GUI<E> implements CategoryListener {
|
|
if (actualObjectClicked.compareTo(cps.getObjName()) == 0) {
|
|
if (actualObjectClicked.compareTo(cps.getObjName()) == 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(
|
|
|
|
- 50, 50,
|
|
|
|
|
|
+ img = new ImageIcon(cps.getImage()).getImage().getScaledInstance(50, 50,
|
|
java.awt.Image.SCALE_SMOOTH);
|
|
java.awt.Image.SCALE_SMOOTH);
|
|
} else {
|
|
} else {
|
|
img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage()
|
|
img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage()
|
|
- .getScaledInstance(50, 50,
|
|
|
|
- java.awt.Image.SCALE_SMOOTH);
|
|
|
|
|
|
+ .getScaledInstance(50, 50, java.awt.Image.SCALE_SMOOTH);
|
|
}
|
|
}
|
|
tempCps = cps;
|
|
tempCps = cps;
|
|
dragging = true;
|
|
dragging = true;
|
|
@@ -1034,7 +1028,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
panel.add(toolBar);
|
|
panel.add(toolBar);
|
|
toolBar.add(comboBox);
|
|
toolBar.add(comboBox);
|
|
- comboBox.setModel(new DefaultComboBoxModel(new String[] { "Category", "Object", "Transformer", "Switch" }));
|
|
|
|
|
|
+ comboBox.setModel(new DefaultComboBoxModel(new String[] { "Category", "Object", "Switch" }));
|
|
// Add Button
|
|
// Add Button
|
|
btnAdd.addActionListener(new ActionListener() {
|
|
btnAdd.addActionListener(new ActionListener() {
|
|
public void actionPerformed(ActionEvent arg0) {
|
|
public void actionPerformed(ActionEvent arg0) {
|
|
@@ -1042,32 +1036,36 @@ public class GUI<E> implements CategoryListener {
|
|
Object nodeInfo = tree.getLastSelectedPathComponent();
|
|
Object nodeInfo = tree.getLastSelectedPathComponent();
|
|
String selectedOption = comboBox.getSelectedItem().toString();
|
|
String selectedOption = comboBox.getSelectedItem().toString();
|
|
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) nodeInfo;
|
|
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) nodeInfo;
|
|
|
|
+ try {
|
|
|
|
|
|
- switch (selectedOption) {
|
|
|
|
|
|
+ switch (selectedOption) {
|
|
|
|
|
|
- case "Category":
|
|
|
|
- String catName = JOptionPane.showInputDialog("Please enter a Name for Category ");
|
|
|
|
- if (catName.length() != 0) {
|
|
|
|
- controller.addCategory(catName);
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case "Object":
|
|
|
|
- if (selectedNode == null) {
|
|
|
|
- JOptionPane.showMessageDialog(new JFrame(),
|
|
|
|
- "Please select a Category first before adding " + selectedOption + ".");
|
|
|
|
- }
|
|
|
|
- if (selectedNode.getLevel() == 1) {
|
|
|
|
- CpsObject tmp = new HolonObject("");
|
|
|
|
- addObjectPopUP = new AddObjectPopUp(false, tmp, null);
|
|
|
|
- addObjectPopUP.setVisible(true);
|
|
|
|
- addObjectPopUP.setController(controller);
|
|
|
|
- addObjectPopUP.setCategory(selectedNode.toString());
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
|
|
+ case "Category":
|
|
|
|
+ String catName = JOptionPane.showInputDialog("Please enter a Name for Category ");
|
|
|
|
+ if (catName.length() != 0) {
|
|
|
|
+ controller.addCategory(catName);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case "Object":
|
|
|
|
+ if (selectedNode == null) {
|
|
|
|
+ JOptionPane.showMessageDialog(new JFrame(),
|
|
|
|
+ "Please select a Category first before adding " + selectedOption + ".");
|
|
|
|
+ }
|
|
|
|
+ if (selectedNode.getLevel() == 1) {
|
|
|
|
+ CpsObject tmp = new HolonObject("");
|
|
|
|
+ addObjectPopUP = new AddObjectPopUp(false, tmp, null);
|
|
|
|
+ addObjectPopUP.setVisible(true);
|
|
|
|
+ addObjectPopUP.setController(controller);
|
|
|
|
+ addObjectPopUP.setCategory(selectedNode.toString());
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
|
|
- default:
|
|
|
|
- addObjectAction(selectedOption, selectedNode);
|
|
|
|
- break;
|
|
|
|
|
|
+ default:
|
|
|
|
+ addObjectAction(selectedOption, selectedNode);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ // TODO: handle exception
|
|
}
|
|
}
|
|
tree.repaint();
|
|
tree.repaint();
|
|
}
|
|
}
|
|
@@ -1502,10 +1500,6 @@ public class GUI<E> implements CategoryListener {
|
|
case "Switch":
|
|
case "Switch":
|
|
controller.addSwitch(cat, objname);
|
|
controller.addSwitch(cat, objname);
|
|
break;
|
|
break;
|
|
-
|
|
|
|
- case "Transformer":
|
|
|
|
- controller.addTransformer(cat, objname);
|
|
|
|
- break;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|