Remove TODO file
[remote/remote-gui.git] / src / main / util / MoteStatusRenderer.java
blobbf476030229972a9e399b6a62afee3f6d5a2673c
1 package util;
3 import javax.swing.JLabel;
4 import javax.swing.JTable;
5 import javax.swing.table.TableCellRenderer;
6 import java.awt.Component;
7 import java.util.Comparator;
9 import diku.distlab.motecontrolclientlib.client.*;
11 public class MoteStatusRenderer extends JLabel implements TableCellRenderer, Comparator {
13 /**
16 private static final long serialVersionUID = 6986857411085856617L;
18 public MoteStatusRenderer()
23 public Component getTableCellRendererComponent(
24 JTable table, Object value,
25 boolean isSelected, boolean hasFocus,
26 int row, int column) {
27 setText(getText(((SimpleMoteStatus)value).getStatus()));
28 return this;
31 public static String getText(short s)
33 switch(s)
35 case SimpleMoteStatus.UNAVAILABLE:
36 return "Control unavailable!";
37 case SimpleMoteStatus.REQ_CANCELPROGRAMMING:
38 return "Cancelling programming...";
39 case SimpleMoteStatus.REQ_PROGRAM:
40 case SimpleMoteStatus.PROGRAMMING:
41 return "Programming...";
42 case SimpleMoteStatus.REQ_RESET:
43 return "Resetting...";
44 case SimpleMoteStatus.REQ_START:
45 return "Starting...";
46 case SimpleMoteStatus.REQ_STOP:
47 return "Stopping..";
48 case SimpleMoteStatus.RUNNING:
49 return "Running";
50 case SimpleMoteStatus.STOPPED:
51 return "Stopped";
52 case SimpleMoteStatus.UNKNOWN:
53 return "Status unknown";
54 default:
55 return "Invalid status "+s;
59 public int compare(Object arg0, Object arg1) {
60 SimpleMoteStatus s0,s1;
61 s0 = (SimpleMoteStatus)arg0;
62 s1 = (SimpleMoteStatus)arg1;
63 return getText(s0.getStatus()).compareTo(getText(s1.getStatus()));