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