Class JJazzUndoManager
- All Implemented Interfaces:
Serializable
,EventListener
,UndoableEditListener
,UndoableEdit
,org.openide.awt.UndoRedo
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Listener 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
addEdit
(UndoableEdit anEdit) Overridden for enabled state management.void
void
Discard all the existing edits from the undomanager.boolean
End a JJazzLab high-level compound edit.void
Notify listeners of a state change.void
handleUnsupportedEditException
(String cEditName, String errMsg) Convenience method : the right way to handle UnsupportedEditException when catched by the highest level caller, ie the one who called startCEdit() and should call endCEdit().boolean
Check if this instance is enabled.boolean
void
Call die on next edit to be redone (if there is one).void
redo()
void
void
void
setEnabled
(boolean enabled) Enable or disable this instance.void
startCEdit
(Object source, String editName) Start a JJazzLab high-level compound edit.void
startCEdit
(String editName) Start a JJazzLab high-level compound edit with a null source object.toString()
void
undo()
void
Consume an undoable edit (if the instance is enabled).void
Methods inherited from class javax.swing.undo.UndoManager
canRedo, canUndo, canUndoOrRedo, end, getLimit, getUndoOrRedoPresentationName, setLimit
Methods inherited from class javax.swing.undo.CompoundEdit
die, getPresentationName, isInProgress, isSignificant
Methods inherited from class javax.swing.undo.AbstractUndoableEdit
replaceEdit
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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
Start a JJazzLab high-level compound edit.- Parameters:
source
- The associated source object. Can be null.editName
- Name of the edit. Can't be null.
-
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:
addEdit
in interfaceUndoableEdit
- Overrides:
addEdit
in 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:
undoableEditHappened
in interfaceUndoableEditListener
- Overrides:
undoableEditHappened
in classUndoManager
- Parameters:
ue
- the edit
-
discardAllEdits
public void discardAllEdits()Discard all the existing edits from the undomanager.- Overrides:
discardAllEdits
in classUndoManager
-
undo
- Specified by:
undo
in interfaceUndoableEdit
- Specified by:
undo
in interfaceorg.openide.awt.UndoRedo
- Overrides:
undo
in classUndoManager
- Throws:
CannotUndoException
-
redo
- Specified by:
redo
in interfaceUndoableEdit
- Specified by:
redo
in interfaceorg.openide.awt.UndoRedo
- Overrides:
redo
in classUndoManager
- Throws:
CannotRedoException
-
undoOrRedo
- Overrides:
undoOrRedo
in classUndoManager
- Throws:
CannotRedoException
CannotUndoException
-
killNextEditToBeRedone
public void killNextEditToBeRedone()Call die on next edit to be redone (if there is one). -
handleUnsupportedEditException
Convenience method : the right way to handle UnsupportedEditException when catched by the highest level caller, ie the one who called startCEdit() and should call endCEdit().This method should be called first in the catch section.
1/ Call endCEdit() on cEditName to terminate properly the compound edit.
Because exception 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.
4/ Show a dialog to notify errMsg.
- Parameters:
cEditName
-errMsg
-
-
fireChange
public void fireChange()Notify listeners of a state change. -
addChangeListener
- Specified by:
addChangeListener
in interfaceorg.openide.awt.UndoRedo
-
removeChangeListener
- Specified by:
removeChangeListener
in interfaceorg.openide.awt.UndoRedo
-
getUndoPresentationName
- Specified by:
getUndoPresentationName
in interfaceUndoableEdit
- Specified by:
getUndoPresentationName
in interfaceorg.openide.awt.UndoRedo
- Overrides:
getUndoPresentationName
in classUndoManager
-
getRedoPresentationName
- Specified by:
getRedoPresentationName
in interfaceUndoableEdit
- Specified by:
getRedoPresentationName
in interfaceorg.openide.awt.UndoRedo
- Overrides:
getRedoPresentationName
in classUndoManager
-
toString
- Overrides:
toString
in classUndoManager
-