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
public abstract class TextEditBasedChange extends Change
An abstract base implementation of a change which is based on text edits.- Since:
- 3.2
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTextEditBasedChange(String name)Creates a new abstract text edit change with the specified name.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddChangeGroup(TextEditBasedChangeGroup group)Adds atext edit change group.voidaddTextEditGroup(TextEditGroup group)Adds atext edit group.TextEditBasedChangeGroup[]getChangeGroups()Returns thetext edit change groupsmanaged by this buffer change.abstract StringgetCurrentContent(IProgressMonitor pm)Returns 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.booleangetKeepPreviewEdits()Returns whether preview edits are remembered for further region tracking or not.StringgetName()Returns the human readable name of this change.abstract StringgetPreviewContent(IProgressMonitor pm)Returns 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.StringgetTextType()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 Detail
-
TextEditBasedChange
protected TextEditBasedChange(String name)
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:
setTextType(String)
-
-
Method Detail
-
addChangeGroup
public void addChangeGroup(TextEditBasedChangeGroup group)
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
public void addTextEditGroup(TextEditGroup group)
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
public boolean hasOneGroupCategory(List<GroupCategory> groupCategories)
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
public final TextEditBasedChangeGroup[] getChangeGroups()
Returns thetext edit change groupsmanaged by this buffer change.- Returns:
- the text edit change groups
-
getCurrentContent
public abstract String getCurrentContent(IProgressMonitor pm) throws CoreException
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
public String 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:
getCurrentContent(IRegion, boolean, int, IProgressMonitor)
- if
-
getPreviewContent
public abstract String getPreviewContent(IProgressMonitor pm) throws CoreException
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
public String 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
public void setTextType(String type)
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.
-
-