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