org.apache.batik.apps.svgbrowser

Class HistoryBrowser

public class HistoryBrowser extends Object

History browser. Manages perform of execute, undo and redo actions.
Nested Class Summary
static interfaceHistoryBrowser.CommandController
Wrapps the command's execute, undo and redo methods.
static classHistoryBrowser.CommandNamesInfo
Contains the info on the command name being executed, undone or redone and last undoable and redoable command names.
static classHistoryBrowser.DocumentCommandController
Lets the DOMViewerController wrap the commands.
static classHistoryBrowser.HistoryBrowserAdapter
The adapter to provide the default behavior.
static classHistoryBrowser.HistoryBrowserEvent
Event to pass to listener.
static interfaceHistoryBrowser.HistoryBrowserListener
The HistoryBrowserListener.
Field Summary
protected HistoryBrowser.CommandControllercommandController
Tells the history browser how to execute, undo and redo the commands.
protected intcurrentCommandIndex
Current command pointer in history array.
protected EventListenerListeventListeners
Listeners list.
static intEXECUTING
The history browser is executing the command(s).
protected ArrayListhistory
Command history.
protected inthistorySize
History size.
static intIDLE
The history browser is in idle state - no command is being executed, undone or redone.
static intREDOING
The history browser is redoing the command(s).
protected intstate
The current state of the history browser.
static intUNDOING
The history browser is undoing the command(s).
Constructor Summary
HistoryBrowser(HistoryBrowser.CommandController commandController)
Constructor.
HistoryBrowser(int historySize)
Constructor.
Method Summary
voidaddCommand(UndoableCommand command)
Adds the given command to history array and executes it.
voidaddListener(HistoryBrowser.HistoryBrowserListener listener)
Adds the listener to the listener list.
voidcompoundRedo(int redoNumber)
Performs redo action the given number of times.
voidcompoundUndo(int undoNumber)
Performs undo action the given number of times.
voidfireCompoundEditPerformed(HistoryBrowser.HistoryBrowserEvent event)
Fires the compoundEditPerformed event.
voidfireDoCompoundEdit(HistoryBrowser.HistoryBrowserEvent event)
Fires the doCompoundEdit event.
voidfireExecutePerformed(HistoryBrowser.HistoryBrowserEvent event)
Fires the executePerformed event.
voidfireHistoryReset(HistoryBrowser.HistoryBrowserEvent event)
Fires the historyReset event.
voidfireRedoPerformed(HistoryBrowser.HistoryBrowserEvent event)
Fires the redoPerformed event.
voidfireUndoPerformed(HistoryBrowser.HistoryBrowserEvent event)
Fires the undoPerformed event.
StringgetLastRedoableCommandName()
Gets the last redoable command name.
StringgetLastUndoableCommandName()
Gets the last undoable command name.
intgetState()
Gets the state of this history browser.
voidredo()
Redoes the last 'undone' command.
voidresetHistory()
Clears the history array.
voidsetCommandController(HistoryBrowser.CommandController newCommandController)
Sets the commandController.
protected voidsetHistorySize(int size)
Setter for the history size.
voidundo()
Undoes the last executed or 'redone' command.

Field Detail

commandController

protected HistoryBrowser.CommandController commandController
Tells the history browser how to execute, undo and redo the commands. Wraps the execute, undo and redo methods

currentCommandIndex

protected int currentCommandIndex
Current command pointer in history array.

eventListeners

protected EventListenerList eventListeners
Listeners list.

EXECUTING

public static final int EXECUTING
The history browser is executing the command(s).

history

protected ArrayList history
Command history.

historySize

protected int historySize
History size.

IDLE

public static final int IDLE
The history browser is in idle state - no command is being executed, undone or redone.

REDOING

public static final int REDOING
The history browser is redoing the command(s).

state

protected int state
The current state of the history browser.

UNDOING

public static final int UNDOING
The history browser is undoing the command(s).

Constructor Detail

HistoryBrowser

public HistoryBrowser(HistoryBrowser.CommandController commandController)
Constructor.

HistoryBrowser

public HistoryBrowser(int historySize)
Constructor.

Parameters: historySize History size

Method Detail

addCommand

public void addCommand(UndoableCommand command)
Adds the given command to history array and executes it.

Parameters: command The given command

addListener

public void addListener(HistoryBrowser.HistoryBrowserListener listener)
Adds the listener to the listener list.

Parameters: listener The listener to add

compoundRedo

public void compoundRedo(int redoNumber)
Performs redo action the given number of times.

Parameters: redoNumber The given number of redo actions to perform

compoundUndo

public void compoundUndo(int undoNumber)
Performs undo action the given number of times.

Parameters: undoNumber The given number of undo actions to perform

fireCompoundEditPerformed

public void fireCompoundEditPerformed(HistoryBrowser.HistoryBrowserEvent event)
Fires the compoundEditPerformed event.

Parameters: event The associated HistoryBrowserEvent event

fireDoCompoundEdit

public void fireDoCompoundEdit(HistoryBrowser.HistoryBrowserEvent event)
Fires the doCompoundEdit event.

Parameters: event The associated HistoryBrowserEvent event

fireExecutePerformed

public void fireExecutePerformed(HistoryBrowser.HistoryBrowserEvent event)
Fires the executePerformed event.

Parameters: event The associated HistoryBrowserEvent event

fireHistoryReset

public void fireHistoryReset(HistoryBrowser.HistoryBrowserEvent event)
Fires the historyReset event.

Parameters: event The associated HistoryBrowserEvent event

fireRedoPerformed

public void fireRedoPerformed(HistoryBrowser.HistoryBrowserEvent event)
Fires the redoPerformed event.

Parameters: event The associated HistoryBrowserEvent event

fireUndoPerformed

public void fireUndoPerformed(HistoryBrowser.HistoryBrowserEvent event)
Fires the undoPerformed event.

Parameters: event The associated HistoryBrowserEvent event

getLastRedoableCommandName

public String getLastRedoableCommandName()
Gets the last redoable command name.

Returns: String or "" if there's no any

getLastUndoableCommandName

public String getLastUndoableCommandName()
Gets the last undoable command name.

Returns: String or "" if there's no any

getState

public int getState()
Gets the state of this history browser.

Returns: the state

redo

public void redo()
Redoes the last 'undone' command.

resetHistory

public void resetHistory()
Clears the history array.

setCommandController

public void setCommandController(HistoryBrowser.CommandController newCommandController)
Sets the commandController.

Parameters: newCommandController The newCommandController to set

setHistorySize

protected void setHistorySize(int size)
Setter for the history size.

Parameters: size New history size

undo

public void undo()
Undoes the last executed or 'redone' command.
Copyright B) 2008 Apache Software Foundation. All Rights Reserved.