p2izing the editor
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor.prototype2 / src / eu / etaxonomy / taxeditor / prototype2 / view / nameviewersupport / NameViewerConfig.java
1 package eu.etaxonomy.taxeditor.prototype2.view.nameviewersupport;
2
3 import org.eclipse.jface.text.presentation.IPresentationReconciler;
4 import org.eclipse.jface.text.presentation.PresentationReconciler;
5 import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
6 import org.eclipse.jface.text.source.ISourceViewer;
7 import org.eclipse.jface.text.source.SourceViewerConfiguration;
8
9 public class NameViewerConfig extends SourceViewerConfiguration {
10
11 /**
12 * Whenever a change is made to the document, a notification is sent to the
13 * IPresentationDamager for each content type in the affected area of the document.
14 * The IPresentationDamager in turn returns an IRegion indicating the area of the
15 * document which needs to be rebuilt as a result of the change. This information is
16 * then passed on to the IPresentationRepairer, which is responsible for reapplying
17 * the textual presentation for the affected region.
18 *
19 * This all probably sounds quite complicated. Fortunately you probably won't ever need
20 * to implement any of these classes yourself. JFace Text provides a
21 * DefaultDamagerRepairer which does the job both of the IPresentationDamager and the
22 * IPresentationRepairer. It also provides a PresentationReconciler class which performs
23 * the co-ordination role we described earlier.
24 *
25 * ...
26 *
27 * If you understand document partitioning then you are in a very good position to understand
28 * syntax highlighting in a JFace Text application. Essentially, syntax highlighting involves
29 * dividing a region into tokens, each of which has its own text display attributes. The
30 * standard mechanism for doing this also involves the use of the already familiar tokens,
31 * scanners and rules.
32 *
33 **/
34 public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer)
35 {
36 PresentationReconciler reconciler = new PresentationReconciler();
37
38 DefaultDamagerRepairer dr = new NameDamagerRepairer(new NamePartitionScanner());
39 // reconciler.setDamager(dr, "genus");
40 // reconciler.setRepairer(dr, "genus");
41
42 return reconciler;
43 }
44 }