Package org.eclipse.ltk.core.refactoring
Class TextEditBasedChange
java.lang.Object
org.eclipse.ltk.core.refactoring.Change
org.eclipse.ltk.core.refactoring.TextEditBasedChange
- All Implemented Interfaces:
IAdaptable
- Direct Known Subclasses:
MultiStateTextFileChange,TextChange
An abstract base implementation of a change which is based on text edits.
- Since:
- 3.2
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTextEditBasedChange(String name) Creates a new abstract text edit change with the specified name. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds atext edit change group.voidaddTextEditGroup(TextEditGroup group) Adds atext edit group.final TextEditBasedChangeGroup[]Returns thetext edit change groupsmanaged by this buffer change.abstract StringReturns the current content of the document this text change is associated with.abstract StringgetCurrentContent(IRegion region, boolean expandRegionToFullLine, int surroundingLines, IProgressMonitor pm) Returns the current content of the text edit change clipped to a specific region.booleanReturns whether preview edits are remembered for further region tracking or not.getName()Returns the human readable name of this change.abstract StringReturns the preview content as a string.abstract StringgetPreviewContent(TextEditBasedChangeGroup[] changeGroups, IRegion region, boolean expandRegionToFullLine, int surroundingLines, IProgressMonitor pm) Returns a preview of the text edit change clipped to a specific region.Returns the text edit change's text type.booleanhasOneGroupCategory(List<GroupCategory> groupCategories) Returnstrueif the change has one of the given group categories.voidsetEnabled(boolean enabled) Sets whether this change is enabled or not.voidsetKeepPreviewEdits(boolean keep) Controls whether the text edit change should keep executed edits during preview generation.voidsetTextType(String type) Sets the text type.Methods inherited from class org.eclipse.ltk.core.refactoring.Change
dispose, getAdapter, getAffectedObjects, getDescriptor, getModifiedElement, getParent, initializeValidationData, isEnabled, isValid, perform, setEnabledShallow
-
Constructor Details
-
TextEditBasedChange
Creates a new abstract text edit change with the specified name. The name is a human-readable value that is displayed to users. The name does not need to be unique, but it must not benull.The text type of this text edit change is set to
txt.- Parameters:
name- the name of the text edit change- See Also:
-
-
Method Details
-
addChangeGroup
Adds atext edit change group. The edits managed by the given text edit change group must be part of the change's root edit.- Parameters:
group- the text edit change group to add
-
addTextEditGroup
Adds atext edit group. This method is a convenience method for callingchange.addChangeGroup(new TextEditBasedChangeGroup(change, group));.- Parameters:
group- the text edit group to add
-
hasOneGroupCategory
Returnstrueif the change has one of the given group categories. Otherwisefalseis returned.- Parameters:
groupCategories- the group categories to check- Returns:
- whether the change has one of the given group categories
- Since:
- 3.2
-
getChangeGroups
Returns thetext edit change groupsmanaged by this buffer change.- Returns:
- the text edit change groups
-
getCurrentContent
Returns the current content of the document this text change is associated with.- Parameters:
pm- a progress monitor to report progress ornullif no progress reporting is desired- Returns:
- the current content of the text edit change
- Throws:
CoreException- if the content can't be accessed
-
getCurrentContent
public abstract String getCurrentContent(IRegion region, boolean expandRegionToFullLine, int surroundingLines, IProgressMonitor pm) throws CoreException Returns the current content of the text edit change clipped to a specific region. The region is determined as follows:- if
expandRegionToFullLineisfalsethen the parameterregiondetermines the clipping. - if
expandRegionToFullLineistruethen the region determined by the parameterregionis extended to cover full lines. - if
surroundingLines> 0 then the given number of surrounding lines is added. The value ofsurroundingLinesis only considered ifexpandRegionToFullLineistrue
- Parameters:
region- the starting region for the text to be returnedexpandRegionToFullLine- iftrueis passed the region is extended to cover full linessurroundingLines- the number of surrounding lines to be added to the clipping region. Is only considered ifexpandRegionToFullLineistruepm- a progress monitor to report progress ornullif no progress reporting is desired- Returns:
- the current content of the text edit change clipped to a region determined by the given parameters.
- Throws:
CoreException- if an exception occurs while accessing the current content
- if
-
getKeepPreviewEdits
public boolean getKeepPreviewEdits()Returns whether preview edits are remembered for further region tracking or not.- Returns:
trueif executed text edits are remembered during preview generation; otherwisefalse
-
getName
Description copied from class:ChangeReturns the human readable name of this change. The name MUST not benull. -
getPreviewContent
public abstract String getPreviewContent(TextEditBasedChangeGroup[] changeGroups, IRegion region, boolean expandRegionToFullLine, int surroundingLines, IProgressMonitor pm) throws CoreException Returns a preview of the text edit change clipped to a specific region. The preview is created by applying the text edits managed by the given array oftext edit change groups. The region is determined as follows:- if
expandRegionToFullLineisfalsethen the parameterregiondetermines the clipping. - if
expandRegionToFullLineistruethen the region determined by the parameterregionis extended to cover full lines. - if
surroundingLines> 0 then the given number of surrounding lines is added. The value ofsurroundingLinesis only considered ifexpandRegionToFullLineistrue
- Parameters:
changeGroups- a set of change groups for which a preview is to be generatedregion- the starting region for the clippingexpandRegionToFullLine- iftrueis passed the region is extended to cover full linessurroundingLines- the number of surrounding lines to be added to the clipping region. Is only considered ifexpandRegionToFullLineistruepm- a progress monitor to report progress ornullif no progress reporting is desired- Returns:
- the current content of the text change clipped to a region determined by the given parameters.
- Throws:
CoreException- if an exception occurs while generating the preview- See Also:
- if
-
getPreviewContent
Returns the preview content as a string.- Parameters:
pm- a progress monitor to report progress ornullif no progress reporting is desired- Returns:
- the preview
- Throws:
CoreException- if the preview can't be created
-
getTextType
Returns the text edit change's text type.- Returns:
- the text edit change's text type
-
setEnabled
public void setEnabled(boolean enabled) Description copied from class:ChangeSets whether this change is enabled or not.- Overrides:
setEnabledin classChange- Parameters:
enabled-trueto enable this change;falseotherwise
-
setKeepPreviewEdits
public void setKeepPreviewEdits(boolean keep) Controls whether the text edit change should keep executed edits during preview generation.- Parameters:
keep- iftrueexecuted preview edits are kept
-
setTextType
Sets the text type. The text type is used to determine the content merge viewer used to present the difference between the original and the preview content in the user interface. Content merge viewers are defined via the extension pointorg.eclipse.compare.contentMergeViewers.The default text type is
txt.- Parameters:
type- the text type. Ifnullis passed the text type is reseted to the default text typetxt.
-