comparison dwtx/jface/text/link/package.html @ 129:eb30df5ca28b

Added JFace Text sources
author Frank Benoit <benoit@tionex.de>
date Sat, 23 Aug 2008 19:10:48 +0200
parents
children
comparison
equal deleted inserted replaced
128:8df1d4193877 129:eb30df5ca28b
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
2 <html>
3 <head>
4 <meta content="text/html; charset=iso-8859-1"
5 http-equiv="Content-Type">
6 <meta content="IBM" name="Author">
7 <meta content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]"
8 name="GENERATOR">
9 <title>Linked Position Infrastructure</title>
10 </head>
11 <body>
12 Application programming interfaces for interaction
13 with the Eclipse text editor's linked position support.
14 <h2>Linked Position Infrastructure</h2>
15 <h3>package <code>org.eclipse.jface.text.link</code></h3>
16 The Linked Position Infrastructure lets one set up a mode in an editor
17 in which regions in a document (or several documents) are <em>linked</em>,
18 i.e. editions
19 of one linked position will be reflected in the others.
20 <h4>Classes</h4>
21 <ul>
22 <li><code>LinkedPositionGroup</code>: a set of linked positions. Add
23 positions to a group using the <code>addPosition</code> method. See <code>LinkedPosition</code> and <code>ProposalPosition</code>
24 for a position type that lets one attach <code>ICompletionProposal</code>s to
25 be shown when the position is hit.</li>
26 <li><code>LinkedModeModel</code>: umbrellas several <code>LinkedPositionGroup</code>s,
27 e.g. in a template that has several groups of linked positions. Handles
28 the forwarding of updates received via an <code>IDocumentListener</code>. Add <code>LinkedPositionGroup</code>s
29 to
30 an model using the <code>addGroup</code> method. Existence of a <code>LinkedModeModel </code>can be
31 tested by one of the static methods.<br>
32 </li>
33 <li><code>LinkedModeUI</code>: The UI for linked mode (for one
34 model, to be precise). Monitors key etc. activity, monitors exit
35 conditions, creates a painter etc. <br>
36 Properties:
37 <ul>
38 <li><b>cycling mode</b> (whether to jump to the first position
39 after the last): either of <code>CYCLE_ALWAYS</code>, <code>CYCLE_NEVER</code>
40 and <code>CYCLE_WHEN_NO_PARENT</code> (default).</li>
41 <li><b>exit position</b>: where to jump upon leaving the linked
42 mode (e.g. using Enter, or Tab from the last position when not
43 cycling). Set <code>isTabStop</code> to <code>true</code> if tabbing
44 should stop over when cycling.</li>
45 <li><span style="font-weight: bold;">position listener</span>:
46 extending classes may register a position listener which will get
47 notified whenever
48 the focus position changes. An example is <code>org.eclipse.ui.texteditor.link.EditorLinkedModeUI.EditorHistoryUpdater</code>
49 which will store the edit location in the editor navigation history.</li>
50 </ul>
51 </li>
52
53 </ul>
54 <h4>Example</h4>
55 <pre>
56 IDocument doc1, doc2;
57 ITextViewer viewer1, viewer2;
58
59 /* create groups - this step is independent of the linked mode */
60 LinkedPositionGroup group1= new LinkedPositionGroup();
61 group1.addPosition(new LinkedPosition(doc1, 3, 4));
62 group1.addPosition(new LinkedPosition(doc1, 7, 8));
63
64 LinkedPositionGroup group2= new LinkedPositionGroup();
65 group2.addPosition(new LinkedPosition(doc1, 15, 25));
66 group2.addPosition(new LinkedPosition(doc2, 0, 10));
67
68 /* set up linked mode */
69 LinkedModeModel model= new LinkedModeModel();
70 model.addGroup(group1);
71 model.addGroup(group2);
72 model.forceInstall();
73
74 /* create UI */
75 LinkedModeUI ui= new LinkedModeUI(model, new ITextViewer[] { viewer1, viewer2 });
76 ui.enter();
77 </pre>
78 </body>
79 </html>