1 package gui
.treeorderings
;
4 import gui
.RenderableTreeNode
;
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
) {
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
);
32 labeltext
= key
.toString();
34 String availability
= row
.get("mote_usage").toString();
35 if (availability
.equals("available")) {
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
) {
53 label
.setText(labeltext
);
54 mote
.setToolTipText(getToolTip(row
));
56 if (imageURL
!= null) {
57 mote
.add(new JLabel(new ImageIcon(imageURL
)));
61 protected static String
getToolTip(TableRow row
) {
64 return row
.get("tosaddress") + " - (" + row
.get("macaddress")
65 + ") @ " + row
.get("site");
66 } catch (Exception e
) {
72 public Component
getRenderable() {
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
};