|
@@ -27,11 +27,9 @@ import javax.swing.DefaultComboBoxModel;
|
|
|
import javax.swing.ImageIcon;
|
|
|
import javax.swing.InputMap;
|
|
|
import javax.swing.JButton;
|
|
|
-import javax.swing.JCheckBoxMenuItem;
|
|
|
import javax.swing.JComboBox;
|
|
|
import javax.swing.JComponent;
|
|
|
import javax.swing.JDialog;
|
|
|
-import javax.swing.JEditorPane;
|
|
|
import javax.swing.JFileChooser;
|
|
|
import javax.swing.JFrame;
|
|
|
import javax.swing.JLabel;
|
|
@@ -109,7 +107,6 @@ public class GUI<E> implements CategoryListener {
|
|
|
private String holonEleNamesDisplayed = "None ";
|
|
|
HashMap<Integer, ArrayList<HolonElement>> eleToDelete = new HashMap<Integer, ArrayList<HolonElement>>();
|
|
|
private final JTree tree = new JTree();
|
|
|
- private final JEditorPane dtrpnHereWillBe = new JEditorPane();
|
|
|
/******************************************
|
|
|
************* Right Container*************
|
|
|
******************************************/
|
|
@@ -135,6 +132,11 @@ public class GUI<E> implements CategoryListener {
|
|
|
// Table for Properties --> Cell with (0,1) is editable by CpsObjt and
|
|
|
// Cell(3,1) is editable by Edges
|
|
|
private JTable tableProperties = new JTable() {
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
+
|
|
|
@Override
|
|
|
public TableCellRenderer getCellRenderer(int row, int column) {
|
|
|
if (getValueAt(row, column) instanceof Boolean) {
|
|
@@ -231,6 +233,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
simMenu = new SimulationMenu(model, control);
|
|
|
initialize();
|
|
|
updateCategories(model.getCategories());
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -278,6 +281,11 @@ public class GUI<E> implements CategoryListener {
|
|
|
inputMap.put(KeyStroke.getKeyStroke("control Z"), cntrlZDown);
|
|
|
actionMap.put(cntrlZDown, new AbstractAction() {
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
+
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
try {
|
|
@@ -310,6 +318,11 @@ public class GUI<E> implements CategoryListener {
|
|
|
inputMap.put(KeyStroke.getKeyStroke("control Y"), cntrlYDown);
|
|
|
actionMap.put(cntrlYDown, new AbstractAction() {
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
+
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
try {
|
|
@@ -341,6 +354,11 @@ public class GUI<E> implements CategoryListener {
|
|
|
String cntrlADown = "controlA";
|
|
|
inputMap.put(KeyStroke.getKeyStroke("control A"), cntrlADown);
|
|
|
actionMap.put(cntrlADown, new AbstractAction() {
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
+
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
model.getSelectedCpsObjects().clear();
|
|
@@ -354,6 +372,11 @@ public class GUI<E> implements CategoryListener {
|
|
|
String delDown = "delete";
|
|
|
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false), delDown);
|
|
|
actionMap.put(delDown, new AbstractAction() {
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
+
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
for (CpsObject cps : model.getSelectedCpsObjects()) {
|
|
@@ -373,11 +396,16 @@ public class GUI<E> implements CategoryListener {
|
|
|
unitGraph.empty();
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
String cntrlFDown = "controlF";
|
|
|
inputMap.put(KeyStroke.getKeyStroke("control F"), cntrlFDown);
|
|
|
actionMap.put(cntrlFDown, new AbstractAction() {
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
+
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
searchPopUp dialog = new searchPopUp(controller, canvas);
|
|
@@ -386,13 +414,15 @@ public class GUI<E> implements CategoryListener {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
String cntrlCDown = "controlC";
|
|
|
inputMap.put(KeyStroke.getKeyStroke("control C"), cntrlCDown);
|
|
|
actionMap.put(cntrlCDown, new AbstractAction() {
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
+
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
if (!model.getSelectedCpsObjects().isEmpty()) {
|
|
@@ -408,6 +438,11 @@ public class GUI<E> implements CategoryListener {
|
|
|
inputMap.put(KeyStroke.getKeyStroke("control V"), cntrlVDown);
|
|
|
actionMap.put(cntrlVDown, new AbstractAction() {
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
+
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
controller.pasteObjects(canvas.getMousePosition());
|
|
@@ -419,6 +454,11 @@ public class GUI<E> implements CategoryListener {
|
|
|
inputMap.put(KeyStroke.getKeyStroke("control X"), cntrlXDown);
|
|
|
actionMap.put(cntrlXDown, new AbstractAction() {
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
+
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
if (!model.getSelectedCpsObjects().isEmpty()) {
|
|
@@ -888,12 +928,11 @@ public class GUI<E> implements CategoryListener {
|
|
|
if (value.toString().compareTo(cps.getObjName()) == 0) {
|
|
|
File checkPath = new File(cps.getImage());
|
|
|
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 {
|
|
|
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) {
|
|
|
label.setIcon(new ImageIcon(imgR));
|
|
@@ -966,7 +1005,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) tree
|
|
|
.getPathForLocation(e.getX(), e.getY()).getLastPathComponent();
|
|
|
if (selectedNode.getLevel() == 2) {
|
|
|
- CpsObject selected = controller.searchCategoryObject(selectedNode.getParent().toString(),
|
|
|
+ controller.searchCategoryObject(selectedNode.getParent().toString(),
|
|
|
selectedNode.toString());
|
|
|
deleteRows(tableModelHolonElementSingle);
|
|
|
deleteRows(tableModelHolonElementMulti);
|
|
@@ -995,13 +1034,11 @@ public class GUI<E> implements CategoryListener {
|
|
|
if (actualObjectClicked.compareTo(cps.getObjName()) == 0) {
|
|
|
File checkPath = new File(cps.getImage());
|
|
|
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);
|
|
|
} else {
|
|
|
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;
|
|
|
dragging = true;
|
|
@@ -1034,7 +1071,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
panel.add(toolBar);
|
|
|
toolBar.add(comboBox);
|
|
|
- comboBox.setModel(new DefaultComboBoxModel(new String[] { "Category", "Object", "Transformer", "Switch" }));
|
|
|
+ comboBox.setModel(new DefaultComboBoxModel(new String[] { "Category", "Object", "Switch" }));
|
|
|
// Add Button
|
|
|
btnAdd.addActionListener(new ActionListener() {
|
|
|
public void actionPerformed(ActionEvent arg0) {
|
|
@@ -1042,32 +1079,36 @@ public class GUI<E> implements CategoryListener {
|
|
|
Object nodeInfo = tree.getLastSelectedPathComponent();
|
|
|
String selectedOption = comboBox.getSelectedItem().toString();
|
|
|
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();
|
|
|
}
|
|
@@ -1502,10 +1543,6 @@ public class GUI<E> implements CategoryListener {
|
|
|
case "Switch":
|
|
|
controller.addSwitch(cat, objname);
|
|
|
break;
|
|
|
-
|
|
|
- case "Transformer":
|
|
|
- controller.addTransformer(cat, objname);
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -1520,6 +1557,11 @@ public class GUI<E> implements CategoryListener {
|
|
|
*/
|
|
|
public void updateCategories(final ArrayList<Category> categories) {
|
|
|
tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Categories") {
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
+
|
|
|
{
|
|
|
DefaultMutableTreeNode node_1;
|
|
|
for (Category c : categories) {
|