Ignore:
Timestamp:
2010-11-01T03:38:44+01:00 (14 years ago)
Author:
oliverw
Message:

Bugfix: Selection was not considered.

Location:
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/AddressEditContainer.java

    r23979 r23981  
    7272public class AddressEditContainer implements Visitor, DataSetListener, IAddressEditContainerListener {
    7373       
     74        private Collection<? extends OsmPrimitive> workingSet;
    7475        /** The street dictionary collecting all streets to a set of unique street names. */
    7576        private HashMap<String, StreetNode> streetDict = new HashMap<String, StreetNode>(100);
     
    106107
    107108        /**
     109         * Gets the working set used by the container. This can by either the complete or just
     110         * a subset of the current data layer.
     111         *
     112         * @return the workingSet
     113         */
     114        protected Collection<? extends OsmPrimitive> getWorkingSet() {
     115                return workingSet;
     116        }
     117
     118
     119        /**
    108120         * Adds a change listener.
    109121         * @param listener
     
    146158         *
    147159         * @param n the n
    148          * @return true, if successful
     160         * @return true, if node has been visited
    149161         */
    150162        private boolean hasBeenVisited(Node n) {
     
    161173        }
    162174       
     175        /**
     176         * Checks a way for been visited.
     177         *
     178         * @param w the w to check
     179         * @return true, if way has been visited
     180         */
    163181        private boolean hasBeenVisited(Way w) {
    164182                return visitedWays.contains(w);
     
    180198                if (aNode != null) {
    181199                        addAndClassifyAddress(aNode);
    182                 } /*else {
    183                         // check, if node is referred by a way
    184                         for (OsmPrimitive osm : n.getReferrers()) {
    185                                 if (osm instanceof Way) {
    186                                         Way w = (Way) osm;
    187                                         if (!hasBeenVisited(w)) {
    188                                                 createNodeFromWay(w);
    189                                         }
    190                                 }
    191                         }
    192                        
    193                 }*/
     200                }
    194201                markNodeAsVisited(n);
    195202        }
     
    234241        private void createNodeFromWay(Way w) {
    235242                INodeEntity ne = NodeFactory.createNodeFromWay(w);
    236 
    237243               
    238244                if (!processNode(ne, w)) {
    239 
    240245                        // Look also into nodes for addresses (unlikely, but at least they
    241246                        // get marked as visited).
     
    249254                                }
    250255                        }
    251                 }
     256                } // else: node has been processed, no need to look deeper
    252257        }
    253258
     
    456461       
    457462        /**
    458          * Rebuilds the street and address lists using the current data set.
     463         * Rebuilds the street and address lists using the data set given
     464         * in  {@link AddressEditContainer#attachToDataSet(Collection)} or the
     465         * full data set of the current data layer {@link Main#getCurrentDataSet()}.
    459466         */
    460467        public void invalidate() {
    461                 invalidate(Main.main.getCurrentDataSet().allPrimitives());
     468                if (workingSet != null) {
     469                        invalidate(workingSet);
     470                } else {
     471                        invalidate(Main.main.getCurrentDataSet().allPrimitives());
     472                }
    462473        }
    463474       
     
    507518       
    508519        /**
    509          * Connects the listener to the data set and revisits the data. This method should
     520         * Connects the listener to the given data set and revisits the data. This method should
    510521         * be called immediately after an edit session finished.
    511522         *
     523         * If the given data set is not null, calls of {@link AddressEditContainer#invalidate()} will
     524         * only consider the data given within this set. This can be useful to keep out unimportant
     525         * areas. However, a side-effect could be that some streets are not included and leads to
     526         * false alarms regarding unresolved addresses.
     527         *
     528         * Calling {@link AddressEditContainer#detachFromDataSet()} drops the explicit data set and uses
     529         * the full data set on subsequent updates.<p>
     530         *
     531         * <b>Example</b><br>
    512532         * <code>
     533         * attachToDataSet(osmDataSetToWorkOn); // osmDataSetToWorkOn = selected items<br>
     534         * //... launch dialog or whatever<br>
    513535         * detachFromDataSet();
    514          * //... launch dialog or whatever
    515          * attachToDataSet();
    516536         * </code>
    517          */
    518         public void attachToDataSet(Collection<? extends OsmPrimitive> dataToExamine) {         
    519                 Main.main.getCurrentDataSet().addDataSetListener(this);
    520                 if (dataToExamine != null && dataToExamine.size() > 0) {
    521                         invalidate(dataToExamine); // use given data set (usually the current selection)
     537         *
     538         * @param osmDataToWorkOn the data to examine
     539         */
     540        public void attachToDataSet(Collection<? extends OsmPrimitive> osmDataToWorkOn) {
     541                if (osmDataToWorkOn != null && !osmDataToWorkOn.isEmpty()) {                   
     542                        workingSet = new ArrayList<OsmPrimitive>(osmDataToWorkOn);
    522543                } else {
    523                         invalidate(); // use current data set
    524                 }
     544                        detachFromDataSet(); // drop old stuff, if present
     545                }
     546                invalidate(); // start our investigation...
    525547        }
    526548       
     
    531553         */
    532554        public void detachFromDataSet() {
    533                 Main.main.getCurrentDataSet().removeDataSetListener(this);
     555                //Main.main.getCurrentDataSet().removeDataSetListener(this);           
     556                if (workingSet != null) {
     557                        workingSet.clear();
     558                        workingSet = null;
     559                }
    534560        }
    535561
  • applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/FixUnresolvedStreetsAction.java

    r23933 r23981  
    4848        @Override
    4949        public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
    50                 /* this changes the dialog contents, so we do nothing here
     50                /* remember new selection for actionPerformed */
    5151                this.newSelection = newSelection;
    52                 if (addressEditContainer != null) {
    53                         addressEditContainer.invalidate(newSelection);
    54                 }*/
    5552        }
    5653
Note: See TracChangeset for help on using the changeset viewer.