Changeset 17745 in osm


Ignore:
Timestamp:
2009-09-21T20:15:26+02:00 (15 years ago)
Author:
miken
Message:

JOSM Addr Interpolation Plugin Update dialog layout

Location:
applications/editors/josm/plugins/addrinterpolation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/addrinterpolation/build.xml

    r17735 r17745  
    9191                <attribute name="Plugin-Description" value="Group common Address Interpolation inputs in a single dialog,"/>
    9292                <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/wiki/JOSM/Plugins/AddrInterpolation"/>
    93                 <attribute name="Plugin-Mainversion" value="2161"/>
     93                <attribute name="Plugin-Mainversion" value="2100"/>
    9494                <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
    9595            </manifest>
  • applications/editors/josm/plugins/addrinterpolation/src/org/openstreetmap/josm/plugins/AddrInterpolation/AddrInterpolationDialog.java

    r17735 r17745  
    7979        private JTextField postCodeTextField = null;
    8080        private JTextField countryTextField = null;
    81         private JTextField allTextField = null;
     81        private JTextField fullTextField = null;
    8282
    8383        private boolean relationChanged = false; // Whether to re-trigger data changed for relation
     
    134134                lastPostCode = postCodeTextField.getText();
    135135                lastCountry = countryTextField.getText();
    136                 lastFullAddress = allTextField.getText();
     136                lastFullAddress = fullTextField.getText();
    137137
    138138        }
     
    201201                AddEditControlRows(textLabels, editFields,      editControlsPane);
    202202
    203                 JPanel optionPanel = new JPanel(new BorderLayout());
    204 
    205                 Border dividerBorder = BorderFactory.createEtchedBorder();
    206                 TitledBorder titleBorder = BorderFactory.createTitledBorder(dividerBorder, tr("Optional Information:"),
    207                                 TitledBorder.LEFT, TitledBorder.BOTTOM);
    208 
    209                 optionPanel.setBorder(titleBorder);
    210                 editControlsPane.add(optionPanel, c);
    211 
    212203                // Address interpolation fields not valid if Way not selected
    213204                if (addrInterpolationWay == null) {
     
    217208                }
    218209
     210
     211
     212                JPanel optionPanel = CreateOptionalFields();
     213                c.gridx = 0;
     214                c.gridwidth = 2; // # of columns to span
     215                c.fill = GridBagConstraints.BOTH;      // Full width
     216                c.gridwidth = GridBagConstraints.REMAINDER;     //end row
     217
     218                editControlsPane.add(optionPanel, c);
     219
     220
     221                KeyAdapter enterProcessor = new KeyAdapter() {
     222                        @Override
     223                        public void keyPressed(KeyEvent e) {
     224                                if (e.getKeyCode() == KeyEvent.VK_ENTER) {
     225                                        if (ValidateAndSave()) {
     226                                                dialog.dispose();
     227                                        }
     228
     229                                }
     230                        }
     231                };
     232
     233                // Make Enter == OK click on fields using this adapter
     234                endTextField.addKeyListener(enterProcessor);
     235                cityTextField.addKeyListener(enterProcessor);
     236
     237
     238
     239                if (houseNumberNodes.size() > 0) {
     240                        JLabel houseNumberNodeNote = new JLabel(tr("Will associate {0} additional house number nodes",
     241                                        houseNumberNodes.size() ));
     242                        editControlsPane.add(houseNumberNodeNote, c);
     243                }
     244
     245                editControlsPane.add(new UrlLabel("http://wiki.openstreetmap.org/wiki/JOSM/Plugins/AddrInterpolation",
     246                                tr("More information about this feature")), c);
     247
     248
     249                c.gridx = 0;
     250                c.gridwidth = 1; //next-to-last
     251                c.fill = GridBagConstraints.NONE;      //reset to default
     252                c.weightx = 0.0;
     253                c.insets = new Insets(15, 0, 0, 0);
     254                c.anchor = GridBagConstraints.LINE_END;
     255                JButton okButton = new JButton(tr("OK"), ImageProvider.get("ok"));
     256                editControlsPane.add(okButton, c);
     257
     258                c.gridx = 1;
     259                c.gridwidth = GridBagConstraints.REMAINDER;     //end row
     260                c.weightx = 1.0;
     261                c.anchor = GridBagConstraints.LINE_START;
     262
     263                JButton cancelButton = new JButton(tr("Cancel"), ImageProvider.get("cancel"));
     264                editControlsPane.add(cancelButton, c);
     265
     266                okButton.setActionCommand("ok");
     267                okButton.addActionListener(this);
     268                cancelButton.setActionCommand("cancel");
     269                cancelButton.addActionListener(this);
     270
     271                return editControlsPane;
     272        }
     273
     274
     275
     276        // Create optional control fields in a group box
     277        private JPanel CreateOptionalFields() {
     278
     279                JPanel editControlsPane = new JPanel();
     280                GridBagLayout gridbag = new GridBagLayout();
     281
     282                editControlsPane.setLayout(gridbag);
     283
     284                editControlsPane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     285
    219286                JLabel[] optionalTextLabels = {new JLabel(tr("City:")),
    220287                                new JLabel(tr("State:")),
    221288                                new JLabel(tr("Post Code:")),
    222289                                new JLabel(tr("Country:")),
    223                                 new JLabel(tr("All:"))};
     290                                new JLabel(tr("Full Address:"))};
    224291                cityTextField = new JTextField(lastCity, 100);
    225292                stateTextField = new JTextField(lastState, 100);
    226293                postCodeTextField = new JTextField(lastPostCode, 20);
    227294                countryTextField = new JTextField(lastCountry, 2);
    228                 allTextField = new JTextField(lastFullAddress, 300);
     295                fullTextField = new JTextField(lastFullAddress, 300);
    229296
    230297                // Special processing for addr:country code, max length and uppercase
     
    239306                                } else if (length > jtextfield.getColumns()) {
    240307                                        // show error message ??
     308                                        e.consume();
    241309                                } else {
    242310                                        // Accept key; convert to upper case
     
    248316                });
    249317
    250 
    251                 KeyAdapter enterProcessor = new KeyAdapter() {
    252                         @Override
    253                         public void keyPressed(KeyEvent e) {
    254                                 if (e.getKeyCode() == KeyEvent.VK_ENTER) {
    255                                         if (ValidateAndSave()) {
    256                                                 dialog.dispose();
    257                                         }
    258 
    259                                 }
    260                         }
    261                 };
    262 
    263                 // Make Enter == OK click on fields using this adapter
    264                 endTextField.addKeyListener(enterProcessor);
    265                 cityTextField.addKeyListener(enterProcessor);
    266 
    267 
    268                 Component[] optionalEditFields = {cityTextField, stateTextField, postCodeTextField, countryTextField, allTextField};
     318                Component[] optionalEditFields = {cityTextField, stateTextField, postCodeTextField, countryTextField, fullTextField};
    269319                AddEditControlRows(optionalTextLabels, optionalEditFields,      editControlsPane);
    270320
    271321
    272322
    273                 c.gridx = 0;
    274                 c.gridwidth = 2; // # of columns to span
    275                 c.fill = GridBagConstraints.BOTH;      // Full width
    276                 c.gridwidth = GridBagConstraints.REMAINDER;     //end row
    277 
    278                 if (houseNumberNodes.size() > 0) {
    279                         JLabel houseNumberNodeNote = new JLabel(tr("Will associate {0} additional house number nodes",
    280                                         houseNumberNodes.size() ));
    281                         editControlsPane.add(houseNumberNodeNote, c);
    282                 }
    283 
    284                 editControlsPane.add(new UrlLabel("http://wiki.openstreetmap.org/wiki/JOSM/Plugins/AddrInterpolation",
    285                                 tr("More information about this feature")), c);
    286 
    287 
    288                 c.gridx = 0;
    289                 c.gridwidth = 1; //next-to-last
    290                 c.fill = GridBagConstraints.NONE;      //reset to default
    291                 c.weightx = 0.0;
    292                 c.insets = new Insets(15, 0, 0, 0);
    293                 c.anchor = GridBagConstraints.LINE_END;
    294                 JButton okButton = new JButton(tr("OK"), ImageProvider.get("ok"));
    295                 editControlsPane.add(okButton, c);
    296 
    297                 c.gridx = 1;
    298                 c.gridwidth = GridBagConstraints.REMAINDER;     //end row
    299                 c.weightx = 1.0;
    300                 c.anchor = GridBagConstraints.LINE_START;
    301 
    302                 JButton cancelButton = new JButton(tr("Cancel"), ImageProvider.get("cancel"));
    303                 editControlsPane.add(cancelButton, c);
    304 
    305                 okButton.setActionCommand("ok");
    306                 okButton.addActionListener(this);
    307                 cancelButton.setActionCommand("cancel");
    308                 cancelButton.addActionListener(this);
    309 
    310                 return editControlsPane;
     323                JPanel optionPanel = new JPanel(new BorderLayout());
     324                Border groupBox = BorderFactory.createEtchedBorder();
     325                TitledBorder titleBorder = BorderFactory.createTitledBorder(groupBox, tr("Optional Information:"),
     326                                TitledBorder.LEFT, TitledBorder.TOP);
     327
     328                optionPanel.setBorder(titleBorder);
     329                optionPanel.add(editControlsPane, BorderLayout.CENTER);
     330
     331                return optionPanel;
    311332        }
    312333
     
    591612                String postCode = ReadTextField(postCodeTextField);
    592613                String country = ReadTextField(countryTextField);
    593                 String fullAddress = ReadTextField(allTextField);
     614                String fullAddress = ReadTextField(fullTextField);
    594615
    595616                String selectedMethod = GetInterpolationMethod();
Note: See TracChangeset for help on using the changeset viewer.