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
{
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()));
31 public static String
getText(short 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
:
46 case SimpleMoteStatus
.REQ_STOP
:
48 case SimpleMoteStatus
.RUNNING
:
50 case SimpleMoteStatus
.STOPPED
:
52 case SimpleMoteStatus
.UNKNOWN
:
53 return "Status unknown";
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()));