|
@@ -18,6 +18,9 @@ import javax.swing.JTabbedPane;
|
|
|
import javax.swing.JTable;
|
|
|
import javax.swing.tree.DefaultTreeModel;
|
|
|
|
|
|
+import ui.model.Category;
|
|
|
+import ui.model.HolonObject;
|
|
|
+import ui.model.Model;
|
|
|
|
|
|
import javax.swing.tree.DefaultMutableTreeNode;
|
|
|
import javax.swing.JEditorPane;
|
|
@@ -33,6 +36,8 @@ import javax.swing.JPanel;
|
|
|
public class GUI {
|
|
|
|
|
|
private JFrame frmCyberPhysical;
|
|
|
+
|
|
|
+
|
|
|
private final JMenuBar menuBar = new JMenuBar();
|
|
|
private final JMenu mnNewMenu = new JMenu("File");
|
|
|
private final JMenu mnNewMenu_1 = new JMenu("Edit");
|
|
@@ -53,37 +58,14 @@ public class GUI {
|
|
|
private final JSplitPane splitPane_2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
|
|
private JTable table;
|
|
|
private final JTable table_2 = new JTable();
|
|
|
+ private Model model;
|
|
|
|
|
|
- /**
|
|
|
- * Launch the application.
|
|
|
- */
|
|
|
- public static void main(String[] args) {
|
|
|
-
|
|
|
- //*Design
|
|
|
- try {
|
|
|
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
|
|
- } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
|
|
|
- | UnsupportedLookAndFeelException e1) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e1.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- EventQueue.invokeLater(new Runnable() {
|
|
|
- public void run() {
|
|
|
- try {
|
|
|
- GUI window = new GUI();
|
|
|
- window.frmCyberPhysical.setVisible(true);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* Create the application.
|
|
|
*/
|
|
|
- public GUI() {
|
|
|
+ public GUI(Model model) {
|
|
|
+ this.model = model;
|
|
|
initialize();
|
|
|
}
|
|
|
|
|
@@ -177,29 +159,7 @@ public class GUI {
|
|
|
|
|
|
splitPane.setLeftComponent(scrollPane_1);
|
|
|
tree.setEditable(true);
|
|
|
- tree.setModel(new DefaultTreeModel(
|
|
|
- new DefaultMutableTreeNode("Components") {
|
|
|
- {
|
|
|
- DefaultMutableTreeNode node_1;
|
|
|
- node_1 = new DefaultMutableTreeNode("PowerPlant");
|
|
|
- node_1.add(new DefaultMutableTreeNode("Standart P.P"));
|
|
|
- node_1.add(new DefaultMutableTreeNode("Power PowerPlant"));
|
|
|
- add(node_1);
|
|
|
- node_1 = new DefaultMutableTreeNode("Houses");
|
|
|
- node_1.add(new DefaultMutableTreeNode("Hospital"));
|
|
|
- node_1.add(new DefaultMutableTreeNode("Standart House"));
|
|
|
- node_1.add(new DefaultMutableTreeNode("Castle"));
|
|
|
- node_1.add(new DefaultMutableTreeNode("Arena"));
|
|
|
- add(node_1);
|
|
|
- node_1 = new DefaultMutableTreeNode("Cars");
|
|
|
- node_1.add(new DefaultMutableTreeNode("Small Car"));
|
|
|
- node_1.add(new DefaultMutableTreeNode("Medium Car"));
|
|
|
- node_1.add(new DefaultMutableTreeNode("Big Car"));
|
|
|
- node_1.add(new DefaultMutableTreeNode("Invisible Car"));
|
|
|
- add(node_1);
|
|
|
- }
|
|
|
- }
|
|
|
- ));
|
|
|
+
|
|
|
|
|
|
scrollPane_1.setViewportView(tree);
|
|
|
|
|
@@ -219,4 +179,28 @@ public class GUI {
|
|
|
});
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ public void refreshCategories(){
|
|
|
+ tree.setModel(new DefaultTreeModel(
|
|
|
+ new DefaultMutableTreeNode("Categories") {
|
|
|
+ {
|
|
|
+ DefaultMutableTreeNode node_1;
|
|
|
+ for (Category c : model.getCategories()) {
|
|
|
+ node_1 = new DefaultMutableTreeNode(c.getName());
|
|
|
+
|
|
|
+ for (HolonObject hol : c.getObjects()) {
|
|
|
+ node_1.add(new DefaultMutableTreeNode(hol.getObjName()));
|
|
|
+ }
|
|
|
+ add(node_1);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ public JFrame getFrmCyberPhysical() {
|
|
|
+ return frmCyberPhysical;
|
|
|
+ }
|
|
|
+
|
|
|
}
|