Changeset 34069 in osm for applications


Ignore:
Timestamp:
2018-02-18T15:26:07+01:00 (7 years ago)
Author:
donvip
Message:

fix #josm15961 - support letter-prefixed numbers

Location:
applications/editors/josm/plugins/HouseNumberTaggingTool
Files:
8 added
6 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/HouseNumberTaggingTool/.classpath

    r32680 r34069  
    22<classpath>
    33        <classpathentry kind="src" path="src"/>
     4        <classpathentry kind="src" path="test/unit"/>
    45        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
     6        <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
    57        <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/>
    68        <classpathentry kind="output" path="bin"/>
  • applications/editors/josm/plugins/HouseNumberTaggingTool/.settings/org.eclipse.core.resources.prefs

    r29859 r34069  
    11eclipse.preferences.version=1
     2encoding/test=UTF-8
    23encoding/src=UTF-8
  • applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/Dto.java

    r30775 r34069  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.housenumbertool;
    23
  • applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/HouseNumberTaggingToolPlugin.java

    r33904 r34069  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.housenumbertool;
    23
     
    1011 */
    1112public class HouseNumberTaggingToolPlugin extends Plugin {
    12     private final LaunchAction action;
    1313
    1414    /**
     
    1818    public HouseNumberTaggingToolPlugin(PluginInformation info) {
    1919        super(info);
    20         action = new LaunchAction(getPluginDirs().getUserDataDirectory(false));
    21         MainMenu.add(MainApplication.getMenu().dataMenu, action, false,0);
     20        LaunchAction action = new LaunchAction(getPluginDirs().getUserDataDirectory(false));
     21        MainMenu.add(MainApplication.getMenu().dataMenu, action, false, 0);
    2222    }
    2323}
  • applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/LaunchAction.java

    r33904 r34069  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.housenumbertool;
    23
  • applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/TagDialog.java

    r33904 r34069  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.housenumbertool;
    23
     
    2324import java.util.logging.Level;
    2425import java.util.logging.Logger;
     26import java.util.regex.Matcher;
     27import java.util.regex.Pattern;
    2528
    2629import javax.swing.ButtonGroup;
     
    320323        housnumber.setPreferredSize(new Dimension(200, 24));
    321324
    322         int number = 0;
    323         try {
    324             number = Integer.valueOf(dto.getHousenumber()) + dto.getHousenumberChangeValue();
    325         } catch (NumberFormatException e)  {
    326             // Do nothing
    327         }
    328         if (number > 0) {
    329             housnumber.setText(String.valueOf(number));
     325        String number = incrementHouseNumber(dto.getHousenumber(), dto.getHousenumberChangeValue());
     326        if (number != null) {
     327            housnumber.setText(number);
    330328        }
    331329
     
    358356
    359357        return editPanel;
     358    }
     359
     360    static String incrementHouseNumber(String number, int increment) {
     361        try {
     362            Matcher m = Pattern.compile("([^\\pN]+)?(\\pN+)([^\\pN]+)?").matcher(number);
     363            if (m.matches()) {
     364                String prefix = m.group(1) != null ? m.group(1) : "";
     365                int n = Integer.valueOf(m.group(2)) + increment;
     366                String suffix = m.group(3) != null ? m.group(3) : "";
     367                return prefix + n + suffix;
     368            }
     369        } catch (NumberFormatException e)  {
     370            // Do nothing
     371        }
     372        return null;
    360373    }
    361374
Note: See TracChangeset for help on using the changeset viewer.