commit 30cbb7ff3cccbb3b2ef7ebcf47e5f2a4ca62806c
Author: p.ciardelli <p.ciardelli@localhost>
Date:   Wed Oct 28 16:32:03 2009 +0000

    .

diff --git a/.gitattributes b/.gitattributes
index 8fc5562da..331a98693 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -662,6 +662,7 @@ taxeditor-bulkeditor/plugin.xml -text
 taxeditor-bulkeditor/pom.xml -text
 taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineDocumentProvider.java -text
 taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditor.java -text
+taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditorPartitioner.java -text
 taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditorReconcilingStrategy.java -text
 taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditorSourceViewerConfiguration.java -text
 taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/EntityListener.java -text
diff --git a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineDocumentProvider.java b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineDocumentProvider.java
index f08a8bf7e..cbc08f17b 100644
--- a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineDocumentProvider.java
+++ b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineDocumentProvider.java
@@ -9,6 +9,7 @@
 */
 package eu.etaxonomy.taxeditor.annotatedlineeditor;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -22,7 +23,13 @@ import org.eclipse.jface.operation.IRunnableContext;
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.Document;
 import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
 import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.TypedRegion;
+import org.eclipse.jface.text.rules.FastPartitioner;
+import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
 import org.eclipse.jface.text.source.Annotation;
 import org.eclipse.jface.text.source.IAnnotationModel;
 import org.eclipse.swt.SWT;
@@ -31,6 +38,7 @@ import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.texteditor.AbstractDocumentProvider;
 
 
+
 /**
  * Using an <code>IEditorPart</code>, creates a document where each line is associated
  * with an entity. Mapping between document positions and entities is stored in
@@ -116,7 +124,6 @@ public class AnnotatedLineDocumentProvider extends AbstractDocumentProvider {
 			documents.put(input, document);
 					
 			for (Object entity : getEntityList(element)) {
-								
 				try {
 					createAnnotatedLine(input, entity);
 				} catch (BadLocationException e) {
@@ -124,6 +131,13 @@ public class AnnotatedLineDocumentProvider extends AbstractDocumentProvider {
 					e.printStackTrace();
 				}
 			}
+			
+			// Create partitioner to put supplemental, non-cache text in different colors
+			IDocumentPartitioner partitioner = 
+					new AnnotatedLineEditorPartitioner(document, (LineAnnotationModel) model, lineDisplayStrategies.get(element));
+			partitioner.connect(document);
+			document.setDocumentPartitioner(partitioner);			
+			
 			return document;
 		}
 		return null;
@@ -154,13 +168,12 @@ public class AnnotatedLineDocumentProvider extends AbstractDocumentProvider {
 		}
 		
 		String text;
-		boolean doItalics = false;
 		if (lineDisplay.isEntityCacheEmpty(entity)) {
 			text = lineDisplay.getEmptyCacheMessage(entity);
-			doItalics = true;
 		} else {
 			text = lineDisplay.getText(entity);
 		}
+		text += lineDisplay.getSupplementalText(entity);
 		docLength = document.getLength();
 		document.replace(docLength, 0, text);
 		
@@ -170,27 +183,28 @@ public class AnnotatedLineDocumentProvider extends AbstractDocumentProvider {
 		model.addAnnotation(annotation, position);
 					
 		logger.info("Annotation added " + entity);
-				
-		if (doItalics) {
-			
-			// TODO implement italics for non-named objects in presentation repairer � la
-			//    http://www.wsmostudio.org/multiproject/org.wsmostudio.grounding.wsdls/xref/org/wsmostudio/grounding/sawsdl/ui/text/NonRuleBasedDamagerRepairer.html
-			
-			StyleRange styleRange = new StyleRange();
-			styleRange.start = docLength;
-			styleRange.length = text.length();
-			styleRange.fontStyle = SWT.ITALIC;
-		}
-				
+							
 		lineDisplay.addDisplayListener(entity, 
 						new EntityListenerImpl((LineAnnotation) annotation, element, lineDisplay));
 				
 		return annotation;
 	}
 	
-	public void updateLineFromAnnotation(Object element, LineAnnotation annotation, String text) {
+	public void updateLineFromAnnotation(Object element, LineAnnotation annotation) {
+				
 		IAnnotationModel model = getAnnotationModel(element);
 		IDocument document = getDocument(element);
+		ILineDisplayStrategy lineDisplay = getLineDisplayStrategy(element);
+		
+		Object entity = annotation.getEntity();
+		String text = "";
+		if (getLineDisplayStrategy(element).isEntityCacheEmpty(entity)) {
+			text = lineDisplay.getEmptyCacheMessage(entity);
+		} else {
+			text = lineDisplay.getText(entity);
+		}		
+		text += lineDisplay.getSupplementalText(entity);
+		
 		try {
 			if (model.getPosition(annotation) == null) {
 				return;
@@ -224,18 +238,8 @@ public class AnnotatedLineDocumentProvider extends AbstractDocumentProvider {
 		 */
 		@Override
 		protected void updateEntity() {
-			
 			annotation.setDirty(true);
-			
-			Object entity = annotation.getEntity();
-			String text;
-			if (lineDisplay.isEntityCacheEmpty(entity)) {
-				text = lineDisplay.getEmptyCacheMessage(entity);
-			} else {
-				text = lineDisplay.getText(entity);
-			}
-
-			updateLineFromAnnotation(element, annotation, text);
+			updateLineFromAnnotation(element, annotation);
 		}
 	}
 	
diff --git a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditor.java b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditor.java
index 18d17dfce..8ab4d53e7 100644
--- a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditor.java
+++ b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditor.java
@@ -190,7 +190,6 @@ public class AnnotatedLineEditor extends TextEditor implements IConversationEnab
 			annotation = provider.createAnnotatedLine(input, entity);
 
 			// Jump to new line
-			IDocument document= provider.getDocument(getEditorInput());
 			int start= provider.getAnnotationModel(input).getPosition(annotation).getOffset();
 			selectAndReveal(start, 0);
 			
diff --git a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditorPartitioner.java b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditorPartitioner.java
new file mode 100644
index 000000000..f86dbd42a
--- /dev/null
+++ b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineEditorPartitioner.java
@@ -0,0 +1,118 @@
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy 
+* http://www.e-taxonomy.eu
+* 
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.annotatedlineeditor;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TypedRegion;
+import org.eclipse.jface.text.rules.FastPartitioner;
+import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
+
+/**
+ * Separates each line into partitions for the main text - usually the
+ * object's title cache - and supplemental text. The supplemental text
+ * partition can then be given a different color and / or font style by 
+ * the editor's presentation reconciler. 
+ * 
+ * @author p.ciardelli
+ * @created 28.10.2009
+ * @version 1.0
+ */
+public class AnnotatedLineEditorPartitioner extends FastPartitioner {
+	private static final Logger logger = Logger
+			.getLogger(AnnotatedLineEditorPartitioner.class);
+	
+	private Document document;
+	private LineAnnotationModel model;
+	private ILineDisplayStrategy lineDisplayStrategy;
+	
+	/**
+	 * @param scanner
+	 * @param legalContentTypes
+	 */
+	public AnnotatedLineEditorPartitioner(Document document, LineAnnotationModel model, ILineDisplayStrategy lineDisplayStrategy) {
+		super(new RuleBasedPartitionScanner(), 
+				new String[] {ILineDisplayStrategy.SUPPLEMENTAL_TEXT});
+		
+		this.document = document;
+		this.model = model;
+		this.lineDisplayStrategy = lineDisplayStrategy;
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.text.rules.FastPartitioner#computePartitioning(int, int, boolean)
+	 */
+	@Override
+	public ITypedRegion[] computePartitioning(int offset,
+			int length, boolean includeZeroLengthPartitions) {
+		List<ITypedRegion> regions = new ArrayList<ITypedRegion>(); 
+		try {
+			int lines = document.getNumberOfLines(offset, length);
+			int startLine = document.getLineOfOffset(offset);
+			
+			// Iterate through all affected lines, separating into regions of DEFAULT_CONTENT_TYPE and SUPPLEMENTAL_TEXT
+			for (int i = startLine; i < startLine + lines; i++) {
+				LineAnnotation annotation = (LineAnnotation) ((LineAnnotationModel) model).getAnnotationAtLine(i, document);
+				if (annotation != null) {
+					IRegion lineInfo = document.getLineInformation(i);
+					String lineText = document.get(lineInfo.getOffset(), lineInfo.getLength());
+					
+					String supplementalText = lineDisplayStrategy.getSupplementalText(annotation.getEntity());
+					if (supplementalText == null || supplementalText.equals("")) {
+						continue;
+					}
+					if (lineText.contains(supplementalText)) {
+						int startSupplementalText = lineText.indexOf(supplementalText) + lineInfo.getOffset();
+						
+						if (startSupplementalText > lineInfo.getOffset()) {
+							regions.add(new TypedRegion(lineInfo.getOffset(), startSupplementalText - lineInfo.getOffset(), 
+															IDocument.DEFAULT_CONTENT_TYPE));
+							logger.warn("Non supp at " + lineInfo.getOffset() + ", length " + (startSupplementalText - lineInfo.getOffset()));
+						}														
+						regions.add(new TypedRegion(startSupplementalText, supplementalText.length(), 
+														ILineDisplayStrategy.SUPPLEMENTAL_TEXT));
+						logger.warn("Supp at " + startSupplementalText + ", length " + supplementalText.length());
+						if (startSupplementalText + supplementalText.length() < lineInfo.getOffset() + lineInfo.getLength()) {
+							regions.add(new TypedRegion(startSupplementalText + supplementalText.length(), 
+															lineInfo.getLength() - startSupplementalText - supplementalText.length(), 
+															IDocument.DEFAULT_CONTENT_TYPE));
+						}									
+					}
+					
+				}
+			}
+		} catch (BadLocationException e) {
+			return super.computePartitioning(offset, length, includeZeroLengthPartitions);
+		}
+		return (ITypedRegion[]) regions.toArray(new ITypedRegion[regions.size()]);
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.text.rules.FastPartitioner#documentChanged2(org.eclipse.jface.text.DocumentEvent)
+	 */
+	@Override
+	public IRegion documentChanged2(DocumentEvent e) {
+		computePartitioning(e.getOffset(), e.getLength());
+		return new Region(e.getOffset(), e.getLength());
+//		return super.documentChanged2(e);
+	}
+}
diff --git a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/ILineDisplayStrategy.java b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/ILineDisplayStrategy.java
index ffdc0488e..30a992e2b 100644
--- a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/ILineDisplayStrategy.java
+++ b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/ILineDisplayStrategy.java
@@ -10,7 +10,6 @@
 
 package eu.etaxonomy.taxeditor.annotatedlineeditor;
 
-import org.eclipse.swt.custom.StyleRange;
 import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.Image;
 
@@ -24,6 +23,8 @@ import org.eclipse.swt.graphics.Image;
  */
 public interface ILineDisplayStrategy {
 
+	public static final String SUPPLEMENTAL_TEXT = "supplemental_text";
+	
 	int getIndent(Object entity);
 	
 	Image getIcon(Object entity);
@@ -31,6 +32,8 @@ public interface ILineDisplayStrategy {
 	Font getFont(Object entity);
 	
 	/**
+	 * For object's title cache output, mainly
+	 * 
 	 * Note: if object's cache is empty, return "", not null
 	 * 
 	 * @param entity
@@ -38,7 +41,14 @@ public interface ILineDisplayStrategy {
 	 */
 	String getText(Object entity);
 	
-	StyleRange[] getTextStyleRanges(Object entity);
+	/**
+	 * For object's supplemental information such as type, markers, etc.,
+	 * usually stored in " [...]". 
+	 * 
+	 * @param entity
+	 * @return
+	 */
+	String getSupplementalText(Object entity);
 	
 	String getEmptyCacheMessage(Object entity);
 	
diff --git a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java
index 88851325f..1a7ed69e3 100644
--- a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java
+++ b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java
@@ -93,7 +93,7 @@ public class BulkEditor extends AnnotatedLineEditor implements PropertyChangeLis
 		
 		setLineDisplayStrategy(new BulkEditorLineDisplay(this));
 		
-		setSourceViewerConfiguration(new BulkEditorViewerConfiguration(lineDisplayStrategy));
+		setSourceViewerConfiguration(new BulkEditorViewerConfiguration());
 	}
 	
 	/* (non-Javadoc)
@@ -195,7 +195,7 @@ public class BulkEditor extends AnnotatedLineEditor implements PropertyChangeLis
 			if (next instanceof LineAnnotation) {
 				LineAnnotation annotation = (LineAnnotation) next;
 				((AnnotatedLineDocumentProvider) getDocumentProvider()).
-						updateLineFromAnnotation(getEditorInput(), annotation, lineDisplayStrategy.getText(annotation.getEntity()));
+						updateLineFromAnnotation(getEditorInput(), annotation);
 			}
 		}
 	}
diff --git a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorLineDisplay.java b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorLineDisplay.java
index fd93ed2b3..7ebc3a327 100644
--- a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorLineDisplay.java
+++ b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorLineDisplay.java
@@ -12,10 +12,6 @@ package eu.etaxonomy.taxeditor.bulkeditor;
 
 import org.apache.log4j.Logger;
 import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.jface.text.source.DefaultAnnotationHover;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
 import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.widgets.Display;
@@ -60,7 +56,6 @@ public class BulkEditorLineDisplay implements ILineDisplayStrategy {
 	 * @see eu.etaxonomy.taxeditor.bulkeditor.ILineDisplayStrategy#getIcon(java.lang.Object)
 	 */
 	public Image getIcon(Object entity) {
-		// TODO Auto-generated method stub
 		return null;
 	}
 
@@ -68,7 +63,6 @@ public class BulkEditorLineDisplay implements ILineDisplayStrategy {
 	 * @see eu.etaxonomy.taxeditor.bulkeditor.ILineDisplayStrategy#getIndent(java.lang.Object)
 	 */
 	public int getIndent(Object entity) {
-		// TODO Auto-generated method stub
 		return 0;
 	}
 
@@ -98,9 +92,26 @@ public class BulkEditorLineDisplay implements ILineDisplayStrategy {
 		if (entity instanceof ReferenceBase) {
 			ReferenceBase reference = (ReferenceBase) HibernateProxyHelper.deproxy(entity);
 			String text = reference.getTitleCache();
-			if (text == null) {
-				return "";
-			}
+			return text == null ? "" : text;
+		}
+		if (entity instanceof TaxonNameBase) {
+			String text = ((TaxonNameBase) entity).getTitleCache(); 
+			return text == null ? "" : text;
+		}
+		if (entity instanceof AgentBase) {
+			String text = ((AgentBase) entity).getTitleCache();
+			return text == null ? "" : text;
+		}
+		return "";
+	}
+
+
+	/* (non-Javadoc)
+	 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.ILineDisplayStrategy#getSupplementalText(java.lang.Object)
+	 */
+	public String getSupplementalText(Object entity) {
+		if (entity instanceof ReferenceBase) {
+			ReferenceBase reference = (ReferenceBase) HibernateProxyHelper.deproxy(entity);
 			// Nobody seems to like displaying the date
 //			TimePeriod datePublished = ((StrictReferenceBase) reference).getDatePublished();
 //						
@@ -120,16 +131,17 @@ public class BulkEditorLineDisplay implements ILineDisplayStrategy {
 				}
 			}
 			if (markerText != null) {
-				text += markerText + "]";
+				markerText += "]";
+			} else {
+				markerText = "";
 			}
-			return text;
+			return markerText;
 		}
-		if (entity instanceof TaxonNameBase) {
-			String text = ((TaxonNameBase) entity).getTitleCache(); 
-			return text == null ? "" : text;
+		if (entity instanceof TaxonNameBase) { 
+			return "";
 		}
 		if (entity instanceof AgentBase) {
-			String text = ((AgentBase) entity).getTitleCache();
+			String text = "";
 			if (entity instanceof Team) {
 				text += " [Team]";
 			}
@@ -139,33 +151,11 @@ public class BulkEditorLineDisplay implements ILineDisplayStrategy {
 			if (entity instanceof Institution) {
 				text += " [Institution]";
 			}
-			return text == null ? "" : text;
+			return text;
 		}
 		return "";
 	}
 	
-
-
-	/* (non-Javadoc)
-	 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.ILineDisplayStrategy#addStyleRanges(java.lang.Object, org.eclipse.jface.text.TextPresentation)
-	 */
-	public StyleRange[] getTextStyleRanges(Object entity) {
-		if (isEntityCacheEmpty(entity)) {
-			return new StyleRange[] { new StyleRange(0, getEmptyCacheMessage(entity).length(), 
-										Display.getCurrent().getSystemColor(SWT.COLOR_GRAY), null) };
-		}
-		if (entity instanceof ReferenceBase) {
-			ReferenceBase reference = (ReferenceBase) HibernateProxyHelper.deproxy(entity);
-			return new StyleRange[] { new StyleRange(reference.getTitleCache().length(), getText(entity).length(), 
-											Display.getCurrent().getSystemColor(SWT.COLOR_GRAY), null)};
-		}
-		if (entity instanceof AgentBase) {
-			return new StyleRange[] { new StyleRange(((AgentBase) entity).getTitleCache().length(), getText(entity).length(), 
-										Display.getCurrent().getSystemColor(SWT.COLOR_GRAY), null)};
-		}
-		return new StyleRange[0];
-	}
-
 	/* (non-Javadoc)
 	 * @see eu.etaxonomy.taxeditor.bulkeditor.ILineDisplayStrategy#setText(java.lang.String, java.lang.Object)
 	 */
diff --git a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorViewerConfiguration.java b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorViewerConfiguration.java
index 7a11c33c6..2365d7bbe 100644
--- a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorViewerConfiguration.java
+++ b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorViewerConfiguration.java
@@ -9,22 +9,20 @@
 */
 package eu.etaxonomy.taxeditor.bulkeditor;
 
-import java.util.Iterator;
-
 import org.apache.log4j.Logger;
 import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
 import org.eclipse.jface.text.TextPresentation;
 import org.eclipse.jface.text.presentation.IPresentationReconciler;
 import org.eclipse.jface.text.presentation.PresentationReconciler;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
 import org.eclipse.jface.text.source.ISourceViewer;
 import org.eclipse.jface.text.source.SourceViewerConfiguration;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.StyleRange;
 
 import eu.etaxonomy.taxeditor.annotatedlineeditor.ILineDisplayStrategy;
-import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation;
-import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotationModel;
 
 
 /**
@@ -35,49 +33,38 @@ import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotationModel;
 public class BulkEditorViewerConfiguration extends SourceViewerConfiguration {
 	private static final Logger logger = Logger
 			.getLogger(BulkEditorViewerConfiguration.class);
-	
-	private ILineDisplayStrategy lineDisplayStrategy;
 
-	/**
-	 * @param lineDisplayStrategy
-	 */
-	public BulkEditorViewerConfiguration(
-			ILineDisplayStrategy lineDisplayStrategy) {
-		this.lineDisplayStrategy = lineDisplayStrategy;
-	}
-	
 	/* (non-Javadoc)
 	 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
 	 */
 	@Override
 	public IPresentationReconciler getPresentationReconciler(
 			final ISourceViewer sourceViewer) {
-		return new PresentationReconciler() {
+		
+		PresentationReconciler reconciler = new PresentationReconciler();
+		
+		DefaultDamagerRepairer damageRepairer = new DefaultDamagerRepairer(new RuleBasedPartitionScanner()) {
 			/* (non-Javadoc)
-			 * @see org.eclipse.jface.text.presentation.PresentationReconciler#createPresentation(org.eclipse.jface.text.IRegion, org.eclipse.jface.text.IDocument)
+			 * @see org.eclipse.jface.text.rules.DefaultDamagerRepairer#createPresentation(org.eclipse.jface.text.TextPresentation, org.eclipse.jface.text.ITypedRegion)
 			 */
 			@Override
-			protected TextPresentation createPresentation(IRegion damage,
-					IDocument document) {
-				
-				TextPresentation presentation = super.createPresentation(damage, document);
-				LineAnnotationModel model = (LineAnnotationModel) sourceViewer.getAnnotationModel();
-				
-				// Update all annotated lines in the damage zone
-				Iterator iter = model.getAnnotationIterator(damage.getOffset(), damage.getLength() + 1, true, true);
-				while (iter.hasNext()) {
-					Object next = iter.next();
-					if (next instanceof LineAnnotation) {
-						for (StyleRange styleRange : lineDisplayStrategy.getTextStyleRanges(((LineAnnotation) next).getEntity())) {
-							styleRange.start += model.getPosition((LineAnnotation) next).getOffset();
-							presentation.addStyleRange(styleRange);
-						}
-					}
-				}
-				
-				return presentation;
+			public void createPresentation(TextPresentation presentation,
+					ITypedRegion region) {
+				presentation.addStyleRange(new StyleRange(region.getOffset(), region.getLength(),
+						sourceViewer.getTextWidget().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY), null, SWT.ITALIC));
 			}
 		};
+		reconciler.setDamager(damageRepairer, ILineDisplayStrategy.SUPPLEMENTAL_TEXT);
+		reconciler.setRepairer(damageRepairer, ILineDisplayStrategy.SUPPLEMENTAL_TEXT);
+		
+		return reconciler;
 	}
 	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredContentTypes(org.eclipse.jface.text.source.ISourceViewer)
+	 */
+	@Override
+	public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
+		return new String[] { IDocument.DEFAULT_CONTENT_TYPE, ILineDisplayStrategy.SUPPLEMENTAL_TEXT };
+	}
 }
\ No newline at end of file
diff --git a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/RemoveMergeCandidateHandler.java b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/RemoveMergeCandidateHandler.java
index 890e479a2..d88f6bc8b 100644
--- a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/RemoveMergeCandidateHandler.java
+++ b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/RemoveMergeCandidateHandler.java
@@ -14,11 +14,11 @@ import java.util.Iterator;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.text.TextSelection;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotationModel;
-import eu.etaxonomy.taxeditor.annotatedlineeditor.LineSelection;
 import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
 
 /**
@@ -33,9 +33,9 @@ public class RemoveMergeCandidateHandler extends AbstractHandler {
 	 */
 	public Object execute(ExecutionEvent event) throws ExecutionException {
 				
-		if (HandlerUtil.getCurrentSelection(event) instanceof LineSelection 
+		if (HandlerUtil.getCurrentSelection(event) instanceof TextSelection 
 				&& HandlerUtil.getActiveEditor(event) instanceof BulkEditor) {
-			LineSelection selection = (LineSelection) HandlerUtil.getCurrentSelection(event);
+			TextSelection selection = (TextSelection) HandlerUtil.getCurrentSelection(event);
 			BulkEditor editor = (BulkEditor) HandlerUtil.getActiveEditor(event);
 			
 			LineAnnotationModel model = (LineAnnotationModel) editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
@@ -49,40 +49,7 @@ public class RemoveMergeCandidateHandler extends AbstractHandler {
 					}
 				}
 			}
-		}
-		
-//		
-//		
-//		
-//		IEditorPart editor = HandlerUtil.getActiveEditor(event);
-//		IEditorInput input = editor.getEditorInput();
-//		
-//		if (editor instanceof BulkEditor && input instanceof BulkEditorInput) {
-//			
-//			IDocumentProvider provider = ((AnnotatedLineEditor) editor).getDocumentProvider();
-//			LineAnnotationModel model = 
-//					(LineAnnotationModel) provider.getAnnotationModel(input);
-//			IDocument document = provider.getDocument(input);
-//			
-//			ISelection selection = HandlerUtil.getActiveMenuSelection(event);
-//			if (selection instanceof TextSelection) {
-//				Annotation annotation = null;
-//				
-//				// Get annotation in current line
-//				int line = ((TextSelection) selection).getStartLine();
-//				annotation = model.getAnnotationAtLine(line, document);
-//				
-//				if (annotation != null) {
-//					if (annotation.getType().equals(IBulkEditorConstants.TYPE_MERGE_CANDIDATE)) {
-//						model.changeAnnotationType(
-//								annotation, LineAnnotation.TYPE_GENERIC);
-//					} else {
-//						model.changeAnnotationType(
-//								annotation, IBulkEditorConstants.TYPE_MERGE_CANDIDATE);
-//					}
-//				}
-//			}
-//		}		
+		}	
 		return null;
 	}
 }
\ No newline at end of file
diff --git a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/SetMarkerFlagFalseHandler.java b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/SetMarkerFlagFalseHandler.java
index 63b44dee9..943645c49 100644
--- a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/SetMarkerFlagFalseHandler.java
+++ b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/SetMarkerFlagFalseHandler.java
@@ -17,6 +17,7 @@ import org.apache.log4j.Logger;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.text.TextSelection;
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.ui.handlers.HandlerUtil;
 
@@ -26,7 +27,6 @@ import eu.etaxonomy.cdm.model.common.Marker;
 import eu.etaxonomy.cdm.model.common.MarkerType;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotationModel;
-import eu.etaxonomy.taxeditor.annotatedlineeditor.LineSelection;
 import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
 
 /**
@@ -47,9 +47,9 @@ public class SetMarkerFlagFalseHandler extends AbstractHandler {
 		
 		Object data = ((Event) event.getTrigger()).data;
 		
-		if (HandlerUtil.getCurrentSelection(event) instanceof LineSelection 
+		if (HandlerUtil.getCurrentSelection(event) instanceof TextSelection 
 					&& HandlerUtil.getActiveEditor(event) instanceof BulkEditor && data instanceof MarkerType) {
-			LineSelection selection = (LineSelection) HandlerUtil.getCurrentSelection(event);
+			TextSelection selection = (TextSelection) HandlerUtil.getCurrentSelection(event);
 			BulkEditor editor = (BulkEditor) HandlerUtil.getActiveEditor(event);
 			
 			LineAnnotationModel model = (LineAnnotationModel) editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
diff --git a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/SetMarkerFlagTrueHandler.java b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/SetMarkerFlagTrueHandler.java
index db7ea555e..c3860abad 100644
--- a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/SetMarkerFlagTrueHandler.java
+++ b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/SetMarkerFlagTrueHandler.java
@@ -17,6 +17,8 @@ import org.apache.log4j.Logger;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.ui.handlers.HandlerUtil;
 
@@ -45,9 +47,9 @@ public class SetMarkerFlagTrueHandler extends AbstractHandler {
 		
 		Object data = ((Event) event.getTrigger()).data;
 		
-		if (HandlerUtil.getCurrentSelection(event) instanceof LineSelection 
+		if (HandlerUtil.getCurrentSelection(event) instanceof TextSelection 
 					&& HandlerUtil.getActiveEditor(event) instanceof BulkEditor && data instanceof MarkerType) {
-			LineSelection selection = (LineSelection) HandlerUtil.getCurrentSelection(event);
+			TextSelection selection = (TextSelection) HandlerUtil.getCurrentSelection(event);
 			BulkEditor editor = (BulkEditor) HandlerUtil.getActiveEditor(event);
 			
 			LineAnnotationModel model = (LineAnnotationModel) editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
diff --git a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/SetMergeCandidateHandler.java b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/SetMergeCandidateHandler.java
index e40dc445a..6c68c95ff 100644
--- a/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/SetMergeCandidateHandler.java
+++ b/taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/SetMergeCandidateHandler.java
@@ -14,6 +14,7 @@ import java.util.Iterator;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.text.TextSelection;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation;
@@ -34,9 +35,9 @@ public class SetMergeCandidateHandler extends AbstractHandler {
 	 */
 	public Object execute(ExecutionEvent event) throws ExecutionException {
 				
-		if (HandlerUtil.getCurrentSelection(event) instanceof LineSelection 
+		if (HandlerUtil.getCurrentSelection(event) instanceof TextSelection 
 				&& HandlerUtil.getActiveEditor(event) instanceof BulkEditor) {
-			LineSelection selection = (LineSelection) HandlerUtil.getCurrentSelection(event);
+			TextSelection selection = (TextSelection) HandlerUtil.getCurrentSelection(event);
 			BulkEditor editor = (BulkEditor) HandlerUtil.getActiveEditor(event);
 			
 			LineAnnotationModel model = (LineAnnotationModel) editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
@@ -50,40 +51,7 @@ public class SetMergeCandidateHandler extends AbstractHandler {
 					}
 				}
 			}
-		}
-		
-//		
-//		
-//		
-//		IEditorPart editor = HandlerUtil.getActiveEditor(event);
-//		IEditorInput input = editor.getEditorInput();
-//		
-//		if (editor instanceof BulkEditor && input instanceof BulkEditorInput) {
-//			
-//			IDocumentProvider provider = ((AnnotatedLineEditor) editor).getDocumentProvider();
-//			LineAnnotationModel model = 
-//					(LineAnnotationModel) provider.getAnnotationModel(input);
-//			IDocument document = provider.getDocument(input);
-//			
-//			ISelection selection = HandlerUtil.getActiveMenuSelection(event);
-//			if (selection instanceof TextSelection) {
-//				Annotation annotation = null;
-//				
-//				// Get annotation in current line
-//				int line = ((TextSelection) selection).getStartLine();
-//				annotation = model.getAnnotationAtLine(line, document);
-//				
-//				if (annotation != null) {
-//					if (annotation.getType().equals(IBulkEditorConstants.TYPE_MERGE_CANDIDATE)) {
-//						model.changeAnnotationType(
-//								annotation, LineAnnotation.TYPE_GENERIC);
-//					} else {
-//						model.changeAnnotationType(
-//								annotation, IBulkEditorConstants.TYPE_MERGE_CANDIDATE);
-//					}
-//				}
-//			}
-//		}		
+		}	
 		return null;
 	}
 }
\ No newline at end of file
