Text editors and JFace text
The workbench package org.eclipse.ui.editors.text
implements the default text editor for the platform. It uses the text
editor framework in org.eclipse.ui.texteditor
for its implementation.
The text editor framework provides a domain-model independent editor that
supports the following features:
- Standard text editing operations such as cut/copy/paste, find/replace
- Visual presentation of resource markers adjacent to the text editing area
- Automatic update of resource markers as the user edits text
- Context menu management
- Responses to user actions in the workbench, such as refreshing resources
from the file system, closing projects, or removal of the editor's input
element resource
ITextEditor
is defined as a text specific extension of IEditorPart.
The default implementation of this interface is provided by AbstractTextEditor.
IDocumentProvider
is used to establish the link between a domain model and an ITextEditor.
The document provider manages the text presentation of the domain model and can
be shared between multiple editors.
The workbench text editing framework is built on top of JFace text. The
Java editor example in org.eclipse.ui.examples.javaeditor
is a good place to start learning about the text editor framework and JFace
text. It shows how complex features like text coloring, hover help, and
automatic indenting can be implemented.
JFace text
The package org.eclipse.jface.text
and its sub-packages support the implementation of robust text editors such as
the workbench text
editor and the JDT Java editor.
The following roadmap gives an overview of the support in JFace text.
- org.eclipse.jface.text
defines a generic document model for text and provides a viewer that
displays text using this model. Documents can be divided into
non-overlapping partitions, which can be useful when the text
represents multiple elements with different meanings (such as methods and
comments inside a Java file). Partitions have content types
which are used to identify places where different behavior should be
assigned for different kinds of content. Document positions can be used to
define text regions that remain updated as the user edits text. IDocument
and TextViewer
are good places to begin learning about this package.
- org.eclipse.jface.text.formatter
defines a text viewer add-on which can be configured with different formatting
behavior per partition content type. Formatting is achieved by
manipulating white spaces and delimiters in order to present the text in a
structured fashion. Formatting is most commonly used when editing code and is
often driven by user preference. The JDT source code editor uses this
support to provide user-driven Java code formatting.
- org.eclipse.jface.text.contentassist
defines a text viewer add-on that provides user-driven text completion
support. Popup windows are used to propose possible text choices to
complete a phrase. The user can select these choices for automatic
insertion in the text. Content assist also
supports contextual popups for providing the user with information that is
related to the current position in the document. IContentAssistant
is a good place to begin learning about this package. It can be
configured with different phrase completion strategies for different
partition content types.
- org.eclipse.jface.text.presentation
defines a text viewer add-on which can control the visual presentation
(font, font style, colors) of the text shown in the text viewer. For
each change applied to a document, the presentation reconciler determines
which region of the visual presentation should be invalidated and how to
repair it. Different strategies can be used for different partition
content types.
- org.eclipse.jface.text.reconciler
defines a text viewer add-on that supports the synchronization of a
document with some external structure that may also be manipulating the
text.
- org.eclipse.jface.text.rules
provides rule-based document scanning. Plug-ins can use rules
to distinguish tokens such as line delimiters, white space, and generic
patterns when scanning a document. This package also provides support
for rule-driven presentation reconciling and document partitioning. The Java editor example uses this package to parse Java
code.
- org.eclipse.jface.text.source
defines a source viewer. A source viewer extends a text viewer
in order to support visual text annotations. These
annotations are used in the JDT source code editor to annotate Java
source code with problem descriptions and breakpoints.
The SWT StyledText
widget is used by the JFace text support.
