3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.bulkeditor
;
12 import java
.util
.Iterator
;
14 import org
.apache
.log4j
.Logger
;
15 import org
.eclipse
.jface
.text
.IDocument
;
16 import org
.eclipse
.jface
.text
.IRegion
;
17 import org
.eclipse
.jface
.text
.TextPresentation
;
18 import org
.eclipse
.jface
.text
.presentation
.IPresentationReconciler
;
19 import org
.eclipse
.jface
.text
.presentation
.PresentationReconciler
;
20 import org
.eclipse
.jface
.text
.source
.ISourceViewer
;
21 import org
.eclipse
.jface
.text
.source
.SourceViewerConfiguration
;
22 import org
.eclipse
.swt
.SWT
;
23 import org
.eclipse
.swt
.custom
.StyleRange
;
25 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.ILineDisplayStrategy
;
26 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.LineAnnotation
;
27 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.LineAnnotationModel
;
35 public class BulkEditorViewerConfiguration
extends SourceViewerConfiguration
{
36 private static final Logger logger
= Logger
37 .getLogger(BulkEditorViewerConfiguration
.class);
39 private ILineDisplayStrategy lineDisplayStrategy
;
42 * @param lineDisplayStrategy
44 public BulkEditorViewerConfiguration(
45 ILineDisplayStrategy lineDisplayStrategy
) {
46 this.lineDisplayStrategy
= lineDisplayStrategy
;
50 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
53 public IPresentationReconciler
getPresentationReconciler(
54 final ISourceViewer sourceViewer
) {
55 return new PresentationReconciler() {
57 * @see org.eclipse.jface.text.presentation.PresentationReconciler#createPresentation(org.eclipse.jface.text.IRegion, org.eclipse.jface.text.IDocument)
60 protected TextPresentation
createPresentation(IRegion damage
,
63 TextPresentation presentation
= super.createPresentation(damage
, document
);
64 LineAnnotationModel model
= (LineAnnotationModel
) sourceViewer
.getAnnotationModel();
66 // Update all annotated lines in the damage zone
67 Iterator iter
= model
.getAnnotationIterator(damage
.getOffset(), damage
.getLength() + 1, true, true);
68 while (iter
.hasNext()) {
69 Object next
= iter
.next();
70 if (next
instanceof LineAnnotation
) {
71 for (StyleRange styleRange
: lineDisplayStrategy
.getTextStyleRanges(((LineAnnotation
) next
).getEntity())) {
72 styleRange
.start
+= model
.getPosition((LineAnnotation
) next
).getOffset();
73 presentation
.addStyleRange(styleRange
);