Changeset 5709 in josm


Ignore:
Timestamp:
2013-02-12T21:41:26+01:00 (12 years ago)
Author:
Don-vip
Message:

fix #8424 - "Select" and "Delete" actions operate on wrong relations when filter is used in relation toggle dialog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

    r5696 r5709  
    410410            List<Relation> toDelete = new LinkedList<Relation>();
    411411            for (int i : displaylist.getSelectedIndices()) {
    412                 toDelete.add(model.getRelation(i));
     412                toDelete.add(model.getVisibleRelation(i));
    413413            }
    414414            for (Relation r : toDelete) {
     
    519519            ArrayList<OsmPrimitive> selection = new ArrayList<OsmPrimitive>(idx.length);
    520520            for (int i: idx) {
    521                 selection.add(model.getRelation(i));
     521                selection.add(model.getVisibleRelation(i));
    522522            }
    523523            if(add) {
     
    692692        private ArrayList<Relation> filteredRelations;
    693693        private DefaultListSelectionModel selectionModel;
    694         private SearchCompiler.Match filter;
     694        //private SearchCompiler.Match filter;
    695695
    696696        public RelationListModel(DefaultListSelectionModel selectionModel) {
     
    785785            int size = relations.size();
    786786            relations.removeAll(removedRelations);
     787            if (filteredRelations != null) {
     788                filteredRelations.removeAll(removedRelations);
     789            }
    787790            if (size != relations.size()) {
    788791                List<Relation> sel = getSelectedRelations();
     
    811814
    812815        public void setFilter(final SearchCompiler.Match filter) {
    813             this.filter = filter;
     816            //this.filter = filter;
    814817            this.filteredRelations = new ArrayList<Relation>(Utils.filter(relations, new Predicate<Relation>() {
    815818                @Override
     
    827830            return filteredRelations == null ? relations : filteredRelations;
    828831        }
     832       
     833        private Relation getVisibleRelation(int index) {
     834            if (index < 0 || index >= getVisibleRelations().size()) return null;
     835            return getVisibleRelations().get(index);
     836        }
    829837
    830838        @Override
    831839        public Object getElementAt(int index) {
    832             if (index < 0 || index >= getVisibleRelations().size()) return null;
    833             return getVisibleRelations().get(index);
     840            return getVisibleRelation(index);
    834841        }
    835842
     
    879886         * Sets the selected relations.
    880887         *
    881          * @return sel the list of selected relations
     888         * @param sel the list of selected relations
    882889         */
    883890        public void setSelectedRelations(Collection<Relation> sel) {
     
    896903        /**
    897904         * Returns the index of the relation
     905         * @param rel The relation to look for
    898906         *
    899907         * @return index of relation (null if it cannot be found)
Note: See TracChangeset for help on using the changeset viewer.