public class UndoTextFileChange extends Change
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.
| Modifier | Constructor and Description |
|---|---|
protected |
UndoTextFileChange(String name,
IFile file,
UndoEdit undo,
ContentStamp stamp,
int saveMode)
Create a new undo text file change object.
|
| Modifier and Type | Method and Description |
|---|---|
protected Change |
createUndoChange(UndoEdit edit,
ContentStamp stampToRestore)
Hook to create an undo change for the given undo edit.
|
void |
dispose()
Disposes this change.
|
Object[] |
getAffectedObjects()
Returns the elements affected by this change or
null if
the affected elements cannot be determined. |
Object |
getModifiedElement()
Returns the element modified by this
Change. |
String |
getName()
Returns the human readable name of this change.
|
int |
getSaveMode()
Returns the change's save mode.
|
void |
initializeValidationData(IProgressMonitor pm)
Hook method to initialize some internal state to provide an adequate answer
for the
isValid method. |
RefactoringStatus |
isValid(IProgressMonitor pm)
Verifies that this change object is still valid and can be executed by calling
perform. |
Change |
perform(IProgressMonitor pm)
Performs this change.
|
getAdapter, getDescriptor, getParent, isEnabled, setEnabled, setEnabledShallowprotected UndoTextFileChange(String name, IFile file, UndoEdit undo, ContentStamp stamp, int saveMode)
name - the human readable name of the changefile - the file the change is working onstamp - the content stamp to restore when the undo is executedundo - the edit representing the undo modificationssaveMode - the save mode as specified by TextFileChangeTextFileChange.KEEP_SAVE_STATE,
TextFileChange.FORCE_SAVE,
TextFileChange.LEAVE_DIRTYpublic int getSaveMode()
TextFileChange.KEEP_SAVE_STATE,
TextFileChange.FORCE_SAVE,
TextFileChange.LEAVE_DIRTYpublic String getName()
null.protected Change createUndoChange(UndoEdit edit, ContentStamp stampToRestore) throws CoreException
Subclasses may override it to create a different undo change.
edit - the undo edit to create a undo change forstampToRestore - the content stamp to restore when the undo
edit is executed.CoreException - if an undo change can't be createdpublic Object getModifiedElement()
Change. The method may return
null if the change isn't related to an element.getModifiedElement in class Changepublic Object[] getAffectedObjects()
null if
the affected elements cannot be determined. Returns an empty array
if the change doesn't modify any elements.
This default implementation returns null to indicate that
the affected elements are unknown. Subclasses should reimplement this method
if they can compute the set of affected elements.
getAffectedObjects in class Changenull if
the affected elements cannot be determinedpublic void initializeValidationData(IProgressMonitor pm)
isValid method. 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:
dispose.isValid is called.
For example, a change object that manipulates the content of an IFile
could 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
when isValid is called.
initializeValidationData in class Changepm - a progress monitorpublic RefactoringStatus isValid(IProgressMonitor pm) throws CoreException
perform. If a refactoring status with a severity of RefactoringStatus.FATAL is 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 UndoManager to decide if
an undo or redo change is still valid and therefore can be executed.
isValid in class Changepm - a progress monitor.CoreException - if an error occurred during validation check. The change
is to be treated as invalid if an exception occurspublic Change perform(IProgressMonitor pm) throws CoreException
IProgressMonitor.isCanceled() since canceling a change tree in the
middle of its execution leaves the workspace in a half changed state.perform in class Changepm - a progress monitornull if no
undo is providedCoreException - if an error occurred during change executionGuidelines for using Eclipse APIs. Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.