Mercurial > projects > dwt-addons
comparison dwtx/jface/text/formatter/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 <title>Package-level Javadoc</title> | |
8 </head> | |
9 <body> | |
10 Provides a content formatter add-on for an <tt>ITextViewer</tt>. | |
11 A content formatter changes the formatting of a document region while | |
12 preserving and correctly updating the positions of the document. | |
13 <h2>Package Specification</h2> | |
14 <tt>IContentFormatter</tt> defines the concept of a text formatter. It | |
15 collaborates with content type specific formatting stratgies (<tt>IFormattingStrategy</tt>) | |
16 which for a given document region format the subregion with the | |
17 matching | |
18 content type. The package contains a default implementation of <tt>IContentFormatter</tt> | |
19 (<tt>ContentFormatter</tt>).<br> | |
20 Additionally, an implementation of <tt>IContentFormatterExtension</tt> | |
21 is provided | |
22 for text edit based formatting strategies. This implementation only | |
23 accepts formatting strategies | |
24 implementing the extension interface <tt>IFormattingStrategyExtension</tt>. | |
25 These formatting strategies are required to handle the position | |
26 updating of the document. To facilitate the work with these text edit | |
27 based formatting strategies, a default implementation called <tt>ContextBasedFormattingStrategy</tt> | |
28 is provided. Formatting strategies inheriting from this class are text | |
29 edit based and behave context dependent. Depending on the formatting | |
30 context that is passed | |
31 to the content formatter, different preferences and modes can be used | |
32 to format different parts of a document. | |
33 <p>To set up a proper working text edit based content formatter, the | |
34 following steps are needed: | |
35 </p> | |
36 <ul> | |
37 <li>Create an instance of <tt>IFormattingContext</tt>. The default | |
38 implementation <tt>FormattingContext</tt> already | |
39 provides support for the conversion of preferences from a preference | |
40 store to a map and vice versa. The method <tt>getPreferenceKeys</tt> | |
41 usually has to be overridden to return the appropriate keys of the | |
42 preferences used during the formatting process. Then register a map of | |
43 preferences | |
44 with the formatting context by calling <tt>setProperty(String, Object)</tt> | |
45 with the property identifier <tt>FormattingContextProperties.CONTEXT_PREFERENCES</tt>.</li> | |
46 <li>Create an instance of the text edit based content formatter class | |
47 <tt>MultiPassContentFormatter</tt>. The document partitioning and | |
48 its associated | |
49 default content type have to be passed to the constructor. This | |
50 information is needed since the content formatter is able to format | |
51 documents | |
52 according to arbitrary partitionings and default content types.</li> | |
53 <li>Register the formatting strategies for the content types that | |
54 have to be formatted. If a formatting strategy is | |
55 registered as master strategy, it is automatically associated with the | |
56 default content type of the specified partitioning. | |
57 If the formatting strategy is registered as slave strategy, it is | |
58 associated with the indicated content type during the registration. | |
59 Note that the master strategy can also be registered as a slave | |
60 strategy for a content type other than the default content type.</li> | |
61 <li>Specify the proper formatting mode (see | |
62 FormattingContextProperties): | |
63 <ul> | |
64 <li>For whole document formatting set the property <tt>CONTEXT_DOCUMENT</tt> | |
65 of the created formatting context to <tt>true</tt>. This is | |
66 equivalent to setting <code>CONTEXT_REGION</code> with a region | |
67 spanning the whole document.</li> | |
68 <li>For multiple region formatting set the property <code>CONTEXT_REGION</code> | |
69 of the formatting context. Note that the content formatter | |
70 automatically aligns the offset of a region to a line start for the | |
71 master formatting strategy, it also completes eventual partitions | |
72 covered only partially by the region for the slave formatting | |
73 strategies.</li> | |
74 <li>For explicit formatting of a partition with the formatting | |
75 strategy registered for a certain content type use the | |
76 property <tt>CONTEXT_PARTITION</tt>. Note that the region denoted by | |
77 this property must correspond to a partition relative to the specified | |
78 partitioning in the document to be formatted. The content type of this | |
79 property overrides the content type of the partition | |
80 in the document.</li> | |
81 </ul> | |
82 </li> | |
83 <li>Call the method <tt>MultiPassContentFormatter#format(IDocument, | |
84 IFormattingContext)</tt> with the created formatting context | |
85 and the document to be formatted.</li> | |
86 </ul> | |
87 <p></p> | |
88 </body> | |
89 </html> |