|
@@ -176,7 +176,7 @@ public class GUI{
|
|
|
private final JLabel minGraph = new JLabel("0%");
|
|
|
private final JLabel elementGraph = new JLabel("None ");
|
|
|
private final ArrayList<HolonElement> selectedElements = new ArrayList<>();
|
|
|
- private final JTree tree = new JTree();
|
|
|
+ private final JTree categoryTree = new JTree();
|
|
|
/******************************************
|
|
|
************* Right Container*************
|
|
|
******************************************
|
|
@@ -337,6 +337,7 @@ public class GUI{
|
|
|
initialize();
|
|
|
updateCategories(model.getCategories());
|
|
|
updCon = new UpdateController(model, controller);
|
|
|
+ control.OnCategoryChanged.addListener(() -> this.updateCategoryUI(model.getCategories()));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -727,8 +728,8 @@ public class GUI{
|
|
|
} catch (Exception e2) {
|
|
|
System.out.println(e2.getMessage());
|
|
|
}
|
|
|
-
|
|
|
- tree.repaint();
|
|
|
+ categoryTree.revalidate();
|
|
|
+ categoryTree.repaint();
|
|
|
});
|
|
|
|
|
|
|
|
@@ -1539,7 +1540,7 @@ public class GUI{
|
|
|
****************/
|
|
|
|
|
|
// Override Key Actions
|
|
|
- inputMap = tree.getInputMap();
|
|
|
+ inputMap = categoryTree.getInputMap();
|
|
|
inputMap.put(KeyStroke.getKeyStroke("control C"), cntrlCDown);
|
|
|
inputMap.put(KeyStroke.getKeyStroke("control V"), cntrlVDown);
|
|
|
inputMap.put(KeyStroke.getKeyStroke("control X"), cntrlXDown);
|
|
@@ -1584,9 +1585,9 @@ public class GUI{
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- tree.setCellRenderer(customRenderer);
|
|
|
+ categoryTree.setCellRenderer(customRenderer);
|
|
|
|
|
|
- tree.addMouseMotionListener(new MouseMotionAdapter() {
|
|
|
+ categoryTree.addMouseMotionListener(new MouseMotionAdapter() {
|
|
|
|
|
|
public void mouseDragged(MouseEvent e){
|
|
|
checkForDragAndDrop(e);
|
|
@@ -1661,7 +1662,7 @@ public class GUI{
|
|
|
}});
|
|
|
|
|
|
|
|
|
- tree.addMouseListener(new MouseAdapter() {
|
|
|
+ categoryTree.addMouseListener(new MouseAdapter() {
|
|
|
|
|
|
public void mouseReleased(MouseEvent e) {
|
|
|
try {
|
|
@@ -1753,16 +1754,16 @@ public class GUI{
|
|
|
editItem.setEnabled(false);
|
|
|
editItem.addActionListener(actionEvent -> {
|
|
|
});
|
|
|
- tree.addMouseListener(new MouseAdapter() {
|
|
|
+ categoryTree.addMouseListener(new MouseAdapter() {
|
|
|
|
|
|
public void mousePressed(MouseEvent e) {
|
|
|
try {
|
|
|
- actualObjectClicked = tree
|
|
|
+ actualObjectClicked = categoryTree
|
|
|
.getPathForLocation(e.getX(), e.getY())
|
|
|
.getLastPathComponent().toString();
|
|
|
// if an Object was selected, the porperties are shown in
|
|
|
// the table
|
|
|
- DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) tree
|
|
|
+ DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) categoryTree
|
|
|
.getPathForLocation(e.getX(), e.getY())
|
|
|
.getLastPathComponent();
|
|
|
if (selectedNode.getLevel() == 2) {
|
|
@@ -1844,7 +1845,7 @@ public class GUI{
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
});
|
|
|
- scrollPane1.setViewportView(tree);
|
|
|
+ scrollPane1.setViewportView(categoryTree);
|
|
|
|
|
|
scrollPane1.setColumnHeaderView(panel);
|
|
|
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
|
@@ -1994,7 +1995,7 @@ public class GUI{
|
|
|
|
|
|
// Del Button
|
|
|
btnDel.addActionListener(actionEvent -> {
|
|
|
- Object nodeInfo = tree.getLastSelectedPathComponent();
|
|
|
+ Object nodeInfo = categoryTree.getLastSelectedPathComponent();
|
|
|
if (nodeInfo != null) {
|
|
|
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) nodeInfo;
|
|
|
String nodeName = selectedNode.getUserObject().toString();
|
|
@@ -2028,7 +2029,7 @@ public class GUI{
|
|
|
JOptionPane.showMessageDialog(holegJFrame,
|
|
|
selectObjBeforeErase);
|
|
|
}
|
|
|
- tree.repaint();
|
|
|
+ categoryTree.repaint();
|
|
|
});
|
|
|
btnDel.setIcon(new ImageIcon(ImageImport.loadImage("Images/minus.png", 16, 16)));
|
|
|
btnDel.setToolTipText("<html><b>Delete</b><br>Removes a Category or a Category Item.</html>");
|
|
@@ -2080,7 +2081,7 @@ public class GUI{
|
|
|
try {
|
|
|
controller.loadFile(file.getAbsolutePath());
|
|
|
canvas.repaint();
|
|
|
- tree.repaint();
|
|
|
+ categoryTree.repaint();
|
|
|
controller.calculateStateAndVisualForCurrentTimeStep();
|
|
|
} catch (IOException | ArchiveException e) {
|
|
|
e.printStackTrace();
|
|
@@ -2417,7 +2418,7 @@ public class GUI{
|
|
|
|
|
|
}
|
|
|
});
|
|
|
- tree.setModel(treemodel);
|
|
|
+ categoryTree.setModel(treemodel);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -2426,8 +2427,8 @@ public class GUI{
|
|
|
* @param categories
|
|
|
* the Categories
|
|
|
*/
|
|
|
- public void onChange(ArrayList<Category> categories) {
|
|
|
- DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
|
|
|
+ public void updateCategoryUI(ArrayList<Category> categories) {
|
|
|
+ DefaultTreeModel model = (DefaultTreeModel) categoryTree.getModel();
|
|
|
updateCategories(categories);
|
|
|
model.reload();
|
|
|
}
|