Package org.eclipse.ui.texteditor
Interface ITextEditor
- All Superinterfaces:
IAdaptable,IEditorPart,ISaveablePart,IWorkbenchPart
- All Known Implementing Classes:
AbstractDecoratedTextEditor,AbstractTextEditor,StatusTextEditor,TextEditor
Interface to a text editor. This interface defines functional extensions to
IEditorPart as well as the configuration capabilities of a text
editor.
Text editors are configured with an IDocumentProvider which
delivers a textual presentation (IDocument) of the editor's
input. The editor works on the document and forwards all input element
related calls, such as save, to the document provider. The
provider also delivers the input's annotation model which is used by the
editor's vertical ruler.
Clients may implement this interface from scratch, but the recommended way is
to subclass the abstract base class AbstractTextEditor.
In order to provided backward compatibility for clients of
ITextEditor, extension interfaces are used to provide a means of
evolution. The following extension interfaces exist:
ITextEditorExtensionsince version 2.0 introducing status fields, read-only state and ruler context menu listeners.ITextEditorExtension2since version 2.1 introducing modifiable state for the editor input and validate state handling.ITextEditorExtension3since version 3.0 adding input state and change information control.ITextEditorExtension4since version 3.2 adding annotation navigation and revision information display.ITextEditorExtension5since version 3.5 adding block selection mode.
- See Also:
-
Field Summary
Fields inherited from interface org.eclipse.ui.IEditorPart
PROP_DIRTY, PROP_INPUTFields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE -
Method Summary
Modifier and TypeMethodDescriptionvoidclose(boolean save) Closes this text editor after optionally saving changes.voidAbandons all modifications applied to this text editor's input element's textual presentation since the last save operation.Returns the action installed under the given action id.Returns this text editor's document provider.Returns the highlighted range of this text editor.Returns this text editor's selection provider.booleanReturns whether the text in this text editor can be changed by the user.voidremoveActionActivationCode(String actionId) Removes any installed activation code for the specified action.voidResets the highlighted range of this text editor.voidselectAndReveal(int offset, int length) Selects and reveals the specified range 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.voidsetHighlightRange(int offset, int length, boolean moveCursor) Sets the highlighted range of this text editor to the specified region.voidshowHighlightRangeOnly(boolean showHighlightRangeOnly) Configures this text editor to show only the highlighted range of the text.booleanReturns whether this text editor is configured to show only the highlighted range of the text.Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapterMethods inherited from interface org.eclipse.ui.IEditorPart
getEditorInput, getEditorSite, initMethods inherited from interface org.eclipse.ui.ISaveablePart
doSave, doSaveAs, isDirty, isSaveAsAllowed, isSaveOnCloseNeededMethods inherited from interface org.eclipse.ui.IWorkbenchPart
addPropertyListener, createPartControl, dispose, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener, setFocus
-
Method Details
-
getDocumentProvider
IDocumentProvider getDocumentProvider()Returns this text editor's document provider.- Returns:
- the document provider or
nullif none, e.g. after closing the editor
-
close
void close(boolean save) Closes this text editor after optionally saving changes.- Parameters:
save-trueif unsaved changed should be saved, andfalseif unsaved changed should be discarded
-
isEditable
boolean isEditable()Returns whether the text in this text editor can be changed by the user.- Returns:
trueif it can be edited, andfalseif it is read-only
-
doRevertToSaved
void doRevertToSaved()Abandons all modifications applied to this text editor's input element's textual presentation since the last save operation. -
setAction
Installs the given action under the given action id.- Parameters:
actionID- the action idaction- the action, ornullto clear it- See Also:
-
getAction
Returns the action installed under the given action id.- Parameters:
actionId- the action id- Returns:
- the action, or
nullif none - See Also:
-
setActionActivationCode
void setActionActivationCode(String actionId, char activationCharacter, int activationKeyCode, int activationStateMask) 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 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.- 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
Removes any installed activation code for the specified action. If no activation code is installed, this method does not have any effect.- Parameters:
actionId- the action id
-
showsHighlightRangeOnly
boolean showsHighlightRangeOnly()Returns whether this text editor is configured to show only the highlighted range of the text.- Returns:
trueif only the highlighted range is shown, andfalseif this editor shows the entire text of the document- See Also:
-
showHighlightRangeOnly
void showHighlightRangeOnly(boolean showHighlightRangeOnly) Configures this text editor to show only the highlighted range of the text.- Parameters:
showHighlightRangeOnly-trueif only the highlighted range is shown, andfalseif this editor shows the entire text of the document- See Also:
-
setHighlightRange
void setHighlightRange(int offset, int length, boolean moveCursor) Sets the highlighted range of this text editor to the specified region.- 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
IRegion getHighlightRange()Returns the highlighted range of this text editor.- Returns:
- the highlighted range
- See Also:
-
resetHighlightRange
void resetHighlightRange()Resets the highlighted range of this text editor. -
getSelectionProvider
ISelectionProvider getSelectionProvider()Returns this text editor's selection provider. Repeated calls to this method return the same selection provider.- Returns:
- the selection provider
-
selectAndReveal
void selectAndReveal(int offset, int length) Selects and reveals the specified range in this text editor.- Parameters:
offset- the offset of the selectionlength- the length of the selection
-