Changeset 2539 in josm


Ignore:
Timestamp:
2009-11-28T22:15:54+01:00 (15 years ago)
Author:
bastiK
Message:

see #3520 - Do not remove selection when using undo (partial fix)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java

    r2512 r2539  
    22package org.openstreetmap.josm.data;
    33
     4import java.util.ArrayList;
     5import java.util.Collection;
    46import java.util.Iterator;
     7import java.util.List;
    58import java.util.LinkedList;
    69import java.util.Stack;
     
    912import org.openstreetmap.josm.command.Command;
    1013import org.openstreetmap.josm.data.osm.DataSet;
     14import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1115import org.openstreetmap.josm.gui.layer.Layer;
    1216import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    2024     */
    2125    public final LinkedList<Command> commands = new LinkedList<Command>();
     26    /**
     27     * Selection to be restored on undo
     28     */
     29    public Collection<? extends OsmPrimitive> lastSelection = new ArrayList<OsmPrimitive>();
    2230    /**
    2331     * The stack for redoing commands
     
    3543     */
    3644    public void addNoRedraw(final Command c) {
     45        lastSelection = Main.main.getCurrentDataSet().getSelected();
    3746        c.executeCommand();
    3847        commands.add(c);
     
    7382        }
    7483        fireCommandsChanged();
    75         Main.main.getCurrentDataSet().setSelected();
     84        List<OsmPrimitive> all = Main.main.getCurrentDataSet().allPrimitives();
     85        for (OsmPrimitive op : lastSelection) {
     86            if (all.contains(op)) {
     87                Main.main.getCurrentDataSet().addSelected(op);
     88            }
     89        }
    7690    }
    7791
Note: See TracChangeset for help on using the changeset viewer.