Changeset 36060 in osm for applications/editors


Ignore:
Timestamp:
2023-02-27T16:08:37+01:00 (21 months ago)
Author:
taylor.smock
Message:

Fix #22667: Add i18n support for HouseNumberTaggingTool data menu entry (patch by holgermappt, modified)

The additional modifications include:

  • Lint cleanups
  • Code deduplication
  • Checkstyle fixes
Location:
applications/editors/josm/plugins/HouseNumberTaggingTool
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/Dto.java

    r35508 r36060  
    55
    66/**
     7 * An object for the current dialog settings
    78 * @author Oliver Raupach 18.01.2012
    89 */
  • applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/HouseNumberHelper.java

    r35508 r36060  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.housenumbertool;
    23
     
    45import java.util.regex.Pattern;
    56
    6 public class HouseNumberHelper {
     7import org.openstreetmap.josm.tools.Logging;
    78
    8     static public String incrementHouseNumber(String number, int increment) {
     9/**
     10 * A helper class for incrementing addr:housenumber
     11 */
     12public final class HouseNumberHelper {
     13    private HouseNumberHelper() {
     14        // Hide constructor
     15    }
     16
     17    /**
     18     * Increment a house number
     19     * @param number The number to increment
     20     * @param increment The amount to increment the number by
     21     * @return The incremented number
     22     */
     23    public static String incrementHouseNumber(String number, int increment) {
    924        if (number != null) {
    1025            try {
     
    1631                    return prefix + n + suffix;
    1732                }
    18             } catch (NumberFormatException e)  {
    19                 // Do nothing
     33            } catch (NumberFormatException e) {
     34                Logging.trace(e);
    2035            }
    2136        }
  • applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/LaunchAction.java

    r35581 r36060  
    1515import org.openstreetmap.josm.tools.Shortcut;
    1616
     17/**
     18 * An action for opening the {@link TagDialog} editor
     19 */
    1720public class LaunchAction extends JosmAction implements DataSelectionListener {
    1821
    19     private OsmPrimitive selection = null;
     22    private static final long serialVersionUID = -2017126466206457986L;
     23    private OsmPrimitive selection;
    2024
    21     private File pluginDir;
     25    private final File pluginDir;
    2226
    2327    /**
     
    2630     */
    2731    public LaunchAction(File pluginDir) {
    28         super("HouseNumberTaggingTool",
     32        super(tr("HouseNumberTaggingTool"),
    2933              "home-icon32",
    30               "Launches the HouseNumberTaggingTool dialog",
     34              tr("Launches the HouseNumberTaggingTool dialog"),
    3135              Shortcut.registerShortcut("edit:housenumbertaggingtool", tr("Data: {0}", "HouseNumberTaggingTool"),
    3236                KeyEvent.VK_K, Shortcut.DIRECT),
     
    6064        if (newSelection != null && newSelection.size() == 1) {
    6165            setEnabled(true);
    62             selection  = newSelection.iterator().next();
     66            selection = newSelection.iterator().next();
    6367        } else {
    6468            setEnabled(false);
  • applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/TagDialog.java

    r35814 r36060  
    99import java.awt.GridBagConstraints;
    1010import java.awt.GridBagLayout;
    11 import java.awt.Insets;
    1211import java.awt.event.ActionEvent;
     12import java.awt.event.ActionListener;
    1313import java.awt.event.ItemEvent;
    1414import java.awt.event.ItemListener;
     
    1616import java.io.FileInputStream;
    1717import java.io.FileOutputStream;
     18import java.io.IOException;
    1819import java.io.ObjectInputStream;
    1920import java.io.ObjectOutputStream;
     
    2425import java.util.Set;
    2526import java.util.TreeSet;
    26 import java.util.logging.Level;
    27 import java.util.logging.Logger;
    2827
    2928import javax.swing.ButtonGroup;
     
    4847import org.openstreetmap.josm.gui.tagging.ac.AutoCompComboBox;
    4948import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager;
     49import org.openstreetmap.josm.gui.widgets.JosmComboBox;
     50import org.openstreetmap.josm.gui.widgets.JosmTextField;
     51import org.openstreetmap.josm.tools.GBC;
     52import org.openstreetmap.josm.tools.Logging;
    5053
    5154/**
     55 * The dialog to show users the tags that will be applied to an object
     56 *
    5257 * @author Oliver Raupach 09.01.2012
    5358 * @author Victor Kropp 10.03.2012
    5459 */
    5560public class TagDialog extends ExtendedDialog {
     61    private static final long serialVersionUID = -4781477945608720136L;
    5662    private static final String APPLY_CHANGES = tr("Apply Changes");
    5763    private static final String TAG_STREET_OR_PLACE = tr("Use tag ''addr:street'' or ''addr:place''");
     
    7076    private static final String[] BUILDING_STRINGS = {
    7177        "yes", "apartments", "chapel", "church", "commercial", "dormitory", "hotel", "house", "residential", "terrace",
    72         "industrial", "retail", "warehouse", "cathedral",  "civic", "hospital", "school", "train_station", "transportation",
     78        "industrial", "retail", "warehouse", "cathedral", "civic", "hospital", "school", "train_station", "transportation",
    7379        "university", "public", "bridge", "bunker", "cabin", "construction", "farm_auxiliary", "garage", "garages",
    7480        "greenhouse", "hangar", "hut", "roof", "shed", "stable"};
    7581
    7682    private static final int FPS_MIN = -10;
    77     private static final int FPS_MAX =  10;
    78 
    79     private static final Logger LOGGER = Logger.getLogger(TagDialog.class.getName());
    80 
    81     private File pluginDir;
     83    private static final int FPS_MAX = 10;
     84
     85    private final File pluginDir;
    8286    private AutoCompletionManager acm;
    83     private OsmPrimitive selection;
     87    private final OsmPrimitive selection;
    8488
    8589    private static final String TEMPLATE_DATA = "/template.data";
     
    8791    private AutoCompComboBox<AutoCompletionItem> source;
    8892    private AutoCompComboBox<AutoCompletionItem> country;
    89     private AutoCompComboBox<AutoCompletionItem> state;
     93    private AutoCompComboBox<AutoCompletionItem> stateTag;
    9094    private AutoCompComboBox<AutoCompletionItem> suburb;
    9195    private AutoCompComboBox<AutoCompletionItem> city;
    9296    private AutoCompComboBox<AutoCompletionItem> postcode;
    9397    private AutoCompComboBox<AutoCompletionItem> street;
    94     private JTextField housnumber;
     98    private JTextField housenumber;
    9599    private JCheckBox buildingEnabled;
    96100    private JCheckBox sourceEnabled;
     
    113117     */
    114118    public TagDialog(File pluginDir, OsmPrimitive selection) {
    115         super(MainApplication.getMainFrame(), tr("House Number Editor"), new String[] { tr("OK"), tr("Cancel") }, true);
     119        super(MainApplication.getMainFrame(), tr("House Number Editor"), new String[] {tr("OK"), tr("Cancel")}, true);
    116120        this.pluginDir = pluginDir;
    117121        this.selection = selection;
     
    132136
    133137        SwingUtilities.invokeLater(() -> {
    134             housnumber.requestFocus();
    135             housnumber.selectAll();
     138            housenumber.requestFocus();
     139            housenumber.selectAll();
    136140        });
    137141    }
     
    143147
    144148        JPanel editPanel = new JPanel(new GridBagLayout());
    145         GridBagConstraints c = new GridBagConstraints();
    146149
    147150        JLabel labelNewValues = new JLabel();
     
    149152        labelNewValues.setFont(newLabelFont);
    150153        labelNewValues.setText(tr("New values:"));
    151         c.fill = GridBagConstraints.HORIZONTAL;
    152         c.gridx = 3;
    153         c.gridy = 0;
    154         c.weightx = 0;
    155         c.gridwidth = 1;
    156         c.insets = new Insets(0, 5, 10, 5);
    157         editPanel.add(labelNewValues, c);
     154        editPanel.add(labelNewValues, GBC.std().grid(3, 0).insets(0, 5, 10, 5));
    158155
    159156        JLabel labelExistingValues = new JLabel();
    160157        labelExistingValues.setFont(newLabelFont);
    161158        labelExistingValues.setText(tr("Existing values:"));
    162         c.fill = GridBagConstraints.HORIZONTAL;
    163         c.gridx = 5;
    164         c.gridy = 0;
    165         c.weightx = 0;
    166         c.gridwidth = 1;
    167         c.insets = new Insets(0, 5, 10, 5);
    168         editPanel.add(labelExistingValues, c);
     159        editPanel.add(labelExistingValues, GBC.std().span(3).weight(0, 0).grid(5, 0).insets(0, 5, 10, 5));
    169160
    170161        JButton getAllButton = new JButton("<<");
     
    172163        getAllButton.setToolTipText(tr("Accept all existing values"));
    173164        getAllButton.addActionListener(actionEvent -> acceptAllExistingValues());
    174         GridBagConstraints buttonContstraints = new GridBagConstraints();
    175         buttonContstraints.fill = GridBagConstraints.NONE;
    176         buttonContstraints.gridx = 6;
    177         buttonContstraints.gridy = 0;
    178         buttonContstraints.weightx = 0;
    179         buttonContstraints.gridwidth = 1;
    180         buttonContstraints.anchor = GridBagConstraints.EAST;
    181         buttonContstraints.insets = new Insets(0, 5, 10, 5);
    182         editPanel.add(getAllButton, buttonContstraints);
     165        editPanel.add(getAllButton, GBC.eol().grid(7, 0).anchor(GridBagConstraints.EAST).insets(0, 5, 10, 5));
     166
     167        GBC columnOne = GBC.std().span(3).insets(5, 5, 0, 5);
     168        GBC columnTwo = GBC.std().span(1).weight(1, 0).fill(GBC.HORIZONTAL).insets(5, 5, 0, 5);
     169        GBC columnThree = GBC.std().insets(5, 5, 0, 5);
     170        GBC columnFour = GBC.eol().weight(1, 0).fill(GBC.HORIZONTAL).insets(5, 5, 0, 5);
    183171
    184172        // building
    185         buildingEnabled = new JCheckBox(TAG_BUILDING);
    186         buildingEnabled.setFocusable(false);
    187         buildingEnabled.setSelected(dto.isSaveBuilding());
    188         buildingEnabled.setToolTipText(APPLY_CHANGES);
    189         c.fill = GridBagConstraints.HORIZONTAL;
    190         c.gridx = 0;
    191         c.gridy = 1;
    192         c.weightx = 0;
    193         c.gridwidth = 3;
    194         c.insets = new Insets(5, 5, 0, 5);
    195         editPanel.add(buildingEnabled, c);
     173        buildingEnabled = generateCheckbox(TAG_BUILDING, dto.isSaveBuilding());
     174        editPanel.add(buildingEnabled, columnOne);
    196175
    197176        Arrays.sort(BUILDING_STRINGS);
    198         building = new JComboBox<>(BUILDING_STRINGS);
     177        building = new JosmComboBox<>(BUILDING_STRINGS);
    199178        building.setSelectedItem(dto.getBuilding());
    200179        building.setMaximumRowCount(50);
    201         c.gridx = 3;
    202         c.gridy = 1;
    203         c.weightx = 1;
    204         c.gridwidth = 1;
    205         c.insets = new Insets(5, 5, 0, 5);
    206         editPanel.add(building, c);
    207 
    208         JButton getBuildingButton = new JButton("<");
    209         getBuildingButton.setPreferredSize(new Dimension(45, 24));
    210         getBuildingButton.setToolTipText(tr("Accept existing value"));
    211         getBuildingButton.addActionListener(actionEvent -> building.setSelectedItem(selection.get(TAG_BUILDING)));
    212         c.fill = GridBagConstraints.NONE;
    213         c.gridx = 4;
    214         c.gridy = 1;
    215         c.weightx = 0;
    216         c.gridwidth = 1;
    217         c.insets = new Insets(5, 5, 0, 5);
    218         editPanel.add(getBuildingButton, c);
    219 
    220         JTextField existingBuilding = new JTextField();
    221         existingBuilding.setText(selection.get(TAG_BUILDING));
    222         existingBuilding.setPreferredSize(new Dimension(200, 24));
    223         existingBuilding.setEditable(false);
    224         c.fill = GridBagConstraints.HORIZONTAL;
    225         c.gridx = 5;
    226         c.gridy = 1;
    227         c.weightx = 1;
    228         c.gridwidth = 2;
    229         c.insets = new Insets(5, 5, 0, 5);
    230         editPanel.add(existingBuilding, c);
     180        editPanel.add(building, columnTwo);
     181
     182        editPanel.add(generateAcceptButton(actionEvent -> building.setSelectedItem(selection.get(TAG_BUILDING))), columnThree);
     183        editPanel.add(generateTextField(selection.get(TAG_BUILDING)), columnFour);
    231184
    232185        // source
    233         sourceEnabled = new JCheckBox(TAG_SOURCE);
    234         sourceEnabled.setFocusable(false);
    235         sourceEnabled.setSelected(dto.isSaveBuilding());
    236         sourceEnabled.setToolTipText(APPLY_CHANGES);
    237         c.fill = GridBagConstraints.HORIZONTAL;
    238         c.gridx = 0;
    239         c.gridy = 2;
    240         c.weightx = 0;
    241         c.gridwidth = 3;
    242         c.insets = new Insets(5, 5, 0, 5);
    243         editPanel.add(sourceEnabled, c);
    244 
    245         source = new AutoCompComboBox<>();
    246         source.getModel().addAllElements(acm.getTagValues(TAG_SOURCE));
    247         source.setPreferredSize(new Dimension(200, 24));
    248         source.setEditable(true);
    249         source.setSelectedItem(dto.getSource());
    250         c.gridx = 3;
    251         c.gridy = 2;
    252         c.weightx = 1;
    253         c.gridwidth = 1;
    254         c.insets = new Insets(5, 5, 0, 5);
    255         editPanel.add(source, c);
    256 
    257         JButton getSourceButton = new JButton("<");
    258         getSourceButton.setPreferredSize(new Dimension(45, 24));
    259         getSourceButton.setToolTipText(tr("Accept existing value"));
    260         getSourceButton.addActionListener(actionEvent -> source.setSelectedItem(selection.get(TAG_SOURCE)));
    261         c.fill = GridBagConstraints.NONE;
    262         c.gridx = 4;
    263         c.gridy = 2;
    264         c.weightx = 0;
    265         c.gridwidth = 1;
    266         c.insets = new Insets(5, 5, 0, 5);
    267         editPanel.add(getSourceButton, c);
    268 
    269         JTextField existingSource = new JTextField();
    270         existingSource.setText(selection.get(TAG_SOURCE));
    271         existingSource.setPreferredSize(new Dimension(200, 24));
    272         existingSource.setEditable(false);
    273         c.fill = GridBagConstraints.HORIZONTAL;
    274         c.gridx = 5;
    275         c.gridy = 2;
    276         c.weightx = 1;
    277         c.gridwidth = 2;
    278         c.insets = new Insets(5, 5, 0, 5);
    279         editPanel.add(existingSource, c);
     186        sourceEnabled = generateCheckbox(TAG_SOURCE, dto.isSaveSource());
     187        editPanel.add(sourceEnabled, columnOne);
     188
     189        source = generateAutoCompTextField(acm.getTagValues(TAG_SOURCE), dto.getSource());
     190        editPanel.add(source, columnTwo);
     191
     192        editPanel.add(generateAcceptButton(actionEvent -> source.setSelectedItem(selection.get(TAG_SOURCE))), columnThree);
     193        editPanel.add(generateTextField(selection.get(TAG_SOURCE)), columnFour);
    280194
    281195        // country
    282         countryEnabled = new JCheckBox(TAG_ADDR_COUNTRY);
    283         countryEnabled.setFocusable(false);
    284         countryEnabled.setSelected(dto.isSaveCountry());
    285         countryEnabled.setToolTipText(APPLY_CHANGES);
    286         c = new GridBagConstraints();
    287         c.fill = GridBagConstraints.HORIZONTAL;
    288         c.gridx = 0;
    289         c.gridy = 3;
    290         c.weightx = 0;
    291         c.gridwidth = 3;
    292         c.insets = new Insets(5, 5, 0, 5);
    293         editPanel.add(countryEnabled, c);
    294 
    295         country = new AutoCompComboBox<>();
    296         country.getModel().addAllElements(acm.getTagValues(TAG_ADDR_COUNTRY));
    297         country.setPreferredSize(new Dimension(200, 24));
    298         country.setEditable(true);
    299         country.setSelectedItem(dto.getCountry());
    300         c.fill = GridBagConstraints.HORIZONTAL;
    301         c.gridx = 3;
    302         c.gridy = 3;
    303         c.weightx = 1;
    304         c.gridwidth = 1;
    305         c.insets = new Insets(5, 5, 0, 5);
    306         editPanel.add(country, c);
    307 
    308         JButton getCountryButton = new JButton("<");
    309         getCountryButton.setPreferredSize(new Dimension(45, 24));
    310         getCountryButton.setToolTipText(tr("Accept existing value"));
    311         getCountryButton.addActionListener(actionEvent -> country.setSelectedItem(selection.get(TAG_ADDR_COUNTRY)));
    312         c.fill = GridBagConstraints.NONE;
    313         c.gridx = 4;
    314         c.gridy = 3;
    315         c.weightx = 0;
    316         c.gridwidth = 1;
    317         c.insets = new Insets(5, 5, 0, 5);
    318         editPanel.add(getCountryButton, c);
    319 
    320         JTextField existingCountry = new JTextField();
    321         existingCountry.setText(selection.get(TAG_ADDR_COUNTRY));
    322         existingCountry.setPreferredSize(new Dimension(200, 24));
    323         existingCountry.setEditable(false);
    324         c.fill = GridBagConstraints.HORIZONTAL;
    325         c.gridx = 5;
    326         c.gridy = 3;
    327         c.weightx = 1;
    328         c.gridwidth = 2;
    329         c.insets = new Insets(5, 5, 0, 5);
    330         editPanel.add(existingCountry, c);
     196        countryEnabled = generateCheckbox(TAG_ADDR_COUNTRY, dto.isSaveCountry());
     197        editPanel.add(countryEnabled, columnOne);
     198
     199        country = generateAutoCompTextField(acm.getTagValues(TAG_ADDR_COUNTRY), dto.getCountry());
     200        editPanel.add(country, columnTwo);
     201
     202        editPanel.add(generateAcceptButton(actionEvent -> country.setSelectedItem(selection.get(TAG_ADDR_COUNTRY))), columnThree);
     203        editPanel.add(generateTextField(selection.get(TAG_ADDR_COUNTRY)), columnFour);
    331204
    332205        // state
    333         stateEnabled = new JCheckBox(TAG_ADDR_STATE);
    334         stateEnabled.setFocusable(false);
    335         stateEnabled.setSelected(dto.isSaveState());
    336         stateEnabled.setToolTipText(APPLY_CHANGES);
    337         c.fill = GridBagConstraints.HORIZONTAL;
    338         c.gridx = 0;
    339         c.gridy = 4;
    340         c.weightx = 0;
    341         c.gridwidth = 3;
    342         c.insets = new Insets(5, 5, 0, 5);
    343         editPanel.add(stateEnabled, c);
    344 
    345         state = new AutoCompComboBox<>();
    346         state.getModel().addAllElements(acm.getTagValues(TAG_ADDR_STATE));
    347         state.setPreferredSize(new Dimension(200, 24));
    348         state.setEditable(true);
    349         state.setSelectedItem(dto.getState());
    350         c.fill = GridBagConstraints.HORIZONTAL;
    351         c.gridx = 3;
    352         c.gridy = 4;
    353         c.weightx = 1;
    354         c.gridwidth = 1;
    355         c.insets = new Insets(5, 5, 0, 5);
    356         editPanel.add(state, c);
    357 
    358         JButton getStateButton = new JButton("<");
    359         getStateButton.setPreferredSize(new Dimension(45, 24));
    360         getStateButton.setToolTipText(tr("Accept existing value"));
    361         getStateButton.addActionListener(actionEvent -> state.setSelectedItem(selection.get(TAG_ADDR_STATE)));
    362         c.fill = GridBagConstraints.NONE;
    363         c.gridx = 4;
    364         c.gridy = 4;
    365         c.weightx = 0;
    366         c.gridwidth = 1;
    367         c.insets = new Insets(5, 5, 0, 5);
    368         editPanel.add(getStateButton, c);
    369 
    370         JTextField existingState= new JTextField();
    371         existingState.setText(selection.get(TAG_ADDR_STATE));
    372         existingState.setPreferredSize(new Dimension(200, 24));
    373         existingState.setEditable(false);
    374         c.fill = GridBagConstraints.HORIZONTAL;
    375         c.gridx = 5;
    376         c.gridy = 4;
    377         c.weightx = 1;
    378         c.gridwidth = 2;
    379         c.insets = new Insets(5, 5, 0, 5);
    380         editPanel.add(existingState, c);
     206        stateEnabled = generateCheckbox(TAG_ADDR_STATE, dto.isSaveState());
     207        editPanel.add(stateEnabled, columnOne);
     208
     209        stateTag = generateAutoCompTextField(acm.getTagValues(TAG_ADDR_STATE), dto.getState());
     210        editPanel.add(stateTag, columnTwo);
     211
     212        editPanel.add(generateAcceptButton(actionEvent -> stateTag.setSelectedItem(selection.get(TAG_ADDR_STATE))), columnThree);
     213        editPanel.add(generateTextField(selection.get(TAG_ADDR_STATE)), columnFour);
    381214
    382215        // suburb
    383         suburbEnabled = new JCheckBox(TAG_ADDR_SUBURB);
    384         suburbEnabled.setFocusable(false);
    385         suburbEnabled.setSelected(dto.isSaveSuburb());
    386         suburbEnabled.setToolTipText(APPLY_CHANGES);
    387         c.fill = GridBagConstraints.HORIZONTAL;
    388         c.gridx = 0;
    389         c.gridy = 5;
    390         c.weightx = 0;
    391         c.gridwidth = 3;
    392         c.insets = new Insets(5, 5, 0, 5);
    393         editPanel.add(suburbEnabled, c);
    394 
    395         suburb = new AutoCompComboBox<>();
    396         suburb.getModel().addAllElements(acm.getTagValues(TAG_ADDR_SUBURB));
    397         suburb.setPreferredSize(new Dimension(200, 24));
    398         suburb.setEditable(true);
    399         suburb.setSelectedItem(dto.getSuburb());
    400         c.fill = GridBagConstraints.HORIZONTAL;
    401         c.gridx = 3;
    402         c.gridy = 5;
    403         c.weightx = 1;
    404         c.gridwidth = 1;
    405         c.insets = new Insets(5, 5, 0, 5);
    406         editPanel.add(suburb, c);
    407 
    408         JButton getSuburbButton = new JButton("<");
    409         getSuburbButton.setPreferredSize(new Dimension(45, 24));
    410         getSuburbButton.setToolTipText(tr("Accept existing value"));
    411         getSuburbButton.addActionListener(actionEvent -> suburb.setSelectedItem(selection.get(TAG_ADDR_SUBURB)));
    412         c.fill = GridBagConstraints.NONE;
    413         c.gridx = 4;
    414         c.gridy = 5;
    415         c.weightx = 0;
    416         c.gridwidth = 1;
    417         c.insets = new Insets(5, 5, 0, 5);
    418         editPanel.add(getSuburbButton, c);
    419 
    420         JTextField existingSuburb = new JTextField();
    421         existingSuburb.setText(selection.get(TAG_ADDR_SUBURB));
    422         existingSuburb.setPreferredSize(new Dimension(200, 24));
    423         existingSuburb.setEditable(false);
    424         c.fill = GridBagConstraints.HORIZONTAL;
    425         c.gridx = 5;
    426         c.gridy = 5;
    427         c.weightx = 1;
    428         c.gridwidth = 2;
    429         c.insets = new Insets(5, 5, 0, 5);
    430         editPanel.add(existingSuburb, c);
     216        suburbEnabled = generateCheckbox(TAG_ADDR_SUBURB, dto.isSaveSuburb());
     217        editPanel.add(suburbEnabled, columnOne);
     218
     219        suburb = generateAutoCompTextField(acm.getTagValues(TAG_ADDR_SUBURB), dto.getSuburb());
     220        editPanel.add(suburb, columnTwo);
     221
     222        editPanel.add(generateAcceptButton(actionEvent -> suburb.setSelectedItem(selection.get(TAG_ADDR_SUBURB))), columnThree);
     223        editPanel.add(generateTextField(selection.get(TAG_ADDR_SUBURB)), columnFour);
    431224
    432225        // city
    433         cityEnabled = new JCheckBox(TAG_ADDR_CITY);
    434         cityEnabled.setFocusable(false);
    435         cityEnabled.setSelected(dto.isSaveCity());
    436         cityEnabled.setToolTipText(APPLY_CHANGES);
    437         c.fill = GridBagConstraints.HORIZONTAL;
    438         c.gridx = 0;
    439         c.gridy = 6;
    440         c.weightx = 0;
    441         c.gridwidth = 3;
    442         c.insets = new Insets(5, 5, 0, 5);
    443         editPanel.add(cityEnabled, c);
    444 
    445         city = new AutoCompComboBox<>();
    446         city.getModel().addAllElements(acm.getTagValues(TAG_ADDR_CITY));
    447         city.setPreferredSize(new Dimension(200, 24));
    448         city.setEditable(true);
    449         city.setSelectedItem(dto.getCity());
    450         c.fill = GridBagConstraints.HORIZONTAL;
    451         c.gridx = 3;
    452         c.gridy = 6;
    453         c.weightx = 1;
    454         c.gridwidth = 1;
    455         c.insets = new Insets(5, 5, 0, 5);
    456         editPanel.add(city, c);
    457 
    458         JButton getCityButton = new JButton("<");
    459         getCityButton.setPreferredSize(new Dimension(45, 24));
    460         getCityButton.setToolTipText(tr("Accept existing value"));
    461         getCityButton.addActionListener(actionEvent -> city.setSelectedItem(selection.get(TAG_ADDR_CITY)));
    462         c.fill = GridBagConstraints.NONE;
    463         c.gridx = 4;
    464         c.gridy = 6;
    465         c.weightx = 0;
    466         c.gridwidth = 1;
    467         c.insets = new Insets(5, 5, 0, 5);
    468         editPanel.add(getCityButton, c);
    469 
    470         JTextField existingCity = new JTextField();
    471         existingCity.setText(selection.get(TAG_ADDR_CITY));
    472         existingCity.setPreferredSize(new Dimension(200, 24));
    473         existingCity.setEditable(false);
    474         c.fill = GridBagConstraints.HORIZONTAL;
    475         c.gridx = 5;
    476         c.gridy = 6;
    477         c.weightx = 1;
    478         c.gridwidth = 2;
    479         c.insets = new Insets(5, 5, 0, 5);
    480         editPanel.add(existingCity, c);
     226        cityEnabled = generateCheckbox(TAG_ADDR_CITY, dto.isSaveCity());
     227        editPanel.add(cityEnabled, columnOne);
     228
     229        city = generateAutoCompTextField(acm.getTagValues(TAG_ADDR_CITY), dto.getCity());
     230        editPanel.add(city, columnTwo);
     231
     232        editPanel.add(generateAcceptButton(actionEvent -> city.setSelectedItem(selection.get(TAG_ADDR_CITY))), columnThree);
     233        editPanel.add(generateTextField(selection.get(TAG_ADDR_CITY)), columnFour);
    481234
    482235        // postcode
    483         zipEnabled = new JCheckBox(TAG_ADDR_POSTCODE);
    484         zipEnabled.setFocusable(false);
    485         zipEnabled.setSelected(dto.isSavePostcode());
    486         zipEnabled.setToolTipText(APPLY_CHANGES);
    487         c.fill = GridBagConstraints.HORIZONTAL;
    488         c.gridx = 0;
    489         c.gridy = 7;
    490         c.weightx = 0;
    491         c.gridwidth = 3;
    492         c.insets = new Insets(5, 5, 0, 5);
    493         editPanel.add(zipEnabled, c);
    494 
    495         postcode = new AutoCompComboBox<>();
    496         postcode.getModel().addAllElements(acm.getTagValues(TAG_ADDR_POSTCODE));
    497         postcode.setPreferredSize(new Dimension(200, 24));
    498         postcode.setEditable(true);
    499         postcode.setSelectedItem(dto.getPostcode());
    500         c.fill = GridBagConstraints.HORIZONTAL;
    501         c.gridx = 3;
    502         c.gridy = 7;
    503         c.weightx = 1;
    504         c.gridwidth = 1;
    505         c.insets = new Insets(5, 5, 0, 5);
    506         editPanel.add(postcode, c);
    507 
    508         JButton getPostcodeButton = new JButton("<");
    509         getPostcodeButton.setPreferredSize(new Dimension(45, 24));
    510         getPostcodeButton.setToolTipText(tr("Accept existing value"));
    511         getPostcodeButton.addActionListener(actionEvent -> postcode.setSelectedItem(selection.get(TAG_ADDR_POSTCODE)));
    512         c.fill = GridBagConstraints.NONE;
    513         c.gridx = 4;
    514         c.gridy = 7;
    515         c.weightx = 0;
    516         c.gridwidth = 1;
    517         c.insets = new Insets(5, 5, 0, 5);
    518         editPanel.add(getPostcodeButton, c);
    519 
    520         JTextField existingPostcode = new JTextField();
    521         existingPostcode.setText(selection.get(TAG_ADDR_POSTCODE));
    522         existingPostcode.setPreferredSize(new Dimension(200, 24));
    523         existingPostcode.setEditable(false);
    524         c.fill = GridBagConstraints.HORIZONTAL;
    525         c.gridx = 5;
    526         c.gridy = 7;
    527         c.weightx = 1;
    528         c.gridwidth = 2;
    529         c.insets = new Insets(5, 5, 0, 5);
    530         editPanel.add(existingPostcode, c);
     236        zipEnabled = generateCheckbox(TAG_ADDR_POSTCODE, dto.isSavePostcode());
     237        editPanel.add(zipEnabled, columnOne);
     238
     239        postcode = generateAutoCompTextField(acm.getTagValues(TAG_ADDR_POSTCODE), dto.getPostcode());
     240        editPanel.add(postcode, columnTwo);
     241
     242        editPanel.add(generateAcceptButton(actionEvent -> postcode.setSelectedItem(selection.get(TAG_ADDR_POSTCODE))), columnThree);
     243        editPanel.add(generateTextField(selection.get(TAG_ADDR_POSTCODE)), columnFour);
    531244
    532245        // street
    533         streetEnabled = new JCheckBox();
    534         streetEnabled.setFocusable(false);
    535         streetEnabled.setSelected(dto.isSaveStreet());
    536         streetEnabled.setToolTipText(APPLY_CHANGES);
    537         c.fill = GridBagConstraints.HORIZONTAL;
    538         c.gridx = 0;
    539         c.gridy = 8;
    540         c.weightx = 0;
    541         c.gridwidth = 1;
    542         c.insets = new Insets(5, 5, 0, 5);
    543         editPanel.add(streetEnabled, c);
     246        streetEnabled = generateCheckbox(null, dto.isSaveStreet());
     247        editPanel.add(streetEnabled, GBC.std().insets(5, 5, 0, 5));
    544248
    545249        streetRadio = new JRadioButton(TAG_ADDR_STREET);
     
    547251        streetRadio.setSelected(dto.isTagStreet());
    548252        streetRadio.addItemListener(new RadioChangeListener());
    549         c.fill = GridBagConstraints.HORIZONTAL;
    550         c.gridx = 1;
    551         c.gridy = 8;
    552         c.weightx = 0;
    553         c.gridwidth = 1;
    554         c.insets = new Insets(5, 5, 0, 5);
    555         editPanel.add(streetRadio, c);
     253        editPanel.add(streetRadio, GBC.std().weight(0, 0).insets(5, 5, 0, 5));
    556254
    557255        placeRadio = new JRadioButton("addr:place");
     
    559257        placeRadio.setSelected(!dto.isTagStreet());
    560258        placeRadio.addItemListener(new RadioChangeListener());
    561         c.fill = GridBagConstraints.HORIZONTAL;
    562         c.gridx = 2;
    563         c.gridy = 8;
    564         c.weightx = 0;
    565         c.gridwidth = 1;
    566         c.insets = new Insets(5, 5, 0, 5);
    567         editPanel.add(placeRadio, c);
     259        editPanel.add(placeRadio, GBC.std().insets(5, 5, 0, 5));
    568260
    569261        ButtonGroup g = new ButtonGroup();
     
    571263        g.add(placeRadio);
    572264
    573         street = new AutoCompComboBox<>();
    574265        if (dto.isTagStreet()) {
    575             street.getModel().addAllElements(getPossibleStreets());
     266            street = generateAutoCompTextField(getPossibleStreets(), dto.getStreet());
    576267        } else {
    577             street.getModel().addAllElements(acm.getTagValues(TAG_ADDR_PLACE));
    578         }
    579         street.setPreferredSize(new Dimension(200, 24));
    580         street.setEditable(true);
    581         street.setSelectedItem(dto.getStreet());
    582         c.fill = GridBagConstraints.HORIZONTAL;
    583         c.gridx = 3;
    584         c.gridy = 8;
    585         c.weightx = 1;
    586         c.gridwidth = 1;
    587         c.insets = new Insets(5, 5, 0, 5);
    588         editPanel.add(street, c);
    589 
    590         JButton getStreetButton = new JButton("<");
    591         getStreetButton.setPreferredSize(new Dimension(45, 24));
    592         getStreetButton.setToolTipText(tr("Accept existing value"));
    593         getStreetButton.addActionListener(actionEvent -> updateStreetOrPlaceValues());
    594         c.fill = GridBagConstraints.NONE;
    595         c.gridx = 4;
    596         c.gridy = 8;
    597         c.weightx = 0;
    598         c.gridwidth = 1;
    599         c.insets = new Insets(5, 5, 0, 5);
    600         editPanel.add(getStreetButton, c);
    601 
    602         JTextField streetOrPlace = new JTextField();
    603         streetOrPlace.setText(getStreetOrPlaceTag());
     268            street = generateAutoCompTextField(acm.getTagValues(TAG_ADDR_PLACE), dto.getStreet());
     269        }
     270        editPanel.add(street, columnTwo);
     271
     272        editPanel.add(generateAcceptButton(actionEvent -> updateStreetOrPlaceValues()), columnThree);
     273
     274        JTextField streetOrPlace = generateTextField(getStreetOrPlaceTag());
    604275        streetOrPlace.setPreferredSize(new Dimension(50, 24));
    605         streetOrPlace.setEditable(false);
    606         c.fill = GridBagConstraints.HORIZONTAL;
    607         c.gridx = 5;
    608         c.gridy = 8;
    609         c.weightx = 0;
    610         c.gridwidth = 1;
    611         c.insets = new Insets(5, 5, 0, 5);
    612         editPanel.add(streetOrPlace, c);
    613 
    614         JTextField existingStreet = new JTextField();
    615         existingStreet.setText(getStreetOrPlaceValue());
     276        editPanel.add(streetOrPlace, GBC.std().weight(0, 0).fill(GridBagConstraints.HORIZONTAL).insets(5, 5, 0, 5));
     277
     278        JTextField existingStreet = generateTextField(getStreetOrPlaceValue());
    616279        existingStreet.setPreferredSize(new Dimension(100, 24));
    617         existingStreet.setEditable(false);
    618         c.fill = GridBagConstraints.HORIZONTAL;
    619         c.gridx = 6;
    620         c.gridy = 8;
    621         c.weightx = 1;
    622         c.gridwidth = 1;
    623         c.insets = new Insets(5, 5, 0, 5);
    624         editPanel.add(existingStreet, c);
    625 
    626 
     280        editPanel.add(existingStreet, GBC.eol().weight(1, 0).insets(5, 5, 0, 5).fill(GridBagConstraints.HORIZONTAL));
    627281        // housenumber
    628         housenumberEnabled = new JCheckBox(TAG_ADDR_HOUSENUMBER);
    629         housenumberEnabled.setFocusable(false);
    630         housenumberEnabled.setSelected(dto.isSaveHousenumber());
    631         housenumberEnabled.setToolTipText(APPLY_CHANGES);
    632         c.fill = GridBagConstraints.HORIZONTAL;
    633         c.gridx = 0;
    634         c.gridy = 9;
    635         c.weightx = 0;
    636         c.gridwidth = 3;
    637         c.insets = new Insets(5, 5, 0, 5);
    638         editPanel.add(housenumberEnabled, c);
    639 
    640         housnumber = new JTextField();
    641         housnumber.setPreferredSize(new Dimension(200, 24));
    642 
    643         String number = HouseNumberHelper.incrementHouseNumber(dto.getHousenumber(), dto.getHousenumberChangeValue());
    644         if (number != null) {
    645             housnumber.setText(number);
    646         }
    647 
    648         c.fill = GridBagConstraints.HORIZONTAL;
    649         c.gridx = 3;
    650         c.gridy = 9;
    651         c.weightx = 1;
    652         c.gridwidth = 1;
    653         c.insets = new Insets(5, 5, 0, 5);
    654         editPanel.add(housnumber, c);
    655 
    656         JButton getHousenumberButton = new JButton("<");
    657         getHousenumberButton.setPreferredSize(new Dimension(45, 24));
    658         getHousenumberButton.setToolTipText(tr("Accept existing value"));
    659         getHousenumberButton.addActionListener(actionEvent -> housnumber.setText(selection.get(TAG_ADDR_HOUSENUMBER)));
    660         c.fill = GridBagConstraints.NONE;
    661         c.gridx = 4;
    662         c.gridy = 9;
    663         c.weightx = 0;
    664         c.gridwidth = 1;
    665         c.insets = new Insets(5, 5, 0, 5);
    666         editPanel.add(getHousenumberButton, c);
    667 
    668         JTextField existingHousenumber = new JTextField();
    669         existingHousenumber.setText(selection.get(TAG_ADDR_HOUSENUMBER));
    670         existingHousenumber.setPreferredSize(new Dimension(200, 24));
    671         existingHousenumber.setEditable(false);
    672         c.fill = GridBagConstraints.HORIZONTAL;
    673         c.gridx = 5;
    674         c.gridy = 9;
    675         c.weightx = 1;
    676         c.gridwidth = 2;
    677         c.insets = new Insets(5, 5, 0, 5);
    678         editPanel.add(existingHousenumber, c);
     282        housenumberEnabled = generateCheckbox(TAG_ADDR_HOUSENUMBER, dto.isSaveHousenumber());
     283        editPanel.add(housenumberEnabled, columnOne);
     284
     285        housenumber = generateTextField(HouseNumberHelper.incrementHouseNumber(dto.getHousenumber(), dto.getHousenumberChangeValue()));
     286        housenumber.setEditable(true);
     287
     288        editPanel.add(housenumber, columnTwo);
     289
     290        editPanel.add(generateAcceptButton(actionEvent -> housenumber.setText(selection.get(TAG_ADDR_HOUSENUMBER))), columnThree);
     291        editPanel.add(generateTextField(selection.get(TAG_ADDR_HOUSENUMBER)), columnFour);
    679292
    680293        // increment
    681294        JLabel seqLabel = new JLabel(tr("House number increment:"));
    682         c.fill = GridBagConstraints.HORIZONTAL;
    683         c.gridx = 0;
    684         c.gridy = 10;
    685         c.weightx = 0;
    686         c.gridwidth = 3;
    687         c.insets = new Insets(5, 5, 0, 5);
    688         editPanel.add(seqLabel, c);
     295        editPanel.add(seqLabel, columnOne);
    689296
    690297        housenumberChangeSequence = new JSlider(JSlider.HORIZONTAL, FPS_MIN, FPS_MAX, dto.getHousenumberChangeValue());
     
    694301        housenumberChangeSequence.setPaintLabels(true);
    695302        housenumberChangeSequence.setSnapToTicks(true);
    696         c.gridx = 3;
    697         c.gridy = 10;
    698         c.weightx = 1;
    699         c.gridwidth = 4;
    700         c.insets = new Insets(20, 5, 10, 5);
    701         editPanel.add(housenumberChangeSequence, c);
     303        editPanel.add(housenumberChangeSequence, GBC.eol().weight(1, 0).insets(20, 5, 10, 5).fill(GridBagConstraints.HORIZONTAL));
    702304
    703305        return editPanel;
     306    }
     307
     308    /**
     309     * Generate a checkbox for applying changes
     310     * @param text The text to show
     311     * @param enabled Whether or not the checkbox is enabled
     312     * @return The checkbox to add
     313     */
     314    private static JCheckBox generateCheckbox(String text, boolean enabled) {
     315        JCheckBox checkBox = new JCheckBox(text, enabled);
     316        checkBox.setFocusable(false);
     317        checkBox.setToolTipText(APPLY_CHANGES);
     318        return checkBox;
     319    }
     320
     321    /**
     322     * Generate an accept button
     323     * @param listener The listener to call when the user "accepts" a value
     324     * @return The button to add
     325     */
     326    private static JButton generateAcceptButton(ActionListener listener) {
     327        JButton button = new JButton("<");
     328        button.setPreferredSize(new Dimension(45, 24));
     329        button.setToolTipText(tr("Accept existing value"));
     330        button.addActionListener(listener);
     331        return button;
     332    }
     333
     334    private static AutoCompComboBox<AutoCompletionItem> generateAutoCompTextField(Collection<AutoCompletionItem> tagValues, String selected) {
     335        AutoCompComboBox<AutoCompletionItem> comboBox = new AutoCompComboBox<>();
     336        comboBox.getModel().addAllElements(tagValues);
     337        comboBox.setPreferredSize(new Dimension(200, 24));
     338        comboBox.setEditable(true);
     339        comboBox.setSelectedItem(selected);
     340        return comboBox;
     341    }
     342
     343    /**
     344     * Generate a non-editable text field
     345     * @param startingText The text to show
     346     * @return The text field (200x24)
     347     */
     348    private static JosmTextField generateTextField(String startingText) {
     349        JosmTextField textField = new JosmTextField();
     350        textField.setText(startingText);
     351        textField.setPreferredSize(new Dimension(200, 24));
     352        textField.setEditable(false);
     353        return textField;
    704354    }
    705355
     
    709359        source.setSelectedItem(selection.get(TAG_SOURCE));
    710360        country.setSelectedItem(selection.get(TAG_ADDR_COUNTRY));
    711         state.setSelectedItem(selection.get(TAG_ADDR_STATE));
     361        stateTag.setSelectedItem(selection.get(TAG_ADDR_STATE));
    712362        suburb.setSelectedItem(selection.get(TAG_ADDR_SUBURB));
    713363        city.setSelectedItem(selection.get(TAG_ADDR_CITY));
    714364        postcode.setSelectedItem(selection.get(TAG_ADDR_POSTCODE));
    715         housnumber.setText(selection.get(TAG_ADDR_HOUSENUMBER));
     365        housenumber.setText(selection.get(TAG_ADDR_HOUSENUMBER));
    716366    }
    717367
     
    720370            placeRadio.setSelected(true);
    721371            street.setSelectedItem(selection.get(TAG_ADDR_PLACE));
    722         }else {
     372        } else {
    723373            streetRadio.setSelected(true);
    724374            street.setSelectedItem(selection.get(TAG_ADDR_STREET));
     
    765415            dto.setCity(getAutoCompletingComboBoxValue(city));
    766416            dto.setCountry(getAutoCompletingComboBoxValue(country));
    767             dto.setHousenumber(housnumber.getText());
     417            dto.setHousenumber(housenumber.getText());
    768418            dto.setPostcode(getAutoCompletingComboBoxValue(postcode));
    769419            dto.setStreet(getAutoCompletingComboBoxValue(street));
    770             dto.setState(getAutoCompletingComboBoxValue(state));
     420            dto.setState(getAutoCompletingComboBoxValue(stateTag));
    771421            dto.setSuburb(getAutoCompletingComboBoxValue(suburb));
    772422            dto.setHousenumberChangeValue(housenumberChangeSequence.getValue());
     
    778428    }
    779429
    780     private String getAutoCompletingComboBoxValue(AutoCompComboBox<AutoCompletionItem> box) {
     430    private static String getAutoCompletingComboBoxValue(AutoCompComboBox<AutoCompletionItem> box) {
    781431        Object item = box.getSelectedItem();
    782432        if (item != null) {
     
    794444
    795445    protected void saveDto(Dto dto) {
    796         File path = pluginDir;
    797446        File fileName = new File(pluginDir + TagDialog.TEMPLATE_DATA);
    798447
    799448        try {
    800             path.mkdirs();
    801             try (
    802                 FileOutputStream file = new FileOutputStream(fileName);
    803                 ObjectOutputStream o = new ObjectOutputStream(file)
    804             ) {
    805                 o.writeObject(dto);
    806             }
    807         } catch (Exception ex) {
    808             LOGGER.log(Level.SEVERE, ex.getMessage());
    809             fileName.delete();
     449            if (pluginDir.mkdirs()) {
     450                try (
     451                        FileOutputStream file = new FileOutputStream(fileName);
     452                        ObjectOutputStream o = new ObjectOutputStream(file)
     453                ) {
     454                    o.writeObject(dto);
     455                }
     456            }
     457        } catch (IOException ex) {
     458            Logging.error(ex);
     459            if (!fileName.delete()) {
     460                Logging.trace("TagDialog: {0} not deleted", fileName);
     461            }
    810462        }
    811463    }
     
    816468        if (dto.isSaveBuilding()) {
    817469            String value = selection.get(TagDialog.TAG_BUILDING);
    818             if (value == null || (value != null && !value.equals(dto.getBuilding()))) {
     470            if (value == null || !value.equals(dto.getBuilding())) {
    819471                ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_BUILDING, dto.getBuilding());
    820472                commands.add(command);
     
    824476        if (dto.isSaveSource()) {
    825477            String value = selection.get(TagDialog.TAG_SOURCE);
    826             if (value == null || (value != null && !value.equals(dto.getSource()))) {
     478            if (value == null || !value.equals(dto.getSource())) {
    827479                ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_SOURCE, dto.getSource());
    828480                commands.add(command);
     
    832484        if (dto.isSaveCity()) {
    833485            String value = selection.get(TagDialog.TAG_ADDR_CITY);
    834             if (value == null || (value != null && !value.equals(dto.getCity()))) {
     486            if (value == null || !value.equals(dto.getCity())) {
    835487                ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_CITY, dto.getCity());
    836488                commands.add(command);
     
    838490        }
    839491
    840         if (dto.isSaveCountry())  {
     492        if (dto.isSaveCountry()) {
    841493            String value = selection.get(TagDialog.TAG_ADDR_COUNTRY);
    842             if (value == null || (value != null && !value.equals(dto.getCountry()))) {
     494            if (value == null || !value.equals(dto.getCountry())) {
    843495                ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_COUNTRY, dto.getCountry());
    844496                commands.add(command);
     
    846498        }
    847499
    848         if (dto.isSaveSuburb())  {
     500        if (dto.isSaveSuburb()) {
    849501            String value = selection.get(TagDialog.TAG_ADDR_SUBURB);
    850             if (value == null || (value != null && !value.equals(dto.getSuburb()))) {
     502            if (value == null || !value.equals(dto.getSuburb())) {
    851503                ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_SUBURB, dto.getSuburb());
    852504                commands.add(command);
     
    854506        }
    855507
    856         if (dto.isSaveHousenumber())  {
     508        if (dto.isSaveHousenumber()) {
    857509            String value = selection.get(TagDialog.TAG_ADDR_HOUSENUMBER);
    858             if (value == null || (value != null && !value.equals(dto.getHousenumber()))) {
     510            if (value == null || !value.equals(dto.getHousenumber())) {
    859511                ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_HOUSENUMBER, dto.getHousenumber());
    860512                commands.add(command);
     
    864516        if (dto.isSavePostcode()) {
    865517            String value = selection.get(TagDialog.TAG_ADDR_POSTCODE);
    866             if (value == null || (value != null && !value.equals(dto.getPostcode()))) {
     518            if (value == null || !value.equals(dto.getPostcode())) {
    867519                ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_POSTCODE, dto.getPostcode());
    868520                commands.add(command);
     
    873525            if (dto.isTagStreet()) {
    874526                String value = selection.get(TagDialog.TAG_ADDR_STREET);
    875                 if (value == null || (value != null && !value.equals(dto.getStreet()))) {
     527                if (value == null || !value.equals(dto.getStreet())) {
    876528                    ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_STREET, dto.getStreet());
    877529                    commands.add(command);
     
    885537            } else {
    886538                String value = selection.get(TagDialog.TAG_ADDR_PLACE);
    887                 if (value == null || (value != null && !value.equals(dto.getStreet()))) {
     539                if (value == null || !value.equals(dto.getStreet())) {
    888540                    ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_PLACE, dto.getStreet());
    889541                    commands.add(command);
     
    900552        if (dto.isSaveState()) {
    901553            String value = selection.get(TagDialog.TAG_ADDR_STATE);
    902             if (value == null || (value != null && !value.equals(dto.getState()))) {
     554            if (value == null || !value.equals(dto.getState())) {
    903555                ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_STATE, dto.getState());
    904556                commands.add(command);
     
    918570    /**
    919571     * Generates a list of all visible names of highways in order to do autocompletion on the road name.
     572     * @return The possible streets for the current edit dataset
    920573     */
    921     private Collection<AutoCompletionItem> getPossibleStreets() {
     574    private static Collection<AutoCompletionItem> getPossibleStreets() {
    922575        Set<AutoCompletionItem> names = new TreeSet<>();
    923576        for (OsmPrimitive osm : MainApplication.getLayerManager().getEditDataSet().allNonDeletedPrimitives()) {
     
    937590                try (
    938591                        FileInputStream file = new FileInputStream(fileName);
    939                         ObjectInputStream o = new ObjectInputStream(file);
     592                        ObjectInputStream o = new ObjectInputStream(file)
    940593                ) {
    941594                    dto = (Dto) o.readObject();
     
    944597                loadExistingValuesToDto(dto);
    945598            }
    946         } catch (Exception ex) {
    947             LOGGER.log(Level.SEVERE, ex.getMessage());
    948             fileName.delete();
     599        } catch (ClassNotFoundException | IOException ex) {
     600            Logging.error(ex);
     601            if (!fileName.delete()) {
     602                Logging.trace("TagDialog: {0} not deleted", fileName);
     603            }
    949604            loadExistingValuesToDto(dto);
    950605        }
  • applications/editors/josm/plugins/HouseNumberTaggingTool/test/unit/org/openstreetmap/josm/plugins/housenumbertool/HouseNumberHelperTest.java

    r35508 r36060  
    22package org.openstreetmap.josm.plugins.housenumbertool;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNull;
    64
    7 import org.junit.Test;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertNull;
     7
     8import org.junit.jupiter.api.Test;
    89
    910/**
    1011 * Unit tests of {@link TagDialog}.
    1112 */
    12 public class HouseNumberHelperTest {
     13class HouseNumberHelperTest {
    1314
    1415    /**
     
    1617     */
    1718    @Test
    18     public void testIncrementHouseNumber() {
     19    void testIncrementHouseNumber() {
    1920        assertEquals("2", HouseNumberHelper.incrementHouseNumber("1", 1));
    2021        assertEquals("12", HouseNumberHelper.incrementHouseNumber("10", 2));
Note: See TracChangeset for help on using the changeset viewer.