Class BmObjectTextContentChange<T extends org.eclipse.emf.ecore.EObject>

  • Type Parameters:
    T - class which attribute will be changed by this Change
    All Implemented Interfaces:
    IFullTextSearchChange, IProjectAwareChange, org.eclipse.core.runtime.IAdaptable

    public class BmObjectTextContentChange<T extends org.eclipse.emf.ecore.EObject>
    extends org.eclipse.ltk.core.refactoring.TextEditBasedChange
    implements IProjectAwareChange, IFullTextSearchChange
    TextEditBasedChange for text content attribute of EObject. Provides mechanism for show changes in text content in preview page
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.eclipse.text.edits.TextEdit edit
      TextEdits for change text content
      protected org.eclipse.emf.ecore.EStructuralFeature feature
      EStructuralFeature corresponding to the text content attribute
      protected T object
      Object with text content attribute
    • Constructor Summary

      Constructors 
      Constructor Description
      BmObjectTextContentChange​(String name, T object, org.eclipse.emf.ecore.EStructuralFeature feature, org.eclipse.text.edits.TextEdit edit)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addEdit​(org.eclipse.text.edits.TextEdit edit)
      Inserts the given edit into the change's edit tree.
      void addEdits​(org.eclipse.text.edits.TextEdit[] edits)
      Inserts the given edits into the change's edit tree.
      void addGroupedEdits​(org.eclipse.ltk.core.refactoring.TextEditBasedChangeGroup group)
      Inserts the edits of the given group into the change's edit tree and then adds the group itself to the change.
      void addGroupedEdits​(org.eclipse.text.edits.TextEditGroup group)
      Inserts the edits of the given group into the change's edit tree and then adds the group itself to the change.
      void dispose()  
      Object[] getAffectedObjects()  
      String getCurrentContent​(org.eclipse.core.runtime.IProgressMonitor pm)  
      String getCurrentContent​(org.eclipse.jface.text.IRegion region, boolean expandRegionToFullLine, int surroundingLines, org.eclipse.core.runtime.IProgressMonitor pm)  
      org.eclipse.text.edits.TextEdit getEdit()  
      Object getModifiedElement()  
      String getPreviewContent​(org.eclipse.core.runtime.IProgressMonitor pm)  
      String getPreviewContent​(org.eclipse.ltk.core.refactoring.TextEditBasedChangeGroup[] changeGroups, org.eclipse.jface.text.IRegion region, boolean expandRegionToFullLine, int surroundingLines, org.eclipse.core.runtime.IProgressMonitor pm)  
      org.eclipse.jface.text.IDocument getPreviewDocument​(org.eclipse.core.runtime.IProgressMonitor pm)
      Returns a document containing a preview of the text change.
      org.eclipse.text.edits.TextEdit getPreviewEdit​(org.eclipse.text.edits.TextEdit original)
      Returns the edit that got executed during preview generation instead of the given original.
      org.eclipse.text.edits.TextEdit[] getPreviewEdits​(org.eclipse.text.edits.TextEdit[] originals)
      Returns the edits that were executed during preview generation instead of the given array of original edits.
      String getProjectName()
      Gets name of the affected project
      void initializeValidationData​(org.eclipse.core.runtime.IProgressMonitor pm)  
      org.eclipse.ltk.core.refactoring.RefactoringStatus isValid​(org.eclipse.core.runtime.IProgressMonitor pm)  
      org.eclipse.ltk.core.refactoring.Change perform​(org.eclipse.core.runtime.IProgressMonitor pm)  
      void setKeepPreviewEdits​(boolean keep)  
      • 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, getDescriptor, getParent, isEnabled, setEnabledShallow
    • Field Detail

      • object

        protected T extends org.eclipse.emf.ecore.EObject object
        Object with text content attribute
      • feature

        protected org.eclipse.emf.ecore.EStructuralFeature feature
        EStructuralFeature corresponding to the text content attribute
      • edit

        protected org.eclipse.text.edits.TextEdit edit
        TextEdits for change text content
    • Constructor Detail

      • BmObjectTextContentChange

        public BmObjectTextContentChange​(String name,
                                         T object,
                                         org.eclipse.emf.ecore.EStructuralFeature feature,
                                         org.eclipse.text.edits.TextEdit edit)
        Constructor
        Parameters:
        name - name of the change, can't be null
        object - object which attribute will be changed by this Change, can't be null
        feature - EStructuralFeature corresponding to the changing text content, can't be null
        edit - TextEdit describes how text content will be changed, can't be null
    • Method Detail

      • getCurrentContent

        public String getCurrentContent​(org.eclipse.core.runtime.IProgressMonitor pm)
                                 throws org.eclipse.core.runtime.CoreException
        Specified by:
        getCurrentContent in class org.eclipse.ltk.core.refactoring.TextEditBasedChange
        Throws:
        org.eclipse.core.runtime.CoreException
      • getCurrentContent

        public String getCurrentContent​(org.eclipse.jface.text.IRegion region,
                                        boolean expandRegionToFullLine,
                                        int surroundingLines,
                                        org.eclipse.core.runtime.IProgressMonitor pm)
                                 throws org.eclipse.core.runtime.CoreException
        Specified by:
        getCurrentContent in class org.eclipse.ltk.core.refactoring.TextEditBasedChange
        Throws:
        org.eclipse.core.runtime.CoreException
      • getPreviewContent

        public String getPreviewContent​(org.eclipse.core.runtime.IProgressMonitor pm)
                                 throws org.eclipse.core.runtime.CoreException
        Specified by:
        getPreviewContent in class org.eclipse.ltk.core.refactoring.TextEditBasedChange
        Throws:
        org.eclipse.core.runtime.CoreException
      • setKeepPreviewEdits

        public void setKeepPreviewEdits​(boolean keep)
        Overrides:
        setKeepPreviewEdits in class org.eclipse.ltk.core.refactoring.TextEditBasedChange
      • getPreviewEdit

        public org.eclipse.text.edits.TextEdit getPreviewEdit​(org.eclipse.text.edits.TextEdit original)
        Returns the edit that got executed during preview generation instead of the given original. The method requires that setKeepPreviewEdits is set to true and that a preview has been requested via one of the getPreview* methods.

        The method returns null if the original isn't managed by this text change.

        Parameters:
        original - the original edit managed by this text change, can't be null
        Returns:
        the edit executed during preview generation, never null
      • getPreviewEdits

        public org.eclipse.text.edits.TextEdit[] getPreviewEdits​(org.eclipse.text.edits.TextEdit[] originals)
        Returns the edits that were executed during preview generation instead of the given array of original edits. The method requires that setKeepPreviewEdits is set to true and that a preview has been requested via one of the getPreview* methods.

        The method returns an empty array if none of the original edits is managed by this text change.

        Parameters:
        originals - an array of original edits managed by this text change, can't be null
        Returns:
        an array of edits containing the corresponding edits executed during preview generation, never null
      • getPreviewDocument

        public org.eclipse.jface.text.IDocument getPreviewDocument​(org.eclipse.core.runtime.IProgressMonitor pm)
                                                            throws org.eclipse.core.runtime.CoreException
        Returns a document containing a preview of the text change. The preview is computed by executing the all managed text edits. The method considers the active state of the added text edit change groups.
        Parameters:
        pm - a progress monitor to report progress or null if no progress reporting is desired, can't be null
        Returns:
        a document containing the preview of the text change, never null
        Throws:
        org.eclipse.core.runtime.CoreException - if the preview can't be created
      • getPreviewContent

        public String getPreviewContent​(org.eclipse.ltk.core.refactoring.TextEditBasedChangeGroup[] changeGroups,
                                        org.eclipse.jface.text.IRegion region,
                                        boolean expandRegionToFullLine,
                                        int surroundingLines,
                                        org.eclipse.core.runtime.IProgressMonitor pm)
                                 throws org.eclipse.core.runtime.CoreException
        Specified by:
        getPreviewContent in class org.eclipse.ltk.core.refactoring.TextEditBasedChange
        Throws:
        org.eclipse.core.runtime.CoreException
      • initializeValidationData

        public void initializeValidationData​(org.eclipse.core.runtime.IProgressMonitor pm)
        Specified by:
        initializeValidationData in class org.eclipse.ltk.core.refactoring.Change
      • isValid

        public org.eclipse.ltk.core.refactoring.RefactoringStatus isValid​(org.eclipse.core.runtime.IProgressMonitor pm)
                                                                   throws org.eclipse.core.runtime.CoreException,
                                                                          org.eclipse.core.runtime.OperationCanceledException
        Specified by:
        isValid in class org.eclipse.ltk.core.refactoring.Change
        Throws:
        org.eclipse.core.runtime.CoreException
        org.eclipse.core.runtime.OperationCanceledException
      • perform

        public org.eclipse.ltk.core.refactoring.Change perform​(org.eclipse.core.runtime.IProgressMonitor pm)
                                                        throws org.eclipse.core.runtime.CoreException
        Specified by:
        perform in class org.eclipse.ltk.core.refactoring.Change
        Throws:
        org.eclipse.core.runtime.CoreException
      • getModifiedElement

        public Object getModifiedElement()
        Specified by:
        getModifiedElement in class org.eclipse.ltk.core.refactoring.Change
      • getEdit

        public org.eclipse.text.edits.TextEdit getEdit()
        Returns:
        the root of the change's edit tree (never null)
      • addEdit

        public void addEdit​(org.eclipse.text.edits.TextEdit edit)
        Inserts the given edit into the change's edit tree.
        Parameters:
        edit - the edit to insert - must not be null
        Throws:
        org.eclipse.text.edits.MalformedTreeException - if edit can't be inserted
      • addEdits

        public void addEdits​(org.eclipse.text.edits.TextEdit[] edits)
        Inserts the given edits into the change's edit tree.
        Parameters:
        edits - the edits to insert - must not be null
        Throws:
        org.eclipse.text.edits.MalformedTreeException - if edits can't be inserted
      • addGroupedEdits

        public void addGroupedEdits​(org.eclipse.ltk.core.refactoring.TextEditBasedChangeGroup group)
        Inserts the edits of the given group into the change's edit tree and then adds the group itself to the change.
        Parameters:
        group - the group to add - must not be null
        Throws:
        org.eclipse.text.edits.MalformedTreeException - if edits can't be inserted
      • addGroupedEdits

        public void addGroupedEdits​(org.eclipse.text.edits.TextEditGroup group)
        Inserts the edits of the given group into the change's edit tree and then adds the group itself to the change.
        Parameters:
        group - the group to add - must not be null
        Throws:
        org.eclipse.text.edits.MalformedTreeException - if edits can't be inserted
      • dispose

        public void dispose()
        Overrides:
        dispose in class org.eclipse.ltk.core.refactoring.Change
      • getAffectedObjects

        public Object[] getAffectedObjects()
        Overrides:
        getAffectedObjects in class org.eclipse.ltk.core.refactoring.Change