Eclipse Platform
Release 3.0

org.eclipse.ui.texteditor
Class AbstractDecoratedTextEditor

java.lang.Object
  extended byorg.eclipse.ui.part.WorkbenchPart
      extended byorg.eclipse.ui.part.EditorPart
          extended byorg.eclipse.ui.texteditor.AbstractTextEditor
              extended byorg.eclipse.ui.texteditor.StatusTextEditor
                  extended byorg.eclipse.ui.texteditor.AbstractDecoratedTextEditor
All Implemented Interfaces:
IAdaptable, IEditorPart, IExecutableExtension, INavigationLocationProvider, IReusableEditor, ISaveablePart, ITextEditor, ITextEditorExtension, ITextEditorExtension2, ITextEditorExtension3, IWorkbenchPart, IWorkbenchPart2
Direct Known Subclasses:
TextEditor

public abstract class AbstractDecoratedTextEditor
extends StatusTextEditor

An intermediate editor comprising functionality not present in the leaner AbstractTextEditor, but used in many heavy weight (and especially source editing) editors, such as line numbers, change ruler, overview ruler, print margins, current line highlighting, etc.

Since:
3.0

Nested Class Summary
 
Nested classes inherited from class org.eclipse.ui.texteditor.AbstractTextEditor
AbstractTextEditor.AbstractSelectionChangedListener, AbstractTextEditor.LineStartAction
 
Nested classes inherited from class org.eclipse.ui.texteditor.ITextEditorExtension3
ITextEditorExtension3.InsertMode
 
Field Summary
protected  IAnnotationAccess fAnnotationAccess
          Helper for accessing annotation from the perspective of this editor.
protected  LineNumberRulerColumn fLineNumberRulerColumn
          The line number column.
protected  IOverviewRuler fOverviewRuler
          The overview ruler of this editor.
protected  SourceViewerDecorationSupport fSourceViewerDecorationSupport
          Helper for managing the decoration support of this editor's viewer.
 
Fields inherited from class org.eclipse.ui.texteditor.AbstractTextEditor
ACTION_MAP, DEFAULT_EDITOR_CONTEXT_MENU_ID, DEFAULT_RULER_CONTEXT_MENU_ID, fErrorLabel, PREFERENCE_COLOR_BACKGROUND, PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, PREFERENCE_COLOR_FIND_SCOPE, PREFERENCE_COLOR_FOREGROUND, PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, PREFERENCE_COLOR_SELECTION_BACKGROUND, PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT, PREFERENCE_COLOR_SELECTION_FOREGROUND, PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT, PREFERENCE_FONT, PREFERENCE_NAVIGATION_SMART_HOME_END, PREFERENCE_USE_CUSTOM_CARETS, PREFERENCE_WIDE_CARET, VERTICAL_RULER_WIDTH
 
Fields inherited from interface org.eclipse.ui.IEditorPart
PROP_DIRTY, PROP_INPUT
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Fields inherited from interface org.eclipse.ui.texteditor.ITextEditorExtension3
INSERT, SMART_INSERT
 
Constructor Summary
AbstractDecoratedTextEditor()
          Creates a new text editor.
 
Method Summary
protected  void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support)
          Configures the decoration support for this editor's source viewer.
protected  void createActions()
          Creates this editor's standard actions and connects them with the global workbench actions.
protected  IAnnotationAccess createAnnotationAccess()
          Creates the annotation access for this editor.
protected  LineChangeHover createChangeHover()
          Creates and returns a LineChangeHover to be used on this editor's change ruler column.
protected  IChangeRulerColumn createChangeRulerColumn()
          Creates a new change ruler column for quick diff display independent of the line number ruler column
protected  CompositeRuler createCompositeRuler()
          Creates a composite ruler to be used as the vertical ruler by this editor.
protected  IVerticalRulerColumn createLineNumberRulerColumn()
          Creates a new line number ruler column that is appropriately initialized.
protected  IOverviewRuler createOverviewRuler(ISharedTextColors sharedColors)
           
 void createPartControl(Composite parent)
          The AbstractTextEditor implementation of this IWorkbenchPart method creates the vertical ruler and source viewer.
protected  ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles)
          Creates the source viewer to be used by this editor.
protected  IVerticalRuler createVerticalRuler()
          Returns createCompositeRuler().
 void dispose()
          The AbstractTextEditor implementation of this IWorkbenchPart method may be extended by subclasses.
protected  void disposeDocumentProvider()
          Disposes of the connection with the document provider.
protected  void doSetInput(IEditorInput input)
          Called directly from setInput and from within a workspace runnable from init, this method does the actual setting of the editor input.
 Object getAdapter(Class adapter)
          Returns an object which is an instance of the given class associated with this object.
protected  IAnnotationAccess getAnnotationAccess()
          Returns the annotation access.
protected  AnnotationPreferenceLookup getAnnotationPreferenceLookup()
          Returns the annotation preference lookup.
protected  MarkerAnnotationPreferences getAnnotationPreferences()
          Returns the annotation preferences.
 IDocumentProvider getDocumentProvider()
          Returns this text editor's document provider.
protected  IOverviewRuler getOverviewRuler()
          Returns the overview ruler.
protected  ISharedTextColors getSharedColors()
           
protected  SourceViewerDecorationSupport getSourceViewerDecorationSupport(ISourceViewer viewer)
          Returns the source viewer decoration support.
 void gotoMarker(IMarker marker)
          Deprecated. visibility will be reduced, use getAdapter(IGotoMarker.class) for accessing this method
protected  void handlePreferenceStoreChanged(PropertyChangeEvent event)
          Handles a property change event describing a change of the editor's preference store and updates the preference related editor properties.
protected  void hideOverviewRuler()
          Hides the overview ruler.
protected  void initializeEditor()
          Initializes this editor.
protected  void initializeKeyBindingScopes()
          Initializes the key binding scopes of this editor.
protected  void initializeLineNumberRulerColumn(LineNumberRulerColumn rulerColumn)
          Initializes the given line number ruler column from the preference store.
 boolean isChangeInformationShowing()
          Returns the quick diff display state.
protected  boolean isErrorStatus(IStatus status)
          Returns whether the given status indicates an error.
protected  boolean isLineNumberRulerVisible()
          Returns whether the line number ruler column should be visible according to the preference store settings.
protected  boolean isOverviewRulerVisible()
          Tells whether the overview ruler is visible.
protected  boolean isPrefQuickDiffAlwaysOn()
          Returns whether quick diff info should be visible upon opening an editor according to the preference store settings.
protected  void setDocumentProvider(IEditorInput input)
          Hook method for setting the document provider for the given input.
 void showChangeInformation(boolean show)
          Sets the display of quick diff information.
protected  void showOverviewRuler()
          Shows the overview ruler.
 
Methods inherited from class org.eclipse.ui.texteditor.StatusTextEditor
createStatusControl, doRevertToSaved, getStatusBanner, getStatusHeader, getStatusMessage, sanityCheckState, updatePartControl, updateStatusField
 
Methods inherited from class org.eclipse.ui.texteditor.AbstractTextEditor
addAction, addAction, addGroup, addRulerContextMenuListener, adjustHighlightRange, affectsTextPresentation, canHandleMove, close, configureInsertMode, createEmptyNavigationLocation, createNavigationActions, createNavigationLocation, doGetSelection, doSave, doSaveAs, doSetSelection, editorContextMenuAboutToShow, editorSaved, enableOverwriteMode, enableSanityChecking, enableStateValidation, firePropertyChange, getAction, getContextMenuListener, getCoverage, getCursorListener, getCursorPosition, getEditorContextMenuId, getFontPropertyPreferenceKey, getHelpContextId, getHighlightRange, getInsertMode, getLegalInsertModes, getPreferenceStore, getProgressMonitor, getRangeIndicator, getRulerContextMenuId, getRulerMouseListener, getSelectionChangedListener, getSelectionProvider, getSourceViewer, getSourceViewerConfiguration, getStatusField, getVerticalRuler, handleCursorPositionChanged, handleEditorInputChanged, handleElementContentReplaced, handleExceptionOnSave, handleInsertModeChanged, init, initializeDragAndDrop, initializeViewerColors, internalInit, isDirty, isEditable, isEditorInputModifiable, isEditorInputReadOnly, isInInsertMode, isSaveAsAllowed, isSaveOnCloseNeeded, isVisible, markAsContentDependentAction, markAsPropertyDependentAction, markAsSelectionDependentAction, markAsStateDependentAction, markInNavigationHistory, modelOffset2WidgetOffset, performRevert, performSave, performSaveAs, rememberSelection, removeActionActivationCode, removeRulerContextMenuListener, resetHighlightRange, restoreSelection, rulerContextMenuAboutToShow, safelySanityCheckState, selectAndReveal, selectAndReveal, setAction, setActionActivationCode, setCompatibilityMode, setDocumentProvider, setEditorContextMenuId, setFocus, setHelpContextId, setHighlightRange, setInput, setInsertMode, setKeyBindingScopes, setPreferenceStore, setRangeIndicator, setRulerContextMenuId, setSourceViewerConfiguration, setStatusField, showHighlightRangeOnly, showsHighlightRangeOnly, updateContentDependentActions, updatePropertyDependentActions, updateSelectionDependentActions, updateState, updateStateDependentActions, updateStatusFields, validateEditorInputState, validateState, widgetOffset2ModelOffset
 
Methods inherited from class org.eclipse.ui.part.EditorPart
getEditorInput, getEditorSite, getTitleToolTip, setContentDescription, setInitializationData, setPartName
 
Methods inherited from class org.eclipse.ui.part.WorkbenchPart
addPropertyListener, getConfigurationElement, getContentDescription, getDefaultImage, getPartName, getSite, getTitle, getTitleImage, removePropertyListener, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.ui.IEditorPart
getEditorInput, getEditorSite
 
Methods inherited from interface org.eclipse.ui.IWorkbenchPart
addPropertyListener, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener
 

Field Detail

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.


fSourceViewerDecorationSupport

protected SourceViewerDecorationSupport fSourceViewerDecorationSupport
Helper for managing the decoration support of this editor's viewer.

This field should not be referenced by subclasses. It is protected for API compatibility reasons and will be made private soon. Use getSourceViewerDecorationSupport(ISourceViewer) 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.

Constructor Detail

AbstractDecoratedTextEditor

public AbstractDecoratedTextEditor()
Creates a new text editor.

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

getSharedColors

protected ISharedTextColors getSharedColors()

createOverviewRuler

protected IOverviewRuler createOverviewRuler(ISharedTextColors sharedColors)

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

createPartControl

public void createPartControl(Composite parent)
Description copied from class: AbstractTextEditor
The AbstractTextEditor implementation of this IWorkbenchPart method creates the vertical ruler and source viewer.

Subclasses may extend this method. Besides extending this method, the behavior of createPartControl may be customized by calling, extending or replacing the following methods:
Subclasses may supply customized implementations for some members using the following methods before createPartControl is invoked:


Subclasses may replace the following methods called from within createPartControl:
Subclasses may extend the following methods called from within createPartControl:

Specified by:
createPartControl in interface IWorkbenchPart
Overrides:
createPartControl in class StatusTextEditor

isOverviewRulerVisible

protected boolean isOverviewRulerVisible()
Tells whether the overview ruler is visible.

Returns:
whether the overview ruler is visible

showChangeInformation

public void showChangeInformation(boolean show)
Description copied from interface: ITextEditorExtension3
Sets the display of quick diff information.

Specified by:
showChangeInformation in interface ITextEditorExtension3
Overrides:
showChangeInformation in class AbstractTextEditor

isChangeInformationShowing

public boolean isChangeInformationShowing()
Description copied from interface: ITextEditorExtension3
Returns the quick diff display state.

Specified by:
isChangeInformationShowing in interface ITextEditorExtension3
Overrides:
isChangeInformationShowing in class AbstractTextEditor

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

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

protected IChangeRulerColumn createChangeRulerColumn()
Creates a new change ruler column for quick diff display independent of the line number ruler column

Returns:
a new change ruler column

createVerticalRuler

protected IVerticalRuler createVerticalRuler()
Returns createCompositeRuler(). Subclasses should not override this method, but rather createCompositeRuler if they want to contribute their own vertical ruler implementation. If not an instance of CompositeRuler is returned, the built-in ruler columns (line numbers, annotations) will not work.

May become final in the future.

Overrides:
createVerticalRuler in class AbstractTextEditor
Returns:
the vertical ruler
See Also:
AbstractTextEditor.createVerticalRuler()

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

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

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

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 Object getAdapter(Class adapter)
Description copied from interface: IAdaptable
Returns an object which is an instance of the given class associated with this object. Returns null if no such object can be found.

Specified by:
getAdapter in interface IAdaptable
Overrides:
getAdapter in class AbstractTextEditor

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.

getDocumentProvider

public IDocumentProvider getDocumentProvider()
Description copied from interface: ITextEditor
Returns this text editor's document provider.

Specified by:
getDocumentProvider in interface ITextEditor
Overrides:
getDocumentProvider in class AbstractTextEditor

disposeDocumentProvider

protected void disposeDocumentProvider()
Description copied from class: AbstractTextEditor
Disposes of the connection with the document provider. Subclasses may extend.

Overrides:
disposeDocumentProvider in class AbstractTextEditor

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
Throws:
CoreException

Eclipse Platform
Release 3.0

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.