Application programming interfaces for interaction
with the Eclipse Java User Interface text support.
Linked Position Infrastructure
package org.eclipse.jface.text.link
The Linked Position Infrastructure lets one set up a mode in an editor
in which regions in a document (or several documents) are linked,
i.e. editions
of one linked position will be reflected in the others.
Classes
LinkedPositionGroup
: a set of linked positions. Add
positions to a group using the addPosition
and createPosition
methods, which
also allow to specify an iteration order. See ProposalPosition
for a position type
that lets one attach ICompletionProposals to
be shown when the position is hit.
LinkedEnvironment
: umbrellas several PositionGroup
s,
e.g. in a template that has several groups of linked positions. Handles
the forwarding of updates received via an IDocumentListener. Add PositionGroup
s
to
an environment using the addGroup
method. Existence of a LinkedEnvironment can be
tested by one of the static methods.
LinkedUIControl
: The UI for linked mode (for one
environment, to be precise). Monitors key etc. activity, monitors exit
conditions, creates a painter etc.
Properties:
- cycling mode (whether to jump to the first position
after the last): either of
CYCLE_ALWAYS
, CYCLE_NEVER
and CYCLE_WHEN_NO_PARENT
(default).
- exit position: where to jump upon leaving the linked
mode (e.g. using Enter, or Tab from the last position when not
cycling). Set
isTabStop
to true
if tabbing
should stop over when cycling.
- position listener:
you can register a position listener which will get notified whenever
the focus position changes. An example is org.eclipse.ui.texteditor.link.EditorHistoryUpdater
which will store the edit location in the editor navigation history.
.
Example
IDocument doc1, doc2;
ITextViewer viewer1, viewer2;
/* create groups - this step is independent of the linked mode */
PositionGroup group1= new PositionGroup();
group1.addPosition(doc1, 3,4);
group1.addPosition(doc1, 7,8);
PositionGroup group2= newPositionGroup();
group2.addPosition(doc1, 15, 25);
group2.addPosition(doc2, 0, 10);
/* set up linked mode */
LinkedEnvironment env= new LinkedEnvironment();
env.addGroup(group1);
env.addGroup(group2);
env.forceInstall();
/* create UI */
LinkedUIControl ui= new LinkedUIControl(env, new ITextViewer[] { viewer1, viewer2 });
ui.enter();
Todo
- handle lazy computation of per-group proposals using a
IContentAssistProcessor
(see PositionGroup, ProposalPosition) .