Eclipse Platform
2.1

org.eclipse.ui.editors.text
Class TextEditor

java.lang.Object
  |
  +--org.eclipse.ui.part.WorkbenchPart
        |
        +--org.eclipse.ui.part.EditorPart
              |
              +--org.eclipse.ui.texteditor.AbstractTextEditor
                    |
                    +--org.eclipse.ui.texteditor.StatusTextEditor
                          |
                          +--org.eclipse.ui.editors.text.TextEditor
All Implemented Interfaces:
IAdaptable, IEditorPart, IExecutableExtension, INavigationLocationProvider, IReusableEditor, ISaveablePart, ITextEditor, ITextEditorExtension, ITextEditorExtension2, IWorkbenchPart

public class TextEditor
extends StatusTextEditor

The standard text editor for file resources (IFile).

This editor has id "org.eclipse.ui.DefaultTextEditor". The editor's context menu has id #TextEditorContext. The editor's ruler context menu has id #TextRulerContext.

The workbench will automatically instantiate this class when the default editor is needed for a workbench window.


Field Summary
protected  IAnnotationAccess fAnnotationAccess
          Helper for accessing annotation from the perspective of this editor.
protected  DefaultEncodingSupport fEncodingSupport
          The encoding support for the 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_FONT, PREFERENCE_NAVIGATION_SMART_HOME_END, 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
 
Constructor Summary
TextEditor()
          Creates a new text editor.
 
Method Summary
protected  void configureSourceViewerDecorationSupport()
          Configures the decoration support for this editor's the 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  IVerticalRulerColumn createLineNumberRulerColumn()
          Creates a new line number ruler column that is appropriately initialized.
 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()
          Creates the vertical ruler to be used by this editor.
 void dispose()
          The AbstractTextEditor implementation of this IWorkbenchPart method may be extended by subclasses.
 void doSave(IProgressMonitor monitor)
          The AbstractTextEditor implementation of this IEditorPart method may be extended by subclasses.
 void doSaveAs()
          The AbstractTextEditor implementation of this IEditorPart method calls performSaveAs.
protected  void doSetInput(IEditorInput input)
          Internal setInput method.
protected  void editorContextMenuAboutToShow(IMenuManager menu)
          Sets up this editor's context menu before it is made visible.
 Object getAdapter(Class adapter)
          Returns an object which is an instance of the given class associated with this object.
protected  String getStatusBanner(IStatus status)
          Returns a banner for the given status.
protected  String getStatusHeader(IStatus status)
          Returns a header for the given status
protected  String getStatusMessage(IStatus status)
          Returns a message for the given status.
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 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.
protected  void installEncodingSupport()
          Installs the encoding support on the given text editor.
protected  boolean isOverviewRulerVisible()
          Tells whether the overview ruler is visible.
 boolean isSaveAsAllowed()
          The AbstractTextEditor implementation of this IEditorPart method returns false.
protected  void performSaveAs(IProgressMonitor progressMonitor)
          The TextEditor implementation of this AbstractTextEditor method asks the user for the workspace path of a file resource and saves the document there.
protected  void updatePropertyDependentActions()
          Updates all property dependent actions.
 
Methods inherited from class org.eclipse.ui.texteditor.StatusTextEditor
createStatusControl, doRevertToSaved, sanityCheckState, updatePartControl, updateStatusField
 
Methods inherited from class org.eclipse.ui.texteditor.AbstractTextEditor
addAction, addAction, addGroup, addRulerContextMenuListener, adjustHighlightRange, affectsTextPresentation, canHandleMove, close, createEmptyNavigationLocation, createNavigationActions, createNavigationLocation, createRevertOperation, createSaveOperation, doGetSelection, doSetSelection, editorSaved, enableSanityChecking, enableStateValidation, firePropertyChange, getAction, getContextMenuListener, getCoverage, getCursorListener, getCursorPosition, getDocumentProvider, getEditorContextMenuId, getFontPropertyPreferenceKey, getHelpContextId, getHighlightRange, getPreferenceStore, getProgressMonitor, getRangeIndicator, getRulerContextMenuId, getRulerMouseListener, getSelectionChangedListener, getSelectionProvider, getSourceViewer, getSourceViewerConfiguration, getStatusField, getVerticalRuler, gotoMarker, handleCursorPositionChanged, handleEditorInputChanged, handleExceptionOnSave, handleInsertModeChanged, init, internalInit, isDirty, isEditable, isEditorInputModifiable, isEditorInputReadOnly, isInInsertMode, isSaveOnCloseNeeded, isVisible, markAsContentDependentAction, markAsPropertyDependentAction, markAsSelectionDependentAction, markAsStateDependentAction, markInNavigationHistory, performRevertOperation, performSaveOperation, rememberSelection, removeActionActivationCode, removeRulerContextMenuListener, resetHighlightRange, restoreSelection, rulerContextMenuAboutToShow, safelySanityCheckState, selectAndReveal, setAction, setActionActivationCode, setCompatibilityMode, setDocumentProvider, setEditorContextMenuId, setFocus, setHelpContextId, setHighlightRange, setInput, setKeyBindingScopes, setPreferenceStore, setRangeIndicator, setRulerContextMenuId, setSourceViewerConfiguration, setStatusField, showHighlightRangeOnly, showsHighlightRangeOnly, updateContentDependentActions, updateSelectionDependentActions, updateState, updateStateDependentActions, updateStatusFields, validateEditorInputState, validateState, widgetOffset2ModelOffset
 
Methods inherited from class org.eclipse.ui.part.EditorPart
getEditorInput, getEditorSite, getTitleToolTip
 
Methods inherited from class org.eclipse.ui.part.WorkbenchPart
addPropertyListener, getConfigurationElement, getDefaultImage, getSite, getTitle, getTitleImage, removePropertyListener, setInitializationData, setSite, setTitle, setTitleImage, setTitleToolTip
 
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.
Since:
2.1

fAnnotationAccess

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

fSourceViewerDecorationSupport

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

fLineNumberRulerColumn

protected LineNumberRulerColumn fLineNumberRulerColumn
The line number column.
Since:
2.1

fEncodingSupport

protected DefaultEncodingSupport fEncodingSupport
The encoding support for the editor.
Since:
2.0
Constructor Detail

TextEditor

public TextEditor()
Creates a new text editor.
Method Detail

initializeEditor

protected void initializeEditor()
Initializes this editor.

initializeKeyBindingScopes

protected void initializeKeyBindingScopes()
Initializes the key binding scopes of this editor.
Since:
2.1

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().
Overrides:
dispose in class AbstractTextEditor

doSaveAs

public void doSaveAs()
Description copied from class: AbstractTextEditor
The AbstractTextEditor implementation of this IEditorPart method calls performSaveAs. Subclasses may reimplement.
Overrides:
doSaveAs in class AbstractTextEditor

doSave

public void doSave(IProgressMonitor monitor)
Description copied from class: AbstractTextEditor
The AbstractTextEditor implementation of this IEditorPart method may be extended by subclasses.
Overrides:
doSave in class AbstractTextEditor
Following copied from class: org.eclipse.ui.texteditor.AbstractTextEditor
Parameters:
progressMonitor - the progress monitor for communicating result state or null

installEncodingSupport

protected void installEncodingSupport()
Installs the encoding support on the given text editor.

Subclasses may override to install their own encoding support or to disable the default encoding support.

Since:
2.1

performSaveAs

protected void performSaveAs(IProgressMonitor progressMonitor)
The TextEditor implementation of this AbstractTextEditor method 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

isSaveAsAllowed

public boolean isSaveAsAllowed()
Description copied from class: AbstractTextEditor
The AbstractTextEditor implementation of this IEditorPart method returns false. Subclasses may override.
Overrides:
isSaveAsAllowed in class AbstractTextEditor
Following copied from interface: org.eclipse.ui.ISaveablePart
Returns:
true if "Save As" is supported, and false if not supported

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

getStatusHeader

protected String getStatusHeader(IStatus status)
Description copied from class: StatusTextEditor
Returns a header for the given status
Overrides:
getStatusHeader in class StatusTextEditor
Following copied from class: org.eclipse.ui.texteditor.StatusTextEditor
Parameters:
status - the status whose message is returned
Returns:
a header for the given status

getStatusBanner

protected String getStatusBanner(IStatus status)
Description copied from class: StatusTextEditor
Returns a banner for the given status.
Overrides:
getStatusBanner in class StatusTextEditor
Following copied from class: org.eclipse.ui.texteditor.StatusTextEditor
Parameters:
status - the status whose message is returned
Returns:
a banner for the given status

getStatusMessage

protected String getStatusMessage(IStatus status)
Description copied from class: StatusTextEditor
Returns a message for the given status.
Overrides:
getStatusMessage in class StatusTextEditor
Following copied from class: org.eclipse.ui.texteditor.StatusTextEditor
Parameters:
status - the status whose message is returned
Returns:
a message for the given status

doSetInput

protected void doSetInput(IEditorInput input)
                   throws CoreException
Description copied from class: AbstractTextEditor
Internal setInput method.
Overrides:
doSetInput in class StatusTextEditor
Following copied from class: org.eclipse.ui.texteditor.AbstractTextEditor
Parameters:
input - the input to be set
Throws:
CoreException - if input cannot be connected to the document provider

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.
Overrides:
getAdapter in class AbstractTextEditor
Following copied from interface: org.eclipse.core.runtime.IAdaptable
Parameters:
adapter - the adapter class to look up
Returns:
a object castable to the given class, or null if this object does not have an adapter for the given class

editorContextMenuAboutToShow

protected void editorContextMenuAboutToShow(IMenuManager menu)
Description copied from class: AbstractTextEditor
Sets up this editor's context menu before it is made visible.

Subclasses may extend to add other actions.

Overrides:
editorContextMenuAboutToShow in class AbstractTextEditor
Following copied from class: org.eclipse.ui.texteditor.AbstractTextEditor
Parameters:
menu - the menu

updatePropertyDependentActions

protected void updatePropertyDependentActions()
Description copied from class: AbstractTextEditor
Updates all property dependent actions.
Overrides:
updatePropertyDependentActions 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
Following copied from class: org.eclipse.ui.texteditor.AbstractTextEditor
Parameters:
parent - the parent control
ruler - the vertical ruler
styles - style bits
Returns:
the source viewer

createAnnotationAccess

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

configureSourceViewerDecorationSupport

protected void configureSourceViewerDecorationSupport()
Configures the decoration support for this editor's the source viewer.
Since:
2.1

isOverviewRulerVisible

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

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
Since:
2.1

createLineNumberRulerColumn

protected IVerticalRulerColumn createLineNumberRulerColumn()
Creates a new line number ruler column that is appropriately initialized.
Since:
2.1

createVerticalRuler

protected IVerticalRuler createVerticalRuler()
Description copied from class: AbstractTextEditor
Creates the vertical ruler to be used by this editor. Subclasses may re-implement this method.
Overrides:
createVerticalRuler in class AbstractTextEditor
Following copied from class: org.eclipse.ui.texteditor.AbstractTextEditor
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.
Overrides:
handlePreferenceStoreChanged in class AbstractTextEditor
Following copied from class: org.eclipse.ui.texteditor.AbstractTextEditor
Parameters:
event - the property change event

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.
Overrides:
createPartControl in class StatusTextEditor
Following copied from class: org.eclipse.ui.texteditor.AbstractTextEditor
Parameters:
parent - the parent composite

Eclipse Platform
2.1

Copyright (c) IBM Corp. and others 2000, 2003. All Rights Reserved.