1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package de.desy.acop.displayers.table;
24
25 import com.cosylab.gui.components.table.cells.StringCell;
26 import com.cosylab.gui.components.table.cells.TableCell;
27 import com.cosylab.gui.displayers.DataConsumer;
28 import com.cosylab.gui.displayers.DataState;
29 import com.cosylab.gui.displayers.DisplayerUtilities;
30 import com.cosylab.gui.displayers.StringSeqConsumer;
31
32 import de.desy.acop.displayers.AcopTable;
33
34
35
36
37
38
39
40 public class AcopStringTableColumn extends AcopTableColumn implements StringSeqConsumer {
41
42 @SuppressWarnings("unchecked")
43 public static final Class[] SUPPORTED_CONSUMER_TYPES = {
44 StringSeqConsumer.class
45 };
46 public static final String[] SUPPORTED_CHARACTERISTICS = {};
47
48 private String[] rows;
49 private DataState state = new DataState(DataState.NORMAL);
50
51
52
53
54
55 public AcopStringTableColumn() {
56 super();
57 }
58
59
60
61
62
63
64
65
66 public AcopStringTableColumn(AcopTable table, String uniqueName, String shortName) {
67 super(table, uniqueName, shortName);
68 rows = new String[0];
69 cells= new StringCell[0];
70 }
71
72
73
74
75
76 public Class<?> getColumnClass() {
77 return StringCell.class;
78 }
79
80
81
82
83 public String[] getSupportedCharacteristics() {
84 return DisplayerUtilities.combineCharacteristics(DisplayerUtilities.COMMON_NUMERIC_DISPLAYER_CHARACTERISTICS,
85 SUPPORTED_CHARACTERISTICS);
86 }
87
88
89
90
91 @SuppressWarnings("unchecked")
92 public Class<DataConsumer>[] getSupportedConsumerTypes() {
93 return SUPPORTED_CONSUMER_TYPES;
94 }
95
96
97
98
99
100 public Object getValue(int rowIndex) {
101 if (rows == null || rowIndex >= rows.length || rowIndex < 0) return null;
102 if (cells[rowIndex] == null) {
103 cells[rowIndex] = new StringCell(displayerParameters.getName()+"[" + rowIndex+"]", this, rows[rowIndex], null);
104 cells[rowIndex].putAllCharacteristics(characteristics);
105 cells[rowIndex].putCharacteristic(TableCell.SUSPENDED, false);
106 cells[rowIndex].putCharacteristic(TableCell.ALARM, false);
107 cells[rowIndex].putCharacteristic(TableCell.WARNING, false);
108 cells[rowIndex].putCharacteristic(TableCell.TIMEOUT, false);
109 cells[rowIndex].putCharacteristic(TableCell.ERROR, false);
110 } else {
111 cells[rowIndex].setValue(rows[rowIndex]);
112 }
113 setCharacteristicsOnCell(cells[rowIndex]);
114 return cells[rowIndex];
115 }
116
117
118
119
120
121 public void updateValue(long timestamp, String[] names) {
122 rows = names;
123 if (cells.length != names.length) {
124 cells = new StringCell[names.length];
125 }
126 fireColumnChanged();
127 }
128
129
130
131
132
133 public DataState getDataState() {
134 return state;
135 }
136 }