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 TypeMethodDescriptionvoidbooleanaddEdit(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.voidhandleUnsupportedEditException(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().booleanCheck if this instance is enabled.booleanvoidCall die on next edit to be redone (if there is one).voidredo()voidvoidvoidsetEnabled(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()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
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:
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
- Specified by:
undoin interfaceUndoableEdit- Specified by:
undoin interfaceorg.openide.awt.UndoRedo- Overrides:
undoin classUndoManager- Throws:
CannotUndoException
-
redo
- Specified by:
redoin interfaceUndoableEdit- Specified by:
redoin interfaceorg.openide.awt.UndoRedo- Overrides:
redoin classUndoManager- Throws:
CannotRedoException
-
undoOrRedo
- Overrides:
undoOrRedoin classUndoManager- Throws:
CannotRedoExceptionCannotUndoException
-
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:
addChangeListenerin interfaceorg.openide.awt.UndoRedo
-
removeChangeListener
- Specified by:
removeChangeListenerin interfaceorg.openide.awt.UndoRedo
-
getUndoPresentationName
- Specified by:
getUndoPresentationNamein interfaceUndoableEdit- Specified by:
getUndoPresentationNamein interfaceorg.openide.awt.UndoRedo- Overrides:
getUndoPresentationNamein classUndoManager
-
getRedoPresentationName
- Specified by:
getRedoPresentationNamein interfaceUndoableEdit- Specified by:
getRedoPresentationNamein interfaceorg.openide.awt.UndoRedo- Overrides:
getRedoPresentationNamein classUndoManager
-
toString
- Overrides:
toStringin classUndoManager
-