| 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.*;
|
|---|
| 24 | import java.awt.event.ActionListener;
|
|---|
| 25 | import java.awt.event.FocusEvent;
|
|---|
| 26 | import java.awt.event.FocusListener;
|
|---|
| 27 | import java.awt.event.ItemListener;
|
|---|
| 28 | import java.util.List;
|
|---|
| 29 | import java.util.ListIterator;
|
|---|
| 30 |
|
|---|
| 31 | import javax.swing.*;
|
|---|
| 32 | import javax.swing.border.*;
|
|---|
| 33 | import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
|
|---|
| 34 | import org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField;
|
|---|
| 35 | import org.openstreetmap.josm.gui.widgets.JosmComboBox;
|
|---|
| 36 |
|
|---|
| 37 | import model.IndoorLevel;
|
|---|
| 38 | import model.TagCatalog;
|
|---|
| 39 | import model.TagCatalog.IndoorObject;
|
|---|
| 40 |
|
|---|
| 41 | /**
|
|---|
| 42 | *
|
|---|
| 43 | * This is the main toolbox of the indoorhelper plug-in.
|
|---|
| 44 | *
|
|---|
| 45 | * @author egru
|
|---|
| 46 | *
|
|---|
| 47 | */
|
|---|
| 48 | @SuppressWarnings("serial")
|
|---|
| 49 | public class ToolBoxView extends ToggleDialog{
|
|---|
| 50 | private JPanel dialogPane;
|
|---|
| 51 | private JPanel contentPanel;
|
|---|
| 52 | private JToggleButton powerButton;
|
|---|
| 53 | private JLabel levelLabel;
|
|---|
| 54 | private JosmComboBox<String> levelBox;
|
|---|
| 55 | private JLabel levelTagLabel;
|
|---|
| 56 | private DisableShortcutsOnFocusGainedTextField levelTagField;
|
|---|
| 57 | private JLabel objectLabel;
|
|---|
| 58 | private JosmComboBox<TagCatalog.IndoorObject> objectBox;
|
|---|
| 59 | private JLabel nameLabel;
|
|---|
| 60 | private DisableShortcutsOnFocusGainedTextField nameField;
|
|---|
| 61 | private JLabel refLabel;
|
|---|
| 62 | private DisableShortcutsOnFocusGainedTextField refField;
|
|---|
| 63 | private JPanel buttonBar;
|
|---|
| 64 | private JButton applyButton;
|
|---|
| 65 | private JSeparator separator1;
|
|---|
| 66 | private JSeparator separator2;
|
|---|
| 67 | private PresetButton preset1;
|
|---|
| 68 | private PresetButton preset2;
|
|---|
| 69 | private PresetButton preset3;
|
|---|
| 70 | private PresetButton preset4;
|
|---|
| 71 |
|
|---|
| 72 | public ToolBoxView(){
|
|---|
| 73 | super(tr("Indoor Mapping Helper"), "indoorhelper",
|
|---|
| 74 | tr("Toolbox for indoor mapping assistance"), null, 300, true);
|
|---|
| 75 |
|
|---|
| 76 | initComponents();
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | /**
|
|---|
| 80 | * Creates the layout of the plug-in.
|
|---|
| 81 | */
|
|---|
| 82 | private void initComponents() {
|
|---|
| 83 | dialogPane = new JPanel();
|
|---|
| 84 | contentPanel = new JPanel();
|
|---|
| 85 | powerButton = new JToggleButton();
|
|---|
| 86 | levelLabel = new JLabel();
|
|---|
| 87 | levelBox = new JosmComboBox<String>();
|
|---|
| 88 | levelTagLabel = new JLabel();
|
|---|
| 89 | levelTagField = new DisableShortcutsOnFocusGainedTextField();
|
|---|
| 90 | objectLabel = new JLabel();
|
|---|
| 91 | objectBox = new JosmComboBox<>(TagCatalog.IndoorObject.values());
|
|---|
| 92 | nameLabel = new JLabel();
|
|---|
| 93 | nameField = new DisableShortcutsOnFocusGainedTextField();
|
|---|
| 94 | refLabel = new JLabel();
|
|---|
| 95 | refField = new DisableShortcutsOnFocusGainedTextField();
|
|---|
| 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.SHELL);
|
|---|
| 102 | preset3 = new PresetButton(IndoorObject.CONCRETE_WALL);
|
|---|
| 103 | preset4 = new PresetButton(IndoorObject.GLASS_WALL);
|
|---|
| 104 |
|
|---|
| 105 | //======== this ========
|
|---|
| 106 | //Container contentPane = this.get;
|
|---|
| 107 | //contentPane.setLayout(new BorderLayout());
|
|---|
| 108 |
|
|---|
| 109 | //======== dialogPane ========
|
|---|
| 110 | {
|
|---|
| 111 | dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
|
|---|
| 112 | dialogPane.setLayout(new BorderLayout());
|
|---|
| 113 |
|
|---|
| 114 | //======== contentPanel ========
|
|---|
| 115 | {
|
|---|
| 116 | contentPanel.setLayout(new GridBagLayout());
|
|---|
| 117 | ((GridBagLayout)contentPanel.getLayout()).columnWidths = new int[] {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};
|
|---|
| 118 | ((GridBagLayout)contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0, 0, 0};
|
|---|
| 119 | ((GridBagLayout)contentPanel.getLayout()).columnWeights = new double[] {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};
|
|---|
| 120 | ((GridBagLayout)contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
|
|---|
| 121 |
|
|---|
| 122 | //---- powerButton ----
|
|---|
| 123 | powerButton.setText(tr("POWER"));
|
|---|
| 124 | powerButton.setToolTipText(tr("Activates the plug-in"));
|
|---|
| 125 | contentPanel.add(powerButton, new GridBagConstraints(8, 0, 4, 1, 0.0, 0.0,
|
|---|
| 126 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 127 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 128 | contentPanel.add(separator1, new GridBagConstraints(1, 1, 12, 1, 0.0, 0.0,
|
|---|
| 129 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 130 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 131 |
|
|---|
| 132 | //---- levelLabel ----
|
|---|
| 133 | levelLabel.setText(tr("Working Level"));
|
|---|
| 134 | contentPanel.add(levelLabel, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0,
|
|---|
| 135 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 136 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 137 |
|
|---|
| 138 | //---- levelBox ----
|
|---|
| 139 | levelBox.setEnabled(false);
|
|---|
| 140 | levelBox.setEditable(false);
|
|---|
| 141 | levelBox.setToolTipText(tr("Selects the working level."));
|
|---|
| 142 | contentPanel.add(levelBox, new GridBagConstraints(3, 2, 3, 1, 0.0, 0.0,
|
|---|
| 143 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 144 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 145 |
|
|---|
| 146 | //---- levelTagLabel ----
|
|---|
| 147 | levelTagLabel.setText(tr("Level Name"));
|
|---|
| 148 | contentPanel.add(levelTagLabel, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0,
|
|---|
| 149 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 150 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 151 |
|
|---|
| 152 | //---- levelTagField ----
|
|---|
| 153 | levelTagField.setEnabled(false);
|
|---|
| 154 | levelTagField.setColumns(6);
|
|---|
| 155 | levelTagField.setToolTipText(tr("Optional name-tag for a level."));
|
|---|
| 156 | contentPanel.add(levelTagField, new GridBagConstraints(8, 2, 5, 1, 0.0, 0.0,
|
|---|
| 157 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 158 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 159 | contentPanel.add(separator2, new GridBagConstraints(1, 3, 12, 1, 0.0, 0.0,
|
|---|
| 160 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 161 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 162 |
|
|---|
| 163 | //---- objectLabel ----
|
|---|
| 164 | objectLabel.setText(tr("Object"));
|
|---|
| 165 | contentPanel.add(objectLabel, new GridBagConstraints(0, 4, 3, 1, 0.0, 0.0,
|
|---|
| 166 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 167 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 168 |
|
|---|
| 169 | //---- objectBox ----
|
|---|
| 170 | objectBox.setEnabled(false);
|
|---|
| 171 | objectBox.setPrototypeDisplayValue(IndoorObject.CONCRETE_WALL);
|
|---|
| 172 | objectBox.setToolTipText(tr("The object preset you want to tag."));
|
|---|
| 173 | contentPanel.add(objectBox, new GridBagConstraints(3, 4, 3, 1, 0.0, 0.0,
|
|---|
| 174 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 175 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 176 |
|
|---|
| 177 | //---- nameLabel ----
|
|---|
| 178 | nameLabel.setText(tr("Name"));
|
|---|
| 179 | contentPanel.add(nameLabel, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0,
|
|---|
| 180 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 181 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 182 |
|
|---|
| 183 | //---- nameField ----
|
|---|
| 184 | nameField.setEnabled(false);
|
|---|
| 185 | nameField.addFocusListener(new FocusListener() {
|
|---|
| 186 |
|
|---|
| 187 | @Override
|
|---|
| 188 | public void focusLost(FocusEvent e) {}
|
|---|
| 189 |
|
|---|
| 190 | @Override
|
|---|
| 191 | public void focusGained(FocusEvent e) {
|
|---|
| 192 | nameField.selectAll();
|
|---|
| 193 | }
|
|---|
| 194 | });
|
|---|
| 195 | nameField.setToolTipText(tr("Sets the name tag when the room-object is selected."));
|
|---|
| 196 | contentPanel.add(nameField, new GridBagConstraints(3, 5, 3, 1, 0.0, 0.0,
|
|---|
| 197 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 198 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 199 |
|
|---|
| 200 | //---- refLabel ----
|
|---|
| 201 | refLabel.setText(tr("Reference"));
|
|---|
| 202 | contentPanel.add(refLabel, new GridBagConstraints(0, 6, 3, 1, 0.0, 0.0,
|
|---|
| 203 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 204 | new Insets(0, 0, 0, 5), 0, 0));
|
|---|
| 205 |
|
|---|
| 206 | //---- refField ----
|
|---|
| 207 | refField.setEnabled(false);
|
|---|
| 208 | refField.addFocusListener(new FocusListener() {
|
|---|
| 209 |
|
|---|
| 210 | @Override
|
|---|
| 211 | public void focusLost(FocusEvent e) {}
|
|---|
| 212 |
|
|---|
| 213 | @Override
|
|---|
| 214 | public void focusGained(FocusEvent e) {
|
|---|
| 215 | refField.selectAll();
|
|---|
| 216 | }
|
|---|
| 217 | });
|
|---|
| 218 | refField.setToolTipText(tr("Sets the ref tag when the room-object is selected."));
|
|---|
| 219 | contentPanel.add(refField, new GridBagConstraints(3, 6, 3, 1, 0.0, 0.0,
|
|---|
| 220 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 221 | new Insets(0, 0, 0, 5), 0, 0));
|
|---|
| 222 |
|
|---|
| 223 | //---- preset1 ----
|
|---|
| 224 | preset1.setEnabled(false);
|
|---|
| 225 | contentPanel.add(preset1, new GridBagConstraints(16, 2, 1, 1, 0.0, 0.0,
|
|---|
| 226 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 227 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 228 | contentPanel.add(separator2, new GridBagConstraints(1, 3, 13, 1, 0.0, 0.0,
|
|---|
| 229 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 230 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 231 |
|
|---|
| 232 | //---- preset2 ----
|
|---|
| 233 | preset2.setEnabled(false);
|
|---|
| 234 | contentPanel.add(preset2, new GridBagConstraints(16, 3, 1, 1, 0.0, 0.0,
|
|---|
| 235 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 236 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 237 |
|
|---|
| 238 | //---- preset3 ----
|
|---|
| 239 | preset3.setEnabled(false);
|
|---|
| 240 | contentPanel.add(preset3, new GridBagConstraints(16, 4, 1, 1, 0.0, 0.0,
|
|---|
| 241 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 242 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 243 |
|
|---|
| 244 | //---- preset4 ----
|
|---|
| 245 | preset4.setEnabled(false);
|
|---|
| 246 | contentPanel.add(preset4, new GridBagConstraints(16, 5, 1, 1, 0.0, 0.0,
|
|---|
| 247 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 248 | new Insets(0, 0, 5, 5), 0, 0));
|
|---|
| 249 | }
|
|---|
| 250 | dialogPane.add(contentPanel, BorderLayout.CENTER);
|
|---|
| 251 |
|
|---|
| 252 | //======== buttonBar ========
|
|---|
| 253 | {
|
|---|
| 254 | buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
|
|---|
| 255 | buttonBar.setLayout(new GridBagLayout());
|
|---|
| 256 | ((GridBagLayout)buttonBar.getLayout()).columnWidths = new int[] {0, 80};
|
|---|
| 257 | ((GridBagLayout)buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0};
|
|---|
| 258 |
|
|---|
| 259 | //---- applyButton ----
|
|---|
| 260 | applyButton.setText(tr("Apply Tags"));
|
|---|
| 261 | applyButton.setEnabled(false);
|
|---|
| 262 | buttonBar.add(applyButton, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
|
|---|
| 263 | GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|---|
| 264 | new Insets(0, 0, 0, 0), 0, 0));
|
|---|
| 265 | }
|
|---|
| 266 | dialogPane.add(buttonBar, BorderLayout.SOUTH);
|
|---|
| 267 | }
|
|---|
| 268 | //contentPane.add(dialogPane, BorderLayout.CENTER);
|
|---|
| 269 |
|
|---|
| 270 |
|
|---|
| 271 | this.createLayout(dialogPane, false, null);
|
|---|
| 272 | }
|
|---|
| 273 |
|
|---|
| 274 | /**
|
|---|
| 275 | * Returns the state of the power button.
|
|---|
| 276 | *
|
|---|
| 277 | * @return boolean which is true when the button is selected
|
|---|
| 278 | */
|
|---|
| 279 | public boolean getPowerButtonState(){
|
|---|
| 280 | return this.powerButton.isSelected();
|
|---|
| 281 | }
|
|---|
| 282 |
|
|---|
| 283 | /**
|
|---|
| 284 | * Enables or disables the interactive UI elements of the toolbox.
|
|---|
| 285 | *
|
|---|
| 286 | * @param enabled set this true for enabled elements
|
|---|
| 287 | */
|
|---|
| 288 | public void setAllUiElementsEnabled(boolean enabled){
|
|---|
| 289 | this.applyButton.setEnabled(enabled);
|
|---|
| 290 | this.levelBox.setEnabled(enabled);
|
|---|
| 291 | this.objectBox.setEnabled(enabled);
|
|---|
| 292 | this.nameField.setEnabled(enabled);
|
|---|
| 293 | this.refField.setEnabled(enabled);
|
|---|
| 294 | this.levelTagField.setEnabled(enabled);
|
|---|
| 295 | this.preset1.setEnabled(enabled);
|
|---|
| 296 | this.preset2.setEnabled(enabled);
|
|---|
| 297 | this.preset3.setEnabled(enabled);
|
|---|
| 298 | this.preset4.setEnabled(enabled);
|
|---|
| 299 |
|
|---|
| 300 |
|
|---|
| 301 | if(enabled==false) {
|
|---|
| 302 | resetUiElements();
|
|---|
| 303 | this.levelTagField.setText("");
|
|---|
| 304 | }
|
|---|
| 305 | }
|
|---|
| 306 |
|
|---|
| 307 | /**
|
|---|
| 308 | * Enables or disables the interactive text box elements name and ref.
|
|---|
| 309 | *
|
|---|
| 310 | * @param enabled set this true for enabled elements
|
|---|
| 311 | */
|
|---|
| 312 | public void setTagUiElementsEnabled(boolean enabled){
|
|---|
| 313 | this.nameField.setEnabled(enabled);
|
|---|
| 314 | this.refField.setEnabled(enabled);
|
|---|
| 315 |
|
|---|
| 316 | if(enabled==false) resetUiElements();
|
|---|
| 317 | }
|
|---|
| 318 |
|
|---|
| 319 | /**
|
|---|
| 320 | * Disables the power-button of the plug-in.
|
|---|
| 321 | */
|
|---|
| 322 | public void setPowerButtonDisabled(){
|
|---|
| 323 | this.powerButton.setSelected(false);
|
|---|
| 324 | }
|
|---|
| 325 |
|
|---|
| 326 | /**
|
|---|
| 327 | * Getter for the selected {@link IndoorObject} in the objectBox.
|
|---|
| 328 | *
|
|---|
| 329 | * @return the selected indoor object in the object ComboBox.
|
|---|
| 330 | */
|
|---|
| 331 | public IndoorObject getSelectedObject(){
|
|---|
| 332 | return (IndoorObject) this.objectBox.getSelectedItem();
|
|---|
| 333 | }
|
|---|
| 334 |
|
|---|
| 335 |
|
|---|
| 336 | /**
|
|---|
| 337 | * Sets the level list for the level selection comboBox.
|
|---|
| 338 | *
|
|---|
| 339 | * @param levelList the list of levels which you want to set
|
|---|
| 340 | */
|
|---|
| 341 | public void setLevelList(List<IndoorLevel> levelList){
|
|---|
| 342 | this.levelBox.removeAllItems();
|
|---|
| 343 |
|
|---|
| 344 | ListIterator<IndoorLevel> listIterator = levelList.listIterator();
|
|---|
| 345 |
|
|---|
| 346 | while(listIterator.hasNext()){
|
|---|
| 347 | IndoorLevel level = listIterator.next();
|
|---|
| 348 | if(level.hasEmptyName()){
|
|---|
| 349 | this.levelBox.addItem(Integer.toString(level.getLevelNumber()));
|
|---|
| 350 | } else{
|
|---|
| 351 | this.levelBox.addItem(level.getName());
|
|---|
| 352 | }
|
|---|
| 353 | }
|
|---|
| 354 | }
|
|---|
| 355 |
|
|---|
| 356 | /**
|
|---|
| 357 | * Getter for the selected working level.
|
|---|
| 358 | *
|
|---|
| 359 | * @return the index of the selected item in the level-box
|
|---|
| 360 | */
|
|---|
| 361 | public int getSelectedLevelIndex(){
|
|---|
| 362 | return this.levelBox.getSelectedIndex();
|
|---|
| 363 | }
|
|---|
| 364 |
|
|---|
| 365 | /**
|
|---|
| 366 | * Checks if the level list is empty.
|
|---|
| 367 | *
|
|---|
| 368 | * @return boolean which is true if the level-list is empty
|
|---|
| 369 | */
|
|---|
| 370 | public boolean levelListIsEmpty(){
|
|---|
| 371 | if(this.levelBox.getItemCount()==0){
|
|---|
| 372 | return true;
|
|---|
| 373 | } else{
|
|---|
| 374 | return false;
|
|---|
| 375 | }
|
|---|
| 376 | }
|
|---|
| 377 |
|
|---|
| 378 | /**
|
|---|
| 379 | * Getter for the level-name-field.
|
|---|
| 380 | *
|
|---|
| 381 | * @return the {@link String} of the levelTagField
|
|---|
| 382 | */
|
|---|
| 383 | public String getLevelName(){
|
|---|
| 384 | return this.levelTagField.getText();
|
|---|
| 385 | }
|
|---|
| 386 |
|
|---|
| 387 | /**
|
|---|
| 388 | * Setter for the level name field.
|
|---|
| 389 | *
|
|---|
| 390 | * @param name the String for the levelTagField
|
|---|
| 391 | */
|
|---|
| 392 | public void setLevelName(String name){
|
|---|
| 393 | this.levelTagField.setText(name);
|
|---|
| 394 | }
|
|---|
| 395 |
|
|---|
| 396 | /**
|
|---|
| 397 | * Getter for the name {@link TextField}.
|
|---|
| 398 | *
|
|---|
| 399 | * @return {@link String} of the name text field
|
|---|
| 400 | */
|
|---|
| 401 | public String getNameText(){
|
|---|
| 402 | return this.nameField.getText();
|
|---|
| 403 | }
|
|---|
| 404 |
|
|---|
| 405 | /**
|
|---|
| 406 | * Getter for the ref {@link TextField}.
|
|---|
| 407 | *
|
|---|
| 408 | * @return {@link String} of the ref text field
|
|---|
| 409 | */
|
|---|
| 410 | public String getRefText(){
|
|---|
| 411 | return this.refField.getText();
|
|---|
| 412 | }
|
|---|
| 413 |
|
|---|
| 414 | /**
|
|---|
| 415 | * Resets the view by making the UI elements disabled and deleting the level list.
|
|---|
| 416 | */
|
|---|
| 417 | public void reset(){
|
|---|
| 418 | this.setAllUiElementsEnabled(false);
|
|---|
| 419 | this.levelBox.removeAllItems();
|
|---|
| 420 | }
|
|---|
| 421 |
|
|---|
| 422 | /**
|
|---|
| 423 | * Clears the text boxes and sets an empty {@link String}.
|
|---|
| 424 | */
|
|---|
| 425 | public void resetUiElements(){
|
|---|
| 426 | this.nameField.setText("");
|
|---|
| 427 | this.refField.setText("");
|
|---|
| 428 | }
|
|---|
| 429 |
|
|---|
| 430 | /*
|
|---|
| 431 | * ********************************
|
|---|
| 432 | * SETTERS FOR THE BUTTON LISTENERS
|
|---|
| 433 | * ********************************
|
|---|
| 434 | */
|
|---|
| 435 |
|
|---|
| 436 | /**
|
|---|
| 437 | * Set the listener for the power button.
|
|---|
| 438 | *
|
|---|
| 439 | * @param l the listener to set
|
|---|
| 440 | */
|
|---|
| 441 | public void setPowerButtonListener(ActionListener l){
|
|---|
| 442 | this.powerButton.addActionListener(l);
|
|---|
| 443 | }
|
|---|
| 444 |
|
|---|
| 445 | /**
|
|---|
| 446 | * Set the listener for the apply button.
|
|---|
| 447 | *
|
|---|
| 448 | * @param l the listener to set
|
|---|
| 449 | */
|
|---|
| 450 | public void setApplyButtonListener(ActionListener l){
|
|---|
| 451 | this.applyButton.addActionListener(l);
|
|---|
| 452 | }
|
|---|
| 453 |
|
|---|
| 454 | /**
|
|---|
| 455 | * Set the listener which is called when a new item in the level list is selected.
|
|---|
| 456 | *
|
|---|
| 457 | * @param l the listener to set
|
|---|
| 458 | */
|
|---|
| 459 | public void setLevelItemListener(ItemListener l){
|
|---|
| 460 | this.levelBox.addItemListener(l);
|
|---|
| 461 | }
|
|---|
| 462 |
|
|---|
| 463 |
|
|---|
| 464 | /**
|
|---|
| 465 | * Set the listener which is called when a new item in the object list is selected.
|
|---|
| 466 | *
|
|---|
| 467 | * @param l the listener to set
|
|---|
| 468 | */
|
|---|
| 469 | public void setObjectItemListener(ItemListener l){
|
|---|
| 470 | this.objectBox.addItemListener(l);
|
|---|
| 471 | }
|
|---|
| 472 |
|
|---|
| 473 | // Preset Button Functions
|
|---|
| 474 |
|
|---|
| 475 | public void setPresetButtons(List<IndoorObject> objects){
|
|---|
| 476 | this.preset1.setIndoorObject(objects.get(0));
|
|---|
| 477 | this.preset2.setIndoorObject(objects.get(1));
|
|---|
| 478 | this.preset3.setIndoorObject(objects.get(2));
|
|---|
| 479 | this.preset4.setIndoorObject(objects.get(3));
|
|---|
| 480 | }
|
|---|
| 481 |
|
|---|
| 482 | public void setPreset1Listener(ActionListener l){
|
|---|
| 483 | this.preset1.addActionListener(l);
|
|---|
| 484 | }
|
|---|
| 485 |
|
|---|
| 486 | public void setPreset2Listener(ActionListener l){
|
|---|
| 487 | this.preset2.addActionListener(l);
|
|---|
| 488 | }
|
|---|
| 489 |
|
|---|
| 490 | public void setPreset3Listener(ActionListener l){
|
|---|
| 491 | this.preset3.addActionListener(l);
|
|---|
| 492 | }
|
|---|
| 493 |
|
|---|
| 494 | public void setPreset4Listener(ActionListener l){
|
|---|
| 495 | this.preset4.addActionListener(l);
|
|---|
| 496 | }
|
|---|
| 497 |
|
|---|
| 498 | public IndoorObject getPreset1(){
|
|---|
| 499 | return preset1.getIndoorObject();
|
|---|
| 500 | }
|
|---|
| 501 |
|
|---|
| 502 | public IndoorObject getPreset2(){
|
|---|
| 503 | return preset2.getIndoorObject();
|
|---|
| 504 | }
|
|---|
| 505 |
|
|---|
| 506 | public IndoorObject getPreset3(){
|
|---|
| 507 | return preset3.getIndoorObject();
|
|---|
| 508 | }
|
|---|
| 509 |
|
|---|
| 510 | public IndoorObject getPreset4(){
|
|---|
| 511 | return preset4.getIndoorObject();
|
|---|
| 512 | }
|
|---|
| 513 | }
|
|---|