Ignore:
Timestamp:
2018-01-04T11:05:03+01:00 (7 years ago)
Author:
rebeccas95
Message:

Update indoorhelper plugin to support the Simple Indoor Tagging scheme

Location:
applications/editors/josm/plugins/indoorhelper/src/views
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/indoorhelper/src/views/LevelSelectorView.java

    r32637 r33974  
    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 
    191package views;
    202
     
    224
    235import java.awt.BorderLayout;
    24 import java.awt.Container;
    256import java.awt.GridBagConstraints;
    267import java.awt.GridBagLayout;
    278import java.awt.Insets;
    289import java.awt.event.ActionListener;
     10import java.awt.event.FocusEvent;
     11import java.awt.event.FocusListener;
     12import java.awt.event.WindowListener;
    2913
    3014import javax.swing.JButton;
     
    3216import javax.swing.JLabel;
    3317import javax.swing.JPanel;
    34 import javax.swing.JSpinner;
    35 import javax.swing.JSpinner.DefaultEditor;
    3618import javax.swing.border.EmptyBorder;
    3719
     20import org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField;
     21
    3822/**
    39  * Class for the pop-up window which provides an level selector to get a user input.
    40  * In this window the user declares the lowest and the highest level of the building he wants to map.
     23 * This is the level selector toolbox of the indoorhelper plug-in.
    4124 *
    42  * @author egru
     25 * @author rebsc
    4326 *
    4427 */
    45 
    46 @SuppressWarnings("serial")
    4728public class LevelSelectorView extends JFrame {
    4829
    49     private JPanel dialogPane;
     30        private static final long serialVersionUID = 1L;
     31        private JPanel dialogPane;
    5032    private JPanel contentPanel;
    51     private JLabel minLabel;
    52     private JSpinner minSpinner;
    53     private JLabel maxLabel;
    54     private JSpinner maxSpinner;
     33    private JPanel infoBar;
    5534    private JPanel buttonBar;
    5635    private JButton okButton;
    5736    private JButton cancelButton;
     37    private JLabel label1;
     38    private JLabel label2;
     39    private DisableShortcutsOnFocusGainedTextField field;
    5840
    5941    public LevelSelectorView() {
     
    6446        dialogPane = new JPanel();
    6547        contentPanel = new JPanel();
    66         minLabel = new JLabel();
    67         minSpinner = new JSpinner();
    68         maxLabel = new JLabel();
    69         maxSpinner = new JSpinner();
     48        infoBar = new JPanel();
    7049        buttonBar = new JPanel();
    7150        okButton = new JButton();
    7251        cancelButton = new JButton();
     52        label1 = new JLabel();
     53        label2 = new JLabel();
     54        field = new DisableShortcutsOnFocusGainedTextField();
    7355
    7456        //======== this ========
    75         setTitle(tr("Level Selection"));
    76         Container contentPane = getContentPane();
     57        setTitle(tr("Add a new level"));
     58        java.awt.Container contentPane = getContentPane();
    7759        contentPane.setLayout(new BorderLayout());
    7860
     
    8264            dialogPane.setLayout(new BorderLayout());
    8365
     66
     67                //======== infoBar ========
     68                {
     69
     70                        //---- Label1 ----
     71                        label1.setText(tr("<html> Please insert the new level number you want to add.<br> "
     72                                        + " <i>Info</i>: <br> If the OK button got pressed you will switch to the drawing action.<br>"
     73                                        + "To finish the new object please press the spacebar. The new level<br>will be tagged automatically. </html>"));
     74                        infoBar.add(label1);
     75                }
     76                dialogPane.add(infoBar,BorderLayout.NORTH);
     77
     78
    8479            //======== contentPanel ========
    8580            {
    86                 contentPanel.setLayout(new GridBagLayout());
     81                contentPanel.setLayout(new GridBagLayout());
    8782                ((GridBagLayout) contentPanel.getLayout()).columnWidths = new int[] {0, 0, 0, 0, 0};
    8883                ((GridBagLayout) contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0};
     
    9085                ((GridBagLayout) contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
    9186
    92                 //---- minLabel ----
    93                 minLabel.setText(tr("Lowest Level"));
    94                 contentPanel.add(maxLabel, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
    95                     GridBagConstraints.CENTER, GridBagConstraints.BOTH,
    96                     new Insets(0, 0, 5, 5), 0, 0));
    97                 JSpinner.DefaultEditor minEditor = (DefaultEditor) maxSpinner.getEditor();
    98                 minEditor.getTextField().setColumns(2);
    99                 maxSpinner.setToolTipText(tr("The lowest level of your building."));
    100                 contentPanel.add(maxSpinner, new GridBagConstraints(2, 0, 2, 1, 0.0, 0.0,
    101                     GridBagConstraints.CENTER, GridBagConstraints.BOTH,
    102                     new Insets(0, 0, 5, 0), 0, 0));
    10387
    104                 //---- maxLabel ----
    105                 maxLabel.setText(tr("Highest Level"));
    106                 contentPanel.add(minLabel, new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0,
    107                     GridBagConstraints.CENTER, GridBagConstraints.BOTH,
    108                     new Insets(0, 0, 5, 5), 0, 0));
    109                 JSpinner.DefaultEditor maxEditor = (DefaultEditor) minSpinner.getEditor();
    110                 maxEditor.getTextField().setColumns(2);
    111                 minSpinner.setToolTipText(tr("The highest level of your building."));
    112                 contentPanel.add(minSpinner, new GridBagConstraints(2, 2, 2, 1, 0.0, 0.0,
    113                     GridBagConstraints.CENTER, GridBagConstraints.BOTH,
    114                     new Insets(0, 0, 5, 0), 0, 0));
     88                //---- Label2 ----
     89                label2.setText(tr("level number:"));
     90                contentPanel.add(label2,new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0,
     91                        GridBagConstraints.CENTER, GridBagConstraints.BOTH,
     92                        new Insets(5, 5, 5, 30), 0, 0));
     93
     94                //---- Field ----
     95                field.setToolTipText(tr("Example: '2' or '3'"));
     96                field.addFocusListener(new FocusListener() {
     97
     98                    @Override
     99                    public void focusLost(FocusEvent e) {}
     100
     101                    @Override
     102                    public void focusGained(FocusEvent e) {
     103                        field.selectAll();
     104                    }
     105                });
     106                contentPanel.add(field, new GridBagConstraints(3, 0, 2, 1, 0.0, 0.0,
     107                        GridBagConstraints.CENTER, GridBagConstraints.BOTH,
     108                        new Insets(5, 0, 5, 200), 0, 0));
     109
    115110            }
    116111            dialogPane.add(contentPanel, BorderLayout.CENTER);
     
    126121                okButton.setText(tr("OK"));
    127122                buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
    128                     GridBagConstraints.CENTER, GridBagConstraints.BOTH,
    129                     new Insets(0, 0, 0, 5), 0, 0));
     123                        GridBagConstraints.CENTER, GridBagConstraints.BOTH,
     124                        new Insets(0, 0, 0, 5), 0, 0));
    130125
    131                 //---- cancelButton ----
    132                 cancelButton.setText(tr("Cancel"));
     126                //---- Button ----
     127               cancelButton.setText(tr("Cancel"));
    133128                buttonBar.add(cancelButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
    134                     GridBagConstraints.CENTER, GridBagConstraints.BOTH,
    135                     new Insets(0, 0, 0, 0), 0, 0));
    136             }
    137             dialogPane.add(contentPanel, BorderLayout.CENTER);
    138 
    139             //======== buttonBar ========
    140             {
    141                 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
    142                 buttonBar.setLayout(new GridBagLayout());
    143                 ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 85, 80};
    144                 ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0, 0.0};
    145 
    146                 //---- okButton ----
    147                 okButton.setText(tr("OK"));
    148                 buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
    149                     GridBagConstraints.CENTER, GridBagConstraints.BOTH,
    150                     new Insets(0, 0, 0, 5), 0, 0));
    151 
    152                 //---- cancelButton ----
    153                 cancelButton.setText(tr("Cancel"));
    154                 buttonBar.add(cancelButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
    155                     GridBagConstraints.CENTER, GridBagConstraints.BOTH,
    156                     new Insets(0, 0, 0, 0), 0, 0));
     129                        GridBagConstraints.CENTER, GridBagConstraints.BOTH,
     130                        new Insets(0, 0, 0, 0), 0, 0));
    157131            }
    158132            dialogPane.add(buttonBar, BorderLayout.SOUTH);
     
    164138    }
    165139
     140/*************************************************
     141* GETTER
     142*
     143*/
    166144    /**
     145     * Getter for the level number field.
     146     *
     147     * @return the {@link String}
     148     */
     149    public String getLevelNumber() {
     150        return this.field.getText();
     151    }
     152
     153/*************************************************
     154* SELECTOR VIEW LISTENER
     155*
     156*/
     157
     158        /**
    167159     * Set the listener for the OK button.
    168160     *
     
    173165    }
    174166
    175     /**
    176      * Set the listener for the cancel button.
     167        /**
     168     * Set the listener for the Cancel button.
    177169     *
    178170     * @param l the listener to set
     
    183175
    184176    /**
    185      * Getter for the lowest level.
     177     * Set the listener for window {@Link LevelSelectorView}
    186178     *
    187      * @return Integer which represents the lowest level of the building.
     179     * @param l the listener to set
    188180     */
    189     public int getMin() {
    190         return (int) this.minSpinner.getValue();
     181    public void setSelectorWindowListener(WindowListener l) {
     182        this.addWindowListener(l);
    191183    }
    192184
    193     /**
    194      * Getter for the highest level.
    195      *
    196      * @return Integer which represents the highest level of the building.
    197      */
    198     public int getMax() {
    199         return (int) this.maxSpinner.getValue();
    200     }
     185/**
     186*
     187*
     188*
     189*
     190*
     191*
     192*
     193*
     194*/
    201195}
  • applications/editors/josm/plugins/indoorhelper/src/views/PresetButton.java

    r32637 r33974  
    4545        this.indoorObject = object;
    4646        this.setText(indoorObject.toString());
    47         this.setToolTipText(indoorObject.toString());
     47        this.setToolTipText("Fast Tag: "+indoorObject.toString());
    4848    }
    4949
     50
     51/**
     52*
     53*
     54*
     55*
     56*
     57*
     58*
     59*
     60*/
    5061}
  • applications/editors/josm/plugins/indoorhelper/src/views/ToolBoxView.java

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