|
@@ -1,9 +1,9 @@
|
|
package de.tu_darmstadt.tk.SmartHomeNetworkSim.view.popups;
|
|
package de.tu_darmstadt.tk.SmartHomeNetworkSim.view.popups;
|
|
|
|
|
|
|
|
+import java.awt.Color;
|
|
import java.awt.Component;
|
|
import java.awt.Component;
|
|
-import java.util.Random;
|
|
|
|
|
|
|
|
-import javax.swing.JLabel;
|
|
|
|
|
|
+import javax.swing.JCheckBox;
|
|
import javax.swing.JTree;
|
|
import javax.swing.JTree;
|
|
import javax.swing.tree.DefaultMutableTreeNode;
|
|
import javax.swing.tree.DefaultMutableTreeNode;
|
|
import javax.swing.tree.TreeCellRenderer;
|
|
import javax.swing.tree.TreeCellRenderer;
|
|
@@ -12,6 +12,7 @@ import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller;
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Connection;
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Connection;
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Link;
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Link;
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
|
|
|
|
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.configuration.NetworkTreeNodeStatus;
|
|
|
|
|
|
/**
|
|
/**
|
|
* TreeCellRenderer for the Network tree, which visualizes the different network parts
|
|
* TreeCellRenderer for the Network tree, which visualizes the different network parts
|
|
@@ -22,7 +23,7 @@ public class NetworkTreeCellRenderer implements TreeCellRenderer {
|
|
/**
|
|
/**
|
|
* Label which describes the node
|
|
* Label which describes the node
|
|
*/
|
|
*/
|
|
- private JLabel label;
|
|
|
|
|
|
+ private JCheckBox label;
|
|
/**
|
|
/**
|
|
* Controller to manipulate / get infos from the model
|
|
* Controller to manipulate / get infos from the model
|
|
*/
|
|
*/
|
|
@@ -32,30 +33,32 @@ public class NetworkTreeCellRenderer implements TreeCellRenderer {
|
|
*/
|
|
*/
|
|
public NetworkTreeCellRenderer(Controller controller) {
|
|
public NetworkTreeCellRenderer(Controller controller) {
|
|
this.controller = controller;
|
|
this.controller = controller;
|
|
- label = new JLabel();
|
|
|
|
|
|
+ label = new JCheckBox();
|
|
|
|
+ label.setBackground(Color.WHITE);
|
|
}
|
|
}
|
|
@Override
|
|
@Override
|
|
public Component getTreeCellRendererComponent(JTree tree, Object value,
|
|
public Component getTreeCellRendererComponent(JTree tree, Object value,
|
|
boolean selected, boolean expanded, boolean leaf, int row,
|
|
boolean selected, boolean expanded, boolean leaf, int row,
|
|
boolean hasFocus) {
|
|
boolean hasFocus) {
|
|
- /**
|
|
|
|
- * TODO: TreeSelection Settings
|
|
|
|
- * e.g. HashMap Link -> Link Settings (visible, color etc.)
|
|
|
|
- */
|
|
|
|
- controller.getSettingsController();
|
|
|
|
/**
|
|
/**
|
|
* Object which should be rendered
|
|
* Object which should be rendered
|
|
*/
|
|
*/
|
|
Object o = ((DefaultMutableTreeNode) value).getUserObject();
|
|
Object o = ((DefaultMutableTreeNode) value).getUserObject();
|
|
|
|
+ /**
|
|
|
|
+ * Status of the object (hidden, expanded etc.)
|
|
|
|
+ */
|
|
|
|
+ NetworkTreeNodeStatus status = controller.getSettingsController().getConfigurationManager().getNetworkTreeSettings().getStatusOfObject(o);
|
|
|
|
+ label.setSelected(status.isVisible());
|
|
|
|
+
|
|
if (o instanceof SmartDevice) {
|
|
if (o instanceof SmartDevice) {
|
|
/**
|
|
/**
|
|
* Device to be rendered
|
|
* Device to be rendered
|
|
*/
|
|
*/
|
|
SmartDevice device = (SmartDevice) o;
|
|
SmartDevice device = (SmartDevice) o;
|
|
- boolean hidden = new Random().nextBoolean();
|
|
|
|
|
|
+ boolean hidden = !status.isVisible();
|
|
//label.setIcon(new ImageIcon(Utility.loadFile("/images/smartHome_icon.png").getScaledInstance(12, 12, 0)));
|
|
//label.setIcon(new ImageIcon(Utility.loadFile("/images/smartHome_icon.png").getScaledInstance(12, 12, 0)));
|
|
|
|
|
|
- label.setText("<html><font color=\""+(hidden?"grey":"black")+"\">"+device.getName()+"</font></html>");
|
|
|
|
|
|
+ label.setText("<html><font color=\""+(hidden?"red":"black")+"\">"+device.getName()+"</font></html>");
|
|
} else if (o instanceof Connection){
|
|
} else if (o instanceof Connection){
|
|
/**
|
|
/**
|
|
* Connection to be rendered
|
|
* Connection to be rendered
|
|
@@ -78,7 +81,7 @@ public class NetworkTreeCellRenderer implements TreeCellRenderer {
|
|
/**
|
|
/**
|
|
* Default use toString
|
|
* Default use toString
|
|
*/
|
|
*/
|
|
- label.setIcon(null);
|
|
|
|
|
|
+ //label.setIcon(null);
|
|
label.setText("" + value);
|
|
label.setText("" + value);
|
|
}
|
|
}
|
|
return label;
|
|
return label;
|