Class UndoTextFileChange
- All Implemented Interfaces:
IAdaptable
TextFileChange.
This class is not intended to be instantiated by clients. It is
usually created by a TextFileChange object.
The class should be subclassed by clients also subclassing
TextFileChange to provide a proper undo change object.
- Since:
- 3.0
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedUndoTextFileChange(String name, IFile file, UndoEdit undo, ContentStamp stamp, int saveMode) Create a new undo text file change object. -
Method Summary
Modifier and TypeMethodDescriptionprotected ChangecreateUndoChange(UndoEdit edit, ContentStamp stampToRestore) Hook to create an undo change for the given undo edit.voiddispose()Disposes this change.Object[]Returns the elements affected by this change ornullif the affected elements cannot be determined.Returns the element modified by thisChange.getName()Returns the human readable name of this change.intReturns the change's save mode.voidHook method to initialize some internal state to provide an adequate answer for theisValidmethod.Verifies that this change object is still valid and can be executed by callingperform.Performs this change.Methods inherited from class org.eclipse.ltk.core.refactoring.Change
getAdapter, getDescriptor, getParent, isEnabled, setEnabled, setEnabledShallow
-
Constructor Details
-
UndoTextFileChange
protected UndoTextFileChange(String name, IFile file, UndoEdit undo, ContentStamp stamp, int saveMode) Create a new undo text file change object.- Parameters:
name- the human readable name of the changefile- the file the change is working onundo- the edit representing the undo modificationsstamp- the content stamp to restore when the undo is executedsaveMode- the save mode as specified byTextFileChange- See Also:
-
-
Method Details
-
getSaveMode
public int getSaveMode()Returns the change's save mode.- Returns:
- the change's save mode
- See Also:
-
getName
Description copied from class:ChangeReturns the human readable name of this change. The name MUST not benull. -
createUndoChange
Hook to create an undo change for the given undo edit. This hook gets called while performing the change to construct the corresponding undo change object.Subclasses may override it to create a different undo change.
- Parameters:
edit- theundo editto create a undo change forstampToRestore- the content stamp to restore when the undo edit is executed.- Returns:
- the undo change
- Throws:
CoreException- if an undo change can't be created
-
getModifiedElement
Description copied from class:ChangeReturns the element modified by thisChange. The method may returnnullif the change isn't related to an element.- Specified by:
getModifiedElementin classChange- Returns:
- the element modified by this change
-
getAffectedObjects
Description copied from class:ChangeReturns the elements affected by this change ornullif the affected elements cannot be determined. Returns an empty array if the change doesn't modify any elements.This default implementation returns
nullto indicate that the affected elements are unknown. Subclasses should reimplement this method if they can compute the set of affected elements.- Overrides:
getAffectedObjectsin classChange- Returns:
- the elements affected by this change or
nullif the affected elements cannot be determined
-
initializeValidationData
Description copied from class:ChangeHook method to initialize some internal state to provide an adequate answer for theisValidmethod. This method gets called after a change or a whole change tree has been created.Typically this method is implemented in one of the following ways:
- the change hooks up a listener on some delta notification mechanism
and marks itself as invalid if it receives a certain delta. Is this
the case the implementor must take care of unhooking the listener
in
dispose. - the change remembers some information allowing to decide if a change
object is still valid when
isValidis called.
For example, a change object that manipulates the content of an
IFilecould either listen to resource changes and detect that the file got changed or it could remember some content stamp and compare it with the actual content stamp whenisValidis called.- Specified by:
initializeValidationDatain classChange- Parameters:
pm- a progress monitor
- the change hooks up a listener on some delta notification mechanism
and marks itself as invalid if it receives a certain delta. Is this
the case the implementor must take care of unhooking the listener
in
-
isValid
Description copied from class:ChangeVerifies that this change object is still valid and can be executed by callingperform. If a refactoring status with a severity ofRefactoringStatus.FATALis returned then the change has to be treated as invalid and can no longer be executed. Performing such a change produces an unspecified result and will very likely throw an exception.This method is also called by the
UndoManagerto decide if an undo or redo change is still valid and therefore can be executed.- Specified by:
isValidin classChange- Parameters:
pm- a progress monitor.- Returns:
- a refactoring status describing the outcome of the validation check
- Throws:
CoreException- if an error occurred during validation check. The change is to be treated as invalid if an exception occurs
-
perform
Description copied from class:ChangePerforms this change. If this method is called on an invalid or disabled change object the result is unspecified. Changes should in general not respond toIProgressMonitor.isCanceled()since canceling a change tree in the middle of its execution leaves the workspace in a half changed state.- Specified by:
performin classChange- Parameters:
pm- a progress monitor- Returns:
- the undo change for this change object or
nullif no undo is provided - Throws:
CoreException- if an error occurred during change execution
-
dispose
public void dispose()Description copied from class:ChangeDisposes this change. Subclasses that override this method typically unregister listeners which got registered during the call toinitializeValidationData.Subclasses may override this method.
-