Ticket #6250: undoSelection_v4.patch

File undoSelection_v4.patch, 4.0 KB (added by akks, 15 years ago)

ready core patch

  • org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

     
    199199        SelectionEventManager.getInstance().addSelectionListener(model, FireMode.IN_EDT_CONSOLIDATED);
    200200        DatasetEventManager.getInstance().addDatasetListener(model, FireMode.IN_EDT);
    201201        MapView.addEditLayerChangeListener(actSearch);
     202        // editLayerChanged also gets the selection history of the level
     203        model.editLayerChanged(null, Main.map.mapView.getEditLayer());
    202204        if (Main.map.mapView.getEditLayer() != null) {
    203205            model.setJOSMSelection(Main.map.mapView.getEditLayer().data.getSelected());
    204206        }
     
    221223        return arrowButton;
    222224    }
    223225
    224     public void clearSelectionHistory() {
    225         model.clearSelectionHistory();
    226     }
    227226
    228227    /**
    229228     * Responds to double clicks on the list of selected objects
     
    481480
    482481        private static final int SELECTION_HISTORY_SIZE = 10;
    483482
    484         private final LinkedList<Collection<? extends OsmPrimitive>> history = new LinkedList<Collection<? extends OsmPrimitive>>();
     483        // Variable to store history from currentDataSet()
     484        private LinkedList<Collection<? extends OsmPrimitive>> history;
    485485        private final List<OsmPrimitive> selection = new ArrayList<OsmPrimitive>();
    486486        private DefaultListSelectionModel selectionModel;
    487487
     
    521521        public void remember(Collection<? extends OsmPrimitive> selection) {
    522522            if (selection == null)return;
    523523            if (selection.isEmpty())return;
     524            if (history == null) return;
    524525            if (history.isEmpty()) {
    525526                history.add(selection);
    526527                return;
     
    548549            return history;
    549550        }
    550551
    551         public void clearSelectionHistory() {
    552             history.clear();
    553         }
    554 
    555552        public Object getElementAt(int index) {
    556553            return selection.get(index);
    557554        }
     
    689686        public void editLayerChanged(OsmDataLayer oldLayer, OsmDataLayer newLayer) {
    690687            if (newLayer == null) {
    691688                setJOSMSelection(null);
     689                history = null;
    692690            } else {
     691                history = newLayer.data.getSelectionHistory();
    693692                setJOSMSelection(newLayer.data.getSelected());
    694693            }
    695694        }
  • org/openstreetmap/josm/data/osm/DataSet.java

     
    133133    }
    134134
    135135    /**
     136     * History of selections - shared by plugins and SelectionListDialog
     137     */
     138    private final LinkedList<Collection<? extends OsmPrimitive>> selectionHistory = new LinkedList<Collection<? extends OsmPrimitive>>();
     139
     140    /**
     141     * Replies the history of JOSM selections
     142     *
     143     * @return
     144     */
     145    public LinkedList<Collection<? extends OsmPrimitive>> getSelectionHistory() {
     146        return selectionHistory;
     147    }
     148
     149    /**
     150     * Clears selection history list
     151     */
     152    public void clearSelectionHistory() {
     153            selectionHistory.clear();
     154        }
     155
     156    /**
    136157     * Maintain a list of used tags for autocompletion
    137158     */
    138159    private AutoCompletionManager autocomplete;
  • org/openstreetmap/josm/actions/PurgeAction.java

     
    207207
    208208        if (cbClearUndoRedo.isSelected()) {
    209209            Main.main.undoRedo.clean();
    210             Main.map.selectionListDialog.clearSelectionHistory();
     210            getCurrentDataSet().clearSelectionHistory();
    211211        }
    212212    }
    213213