Class AbstractDecoratedTextEditor

    • Field Detail

      • DEFAULT_OVERVIEW_RULER_CONTEXT_MENU_ID

        public static final String DEFAULT_OVERVIEW_RULER_CONTEXT_MENU_ID
        Menu id for the overview ruler context menu.
        Since:
        3.4
        See Also:
        Constant Field Values
      • fOverviewRuler

        protected IOverviewRuler fOverviewRuler
        The overview ruler of this editor.

        This field should not be referenced by subclasses. It is protected for API compatibility reasons and will be made private soon. Use getOverviewRuler() instead.

      • fAnnotationAccess

        protected IAnnotationAccess fAnnotationAccess
        Helper for accessing annotation from the perspective of this editor.

        This field should not be referenced by subclasses. It is protected for API compatibility reasons and will be made private soon. Use getAnnotationAccess() instead.

      • fLineNumberRulerColumn

        protected LineNumberRulerColumn fLineNumberRulerColumn
        The line number column.

        This field should not be referenced by subclasses. It is protected for API compatibility reasons and will be made private soon. Use AbstractTextEditor.getVerticalRuler() to access the vertical bar instead.

      • fIsUpdatingMarkerViews

        protected boolean fIsUpdatingMarkerViews
        Indicates whether this editor is updating views that show markers.
        Since:
        3.2
        See Also:
        updateMarkerViews(Annotation)
    • Method Detail

      • initializeEditor

        protected void initializeEditor()
        Initializes this editor. Subclasses may re-implement. If sub-classes do not change the contract, this method should not be extended, i.e. do not call super.initializeEditor() in order to avoid the temporary creation of objects that are immediately overwritten by subclasses.
      • initializeKeyBindingScopes

        protected void initializeKeyBindingScopes()
        Initializes the key binding scopes of this editor.
      • dispose

        public void dispose()
        Description copied from class: AbstractTextEditor
        The AbstractTextEditor implementation of this IWorkbenchPart method may be extended by subclasses. Subclasses must call super.dispose().

        Note that many methods may return null after the editor is disposed.

        Specified by:
        dispose in interface IWorkbenchPart
        Overrides:
        dispose in class AbstractTextEditor
      • createSourceViewer

        protected ISourceViewer createSourceViewer​(Composite parent,
                                                   IVerticalRuler ruler,
                                                   int styles)
        Description copied from class: AbstractTextEditor
        Creates the source viewer to be used by this editor. Subclasses may re-implement this method.
        Overrides:
        createSourceViewer in class AbstractTextEditor
        Parameters:
        parent - the parent control
        ruler - the vertical ruler
        styles - style bits, SWT.WRAP is currently not supported
        Returns:
        the source viewer
      • createAnnotationAccess

        protected IAnnotationAccess createAnnotationAccess()
        Creates the annotation access for this editor.
        Returns:
        the created annotation access
      • configureSourceViewerDecorationSupport

        protected void configureSourceViewerDecorationSupport​(SourceViewerDecorationSupport support)
        Configures the decoration support for this editor's source viewer. Subclasses may override this method, but should call their superclass' implementation at some point.
        Parameters:
        support - the decoration support to configure
      • createOverviewRulerContextMenu

        protected void createOverviewRulerContextMenu()
        Creates the context menu for the overview ruler.

        Subclasses may extend or replace this method.

        Since:
        3.4
      • createStatusControl

        protected Control createStatusControl​(Composite parent,
                                              IStatus status)
        Description copied from class: StatusTextEditor
        Creates the status control for the given status. May be overridden by subclasses.
        Overrides:
        createStatusControl in class StatusTextEditor
        Parameters:
        parent - the parent control
        status - the status
        Returns:
        the new status control
      • isOverviewRulerVisible

        protected boolean isOverviewRulerVisible()
        Tells whether the overview ruler is visible.
        Returns:
        whether the overview ruler is visible
      • isLineNumberRulerVisible

        protected boolean isLineNumberRulerVisible()
        Returns whether the line number ruler column should be visible according to the preference store settings. Subclasses may override this method to provide a custom preference setting.
        Returns:
        true if the line numbers should be visible
      • isOverwriteModeEnabled

        protected boolean isOverwriteModeEnabled()
        Returns whether the overwrite mode is enabled according to the preference store settings. Subclasses may override this method to provide a custom preference setting.
        Returns:
        true if overwrite mode is enabled
        Since:
        3.1
      • isPrefQuickDiffAlwaysOn

        protected boolean isPrefQuickDiffAlwaysOn()
        Returns whether quick diff info should be visible upon opening an editor according to the preference store settings.
        Returns:
        true if the line numbers should be visible
      • initializeLineNumberRulerColumn

        protected void initializeLineNumberRulerColumn​(LineNumberRulerColumn rulerColumn)
        Initializes the given line number ruler column from the preference store.
        Parameters:
        rulerColumn - the ruler column to be initialized
      • createLineNumberRulerColumn

        protected IVerticalRulerColumn createLineNumberRulerColumn()
        Creates a new line number ruler column that is appropriately initialized.
        Returns:
        the created line number column
      • createChangeHover

        protected LineChangeHover createChangeHover()
        Creates and returns a LineChangeHover to be used on this editor's change ruler column. This default implementation returns a plain LineChangeHover. Subclasses may override.
        Returns:
        the change hover to be used by this editors quick diff display
      • createChangeRulerColumn

        @Deprecated
        protected IChangeRulerColumn createChangeRulerColumn()
        Deprecated.
        as of 3.3. Not called any longer, replaced by createLineNumberRulerColumn()
        Creates a new change ruler column for quick diff display independent of the line number ruler column
        Returns:
        a new change ruler column
      • createCompositeRuler

        protected CompositeRuler createCompositeRuler()
        Creates a composite ruler to be used as the vertical ruler by this editor. Subclasses may re-implement this method.
        Returns:
        the vertical ruler
      • createAnnotationRulerColumn

        protected IVerticalRulerColumn createAnnotationRulerColumn​(CompositeRuler ruler)
        Creates the annotation ruler column. Subclasses may re-implement or extend.
        Parameters:
        ruler - the composite ruler that the column will be added
        Returns:
        an annotation ruler column
        Since:
        3.2
      • handlePreferenceStoreChanged

        protected void handlePreferenceStoreChanged​(PropertyChangeEvent event)
        Description copied from class: AbstractTextEditor
        Handles a property change event describing a change of the editor's preference store and updates the preference related editor properties.

        Subclasses may extend.

        Overrides:
        handlePreferenceStoreChanged in class AbstractTextEditor
        Parameters:
        event - the property change event
      • showOverviewRuler

        protected void showOverviewRuler()
        Shows the overview ruler.
      • hideOverviewRuler

        protected void hideOverviewRuler()
        Hides the overview ruler.
      • getAnnotationAccess

        protected IAnnotationAccess getAnnotationAccess()
        Returns the annotation access.
        Returns:
        the annotation access
      • getAnnotationPreferenceLookup

        protected AnnotationPreferenceLookup getAnnotationPreferenceLookup()
        Returns the annotation preference lookup.
        Returns:
        the annotation preference lookup
      • getOverviewRuler

        protected IOverviewRuler getOverviewRuler()
        Returns the overview ruler.
        Returns:
        the overview ruler
      • getSourceViewerDecorationSupport

        protected SourceViewerDecorationSupport getSourceViewerDecorationSupport​(ISourceViewer viewer)
        Returns the source viewer decoration support.
        Parameters:
        viewer - the viewer for which to return a decoration support
        Returns:
        the source viewer decoration support
      • getAnnotationPreferences

        protected MarkerAnnotationPreferences getAnnotationPreferences()
        Returns the annotation preferences.
        Returns:
        the annotation preferences
      • gotoMarker

        @Deprecated
        public void gotoMarker​(IMarker marker)
        Deprecated.
        visibility will be reduced, use getAdapter(IGotoMarker.class) for accessing this method
        If the editor can be saved all marker ranges have been changed according to the text manipulations. However, those changes are not yet propagated to the marker manager. Thus, when opening a marker, the marker's position in the editor must be determined as it might differ from the position stated in the marker.
        Parameters:
        marker - the marker to go to
      • isEditable

        public boolean isEditable()
        Description copied from interface: ITextEditor
        Returns whether the text in this text editor can be changed by the user.
        Specified by:
        isEditable in interface ITextEditor
        Overrides:
        isEditable in class AbstractTextEditor
        Returns:
        true if it can be edited, and false if it is read-only
      • isErrorStatus

        protected boolean isErrorStatus​(IStatus status)
        Description copied from class: StatusTextEditor
        Returns whether the given status indicates an error. Subclasses may override.
        Overrides:
        isErrorStatus in class StatusTextEditor
        Parameters:
        status - the status to be checked
        Returns:
        true if the status indicates an error, false otherwise\
      • createActions

        protected void createActions()
        Description copied from class: AbstractTextEditor
        Creates this editor's standard actions and connects them with the global workbench actions.

        Subclasses may extend.

        Overrides:
        createActions in class AbstractTextEditor
      • getAdapter

        public <T> T getAdapter​(Class<T> adapter)
        Description copied from class: WorkbenchPart
        Returns an object which is an instance of the given class associated with this object. Returns null if no such object can be found.

        Clients may implement this method but should generally call Adapters.adapt(Object, Class, boolean) rather than invoking it directly. Subclasses may override this method (however, if they do so, they should invoke the method on their superclass to ensure that the Platform's adapter manager is consulted).

        Specified by:
        getAdapter in interface IAdaptable
        Overrides:
        getAdapter in class AbstractTextEditor
        Type Parameters:
        T - the class type
        Parameters:
        adapter - the adapter class to look up
        Returns:
        a object of the given class, or null if this object does not have an adapter for the given class
      • setDocumentProvider

        protected void setDocumentProvider​(IEditorInput input)
        Description copied from class: AbstractTextEditor
        Hook method for setting the document provider for the given input. This default implementation does nothing. Clients may reimplement.
        Overrides:
        setDocumentProvider in class AbstractTextEditor
        Parameters:
        input - the input of this editor.
      • doSetInput

        protected void doSetInput​(IEditorInput input)
                           throws CoreException
        Description copied from class: AbstractTextEditor
        Called directly from setInput and from within a workspace runnable from init, this method does the actual setting of the editor input. Closes the editor if input is null. Disconnects from any previous editor input and its document provider and connects to the new one.

        Subclasses may extend.

        Overrides:
        doSetInput in class StatusTextEditor
        Parameters:
        input - the input to be set
        Throws:
        CoreException - if input cannot be connected to the document provider
      • performSaveAs

        protected void performSaveAs​(IProgressMonitor progressMonitor)
        This implementation asks the user for the workspace path of a file resource and saves the document there.
        Overrides:
        performSaveAs in class AbstractTextEditor
        Parameters:
        progressMonitor - the progress monitor to be used
        Since:
        3.2
      • openSaveErrorDialog

        protected void openSaveErrorDialog​(String title,
                                           String message,
                                           CoreException exception)
        Presents an error dialog to the user when a problem happens during save.

        Overrides the default behavior by showing a more advanced error dialog in case of encoding problems.

        Overrides:
        openSaveErrorDialog in class AbstractTextEditor
        Parameters:
        title - the dialog title
        message - the message to display
        exception - the exception to handle
        Since:
        3.6
      • setOverviewRulerContextMenuId

        protected void setOverviewRulerContextMenuId​(String contextMenuId)
        Sets the ruler's overview context menu id.
        Parameters:
        contextMenuId - the overview ruler context menu id
        Since:
        3.4
      • getOverviewRulerContextMenuId

        protected final String getOverviewRulerContextMenuId()
        Returns the ruler's overview context menu id. May return null before the editor's part has been created.
        Returns:
        the ruler's context menu id which may be null
        Since:
        3.4
      • overviewRulerContextMenuAboutToShow

        protected void overviewRulerContextMenuAboutToShow​(IMenuManager menu)
        Sets up the overview ruler context menu before it is made visible.

        Subclasses may extend to add other actions.

        Parameters:
        menu - the menu
        Since:
        3.4
      • createShowInTargetList

        protected String[] createShowInTargetList()
        Creates and returns the list of target part IDs for the Show In menu
        Returns:
        the 'Show In' target part IDs
        Since:
        3.13
      • collectContextMenuPreferencePages

        protected String[] collectContextMenuPreferencePages()
        Returns the preference page ids of the preference pages to be shown when executing the preferences action from the editor context menu. The first page will be selected.

        Subclasses may extend or replace.

        Returns:
        the preference page ids to show, may be empty
        Since:
        3.1
      • collectRulerMenuPreferencePages

        protected String[] collectRulerMenuPreferencePages()
        Returns the preference page ids of the preference pages to be shown when executing the preferences action from the editor ruler context menu. The first page will be selected.

        The default is to return the same list as collectContextMenuPreferencePages.

        Subclasses may extend or replace.

        Returns:
        the preference page ids to show, may be empty
        Since:
        3.1
      • collectOverviewRulerMenuPreferencePages

        protected String[] collectOverviewRulerMenuPreferencePages()
        Returns the preference page ids of the preference pages to be shown when executing the preferences action from the editor overview ruler context menu. The first page will be selected.

        The default is to select the 'Annotations' preference page.

        Subclasses may extend or replace.

        Returns:
        the preference page ids to show, may be empty
        Since:
        3.4
      • getUndoRedoOperationApprover

        protected IOperationApprover getUndoRedoOperationApprover​(IUndoContext undoContext)
        Description copied from class: AbstractTextEditor
        Return an IOperationApprover appropriate for approving the undo and redo of operations that have the specified undo context.

        Subclasses may override.

        Overrides:
        getUndoRedoOperationApprover in class AbstractTextEditor
        Parameters:
        undoContext - the IUndoContext of operations that should be examined by the operation approver
        Returns:
        the IOperationApprover appropriate for approving undo and redo operations inside this editor, or null if no approval is needed
      • isNavigationTarget

        protected boolean isNavigationTarget​(Annotation annotation)
        Returns whether the given annotation is configured as a target for the "Go to Next/Previous Annotation" actions.

        The annotation is a target if their annotation type is configured to be in the Next/Previous tool bar drop down menu and if it is checked.

        Overrides:
        isNavigationTarget in class AbstractTextEditor
        Parameters:
        annotation - the annotation
        Returns:
        true if this is a target, false otherwise
        Since:
        3.2
      • updateMarkerViews

        protected void updateMarkerViews​(Annotation annotation)
        Updates visible views that show markers.

        If the given annotation can be associated with a marker then this method tries select the this marker in views that show markers.

        Parameters:
        annotation - the annotation
        Since:
        3.2
      • isTabsToSpacesConversionEnabled

        protected boolean isTabsToSpacesConversionEnabled()
        Description copied from class: AbstractTextEditor
        Tells whether tabs should be converted to spaces while editing inside this editor.

        Subclasses may override this method.

        Overrides:
        isTabsToSpacesConversionEnabled in class AbstractTextEditor
        Returns:
        true if tabs should be converted to spaces