Ignore:
Timestamp:
2017-10-03T22:17:31+02:00 (7 years ago)
Author:
donvip
Message:

fix #josm15389

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

Legend:

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

    r32680 r33692  
    44    <property name="commit.message" value="Impoved Icon"/>
    55    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    6     <property name="plugin.main.version" value="10580"/>
     6    <property name="plugin.main.version" value="12726"/>
    77   
    88    <!-- Configure these properties (replace "..." accordingly).
  • applications/editors/josm/plugins/addrinterpolation/src/org/openstreetmap/josm/plugins/AddrInterpolation/AddrInterpolationAction.java

    r33005 r33692  
    2727    }
    2828
     29    @Override
    2930    public void actionPerformed(ActionEvent e) {
    3031        /*AddrInterpolationDialog addrDialog =*/ new AddrInterpolationDialog(tr("Define Address Interpolation"));
    3132    }
    3233
     34    @Override
    3335    public void selectionChanged(
    3436            Collection<? extends OsmPrimitive> newSelection) {
  • applications/editors/josm/plugins/addrinterpolation/src/org/openstreetmap/josm/plugins/AddrInterpolation/AddrInterpolationDialog.java

    r33005 r33692  
    2424import java.util.ArrayList;
    2525import java.util.Collection;
     26import java.util.Collections;
     27import java.util.HashMap;
    2628import java.util.LinkedList;
     29import java.util.Map;
    2730import java.util.regex.Pattern;
    2831
     
    5457import org.openstreetmap.josm.data.osm.RelationMember;
    5558import org.openstreetmap.josm.data.osm.Way;
     59import org.openstreetmap.josm.gui.MainApplication;
    5660import org.openstreetmap.josm.gui.widgets.UrlLabel;
    5761import org.openstreetmap.josm.tools.ImageProvider;
     
    266270        // Numeric increment box can be enabled or disabled.
    267271        addrInterpolationList.addActionListener(new ActionListener() {
     272            @Override
    268273            public void actionPerformed(ActionEvent e) {
    269274                int selectedIndex = addrInterpolationList.getSelectedIndex();
     
    527532    private String FindRelation() {
    528533        String relationDescription = null;
    529         DataSet currentDataSet = Main.getLayerManager().getEditDataSet();
     534        DataSet currentDataSet = MainApplication.getLayerManager().getEditDataSet();
    530535        if (currentDataSet != null) {
    531536            for (Relation relation : currentDataSet.getRelations()) {
     
    574579        int namedWayCount = 0;
    575580        int unNamedWayCount = 0;
    576         DataSet currentDataSet = Main.getLayerManager().getEditDataSet();
     581        DataSet currentDataSet = MainApplication.getLayerManager().getEditDataSet();
    577582        if (currentDataSet != null) {
    578583            for (OsmPrimitive osm : currentDataSet.getSelectedWays()) {
     
    667672    }
    668673
     674    @Override
    669675    public void actionPerformed(ActionEvent e) {
    670676        if ("ok".equals(e.getActionCommand())) {
     
    761767                newHouseNumberNode.put("addr:housenumber", newHouseNumber);
    762768
    763                 commandGroup.add(new AddCommand(newHouseNumberNode));
     769                commandGroup.add(new AddCommand(MainApplication.getLayerManager().getEditDataSet(), newHouseNumberNode));
    764770                houseNumberNodes.add(newHouseNumberNode);   // Street, etc information to be added later
    765771
     
    863869                newHouseNumberNode.put("addr:housenumber", newHouseNumber);
    864870
    865                 commandGroup.add(new AddCommand(newHouseNumberNode));
     871                commandGroup.add(new AddCommand(MainApplication.getLayerManager().getEditDataSet(), newHouseNumberNode));
    866872                houseNumberNodes.add(newHouseNumberNode);   // Street, etc information to be added later
    867873
     
    10111017
    10121018        String streetName = selectedStreet.get("name");
     1019        DataSet currentDataSet = MainApplication.getLayerManager().getEditDataSet();
    10131020
    10141021        if (addrInterpolationWay != null) {
     
    10181025
    10191026            // De-select address interpolation way; leave street selected
    1020             DataSet currentDataSet = Main.getLayerManager().getEditDataSet();
    1021             if (currentDataSet != null) {
    1022                 currentDataSet.clearSelection(addrInterpolationWay);
    1023                 currentDataSet.clearSelection(lastNode);  // Workaround for JOSM Bug #3838
    1024             }
     1027            currentDataSet.clearSelection(addrInterpolationWay);
     1028            currentDataSet.clearSelection(lastNode);  // Workaround for JOSM Bug #3838
    10251029
    10261030            String interpolationTagValue = selectedMethod;
     
    10521056            // Relation button was selected
    10531057            if (associatedStreetRelation == null) {
    1054                 CreateRelation(streetName);
     1058                CreateRelation(currentDataSet, streetName);
    10551059                // relationChanged = true;   (not changed since it was created)
    10561060            }
     
    10701074                AddToRelation(associatedStreetRelation, node, "house");
    10711075            }
     1076            Map<String, String> tags = new HashMap<>();
    10721077            if ((city != null) || (streetNameButton.isSelected())) {
    10731078                // Include street unconditionally if adding nodes only or city name specified
    1074                 commandGroup.add(new ChangePropertyCommand(node, "addr:street", streetName));
     1079                tags.put("addr:street", streetName);
    10751080            }
    10761081            // Set or remove remaining optional fields
    1077             commandGroup.add(new ChangePropertyCommand(node, "addr:city", city));
    1078             commandGroup.add(new ChangePropertyCommand(node, "addr:state", state));
    1079             commandGroup.add(new ChangePropertyCommand(node, "addr:postcode", postCode));
    1080             commandGroup.add(new ChangePropertyCommand(node, "addr:country", country));
    1081             commandGroup.add(new ChangePropertyCommand(node, "addr:full", fullAddress));
     1082            tags.put("addr:city", city);
     1083            tags.put("addr:state", state);
     1084            tags.put("addr:postcode", postCode);
     1085            tags.put("addr:country", country);
     1086            tags.put("addr:full", fullAddress);
     1087            commandGroup.add(new ChangePropertyCommand(currentDataSet, Collections.singleton(node), tags));
    10821088        }
    10831089
     
    10871093
    10881094        Main.main.undoRedo.add(new SequenceCommand(tr("Address Interpolation"), commandGroup));
    1089         Main.map.repaint();
     1095        MainApplication.getLayerManager().getEditLayer().invalidate();
    10901096
    10911097        return true;
     
    11091115
    11101116    // Create Associated Street relation, add street, and add to list of commands to perform
    1111     private void CreateRelation(String streetName) {
     1117    private void CreateRelation(DataSet currentDataSet, String streetName) {
    11121118        associatedStreetRelation = new Relation();
    11131119        associatedStreetRelation.put("name", streetName);
     
    11151121        RelationMember newStreetMember = new RelationMember("street", selectedStreet);
    11161122        associatedStreetRelation.addMember(newStreetMember);
    1117         commandGroup.add(new AddCommand(associatedStreetRelation));
     1123        commandGroup.add(new AddCommand(currentDataSet, associatedStreetRelation));
    11181124    }
    11191125
  • applications/editors/josm/plugins/addrinterpolation/src/org/openstreetmap/josm/plugins/AddrInterpolation/AddrInterpolationPlugin.java

    r33005 r33692  
    22package org.openstreetmap.josm.plugins.AddrInterpolation;
    33
    4 import org.openstreetmap.josm.Main;
     4import org.openstreetmap.josm.gui.MainApplication;
    55import org.openstreetmap.josm.gui.MainMenu;
    66import org.openstreetmap.josm.plugins.Plugin;
     
    99public class AddrInterpolationPlugin extends Plugin {
    1010
    11     AddrInterpolationAction action = null;
    12 
    1311    /**
    1412     * constructor
     
    1614    public AddrInterpolationPlugin(PluginInformation info) {
    1715        super(info);
    18         action = new AddrInterpolationAction();
    19         MainMenu.add(Main.main.menu.dataMenu, action, false, 0);
     16        MainMenu.add(MainApplication.getMenu().dataMenu, new AddrInterpolationAction(), false, 0);
    2017    }
    2118}
  • applications/editors/josm/plugins/addrinterpolation/src/org/openstreetmap/josm/plugins/AddrInterpolation/EscapeDialog.java

    r33005 r33692  
    5353    protected JRootPane createRootPane() {
    5454        ActionListener escapeActionListener = new ActionListener() {
     55            @Override
    5556            public void actionPerformed(ActionEvent actionEvent) {
    5657                dispose();
    57                 // setVisible(false);
    5858            }
    5959        };
Note: See TracChangeset for help on using the changeset viewer.