Beruflich Dokumente
Kultur Dokumente
Kai-Uwe Mtzel
IBM OTI Labs Zurich, Switzerland
Text Editors
and
How to Implement Your Own
2004 IBM Corporation
Example: J ava Editor
2004 IBM Corporation
J ava Editor
functionality
text coloring, current line highlighting, multi-column vertical ruler,
overview ruler, error squiggles, different kind of hovers, dynamically
updated outliner, content assist, bracket matching, find/replace,
annotation navigation,
variety conceptually different functions
nested control flows
interleaving control flows
2004 IBM Corporation
Overview
defining a text editor
the basics of text editors
connecting to the menu bar and tool bar
adding actions to the text editor
adding syntax highlighting
available configuration options
architecture
outlook
2004 IBM Corporation
Defining a text editor
<extension poi nt =" or g. ecl i pse. ui . edi t or s">
<editor
i d=" or g. ecl i pse. edi t or . exampl e"
name="Exampl e Edi t or "
ext ensi ons=" expl "
def aul t ="t r ue"
i con="i cons/ exampl e. gi f "
cl ass=" or g. ecl i pse. edi t or . i nt er nal . Exampl eEdi t or ">
</editor>
</extension>
can be opened on files with the expl extension
lives in the workbench not yet connected to the tool or menu bar
works on documents
ExtendedTextEditor
AbstractTextEditor
ITextEditor
2004 IBM Corporation
What are documents?
Documents store text and provide support for
line information
text manipulation
document change listeners
customizable position management
search
customizable partition management
document partition change listeners
2004 IBM Corporation
IDocument and its implementation
IDocument
IDocumentListener
IPositionUpdater
IDocumentPartitioner
IDocumentPartitioningListener
ConfigurableLineTracker
SequentialRewriteStore
GapTextStore
DefaultLineTracker
AbstractDocument
ITextStore
ILineTracker
2004 IBM Corporation
Recurring abstraction layers
Concept
Default Strategy for
Default Implementation
Default
Implementation
of Concept
Strategy
configurable with
r
e
p
l
a
c
a
b
l
e
r
e
p
l
a
c
a
b
l
e
2004 IBM Corporation
Where do documents come from?
each editor is connected to a document provider
document providers can be shared between editors
document provider
maps editor inputs onto documents and annotation models
tracks and communicates changes to the editor inputs into editor
understandable events (I El ement ChangeLi st ener )
translates changes of the documents and annotation models into
changes of the editor input (save)
manages dirty state, modification stamps, encoding
provides uniform access to editor inputs and their underlying elements
i nt er f ace I Text Edi t or ext ends I Edi t or Par t {
}
publ i c abst r act cl ass Abst r act Exampl eEdi t or {
publ i c voi d createPartControl( Composi t e par ent ) {
f Sour ceVi ewer = new SourceViewer( par ent , ) ;
}
}
2004 IBM Corporation
Adding an annotation hover
publ i c cl ass Exampl eSour ceVi ewer Conf i gur at i on
ext ends Sour ceVi ewer Conf i gur at i on {
publ i c I Annot at i onHover getAnnotationHover( I Sour ceVi ewer vi ewer ) {
r et ur n new ExampleAnnotationHover( ) ;
}
}
}
2004 IBM Corporation
Adding syntax coloring
publ i c cl ass Exampl eSour ceVi ewer Conf i gur at i on {