Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.ui.texteditor
Class AbstractTextEditor

java.lang.Object
  extended by 

org.eclipse.core.commands.common.EventManager
      extended by 

org.eclipse.ui.part.WorkbenchPart
          extended by 

org.eclipse.ui.part.EditorPart
              extended by 
org.eclipse.ui.texteditor.AbstractTextEditor
All Implemented Interfaces:
IAdaptable, IExecutableExtension, IEditorPart, INavigationLocationProvider, IPersistable, IPersistableEditor, IReusableEditor, ISaveablePart, ISaveablesSource, IWorkbenchPart, IWorkbenchPart2, IWorkbenchPart3, IWorkbenchPartOrientation, ITextEditor, ITextEditorExtension, ITextEditorExtension2, ITextEditorExtension3, ITextEditorExtension4, ITextEditorExtension5
Direct Known Subclasses:
StatusTextEditor

public abstract class AbstractTextEditor
extends EditorPart
implements ITextEditor, IReusableEditor, ITextEditorExtension, ITextEditorExtension2, ITextEditorExtension3, ITextEditorExtension4, ITextEditorExtension5, INavigationLocationProvider, ISaveablesSource, IPersistableEditor

Abstract base implementation of a text editor.

Subclasses are responsible for configuring the editor appropriately. The standard text editor, TextEditor, is one such example.

If a subclass calls setEditorContextMenuId the argument is used as the id under which the editor's context menu is registered for extensions. If no id is set, the context menu is registered under [editor_id].EditorContext whereby [editor_id] is replaced with the editor's part id. If the editor is instructed to run in version 1.0 context menu registration compatibility mode, the latter form of the registration even happens if a context menu id has been set via setEditorContextMenuId. If no id is set while in compatibility mode, the menu is registered under DEFAULT_EDITOR_CONTEXT_MENU_ID.

If a subclass calls setRulerContextMenuId the argument is used as the id under which the ruler's context menu is registered for extensions. If no id is set, the context menu is registered under [editor_id].RulerContext whereby [editor_id] is replaced with the editor's part id. If the editor is instructed to run in version 1.0 context menu registration compatibility mode, the latter form of the registration even happens if a context menu id has been set via setRulerContextMenuId. If no id is set while in compatibility mode, the menu is registered under DEFAULT_RULER_CONTEXT_MENU_ID.

As of 3.5, contributers can contribute editor and ruler context menu actions to all subclasses of this class by using COMMON_EDITOR_CONTEXT_MENU_ID and COMMON_RULER_CONTEXT_MENU_ID.


Nested Class Summary
protected  class AbstractTextEditor.AbstractSelectionChangedListener
          Internal implementation class for a change listener.
protected static class AbstractTextEditor.ColumnSupport
          Implements the ruler column support of for the given editor.
protected static class AbstractTextEditor.IdMapEntry
          Maps an action definition id to an StyledText action.
protected  class AbstractTextEditor.LineEndAction
          This action implements smart end.
protected  class AbstractTextEditor.LineStartAction
          This action implements smart home.
protected  class AbstractTextEditor.SelectionProvider
          Editor specific selection provider which wraps the source viewer's selection provider.
protected static class AbstractTextEditor.TextEditorSavable
          This text editor's savable.
 
Nested classes/interfaces inherited from interface org.eclipse.ui.texteditor. ITextEditorExtension3
ITextEditorExtension3.InsertMode
 
Field Summary
protected static  AbstractTextEditor.IdMapEntry[] ACTION_MAP
          The complete mapping between action definition IDs used by eclipse and StyledText actions.
static  String COMMON_EDITOR_CONTEXT_MENU_ID
          Menu id used to contribute to the editor context menu of all textual editors.
static  String COMMON_RULER_CONTEXT_MENU_ID
          Menu id used to contribute to the ruler context menu of all textual editors.
static  String DEFAULT_EDITOR_CONTEXT_MENU_ID
          Menu id for the editor context menu.
static  String DEFAULT_RULER_CONTEXT_MENU_ID
          Menu id for the ruler context menu.
protected   String fErrorLabel
          The error message shown in the status line in case of failed information look up.
static  String PREFERENCE_COLOR_BACKGROUND
          Key used to look up background color preference.
static  String PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT
          Key used to look up background color system default preference.
static  String PREFERENCE_COLOR_FIND_SCOPE
          Key used to look up find scope background color preference.
static  String PREFERENCE_COLOR_FOREGROUND
          Key used to look up foreground color preference.
static  String PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT
          Key used to look up foreground color system default preference.
static  String PREFERENCE_COLOR_SELECTION_BACKGROUND
          Key used to look up selection background color preference.
static  String PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT
          Key used to look up selection background color system default preference.
static  String PREFERENCE_COLOR_SELECTION_FOREGROUND
          Key used to look up selection foreground color preference.
static  String PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT
          Key used to look up selection foreground color system default preference.
static  String PREFERENCE_FONT
          Deprecated. As of 2.1, replaced by JFaceResources.TEXT_FONT
static  String PREFERENCE_HOVER_ENRICH_MODE
          A named preference that controls if hovers should automatically be closed when the mouse is moved into them, or when they should be enriched.
static  String PREFERENCE_HYPERLINK_KEY_MODIFIER
          A named preference that controls the key modifier for hyperlinks.
static  String PREFERENCE_HYPERLINK_KEY_MODIFIER_MASK
          A named preference that controls the key modifier mask for hyperlinks.
static  String PREFERENCE_HYPERLINKS_ENABLED
          A named preference that controls if hyperlinks are turned on or off.
static  String PREFERENCE_NAVIGATION_SMART_HOME_END
          Key used to look up smart home/end preference.
static  String PREFERENCE_RULER_CONTRIBUTIONS
          A named preference that controls the visible ruler column contributions.
static  String PREFERENCE_SHOW_WHITESPACE_CHARACTERS
          A named preference that controls the display of whitespace characters.
static  String PREFERENCE_TEXT_DRAG_AND_DROP_ENABLED
          A named preference that controls whether text drag and drop is enabled.
static  String PREFERENCE_USE_CUSTOM_CARETS
          Key used to look up the custom caret preference.
static  String PREFERENCE_WIDE_CARET
          Key used to look up the caret width preference.
protected static  String TAG_SELECTION_LENGTH
          Tag used in the IMemento when saving and restoring the editor's selection length.
protected static  String TAG_SELECTION_OFFSET
          Tag used in the IMemento when saving and restoring the editor's selection offset.
protected static int VERTICAL_RULER_WIDTH
          The width of the vertical ruler.
 
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
protected AbstractTextEditor ()
          Creates a new text editor.
 
Method Summary
protected  void addAction ( IMenuManager menu, String actionId)
          Convenience method to add the action installed under the given action id to the given menu.
protected  void addAction ( IMenuManager menu, String group, String actionId)
          Convenience method to add the action installed under the given action id to the specified group of the menu.
protected  void addGroup ( IMenuManager menu, String existingGroup, String newGroup)
          Convenience method to add a new group after the specified group.
 void addRulerContextMenuListener ( IMenuListener listener)
          Adds a ruler context menu listener to the editor.
protected  void adjustHighlightRange (int offset, int length)
          Adjusts the highlight range so that at least the specified range is highlighted.
protected  boolean affectsTextPresentation ( PropertyChangeEvent event)
          Determines whether the given preference change affects the editor's presentation.
protected  boolean canHandleMove ( IEditorInput originalElement, IEditorInput movedElement)
          Returns whether this editor can handle the move of the original element so that it ends up being the moved element.
 void close (boolean save)
          Closes this text editor after optionally saving changes.
protected  void configureInsertMode ( ITextEditorExtension3.InsertMode mode, boolean legal)
          Configures the given insert mode as legal or illegal.
protected  boolean containsSavedState ( IMemento memento)
          Returns whether the given memento contains saved state Subclasses may extend or override this method.
protected  void createActions ()
          Creates this editor's standard actions and connects them with the global workbench actions.
protected   IColumnSupport createColumnSupport ()
          Creates the column support to be used by this editor to manage the contributed ruler columns.
protected   IMenuListener createContextMenuListener ()
          Creates the listener on this editor's context menus.
  INavigationLocation createEmptyNavigationLocation ()
          Creates an empty navigation location.
protected  void createNavigationActions ()
          Creates action entries for all SWT StyledText actions as defined in org.eclipse.swt.custom.ST.
  INavigationLocation createNavigationLocation ()
          Creates a navigation location describing the current state.
 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  void createUndoRedoActions ()
          Creates this editor's undo/redo actions.
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.
protected  void disposeDocumentProvider ()
          Disposes of the connection with the document provider.
protected   ISelection doGetSelection ()
          Returns the current selection.
protected  void doRestoreState ( IMemento memento)
          Restores this editor's state using the given memento.
 void doRevertToSaved ()
          The AbstractTextEditor implementation of this ITextEditor method may be extended by subclasses.
 void doSave ( IProgressMonitor progressMonitor)
          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)
          Called directly from setInput and from within a workspace runnable from init, this method does the actual setting of the editor input.
protected  void doSetSelection ( ISelection selection)
          Sets the given selection.
protected  void editorContextMenuAboutToShow ( IMenuManager menu)
          Sets up this editor's context menu before it is made visible.
protected  void editorSaved ()
          Hook which gets called when the editor has been saved.
protected  void enableOverwriteMode (boolean enable)
          Sets the overwrite mode enablement.
protected  void enableSanityChecking (boolean enable)
          Enables/disables sanity checking.
protected  void enableStateValidation (boolean enable)
          Enables/disables state validation.
protected   Annotation findAnnotation (int offset, int length, boolean forward, Position annotationPosition)
          Returns the annotation closest to the given range respecting the given direction.
protected  void firePropertyChange (int property)
          Fires a property changed event.
  IAction getAction ( String actionID)
          Returns the action installed under the given action id.
  Saveable[] getActiveSaveables ()
          Returns the saveables currently active in the workbench part.
  Object getAdapter ( Class required)
          Returns an object which is an instance of the given class associated with this object.
protected   IMenuListener getContextMenuListener ()
          Creates and returns the listener on this editor's context menus.
protected static  IRegion getCoverage ( ISourceViewer viewer)
          Returns the minimal region of the given source viewer's document that completely comprises everything that is visible in the viewer's widget.
protected  org.eclipse.ui.texteditor.AbstractTextEditor.ICursorListener getCursorListener ()
          Returns this editor's "cursor" listener to be installed on the editor's source viewer.
protected   String getCursorPosition ()
          Returns a description of the cursor position.
  IDocumentProvider getDocumentProvider ()
          Returns this text editor's document provider.
protected   String getEditorContextMenuId ()
          Returns the editor's context menu id.
protected   String getFontPropertyPreferenceKey ()
          Returns the property preference key for the editor font.
protected   String getHelpContextId ()
          Returns the editor's help context id or null if none has been set.
  IRegion getHighlightRange ()
          Returns the highlighted range of this text editor.
  ITextEditorExtension3.InsertMode getInsertMode ()
          Returns the current input mode of this editor.
protected   List getLegalInsertModes ()
          Returns the set of legal insert modes.
protected   IPreferenceStore getPreferenceStore ()
          Returns this editor's preference store or null if none has been set.
protected   IProgressMonitor getProgressMonitor ()
          Returns the progress monitor related to this editor.
protected   Annotation getRangeIndicator ()
          Returns the editor's range indicator.
protected   String getRulerContextMenuId ()
          Returns the ruler's context menu id.
protected   MouseListener getRulerMouseListener ()
          Creates and returns the listener on this editor's vertical ruler.
  Saveable[] getSaveables ()
          Returns the saveables presented by the workbench part.
protected   ISelectionChangedListener getSelectionChangedListener ()
          Returns this editor's selection changed listener to be installed on the editor's source viewer.
  ISelectionProvider getSelectionProvider ()
          Returns this text editor's selection provider.
protected   ISourceViewer getSourceViewer ()
          Returns the editor's source viewer.
protected   SourceViewerConfiguration getSourceViewerConfiguration ()
          Returns the editor's source viewer configuration.
protected   IStatusField getStatusField ( String category)
          Returns the current status field for the given status category.
protected   IStatusLineManager getStatusLineManager ()
          Returns the status line manager of this editor.
protected   IOperationApprover getUndoRedoOperationApprover ( IUndoContext undoContext)
          Return an IOperationApprover appropriate for approving the undo and redo of operations that have the specified undo context.
protected   IVerticalRuler getVerticalRuler ()
          Returns the editor's vertical ruler.
  Annotation gotoAnnotation (boolean forward)
          Jumps to the next annotation according to the given direction.
protected  void handleCursorPositionChanged ()
          Handles a potential change of the cursor position.
protected  void handleEditorInputChanged ()
          Handles an external change of the editor's input element.
protected  void handleElementContentReplaced ()
          Performs any additional action necessary to perform after the input document's content has been replaced.
protected  void handleExceptionOnSave ( CoreException exception, IProgressMonitor progressMonitor)
          Handles the given exception.
protected  void handleInsertModeChanged ()
          Handles a change of the editor's insert mode.
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.
 void init ( IEditorSite site, IEditorInput input)
          Initializes this editor with the given editor site and input.
protected  void initializeDragAndDrop ( ISourceViewer viewer)
          Initializes the drag and drop support for the given viewer based on provided editor adapter for drop target listeners.
protected  void initializeViewerColors ( ISourceViewer viewer)
          Initializes the fore- and background colors of the given viewer for both normal and selected text.
protected  void installTabsToSpacesConverter ()
          Installs a tabs to spaces converter.
protected  void installTextDragAndDrop ( ISourceViewer viewer)
          Installs text drag and drop on the given source viewer.
protected  void internalInit ( IWorkbenchWindow window, IEditorSite site, IEditorInput input)
          Implements the init method of IEditorPart.
 boolean isBlockSelectionModeEnabled ()
          Returns true if the receiver is in block (aka column) selection mode, false otherwise.
protected  boolean isBlockSelectionModeSupported ()
          Tells whether selection mode is supported.
 boolean isChangeInformationShowing ()
          Returns the quick diff display state.
 boolean isDirty ()
          Returns whether the contents of this part have changed since the last save operation.
 boolean isEditable ()
          Returns whether the text in this text editor can be changed by the user.
protected  boolean isEditorInputIncludedInContextMenu ()
          Tells whether the editor input should be included when adding object contributions to this editor's context menu.
 boolean isEditorInputModifiable ()
          Returns whether the editor's input can be persistently be modified.
 boolean isEditorInputReadOnly ()
          Returns whether the editor's input is read-only.
protected  boolean isInInsertMode ()
          Returns whether this editor is in overwrite or insert mode.
protected  boolean isNavigationTarget ( Annotation annotation)
          Returns whether the given annotation is configured as a target for the "Go to Next/Previous Annotation" actions.
 boolean isSaveAsAllowed ()
          The AbstractTextEditor implementation of this IEditorPart method returns false.
protected  boolean isTabsToSpacesConversionEnabled ()
          Tells whether tabs should be converted to spaces while editing inside this editor.
protected static boolean isVisible ( ISourceViewer viewer, int offset, int length)
          Tells whether the given region is visible in the given source viewer.
 void markAsContentDependentAction ( String actionId, boolean mark)
          Marks or unmarks the given action to be updated on content changes.
 void markAsPropertyDependentAction ( String actionId, boolean mark)
          Marks or unmarks the given action to be updated on property changes.
 void markAsSelectionDependentAction ( String actionId, boolean mark)
          Marks or unmarks the given action to be updated on text selection changes.
 void markAsStateDependentAction ( String actionId, boolean mark)
          Marks or unmarks the given action to be updated on state changes.
protected  void markInNavigationHistory ()
          Writes a check mark of the given situation into the navigation history.
protected static int modelOffset2WidgetOffset ( ISourceViewer viewer, int modelOffset)
          Returns the offset of the given source viewer's text widget that corresponds to the given model offset or -1 if there is no such offset.
protected  void openSaveErrorDialog ( String title, String message, CoreException exception)
          Presents an error dialog to the user when a problem happens during save.
protected  void performRevert ()
          Performs revert and handles errors appropriately.
protected  void performSave (boolean overwrite, IProgressMonitor progressMonitor)
          Performs the save and handles errors appropriately.
protected  void performSaveAs ( IProgressMonitor progressMonitor)
          Performs a save as and reports the result state back to the given progress monitor.
protected  void rememberSelection ()
          Remembers the current selection of this editor.
 void removeActionActivationCode ( String actionID)
          Removes any installed activation code for the specified action.
 void removeRulerContextMenuListener ( IMenuListener listener)
          Removes a ruler context menu listener from the editor.
 void resetHighlightRange ()
          Resets the highlighted range of this text editor.
protected  void restoreSelection ()
          Restores a selection previously remembered by rememberSelection.
 void restoreState ( IMemento memento)
          Called with a memento for this editor.
protected  void rulerContextMenuAboutToShow ( IMenuManager menu)
          Sets up the ruler context menu before it is made visible.
protected  void safelySanityCheckState ( IEditorInput input)
          Checks the state of the given editor input if sanity checking is enabled.
protected  void sanityCheckState ( IEditorInput input)
          Checks the state of the given editor input.
 void saveState ( IMemento memento)
          Saves the state of the object in the given memento.
 void selectAndReveal (int start, int length)
          Selects and reveals the specified range in this text editor.
protected  void selectAndReveal (int selectionStart, int selectionLength, int revealStart, int revealLength)
          Selects and reveals the specified ranges in this text editor.
 void setAction ( String actionID, IAction action)
          Installs the given action under the given action id.
 void setActionActivationCode ( String actionID, char activationCharacter, int activationKeyCode, int activationStateMask)
          Sets the given activation code for the specified action.
 void setBlockSelectionMode (boolean enable)
          Sets the block selection mode state of the receiver to state.
protected  void setCompatibilityMode (boolean compatible)
          Sets the context menu registration 1.0 compatibility mode.
protected  void setDocumentProvider ( IDocumentProvider provider)
          Sets this editor's document provider.
protected  void setDocumentProvider ( IEditorInput input)
          Hook method for setting the document provider for the given input.
protected  void setEditorContextMenuId ( String contextMenuId)
          Sets this editor's context menu id.
 void setFocus ()
          Asks this part to take focus within the workbench.
protected  void setHelpContextId ( String helpContextId)
          Sets the editor's help context id.
 void setHighlightRange (int offset, int length, boolean moveCursor)
          Sets the highlighted range of this text editor to the specified region.
 void setInput ( IEditorInput input)
          Sets the input to this editor.
protected  void setInputWithNotify ( IEditorInput input)
          Sets the input to this editor and fires a PROP_INPUT property change if the input has changed.
 void setInsertMode ( ITextEditorExtension3.InsertMode newMode)
          Sets the insert mode of this editor.
protected  void setKeyBindingScopes ( String[] scopes)
          Sets the key binding scopes for this editor.
protected  void setPreferenceStore ( IPreferenceStore store)
          Sets this editor's preference store.
protected  void setRangeIndicator ( Annotation rangeIndicator)
          Sets the annotation which this editor uses to represent the highlight range if the editor is configured to show the entire document.
protected  void setRulerContextMenuId ( String contextMenuId)
          Sets the ruler's context menu id.
protected  void setSourceViewerConfiguration ( SourceViewerConfiguration configuration)
          Sets this editor's source viewer configuration used to configure its internal source viewer.
 void setStatusField ( IStatusField field, String category)
          Informs the editor which status field is to be used when posting status information in the given category.
protected  void setStatusLineErrorMessage ( String message)
          Sets the given message as error message to this editor's status line.
protected  void setStatusLineMessage ( String message)
          Sets the given message as message to this editor's status line.
 void showChangeInformation (boolean show)
          Sets the display of quick diff information.
 void showHighlightRangeOnly (boolean showHighlightRangeOnly)
          Configures this text editor to show only the highlighted range of the text.
 void showRevisionInformation ( RevisionInformation info, String quickDiffProviderId)
          Shows revision information in this editor.
 boolean showsHighlightRangeOnly ()
          Returns whether this text editor is configured to show only the highlighted range of the text.
protected  void uninstallTabsToSpacesConverter ()
          Installs a tabs to spaces converter.
protected  void uninstallTextDragAndDrop ( ISourceViewer viewer)
          Uninstalls text drag and drop from the given source viewer.
protected  void updateContentDependentActions ()
          Updates all content dependent actions.
protected  void updateContributedRulerColumns ( CompositeRuler ruler)
          Adds enabled ruler contributions to the vertical ruler.
protected  void updateIndentPrefixes ()
          Updates the source viewer's indent prefixes with the values provided by the source viewer configuration.
protected  void updatePropertyDependentActions ()
          Updates all property dependent actions.
protected  void updateSelectionDependentActions ()
          Updates all selection dependent actions.
protected  void updateState ( IEditorInput input)
          Updates the state of the given editor input such as read-only flag.
protected  void updateStateDependentActions ()
          Updates all state dependent actions.
protected  void updateStatusField ( String category)
          Updates the status fields for the given category.
protected  void updateStatusFields ()
          Updates all status fields.
 boolean validateEditorInputState ()
          Validates the state of the given editor input.
protected  void validateState ( IEditorInput input)
          Validates the state of the given editor input.
protected static int widgetOffset2ModelOffset ( ISourceViewer viewer, int widgetOffset)
          Returns the offset of the given source viewer's document that corresponds to the given widget offset or -1 if there is no such offset.
 
Methods inherited from class org.eclipse.ui.part. EditorPart
checkSite, getEditorInput, getEditorSite, getTitleToolTip, isSaveOnCloseNeeded, setContentDescription, setInitializationData, setPartName
 
Methods inherited from class org.eclipse.ui.part. WorkbenchPart
addPartPropertyListener, addPropertyListener, firePartPropertyChanged, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, removePartPropertyListener, removePropertyListener, setPartProperty, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy
 
Methods inherited from class org.eclipse.core.commands.common. EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
 
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
 
Methods inherited from interface org.eclipse.ui. ISaveablePart
isSaveOnCloseNeeded
 

Field Detail

TAG_SELECTION_OFFSET

protected static final 
String TAG_SELECTION_OFFSET
Tag used in the IMemento when saving and restoring the editor's selection offset.

Since:
3.3
See Also:
saveState(IMemento), restoreState(IMemento), doRestoreState(IMemento), Constant Field Values

TAG_SELECTION_LENGTH

protected static final 
String TAG_SELECTION_LENGTH
Tag used in the IMemento when saving and restoring the editor's selection length.

Since:
3.3
See Also:
saveState(IMemento), restoreState(IMemento), doRestoreState(IMemento), Constant Field Values

PREFERENCE_FONT

public static final 
String PREFERENCE_FONT
Deprecated. As of 2.1, replaced by JFaceResources.TEXT_FONT
Key used to look up font preference. Value: "org.eclipse.jface.textfont"

See Also:
Constant Field Values

PREFERENCE_COLOR_FOREGROUND

public static final 
String PREFERENCE_COLOR_FOREGROUND
Key used to look up foreground color preference. Value: AbstractTextEditor.Color.Foreground

Since:
2.0
See Also:
Constant Field Values

PREFERENCE_COLOR_BACKGROUND

public static final 
String PREFERENCE_COLOR_BACKGROUND
Key used to look up background color preference. Value: AbstractTextEditor.Color.Background

Since:
2.0
See Also:
Constant Field Values

PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT

public static final 
String PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT
Key used to look up foreground color system default preference. Value: AbstractTextEditor.Color.Foreground.SystemDefault

Since:
2.0
See Also:
Constant Field Values

PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT

public static final 
String PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT
Key used to look up background color system default preference. Value: AbstractTextEditor.Color.Background.SystemDefault

Since:
2.0
See Also:
Constant Field Values

PREFERENCE_COLOR_SELECTION_FOREGROUND

public static final 
String PREFERENCE_COLOR_SELECTION_FOREGROUND
Key used to look up selection foreground color preference. Value: AbstractTextEditor.Color.SelectionForeground

Since:
3.0
See Also:
Constant Field Values

PREFERENCE_COLOR_SELECTION_BACKGROUND

public static final 
String PREFERENCE_COLOR_SELECTION_BACKGROUND
Key used to look up selection background color preference. Value: AbstractTextEditor.Color.SelectionBackground

Since:
3.0
See Also:
Constant Field Values

PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT

public static final 
String PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT
Key used to look up selection foreground color system default preference. Value: AbstractTextEditor.Color.SelectionForeground.SystemDefault

Since:
3.0
See Also:
Constant Field Values

PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT

public static final 
String PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT
Key used to look up selection background color system default preference. Value: AbstractTextEditor.Color.SelectionBackground.SystemDefault

Since:
3.0
See Also:
Constant Field Values

PREFERENCE_COLOR_FIND_SCOPE

public static final 
String PREFERENCE_COLOR_FIND_SCOPE
Key used to look up find scope background color preference. Value: AbstractTextEditor.Color.FindScope

Since:
2.0
See Also:
Constant Field Values

PREFERENCE_NAVIGATION_SMART_HOME_END

public static final 
String PREFERENCE_NAVIGATION_SMART_HOME_END
Key used to look up smart home/end preference. Value: AbstractTextEditor.Navigation.SmartHomeEnd

Since:
2.1
See Also:
Constant Field Values

PREFERENCE_USE_CUSTOM_CARETS

public static final 
String PREFERENCE_USE_CUSTOM_CARETS
Key used to look up the custom caret preference. Value: "AbstractTextEditor.Accessibility.UseCustomCarets"

Since:
3.0
See Also:
Constant Field Values

PREFERENCE_WIDE_CARET

public static final 
String PREFERENCE_WIDE_CARET
Key used to look up the caret width preference. Value: "AbstractTextEditor.Accessibility.WideCaret"

Since:
3.0
See Also:
Constant Field Values

PREFERENCE_HYPERLINKS_ENABLED

public static final 
String PREFERENCE_HYPERLINKS_ENABLED
A named preference that controls if hyperlinks are turned on or off.

Value is of type Boolean.

Since:
3.1
See Also:
Constant Field Values

PREFERENCE_HYPERLINK_KEY_MODIFIER

public static final 
String PREFERENCE_HYPERLINK_KEY_MODIFIER
A named preference that controls the key modifier for hyperlinks.

Value is of type String.

Since:
3.1
See Also:
Constant Field Values

PREFERENCE_HYPERLINK_KEY_MODIFIER_MASK

public static final 
String PREFERENCE_HYPERLINK_KEY_MODIFIER_MASK
A named preference that controls the key modifier mask for hyperlinks. The value is only used if the value of PREFERENCE_HYPERLINK_KEY_MODIFIER cannot be resolved to valid SWT modifier bits.

Value is of type String.

Since:
3.1
See Also:
PREFERENCE_HYPERLINK_KEY_MODIFIER, Constant Field Values

PREFERENCE_RULER_CONTRIBUTIONS

public static final 
String PREFERENCE_RULER_CONTRIBUTIONS
A named preference that controls the visible ruler column contributions.

Value is of type String and should be read using a RulerColumnPreferenceAdapter.

Since:
3.3
See Also:
Constant Field Values

PREFERENCE_SHOW_WHITESPACE_CHARACTERS

public static final 
String PREFERENCE_SHOW_WHITESPACE_CHARACTERS
A named preference that controls the display of whitespace characters.

Value is of type Boolean.

Since:
3.3
See Also:
Constant Field Values

PREFERENCE_TEXT_DRAG_AND_DROP_ENABLED

public static final 
String PREFERENCE_TEXT_DRAG_AND_DROP_ENABLED
A named preference that controls whether text drag and drop is enabled.

Value is of type Boolean.

Since:
3.3
See Also:
Constant Field Values

PREFERENCE_HOVER_ENRICH_MODE

public static final 
String PREFERENCE_HOVER_ENRICH_MODE
A named preference that controls if hovers should automatically be closed when the mouse is moved into them, or when they should be enriched.

Value is of type Integer and maps to the following ITextViewerExtension8.EnrichMode:

Since:
3.4
See Also:
Constant Field Values

DEFAULT_EDITOR_CONTEXT_MENU_ID

public static final 
String DEFAULT_EDITOR_CONTEXT_MENU_ID
Menu id for the editor context menu.

See Also:
Constant Field Values

DEFAULT_RULER_CONTEXT_MENU_ID

public static final 
String DEFAULT_RULER_CONTEXT_MENU_ID
Menu id for the ruler context menu.

See Also:
Constant Field Values

COMMON_EDITOR_CONTEXT_MENU_ID

public static final 
String COMMON_EDITOR_CONTEXT_MENU_ID
Menu id used to contribute to the editor context menu of all textual editors.

Since:
3.5
See Also:
Constant Field Values

COMMON_RULER_CONTEXT_MENU_ID

public static final 
String COMMON_RULER_CONTEXT_MENU_ID
Menu id used to contribute to the ruler context menu of all textual editors.

Since:
3.5
See Also:
Constant Field Values

VERTICAL_RULER_WIDTH

protected static final int VERTICAL_RULER_WIDTH
The width of the vertical ruler.

See Also:
Constant Field Values

ACTION_MAP

protected static final 
AbstractTextEditor.IdMapEntry[] ACTION_MAP
The complete mapping between action definition IDs used by eclipse and StyledText actions.

Since:
2.0

fErrorLabel

protected final 
String fErrorLabel
The error message shown in the status line in case of failed information look up.

Constructor Detail

AbstractTextEditor

protected AbstractTextEditor()
Creates a new text editor. If not explicitly set, this editor uses a SourceViewerConfiguration to configure its source viewer. This viewer does not have a range indicator installed, nor any menu id set. By default, the created editor runs in 1.0 context menu registration compatibility mode.

Method Detail

getDocumentProvider

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

Specified by:
getDocumentProvider in interface ITextEditor
Returns:
the document provider or null if none, e.g. after closing the editor

getRangeIndicator

protected final 
Annotation getRangeIndicator()
Returns the editor's range indicator. May return null if no range indicator is installed.

Returns:
the editor's range indicator which may be null

getSourceViewerConfiguration

protected final 
SourceViewerConfiguration getSourceViewerConfiguration()
Returns the editor's source viewer configuration. May return null before the editor's part has been created and after disposal.

Returns:
the editor's source viewer configuration which may be null

getSourceViewer

protected final 
ISourceViewer getSourceViewer()
Returns the editor's source viewer. May return null before the editor's part has been created and after disposal.

Returns:
the editor's source viewer which may be null

getVerticalRuler

protected final 
IVerticalRuler getVerticalRuler()
Returns the editor's vertical ruler. May return null before the editor's part has been created and after disposal.

Returns:
the editor's vertical ruler which may be null

getEditorContextMenuId

protected final 
String getEditorContextMenuId()
Returns the editor's context menu id. May return null before the editor's part has been created.

Returns:
the editor's context menu id which may be null

getRulerContextMenuId

protected final 
String getRulerContextMenuId()
Returns the ruler's 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

getHelpContextId

protected final 
String getHelpContextId()
Returns the editor's help context id or null if none has been set.

Returns:
the editor's help context id which may be null

getPreferenceStore

protected final 
IPreferenceStore getPreferenceStore()
Returns this editor's preference store or null if none has been set.

Returns:
this editor's preference store which may be null

setDocumentProvider

protected void setDocumentProvider(
IDocumentProvider provider)
Sets this editor's document provider. This method must be called before the editor's control is created.

Parameters:
provider - the document provider

setSourceViewerConfiguration

protected void setSourceViewerConfiguration(
SourceViewerConfiguration configuration)
Sets this editor's source viewer configuration used to configure its internal source viewer. This method must be called before the editor's control is created. If not, this editor uses a SourceViewerConfiguration.

Parameters:
configuration - the source viewer configuration object

setRangeIndicator

protected void setRangeIndicator(
Annotation rangeIndicator)
Sets the annotation which this editor uses to represent the highlight range if the editor is configured to show the entire document. If the range indicator is not set, this editor will not show a range indication.

Parameters:
rangeIndicator - the annotation

setEditorContextMenuId

protected void setEditorContextMenuId(
String contextMenuId)
Sets this editor's context menu id.

Parameters:
contextMenuId - the context menu id

setRulerContextMenuId

protected void setRulerContextMenuId(
String contextMenuId)
Sets the ruler's context menu id.

Parameters:
contextMenuId - the context menu id

setCompatibilityMode

protected final void setCompatibilityMode(boolean compatible)
Sets the context menu registration 1.0 compatibility mode. (See class description for more details.)

Parameters:
compatible - true if compatibility mode is enabled
Since:
2.0

setHelpContextId

protected void setHelpContextId(
String helpContextId)
Sets the editor's help context id.

Parameters:
helpContextId - the help context id

setKeyBindingScopes

protected void setKeyBindingScopes(
String[] scopes)
Sets the key binding scopes for this editor.

Parameters:
scopes - a non-empty array of key binding scope identifiers
Since:
2.1

setPreferenceStore

protected void setPreferenceStore(
IPreferenceStore store)
Sets this editor's preference store. This method must be called before the editor's control is created.

Parameters:
store - the preference store or null to remove the preference store

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
Returns:
true if it can be edited, and false if it is read-only

getSelectionProvider

public 
ISelectionProvider getSelectionProvider()
Returns this text editor's selection provider. Repeated calls to this method return the same selection provider.

Returns null after disposal.

Specified by:
getSelectionProvider in interface ITextEditor
Returns:
the selection provider or null if the editor has been disposed

rememberSelection

protected void rememberSelection()
Remembers the current selection of this editor. This method is called when, e.g., the content of the editor is about to be reverted to the saved state. This method remembers the selection in a semantic format, i.e., in a format which allows to restore the selection even if the originally selected text is no longer part of the editor's content.

Subclasses should implement this method including all necessary state. This default implementation remembers the textual range only and is thus purely syntactic.

Since:
2.0
See Also:
restoreSelection()

doGetSelection

protected 
ISelection doGetSelection()
Returns the current selection.

Returns:
ISelection
Since:
2.1

restoreSelection

protected void restoreSelection()
Restores a selection previously remembered by rememberSelection. Subclasses may reimplement this method and thereby semantically adapt the remembered selection. This default implementation just selects the remembered textual range.

Since:
2.0
See Also:
rememberSelection()

doSetSelection

protected void doSetSelection(
ISelection selection)
Sets the given selection.

Parameters:
selection - the selection
Since:
2.1

createContextMenuListener

protected 
IMenuListener createContextMenuListener()
Creates the listener on this editor's context menus.

Returns:
the created menu listener
Since:
3.4

getContextMenuListener

protected final 
IMenuListener getContextMenuListener()
Creates and returns the listener on this editor's context menus.

Returns:
the menu listener

getRulerMouseListener

protected final 
MouseListener getRulerMouseListener()
Creates and returns the listener on this editor's vertical ruler.

Returns:
the mouse listener

getSelectionChangedListener

protected final 
ISelectionChangedListener getSelectionChangedListener()
Returns this editor's selection changed listener to be installed on the editor's source viewer.

Returns:
the listener

getCursorListener

protected final org.eclipse.ui.texteditor.AbstractTextEditor.ICursorListener getCursorListener()
Returns this editor's "cursor" listener to be installed on the editor's source viewer. This listener is listening to key and mouse button events. It triggers the updating of the status line by calling handleCursorPositionChanged().

Returns:
the listener
Since:
2.0

internalInit

protected final void internalInit(
IWorkbenchWindow window,
                                  
IEditorSite site,
                                  
IEditorInput input)
                           throws 
PartInitException
Implements the init method of IEditorPart. Subclasses replacing init may choose to call this method in their implementation.

Parameters:
window - the workbench window
site - the editor's site
input - the editor input for the editor being created
Throws:
PartInitException - if doSetInput(IEditorInput) fails or gets canceled
Since:
2.1
See Also:
IEditorPart.init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)

init

public void init(
IEditorSite site,
                 
IEditorInput input)
          throws 
PartInitException
Description copied from interface: IEditorPart
Initializes this editor with the given editor site and input.

This method is automatically called shortly after the part is instantiated. It marks the start of the part's lifecycle. The IWorkbenchPart.dispose method will be called automically at the end of the lifecycle. Clients must not call this method.

Implementors of this method must examine the editor input object type to determine if it is understood. If not, the implementor must throw a PartInitException

Specified by:
init in interface IEditorPart
Specified by:
init in class EditorPart
Parameters:
site - the editor site
input - the editor input
Throws:
PartInitException - if this editor was not initialized successfully

createVerticalRuler

protected 
IVerticalRuler createVerticalRuler()
Creates the vertical ruler to be used by this editor. Subclasses may re-implement this method.

Returns:
the vertical ruler

updateContributedRulerColumns

protected void updateContributedRulerColumns(
CompositeRuler ruler)
Adds enabled ruler contributions to the vertical ruler.

Clients may extend or replace.

Parameters:
ruler - the composite ruler to add contributions to
Since:
3.3

createColumnSupport

protected 
IColumnSupport createColumnSupport()
Creates the column support to be used by this editor to manage the contributed ruler columns. Subclasses may re-implement this method using the AbstractTextEditor.ColumnSupport, e.g. by returning new ColumnSupport(this, RulerColumnRegistry.getDefault());.

Note: If you override this method to provide column support you will also need to override createVerticalRuler() to return a CompositeRuler.

Out of the box this class does not install this support and hence this implementation always returns null.

Returns:
the column support or null if none
Since:
3.3

createSourceViewer

protected 
ISourceViewer createSourceViewer(
Composite parent,
                                           
IVerticalRuler ruler,
                                           int styles)
Creates the source viewer to be used by this editor. Subclasses may re-implement this method.

Parameters:
parent - the parent control
ruler - the vertical ruler
styles - style bits, SWT.WRAP is currently not supported
Returns:
the source viewer

initializeDragAndDrop

protected void initializeDragAndDrop(
ISourceViewer viewer)
Initializes the drag and drop support for the given viewer based on provided editor adapter for drop target listeners.

Parameters:
viewer - the viewer
Since:
3.0

createPartControl

public void createPartControl(
Composite parent)
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
Specified by:
createPartControl in class WorkbenchPart
Parameters:
parent - the parent composite

installTextDragAndDrop

protected void installTextDragAndDrop(
ISourceViewer viewer)
Installs text drag and drop on the given source viewer.

Parameters:
viewer - the viewer
Since:
3.3

uninstallTextDragAndDrop

protected void uninstallTextDragAndDrop(
ISourceViewer viewer)
Uninstalls text drag and drop from the given source viewer.

Parameters:
viewer - the viewer
Since:
3.3

isEditorInputIncludedInContextMenu

protected boolean isEditorInputIncludedInContextMenu()
Tells whether the editor input should be included when adding object contributions to this editor's context menu.

This implementation always returns true.

Returns:
true if the editor input should be considered
Since:
3.2

initializeViewerColors

protected void initializeViewerColors(
ISourceViewer viewer)
Initializes the fore- and background colors of the given viewer for both normal and selected text.

Parameters:
viewer - the viewer to be initialized
Since:
2.0

setDocumentProvider

protected void setDocumentProvider(
IEditorInput input)
Hook method for setting the document provider for the given input. This default implementation does nothing. Clients may reimplement.

Parameters:
input - the input of this editor.
Since:
3.0

doSetInput

protected void doSetInput(
IEditorInput input)
                   throws 
CoreException
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.

Parameters:
input - the input to be set
Throws:
CoreException - if input cannot be connected to the document provider

setInputWithNotify

protected final void setInputWithNotify(
IEditorInput input)
Description copied from class: EditorPart
Sets the input to this editor and fires a PROP_INPUT property change if the input has changed. This is the convenience method implementation.

Note that firing a property change may cause other objects to reach back and invoke methods on the editor. Care should be taken not to call this method until the editor has fully updated its internal state to reflect the new input.

Overrides:
setInputWithNotify in class EditorPart
Parameters:
input - the editor input

setInput

public final void setInput(
IEditorInput input)
Description copied from class: EditorPart
Sets the input to this editor. This method simply updates the internal member variable.

Unlike most of the other set methods on this class, this method does not fire a property change. Clients that call this method from a subclass must ensure that they fire an IWorkbenchPartConstants.PROP_INPUT property change after calling this method but before leaving whatever public method they are in. Clients that expose this method as public API must fire the property change within their implementation of setInput.

Note that firing a property change may cause listeners to immediately reach back and call methods on this editor. Care should be taken not to fire the property change until the editor has fully updated its internal state to reflect the new input.

Specified by:
setInput in interface IReusableEditor
Overrides:
setInput in class EditorPart
Parameters:
input - the editor input
See Also:
EditorPart.setInputWithNotify(IEditorInput)

close

public void close(boolean save)
Description copied from interface: ITextEditor
Closes this text editor after optionally saving changes.

Specified by:
close in interface ITextEditor
Parameters:
save - true if unsaved changed should be saved, and false if unsaved changed should be discarded

dispose

public void dispose()
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 WorkbenchPart

disposeDocumentProvider

protected void disposeDocumentProvider()
Disposes of the connection with the document provider. Subclasses may extend.

Since:
3.0

affectsTextPresentation

protected boolean affectsTextPresentation(
PropertyChangeEvent event)
Determines whether the given preference change affects the editor's presentation. This implementation always returns false. May be reimplemented by subclasses.

Parameters:
event - the event which should be investigated
Returns:
true if the event describes a preference change affecting the editor's presentation
Since:
2.0

getFontPropertyPreferenceKey

protected final 
String getFontPropertyPreferenceKey()
Returns the property preference key for the editor font.

If the editor is defined with a symbolicFontName then this name is returned and the font is looked up in the JFace resource registry. Otherwise, JFaceResources.TEXT_FONT is returned and the font is looked up in this editor's preference store.

Returns:
a String with the key
Since:
2.1

handlePreferenceStoreChanged

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.

Subclasses may extend.

Parameters:
event - the property change event

getProgressMonitor

protected 
IProgressMonitor getProgressMonitor()
Returns the progress monitor related to this editor. It should not be necessary to extend this method.

Returns:
the progress monitor related to this editor
Since:
2.1

handleEditorInputChanged

protected void handleEditorInputChanged()
Handles an external change of the editor's input element. Subclasses may extend.


doSaveAs

public void doSaveAs()
The AbstractTextEditor implementation of this IEditorPart method calls performSaveAs. Subclasses may reimplement.

Specified by:
doSaveAs in interface ISaveablePart
Specified by:
doSaveAs in class EditorPart

performSaveAs

protected void performSaveAs(
IProgressMonitor progressMonitor)
Performs a save as and reports the result state back to the given progress monitor. This default implementation does nothing. Subclasses may reimplement.

Parameters:
progressMonitor - the progress monitor for communicating result state or null

doSave

public void doSave(
IProgressMonitor progressMonitor)
The AbstractTextEditor implementation of this IEditorPart method may be extended by subclasses.

Specified by:
doSave in interface ISaveablePart
Specified by:
doSave in class EditorPart
Parameters:
progressMonitor - the progress monitor for communicating result state or null

enableSanityChecking

protected void enableSanityChecking(boolean enable)
Enables/disables sanity checking.

Parameters:
enable - true if sanity checking should be enabled, false otherwise
Since:
2.0

safelySanityCheckState

protected void safelySanityCheckState(
IEditorInput input)
Checks the state of the given editor input if sanity checking is enabled.

Parameters:
input - the editor input whose state is to be checked
Since:
2.0

sanityCheckState

protected void sanityCheckState(
IEditorInput input)
Checks the state of the given editor input.

Parameters:
input - the editor input whose state is to be checked
Since:
2.0

enableStateValidation

protected void enableStateValidation(boolean enable)
Enables/disables state validation.

Parameters:
enable - true if state validation should be enabled, false otherwise
Since:
2.1

validateState

protected void validateState(
IEditorInput input)
Validates the state of the given editor input. The predominate intent of this method is to take any action probably necessary to ensure that the input can persistently be changed.

Parameters:
input - the input to be validated
Since:
2.0

validateEditorInputState

public boolean validateEditorInputState()
Description copied from interface: ITextEditorExtension2
Validates the state of the given editor input. The predominate intent of this method is to take any action probably necessary to ensure that the input can persistently be changed.

Specified by:
validateEditorInputState in interface ITextEditorExtension2
Returns:
true if the input was validated, false otherwise

updateState

protected void updateState(
IEditorInput input)
Updates the state of the given editor input such as read-only flag.

Parameters:
input - the input to be validated
Since:
2.0

performSave

protected void performSave(boolean overwrite,
                           
IProgressMonitor progressMonitor)
Performs the save and handles errors appropriately.

Parameters:
overwrite - indicates whether or not overwriting is allowed
progressMonitor - the monitor in which to run the operation
Since:
3.0

handleExceptionOnSave

protected void handleExceptionOnSave(
CoreException exception,
                                     
IProgressMonitor progressMonitor)
Handles the given exception. If the exception reports an out-of-sync situation, this is reported to the user. Otherwise, the exception is generically reported.

Parameters:
exception - the exception to handle
progressMonitor - the progress monitor

openSaveErrorDialog

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

Subclasses can decide to override the given title and message.

Parameters:
title - the dialog title
message - the message to display
exception - the exception to handle
Since:
3.3

isSaveAsAllowed

public boolean isSaveAsAllowed()
The AbstractTextEditor implementation of this IEditorPart method returns false. Subclasses may override.

Specified by:
isSaveAsAllowed in interface ISaveablePart
Specified by:
isSaveAsAllowed in class EditorPart
Returns:
false

isDirty

public boolean isDirty()
Description copied from interface: ISaveablePart
Returns whether the contents of this part have changed since the last save operation. If this value changes the part must fire a property listener event with PROP_DIRTY.

Note: this method is called often on a part open or part activation switch, for example by actions to determine their enabled status.

Specified by:
isDirty in interface ISaveablePart
Specified by:
isDirty in class EditorPart
Returns:
true if the contents have been modified and need saving, and false if they have not changed since the last save

doRevertToSaved

public void doRevertToSaved()
The AbstractTextEditor implementation of this ITextEditor method may be extended by subclasses.

Specified by:
doRevertToSaved in interface ITextEditor

performRevert

protected void performRevert()
Performs revert and handles errors appropriately.

Subclasses may extend.

Since:
3.0

handleElementContentReplaced

protected void handleElementContentReplaced()
Performs any additional action necessary to perform after the input document's content has been replaced.

Clients may extended this method.

Since:
3.0

setAction

public void setAction(
String actionID,
                      
IAction action)
Description copied from interface: ITextEditor
Installs the given action under the given action id.

Specified by:
setAction in interface ITextEditor
Parameters:
actionID - the action id
action - the action, or null to clear it
See Also:
ITextEditor.getAction(String)

setActionActivationCode

public void setActionActivationCode(
String actionID,
                                    char activationCharacter,
                                    int activationKeyCode,
                                    int activationStateMask)
Description copied from interface: ITextEditor
Sets the given activation code for the specified action. If there is an activation code already registered, it is replaced. The activation code consists of the same information as a KeyEvent. If the activation code is triggered and the associated action is enabled, the action is performed and the triggering KeyEvent is considered consumed. If the action is disabled, the KeyEvent is passed on unmodified. Thus, action activation codes and action accelerators differ in their model of event consumption. The key code parameter can be -1 to indicate a wild card. The state mask parameter can be SWT.DEFAULT to indicate a wild card.

Specified by:
setActionActivationCode in interface ITextEditor
Parameters:
actionID - the action id
activationCharacter - the activation code character
activationKeyCode - the activation code key code or -1 for wild card
activationStateMask - the activation code state mask or SWT.DEFAULT for wild card

removeActionActivationCode

public void removeActionActivationCode(
String actionID)
Description copied from interface: ITextEditor
Removes any installed activation code for the specified action. If no activation code is installed, this method does not have any effect.

Specified by:
removeActionActivationCode in interface ITextEditor
Parameters:
actionID - the action id

getAction

public 
IAction getAction(
String actionID)
Description copied from interface: ITextEditor
Returns the action installed under the given action id.

Specified by:
getAction in interface ITextEditor
Parameters:
actionID - the action id
Returns:
the action, or null if none
See Also:
ITextEditor.setAction(String, IAction)

markAsSelectionDependentAction

public void markAsSelectionDependentAction(
String actionId,
                                           boolean mark)
Marks or unmarks the given action to be updated on text selection changes.

Parameters:
actionId - the action id
mark - true if the action is selection dependent

markAsContentDependentAction

public void markAsContentDependentAction(
String actionId,
                                         boolean mark)
Marks or unmarks the given action to be updated on content changes.

Parameters:
actionId - the action id
mark - true if the action is content dependent

markAsPropertyDependentAction

public void markAsPropertyDependentAction(
String actionId,
                                          boolean mark)
Marks or unmarks the given action to be updated on property changes.

Parameters:
actionId - the action id
mark - true if the action is property dependent
Since:
2.0

markAsStateDependentAction

public void markAsStateDependentAction(
String actionId,
                                       boolean mark)
Marks or unmarks the given action to be updated on state changes.

Parameters:
actionId - the action id
mark - true if the action is state dependent
Since:
2.0

updateSelectionDependentActions

protected void updateSelectionDependentActions()
Updates all selection dependent actions.


updateContentDependentActions

protected void updateContentDependentActions()
Updates all content dependent actions.


updatePropertyDependentActions

protected void updatePropertyDependentActions()
Updates all property dependent actions.

Since:
2.0

updateStateDependentActions

protected void updateStateDependentActions()
Updates all state dependent actions.

Since:
2.0

createNavigationActions

protected void createNavigationActions()
Creates action entries for all SWT StyledText actions as defined in org.eclipse.swt.custom.ST. Overwrites and extends the list of these actions afterwards.

Subclasses may extend.

Since:
2.0

createUndoRedoActions

protected void createUndoRedoActions()
Creates this editor's undo/redo actions.

Subclasses may override or extend.

Since:
3.1

getUndoRedoOperationApprover

protected 
IOperationApprover getUndoRedoOperationApprover(
IUndoContext undoContext)
Return an IOperationApprover appropriate for approving the undo and redo of operations that have the specified undo context.

Subclasses may override.

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

createActions

protected void createActions()
Creates this editor's standard actions and connects them with the global workbench actions.

Subclasses may extend.


addAction

protected final void addAction(
IMenuManager menu,
                               
String actionId)
Convenience method to add the action installed under the given action id to the given menu.

Parameters:
menu - the menu to add the action to
actionId - the id of the action to be added

addAction

protected final void addAction(
IMenuManager menu,
                               
String group,
                               
String actionId)
Convenience method to add the action installed under the given action id to the specified group of the menu.

Parameters:
menu - the menu to add the action to
group - the group in the menu
actionId - the id of the action to add

addGroup

protected final void addGroup(
IMenuManager menu,
                              
String existingGroup,
                              
String newGroup)
Convenience method to add a new group after the specified group.

Parameters:
menu - the menu to add the new group to
existingGroup - the group after which to insert the new group
newGroup - the new group

rulerContextMenuAboutToShow

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

Subclasses may extend to add other actions.

Parameters:
menu - the menu

editorContextMenuAboutToShow

protected void editorContextMenuAboutToShow(
IMenuManager menu)
Sets up this editor's context menu before it is made visible.

Subclasses may extend to add other actions.

Parameters:
menu - the menu

getStatusLineManager

protected 
IStatusLineManager getStatusLineManager()
Returns the status line manager of this editor.

Returns:
the status line manager of this editor
Since:
2.0, protected since 3.3

getAdapter

public 
Object getAdapter(
Class required)
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. 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 WorkbenchPart
Parameters:
required - 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

setFocus

public void setFocus()
Description copied from interface: IWorkbenchPart
Asks this part to take focus within the workbench. Parts must assign focus to one of the controls contained in the part's parent composite.

Clients should not call this method (the workbench calls this method at appropriate times). To have the workbench activate a part, use IWorkbenchPage.activate(IWorkbenchPart) instead.

Specified by:
setFocus in interface IWorkbenchPart
Specified by:
setFocus in class WorkbenchPart

showsHighlightRangeOnly

public boolean showsHighlightRangeOnly()
Description copied from interface: ITextEditor
Returns whether this text editor is configured to show only the highlighted range of the text.

Specified by:
showsHighlightRangeOnly in interface ITextEditor
Returns:
true if only the highlighted range is shown, and false if this editor shows the entire text of the document
See Also:
ITextEditor.showHighlightRangeOnly(boolean)

showHighlightRangeOnly

public void showHighlightRangeOnly(boolean showHighlightRangeOnly)
Description copied from interface: ITextEditor
Configures this text editor to show only the highlighted range of the text.

Specified by:
showHighlightRangeOnly in interface ITextEditor
Parameters:
showHighlightRangeOnly - true if only the highlighted range is shown, and false if this editor shows the entire text of the document
See Also:
ITextEditor.showsHighlightRangeOnly()

setHighlightRange

public void setHighlightRange(int offset,
                              int length,
                              boolean moveCursor)
Description copied from interface: ITextEditor
Sets the highlighted range of this text editor to the specified region.

Specified by:
setHighlightRange in interface ITextEditor
Parameters:
offset - the offset of the highlighted range
length - the length of the highlighted range
moveCursor - true if the cursor should be moved to the start of the highlighted range, and false to leave the cursor unaffected
See Also:
ITextEditor.getHighlightRange()

getHighlightRange

public 
IRegion getHighlightRange()
Description copied from interface: ITextEditor
Returns the highlighted range of this text editor.

Specified by:
getHighlightRange in interface ITextEditor
Returns:
the highlighted range
See Also:
ITextEditor.setHighlightRange(int, int, boolean)

resetHighlightRange

public void resetHighlightRange()
Description copied from interface: ITextEditor
Resets the highlighted range of this text editor.

Specified by:
resetHighlightRange in interface ITextEditor

adjustHighlightRange

protected void adjustHighlightRange(int offset,
                                    int length)
Adjusts the highlight range so that at least the specified range is highlighted.

Subclasses may re-implement this method.

Parameters:
offset - the offset of the range which at least should be highlighted
length - the length of the range which at least should be highlighted

selectAndReveal

public void selectAndReveal(int start,
                            int length)
Description copied from interface: ITextEditor
Selects and reveals the specified range in this text editor.

Specified by:
selectAndReveal in interface ITextEditor
Parameters:
start - the offset of the selection
length - the length of the selection

selectAndReveal

protected void selectAndReveal(int selectionStart,
                               int selectionLength,
                               int revealStart,
                               int revealLength)
Selects and reveals the specified ranges in this text editor.

Parameters:
selectionStart - the offset of the selection
selectionLength - the length of the selection
revealStart - the offset of the revealed range
revealLength - the length of the revealed range
Since:
3.0

createEmptyNavigationLocation

public 
INavigationLocation createEmptyNavigationLocation()
Description copied from interface: INavigationLocationProvider
Creates an empty navigation location. The message restoreState will be sent to the location to restore its state.

Specified by:
createEmptyNavigationLocation in interface INavigationLocationProvider
Returns:
INavigationLocation

createNavigationLocation

public 
INavigationLocation createNavigationLocation()
Description copied from interface: INavigationLocationProvider
Creates a navigation location describing the current state.

Specified by:
createNavigationLocation in interface INavigationLocationProvider
Returns:
INavigationLocation

markInNavigationHistory

protected void markInNavigationHistory()
Writes a check mark of the given situation into the navigation history.

Since:
2.1

editorSaved

protected void editorSaved()
Hook which gets called when the editor has been saved. Subclasses may extend.

Since:
2.1

firePropertyChange

protected void firePropertyChange(int property)
Description copied from class: WorkbenchPart
Fires a property changed event.

Overrides:
firePropertyChange in class WorkbenchPart
Parameters:
property - the id of the property that changed

setStatusField

public void setStatusField(
IStatusField field,
                           
String category)
Description copied from interface: ITextEditorExtension
Informs the editor which status field is to be used when posting status information in the given category.

Specified by:
setStatusField in interface ITextEditorExtension
Parameters:
field - the status field to be used
category - the status information category
See Also:
ITextEditorActionConstants

getStatusField

protected 
IStatusField getStatusField(
String category)
Returns the current status field for the given status category.

Parameters:
category - the status category
Returns:
the current status field for the given status category
Since:
2.0

isInInsertMode

protected boolean isInInsertMode()
Returns whether this editor is in overwrite or insert mode.

Returns:
true if in insert mode, false for overwrite mode
Since:
2.0

getInsertMode

public 
ITextEditorExtension3.InsertMode getInsertMode()
Description copied from interface: ITextEditorExtension3
Returns the current input mode of this editor.

Specified by:
getInsertMode in interface ITextEditorExtension3
Returns:
the current input mode of this editor

setInsertMode

public void setInsertMode(
ITextEditorExtension3.InsertMode newMode)
Description copied from interface: ITextEditorExtension3
Sets the insert mode of this editor.

Specified by:
setInsertMode in interface ITextEditorExtension3
Parameters:
newMode - the new insert mode

getLegalInsertModes

protected 
List getLegalInsertModes()
Returns the set of legal insert modes. If insert modes are configured all defined insert modes are legal.

Returns:
the set of legal insert modes
Since:
3.0

configureInsertMode

protected void configureInsertMode(
ITextEditorExtension3.InsertMode mode,
                                   boolean legal)
Configures the given insert mode as legal or illegal. This call is ignored if the set of legal input modes would be empty after the call.

Parameters:
mode - the insert mode to be configured
legal - true if the given mode is legal, false otherwise
Since:
3.0

enableOverwriteMode

protected void enableOverwriteMode(boolean enable)
Sets the overwrite mode enablement.

Parameters:
enable - true to enable new overwrite mode, false to disable
Since:
3.0

handleInsertModeChanged

protected void handleInsertModeChanged()
Handles a change of the editor's insert mode. Subclasses may extend.

Since:
2.0

handleCursorPositionChanged

protected void handleCursorPositionChanged()
Handles a potential change of the cursor position. Subclasses may extend.

Since:
2.0

updateStatusField

protected void updateStatusField(
String category)
Updates the status fields for the given category.

Parameters:
category - the category
Since:
2.0

updateStatusFields

protected void updateStatusFields()
Updates all status fields.

Since:
2.0

getCursorPosition

protected 
String getCursorPosition()
Returns a description of the cursor position.

Returns:
a description of the cursor position
Since:
2.0

isEditorInputReadOnly

public boolean isEditorInputReadOnly()
Description copied from interface: ITextEditorExtension
Returns whether the editor's input is read-only. The semantics of this method is orthogonal to isEditable as it talks about the editor input, i.e. the domain element, and not about the editor document.

Specified by:
isEditorInputReadOnly in interface ITextEditorExtension
Returns:
true if the editor input is read-only

isEditorInputModifiable

public boolean isEditorInputModifiable()
Description copied from interface: ITextEditorExtension2
Returns whether the editor's input can be persistently be modified. This is orthogonal to ITextEditorExtension.isEditorInputReadOnly as read-only elements may be modifiable and writable elements may not be modifiable. If the given element is not connected to this document provider, the result is undefined. Document providers are allowed to use a cache to answer this question, i.e. there can be a difference between the "real" state of the element and the return value.

Specified by:
isEditorInputModifiable in interface ITextEditorExtension2
Returns:
true if the editor input is modifiable

addRulerContextMenuListener

public void addRulerContextMenuListener(
IMenuListener listener)
Description copied from interface: ITextEditorExtension
Adds a ruler context menu listener to the editor.

Specified by:
addRulerContextMenuListener in interface ITextEditorExtension
Parameters:
listener - the listener

removeRulerContextMenuListener

public void removeRulerContextMenuListener(
IMenuListener listener)
Description copied from interface: ITextEditorExtension
Removes a ruler context menu listener from the editor.

Specified by:
removeRulerContextMenuListener in interface ITextEditorExtension
Parameters:
listener - the listener

canHandleMove

protected boolean canHandleMove(
IEditorInput originalElement,
                                
IEditorInput movedElement)
Returns whether this editor can handle the move of the original element so that it ends up being the moved element. By default this method returns true. Subclasses may reimplement.

Parameters:
originalElement - the original element
movedElement - the moved element
Returns:
whether this editor can handle the move of the original element so that it ends up being the moved element
Since:
2.0

widgetOffset2ModelOffset

protected static final int widgetOffset2ModelOffset(
ISourceViewer viewer,
                                                    int widgetOffset)
Returns the offset of the given source viewer's document that corresponds to the given widget offset or -1 if there is no such offset.

Parameters:
viewer - the source viewer
widgetOffset - the widget offset
Returns:
the corresponding offset in the source viewer's document or -1
Since:
2.1

modelOffset2WidgetOffset

protected static final int modelOffset2WidgetOffset(
ISourceViewer viewer,
                                                    int modelOffset)
Returns the offset of the given source viewer's text widget that corresponds to the given model offset or -1 if there is no such offset.

Parameters:
viewer - the source viewer
modelOffset - the model offset
Returns:
the corresponding offset in the source viewer's text widget or -1
Since:
3.0

getCoverage

protected static final 
IRegion getCoverage(
ISourceViewer viewer)
Returns the minimal region of the given source viewer's document that completely comprises everything that is visible in the viewer's widget.

Parameters:
viewer - the viewer go return the coverage for
Returns:
the minimal region of the source viewer's document comprising the contents of the viewer's widget
Since:
2.1

isVisible

protected static final boolean isVisible(
ISourceViewer viewer,
                                         int offset,
                                         int length)
Tells whether the given region is visible in the given source viewer.

Parameters:
viewer - the source viewer
offset - the offset of the region
length - the length of the region
Returns:
true if visible
Since:
2.1

showChangeInformation

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

Specified by:
showChangeInformation in interface ITextEditorExtension3
Parameters:
show - true if quick diff information should be shown, false otherwise

isChangeInformationShowing

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

Specified by:
isChangeInformationShowing in interface ITextEditorExtension3
Returns:
true if quick diff info is displayed, false otherwise

setStatusLineErrorMessage

protected void setStatusLineErrorMessage(
String message)
Sets the given message as error message to this editor's status line.

Parameters:
message - message to be set
Since:
3.2

setStatusLineMessage

protected void setStatusLineMessage(
String message)
Sets the given message as message to this editor's status line.

Parameters:
message - message to be set
Since:
3.2

gotoAnnotation

public 
Annotation gotoAnnotation(boolean forward)
Jumps to the next annotation according to the given direction.

Specified by:
gotoAnnotation in interface ITextEditorExtension4
Parameters:
forward - true if search direction is forward, false if backward
Returns:
the selected annotation or null if none
Since:
3.2
See Also:
isNavigationTarget(Annotation), findAnnotation(int, int, boolean, Position)

findAnnotation

protected 
Annotation findAnnotation(int offset,
                                    int length,
                                    boolean forward,
                                    
Position annotationPosition)
Returns the annotation closest to the given range respecting the given direction. If an annotation is found, the annotations current position is copied into the provided annotation position.

Parameters:
offset - the region offset
length - the region length
forward - true for forwards, false for backward
annotationPosition - the position of the found annotation
Returns:
the found annotation
Since:
3.2

isNavigationTarget

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

Per default every annotation is a target.

Parameters:
annotation - the annotation
Returns:
true if this is a target, false otherwise
Since:
3.2

showRevisionInformation

public void showRevisionInformation(
RevisionInformation info,
                                    
String quickDiffProviderId)
Description copied from interface: ITextEditorExtension4
Shows revision information in this editor.

Specified by:
showRevisionInformation in interface ITextEditorExtension4
Parameters:
info - the revision information to display
quickDiffProviderId - the quick diff provider that matches the source of the revision information

restoreState

public void restoreState(
IMemento memento)
Description copied from interface: IPersistableEditor
Called with a memento for this editor. The editor can parse the data or save the memento. This method may not be called.

Specified by:
restoreState in interface IPersistableEditor
Parameters:
memento - the saved state for this editor. May be null.

saveState

public void saveState(
IMemento memento)
Description copied from interface: IPersistable
Saves the state of the object in the given memento.

Specified by:
saveState in interface IPersistable
Parameters:
memento - the storage area for object's state

containsSavedState

protected boolean containsSavedState(
IMemento memento)
Returns whether the given memento contains saved state

Subclasses may extend or override this method.

Parameters:
memento - the saved state of this editor
Returns:
true if the given memento contains saved state
Since:
3.3

doRestoreState

protected void doRestoreState(
IMemento memento)
Restores this editor's state using the given memento.

Subclasses may extend or override this method.

Parameters:
memento - the saved state of this editor
Since:
3.3

getSaveables

public 
Saveable[] getSaveables()
Description copied from interface: ISaveablesSource
Returns the saveables presented by the workbench part. If the return value of this method changes during the lifetime of this part (i.e. after initialization and control creation but before disposal) the part must notify an implicit listener using ISaveablesLifecycleListener.handleLifecycleEvent(SaveablesLifecycleEvent).

Additions of saveables to the list of saveables of this part are announced using an event of type SaveablesLifecycleEvent.POST_OPEN. Removals are announced in a two-stage process, first using an event of type SaveablesLifecycleEvent.PRE_CLOSE followed by an event of type SaveablesLifecycleEvent.POST_CLOSE. Since firing the PRE_CLOSE event may trigger prompts to save dirty saveables, the cancellation status of the event must be checked by the part after the notification. When removing only non-dirty saveables, POST_CLOSE notification is sufficient.

The listener is obtained from the part site by calling partSite.getService(ISaveablesLifecycleListener.class).

The part must not notify from its initialization methods (e.g. init or createPartControl), or from its dispose method. Parts that implement IReusableEditor must notify when their input is changed through IReusableEditor.setInput(IEditorInput).

Specified by:
getSaveables in interface ISaveablesSource
Returns:
the saveables presented by the workbench part
See Also:
ISaveablesLifecycleListener

getActiveSaveables

public 
Saveable[] getActiveSaveables()
Description copied from interface: ISaveablesSource
Returns the saveables currently active in the workbench part.

Certain workbench actions, such as Save, target only the active saveables in the active part. For example, the active saveables could be determined based on the current selection in the part.

Specified by:
getActiveSaveables in interface ISaveablesSource
Returns:
the saveables currently active in the workbench part

installTabsToSpacesConverter

protected void installTabsToSpacesConverter()
Installs a tabs to spaces converter.

Subclasses may extend or override this method.

Since:
3.3

uninstallTabsToSpacesConverter

protected void uninstallTabsToSpacesConverter()
Installs a tabs to spaces converter.

Subclasses may extend or override this method.

Since:
3.3

isTabsToSpacesConversionEnabled

protected boolean isTabsToSpacesConversionEnabled()
Tells whether tabs should be converted to spaces while editing inside this editor.

Subclasses may override this method.

Returns:
true if tabs should be converted to spaces
Since:
3.3

updateIndentPrefixes

protected final void updateIndentPrefixes()
Updates the source viewer's indent prefixes with the values provided by the source viewer configuration.

Since:
3.3

isBlockSelectionModeSupported

protected boolean isBlockSelectionModeSupported()
Tells whether selection mode is supported.

By default block selection mode is supported. Subclasses may override this method to disable it.

Returns:
true if block selection mode is supported, false otherwise
Since:
3.5

isBlockSelectionModeEnabled

public final boolean isBlockSelectionModeEnabled()
Description copied from interface: ITextEditorExtension5
Returns true if the receiver is in block (aka column) selection mode, false otherwise.

Specified by:
isBlockSelectionModeEnabled in interface ITextEditorExtension5
Returns:
the receiver's block selection state
Since:
3.5
See Also:
ITextEditorExtension5.isBlockSelectionModeEnabled()

setBlockSelectionMode

public void setBlockSelectionMode(boolean enable)
Description copied from interface: ITextEditorExtension5
Sets the block selection mode state of the receiver to state. Nothing happens if the receiver already is in the requested state.

Specified by:
setBlockSelectionMode in interface ITextEditorExtension5
Parameters:
enable - the new block selection state
Since:
3.5
See Also:
ITextEditorExtension5.setBlockSelectionMode(boolean)

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire