|
Eclipse Platform Release 3.3 |
|||||||||||
| 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.TextEditBasedChange
org.eclipse.ltk.core.refactoring.MultiStateTextFileChange
A multi state text file change is a special change object that applies a sequence of text edit trees to a document. The multi state text file change manages the text edit trees.
A multi state text file change offers the ability to access the original content of
the document as well as creating a preview of the change. The edit
trees get copied when creating any kind of preview. Therefore no region
updating on the original edit trees takes place when requesting a preview
(for more information on region updating see class TextEdit.
If region tracking is required for a preview it can be enabled via a call
to the method setKeepPreviewEdits.
If enabled the multi state text file change keeps the copied edit trees executed for the
preview allowing clients to map an original edit to an executed edit. The
executed edit can then be used to determine its position in the preview.
| Constructor Summary | |
|---|---|
MultiStateTextFileChange(String name,
IFile file)
Creates a new composite text file change. |
|
| Method Summary | |
|---|---|
void |
addChange(TextChange change)
Adds a new text change to this composite change. |
void |
dispose()
Disposes this change. |
String |
getCurrentContent(IProgressMonitor monitor)
Returns the current content of the document this text change is associated with. |
String |
getCurrentContent(IRegion region,
boolean expand,
int surround,
IProgressMonitor monitor)
Returns the current content of the text edit change clipped to a specific region. |
IDocument |
getCurrentDocument(IProgressMonitor monitor)
Returns a document representing the current state of the buffer, prior to the application of the change. |
Object |
getModifiedElement()
Returns the element modified by this Change. |
String |
getPreviewContent(IProgressMonitor monitor)
Returns the preview content as a string. |
String |
getPreviewContent(TextEditBasedChangeGroup[] groups,
IRegion region,
boolean expand,
int surround,
IProgressMonitor monitor)
Returns a preview of the text edit change clipped to a specific region. |
IDocument |
getPreviewDocument(IProgressMonitor monitor)
Returns a document representing the preview of the refactored buffer, after the application of the change object. |
int |
getSaveMode()
Returns the save mode of this change. |
void |
initializeValidationData(IProgressMonitor monitor)
Hook method to initialize some internal state to provide an adequate answer for the isValid method. |
RefactoringStatus |
isValid(IProgressMonitor monitor)
Verifies that this change object is still valid and can be executed by calling perform. |
boolean |
needsSaving()
Does the change need saving? |
Change |
perform(IProgressMonitor monitor)
Performs this change. |
void |
setKeepPreviewEdits(boolean keep)
Controls whether the text edit change should keep executed edits during preview generation. |
void |
setSaveMode(int mode)
Sets the save mode. |
| Methods inherited from class org.eclipse.ltk.core.refactoring.TextEditBasedChange |
|---|
addChangeGroup, addTextEditGroup, getChangeGroups, getKeepPreviewEdits, getName, getTextType, hasOneGroupCategory, setEnabled, setTextType |
| Methods inherited from class org.eclipse.ltk.core.refactoring.Change |
|---|
getAdapter, getAffectedObjects, getDescriptor, getParent, isEnabled, setEnabledShallow |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public MultiStateTextFileChange(String name,
IFile file)
The default text type is txt.
name - the name of the composite text file changefile - the text file to apply the change to| Method Detail |
public final void addChange(TextChange change)
The text change which is added is not changed in any way. Rather the contents of the text change are retrieved and stored internally in this composite text change.
change - the text change to addpublic final void dispose()
Change
initializeValidationState.
Subclasses may override this method.
dispose in class Change
public final String getCurrentContent(IProgressMonitor monitor)
throws CoreException
TextEditBasedChange
getCurrentContent in class TextEditBasedChangemonitor - a progress monitor to report progress or null
if no progress reporting is desired
CoreException - if the content can't be accessed
public final String getCurrentContent(IRegion region,
boolean expand,
int surround,
IProgressMonitor monitor)
throws CoreException
TextEditBasedChangeexpandRegionToFullLine is false
then the parameter region determines the clipping.
expandRegionToFullLine is true
then the region determined by the parameter region
is extended to cover full lines.
surroundingLines > 0 then the given number
of surrounding lines is added. The value of surroundingLines
is only considered if expandRegionToFullLine
is true
getCurrentContent in class TextEditBasedChangeregion - the starting region for the text to be returnedexpand - if true is passed the region
is extended to cover full linessurround - the number of surrounding lines to be added to
the clipping region. Is only considered if expandRegionToFullLine
is truemonitor - a progress monitor to report progress or null
if no progress reporting is desired
CoreException - if an exception occurs while accessing the current content
public final IDocument getCurrentDocument(IProgressMonitor monitor)
throws CoreException
The returned document should not be modified.
monitor - the progress monitor to use, or null
CoreException - if no document could be acquiredpublic final Object getModifiedElement()
ChangeChange. The method may return
null if the change isn't related to an element.
getModifiedElement in class Change
public final String getPreviewContent(TextEditBasedChangeGroup[] groups,
IRegion region,
boolean expand,
int surround,
IProgressMonitor monitor)
throws CoreException
TextEditBasedChangetext edit change groups.
The region is determined as follows:
expandRegionToFullLine is false
then the parameter region determines the clipping.
expandRegionToFullLine is true
then the region determined by the parameter region
is extended to cover full lines.
surroundingLines > 0 then the given number
of surrounding lines is added. The value of surroundingLines
is only considered if expandRegionToFullLine
is true
getPreviewContent in class TextEditBasedChangegroups - a set of change groups for which a preview is to be
generatedregion - the starting region for the clippingexpand - if true is passed the region
is extended to cover full linessurround - the number of surrounding lines to be added to
the clipping region. Is only considered if expandRegionToFullLine
is truemonitor - a progress monitor to report progress or null
if no progress reporting is desired
CoreException - if an exception occurs while generating the previewTextEditBasedChange.getCurrentContent(IRegion, boolean, int, IProgressMonitor)
public final String getPreviewContent(IProgressMonitor monitor)
throws CoreException
TextEditBasedChange
getPreviewContent in class TextEditBasedChangemonitor - a progress monitor to report progress or null
if no progress reporting is desired
CoreException - if the preview can't be created
public final IDocument getPreviewDocument(IProgressMonitor monitor)
throws CoreException
monitor - the progress monitor to use, or null
CoreException - if no document could be acquiredpublic final int getSaveMode()
public final void initializeValidationData(IProgressMonitor monitor)
ChangeisValid 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 Changemonitor - a progress monitor
public final RefactoringStatus isValid(IProgressMonitor monitor)
throws CoreException,
OperationCanceledException
Changeperform. 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 Changemonitor - a progress monitor.
OperationCanceledException - if the validation check got canceled
CoreException - if an error occurred during validation check. The change
is to be treated as invalid if an exception occurspublic final boolean needsSaving()
true if it needs saving, false
otherwise
public final Change perform(IProgressMonitor monitor)
throws CoreException
ChangeIProgressMonitor.isCanceled() since canceling a change tree in the
middle of its execution leaves the workspace in a half changed state.
perform in class Changemonitor - a progress monitor
null if no
undo is provided
CoreException - if an error occurred during change executionpublic final void setKeepPreviewEdits(boolean keep)
TextEditBasedChange
setKeepPreviewEdits in class TextEditBasedChangekeep - if true executed preview edits are keptpublic final void setSaveMode(int mode)
mode - The mode to set
|
Eclipse Platform Release 3.3 |
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2000, 2007. All rights reserved.