| 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 |
|
|---|
| 289 | //---- preset3 ----
|
|---|
| 290 | preset3.setEnabled(false);
|
|---|
| 291 | contentPanel.add(preset3, new GridBagConstraints(6, 5, 1, 1, 0.0, 0.0,
|
|---|
| 292 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 293 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 294 |
|
|---|
| 295 | //---- preset4 ----
|
|---|
| 296 | preset4.setEnabled(false);
|
|---|
| 297 | contentPanel.add(preset4, new GridBagConstraints(6, 6, 1, 1, 0.0, 0.0,
|
|---|
| 298 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 299 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 300 |
|
|---|
| 301 | //---- multiLabel ----
|
|---|
| 302 | multiLabel.setText(tr("Multipolygon"));
|
|---|
| 303 | contentPanel.add(multiLabel, new GridBagConstraints(0, 8, 3, 1, 0.0, 1.0,
|
|---|
| 304 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 305 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 306 |
|
|---|
| 307 | //---- multiOuterButton ----
|
|---|
| 308 | multiOuterButton.setText(tr("OUTER"));
|
|---|
| 309 | multiOuterButton.setToolTipText(tr("Creation-Tool for multipolygon with role: outer. To finish press the spacebar."));
|
|---|
| 310 | multiOuterButton.setEnabled(false);
|
|---|
| 311 | contentPanel.add(multiOuterButton, new GridBagConstraints(3, 8, 3, 1, 0.0, 1.0,
|
|---|
| 312 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 313 | new Insets(0, 0, 5, 30), 0, 0));
|
|---|
| 314 |
|
|---|
| 315 | //---- multiInnerButton ----
|
|---|
| 316 | multiInnerButton.setText(tr("INNER"));
|
|---|
| 317 | multiInnerButton.setToolTipText(
|
|---|
| 318 | tr("Creation-Tool for multipolygons with role: inner. To finish press spacebar. To add to relation select \"outer\" and press enter."));
|
|---|
| 319 | multiInnerButton.setEnabled(false);
|
|---|
| 320 | contentPanel.add(multiInnerButton, new GridBagConstraints(6, 8, 1, 1, 0.0, 0.0,
|
|---|
| 321 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 322 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 323 |
|
|---|
| 324 | //---- multiCheckBox ----
|
|---|
| 325 | multiCheckBox.setToolTipText(tr("Deactivate multipolygon function."));
|
|---|
| 326 | contentPanel.add(multiCheckBox, new GridBagConstraints(9, 8, 1, 1, 0.0, 1.0,
|
|---|
| 327 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 328 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 329 |
|
|---|
| 330 | dialogPanel.add(contentPanel, BorderLayout.CENTER);
|
|---|
| 331 |
|
|---|
| 332 | //======== buttonBar ========
|
|---|
| 333 | buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
|
|---|
| 334 | buttonBar.setLayout(new GridBagLayout());
|
|---|
| 335 | ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 80};
|
|---|
| 336 | ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0};
|
|---|
| 337 |
|
|---|
| 338 | //---- applyButton ----
|
|---|
| 339 | applyButton.setText("Apply");
|
|---|
| 340 | applyButton.setToolTipText(tr("Add selected tags and/or relations to obeject."));
|
|---|
| 341 | applyButton.setEnabled(false);
|
|---|
| 342 | buttonBar.add(applyButton, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0,
|
|---|
| 343 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 344 | new Insets(0, 0, 0, 0), 0, 0));
|
|---|
| 345 |
|
|---|
| 346 | dialogPanel.add(buttonBar, BorderLayout.SOUTH);
|
|---|
| 347 |
|
|---|
| 348 | this.createLayout(dialogPanel, true, null);
|
|---|
| 349 | }
|
|---|
| 350 |
|
|---|
| 351 | /**
|
|---|
| 352 | * Enables or disables the interactive UI elements of {@link #ToolBoxView}.
|
|---|
| 353 | *
|
|---|
| 354 | * @param enabled set this true for enabled elements
|
|---|
| 355 | */
|
|---|
| 356 | public void setAllUiElementsEnabled(boolean enabled) {
|
|---|
| 357 | this.applyButton.setEnabled(enabled);
|
|---|
| 358 | this.levelCheckBox.setEnabled(enabled);
|
|---|
| 359 | this.helpButton.setEnabled(enabled);
|
|---|
| 360 | this.objectBox.setEnabled(enabled);
|
|---|
| 361 | this.levelNameField.setEnabled(enabled);
|
|---|
| 362 | this.nameField.setEnabled(enabled);
|
|---|
| 363 | this.refField.setEnabled(enabled);
|
|---|
| 364 | this.levelNameField.setEnabled(enabled);
|
|---|
| 365 | this.repeatOnField.setEnabled(enabled);
|
|---|
| 366 | this.multiOuterButton.setEnabled(enabled);
|
|---|
| 367 | this.multiInnerButton.setEnabled(enabled);
|
|---|
| 368 | this.multiCheckBox.setEnabled(enabled);
|
|---|
| 369 | this.helpButton.setEnabled(enabled);
|
|---|
| 370 | this.addLevelButton.setEnabled(enabled);
|
|---|
| 371 | this.preset1.setEnabled(enabled);
|
|---|
| 372 | this.preset2.setEnabled(enabled);
|
|---|
| 373 | this.preset3.setEnabled(enabled);
|
|---|
| 374 | this.preset4.setEnabled(enabled);
|
|---|
| 375 |
|
|---|
| 376 | if (enabled == false) {
|
|---|
| 377 | resetUiElements();
|
|---|
| 378 | }
|
|---|
| 379 | }
|
|---|
| 380 |
|
|---|
| 381 | /**
|
|---|
| 382 | * Enables or disables the interactive text box elements {@link #nameField} and {@link #refField}.
|
|---|
| 383 | *
|
|---|
| 384 | * @param enabled set this true for enabled elements
|
|---|
| 385 | */
|
|---|
| 386 | public void setNRUiElementsEnabled(boolean enabled) {
|
|---|
| 387 | this.nameField.setEnabled(enabled);
|
|---|
| 388 | this.refField.setEnabled(enabled);
|
|---|
| 389 |
|
|---|
| 390 | }
|
|---|
| 391 |
|
|---|
| 392 | /**
|
|---|
| 393 | * Enables or disables the interactive text box element {@link #repeatOnField}.
|
|---|
| 394 | * @param enabled set this true for enabled elements
|
|---|
| 395 | */
|
|---|
| 396 | public void setROUiElementsEnabled(boolean enabled) {
|
|---|
| 397 | this.repeatOnField.setEnabled(enabled);
|
|---|
| 398 | }
|
|---|
| 399 |
|
|---|
| 400 | /**
|
|---|
| 401 | * Enables or disables the interactive text box element {@link #levelNameField} and {@link #addLevelButton}.
|
|---|
| 402 | * @param enabled set this true for enabled elements
|
|---|
| 403 | */
|
|---|
| 404 | public void setLVLUiElementsEnabled(boolean enabled) {
|
|---|
| 405 | this.levelNameField.setEnabled(enabled);
|
|---|
| 406 | this.addLevelButton.setEnabled(enabled);
|
|---|
| 407 |
|
|---|
| 408 | }
|
|---|
| 409 |
|
|---|
| 410 | /**
|
|---|
| 411 | * Enables or disables the interactive ComboBoxes {@link #multiOuterButton} and {@link #multiInnerButton}.
|
|---|
| 412 | * @param enabled set this true for enabled elements
|
|---|
| 413 | */
|
|---|
| 414 | public void setMultiUiElementsEnabled(boolean enabled) {
|
|---|
| 415 | this.multiOuterButton.setEnabled(enabled);
|
|---|
| 416 | this.multiInnerButton.setEnabled(enabled);
|
|---|
| 417 |
|
|---|
| 418 | if (enabled == false) resetUiElements();
|
|---|
| 419 | }
|
|---|
| 420 |
|
|---|
| 421 | /**
|
|---|
| 422 | * Resets the view by making the UI elements disabled.
|
|---|
| 423 | */
|
|---|
| 424 | public void reset() {
|
|---|
| 425 | this.setAllUiElementsEnabled(false);
|
|---|
| 426 | }
|
|---|
| 427 |
|
|---|
| 428 | /**
|
|---|
| 429 | * Getter for the selected {@link IndoorObject} in the {@link #objectBox}.
|
|---|
| 430 | *
|
|---|
| 431 | * @return the selected indoor object in the object ComboBox.
|
|---|
| 432 | */
|
|---|
| 433 | public IndoorObject getSelectedObject() {
|
|---|
| 434 | return (IndoorObject) this.objectBox.getSelectedItem();
|
|---|
| 435 | }
|
|---|
| 436 |
|
|---|
| 437 | /**
|
|---|
| 438 | * Getter for the level name field.
|
|---|
| 439 | *
|
|---|
| 440 | * @return the {@link String} of the {@link #levelNameField}
|
|---|
| 441 | */
|
|---|
| 442 | public String getLevelNameText() {
|
|---|
| 443 | return this.levelNameField.getText();
|
|---|
| 444 | }
|
|---|
| 445 |
|
|---|
| 446 | /**
|
|---|
| 447 | * Setter for the {@link #levelNameField}.
|
|---|
| 448 | *
|
|---|
| 449 | * @param name the String for the {@link #levelNameField}
|
|---|
| 450 | */
|
|---|
| 451 | public void setLevelNameText(String name) {
|
|---|
| 452 | this.levelNameField.setText(name);
|
|---|
| 453 | }
|
|---|
| 454 |
|
|---|
| 455 | /**
|
|---|
| 456 | * Getter for the {@link #nameField}.
|
|---|
| 457 | *
|
|---|
| 458 | * @return String of the name text field
|
|---|
| 459 | */
|
|---|
| 460 | public String getNameText() {
|
|---|
| 461 | return this.nameField.getText();
|
|---|
| 462 | }
|
|---|
| 463 |
|
|---|
| 464 | /**
|
|---|
| 465 | * Setter for the current level value tag {@link #levelLabel}.
|
|---|
| 466 | *
|
|---|
| 467 | * @author rebsc
|
|---|
| 468 | * @param levelTag level value as String
|
|---|
| 469 | */
|
|---|
| 470 | public void setLevelLabel(String levelTag) {
|
|---|
| 471 | if (getLevelCheckBoxStatus() == false) {
|
|---|
| 472 | if (!levelTag.equals("")) {
|
|---|
| 473 | this.levelLabel.setText((tr("Working level: {0}", levelTag)));
|
|---|
| 474 | } else {
|
|---|
| 475 | this.levelLabel.setText((tr("Working level: NONE")));
|
|---|
| 476 | }
|
|---|
| 477 | } else {
|
|---|
| 478 | this.levelLabel.setText((tr("Working level: NONE")));
|
|---|
| 479 | }
|
|---|
| 480 | }
|
|---|
| 481 |
|
|---|
| 482 | /**
|
|---|
| 483 | * Getter for the {@link #levelCheckBox} status.
|
|---|
| 484 | *
|
|---|
| 485 | * @return boolean which tells if box is selected or not.
|
|---|
| 486 | */
|
|---|
| 487 | public boolean getLevelCheckBoxStatus() {
|
|---|
| 488 | return this.levelCheckBox.isSelected();
|
|---|
| 489 | }
|
|---|
| 490 |
|
|---|
| 491 | /**
|
|---|
| 492 | * Getter for the {@link #refField}.
|
|---|
| 493 | *
|
|---|
| 494 | * @return String of the ref text field
|
|---|
| 495 | */
|
|---|
| 496 | public String getRefText() {
|
|---|
| 497 | return this.refField.getText();
|
|---|
| 498 | }
|
|---|
| 499 |
|
|---|
| 500 | /**
|
|---|
| 501 | * Getter for the repeat on TextField.
|
|---|
| 502 | * @return String of the repeat on text field
|
|---|
| 503 | */
|
|---|
| 504 | public String getRepeatOnText() {
|
|---|
| 505 | return this.repeatOnField.getText();
|
|---|
| 506 | }
|
|---|
| 507 |
|
|---|
| 508 | /**
|
|---|
| 509 | * Clears the text boxes and sets an empty String.
|
|---|
| 510 | */
|
|---|
| 511 | public void resetUiElements() {
|
|---|
| 512 | this.nameField.setText(tr(""));
|
|---|
| 513 | this.levelNameField.setText(tr(""));
|
|---|
| 514 | this.refField.setText(tr(""));
|
|---|
| 515 | this.repeatOnField.setText(tr(""));
|
|---|
| 516 | this.levelNameField.setText(tr(""));
|
|---|
| 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 | }
|
|---|