public class UndoRedoHandler extends java.lang.Object implements LayerManager.LayerChangeListener
OsmDataLayer
s.
If you want to change a data layer, you can use add(Command)
to execute a command on it and make that command undoable.
Modifier and Type | Field and Description |
---|---|
java.util.LinkedList<Command> |
commands
All commands that were made on the dataset.
|
private java.util.LinkedList<OsmDataLayer.CommandQueueListener> |
listenerCommands |
java.util.LinkedList<Command> |
redoCommands
The stack for redoing commands
|
Constructor and Description |
---|
UndoRedoHandler()
Constructs a new
UndoRedoHandler . |
Modifier and Type | Method and Description |
---|---|
void |
add(Command c)
Executes the command and add it to the intern command queue.
|
boolean |
addCommandQueueListener(OsmDataLayer.CommandQueueListener l)
Adds a command queue listener.
|
void |
addNoRedraw(Command c)
Executes the command and add it to the intern command queue.
|
void |
afterAdd()
Fires a commands change event after adding a command.
|
void |
clean()
Resets the undo/redo list.
|
void |
clean(Layer layer)
Resets all commands that affect the given layer.
|
private void |
fireCommandsChanged()
Fires a command change to all listeners.
|
private static void |
fireIfSelectionChanged(DataSet ds,
java.util.Collection<? extends OsmPrimitive> oldSelection) |
void |
layerAdded(LayerManager.LayerAddEvent e)
Notifies this listener that a layer has been added.
|
void |
layerOrderChanged(LayerManager.LayerOrderChangeEvent e)
Notifies this listener that the order of layers was changed.
|
void |
layerRemoving(LayerManager.LayerRemoveEvent e)
Notifies this listener that a alayer was just removed.
|
void |
redo()
Redoes the last undoed command.
|
void |
redo(int num)
Redoes multiple commands.
|
void |
removeCommandQueueListener(OsmDataLayer.CommandQueueListener l)
Removes a command queue listener.
|
void |
undo()
Undoes the last added command.
|
void |
undo(int num)
Undoes multiple commands.
|
public final java.util.LinkedList<Command> commands
public final java.util.LinkedList<Command> redoCommands
private final java.util.LinkedList<OsmDataLayer.CommandQueueListener> listenerCommands
public UndoRedoHandler()
UndoRedoHandler
.public void addNoRedraw(Command c)
c
- The command to execute. Must not be null
.public void afterAdd()
public void add(Command c)
c
- The command to execute. Must not be null
.public void undo()
public void undo(int num)
num
- The number of commands to undopublic void redo()
public void redo(int num)
num
- The number of commands to redoprivate static void fireIfSelectionChanged(DataSet ds, java.util.Collection<? extends OsmPrimitive> oldSelection)
private void fireCommandsChanged()
public void clean()
public void clean(Layer layer)
layer
- The layer that was affected.public void layerRemoving(LayerManager.LayerRemoveEvent e)
LayerManager.LayerChangeListener
Listeners are called in the EDT thread after the layer was removed.
Use LayerManager.LayerRemoveEvent.scheduleRemoval(Collection)
to remove more layers.
You should not do blocking or long-running tasks in this method.
layerRemoving
in interface LayerManager.LayerChangeListener
e
- The layer to be removed (as event)public void layerAdded(LayerManager.LayerAddEvent e)
LayerManager.LayerChangeListener
Listeners are called in the EDT thread. You should not do blocking or long-running tasks in this method.
layerAdded
in interface LayerManager.LayerChangeListener
e
- The new added layer eventpublic void layerOrderChanged(LayerManager.LayerOrderChangeEvent e)
LayerManager.LayerChangeListener
Listeners are called in the EDT thread. You should not do blocking or long-running tasks in this method.
layerOrderChanged
in interface LayerManager.LayerChangeListener
e
- The order change event.public void removeCommandQueueListener(OsmDataLayer.CommandQueueListener l)
l
- The command queue listener to removepublic boolean addCommandQueueListener(OsmDataLayer.CommandQueueListener l)
l
- The commands queue listener to addtrue
if the listener has been added, false
otherwise