|
@@ -2,6 +2,7 @@ package ui.view;
|
|
|
|
|
|
import java.awt.EventQueue;
|
|
import java.awt.EventQueue;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
|
import javax.swing.JFrame;
|
|
import javax.swing.JFrame;
|
|
import javax.swing.JMenuBar;
|
|
import javax.swing.JMenuBar;
|
|
@@ -10,7 +11,6 @@ import javax.swing.JMenuItem;
|
|
import javax.swing.UIManager;
|
|
import javax.swing.UIManager;
|
|
import javax.swing.UnsupportedLookAndFeelException;
|
|
import javax.swing.UnsupportedLookAndFeelException;
|
|
import javax.swing.JTree;
|
|
import javax.swing.JTree;
|
|
-
|
|
|
|
import javax.swing.BoxLayout;
|
|
import javax.swing.BoxLayout;
|
|
import javax.swing.JSplitPane;
|
|
import javax.swing.JSplitPane;
|
|
import javax.swing.JScrollPane;
|
|
import javax.swing.JScrollPane;
|
|
@@ -19,17 +19,25 @@ import javax.swing.JTable;
|
|
import javax.swing.tree.DefaultTreeModel;
|
|
import javax.swing.tree.DefaultTreeModel;
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+import ui.controller.Control;
|
|
import ui.model.*;
|
|
import ui.model.*;
|
|
|
|
|
|
import javax.swing.tree.DefaultMutableTreeNode;
|
|
import javax.swing.tree.DefaultMutableTreeNode;
|
|
import javax.swing.JEditorPane;
|
|
import javax.swing.JEditorPane;
|
|
import javax.swing.JFileChooser;
|
|
import javax.swing.JFileChooser;
|
|
import javax.swing.table.DefaultTableModel;
|
|
import javax.swing.table.DefaultTableModel;
|
|
|
|
+
|
|
import java.awt.Color;
|
|
import java.awt.Color;
|
|
import java.awt.Component;
|
|
import java.awt.Component;
|
|
import java.awt.Window.Type;
|
|
import java.awt.Window.Type;
|
|
|
|
+
|
|
import javax.swing.JInternalFrame;
|
|
import javax.swing.JInternalFrame;
|
|
|
|
+
|
|
import java.awt.BorderLayout;
|
|
import java.awt.BorderLayout;
|
|
|
|
+
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JTextField;
|
|
import javax.swing.JTextField;
|
|
import javax.swing.JToolBar;
|
|
import javax.swing.JToolBar;
|
|
@@ -37,16 +45,23 @@ import javax.swing.JButton;
|
|
import javax.swing.JList;
|
|
import javax.swing.JList;
|
|
import javax.swing.ListSelectionModel;
|
|
import javax.swing.ListSelectionModel;
|
|
import javax.swing.AbstractListModel;
|
|
import javax.swing.AbstractListModel;
|
|
|
|
+
|
|
import java.awt.Choice;
|
|
import java.awt.Choice;
|
|
|
|
+
|
|
import javax.swing.JComboBox;
|
|
import javax.swing.JComboBox;
|
|
import javax.swing.DefaultComboBoxModel;
|
|
import javax.swing.DefaultComboBoxModel;
|
|
import javax.swing.GroupLayout;
|
|
import javax.swing.GroupLayout;
|
|
import javax.swing.GroupLayout.Alignment;
|
|
import javax.swing.GroupLayout.Alignment;
|
|
|
|
+
|
|
|
|
+import Interfaces.CategoryListener;
|
|
|
|
+
|
|
import java.awt.GridBagLayout;
|
|
import java.awt.GridBagLayout;
|
|
import java.awt.GridBagConstraints;
|
|
import java.awt.GridBagConstraints;
|
|
import java.awt.Font;
|
|
import java.awt.Font;
|
|
|
|
+import java.awt.event.ActionListener;
|
|
|
|
+import java.awt.event.ActionEvent;
|
|
|
|
|
|
-public class GUI {
|
|
|
|
|
|
+public class GUI implements CategoryListener {
|
|
|
|
|
|
private JFrame frmCyberPhysical;
|
|
private JFrame frmCyberPhysical;
|
|
|
|
|
|
@@ -72,18 +87,27 @@ public class GUI {
|
|
private JTable table;
|
|
private JTable table;
|
|
private final JTable table_2 = new JTable();
|
|
private final JTable table_2 = new JTable();
|
|
private Model model;
|
|
private Model model;
|
|
|
|
+ private final Control control;
|
|
|
|
+ public Control getControl() {
|
|
|
|
+ return control;
|
|
|
|
+ }
|
|
|
|
+
|
|
private final JPanel panel = new JPanel();
|
|
private final JPanel panel = new JPanel();
|
|
private final JTextField textField = new JTextField();
|
|
private final JTextField textField = new JTextField();
|
|
private final JComboBox comboBox = new JComboBox();
|
|
private final JComboBox comboBox = new JComboBox();
|
|
private final JButton btnAdd = new JButton("Add");
|
|
private final JButton btnAdd = new JButton("Add");
|
|
|
|
+
|
|
|
|
+
|
|
private final JToolBar toolBar = new JToolBar();
|
|
private final JToolBar toolBar = new JToolBar();
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* Create the application.
|
|
* Create the application.
|
|
*/
|
|
*/
|
|
- public GUI(Model model) {
|
|
|
|
- this.model = model;
|
|
|
|
|
|
+ public GUI(Control control) {
|
|
|
|
+ this.control = control;
|
|
|
|
+ this.model = control.getModel();
|
|
|
|
+ model.addCatListener(this);
|
|
initialize();
|
|
initialize();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -187,6 +211,15 @@ public class GUI {
|
|
panel.add(toolBar);
|
|
panel.add(toolBar);
|
|
toolBar.add(comboBox);
|
|
toolBar.add(comboBox);
|
|
comboBox.setModel(new DefaultComboBoxModel(new String[] {"Category", "Object"}));
|
|
comboBox.setModel(new DefaultComboBoxModel(new String[] {"Category", "Object"}));
|
|
|
|
+ btnAdd.addActionListener(new ActionListener() {
|
|
|
|
+ public void actionPerformed(ActionEvent arg0) {
|
|
|
|
+ if(comboBox.getSelectedItem().toString() == "Category"){
|
|
|
|
+ control.addCategory(textField.getText());
|
|
|
|
+ }
|
|
|
|
+ else if(comboBox.getSelectedItem().toString()== "Object"){
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
toolBar.add(btnAdd);
|
|
toolBar.add(btnAdd);
|
|
panel.add(textField);
|
|
panel.add(textField);
|
|
frmCyberPhysical.getContentPane().add(splitPane);
|
|
frmCyberPhysical.getContentPane().add(splitPane);
|
|
@@ -208,15 +241,21 @@ public class GUI {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void onChange(ArrayList<Category> cats){
|
|
|
|
+ DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
|
|
|
|
+ refreshCategories(cats);
|
|
|
|
+ textField.setText("Test");
|
|
|
|
+ model.reload();
|
|
|
|
+ }
|
|
/**
|
|
/**
|
|
* reloads the Categories from Model
|
|
* reloads the Categories from Model
|
|
*/
|
|
*/
|
|
- public void refreshCategories(){
|
|
|
|
|
|
+ public void refreshCategories(final ArrayList<Category> cats){
|
|
tree.setModel(new DefaultTreeModel(
|
|
tree.setModel(new DefaultTreeModel(
|
|
new DefaultMutableTreeNode("Categories") {
|
|
new DefaultMutableTreeNode("Categories") {
|
|
{
|
|
{
|
|
DefaultMutableTreeNode node_1;
|
|
DefaultMutableTreeNode node_1;
|
|
- for (Category c : model.getCategories()) {
|
|
|
|
|
|
+ for (Category c : cats) {
|
|
node_1 = new DefaultMutableTreeNode(c.getName());
|
|
node_1 = new DefaultMutableTreeNode(c.getName());
|
|
|
|
|
|
//kann eventuell umgeändert werden
|
|
//kann eventuell umgeändert werden
|