|
Eclipse JDT Release 3.0 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.eclipse.ltk.core.refactoring.Change
org.eclipse.ltk.core.refactoring.TextChange
org.eclipse.ltk.core.refactoring.TextFileChange
A special TextChange that operates on a IFile.
The class should be subclassed by clients which need to perform special operation when acquiring or releasing a document.
| Field Summary | |
static int |
FORCE_SAVE
Flag (value 2) indicating that the file is to be saved after the change has been applied. |
static int |
KEEP_SAVE_STATE
Flag (value 1) indicating that the file's save state has to be kept. |
static int |
LEAVE_DIRTY
Flag (value 4) indicating that the file will not be saved after the change has been applied. |
| Constructor Summary | |
TextFileChange(String name,
org.eclipse.core.resources.IFile file)
Creates a new TextFileChange for the given file. |
|
| Method Summary | |
protected org.eclipse.jface.text.IDocument |
acquireDocument(org.eclipse.core.runtime.IProgressMonitor pm)
Acquires a reference to the document to be changed by this text change. A document acquired by this call MUST be released via a call to TextChange.releaseDocument(IDocument, IProgressMonitor).
The method |
protected void |
commit(org.eclipse.jface.text.IDocument document,
org.eclipse.core.runtime.IProgressMonitor pm)
Commits the document acquired via a call to aquireDocument. It is up to the implementors of this method to decide what committing
a document means. Typically, the content of the document is written back to the file
system. |
protected Change |
createUndoChange(org.eclipse.text.edits.UndoEdit edit)
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. |
protected Change |
createUndoChange(org.eclipse.text.edits.UndoEdit edit,
ContentStamp stampToRestore)
Hook to create an undo change for the given undo edit and content stamp. |
void |
dispose()
Disposes this change. Subclasses that override this method typically unregister listeners which got registered during the call to
initializeValidationState.
Subclasses may override this method. |
org.eclipse.core.resources.IFile |
getFile()
Returns the IFile this change is working on. |
Object |
getModifiedElement()
Returns the element modified by this Change. The method may return
null if the change isn't related to an element. |
int |
getSaveMode()
Returns the save state set via setSaveMode(int). |
void |
initializeValidationData(org.eclipse.core.runtime.IProgressMonitor pm)
Hook method to initialize some internal state to provide an adequate answer for the 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:
For example, a change object that manipulates the content of an |
RefactoringStatus |
isValid(org.eclipse.core.runtime.IProgressMonitor pm)
Verifies that this change object is still valid and can be executed by calling 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 |
protected void |
releaseDocument(org.eclipse.jface.text.IDocument document,
org.eclipse.core.runtime.IProgressMonitor pm)
Releases the document acquired via a call to aquireDocument. |
void |
setSaveMode(int saveMode)
Sets the save state. |
| Methods inherited from class org.eclipse.ltk.core.refactoring.TextChange |
addTextEditChangeGroup, addTextEditGroup, getCurrentContent, getCurrentContent, getCurrentDocument, getEdit, getKeepPreviewEdits, getName, getPreviewContent, getPreviewContent, getPreviewDocument, getPreviewEdit, getPreviewEdits, getTextEditChangeGroups, getTextType, perform, setEdit, setEnabled, setKeepPreviewEdits, setTextType |
| Methods inherited from class org.eclipse.ltk.core.refactoring.Change |
getAdapter, getParent, isEnabled |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int KEEP_SAVE_STATE
public static final int FORCE_SAVE
public static final int LEAVE_DIRTY
| Constructor Detail |
public TextFileChange(String name,
org.eclipse.core.resources.IFile file)
TextFileChange for the given file.
name - the change's name mainly used to render the change in the UIfile - the file this text change operates on| Method Detail |
public void setSaveMode(int saveMode)
KEEP_SAVE_STATE,
FORCE_SAVE or LEAVE_DIRTY.
saveMode - indicating how save is handled when the document
gets committedpublic int getSaveMode()
setSaveMode(int).
public org.eclipse.core.resources.IFile getFile()
IFile this change is working on.
protected Change createUndoChange(org.eclipse.text.edits.UndoEdit edit,
ContentStamp stampToRestore)
edit - the UndoEdit to create an undo change forstampToRestore - the content stamp to restore when the undo
edit is executed.
null if no undo change can
be created. Returning null results in the fact that
the whole change tree can't be undone. So returning null
is only recommended if an exception occurred during creating the
undo change.public Object getModifiedElement()
Change. The method may return
null if the change isn't related to an element.
getModifiedElement in class Changepublic void initializeValidationData(org.eclipse.core.runtime.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 monitor
public RefactoringStatus isValid(org.eclipse.core.runtime.IProgressMonitor pm)
throws org.eclipse.core.runtime.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.
org.eclipse.core.runtime.CoreException - if an error occurred during validation check. The change
is to be treated as invalid if an exception occurspublic void dispose()
initializeValidationState.
Subclasses may override this method.
dispose in class Change
protected org.eclipse.jface.text.IDocument acquireDocument(org.eclipse.core.runtime.IProgressMonitor pm)
throws org.eclipse.core.runtime.CoreException
TextChange.releaseDocument(IDocument, IProgressMonitor).
The method releaseDocument must be call as many times as
aquireDocument has been called.
acquireDocument in class TextChangepm - a progress monitor
org.eclipse.core.runtime.CoreException - if the document can't be acquired
protected void commit(org.eclipse.jface.text.IDocument document,
org.eclipse.core.runtime.IProgressMonitor pm)
throws org.eclipse.core.runtime.CoreException
aquireDocument. It is up to the implementors of this method to decide what committing
a document means. Typically, the content of the document is written back to the file
system.
commit in class TextChangedocument - the document to commitpm - a progress monitor
org.eclipse.core.runtime.CoreException - if the document can't be committed
protected void releaseDocument(org.eclipse.jface.text.IDocument document,
org.eclipse.core.runtime.IProgressMonitor pm)
throws org.eclipse.core.runtime.CoreException
aquireDocument.
releaseDocument in class TextChangedocument - the document to releasepm - a progress monitor
org.eclipse.core.runtime.CoreException - if the document can't be releasedprotected final Change createUndoChange(org.eclipse.text.edits.UndoEdit edit)
createUndoChange in class TextChangeedit - the UndoEdit to create an undo change for
null if no undo change can
be created. Returning null results in the fact that
the whole change tree can't be undone. So returning null
is only recommended if an exception occurred during creating the
undo change.
|
Eclipse JDT Release 3.0 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||