blob: aeab0f0e75ef82443a3a5f4b2660fd761f46d05b [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta content="text/html; charset=iso-8859-1"
http-equiv="Content-Type">
<meta content="IBM" name="Author">
<meta content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]"
name="GENERATOR">
<title>Linked Position Infrastructure</title>
</head>
<body>
Application programming interfaces for interaction
with the Eclipse Java User Interface text support.
<h2>Linked Position Infrastructure</h2>
<h3>package <span style="font-family: monospace;">org.eclipse.jface.text.link
</span><span style="font-family: monospace;"></span></h3>
<h3><code></code></h3>
The Linked Position Infrastructure lets one set up a mode in an editor
in which regions in a document (or several documents) are <em>linked</em>,
i.e. editions
of one linked position will be reflected in the others.
<h4>Classes</h4>
<ul>
<li><code>LinkedPositionGroup</code>: a set of linked positions. Add
positions to a group using the <code>addPosition</code> and <code>createPosition</code>
methods, which
also allow to specify an iteration order. See <span
style="font-family: monospace;">ProposalPosition</span><code><span
style="font-family: helvetica,arial,sans-serif;"> </span></code><span
style="font-family: helvetica,arial,sans-serif;">for a position type
that lets one attach </span><span style="font-family: monospace;">ICompletionProposals</span><span
style="font-family: monospace;"></span><span
style="font-family: helvetica,arial,sans-serif;"> </span><span
style="font-family: helvetica,arial,sans-serif;">to</span>
be shown when the position is hit.</li>
<li><code>LinkedEnvironment</code>: umbrellas several <code>PositionGroup</code>s,
e.g. in a template that has several groups of linked positions. Handles
the forwarding of updates received via an IDocumentListener. Add <code>PositionGroup</code>s
to
an environment using the <code>addGroup</code> method. Existence of a <span
style="font-family: monospace;">LinkedEnvironment </span>can be
tested by one of the static methods.<br>
</li>
<li><code>LinkedUIControl</code>: The UI for linked mode (for one
environment, to be precise). Monitors key etc. activity, monitors exit
conditions, creates a painter etc. <br>
Properties:
<ul>
<li><b>cycling mode</b> (whether to jump to the first position
after the last): either of <code>CYCLE_ALWAYS</code>, <code>CYCLE_NEVER</code>
and <code>CYCLE_WHEN_NO_PARENT</code> (default).</li>
<li><b>exit position</b>: where to jump upon leaving the linked
mode (e.g. using Enter, or Tab from the last position when not
cycling). Set <code>isTabStop</code> to <code>true</code> if tabbing
should stop over when cycling.</li>
<li><span style="font-weight: bold;">position listener</span>:
you can register a position listener which will get notified whenever
the focus position changes. An example is <span
style="font-family: monospace;">org.eclipse.ui.texteditor.link.EditorHistoryUpdater</span>
which will store the edit location in the editor navigation history.<br>
</li>
</ul>
</li>
.
</ul>
<h4>Example</h4>
<pre> IDocument doc1, doc2;<br> ITextViewer viewer1, viewer2;<br> <br> /* create groups - this step is independent of the linked mode */<br> PositionGroup group1= new PositionGroup();<br> group1.addPosition(doc1, 3,4);<br> group1.addPosition(doc1, 7,8);<br> <br> PositionGroup group2= newPositionGroup();<br> group2.addPosition(doc1, 15, 25);<br> group2.addPosition(doc2, 0, 10);<br> <br> /* set up linked mode */<br> LinkedEnvironment env= new LinkedEnvironment();<br> env.addGroup(group1);<br> env.addGroup(group2);<br> env.forceInstall();<br> <br> /* create UI */<br> LinkedUIControl ui= new LinkedUIControl(env, new ITextViewer[] { viewer1, viewer2 });<br> ui.enter();<br></pre>
<h4>Todo</h4>
<ul>
<li>handle lazy computation of per-group proposals using a <code>IContentAssistProcessor</code>
(see PositionGroup, ProposalPosition) .</li>
</ul>
</body>
</html>