Class JJazzUndoManager
- All Implemented Interfaces:
Serializable,EventListener,UndoableEditListener,UndoableEdit,org.openide.awt.UndoRedo
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceListener for JJazzLab user-level undoable edits.Nested classes/interfaces inherited from interface org.openide.awt.UndoRedo
org.openide.awt.UndoRedo.Empty, org.openide.awt.UndoRedo.Manager, org.openide.awt.UndoRedo.Provider -
Field Summary
Fields inherited from interface org.openide.awt.UndoRedo
NONE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidabortCEdit(String cEditName, String errMsg) Abort a compound edit started with startCEdit() in the middle: some SimpleEdits have been done but not all of them (endCEdit() was not called).voidAdd a change listener.booleanaddEdit(UndoableEdit anEdit) Overridden for enabled state management.voidvoidDiscard all the existing edits from the undomanager.booleanEnd a JJazzLab high-level compound edit.voidNotify listeners of a state change.The name of the current compound edit.Get a human-presentable name describing the redo operation.Get a human-presentable name describing the undo operation.booleanCheck if this instance is enabled.booleanvoidCall die on next edit to be redone (if there is one).voidredo()Redo a previously undone edit.voidRemove a change listener.voidvoidsetEnabled(boolean enabled) Enable or disable this instance.voidstartCEdit(Object source, String editName) Start a JJazzLab high-level compound edit.voidstartCEdit(String editName) Start a JJazzLab high-level compound edit with a null source object.toString()voidundo()Undo an edit.voidConsume an undoable edit (if the instance is enabled).voidMethods inherited from class javax.swing.undo.UndoManager
canRedo, canUndo, canUndoOrRedo, end, getLimit, getUndoOrRedoPresentationName, setLimitMethods inherited from class javax.swing.undo.CompoundEdit
die, getPresentationName, isInProgress, isSignificantMethods inherited from class javax.swing.undo.AbstractUndoableEdit
replaceEditMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.openide.awt.UndoRedo
canRedo, canUndo
-
Constructor Details
-
JJazzUndoManager
public JJazzUndoManager() -
JJazzUndoManager
- Parameters:
name- Used for debug purpose, returned by toString()
-
-
Method Details
-
isUndoRedoInProgress
public boolean isUndoRedoInProgress() -
addUserEditListener
-
removeUserEditListener
-
startCEdit
Start a JJazzLab high-level compound edit with a null source object.- Parameters:
editName- Name of the edit
-
startCEdit
-
getCurrentCEditName
The name of the current compound edit.- Returns:
- Can be null if not current edit
- See Also:
-
endCEdit
End a JJazzLab high-level compound edit.Notify the UserEditListeners.
- Returns:
- true if the compound edit was non empty.
-
addEdit
Overridden for enabled state management.- Specified by:
addEditin interfaceUndoableEdit- Overrides:
addEditin classUndoManager
-
isEnabled
public boolean isEnabled()Check if this instance is enabled.- Returns:
- True by default
- See Also:
-
setEnabled
public void setEnabled(boolean enabled) Enable or disable this instance.If disabled no new edit can be added (either via addEdit() or undoableEditHappened()).
NOTE: Model must NOT be changed while the associated JJazzUndoManager is disabled.
- Parameters:
enabled-- Throws:
IllegalStateException- If an undo is in progress- See Also:
-
undoableEditHappened
Consume an undoable edit (if the instance is enabled).Delegates to superclass and notifies listeners.
- Specified by:
undoableEditHappenedin interfaceUndoableEditListener- Overrides:
undoableEditHappenedin classUndoManager- Parameters:
ue- the edit
-
discardAllEdits
public void discardAllEdits()Discard all the existing edits from the undomanager.- Overrides:
discardAllEditsin classUndoManager
-
undo
Description copied from interface:org.openide.awt.UndoRedoUndo an edit.- Specified by:
undoin interfaceUndoableEdit- Specified by:
undoin interfaceorg.openide.awt.UndoRedo- Overrides:
undoin classUndoManager- Throws:
CannotUndoException- if it fails
-
redo
Description copied from interface:org.openide.awt.UndoRedoRedo a previously undone edit.- Specified by:
redoin interfaceUndoableEdit- Specified by:
redoin interfaceorg.openide.awt.UndoRedo- Overrides:
redoin classUndoManager- Throws:
CannotRedoException- if it fails
-
undoOrRedo
- Overrides:
undoOrRedoin classUndoManager- Throws:
CannotRedoExceptionCannotUndoException
-
killNextEditToBeRedone
public void killNextEditToBeRedone()Call die on next edit to be redone (if there is one). -
abortCEdit
Abort a compound edit started with startCEdit() in the middle: some SimpleEdits have been done but not all of them (endCEdit() was not called).The method will :
0/ Possibly show a dialog to notify user with errMsg.
1/ Call endCEdit() on cEditName to terminate properly the compound edit.
Because an exception might have occured some SimpleEdits may be missing in the CEdit (compared to normal).If compound edit is not empty:
2/ Call undo()
This will roll back the CEdit eEditName, ie undo each of the collected simple edits before the exception occured.3/ Remove CEdit cEditName from the undomanager, so that it can't be redone.
- Parameters:
cEditName- The aborted edit name used with startCEdit()errMsg- Error message to notify user. If null user is not notified.
-
fireChange
public void fireChange()Notify listeners of a state change. -
addChangeListener
Description copied from interface:org.openide.awt.UndoRedoAdd a change listener. The listener will be notified every time the undo/redo ability of this object changes.- Specified by:
addChangeListenerin interfaceorg.openide.awt.UndoRedo- Parameters:
l- the listener to add
-
removeChangeListener
Description copied from interface:org.openide.awt.UndoRedoRemove a change listener.- Specified by:
removeChangeListenerin interfaceorg.openide.awt.UndoRedo- Parameters:
l- the listener to remove- See Also:
-
getUndoPresentationName
Description copied from interface:org.openide.awt.UndoRedoGet a human-presentable name describing the undo operation.- Specified by:
getUndoPresentationNamein interfaceUndoableEdit- Specified by:
getUndoPresentationNamein interfaceorg.openide.awt.UndoRedo- Overrides:
getUndoPresentationNamein classUndoManager- Returns:
- the name
-
getRedoPresentationName
Description copied from interface:org.openide.awt.UndoRedoGet a human-presentable name describing the redo operation.- Specified by:
getRedoPresentationNamein interfaceUndoableEdit- Specified by:
getRedoPresentationNamein interfaceorg.openide.awt.UndoRedo- Overrides:
getRedoPresentationNamein classUndoManager- Returns:
- the name
-
toString
- Overrides:
toStringin classUndoManager
-