Remove TODO file
[remote/remote-gui.git] / src / main / gui / treeorderings / OrderingsAllMotesView.java
blobee4c8688f51aa5cfc0748f5517f66b80382f34a8
1 package gui.treeorderings;
3 import gui.ReMote;
4 import gui.RenderableTreeNode;
6 import java.awt.Color;
7 import java.awt.Component;
9 import javax.swing.ImageIcon;
10 import javax.swing.JLabel;
11 import javax.swing.JPanel;
13 import util.MoteControlRow;
14 import util.TableRowOrdering;
16 import diku.distlab.remote.client.motedata.TableRow;
18 public class OrderingsAllMotesView {
20 private static class MoteNodeRenderer extends RenderableTreeNode {
21 JPanel mote = new JPanel();
23 protected MoteNodeRenderer(Comparable key, TableRow row) {
24 super(key);
25 mote.setBackground(new Color(0, true));
26 String labeltext = "";
27 java.net.URL imageURL = ReMote.class
28 .getResource("/icons/mote16x16.png");
29 ImageIcon icon = new ImageIcon(imageURL);
30 JLabel label = new JLabel(icon);
31 try {
32 labeltext = key.toString();
33 imageURL = null;
34 String availability = row.get("mote_usage").toString();
35 if (availability.equals("available")) {
36 imageURL = null;
37 /*} else if (availability.equals("available_project")) {
38 imageURL = ReMote.class.getResource("/icons/clock.png");
40 } else if (availability.equals("reserved")) {
41 imageURL = ReMote.class.getResource("/icons/lock_off.png");*/
43 } else if (availability.equals("occupied")) {
44 imageURL = ReMote.class.getResource("/icons/lock_on.png");
45 /*} else if (availability.equals("occupied_project")) {
46 imageURL = ReMote.class.getResource("/icons/lock_on.png");*/
47 } else if (availability.equals("controlled")) {
48 imageURL = ReMote.class.getResource("/icons/user.gif");
50 } catch (Exception e) {
51 e.printStackTrace();
53 label.setText(labeltext);
54 mote.setToolTipText(getToolTip(row));
55 mote.add(label);
56 if (imageURL != null) {
57 mote.add(new JLabel(new ImageIcon(imageURL)));
61 protected static String getToolTip(TableRow row) {
62 try {
63 //return "mote";
64 return row.get("tosaddress") + " - (" + row.get("macaddress")
65 + ") @ " + row.get("site");
66 } catch (Exception e) {
67 e.printStackTrace();
68 return "";
72 public Component getRenderable() {
73 return mote;
78 private static class RenderableOrdering extends SimpleTableRowOrdering {
80 public RenderableOrdering(String key, String name, boolean total) {
81 super(key, name, total);
84 public Comparable getKey(TableRow row) {
85 return new MoteNodeRenderer(super.getKey(row), row);
89 public static TableRowOrdering BY_USAGE
90 = new SimpleTableRowOrdering("mote_usage", "Usage", false);/*
92 public static TableRowOrdering BY_RESERVATION
93 = new SimpleTableRowOrdering("reservation", "reservation", false);
95 public static TableRowOrdering BY_ROOM
96 = new SimpleTableRowOrdering("room", "room", false);**/
98 public static TableRowOrdering BY_TOS
99 = new RenderableOrdering("tosaddress","TOS",true);
101 public static TableRowOrdering BY_MAC
102 = new RenderableOrdering("macaddress","MAC",true);
104 /**public static TableRowOrdering BY_MOTE_ID
105 = new RenderableOrdering("mote_id","mote_id",true);**/
108 public static TableRowOrdering[] orderings
109 = { BY_TOS,BY_MAC,BY_USAGE };