Ignore:
Timestamp:
2018-01-13T18:19:22+01:00 (7 years ago)
Author:
donvip
Message:

code cleanup

File:
1 edited

Legend:

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

    r33997 r34005  
    4646public class LevelSelectorView extends JFrame {
    4747
    48         private static final long serialVersionUID = 1L;
    49         private JPanel dialogPane;
     48    private static final long serialVersionUID = 1L;
     49    private JPanel dialogPane;
    5050    private JPanel contentPanel;
    5151    private JPanel infoBar;
     
    7878
    7979        //======== dialogPane ========
    80         {
    81             dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
    82             dialogPane.setLayout(new BorderLayout());
    8380
     81        dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
     82        dialogPane.setLayout(new BorderLayout());
    8483
    85                 //======== infoBar ========
    86                 {
     84        //======== infoBar ========
    8785
    88                         //---- Label1 ----
    89                         label1.setText(tr("<html> Please insert the new level number you want to add.<br> "
    90                                         + " <i>Info</i>: <br> If the OK button got pressed you will switch to the drawing action.<br>"
    91                                         + "To finish the new object please press the spacebar. The new level<br>will be tagged automatically. </html>"));
    92                         infoBar.add(label1);
    93                 }
    94                 dialogPane.add(infoBar,BorderLayout.NORTH);
     86        //---- Label1 ----
     87        label1.setText(tr("<html> Please insert the new level number you want to add.<br> "
     88                + " <i>Info</i>: <br> If the OK button got pressed you will switch to the drawing action.<br>"
     89                + "To finish the new object please press the spacebar. The new level<br>will be tagged automatically. </html>"));
     90        infoBar.add(label1);
     91        dialogPane.add(infoBar, BorderLayout.NORTH);
    9592
     93        //======== contentPanel ========
    9694
    97             //======== contentPanel ========
    98             {
    99                 contentPanel.setLayout(new GridBagLayout());
    100                 ((GridBagLayout) contentPanel.getLayout()).columnWidths = new int[] {0, 0, 0, 0, 0};
    101                 ((GridBagLayout) contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0};
    102                 ((GridBagLayout) contentPanel.getLayout()).columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 1.0E-4};
    103                 ((GridBagLayout) contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
     95        contentPanel.setLayout(new GridBagLayout());
     96        ((GridBagLayout) contentPanel.getLayout()).columnWidths = new int[] {0, 0, 0, 0, 0};
     97        ((GridBagLayout) contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0, 0, 0};
     98        ((GridBagLayout) contentPanel.getLayout()).columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 1.0E-4};
     99        ((GridBagLayout) contentPanel.getLayout()).rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};
    104100
     101        //---- Label2 ----
     102        label2.setText(tr("level number:"));
     103        contentPanel.add(label2, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0,
     104                GridBagConstraints.CENTER, GridBagConstraints.BOTH,
     105                new Insets(5, 5, 5, 30), 0, 0));
    105106
    106                 //---- Label2 ----
    107                 label2.setText(tr("level number:"));
    108                 contentPanel.add(label2,new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0,
    109                         GridBagConstraints.CENTER, GridBagConstraints.BOTH,
    110                         new Insets(5, 5, 5, 30), 0, 0));
     107        //---- Field ----
     108        field.setToolTipText(tr("Example: '2' or '3'"));
     109        field.addFocusListener(new FocusListener() {
    111110
    112                 //---- Field ----
    113                 field.setToolTipText(tr("Example: '2' or '3'"));
    114                 field.addFocusListener(new FocusListener() {
     111            @Override
     112            public void focusLost(FocusEvent e) {}
    115113
    116                     @Override
    117                     public void focusLost(FocusEvent e) {}
     114            @Override
     115            public void focusGained(FocusEvent e) {
     116                field.selectAll();
     117            }
     118        });
     119        contentPanel.add(field, new GridBagConstraints(3, 0, 2, 1, 0.0, 0.0,
     120                GridBagConstraints.CENTER, GridBagConstraints.BOTH,
     121                new Insets(5, 0, 5, 200), 0, 0));
    118122
    119                     @Override
    120                     public void focusGained(FocusEvent e) {
    121                         field.selectAll();
    122                     }
    123                 });
    124                 contentPanel.add(field, new GridBagConstraints(3, 0, 2, 1, 0.0, 0.0,
    125                         GridBagConstraints.CENTER, GridBagConstraints.BOTH,
    126                         new Insets(5, 0, 5, 200), 0, 0));
     123        dialogPane.add(contentPanel, BorderLayout.CENTER);
    127124
    128             }
    129             dialogPane.add(contentPanel, BorderLayout.CENTER);
     125        //======== buttonBar ========
    130126
    131             //======== buttonBar ========
    132             {
    133                 buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
    134                 buttonBar.setLayout(new GridBagLayout());
    135                 ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 85, 80};
    136                 ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0, 0.0};
     127        buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
     128        buttonBar.setLayout(new GridBagLayout());
     129        ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 85, 80};
     130        ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0, 0.0};
    137131
    138                 //---- okButton ----
    139                 okButton.setText(tr("OK"));
    140                 buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
    141                         GridBagConstraints.CENTER, GridBagConstraints.BOTH,
    142                         new Insets(0, 0, 0, 5), 0, 0));
     132        //---- okButton ----
     133        okButton.setText(tr("OK"));
     134        buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
     135                GridBagConstraints.CENTER, GridBagConstraints.BOTH,
     136                new Insets(0, 0, 0, 5), 0, 0));
    143137
    144                 //---- Button ----
    145                cancelButton.setText(tr("Cancel"));
    146                 buttonBar.add(cancelButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
    147                         GridBagConstraints.CENTER, GridBagConstraints.BOTH,
    148                         new Insets(0, 0, 0, 0), 0, 0));
    149             }
    150             dialogPane.add(buttonBar, BorderLayout.SOUTH);
    151         }
     138        //---- Button ----
     139        cancelButton.setText(tr("Cancel"));
     140        buttonBar.add(cancelButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
     141                GridBagConstraints.CENTER, GridBagConstraints.BOTH,
     142                new Insets(0, 0, 0, 0), 0, 0));
     143
     144        dialogPane.add(buttonBar, BorderLayout.SOUTH);
     145
    152146        contentPane.add(dialogPane, BorderLayout.CENTER);
    153147        pack();
    154148        setLocationRelativeTo(getOwner());
    155 
    156149    }
    157150
    158 /*************************************************
    159 * GETTER
    160 *
    161 */
    162151    /**
    163152     * Getter for the level number field.
     
    169158    }
    170159
    171 /*************************************************
    172 * SELECTOR VIEW LISTENER
    173 *
    174 */
    175 
    176         /**
     160    /**
    177161     * Set the listener for the OK button.
    178162     *
     
    183167    }
    184168
    185         /**
     169    /**
    186170     * Set the listener for the Cancel button.
    187171     *
     
    198182     */
    199183    public void setSelectorWindowListener(WindowListener l) {
    200         this.addWindowListener(l);
     184        this.addWindowListener(l);
    201185    }
    202 
    203 /**
    204 *
    205 *
    206 *
    207 *
    208 *
    209 *
    210 *
    211 *
    212 */
    213186}
Note: See TracChangeset for help on using the changeset viewer.