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.selector;
24
25 import java.awt.Dimension;
26 import java.awt.GridBagConstraints;
27 import java.awt.GridBagLayout;
28 import java.awt.Insets;
29
30 import javax.swing.JComboBox;
31 import javax.swing.JLabel;
32 import javax.swing.JPanel;
33 import javax.swing.JTextField;
34
35 import de.desy.acop.displayers.table.AcopTableParameters;
36 import de.desy.acop.displayers.table.TableColumnType;
37
38
39
40
41
42
43
44
45
46
47
48 public class TableCustomizerPanel extends MultipleDisplayerAbstractSettingsPanel<AcopTableParameters>{
49
50 private static final long serialVersionUID = -4547732237651600499L;
51 private JComboBox tableCustomizerCombo;
52 private JLabel tableCustomizerLabel;
53
54 private JTextField tableColumnNameField;
55 private JLabel tableColumnNameLabel;
56
57 private JPanel propertiesPanel;
58
59
60
61
62
63 public TableCustomizerPanel() {
64 super();
65 initialize();
66 }
67
68 private void initialize() {
69 setLayout(new GridBagLayout());
70 add(getPropertiesPanel(), new GridBagConstraints(0,0,1,1,1,1,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(0,0,0,0),0,0));
71 }
72
73 private JPanel getPropertiesPanel() {
74 if (propertiesPanel == null) {
75 propertiesPanel = new JPanel(new GridBagLayout());
76 tableCustomizerLabel = new JLabel("Type of data");
77 tableCustomizerLabel.setPreferredSize(new Dimension(100,21));
78 tableCustomizerLabel.setMinimumSize(new Dimension(100,21));
79 tableCustomizerLabel.setMaximumSize(new Dimension(100,21));
80 propertiesPanel.add(tableCustomizerLabel, new GridBagConstraints(0,0,1,1,1,0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1,1,1,1),0,0));
81 propertiesPanel.add(getTableCustomizerCombo(), new GridBagConstraints(1,0,2,1,1,0,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(1,1,1,1),0,0));
82
83 tableColumnNameLabel = new JLabel("Name of column");
84 tableColumnNameLabel.setPreferredSize(new Dimension(100,21));
85 tableColumnNameLabel.setMinimumSize(new Dimension(100,21));
86 tableColumnNameLabel.setMaximumSize(new Dimension(100,21));
87 propertiesPanel.add(tableColumnNameLabel, new GridBagConstraints(0,1,1,1,1,0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1,1,1,1),0,0));
88 propertiesPanel.add(getTableColumnNameField(), new GridBagConstraints(1,1,2,1,1,0,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(1,1,1,1),0,0));
89
90 }
91 return propertiesPanel;
92 }
93
94 private JTextField getTableColumnNameField() {
95 if (tableColumnNameField == null) {
96 tableColumnNameField = new JTextField();
97 tableColumnNameField.setPreferredSize(new Dimension(150,21));
98 tableColumnNameField.setMinimumSize(new Dimension(150,21));
99 tableColumnNameField.setMaximumSize(new Dimension(150,21));
100 }
101 return tableColumnNameField;
102 }
103
104 private JComboBox getTableCustomizerCombo() {
105 if (tableCustomizerCombo == null) {
106 tableCustomizerCombo = new JComboBox(TableColumnType.values());
107 tableCustomizerCombo.setPreferredSize(new Dimension(150,21));
108 tableCustomizerCombo.setMinimumSize(new Dimension(150,21));
109 tableCustomizerCombo.setMaximumSize(new Dimension(150,21));
110 tableCustomizerCombo.setSelectedItem(null);
111 }
112 return tableCustomizerCombo;
113 }
114
115
116
117
118
119 public TableColumnType getType() {
120 if (getTableCustomizerCombo().getSelectedItem() != null) {
121 return (TableColumnType) getTableCustomizerCombo().getSelectedItem();
122 } else {
123 return TableColumnType.VALUE;
124 }
125 }
126
127
128
129
130
131 public void setType(TableColumnType type) {
132 getTableCustomizerCombo().setSelectedItem(type);
133 }
134
135
136
137
138
139 public void setName(String name) {
140 if (name == null) {
141 name = "";
142 }
143 getTableColumnNameField().setText(name);
144 getTableColumnNameField().setToolTipText(name);
145 }
146
147
148
149
150
151
152 public String getName() {
153 return getTableColumnNameField().getText();
154 }
155
156
157
158
159
160 @Override
161 public void setParameters(AcopTableParameters parameters) {
162 if (parameters == null) {
163 getTableCustomizerCombo().setSelectedItem(null);
164 setName("");
165 } else {
166 getTableCustomizerCombo().setSelectedItem(parameters.getColumnType());
167 setName(parameters.getName());
168 }
169 }
170
171
172 }