1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package views;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.BorderLayout;
|
---|
7 | import java.awt.Color;
|
---|
8 | import java.awt.GridBagConstraints;
|
---|
9 | import java.awt.GridBagLayout;
|
---|
10 | import java.awt.Insets;
|
---|
11 | import java.awt.event.ActionListener;
|
---|
12 | import java.awt.event.FocusEvent;
|
---|
13 | import java.awt.event.FocusListener;
|
---|
14 | import java.awt.event.ItemListener;
|
---|
15 | import java.util.List;
|
---|
16 |
|
---|
17 | import javax.swing.JButton;
|
---|
18 | import javax.swing.JCheckBox;
|
---|
19 | import javax.swing.JLabel;
|
---|
20 | import javax.swing.JPanel;
|
---|
21 | import javax.swing.JSeparator;
|
---|
22 | import javax.swing.border.EmptyBorder;
|
---|
23 |
|
---|
24 | import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
|
---|
25 | import org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField;
|
---|
26 | import org.openstreetmap.josm.gui.widgets.JosmComboBox;
|
---|
27 |
|
---|
28 | import model.TagCatalog;
|
---|
29 | import model.TagCatalog.IndoorObject;
|
---|
30 |
|
---|
31 | /**
|
---|
32 | *
|
---|
33 | * This is the main toolbox of the indoorhelper plug-in.
|
---|
34 | *
|
---|
35 | * @author egru
|
---|
36 | * @author rebsc
|
---|
37 | *
|
---|
38 | */
|
---|
39 | @SuppressWarnings("serial")
|
---|
40 | public class ToolBoxView extends ToggleDialog {
|
---|
41 | private JPanel dialogPanel;
|
---|
42 | private JPanel contentPanel;
|
---|
43 | private JLabel levelLabel;
|
---|
44 | private JCheckBox levelCheckBox;
|
---|
45 | private JLabel levelNameLabel;
|
---|
46 | private DisableShortcutsOnFocusGainedTextField levelNameField;
|
---|
47 | private JLabel repeatOnLabel;
|
---|
48 | private DisableShortcutsOnFocusGainedTextField repeatOnField;
|
---|
49 | private JLabel objectLabel;
|
---|
50 | private JosmComboBox<TagCatalog.IndoorObject> objectBox;
|
---|
51 | private JLabel nameLabel;
|
---|
52 | private DisableShortcutsOnFocusGainedTextField nameField;
|
---|
53 | private JLabel refLabel;
|
---|
54 | private DisableShortcutsOnFocusGainedTextField refField;
|
---|
55 | private JLabel multiLabel;
|
---|
56 | private JButton multiOuterButton;
|
---|
57 | private JButton multiInnerButton;
|
---|
58 | private JCheckBox multiCheckBox;
|
---|
59 | private JPanel buttonBar;
|
---|
60 | private JButton applyButton;
|
---|
61 | private JSeparator separator1;
|
---|
62 | private JSeparator separator2;
|
---|
63 | private PresetButton preset1;
|
---|
64 | private PresetButton preset2;
|
---|
65 | private PresetButton preset3;
|
---|
66 | private PresetButton preset4;
|
---|
67 | private JButton addLevelButton;
|
---|
68 | private JButton helpButton;
|
---|
69 |
|
---|
70 | public ToolBoxView() {
|
---|
71 | super(tr("Indoor Mapping Helper"), "indoorhelper",
|
---|
72 | tr("Toolbox for indoor mapping assistance"), null, 300, true);
|
---|
73 |
|
---|
74 | initComponents();
|
---|
75 | }
|
---|
76 |
|
---|
77 | private void initComponents() {
|
---|
78 | dialogPanel = new JPanel();
|
---|
79 | contentPanel = new JPanel();
|
---|
80 | levelLabel = new JLabel();
|
---|
81 | levelCheckBox = new JCheckBox();
|
---|
82 | levelNameLabel = new JLabel();
|
---|
83 | levelNameField = new DisableShortcutsOnFocusGainedTextField();
|
---|
84 | repeatOnLabel = new JLabel();
|
---|
85 | repeatOnField = new DisableShortcutsOnFocusGainedTextField();
|
---|
86 | objectLabel = new JLabel();
|
---|
87 | objectBox = new JosmComboBox<>(TagCatalog.IndoorObject.values());
|
---|
88 | nameLabel = new JLabel();
|
---|
89 | nameField = new DisableShortcutsOnFocusGainedTextField();
|
---|
90 | refLabel = new JLabel();
|
---|
91 | refField = new DisableShortcutsOnFocusGainedTextField();
|
---|
92 | multiLabel = new JLabel();
|
---|
93 | multiOuterButton = new JButton();
|
---|
94 | multiInnerButton = new JButton();
|
---|
95 | multiCheckBox = new JCheckBox();
|
---|
96 | buttonBar = new JPanel();
|
---|
97 | applyButton = new JButton();
|
---|
98 | separator1 = new JSeparator();
|
---|
99 | separator2 = new JSeparator();
|
---|
100 | preset1 = new PresetButton(IndoorObject.ROOM);
|
---|
101 | preset2 = new PresetButton(IndoorObject.STEPS);
|
---|
102 | preset3 = new PresetButton(IndoorObject.CONCRETE_WALL);
|
---|
103 | preset4 = new PresetButton(IndoorObject.GLASS_WALL);
|
---|
104 | addLevelButton = new JButton();
|
---|
105 | helpButton = new JButton();
|
---|
106 |
|
---|
107 | //======== this ========
|
---|
108 | //Container contentPane = this.get;
|
---|
109 | //contentPane.setLayout(new BorderLayout());
|
---|
110 |
|
---|
111 | //======== dialogPane ========
|
---|
112 |
|
---|
113 | dialogPanel.setBorder(new EmptyBorder(12, 12, 12, 12));
|
---|
114 | dialogPanel.setLayout(new BorderLayout());
|
---|
115 |
|
---|
116 | //======== contentPanel ========
|
---|
117 |
|
---|
118 | contentPanel.setLayout(new GridBagLayout());
|
---|
119 | ((GridBagLayout) contentPanel.getLayout()).columnWidths = new int[] {
|
---|
120 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
---|
121 | ((GridBagLayout) contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0, 0, 0};
|
---|
122 | ((GridBagLayout) contentPanel.getLayout()).columnWeights = new double[] {
|
---|
123 | 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
---|
124 | 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
|
---|
125 | ((GridBagLayout) contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
|
---|
126 |
|
---|
127 | //---- addLevelButton ----
|
---|
128 | addLevelButton.setText(tr("Insert level"));
|
---|
129 | addLevelButton.setToolTipText(tr("Add a new level to layer."));
|
---|
130 | addLevelButton.setEnabled(false);
|
---|
131 | contentPanel.add(addLevelButton, new GridBagConstraints(12, 1, 3, 1, 0.0, 1.0,
|
---|
132 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
133 | new Insets(0, 0, 5, 30), 0, 0));
|
---|
134 |
|
---|
135 | //---- helpButton ----
|
---|
136 | helpButton.setText(tr("<html><b>?</strong></b>"));
|
---|
137 | helpButton.setToolTipText(tr("Show Help-Browser."));
|
---|
138 | helpButton.setBackground(Color.LIGHT_GRAY);
|
---|
139 | helpButton.setEnabled(false);
|
---|
140 | contentPanel.add(helpButton, new GridBagConstraints(0, 0, 1, 1, 0.0, 1.0,
|
---|
141 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
142 | new Insets(0, 0, 5, 0), 0, 0));
|
---|
143 |
|
---|
144 | //---- levelNameLabel ----
|
---|
145 | levelNameLabel.setText(tr("Level name"));
|
---|
146 | contentPanel.add(levelNameLabel, new GridBagConstraints(0, 1, 3, 1, 0.0, 1.0,
|
---|
147 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
148 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
149 |
|
---|
150 | //---- levelNameField ----
|
---|
151 | levelNameField.setEnabled(false);
|
---|
152 | levelNameField.setToolTipText(tr("Sets optional name tag for a level."));
|
---|
153 | contentPanel.add(levelNameField, new GridBagConstraints(3, 1, 3, 1, 0.0, 1.0,
|
---|
154 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
155 | new Insets(0, 0, 5, 30), 0, 0));
|
---|
156 |
|
---|
157 | //---- levelLabel ----
|
---|
158 | levelLabel.setText(tr("Working level: NONE"));
|
---|
159 | levelLabel.setToolTipText(tr("Shows the current working level."));
|
---|
160 | contentPanel.add(levelLabel, new GridBagConstraints(6, 1, 3, 1, 0.0, 1.0,
|
---|
161 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
162 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
163 |
|
---|
164 | //---- levelCheckBox ----
|
---|
165 | levelCheckBox.setToolTipText(tr("Deactivate automatic level tagging."));
|
---|
166 | contentPanel.add(levelCheckBox, new GridBagConstraints(9, 1, 1, 1, 0.0, 1.0,
|
---|
167 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
168 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
169 | contentPanel.add(separator1, new GridBagConstraints(0, 2, 0, 1, 0.0, 0.0,
|
---|
170 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
171 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
172 |
|
---|
173 | //---- objectLabel ----
|
---|
174 | objectLabel.setText(tr("Object"));
|
---|
175 | contentPanel.add(objectLabel, new GridBagConstraints(0, 3, 3, 1, 0.0, 1.0,
|
---|
176 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
177 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
178 |
|
---|
179 | //---- objectBox ----
|
---|
180 | objectBox.setEnabled(false);
|
---|
181 | objectBox.setPrototypeDisplayValue(IndoorObject.CONCRETE_WALL);
|
---|
182 | objectBox.setToolTipText(tr("The object preset you want to tag."));
|
---|
183 | contentPanel.add(objectBox, new GridBagConstraints(3, 3, 3, 1, 0.0, 1.0,
|
---|
184 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
185 | new Insets(0, 0, 5, 30), 0, 0));
|
---|
186 |
|
---|
187 | //---- nameLabel ----
|
---|
188 | nameLabel.setText(tr("Name"));
|
---|
189 | contentPanel.add(nameLabel, new GridBagConstraints(0, 4, 3, 1, 0.0, 1.0,
|
---|
190 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
191 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
192 |
|
---|
193 | //---- nameField ----
|
---|
194 | nameField.setEnabled(false);
|
---|
195 | nameField.addFocusListener(new FocusListener() {
|
---|
196 |
|
---|
197 | @Override
|
---|
198 | public void focusLost(FocusEvent e) {}
|
---|
199 |
|
---|
200 | @Override
|
---|
201 | public void focusGained(FocusEvent e) {
|
---|
202 | nameField.selectAll();
|
---|
203 | }
|
---|
204 | });
|
---|
205 | nameField.setToolTipText(tr("Sets the name tag."));
|
---|
206 | contentPanel.add(nameField, new GridBagConstraints(3, 4, 3, 1, 0.0, 1.0,
|
---|
207 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
208 | new Insets(0, 0, 5, 30), 0, 0));
|
---|
209 |
|
---|
210 | //---- refLabel ----
|
---|
211 | refLabel.setText(tr("Reference"));
|
---|
212 | contentPanel.add(refLabel, new GridBagConstraints(0, 5, 3, 1, 0.0, 1.0,
|
---|
213 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
214 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
215 |
|
---|
216 | //---- refField ----
|
---|
217 | refField.setEnabled(false);
|
---|
218 | refField.addFocusListener(new FocusListener() {
|
---|
219 |
|
---|
220 | @Override
|
---|
221 | public void focusLost(FocusEvent e) {}
|
---|
222 |
|
---|
223 | @Override
|
---|
224 | public void focusGained(FocusEvent e) {
|
---|
225 | refField.selectAll();
|
---|
226 | }
|
---|
227 | });
|
---|
228 | refField.setToolTipText(tr("Sets the referance tag."));
|
---|
229 | contentPanel.add(refField, new GridBagConstraints(3, 5, 3, 1, 0.0, 1.0,
|
---|
230 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
231 | new Insets(0, 0, 5, 30), 0, 0));
|
---|
232 |
|
---|
233 | //---- repeatOnLabel ----
|
---|
234 | repeatOnLabel.setText(tr("Repeat on"));
|
---|
235 | contentPanel.add(repeatOnLabel, new GridBagConstraints(0, 6, 3, 1, 0.0, 1.0,
|
---|
236 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
237 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
238 |
|
---|
239 | //---- repeatOnField ----
|
---|
240 | repeatOnField.setEnabled(false);
|
---|
241 | repeatOnField.addFocusListener(new FocusListener() {
|
---|
242 |
|
---|
243 | @Override
|
---|
244 | public void focusLost(FocusEvent e) {}
|
---|
245 |
|
---|
246 | @Override
|
---|
247 | public void focusGained(FocusEvent e) {
|
---|
248 | repeatOnField.selectAll();
|
---|
249 | }
|
---|
250 | });
|
---|
251 | repeatOnField.setToolTipText(
|
---|
252 | tr("Sets the repeat on tag when highway objects are selected. Please tag like this: -3-4 or -2--3 or 5-6 ."));
|
---|
253 | contentPanel.add(repeatOnField, new GridBagConstraints(3, 6, 3, 1, 0.0, 1.0,
|
---|
254 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
255 | new Insets(0, 0, 5, 30), 0, 0));
|
---|
256 | contentPanel.add(separator2, new GridBagConstraints(0, 7, 0, 1, 0.0, 1.0,
|
---|
257 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
258 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
259 |
|
---|
260 | //---- preset1 ----
|
---|
261 | preset1.setEnabled(false);
|
---|
262 | contentPanel.add(preset1, new GridBagConstraints(6, 3, 1, 1, 0.0, 0.0,
|
---|
263 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
264 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
265 | //---- preset2 ----
|
---|
266 | preset2.setEnabled(false);
|
---|
267 | contentPanel.add(preset2, new GridBagConstraints(6, 4, 1, 1, 0.0, 0.0,
|
---|
268 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
269 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
270 | //---- preset3 ----
|
---|
271 | preset3.setEnabled(false);
|
---|
272 | contentPanel.add(preset3, new GridBagConstraints(6, 5, 1, 1, 0.0, 0.0,
|
---|
273 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
274 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
275 |
|
---|
276 | //---- preset4 ----
|
---|
277 | preset4.setEnabled(false);
|
---|
278 | contentPanel.add(preset4, new GridBagConstraints(6, 6, 1, 1, 0.0, 0.0,
|
---|
279 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
280 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
281 |
|
---|
282 | //---- multiLabel ----
|
---|
283 | multiLabel.setText(tr("Multipolygon"));
|
---|
284 | contentPanel.add(multiLabel, new GridBagConstraints(0, 8, 3, 1, 0.0, 1.0,
|
---|
285 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
286 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
287 |
|
---|
288 | //---- multiOuterButton ----
|
---|
289 | multiOuterButton.setText(tr("OUTER"));
|
---|
290 | multiOuterButton.setToolTipText(tr("Creation-Tool for multipolygon with role: outer. To finish press the spacebar."));
|
---|
291 | multiOuterButton.setEnabled(false);
|
---|
292 | contentPanel.add(multiOuterButton, new GridBagConstraints(3, 8, 3, 1, 0.0, 1.0,
|
---|
293 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
294 | new Insets(0, 0, 5, 30), 0, 0));
|
---|
295 |
|
---|
296 | //---- multiInnerButton ----
|
---|
297 | multiInnerButton.setText(tr("INNER"));
|
---|
298 | multiInnerButton.setToolTipText(
|
---|
299 | tr("Creation-Tool for multipolygons with role: inner. To finish press spacebar. To add to relation select \"outer\" and press enter."));
|
---|
300 | multiInnerButton.setEnabled(false);
|
---|
301 | contentPanel.add(multiInnerButton, new GridBagConstraints(6, 8, 1, 1, 0.0, 0.0,
|
---|
302 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
303 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
304 |
|
---|
305 | //---- multiCheckBox ----
|
---|
306 | multiCheckBox.setToolTipText(tr("Deactivate multipolygon function."));
|
---|
307 | contentPanel.add(multiCheckBox, new GridBagConstraints(9, 8, 1, 1, 0.0, 1.0,
|
---|
308 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
309 | new Insets(0, 0, 5, 5), 0, 0));
|
---|
310 |
|
---|
311 | dialogPanel.add(contentPanel, BorderLayout.CENTER);
|
---|
312 |
|
---|
313 | //======== buttonBar ========
|
---|
314 | buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
|
---|
315 | buttonBar.setLayout(new GridBagLayout());
|
---|
316 | ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 80};
|
---|
317 | ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0};
|
---|
318 |
|
---|
319 | //---- applyButton ----
|
---|
320 | applyButton.setText(tr("Apply"));
|
---|
321 | applyButton.setToolTipText(tr("Add selected tags and/or relations to obeject."));
|
---|
322 | applyButton.setEnabled(false);
|
---|
323 | buttonBar.add(applyButton, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0,
|
---|
324 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
---|
325 | new Insets(0, 0, 0, 0), 0, 0));
|
---|
326 |
|
---|
327 | dialogPanel.add(buttonBar, BorderLayout.SOUTH);
|
---|
328 |
|
---|
329 | this.createLayout(dialogPanel, true, null);
|
---|
330 | }
|
---|
331 |
|
---|
332 | /**
|
---|
333 | * Enables or disables the interactive UI elements of {@link #ToolBoxView}.
|
---|
334 | *
|
---|
335 | * @param enabled set this true for enabled elements
|
---|
336 | */
|
---|
337 | public void setAllUiElementsEnabled(boolean enabled) {
|
---|
338 | this.applyButton.setEnabled(enabled);
|
---|
339 | this.levelCheckBox.setEnabled(enabled);
|
---|
340 | this.helpButton.setEnabled(enabled);
|
---|
341 | this.objectBox.setEnabled(enabled);
|
---|
342 | this.levelNameField.setEnabled(enabled);
|
---|
343 | this.nameField.setEnabled(enabled);
|
---|
344 | this.refField.setEnabled(enabled);
|
---|
345 | this.levelNameField.setEnabled(enabled);
|
---|
346 | this.repeatOnField.setEnabled(enabled);
|
---|
347 | this.multiOuterButton.setEnabled(enabled);
|
---|
348 | this.multiInnerButton.setEnabled(enabled);
|
---|
349 | this.multiCheckBox.setEnabled(enabled);
|
---|
350 | this.helpButton.setEnabled(enabled);
|
---|
351 | this.addLevelButton.setEnabled(enabled);
|
---|
352 | this.preset1.setEnabled(enabled);
|
---|
353 | this.preset2.setEnabled(enabled);
|
---|
354 | this.preset3.setEnabled(enabled);
|
---|
355 | this.preset4.setEnabled(enabled);
|
---|
356 |
|
---|
357 | if (enabled == false) {
|
---|
358 | resetUiElements();
|
---|
359 | }
|
---|
360 | }
|
---|
361 |
|
---|
362 | /**
|
---|
363 | * Enables or disables the interactive text box elements {@link #nameField} and {@link #refField}.
|
---|
364 | *
|
---|
365 | * @param enabled set this true for enabled elements
|
---|
366 | */
|
---|
367 | public void setNRUiElementsEnabled(boolean enabled) {
|
---|
368 | this.nameField.setEnabled(enabled);
|
---|
369 | this.refField.setEnabled(enabled);
|
---|
370 |
|
---|
371 | }
|
---|
372 |
|
---|
373 | /**
|
---|
374 | * Enables or disables the interactive text box element {@link #repeatOnField}.
|
---|
375 | * @param enabled set this true for enabled elements
|
---|
376 | */
|
---|
377 | public void setROUiElementsEnabled(boolean enabled) {
|
---|
378 | this.repeatOnField.setEnabled(enabled);
|
---|
379 | }
|
---|
380 |
|
---|
381 | /**
|
---|
382 | * Enables or disables the interactive text box element {@link #levelNameField} and {@link #addLevelButton}.
|
---|
383 | * @param enabled set this true for enabled elements
|
---|
384 | */
|
---|
385 | public void setLVLUiElementsEnabled(boolean enabled) {
|
---|
386 | this.levelNameField.setEnabled(enabled);
|
---|
387 | this.addLevelButton.setEnabled(enabled);
|
---|
388 |
|
---|
389 | }
|
---|
390 |
|
---|
391 | /**
|
---|
392 | * Enables or disables the interactive ComboBoxes {@link #multiOuterButton} and {@link #multiInnerButton}.
|
---|
393 | * @param enabled set this true for enabled elements
|
---|
394 | */
|
---|
395 | public void setMultiUiElementsEnabled(boolean enabled) {
|
---|
396 | this.multiOuterButton.setEnabled(enabled);
|
---|
397 | this.multiInnerButton.setEnabled(enabled);
|
---|
398 |
|
---|
399 | if (enabled == false) resetUiElements();
|
---|
400 | }
|
---|
401 |
|
---|
402 | /**
|
---|
403 | * Resets the view by making the UI elements disabled.
|
---|
404 | */
|
---|
405 | public void reset() {
|
---|
406 | this.setAllUiElementsEnabled(false);
|
---|
407 | }
|
---|
408 |
|
---|
409 | /**
|
---|
410 | * Getter for the selected {@link IndoorObject} in the {@link #objectBox}.
|
---|
411 | *
|
---|
412 | * @return the selected indoor object in the object ComboBox.
|
---|
413 | */
|
---|
414 | public IndoorObject getSelectedObject() {
|
---|
415 | return (IndoorObject) this.objectBox.getSelectedItem();
|
---|
416 | }
|
---|
417 |
|
---|
418 | /**
|
---|
419 | * Getter for the level name field.
|
---|
420 | *
|
---|
421 | * @return the {@link String} of the {@link #levelNameField}
|
---|
422 | */
|
---|
423 | public String getLevelNameText() {
|
---|
424 | return this.levelNameField.getText();
|
---|
425 | }
|
---|
426 |
|
---|
427 | /**
|
---|
428 | * Setter for the {@link #levelNameField}.
|
---|
429 | *
|
---|
430 | * @param name the String for the {@link #levelNameField}
|
---|
431 | */
|
---|
432 | public void setLevelNameText(String name) {
|
---|
433 | this.levelNameField.setText(name);
|
---|
434 | }
|
---|
435 |
|
---|
436 | /**
|
---|
437 | * Getter for the {@link #nameField}.
|
---|
438 | *
|
---|
439 | * @return String of the name text field
|
---|
440 | */
|
---|
441 | public String getNameText() {
|
---|
442 | return this.nameField.getText();
|
---|
443 | }
|
---|
444 |
|
---|
445 | /**
|
---|
446 | * Setter for the current level value tag {@link #levelLabel}.
|
---|
447 | *
|
---|
448 | * @author rebsc
|
---|
449 | * @param levelTag level value as String
|
---|
450 | */
|
---|
451 | public void setLevelLabel(String levelTag) {
|
---|
452 | if (getLevelCheckBoxStatus() == false) {
|
---|
453 | if (!levelTag.equals("")) {
|
---|
454 | this.levelLabel.setText(tr("Working level: {0}", levelTag));
|
---|
455 | } else {
|
---|
456 | this.levelLabel.setText(tr("Working level: NONE"));
|
---|
457 | }
|
---|
458 | } else {
|
---|
459 | this.levelLabel.setText(tr("Working level: NONE"));
|
---|
460 | }
|
---|
461 | }
|
---|
462 |
|
---|
463 | /**
|
---|
464 | * Getter for the {@link #levelCheckBox} status.
|
---|
465 | *
|
---|
466 | * @return boolean which tells if box is selected or not.
|
---|
467 | */
|
---|
468 | public boolean getLevelCheckBoxStatus() {
|
---|
469 | return this.levelCheckBox.isSelected();
|
---|
470 | }
|
---|
471 |
|
---|
472 | /**
|
---|
473 | * Getter for the {@link #refField}.
|
---|
474 | *
|
---|
475 | * @return String of the ref text field
|
---|
476 | */
|
---|
477 | public String getRefText() {
|
---|
478 | return this.refField.getText();
|
---|
479 | }
|
---|
480 |
|
---|
481 | /**
|
---|
482 | * Getter for the repeat on TextField.
|
---|
483 | * @return String of the repeat on text field
|
---|
484 | */
|
---|
485 | public String getRepeatOnText() {
|
---|
486 | return this.repeatOnField.getText();
|
---|
487 | }
|
---|
488 |
|
---|
489 |
|
---|
490 | /**
|
---|
491 | * Clears the text boxes and sets an empty String.
|
---|
492 | */
|
---|
493 | public void resetUiElements() {
|
---|
494 | this.nameField.setText("");
|
---|
495 | this.levelNameField.setText("");
|
---|
496 | this.refField.setText("");
|
---|
497 | this.repeatOnField.setText("");
|
---|
498 | this.levelNameField.setText("");
|
---|
499 | }
|
---|
500 |
|
---|
501 | /**
|
---|
502 | * Set the listener for the {@link #applyButton}.
|
---|
503 | *
|
---|
504 | * @param l the listener to set
|
---|
505 | */
|
---|
506 | public void setApplyButtonListener(ActionListener l) {
|
---|
507 | this.applyButton.addActionListener(l);
|
---|
508 | }
|
---|
509 |
|
---|
510 | /**
|
---|
511 | * Set the listener for {@link #levelCheckBox}.
|
---|
512 | * @param l the listener to set
|
---|
513 | */
|
---|
514 | public void setLevelCheckBoxListener(ItemListener l) {
|
---|
515 | this.levelCheckBox.addItemListener(l);
|
---|
516 | }
|
---|
517 |
|
---|
518 | /**
|
---|
519 | * Set the listener for {@link #helpButton}.
|
---|
520 | * @param l the listener to set
|
---|
521 | */
|
---|
522 | public void setHelpButtonListener(ActionListener l) {
|
---|
523 | this.helpButton.addActionListener(l);
|
---|
524 | }
|
---|
525 |
|
---|
526 | /**
|
---|
527 | * Set the listener for {@link #addLevelButton}.
|
---|
528 | * @param l the listener to set
|
---|
529 | */
|
---|
530 | public void setAddLevelButtonListener(ActionListener l) {
|
---|
531 | this.addLevelButton.addActionListener(l);
|
---|
532 | }
|
---|
533 |
|
---|
534 |
|
---|
535 | /**
|
---|
536 | * Set the listener for {@link #objectBox}.
|
---|
537 | *
|
---|
538 | * @param l the listener to set
|
---|
539 | */
|
---|
540 | public void setObjectItemListener(ItemListener l) {
|
---|
541 | this.objectBox.addItemListener(l);
|
---|
542 | }
|
---|
543 |
|
---|
544 | /**
|
---|
545 | * Set the listener for the {@link #multiOuterButton}.
|
---|
546 | *
|
---|
547 | * @param l the listener to set
|
---|
548 | */
|
---|
549 | public void setOuterButtonListener(ActionListener l) {
|
---|
550 | this.multiOuterButton.addActionListener(l);
|
---|
551 | }
|
---|
552 |
|
---|
553 | /**
|
---|
554 | * Set the listener for the {@link #multiInnerButton}.
|
---|
555 | *
|
---|
556 | * @param l the listener to set
|
---|
557 | */
|
---|
558 | public void setInnerButtonListener(ActionListener l) {
|
---|
559 | this.multiInnerButton.addActionListener(l);
|
---|
560 | }
|
---|
561 |
|
---|
562 | /**
|
---|
563 | * Set the listener for the {@link #multiCheckBox}.
|
---|
564 | *
|
---|
565 | * @param l the listener to set
|
---|
566 | */
|
---|
567 | public void setMultiCheckBoxListener(ItemListener l) {
|
---|
568 | this.multiCheckBox.addItemListener(l);
|
---|
569 | }
|
---|
570 |
|
---|
571 | public void setPresetButtons(List<IndoorObject> objects) {
|
---|
572 | this.preset1.setIndoorObject(objects.get(0));
|
---|
573 | this.preset2.setIndoorObject(objects.get(1));
|
---|
574 | this.preset3.setIndoorObject(objects.get(2));
|
---|
575 | this.preset4.setIndoorObject(objects.get(3));
|
---|
576 | }
|
---|
577 |
|
---|
578 | public void setPreset1Listener(ActionListener l) {
|
---|
579 | this.preset1.addActionListener(l);
|
---|
580 | }
|
---|
581 |
|
---|
582 | public void setPreset2Listener(ActionListener l) {
|
---|
583 | this.preset2.addActionListener(l);
|
---|
584 | }
|
---|
585 |
|
---|
586 | public void setPreset3Listener(ActionListener l) {
|
---|
587 | this.preset3.addActionListener(l);
|
---|
588 | }
|
---|
589 |
|
---|
590 | public void setPreset4Listener(ActionListener l) {
|
---|
591 | this.preset4.addActionListener(l);
|
---|
592 | }
|
---|
593 |
|
---|
594 | public IndoorObject getPreset1() {
|
---|
595 | return preset1.getIndoorObject();
|
---|
596 | }
|
---|
597 |
|
---|
598 | public IndoorObject getPreset2() {
|
---|
599 | return preset2.getIndoorObject();
|
---|
600 | }
|
---|
601 |
|
---|
602 | public IndoorObject getPreset3() {
|
---|
603 | return preset3.getIndoorObject();
|
---|
604 | }
|
---|
605 |
|
---|
606 | public IndoorObject getPreset4() {
|
---|
607 | return preset4.getIndoorObject();
|
---|
608 | }
|
---|
609 | }
|
---|