Package org.apache.batik.apps.svgbrowser
Class HistoryBrowser
- java.lang.Object
-
- org.apache.batik.apps.svgbrowser.HistoryBrowser
-
public class HistoryBrowser extends java.lang.Object
History browser. Manages perform of execute, undo and redo actions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
HistoryBrowser.CommandController
Wrapps the command's execute, undo and redo methods.static class
HistoryBrowser.CommandNamesInfo
Contains the info on the command name being executed, undone or redone and last undoable and redoable command names.static class
HistoryBrowser.DocumentCommandController
Lets the DOMViewerController wrap the commands.static class
HistoryBrowser.HistoryBrowserAdapter
The adapter to provide the default behavior.static class
HistoryBrowser.HistoryBrowserEvent
Event to pass to listener.static interface
HistoryBrowser.HistoryBrowserListener
The HistoryBrowserListener.
-
Field Summary
Fields Modifier and Type Field Description protected HistoryBrowser.CommandController
commandController
Tells the history browser how to execute, undo and redo the commands.protected int
currentCommandIndex
Current command pointer in history array.protected javax.swing.event.EventListenerList
eventListeners
Listeners list.static int
EXECUTING
The history browser is executing the command(s).protected java.util.ArrayList
history
Command history.protected int
historySize
History size.static int
IDLE
The history browser is in idle state - no command is being executed, undone or redone.static int
REDOING
The history browser is redoing the command(s).protected int
state
The current state of the history browser.static int
UNDOING
The history browser is undoing the command(s).
-
Constructor Summary
Constructors Constructor Description HistoryBrowser(int historySize)
Constructor.HistoryBrowser(HistoryBrowser.CommandController commandController)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCommand(UndoableCommand command)
Adds the given command to history array and executes it.void
addListener(HistoryBrowser.HistoryBrowserListener listener)
Adds the listener to the listener list.void
compoundRedo(int redoNumber)
Performs redo action the given number of times.void
compoundUndo(int undoNumber)
Performs undo action the given number of times.void
fireCompoundEditPerformed(HistoryBrowser.HistoryBrowserEvent event)
Fires the compoundEditPerformed event.void
fireDoCompoundEdit(HistoryBrowser.HistoryBrowserEvent event)
Fires the doCompoundEdit event.void
fireExecutePerformed(HistoryBrowser.HistoryBrowserEvent event)
Fires the executePerformed event.void
fireHistoryReset(HistoryBrowser.HistoryBrowserEvent event)
Fires the historyReset event.void
fireRedoPerformed(HistoryBrowser.HistoryBrowserEvent event)
Fires the redoPerformed event.void
fireUndoPerformed(HistoryBrowser.HistoryBrowserEvent event)
Fires the undoPerformed event.java.lang.String
getLastRedoableCommandName()
Gets the last redoable command name.java.lang.String
getLastUndoableCommandName()
Gets the last undoable command name.int
getState()
Gets the state of this history browser.void
redo()
Redoes the last 'undone' command.void
resetHistory()
Clears the history array.void
setCommandController(HistoryBrowser.CommandController newCommandController)
Sets the commandController.protected void
setHistorySize(int size)
Setter for the history size.void
undo()
Undoes the last executed or 'redone' command.
-
-
-
Field Detail
-
EXECUTING
public static final int EXECUTING
The history browser is executing the command(s).- See Also:
- Constant Field Values
-
UNDOING
public static final int UNDOING
The history browser is undoing the command(s).- See Also:
- Constant Field Values
-
REDOING
public static final int REDOING
The history browser is redoing the command(s).- See Also:
- Constant Field Values
-
IDLE
public static final int IDLE
The history browser is in idle state - no command is being executed, undone or redone.- See Also:
- Constant Field Values
-
eventListeners
protected javax.swing.event.EventListenerList eventListeners
Listeners list.
-
history
protected java.util.ArrayList history
Command history.
-
currentCommandIndex
protected int currentCommandIndex
Current command pointer in history array.
-
historySize
protected int historySize
History size.
-
state
protected int state
The current state of the history browser.
-
commandController
protected HistoryBrowser.CommandController commandController
Tells the history browser how to execute, undo and redo the commands. Wraps the execute, undo and redo methods
-
-
Constructor Detail
-
HistoryBrowser
public HistoryBrowser(HistoryBrowser.CommandController commandController)
Constructor.
-
HistoryBrowser
public HistoryBrowser(int historySize)
Constructor.- Parameters:
historySize
- History size
-
-
Method Detail
-
setHistorySize
protected void setHistorySize(int size)
Setter for the history size.- Parameters:
size
- New history size
-
setCommandController
public void setCommandController(HistoryBrowser.CommandController newCommandController)
Sets the commandController.- Parameters:
newCommandController
- The newCommandController to set
-
addCommand
public void addCommand(UndoableCommand command)
Adds the given command to history array and executes it.- Parameters:
command
- The given command
-
undo
public void undo()
Undoes the last executed or 'redone' command.
-
redo
public void redo()
Redoes the last 'undone' command.
-
compoundUndo
public void compoundUndo(int undoNumber)
Performs undo action the given number of times.- Parameters:
undoNumber
- The given number of undo actions to perform
-
compoundRedo
public void compoundRedo(int redoNumber)
Performs redo action the given number of times.- Parameters:
redoNumber
- The given number of redo actions to perform
-
getLastUndoableCommandName
public java.lang.String getLastUndoableCommandName()
Gets the last undoable command name.- Returns:
- String or "" if there's no any
-
getLastRedoableCommandName
public java.lang.String getLastRedoableCommandName()
Gets the last redoable command name.- Returns:
- String or "" if there's no any
-
resetHistory
public void resetHistory()
Clears the history array.
-
getState
public int getState()
Gets the state of this history browser.- Returns:
- the state
-
addListener
public void addListener(HistoryBrowser.HistoryBrowserListener listener)
Adds the listener to the listener list.- Parameters:
listener
- The listener to add
-
fireExecutePerformed
public void fireExecutePerformed(HistoryBrowser.HistoryBrowserEvent event)
Fires the executePerformed event.- Parameters:
event
- The associated HistoryBrowserEvent event
-
fireUndoPerformed
public void fireUndoPerformed(HistoryBrowser.HistoryBrowserEvent event)
Fires the undoPerformed event.- Parameters:
event
- The associated HistoryBrowserEvent event
-
fireRedoPerformed
public void fireRedoPerformed(HistoryBrowser.HistoryBrowserEvent event)
Fires the redoPerformed event.- Parameters:
event
- The associated HistoryBrowserEvent event
-
fireHistoryReset
public void fireHistoryReset(HistoryBrowser.HistoryBrowserEvent event)
Fires the historyReset event.- Parameters:
event
- The associated HistoryBrowserEvent event
-
fireDoCompoundEdit
public void fireDoCompoundEdit(HistoryBrowser.HistoryBrowserEvent event)
Fires the doCompoundEdit event.- Parameters:
event
- The associated HistoryBrowserEvent event
-
fireCompoundEditPerformed
public void fireCompoundEditPerformed(HistoryBrowser.HistoryBrowserEvent event)
Fires the compoundEditPerformed event.- Parameters:
event
- The associated HistoryBrowserEvent event
-
-