Changeset 33718 in osm


Ignore:
Timestamp:
2017-10-14T00:20:49+02:00 (7 years ago)
Author:
donvip
Message:

fix #josm15434 - NoSuchElementException

Location:
applications/editors/josm/plugins/FixAddresses
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/FixAddresses

    • Property svn:ignore
      •  

        old new  
        22checkstyle-josm-FixAddresses.xml
        33findbugs-josm-FixAddresses.xml
         4spotbugs-josm-FixAddresses.xml
  • applications/editors/josm/plugins/FixAddresses/build.xml

    r32680 r33718  
    44    <property name="commit.message" value="[josm_fixadresses]: Fixes #josm8336"/>
    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="12840"/>
    77       
    88    <!-- Configure these properties (replace "..." accordingly).
  • applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/AddressEditContainer.java

    r32970 r33718  
    1010
    1111import org.openstreetmap.josm.Main;
    12 import org.openstreetmap.josm.data.osm.Changeset;
     12import org.openstreetmap.josm.data.osm.DataSet;
    1313import org.openstreetmap.josm.data.osm.Node;
    1414import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    2424import org.openstreetmap.josm.data.osm.event.TagsChangedEvent;
    2525import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent;
    26 import org.openstreetmap.josm.data.osm.visitor.Visitor;
     26import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor;
     27import org.openstreetmap.josm.gui.MainApplication;
    2728import org.openstreetmap.josm.tools.CheckParameterUtil;
    2829
     
    4344 *
    4445 */
    45 public class AddressEditContainer implements Visitor, DataSetListener, IAddressEditContainerListener, IProblemVisitor, IAllKnowingTrashHeap {
     46public class AddressEditContainer implements OsmPrimitiveVisitor, DataSetListener, IAddressEditContainerListener, IProblemVisitor, IAllKnowingTrashHeap {
    4647
    4748    private Collection<? extends OsmPrimitive> workingSet;
     
    300301    }
    301302
    302     @Override
    303     public void visit(Changeset cs) {
    304     }
    305 
    306303    /**
    307304     * Gets the dictionary containing the collected streets.
     
    489486            invalidate(workingSet);
    490487        } else {
    491             if (Main.getLayerManager().getEditDataSet() != null) {
    492                 invalidate(Main.getLayerManager().getEditDataSet().allPrimitives());
     488            DataSet ds = MainApplication.getLayerManager().getEditDataSet();
     489            if (ds != null) {
     490                invalidate(ds.allPrimitives());
    493491            }
    494492        }
     
    708706     * Internal class to handle results of {@link AddressEditContainer#getClosestStreetNames(String, int)}.
    709707     */
    710     private class StreetScore implements Comparable<StreetScore> {
     708    private static class StreetScore implements Comparable<StreetScore> {
    711709        private String name;
    712710        private int score;
  • applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/FixAddressesMapMode.java

    r30348 r33718  
    77
    88import org.openstreetmap.josm.actions.mapmode.MapMode;
    9 import org.openstreetmap.josm.gui.MapFrame;
    109
    1110@SuppressWarnings("serial")
    1211public class FixAddressesMapMode extends MapMode {
    1312
    14     public FixAddressesMapMode(MapFrame mapFrame) {
     13    public FixAddressesMapMode() {
    1514        super(tr("Fix addresses"), "incompleteaddress_24",
    1615                tr("Show dialog with incomplete addresses"),
    17                 mapFrame,
    1816                Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    1917    }
  • applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/FixAddressesPlugin.java

    r30348 r33718  
    22package org.openstreetmap.josm.plugins.fixAddresses;
    33
    4 import org.openstreetmap.josm.Main;
    54import org.openstreetmap.josm.gui.IconToggleButton;
     5import org.openstreetmap.josm.gui.MainApplication;
    66import org.openstreetmap.josm.gui.MainMenu;
    77import org.openstreetmap.josm.gui.MapFrame;
     
    3030
    3131        // ... and add them to the tools menu in main
    32                 MainMenu.add(Main.main.menu.toolsMenu, action, false, 0);
    33         MainMenu.add(Main.main.menu.toolsMenu, incAddrAction);
     32        MainMenu.add(MainApplication.getMenu().toolsMenu, action, false, 0);
     33        MainMenu.add(MainApplication.getMenu().toolsMenu, incAddrAction);
    3434
    3535        // create preferences instance
     
    4040    public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
    4141        if (newFrame != null) {
    42             FixAddressesMapMode faMode = new FixAddressesMapMode(Main.map);
     42            FixAddressesMapMode faMode = new FixAddressesMapMode();
    4343            IconToggleButton faModeButton = new IconToggleButton(faMode);
    4444            faModeButton.setVisible(true);
  • applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/FixAddressesPreferences.java

    r32970 r33718  
    5050     */
    5151    private void saveToPrefs() {
    52         Main.pref.put(FIX_ADDRESSES_SELECT_GUESSED_OBJECTS_KEY, isSelectGuessedObjects());
    53         Main.pref.put(FIX_ADDRESSES_IGNORE_POST_CODE_KEY, isIgnorePostCode());
     52        Main.pref.putBoolean(FIX_ADDRESSES_SELECT_GUESSED_OBJECTS_KEY, isSelectGuessedObjects());
     53        Main.pref.putBoolean(FIX_ADDRESSES_IGNORE_POST_CODE_KEY, isIgnorePostCode());
    5454    }
    5555
  • applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/GuessAddressRunnable.java

    r32970 r33718  
    99import java.util.List;
    1010
    11 import org.openstreetmap.josm.Main;
     11import org.openstreetmap.josm.data.osm.DataSet;
    1212import org.openstreetmap.josm.data.osm.Node;
    1313import org.openstreetmap.josm.data.osm.Way;
     14import org.openstreetmap.josm.gui.MainApplication;
    1415import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    1516import org.openstreetmap.josm.io.OsmTransferException;
     
    120121    OsmTransferException {
    121122
    122         if (Main.getLayerManager().getEditDataSet() == null || addressesToGuess == null) return;
     123        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
     124        if (ds == null || addressesToGuess == null) return;
    123125
    124126        isRunning = true;
     
    153155
    154156                    // visit osm data
    155                     for (Way way : Main.getLayerManager().getEditDataSet().getWays()) {
     157                    for (Way way : ds.getWays()) {
    156158                        if (canceled) {
    157159                            break;
     
    173175
    174176                    // visit osm data
    175                     for (Node node : Main.getLayerManager().getEditDataSet().getNodes()) {
     177                    for (Node node : ds.getNodes()) {
    176178                        if (canceled) {
    177179                            break;
  • applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/GuessedValueHandler.java

    r32970 r33718  
    22package org.openstreetmap.josm.plugins.fixAddresses;
    33
    4 import org.openstreetmap.josm.data.osm.Changeset;
    54import org.openstreetmap.josm.data.osm.Node;
    65import org.openstreetmap.josm.data.osm.OsmPrimitive;
    76import org.openstreetmap.josm.data.osm.Relation;
    87import org.openstreetmap.josm.data.osm.Way;
    9 import org.openstreetmap.josm.data.osm.visitor.Visitor;
     8import org.openstreetmap.josm.data.osm.visitor.OsmPrimitiveVisitor;
    109
    1110/**
     
    1615 * The default maximum distance is 100m.
    1716 */
    18 public class GuessedValueHandler implements Visitor {
     17public class GuessedValueHandler implements OsmPrimitiveVisitor {
    1918
    2019    /** Default maximum distance (100m) */
     
    191190        // nothing to do (yet)
    192191    }
    193 
    194     @Override
    195     public void visit(Changeset cs) {
    196         // nothing to do (yet)
    197     }
    198192}
  • applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/OsmUtils.java

    r32970 r33718  
    55import java.util.Locale;
    66
    7 import org.openstreetmap.josm.Main;
    87import org.openstreetmap.josm.data.Bounds;
    98import org.openstreetmap.josm.data.coor.LatLon;
     
    1413import org.openstreetmap.josm.data.osm.Way;
    1514import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
     15import org.openstreetmap.josm.gui.MainApplication;
    1616import org.openstreetmap.josm.tools.CheckParameterUtil;
    1717import org.openstreetmap.josm.tools.Pair;
     
    202202        CheckParameterUtil.ensureParameterNotNull(addressList, "addressList");
    203203
    204         if (Main.map == null && Main.map.mapView == null) return;   // nothing to do
    205         if (addressList.size() == 0) return;                        // dto.
     204        if (!MainApplication.isDisplayingMapView()) return;   // nothing to do
     205        if (addressList.size() == 0) return;                  // dto.
    206206
    207207        // compute bounding box
     
    215215        if (bbox.getBounds() != null) {
    216216            //  zoom to calculated bounding box
    217             Main.map.mapView.zoomTo(bbox.getBounds());
     217            MainApplication.getMap().mapView.zoomTo(bbox.getBounds());
    218218        }
    219219    }
  • applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/AbstractAddressEditAction.java

    r32970 r33718  
    170170            throw new RuntimeException("No command list available. Did you forget to call beginTransaction?");
    171171        }
    172         // execute the command
    173         Main.main.undoRedo.add(new SequenceCommand(txName, commands));
    174         commands.clear();
    175         if (container != null) {
    176             container.invalidate();
     172        // execute the commands
     173        if (!commands.isEmpty()) {
     174            Main.main.undoRedo.add(new SequenceCommand(txName, commands));
     175            commands.clear();
     176            if (container != null) {
     177                container.invalidate();
     178            }
    177179        }
    178180    }
  • applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/ConvertToRelationAction.java

    r32970 r33718  
    5555        // Create the relation
    5656        Relation r = new Relation();
    57         commands.add(new AddCommand(r));
     57        commands.add(new AddCommand(getLayerManager().getEditDataSet(), r));
    5858        commands.add(new ChangePropertyCommand(r, TagConstants.NAME_TAG, streetNode.getName()));
    5959        commands.add(new ChangePropertyCommand(r, TagConstants.RELATION_TYPE, TagConstants.ASSOCIATEDSTREET_RELATION_TYPE));
  • applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/GuessAddressDataAction.java

    r32970 r33718  
    66import java.util.List;
    77
    8 import org.openstreetmap.josm.Main;
     8import org.openstreetmap.josm.gui.MainApplication;
    99import org.openstreetmap.josm.plugins.fixAddresses.AddressEditContainer;
    1010import org.openstreetmap.josm.plugins.fixAddresses.GuessAddressRunnable;
     
    6666        GuessAddressRunnable aft = new GuessAddressRunnable(nodes, tr("Guessing address values"));
    6767        aft.addFinishListener(this);
    68         Main.worker.submit(aft);
     68        MainApplication.worker.submit(aft);
    6969    }
    7070
Note: See TracChangeset for help on using the changeset viewer.