Class AbstractTextEditor
- All Implemented Interfaces:
IAdaptable,IExecutableExtension,IEditorPart,INavigationLocationProvider,IPersistable,IPersistableEditor,IReusableEditor,ISaveablePart,ISaveablesSource,IWorkbenchPart,IWorkbenchPart2,IWorkbenchPart3,IWorkbenchPartOrientation,ITextEditor,ITextEditorExtension,ITextEditorExtension2,ITextEditorExtension3,ITextEditorExtension4,ITextEditorExtension5,ITextEditorExtension6
- Direct Known Subclasses:
StatusTextEditor
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
Nested ClassesModifier and TypeClassDescriptionprotected classInternal implementation class for a change listener.protected static classImplements the ruler column support of for the given editor.protected static final classMaps an action definition id to an StyledText action.protected classThis action implements smart end.protected classThis action implements smart home.protected classEditor specific selection provider which wraps the source viewer's selection provider.protected static classThis text editor's savable.Nested classes/interfaces inherited from interface org.eclipse.ui.texteditor.ITextEditorExtension3
ITextEditorExtension3.InsertMode -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final AbstractTextEditor.IdMapEntry[]The complete mapping between action definition IDs used by eclipse and StyledText actions.static final StringMenu id used to contribute to the editor context menu of all textual editors.static final StringMenu id used to contribute to the ruler context menu of all textual editors.static final StringMenu id for the editor context menu.static final StringMenu id for the ruler context menu.protected final StringThe error message shown in the status line in case of failed information look up.static final StringKey used to look up background color preference.static final StringKey used to look up background color system default preference.static final StringKey used to look up find scope background color preference.static final StringKey used to look up foreground color preference.static final StringKey used to look up foreground color system default preference.static final StringKey used to look up selection background color preference.static final StringKey used to look up selection background color system default preference.static final StringKey used to look up selection foreground color preference.static final StringKey used to look up selection foreground color system default preference.static final StringDeprecated.static final StringA named preference that controls if hovers should automatically be closed when the mouse is moved into them, or when they should be enriched.static final StringA named preference that controls the key modifier for hyperlinks.static final StringA named preference that controls the key modifier mask for hyperlinks.static final StringA named preference that controls if hyperlinks are turned on or off.static final StringKey used to look up smart home/end preference.static final StringA named preference that controls the visible ruler column contributions.static final StringA named preference to control the initial caret offset visibility on the status line.static final StringA named preference that controls the display of Carriage Return characters.static final StringA named preference that controls the display of enclosed Ideographic Space characters.static final StringA named preference that controls the display of enclosed Space characters.static final StringA named preference that controls the display of enclosed Tab characters.static final StringA named preference that controls the display of leading Ideographic Space characters.static final StringA named preference that controls the display of leading Space characters.static final StringA named preference that controls the display of leading Tab characters.static final StringA named preference that controls the display of Line Feed characters.static final StringA named preference to control the selection visibility on the status line.static final StringA named preference that controls the display of trailing Ideographic Space characters.static final StringA named preference that controls the display of trailing Space characters.static final StringA named preference that controls the display of trailing Tab characters.static final StringA named preference that controls the display of whitespace characters.static final StringA named preference that controls whether text drag and drop is enabled.static final StringKey used to look up the custom caret preference.static final StringA named preference that controls the alpha value of whitespace characters.static final StringKey used to look up the caret width preference.static final StringA named preference to control the initial word wrap status.protected static final StringTag used in theIMementowhen saving and restoring the editor's horizontal pixel value.protected static final StringTag used in theIMementowhen saving and restoring the editor's selection length.protected static final StringTag used in theIMementowhen saving and restoring the editor's selection offset.protected static final StringTag used in theIMementowhen saving and restoring the editor's top pixel value.protected static final intThe width of the vertical ruler.Fields inherited from interface org.eclipse.ui.IEditorPart
PROP_DIRTY, PROP_INPUTFields inherited from interface org.eclipse.ui.texteditor.ITextEditorExtension3
INSERT, SMART_INSERTFields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidaddAction(IMenuManager menu, String actionId) Convenience method to add the action installed under the given action id to the given menu.protected final voidaddAction(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 final voidaddGroup(IMenuManager menu, String existingGroup, String newGroup) Convenience method to add a new group after the specified group.voidaddRulerContextMenuListener(IMenuListener listener) Adds a ruler context menu listener to the editor.protected voidadjustHighlightRange(int offset, int length) Adjusts the highlight range so that at least the specified range is highlighted.protected booleanDetermines whether the given preference change affects the editor's presentation.protected booleancanHandleMove(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.voidclose(boolean save) Closes this text editor after optionally saving changes.protected voidconfigureInsertMode(ITextEditorExtension3.InsertMode mode, boolean legal) Configures the given insert mode as legal or illegal.protected booleancontainsSavedState(IMemento memento) Returns whether the given memento contains saved stateprotected voidCreates this editor's standard actions and connects them with the global workbench actions.protected IColumnSupportCreates the column support to be used by this editor to manage the contributed ruler columns.protected IMenuListenerCreates the listener on this editor's context menus.Creates an empty navigation location.protected voidCreates action entries for all SWT StyledText actions as defined inorg.eclipse.swt.custom.ST.Creates a navigation location describing the current state.voidcreatePartControl(Composite parent) TheAbstractTextEditorimplementation of thisIWorkbenchPartmethod creates the vertical ruler and source viewer.protected ISourceViewercreateSourceViewer(Composite parent, IVerticalRuler ruler, int styles) Creates the source viewer to be used by this editor.protected voidCreates this editor's undo/redo actions.protected IVerticalRulerCreates the vertical ruler to be used by this editor.voiddispose()TheAbstractTextEditorimplementation of thisIWorkbenchPartmethod may be extended by subclasses.protected voidDisposes of the connection with the document provider.protected ISelectionReturns the current selection.protected voiddoRestoreState(IMemento memento) Restores this editor's state using the given memento.voidTheAbstractTextEditorimplementation of thisITextEditormethod may be extended by subclasses.voiddoSave(IProgressMonitor progressMonitor) TheAbstractTextEditorimplementation of thisIEditorPartmethod may be extended by subclasses.voiddoSaveAs()TheAbstractTextEditorimplementation of thisIEditorPartmethod callsperformSaveAs.protected voiddoSetInput(IEditorInput input) Called directly fromsetInputand from within a workspace runnable frominit, this method does the actual setting of the editor input.protected voiddoSetSelection(ISelection selection) Sets the given selection.protected voidSets up this editor's context menu before it is made visible.protected voidHook which gets called when the editor has been saved.protected voidenableOverwriteMode(boolean enable) Sets the overwrite mode enablement.protected voidenableSanityChecking(boolean enable) Enables/disables sanity checking.protected voidenableStateValidation(boolean enable) Enables/disables state validation.protected AnnotationfindAnnotation(int offset, int length, boolean forward, Position annotationPosition) Returns the annotation closest to the given range respecting the given direction.protected voidfirePropertyChange(int property) Fires a property changed event.Returns the action installed under the given action id.Saveable[]Returns the saveables currently active in the workbench part.<T> TgetAdapter(Class<T> required) Returns an object which is an instance of the given class associated with this object.protected final IMenuListenerCreates and returns the listener on this editor's context menus.protected static final IRegiongetCoverage(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 final org.eclipse.ui.texteditor.AbstractTextEditor.ICursorListenerReturns this editor's "cursor" listener to be installed on the editor's source viewer.protected StringReturns a description of the cursor position.Returns this text editor's document provider.protected final StringReturns the editor's context menu id.protected final StringReturns the property preference key for the editor font.protected final StringReturns the editor's help context id ornullif none has been set.Returns the highlighted range of this text editor.protected booleanReturns the initial word wrap status.Returns the current input mode of this editor.protected List<ITextEditorExtension3.InsertMode> Returns the set of legal insert modes.protected final IPreferenceStoreReturns this editor's preference store ornullif none has been set.protected IProgressMonitorReturns the progress monitor related to this editor.protected final AnnotationReturns the editor's range indicator.protected final StringReturns the ruler's context menu id.protected final MouseListenerCreates and returns the listener on this editor's vertical ruler.Saveable[]Returns the saveables presented by the workbench part.protected final ISelectionChangedListenerReturns this editor's selection changed listener to be installed on the editor's source viewer.Returns this text editor's selection provider.protected final ISourceViewerReturns the editor's source viewer.protected final SourceViewerConfigurationReturns the editor's source viewer configuration.protected IStatusFieldgetStatusField(String category) Returns the current status field for the given status category.protected IStatusLineManagerReturns the status line manager of this editor.protected IOperationApprovergetUndoRedoOperationApprover(IUndoContext undoContext) Return anIOperationApproverappropriate for approving the undo and redo of operations that have the specified undo context.protected final IVerticalRulerReturns the editor's vertical ruler.gotoAnnotation(boolean forward) Jumps to the next annotation according to the given direction.protected voidHandles a potential change of the cursor position.protected voidHandles an external change of the editor's input element.protected voidPerforms any additional action necessary to perform after the input document's content has been replaced.protected voidhandleExceptionOnSave(CoreException exception, IProgressMonitor progressMonitor) Handles the given exception.protected voidHandles a change of the editor's insert mode.protected voidHandles a property change event describing a change of the editor's preference store and updates the preference related editor properties.voidinit(IEditorSite site, IEditorInput input) Initializes this editor with the given editor site and input.protected voidinitializeDragAndDrop(ISourceViewer viewer) Initializes the drag and drop support for the given viewer based on provided editor adapter for drop target listeners.protected voidinitializeViewerColors(ISourceViewer viewer) Initializes the fore- and background colors of the given viewer for both normal and selected text.protected voidInstall codemining providers.protected voidInstalls a tabs to spaces converter.protected voidinstallTextDragAndDrop(ISourceViewer viewer) Installs text drag and drop on the given source viewer.protected final voidinternalInit(IWorkbenchWindow window, IEditorSite site, IEditorInput input) Implements theinitmethod ofIEditorPart.final booleanReturnstrueif the receiver is in block (aka column) selection mode,falseotherwise.protected booleanTells whether selection mode is supported.booleanReturns the quick diff display state.booleanisDirty()Returns whether the contents of this part have changed since the last save operation.booleanReturns whether the text in this text editor can be changed by the user.protected booleanTells whether the editor input should be included when adding object contributions to this editor's context menu.booleanReturns whether the editor's input can be persistently be modified.booleanReturns whether the editor's input is read-only.protected booleanReturns whether this editor is in overwrite or insert mode.protected booleanisNavigationTarget(Annotation annotation) Returns whether the given annotation is configured as a target for the "Go to Next/Previous Annotation" actions.booleanTheAbstractTextEditorimplementation of thisIEditorPartmethod returnsfalse.protected booleanTells whether delete and backspace keys should remove multiple spaces as if they were a tab.protected booleanTells whether tabs should be converted to spaces while editing inside this editor.protected static final booleanisVisible(ISourceViewer viewer, int offset, int length) Tells whether the given region is visible in the given source viewer.final booleantrueif word wrap is supported and enabled,falseotherwiseprotected booleanTells whether word wrap is supported.voidmarkAsContentDependentAction(String actionId, boolean mark) Marks or unmarks the given action to be updated on content changes.voidmarkAsPropertyDependentAction(String actionId, boolean mark) Marks or unmarks the given action to be updated on property changes.voidmarkAsSelectionDependentAction(String actionId, boolean mark) Marks or unmarks the given action to be updated on text selection changes.voidmarkAsStateDependentAction(String actionId, boolean mark) Marks or unmarks the given action to be updated on state changes.protected voidWrites a check mark of the given situation into the navigation history.protected static final intmodelOffset2WidgetOffset(ISourceViewer viewer, int modelOffset) Returns the offset of the given source viewer's text widget that corresponds to the given model offset or-1if there is no such offset.protected voidopenSaveErrorDialog(String title, String message, CoreException exception) Presents an error dialog to the user when a problem happens during save.protected voidPerforms revert and handles errors appropriately.protected voidperformSave(boolean overwrite, IProgressMonitor progressMonitor) Performs the save and handles errors appropriately.protected voidperformSaveAs(IProgressMonitor progressMonitor) Performs a save as and reports the result state back to the given progress monitor.protected voidRemembers the current selection of this editor.voidremoveActionActivationCode(String actionID) Removes any installed activation code for the specified action.voidremoveRulerContextMenuListener(IMenuListener listener) Removes a ruler context menu listener from the editor.voidResets the highlighted range of this text editor.protected voidRestores a selection previously remembered byrememberSelection.voidrestoreState(IMemento memento) Called with a memento for this editor.protected voidSets up the ruler context menu before it is made visible.protected voidChecks the state of the given editor input if sanity checking is enabled.protected voidsanityCheckState(IEditorInput input) Checks the state of the given editor input.voidSaves the state of the object in the given memento.voidselectAndReveal(int start, int length) Selects and reveals the specified range in this text editor.protected voidselectAndReveal(int selectionStart, int selectionLength, int revealStart, int revealLength) Selects and reveals the specified ranges in this text editor.voidInstalls the given action under the given action id.voidsetActionActivationCode(String actionID, char activationCharacter, int activationKeyCode, int activationStateMask) Sets the given activation code for the specified action.voidsetBlockSelectionMode(boolean enable) Sets the block selection mode state of the receiver tostate.protected final voidsetCompatibilityMode(boolean compatible) Sets the context menu registration 1.0 compatibility mode.protected voidsetDocumentProvider(IEditorInput input) Hook method for setting the document provider for the given input.protected voidsetDocumentProvider(IDocumentProvider provider) Sets this editor's document provider.protected voidsetEditorContextMenuId(String contextMenuId) Sets this editor's context menu id.voidsetFocus()Asks this part to take focus within the workbench.protected voidsetHelpContextId(String helpContextId) Sets the editor's help context id.voidsetHighlightRange(int offset, int length, boolean moveCursor) Sets the highlighted range of this text editor to the specified region.final voidsetInput(IEditorInput input) Sets the input to this editor.protected final voidsetInputWithNotify(IEditorInput input) Sets the input to this editor and fires a PROP_INPUT property change if the input has changed.voidSets the insert mode of this editor.protected voidsetKeyBindingScopes(String[] scopes) Sets the key binding scopes for this editor.protected voidSets this editor's preference store.protected voidsetRangeIndicator(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 voidsetRulerContextMenuId(String contextMenuId) Sets the ruler's context menu id.protected voidsetSourceViewerConfiguration(SourceViewerConfiguration configuration) Sets this editor's source viewer configuration used to configure its internal source viewer.voidsetStatusField(IStatusField field, String category) Informs the editor which status field is to be used when posting status information in the given category.protected voidsetStatusLineErrorMessage(String message) Sets the given message as error message to this editor's status line.protected voidsetStatusLineMessage(String message) Sets the given message as message to this editor's status line.voidsetWordWrap(boolean enable) Sets whether the text editor wraps lines.voidshowChangeInformation(boolean show) Sets the display of quick diff information.voidshowHighlightRangeOnly(boolean showHighlightRangeOnly) Configures this text editor to show only the highlighted range of the text.voidshowRevisionInformation(RevisionInformation info, String quickDiffProviderId) Shows revision information in this editor.booleanReturns whether this text editor is configured to show only the highlighted range of the text.protected voidInstalls a tabs to spaces converter.protected voidUninstalls text drag and drop from the given source viewer.protected voidUpdates all content dependent actions.protected voidAdds enabled ruler contributions to the vertical ruler.protected final voidUpdates the source viewer's indent prefixes with the values provided by the source viewer configuration.protected voidUpdates all property dependent actions.protected voidUpdates all selection dependent actions.protected voidupdateState(IEditorInput input) Updates the state of the given editor input such as read-only flag.protected voidUpdates all state dependent actions.protected voidupdateStatusField(String category) Updates the status fields for the given category.protected voidUpdates all status fields.booleanValidates the state of the given editor input.protected voidvalidateState(IEditorInput input) Validates the state of the given editor input.protected static final intwidgetOffset2ModelOffset(ISourceViewer viewer, int widgetOffset) Returns the offset of the given source viewer's document that corresponds to the given widget offset or-1if there is no such offset.Methods inherited from class org.eclipse.ui.part.EditorPart
checkSite, getEditorInput, getEditorSite, getTitleToolTip, isSaveOnCloseNeeded, setContentDescription, setInitializationData, setPartNameMethods 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, showBusyMethods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObjectMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.ui.IEditorPart
getEditorInput, getEditorSiteMethods inherited from interface org.eclipse.ui.ISaveablePart
isSaveOnCloseNeededMethods inherited from interface org.eclipse.ui.IWorkbenchPart
addPropertyListener, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener
-
Field Details
-
TAG_SELECTION_OFFSET
Tag used in theIMementowhen saving and restoring the editor's selection offset.- Since:
- 3.3
- See Also:
-
TAG_SELECTION_LENGTH
Tag used in theIMementowhen saving and restoring the editor's selection length.- Since:
- 3.3
- See Also:
-
TAG_SELECTION_TOP_PIXEL
Tag used in theIMementowhen saving and restoring the editor's top pixel value.- Since:
- 3.6
- See Also:
-
TAG_SELECTION_HORIZONTAL_PIXEL
Tag used in theIMementowhen saving and restoring the editor's horizontal pixel value.- Since:
- 3.6
- See Also:
-
PREFERENCE_FONT
Deprecated.As of 2.1, replaced byJFaceResources.TEXT_FONTKey used to look up font preference. Value:"org.eclipse.jface.textfont"- See Also:
-
PREFERENCE_COLOR_FOREGROUND
Key used to look up foreground color preference. Value:AbstractTextEditor.Color.Foreground- Since:
- 2.0
- See Also:
-
PREFERENCE_COLOR_BACKGROUND
Key used to look up background color preference. Value:AbstractTextEditor.Color.Background- Since:
- 2.0
- See Also:
-
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:
-
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:
-
PREFERENCE_COLOR_SELECTION_FOREGROUND
Key used to look up selection foreground color preference. Value:AbstractTextEditor.Color.SelectionForeground- Since:
- 3.0
- See Also:
-
PREFERENCE_COLOR_SELECTION_BACKGROUND
Key used to look up selection background color preference. Value:AbstractTextEditor.Color.SelectionBackground- Since:
- 3.0
- See Also:
-
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:
-
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:
-
PREFERENCE_COLOR_FIND_SCOPE
Key used to look up find scope background color preference. Value:AbstractTextEditor.Color.FindScope- Since:
- 2.0
- See Also:
-
PREFERENCE_NAVIGATION_SMART_HOME_END
Key used to look up smart home/end preference. Value:AbstractTextEditor.Navigation.SmartHomeEnd- Since:
- 2.1
- See Also:
-
PREFERENCE_USE_CUSTOM_CARETS
Key used to look up the custom caret preference. Value: "AbstractTextEditor.Accessibility.UseCustomCarets"- Since:
- 3.0
- See Also:
-
PREFERENCE_WIDE_CARET
Key used to look up the caret width preference. Value: "AbstractTextEditor.Accessibility.WideCaret"- Since:
- 3.0
- See Also:
-
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:
-
PREFERENCE_HYPERLINK_KEY_MODIFIER
A named preference that controls the key modifier for hyperlinks.Value is of type
String.- Since:
- 3.1
- See Also:
-
PREFERENCE_HYPERLINK_KEY_MODIFIER_MASK
A named preference that controls the key modifier mask for hyperlinks. The value is only used if the value ofPREFERENCE_HYPERLINK_KEY_MODIFIERcannot be resolved to valid SWT modifier bits.Value is of type
String.- Since:
- 3.1
- See Also:
-
PREFERENCE_RULER_CONTRIBUTIONS
A named preference that controls the visible ruler column contributions.Value is of type
Stringand should be read using aRulerColumnPreferenceAdapter.- Since:
- 3.3
- See Also:
-
PREFERENCE_SHOW_WHITESPACE_CHARACTERS
A named preference that controls the display of whitespace characters.Value is of type
Boolean.The following preferences can be used for fine-grained configuration when enabled.
PREFERENCE_SHOW_LEADING_SPACESPREFERENCE_SHOW_ENCLOSED_SPACESPREFERENCE_SHOW_TRAILING_SPACESPREFERENCE_SHOW_LEADING_IDEOGRAPHIC_SPACESPREFERENCE_SHOW_ENCLOSED_IDEOGRAPHIC_SPACESPREFERENCE_SHOW_TRAILING_IDEOGRAPHIC_SPACESPREFERENCE_SHOW_LEADING_TABSPREFERENCE_SHOW_ENCLOSED_TABSPREFERENCE_SHOW_TRAILING_TABSPREFERENCE_SHOW_CARRIAGE_RETURNPREFERENCE_SHOW_LINE_FEEDPREFERENCE_WHITESPACE_CHARACTER_ALPHA_VALUE
- Since:
- 3.3
- See Also:
-
PREFERENCE_SHOW_LEADING_SPACES
A named preference that controls the display of leading Space characters. The value is used only if the value ofPREFERENCE_SHOW_WHITESPACE_CHARACTERSistrue.Value is of type
Boolean.- Since:
- 3.7
- See Also:
-
PREFERENCE_SHOW_ENCLOSED_SPACES
A named preference that controls the display of enclosed Space characters. The value is used only if the value ofPREFERENCE_SHOW_WHITESPACE_CHARACTERSistrue.Value is of type
Boolean.- Since:
- 3.7
- See Also:
-
PREFERENCE_SHOW_TRAILING_SPACES
A named preference that controls the display of trailing Space characters. The value is used only if the value ofPREFERENCE_SHOW_WHITESPACE_CHARACTERSistrue.Value is of type
Boolean.- Since:
- 3.7
- See Also:
-
PREFERENCE_SHOW_LEADING_IDEOGRAPHIC_SPACES
A named preference that controls the display of leading Ideographic Space characters. The value is used only if the value ofPREFERENCE_SHOW_WHITESPACE_CHARACTERSistrue.Value is of type
Boolean.- Since:
- 3.7
- See Also:
-
PREFERENCE_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES
A named preference that controls the display of enclosed Ideographic Space characters. The value is used only if the value ofPREFERENCE_SHOW_WHITESPACE_CHARACTERSistrue.Value is of type
Boolean.- Since:
- 3.7
- See Also:
-
PREFERENCE_SHOW_TRAILING_IDEOGRAPHIC_SPACES
A named preference that controls the display of trailing Ideographic Space characters. The value is used only if the value ofPREFERENCE_SHOW_WHITESPACE_CHARACTERSistrue.Value is of type
Boolean.- Since:
- 3.7
- See Also:
-
PREFERENCE_SHOW_LEADING_TABS
A named preference that controls the display of leading Tab characters. The value is used only if the value ofPREFERENCE_SHOW_WHITESPACE_CHARACTERSistrue.Value is of type
Boolean.- Since:
- 3.7
- See Also:
-
PREFERENCE_SHOW_ENCLOSED_TABS
A named preference that controls the display of enclosed Tab characters. The value is used only if the value ofPREFERENCE_SHOW_WHITESPACE_CHARACTERSistrue.Value is of type
Boolean.- Since:
- 3.7
- See Also:
-
PREFERENCE_SHOW_TRAILING_TABS
A named preference that controls the display of trailing Tab characters. The value is used only if the value ofPREFERENCE_SHOW_WHITESPACE_CHARACTERSistrue.Value is of type
Boolean.- Since:
- 3.7
- See Also:
-
PREFERENCE_SHOW_CARRIAGE_RETURN
A named preference that controls the display of Carriage Return characters. The value is used only if the value ofPREFERENCE_SHOW_WHITESPACE_CHARACTERSistrue.Value is of type
Boolean.- Since:
- 3.7
- See Also:
-
PREFERENCE_SHOW_LINE_FEED
A named preference that controls the display of Line Feed characters. The value is used only if the value ofPREFERENCE_SHOW_WHITESPACE_CHARACTERSistrue.Value is of type
Boolean.- Since:
- 3.7
- See Also:
-
PREFERENCE_WHITESPACE_CHARACTER_ALPHA_VALUE
A named preference that controls the alpha value of whitespace characters. The value is used only if the value ofPREFERENCE_SHOW_WHITESPACE_CHARACTERSistrue.Value is of type
Integer.- Since:
- 3.7
- See Also:
-
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:
-
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
Integerand maps to the followingITextViewerExtension8.EnrichMode:- -1:
null(don't allow moving the mouse into a hover), - 0:
ITextViewerExtension8.EnrichMode.AFTER_DELAY, - 1:
ITextViewerExtension8.EnrichMode.IMMEDIATELY, - 2:
ITextViewerExtension8.EnrichMode.ON_CLICK.
- Since:
- 3.4
- See Also:
- -1:
-
PREFERENCE_WORD_WRAP_ENABLED
A named preference to control the initial word wrap status.Value is of type
Boolean.- Since:
- 3.10
- See Also:
-
PREFERENCE_SHOW_CARET_OFFSET
A named preference to control the initial caret offset visibility on the status line.Value is of type
Boolean.- Since:
- 3.13
- See Also:
-
PREFERENCE_SHOW_SELECTION_SIZE
A named preference to control the selection visibility on the status line.Value is of type
Boolean.- Since:
- 3.13
- See Also:
-
DEFAULT_EDITOR_CONTEXT_MENU_ID
Menu id for the editor context menu.- See Also:
-
DEFAULT_RULER_CONTEXT_MENU_ID
Menu id for the ruler context menu.- See Also:
-
COMMON_EDITOR_CONTEXT_MENU_ID
Menu id used to contribute to the editor context menu of all textual editors.- Since:
- 3.5
- See Also:
-
COMMON_RULER_CONTEXT_MENU_ID
Menu id used to contribute to the ruler context menu of all textual editors.- Since:
- 3.5
- See Also:
-
VERTICAL_RULER_WIDTH
protected static final int VERTICAL_RULER_WIDTHThe width of the vertical ruler.- See Also:
-
ACTION_MAP
The complete mapping between action definition IDs used by eclipse and StyledText actions.- Since:
- 2.0
-
fErrorLabel
The error message shown in the status line in case of failed information look up.
-
-
Constructor Details
-
AbstractTextEditor
protected AbstractTextEditor()Creates a new text editor. If not explicitly set, this editor uses aSourceViewerConfigurationto 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 Details
-
getDocumentProvider
Description copied from interface:ITextEditorReturns this text editor's document provider.- Specified by:
getDocumentProviderin interfaceITextEditor- Returns:
- the document provider or
nullif none, e.g. after closing the editor
-
getRangeIndicator
Returns the editor's range indicator. May returnnullif no range indicator is installed.- Returns:
- the editor's range indicator which may be
null
-
getSourceViewerConfiguration
Returns the editor's source viewer configuration. May returnnullbefore the editor's part has been created and after disposal.- Returns:
- the editor's source viewer configuration which may be
null
-
getSourceViewer
Returns the editor's source viewer. May returnnullbefore the editor's part has been created and after disposal.- Returns:
- the editor's source viewer which may be
null
-
getVerticalRuler
Returns the editor's vertical ruler. May returnnullbefore the editor's part has been created and after disposal.- Returns:
- the editor's vertical ruler which may be
null
-
getEditorContextMenuId
Returns the editor's context menu id. May returnnullbefore the editor's part has been created.- Returns:
- the editor's context menu id which may be
null
-
getRulerContextMenuId
Returns the ruler's context menu id. May returnnullbefore the editor's part has been created.- Returns:
- the ruler's context menu id which may be
null
-
getHelpContextId
Returns the editor's help context id ornullif none has been set.- Returns:
- the editor's help context id which may be
null
-
getPreferenceStore
Returns this editor's preference store ornullif none has been set.- Returns:
- this editor's preference store which may be
null
-
setDocumentProvider
Sets this editor's document provider. This method must be called before the editor's control is created.- Parameters:
provider- the document provider
-
setSourceViewerConfiguration
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 aSourceViewerConfiguration.- Parameters:
configuration- the source viewer configuration object
-
setRangeIndicator
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
Sets this editor's context menu id.- Parameters:
contextMenuId- the context menu id
-
setRulerContextMenuId
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-trueif compatibility mode is enabled- Since:
- 2.0
-
setHelpContextId
Sets the editor's help context id.- Parameters:
helpContextId- the help context id
-
setKeyBindingScopes
Sets the key binding scopes for this editor.- Parameters:
scopes- a non-empty array of key binding scope identifiers- Since:
- 2.1
-
setPreferenceStore
Sets this editor's preference store. This method must be called before the editor's control is created.- Parameters:
store- the preference store ornullto remove the preference store
-
isEditable
public boolean isEditable()Description copied from interface:ITextEditorReturns whether the text in this text editor can be changed by the user.- Specified by:
isEditablein interfaceITextEditor- Returns:
trueif it can be edited, andfalseif it is read-only
-
getSelectionProvider
Returns this text editor's selection provider. Repeated calls to this method return the same selection provider.Returns
nullafter disposal.- Specified by:
getSelectionProviderin interfaceITextEditor- Returns:
- the selection provider or
nullif 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:
-
doGetSelection
Returns the current selection.- Returns:
- ISelection
- Since:
- 2.1
-
restoreSelection
protected void restoreSelection()Restores a selection previously remembered byrememberSelection. 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:
-
doSetSelection
Sets the given selection.- Parameters:
selection- the selection- Since:
- 2.1
-
createContextMenuListener
Creates the listener on this editor's context menus.- Returns:
- the created menu listener
- Since:
- 3.4
-
getContextMenuListener
Creates and returns the listener on this editor's context menus.- Returns:
- the menu listener
-
getRulerMouseListener
Creates and returns the listener on this editor's vertical ruler.- Returns:
- the mouse listener
-
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 callinghandleCursorPositionChanged().- Returns:
- the listener
- Since:
- 2.0
-
internalInit
protected final void internalInit(IWorkbenchWindow window, IEditorSite site, IEditorInput input) throws PartInitException Implements theinitmethod ofIEditorPart. Subclasses replacinginitmay choose to call this method in their implementation.- Parameters:
window- the workbench windowsite- the editor's siteinput- the editor input for the editor being created- Throws:
PartInitException- ifdoSetInput(IEditorInput)fails or gets canceled- Since:
- 2.1
- See Also:
-
init
Description copied from interface:IEditorPartInitializes 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.disposemethod 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:
initin interfaceIEditorPart- Specified by:
initin classEditorPart- Parameters:
site- the editor siteinput- the editor input- Throws:
PartInitException- if this editor was not initialized successfully
-
createVerticalRuler
Creates the vertical ruler to be used by this editor. Subclasses may re-implement this method.- Returns:
- the vertical ruler
-
updateContributedRulerColumns
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
Creates the column support to be used by this editor to manage the contributed ruler columns. Subclasses may re-implement this method using theAbstractTextEditor.ColumnSupport, e.g. by returningnew ColumnSupport(this, RulerColumnRegistry.getDefault());.Note: If you override this method to provide column support you will also need to override
createVerticalRuler()to return aCompositeRuler.Out of the box this class does not install this support and hence this implementation always returns
null.- Returns:
- the column support or
nullif none - Since:
- 3.3
-
createSourceViewer
Creates the source viewer to be used by this editor. Subclasses may re-implement this method.- Parameters:
parent- the parent controlruler- the vertical rulerstyles- style bits,SWT.WRAPis currently not supported- Returns:
- the source viewer
-
initializeDragAndDrop
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
TheAbstractTextEditorimplementation of thisIWorkbenchPartmethod creates the vertical ruler and source viewer.Subclasses may extend this method. Besides extending this method, the behavior of
createPartControlmay be customized by calling, extending or replacing the following methods:
Subclasses may supply customized implementations for some members using the following methods beforecreatePartControlis invoked:- setSourceViewerConfiguration to supply a custom source viewer configuration,
- setRangeIndicator to provide a range indicator,
- setHelpContextId to provide a help context id,
- setEditorContextMenuId to set a custom context menu id,
- setRulerContextMenuId to set a custom ruler context menu id.
Subclasses may replace the following methods called from withincreatePartControl:- createVerticalRuler to supply a custom vertical ruler,
- createSourceViewer to supply a custom source viewer,
- getSelectionProvider to supply a custom selection provider.
Subclasses may extend the following methods called from withincreatePartControl:- initializeViewerColors to customize the viewer color scheme (may also be replaced),
- initializeDragAndDrop to customize drag and drop (may also be replaced),
- createNavigationActions to add navigation actions,
- createActions to add text editor actions.
- Specified by:
createPartControlin interfaceIWorkbenchPart- Specified by:
createPartControlin classWorkbenchPart- Parameters:
parent- the parent composite
-
installTextDragAndDrop
Installs text drag and drop on the given source viewer.- Parameters:
viewer- the viewer- Since:
- 3.3
-
uninstallTextDragAndDrop
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:
trueif the editor input should be considered- Since:
- 3.2
-
initializeViewerColors
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
-
installCodeMiningProviders
protected void installCodeMiningProviders()Install codemining providers.- Since:
- 3.11
-
setDocumentProvider
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
Called directly fromsetInputand from within a workspace runnable frominit, this method does the actual setting of the editor input. Closes the editor ifinputisnull. 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
Description copied from class:EditorPartSets 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:
setInputWithNotifyin classEditorPart- Parameters:
input- the editor input
-
setInput
Description copied from class:EditorPartSets 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:
setInputin interfaceIReusableEditor- Overrides:
setInputin classEditorPart- Parameters:
input- the editor input- See Also:
-
close
public void close(boolean save) Description copied from interface:ITextEditorCloses this text editor after optionally saving changes.- Specified by:
closein interfaceITextEditor- Parameters:
save-trueif unsaved changed should be saved, andfalseif unsaved changed should be discarded
-
dispose
public void dispose()TheAbstractTextEditorimplementation of thisIWorkbenchPartmethod may be extended by subclasses. Subclasses must callsuper.dispose().Note that many methods may return
nullafter the editor is disposed.- Specified by:
disposein interfaceIWorkbenchPart- Overrides:
disposein classWorkbenchPart
-
disposeDocumentProvider
protected void disposeDocumentProvider()Disposes of the connection with the document provider. Subclasses may extend.- Since:
- 3.0
-
affectsTextPresentation
Determines whether the given preference change affects the editor's presentation. This implementation always returnsfalse. May be reimplemented by subclasses.- Parameters:
event- the event which should be investigated- Returns:
trueif the event describes a preference change affecting the editor's presentation- Since:
- 2.0
-
getFontPropertyPreferenceKey
Returns the property preference key for the editor font.If the editor is defined with a
symbolicFontNamethen this name is returned and the font is looked up in the JFace resource registry. Otherwise,JFaceResources.TEXT_FONTis returned and the font is looked up in this editor's preference store.- Returns:
- a String with the key
- Since:
- 2.1
-
handlePreferenceStoreChanged
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
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()TheAbstractTextEditorimplementation of thisIEditorPartmethod callsperformSaveAs. Subclasses may reimplement.- Specified by:
doSaveAsin interfaceISaveablePart- Specified by:
doSaveAsin classEditorPart
-
performSaveAs
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 ornull
-
doSave
TheAbstractTextEditorimplementation of thisIEditorPartmethod may be extended by subclasses.- Specified by:
doSavein interfaceISaveablePart- Specified by:
doSavein classEditorPart- Parameters:
progressMonitor- the progress monitor for communicating result state ornull
-
enableSanityChecking
protected void enableSanityChecking(boolean enable) Enables/disables sanity checking.- Parameters:
enable-trueif sanity checking should be enabled,falseotherwise- Since:
- 2.0
-
safelySanityCheckState
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
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-trueif state validation should be enabled,falseotherwise- Since:
- 2.1
-
validateState
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:ITextEditorExtension2Validates 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:
validateEditorInputStatein interfaceITextEditorExtension2- Returns:
trueif the input was validated,falseotherwise
-
updateState
Updates the state of the given editor input such as read-only flag.- Parameters:
input- the input to be validated- Since:
- 2.0
-
performSave
Performs the save and handles errors appropriately.- Parameters:
overwrite- indicates whether or not overwriting is allowedprogressMonitor- the monitor in which to run the operation- Since:
- 3.0
-
handleExceptionOnSave
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 handleprogressMonitor- the progress monitor
-
openSaveErrorDialog
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 titlemessage- the message to displayexception- the exception to handle- Since:
- 3.3
-
isSaveAsAllowed
public boolean isSaveAsAllowed()TheAbstractTextEditorimplementation of thisIEditorPartmethod returnsfalse. Subclasses may override.- Specified by:
isSaveAsAllowedin interfaceISaveablePart- Specified by:
isSaveAsAllowedin classEditorPart- Returns:
false
-
isDirty
public boolean isDirty()Description copied from interface:ISaveablePartReturns 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 withPROP_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:
isDirtyin interfaceISaveablePart- Specified by:
isDirtyin classEditorPart- Returns:
trueif the contents have been modified and need saving, andfalseif they have not changed since the last save
-
doRevertToSaved
public void doRevertToSaved()TheAbstractTextEditorimplementation of thisITextEditormethod may be extended by subclasses.- Specified by:
doRevertToSavedin interfaceITextEditor
-
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
Description copied from interface:ITextEditorInstalls the given action under the given action id.- Specified by:
setActionin interfaceITextEditor- Parameters:
actionID- the action idaction- the action, ornullto clear it- See Also:
-
setActionActivationCode
public void setActionActivationCode(String actionID, char activationCharacter, int activationKeyCode, int activationStateMask) Description copied from interface:ITextEditorSets 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 aKeyEvent. If the activation code is triggered and the associated action is enabled, the action is performed and the triggeringKeyEventis considered consumed. If the action is disabled, theKeyEventis passed on unmodified. Thus, action activation codes and action accelerators differ in their model of event consumption. The key code parameter can be-1to indicate a wild card. The state mask parameter can be SWT.DEFAULT to indicate a wild card.- Specified by:
setActionActivationCodein interfaceITextEditor- Parameters:
actionID- the action idactivationCharacter- the activation code characteractivationKeyCode- the activation code key code or-1for wild cardactivationStateMask- the activation code state mask orSWT.DEFAULTfor wild card
-
removeActionActivationCode
Description copied from interface:ITextEditorRemoves any installed activation code for the specified action. If no activation code is installed, this method does not have any effect.- Specified by:
removeActionActivationCodein interfaceITextEditor- Parameters:
actionID- the action id
-
getAction
Description copied from interface:ITextEditorReturns the action installed under the given action id.- Specified by:
getActionin interfaceITextEditor- Parameters:
actionID- the action id- Returns:
- the action, or
nullif none - See Also:
-
markAsSelectionDependentAction
Marks or unmarks the given action to be updated on text selection changes.- Parameters:
actionId- the action idmark-trueif the action is selection dependent
-
markAsContentDependentAction
Marks or unmarks the given action to be updated on content changes.- Parameters:
actionId- the action idmark-trueif the action is content dependent
-
markAsPropertyDependentAction
Marks or unmarks the given action to be updated on property changes.- Parameters:
actionId- the action idmark-trueif the action is property dependent- Since:
- 2.0
-
markAsStateDependentAction
Marks or unmarks the given action to be updated on state changes.- Parameters:
actionId- the action idmark-trueif 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
-
createUndoRedoActions
protected void createUndoRedoActions()Creates this editor's undo/redo actions.Subclasses may override or extend.
- Since:
- 3.1
-
getUndoRedoOperationApprover
Return anIOperationApproverappropriate 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
IOperationApproverappropriate for approving undo and redo operations inside this editor, ornullif 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
Convenience method to add the action installed under the given action id to the given menu.- Parameters:
menu- the menu to add the action toactionId- the id of the action to be added
-
addAction
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 togroup- the group in the menuactionId- the id of the action to add
-
addGroup
Convenience method to add a new group after the specified group.- Parameters:
menu- the menu to add the new group toexistingGroup- the group after which to insert the new groupnewGroup- the new group
-
rulerContextMenuAboutToShow
Sets up the ruler context menu before it is made visible.Subclasses may extend to add other actions.
- Parameters:
menu- the menu
-
editorContextMenuAboutToShow
Sets up this editor's context menu before it is made visible.Subclasses may extend to add other actions.
- Parameters:
menu- the menu
-
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
Description copied from class:WorkbenchPartReturns an object which is an instance of the given class associated with this object. Returnsnullif no such object can be found.Clients may implement this method but should generally call
Adapters.adapt(Object, Class, boolean)rather than invoking it directly. Subclasses may override this method (however, if they do so, they should invoke the method on their superclass to ensure that the Platform's adapter manager is consulted).- Specified by:
getAdapterin interfaceIAdaptable- Overrides:
getAdapterin classWorkbenchPart- Type Parameters:
T- the class type- Parameters:
required- the adapter class to look up- Returns:
- a object of the given class, or
nullif this object does not have an adapter for the given class
-
setFocus
public void setFocus()Description copied from interface:IWorkbenchPartAsks 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:
setFocusin interfaceIWorkbenchPart- Specified by:
setFocusin classWorkbenchPart
-
showsHighlightRangeOnly
public boolean showsHighlightRangeOnly()Description copied from interface:ITextEditorReturns whether this text editor is configured to show only the highlighted range of the text.- Specified by:
showsHighlightRangeOnlyin interfaceITextEditor- Returns:
trueif only the highlighted range is shown, andfalseif this editor shows the entire text of the document- See Also:
-
showHighlightRangeOnly
public void showHighlightRangeOnly(boolean showHighlightRangeOnly) Description copied from interface:ITextEditorConfigures this text editor to show only the highlighted range of the text.- Specified by:
showHighlightRangeOnlyin interfaceITextEditor- Parameters:
showHighlightRangeOnly-trueif only the highlighted range is shown, andfalseif this editor shows the entire text of the document- See Also:
-
setHighlightRange
public void setHighlightRange(int offset, int length, boolean moveCursor) Description copied from interface:ITextEditorSets the highlighted range of this text editor to the specified region.- Specified by:
setHighlightRangein interfaceITextEditor- Parameters:
offset- the offset of the highlighted rangelength- the length of the highlighted rangemoveCursor-trueif the cursor should be moved to the start of the highlighted range, andfalseto leave the cursor unaffected - has no effect if the range to highlight is already the highlighted one- See Also:
-
getHighlightRange
Description copied from interface:ITextEditorReturns the highlighted range of this text editor.- Specified by:
getHighlightRangein interfaceITextEditor- Returns:
- the highlighted range
- See Also:
-
resetHighlightRange
public void resetHighlightRange()Description copied from interface:ITextEditorResets the highlighted range of this text editor.- Specified by:
resetHighlightRangein interfaceITextEditor
-
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 highlightedlength- the length of the range which at least should be highlighted
-
selectAndReveal
public void selectAndReveal(int start, int length) Description copied from interface:ITextEditorSelects and reveals the specified range in this text editor.- Specified by:
selectAndRevealin interfaceITextEditor- Parameters:
start- the offset of the selectionlength- 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 selectionselectionLength- the length of the selectionrevealStart- the offset of the revealed rangerevealLength- the length of the revealed range- Since:
- 3.0
-
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:WorkbenchPartFires a property changed event.- Overrides:
firePropertyChangein classWorkbenchPart- Parameters:
property- the id of the property that changed
-
setStatusField
Description copied from interface:ITextEditorExtensionInforms the editor which status field is to be used when posting status information in the given category.- Specified by:
setStatusFieldin interfaceITextEditorExtension- Parameters:
field- the status field to be usedcategory- the status information category- See Also:
-
getStatusField
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:
trueif in insert mode,falsefor overwrite mode- Since:
- 2.0
-
getInsertMode
Description copied from interface:ITextEditorExtension3Returns the current input mode of this editor.- Specified by:
getInsertModein interfaceITextEditorExtension3- Returns:
- the current input mode of this editor
-
setInsertMode
Description copied from interface:ITextEditorExtension3Sets the insert mode of this editor.- Specified by:
setInsertModein interfaceITextEditorExtension3- Parameters:
newMode- the new insert mode
-
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
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 configuredlegal-trueif the given mode is legal,falseotherwise- Since:
- 3.0
-
enableOverwriteMode
protected void enableOverwriteMode(boolean enable) Sets the overwrite mode enablement.- Parameters:
enable-trueto enable new overwrite mode,falseto 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
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
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:ITextEditorExtensionReturns whether the editor's input is read-only. The semantics of this method is orthogonal toisEditableas it talks about the editor input, i.e. the domain element, and not about the editor document.- Specified by:
isEditorInputReadOnlyin interfaceITextEditorExtension- Returns:
trueif the editor input is read-only
-
isEditorInputModifiable
public boolean isEditorInputModifiable()Description copied from interface:ITextEditorExtension2Returns whether the editor's input can be persistently be modified. This is orthogonal toITextEditorExtension.isEditorInputReadOnlyas 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:
isEditorInputModifiablein interfaceITextEditorExtension2- Returns:
trueif the editor input is modifiable
-
addRulerContextMenuListener
Description copied from interface:ITextEditorExtensionAdds a ruler context menu listener to the editor.- Specified by:
addRulerContextMenuListenerin interfaceITextEditorExtension- Parameters:
listener- the listener
-
removeRulerContextMenuListener
Description copied from interface:ITextEditorExtensionRemoves a ruler context menu listener from the editor.- Specified by:
removeRulerContextMenuListenerin interfaceITextEditorExtension- Parameters:
listener- the listener
-
canHandleMove
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 returnstrue. Subclasses may reimplement.- Parameters:
originalElement- the original elementmovedElement- 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
Returns the offset of the given source viewer's document that corresponds to the given widget offset or-1if there is no such offset.- Parameters:
viewer- the source viewerwidgetOffset- the widget offset- Returns:
- the corresponding offset in the source viewer's document or
-1 - Since:
- 2.1
-
modelOffset2WidgetOffset
Returns the offset of the given source viewer's text widget that corresponds to the given model offset or-1if there is no such offset.- Parameters:
viewer- the source viewermodelOffset- the model offset- Returns:
- the corresponding offset in the source viewer's text widget or
-1 - Since:
- 3.0
-
getCoverage
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
Tells whether the given region is visible in the given source viewer.- Parameters:
viewer- the source vieweroffset- the offset of the regionlength- the length of the region- Returns:
trueif visible- Since:
- 2.1
-
showChangeInformation
public void showChangeInformation(boolean show) Description copied from interface:ITextEditorExtension3Sets the display of quick diff information.- Specified by:
showChangeInformationin interfaceITextEditorExtension3- Parameters:
show-trueif quick diff information should be shown,falseotherwise
-
isChangeInformationShowing
public boolean isChangeInformationShowing()Description copied from interface:ITextEditorExtension3Returns the quick diff display state.- Specified by:
isChangeInformationShowingin interfaceITextEditorExtension3- Returns:
trueif quick diff info is displayed,falseotherwise
-
setStatusLineErrorMessage
Sets the given message as error message to this editor's status line.- Parameters:
message- message to be set- Since:
- 3.2
-
setStatusLineMessage
Sets the given message as message to this editor's status line.- Parameters:
message- message to be set- Since:
- 3.2
-
gotoAnnotation
Jumps to the next annotation according to the given direction.- Specified by:
gotoAnnotationin interfaceITextEditorExtension4- Parameters:
forward-trueif search direction is forward,falseif backward- Returns:
- the selected annotation or
nullif none - Since:
- 3.2
- See Also:
-
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 offsetlength- the region lengthforward-truefor forwards,falsefor backwardannotationPosition- the position of the found annotation- Returns:
- the found annotation
- Since:
- 3.2
-
showRevisionInformation
Description copied from interface:ITextEditorExtension4Shows revision information in this editor.- Specified by:
showRevisionInformationin interfaceITextEditorExtension4- Parameters:
info- the revision information to displayquickDiffProviderId- the quick diff provider that matches the source of the revision information
-
restoreState
Description copied from interface:IPersistableEditorCalled with a memento for this editor. The editor can parse the data or save the memento. This method may not be called.- Specified by:
restoreStatein interfaceIPersistableEditor- Parameters:
memento- the saved state for this editor. May benull.
-
saveState
Description copied from interface:IPersistableSaves the state of the object in the given memento.- Specified by:
saveStatein interfaceIPersistable- Parameters:
memento- the storage area for object's state
-
containsSavedState
Returns whether the given memento contains saved stateSubclasses may extend or override this method.
- Parameters:
memento- the saved state of this editor- Returns:
trueif the given memento contains saved state- Since:
- 3.3
-
doRestoreState
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
Description copied from interface:ISaveablesSourceReturns 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 usingISaveablesLifecycleListener.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 typeSaveablesLifecycleEvent.PRE_CLOSEfollowed by an event of typeSaveablesLifecycleEvent.POST_CLOSE. Since firing thePRE_CLOSEevent 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_CLOSEnotification 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.
initorcreatePartControl), or from its dispose method. Parts that implementIReusableEditormust notify when their input is changed throughIReusableEditor.setInput(IEditorInput).- Specified by:
getSaveablesin interfaceISaveablesSource- Returns:
- the saveables presented by the workbench part
- See Also:
-
getActiveSaveables
Description copied from interface:ISaveablesSourceReturns 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:
getActiveSaveablesin interfaceISaveablesSource- 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:
trueif tabs should be converted to spaces- Since:
- 3.3
-
isSpacesAsTabsDeletionEnabled
protected boolean isSpacesAsTabsDeletionEnabled()Tells whether delete and backspace keys should remove multiple spaces as if they were a tab. Only relevant whenisTabsToSpacesConversionEnabled()returns true.Subclasses may override this method.
- Returns:
trueif spaces should be removed as tabs- Since:
- 3.14
-
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:
trueif block selection mode is supported,falseotherwise- Since:
- 3.5
-
isBlockSelectionModeEnabled
public final boolean isBlockSelectionModeEnabled()Description copied from interface:ITextEditorExtension5Returnstrueif the receiver is in block (aka column) selection mode,falseotherwise.- Specified by:
isBlockSelectionModeEnabledin interfaceITextEditorExtension5- Returns:
- the receiver's block selection state
- Since:
- 3.5
- See Also:
-
setBlockSelectionMode
public void setBlockSelectionMode(boolean enable) Description copied from interface:ITextEditorExtension5Sets the block selection mode state of the receiver tostate. Nothing happens if the receiver already is in the requested state.Note: enabling block selection mode disables word wrap
ITextEditorExtension6), enabling word wrap will disable block selection mode.- Specified by:
setBlockSelectionModein interfaceITextEditorExtension5- Parameters:
enable- the new block selection state- Since:
- 3.5
- See Also:
-
isWordWrapSupported
protected boolean isWordWrapSupported()Tells whether word wrap is supported.By default word wrap is supported. Subclasses may override this method to disable it.
- Returns:
trueif word wrap is supported,falseotherwise- Since:
- 3.10
-
isWordWrapEnabled
public final boolean isWordWrapEnabled()trueif word wrap is supported and enabled,falseotherwise- Specified by:
isWordWrapEnabledin interfaceITextEditorExtension6- Returns:
- the receiver's word wrap state if word wrap is supported
- Since:
- 3.10
- See Also:
-
setWordWrap
public void setWordWrap(boolean enable) Description copied from interface:ITextEditorExtension6Sets whether the text editor wraps lines. Nothing happens if the receiver already is in the requested state.Note: enabling word wrap disables block selection mode (see
ITextEditorExtension5), enabling block selection mode will disable word wrap.- Specified by:
setWordWrapin interfaceITextEditorExtension6- Parameters:
enable-trueto enable word wrap,falseto turn it off.- Since:
- 3.10
- See Also:
-
getInitialWordWrapStatus
protected boolean getInitialWordWrapStatus()Returns the initial word wrap status.- Returns:
- initial word wrap status
- Since:
- 3.10
-
JFaceResources.TEXT_FONT