Index: TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationManager.java
===================================================================
--- TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationManager.java	(revision 4026)
+++ TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationManager.java	(revision 4027)
@@ -194,23 +194,24 @@
 	 * 
 	 * CQP Annotations must be shadowed by temporary annotations of the same type and positions
 	 */
-	public List<Annotation> getAnnotationsForMatches(AnnotationType type, List<Match> matches, boolean overlap) {
+	public List<Annotation> getAnnotationsForMatches(AnnotationType type, List<Match> subsetMatches, boolean overlap) {
+		
 		List<Annotation> temporaryAnnotations = null;
 		List<Annotation> resultAnnotations = new ArrayList<>();
 		try {
-			temporaryAnnotations = tempManager.getAnnotations(type, matches, null, false, overlap);
-			temporaryAnnotations = tempManager.getAnnotationsForMatches(matches, temporaryAnnotations, overlap);
+			temporaryAnnotations = tempManager.getAnnotations(type, subsetMatches, null, false, overlap);
+			temporaryAnnotations = tempManager.getAnnotationsForMatches(subsetMatches, temporaryAnnotations, overlap);
 			
-			List<? extends Annotation> cqpAnnotations = cqpManager.getAnnotationsForMatches(matches, type, overlap);
+			List<? extends Annotation> cqpAnnotations = cqpManager.getAnnotationsForMatches(subsetMatches, type, overlap);
 			
 			// System.out.println("Temporary annotations: "+temporaryAnnotations);
 			// System.out.println("CQP annotations: "+cqpAnnotations);
-			if (cqpAnnotations.size() != matches.size() || temporaryAnnotations.size() != matches.size()) {
+			if (cqpAnnotations.size() != subsetMatches.size() || temporaryAnnotations.size() != subsetMatches.size()) {
 				Log.info("ERROR in getAnnotationsForMatches methods! "); //$NON-NLS-1$
-				return new ArrayList<>(matches.size());
+				return new ArrayList<>(subsetMatches.size());
 			}
 			// merge the 2 results
-			for (int i = 0; i < matches.size(); i++) {
+			for (int i = 0; i < subsetMatches.size(); i++) {
 				if (cqpAnnotations.get(i) == null && temporaryAnnotations.get(i) == null) {
 					resultAnnotations.add(null);
 				}
@@ -227,7 +228,7 @@
 		}
 		catch (Exception e) {
 			e.printStackTrace();
-			return new ArrayList<>(matches.size());
+			return new ArrayList<>(subsetMatches.size());
 		}
 		return resultAnnotations;
 	}
@@ -385,10 +386,31 @@
 		return temporaryAnnotations;
 	}
 	
-	public List<Annotation> getAnnotations(AnnotationType type, int i, int j) {
-		return getAnnotations(type, i, j, false);
+	public List<Annotation> getAnnotations(AnnotationType type, boolean overlap) {
+		List<Annotation> temporaryAnnotations = null;
+		List<Annotation> cqpAnnotations = null;
+		try {
+			temporaryAnnotations = tempManager.getAnnotations(type, true);
+			cqpAnnotations = cqpManager.getAnnotations(type, overlap);
+			
+			int i = 0;
+			for (Annotation a : cqpAnnotations) {
+				while (temporaryAnnotations.get(i).getStart() < a.getStart()) {
+					i++;
+				}
+				temporaryAnnotations.add(i, a);
+			}
+		}
+		catch (Exception e) {
+			
+		}
+		return temporaryAnnotations;
 	}
 	
+	public List<Annotation> getAnnotations(AnnotationType type, int start, int end) {
+		return getAnnotations(type, start, end, false);
+	}
+	
 	public void closeAll() {
 		Log.fine("Closing annotation manager of " + corpus); //$NON-NLS-1$
 		tempManager.close();
Index: TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/CQPAnnotationManager.java
===================================================================
--- TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/CQPAnnotationManager.java	(revision 4026)
+++ TXM/trunk/bundles/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/CQPAnnotationManager.java	(revision 4027)
@@ -4,6 +4,7 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
+import java.util.regex.Pattern;
 
 import org.osgi.service.prefs.BackingStoreException;
 import org.txm.annotation.kr.core.repository.AnnotationEffect;
@@ -72,6 +73,75 @@
 	 * @throws IOException
 	 */
 	public List<Annotation> getAnnotations(AnnotationType type, Match match, String value, boolean overlap) throws CqiClientException, IOException, CqiServerError {
+		if (type == null || type.getEffect().equals(AnnotationEffect.SEGMENT)) {
+			return getSegmentAnnotations(type, match, value, overlap);
+		} else {
+			return getTokenAnnotations(type, match, value, overlap);
+		}
+	}
+	
+	/**
+	 * 
+	 * @param matches Ordered matches, not null
+	 * @param type not null
+	 * @param overlap use true to detect overlapping annotations
+	 * @return ONE Annotation per Match for a given type
+	 * 
+	 * @throws CqiServerError
+	 * @throws IOException
+	 * @throws CqiClientException
+	 */
+	public List<Annotation> getTokenAnnotations(AnnotationType type, Match subsetMatch, String value, boolean overlap) throws IOException, CqiServerError, CqiClientException {
+		
+		Property prop = corpus.getProperty(type.getId().toLowerCase());
+		if (prop == null) return nullAnnotationList(0); // no property, no annotation :)
+		
+		AbstractCqiClient cqi = CQPSearchEngine.getCqiClient();
+		
+		int start = corpus.getFirstPosition();
+		int n = corpus.getSize();
+		
+		if (subsetMatch != null) { // use a subset instead of all the corpus
+			start = subsetMatch.getStart();
+			n = subsetMatch.size();
+		}
+		
+		int i = 0;
+		int positions[] = new int[n];
+		for (i = 0 ; i < n ; i++) {
+			positions[i] = start + i;
+		}
+		
+		String[] strs = cqi.cpos2Str(prop.getQualifiedName(), positions);
+		
+		Pattern pattern = null;
+		if (value != null) pattern = Pattern.compile(value);
+		
+		ArrayList<Annotation> annotations = new ArrayList<Annotation>();
+		i = 0;
+		for (String str : strs) {
+			int p = positions[i++];
+			if (value == null || pattern.matcher(str).matches()) {
+				annotations.add(new CQPAnnotation(type.getId(), str, p, p));
+			}
+		}
+		// Log.info("TOKEN ANNOTATION CQP VALUES: "+annotations);
+		return annotations;
+	}
+	
+	/**
+	 * Return all annotations for ONE match
+	 * can be use to find out overlap
+	 * 
+	 * @param match can be null
+	 * @param value can be null
+	 * @param overlap
+	 * @return
+	 * @throws CqiClientException
+	 * @throws CqiServerError
+	 * @throws IOException
+	 */
+	public List<Annotation> getSegmentAnnotations(AnnotationType type, Match match, String value, boolean overlap) throws CqiClientException, IOException, CqiServerError {
 		HashMap<StructuralUnitProperty, AnnotationType> supList = new HashMap<StructuralUnitProperty, AnnotationType>();
 		
 		// TODO add a corpus parameters for structures that code annotations
Index: TXM/trunk/bundles/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/WordAnnotationToolbar.java
===================================================================
--- TXM/trunk/bundles/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/WordAnnotationToolbar.java	(revision 4026)
+++ TXM/trunk/bundles/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/WordAnnotationToolbar.java	(revision 4027)
@@ -215,7 +215,6 @@
 		final KnowledgeRepository kr = KnowledgeRepositoryManager.getKnowledgeRepository(type.getKnowledgeRepository());
 		value_to_add = kr.getValue(type, svalue);
 		
-		
 		if (value_to_add == null && kr instanceof LocalKnowledgeRepository) { // create or not the annotation is simple mode
 			value_to_add = kr.addValue(svalue, svalue, type.getId());
 		}
Index: TXM/trunk/bundles/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/edition/WordAnnotationToolbar.java
===================================================================
--- TXM/trunk/bundles/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/edition/WordAnnotationToolbar.java	(revision 4026)
+++ TXM/trunk/bundles/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/edition/WordAnnotationToolbar.java	(revision 4027)
@@ -1,10 +1,13 @@
 package org.txm.annotation.kr.rcp.edition;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Vector;
 import java.util.logging.Level;
+import java.util.regex.Pattern;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
@@ -46,15 +49,14 @@
 import org.txm.annotation.kr.core.repository.TypedValue;
 import org.txm.annotation.kr.rcp.commands.InitializeKnowledgeRepository;
 import org.txm.annotation.kr.rcp.commands.SaveAnnotations;
-import org.txm.annotation.kr.rcp.concordance.ConcordanceAnnotations;
 import org.txm.annotation.kr.rcp.messages.Messages;
 import org.txm.annotation.kr.rcp.views.knowledgerepositories.KRView;
 import org.txm.annotation.rcp.editor.AnnotationArea;
 import org.txm.annotation.rcp.editor.AnnotationExtension;
-import org.txm.concordance.core.functions.Concordance;
 import org.txm.concordance.rcp.messages.ConcordanceUIMessages;
 import org.txm.core.messages.TXMCoreMessages;
 import org.txm.core.results.TXMResult;
+import org.txm.edition.rcp.editors.RGBA;
 import org.txm.edition.rcp.editors.SynopticEditionEditor;
 import org.txm.objects.Match;
 import org.txm.objects.Match2P;
@@ -65,87 +67,93 @@
 import org.txm.rcp.swt.dialog.ConfirmDialog;
 import org.txm.rcp.swt.provider.SimpleLabelProvider;
 import org.txm.rcp.utils.JobHandler;
+import org.txm.searchengine.cqp.AbstractCqiClient;
 import org.txm.searchengine.cqp.CQPSearchEngine;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.corpus.CQPCorpus;
 import org.txm.searchengine.cqp.corpus.WordProperty;
 import org.txm.utils.AsciiUtils;
 import org.txm.utils.logger.Log;
 
 public class WordAnnotationToolbar extends AnnotationArea {
-	
+
 	/**
 	 * the limit number of annotation when a confirm dialog box is shown
 	 */
 	protected static final int NALERTAFFECTANNOTATIONS = 100;
-	
+
 	public static final String EMPTYTEXT = ""; //$NON-NLS-1$
-	
+
 	/** The annotation service */
 	protected AnnotationManager annotManager;
-	
+
 	protected SynopticEditionEditor editor;
-	
+
 	/**
 	 * The concordance annotations to show in the concordance column table
 	 */
 	private EditionAnnotations annotations = null;
-	
+
 	/**
 	 * All available annotation types
 	 */
 	protected List<TypedValue> typeValuesList;
-	
+
 	protected ComboViewer annotationTypesCombo;
-	
+
 	protected Label equalLabel;
-	
+
 	protected Text annotationValuesText;
-	
+
 	protected Button affectAnnotationButton;
-	
+
 	protected Button deleteAnnotationButton;
-	
+
 	protected KnowledgeRepository currentKnowledgeRepository = null;
-	
+
 	protected Vector<AnnotationType> typesList = new Vector<>();
-	
+
 	protected AnnotationType tagAnnotationType; // the tag annotation type if annotation mode is simple
-	
+
 	protected TypedValue value_to_add;
-	
+
 	//protected Concordance concordance;
-	
+
 	private CQPCorpus corpus;
-	
+
 	private TableViewerColumn annotationColumnViewer;
-	
+
 	private Font annotationColummnFont;
-	
+
 	private Font defaultColummnFont;
-	
+
 	private Button addAnnotationTypeLink;
-	
+
 	private Button addTypedValueLink;
-	
+
+	protected Label colorsLabel;
+
+	protected Text colorsValuesText;
+
 	@Override
 	public String getName() {
 		return Messages.motsPropritsInfDfaut;
 	}
-	
+
 	@Override
 	public boolean allowMultipleAnnotations() {
 		return true;
 	}
-	
+
 	public WordAnnotationToolbar() {}
-	
+
 	protected AnnotationType getSelectedAnnotationType() {
 		return annotations.getViewAnnotation();
 	}
-	
+
 	public void updateAnnotationWidgetStates() {
 		if (annotationArea == null) return; // :)
-		
+
 		if (getSelectedAnnotationType() != null) {
 			annotationValuesText.setEnabled(true);
 			affectAnnotationButton.setEnabled(true);
@@ -157,15 +165,20 @@
 			deleteAnnotationButton.setEnabled(false);
 		}
 	}
-	
+
 	protected void affectAnnotationToSelection(String[] word_selection) {
-		
+
+		if (word_selection == null) return;
+
 		ArrayList<Match> matches = new ArrayList<>();
 
+		if (word_selection[1] == null) word_selection[1] = word_selection[0];
+
 		try {
+			
 			int[] indexes = CQPSearchEngine.getCqiClient().str2Id(corpus.getProperty("id").getQualifiedName(), word_selection);
 			int[] allPositions = CQPSearchEngine.getCqiClient().idList2Cpos(corpus.getProperty("id").getQualifiedName(), indexes);
-			for (int p : allPositions) {
+			for (int p = allPositions[0] ; p <= allPositions[1] ; p++) {
 				matches.add(new Match2P(p));
 			}
 			affectAnnotationsToMatches(matches);
@@ -174,7 +187,7 @@
 			e.printStackTrace();
 		}
 	}
-	
+
 	protected void affectAnnotationValues(final List<? extends Match> matches, final AnnotationType type, final String svalue, JobHandler job) {
 		value_to_add = null; // reset
 		if (matches == null || matches.size() == 0) {
@@ -182,9 +195,9 @@
 			return;
 		}
 		if (type == null) return; // no type, no annotation
-		
+
 		job.syncExec(new Runnable() {
-			
+
 			@Override
 			public void run() {
 				if (matches.size() > NALERTAFFECTANNOTATIONS) {
@@ -192,7 +205,7 @@
 							"confirm_annotate",  //$NON-NLS-1$
 							Messages.confirmAnnotationAffectation,
 							NLS.bind(Messages.youAreAboutToAnnotateP0ElementsContinue, matches.size()));
-					
+
 					if (dialog.open() == ConfirmDialog.CANCEL) {
 						Log.info("Annotation aborted by user.");
 						matches.clear();
@@ -200,20 +213,20 @@
 				}
 			}
 		});
-		
+
 		// get value from combo text value
 		Log.fine(NLS.bind(Messages.lookingForTypedValueWithIdEqualsP0, svalue));
 		final KnowledgeRepository kr = KnowledgeRepositoryManager.getKnowledgeRepository(type.getKnowledgeRepository());
 		value_to_add = kr.getValue(type, svalue);
-		
-		
+
+
 		if (value_to_add == null && kr instanceof LocalKnowledgeRepository) { // create or not the annotation is simple mode
 			value_to_add = kr.addValue(svalue, svalue, type.getId());
 		}
-		
+
 		if (value_to_add == null) {
 			job.syncExec(new Runnable() {
-				
+
 				@Override
 				public void run() {
 					String mess = Messages.bind(Messages.noValueFoundWithTheP0Id, svalue);
@@ -223,19 +236,19 @@
 			});
 			return;
 		}
-		
+
 		Log.info(TXMCoreMessages.bind(Messages.AffectP0ToP1SelectionEqualsP2, value_to_add.getId(), value_to_add.getTypeID(), matches.size()));
-		
+
 		// finally we can 'try' to create the annotations \o/
 		try {
 			HashMap<Match, List<Annotation>> existingAnnots = annotManager.createAnnotations(type, value_to_add, matches, job);
-			
+
 			// did we had problems ?
 			if (existingAnnots != null && existingAnnots.size() > 0) {
 				String message = NLS.bind(Messages.couldNotAnnotateTheValueP0OnCertainSequences, value_to_add.getStandardName());
 				for (Match m : existingAnnots.keySet()) {
 					message += NLS.bind(Messages.theSequenceP0IsOverlappingWith, m);
-					
+
 					for (Annotation existingAnnot : existingAnnots.get(m)) {
 						if (existingAnnot.getStart() < m.getStart()) {
 							message += TXMCoreMessages.bind(Messages.theEndOfAStructureP0AtP1P2, existingAnnot.getType(), existingAnnot.getStart(), existingAnnot.getEnd());
@@ -247,7 +260,7 @@
 				}
 				final String final_message = message;
 				job.syncExec(new Runnable() {
-					
+
 					@Override
 					public void run() {
 						MessageDialog.openInformation(editor.getSite().getShell(), Messages.aboutAnnotations, final_message);
@@ -256,7 +269,7 @@
 			}
 			// if (history != null && !history.get(type).contains(value_to_add))
 			// history.get(type).add(value_to_add);
-			
+
 			if (Log.getLevel().intValue() < Level.INFO.intValue() && annotManager != null) {
 				annotManager.checkData();
 			}
@@ -267,9 +280,9 @@
 			Log.printStackTrace(e1);
 			return;
 		}
-		
+
 		job.syncExec(new Runnable() {
-			
+
 			@Override
 			public void run() {
 				try {
@@ -282,9 +295,27 @@
 			}
 		});
 	}
-	
+
+	private HashMap<RGBA, HashSet<String>> previousSelectedTypeUnitIDS;
+
+	public void clearHighlight() {
+
+		if (previousSelectedTypeUnitIDS != null) {
+			if (!editor.isDisposed()) {
+				for (RGBA color : previousSelectedTypeUnitIDS.keySet()) {
+					editor.removeHighlightWordsById(color, previousSelectedTypeUnitIDS.get(color));
+				}
+			}
+			previousSelectedTypeUnitIDS = null; // release memory
+		} else {
+			previousSelectedTypeUnitIDS = new HashMap<RGBA, HashSet<String>>();
+		}
+	}
+
 	protected void deleteAnnotationValues(String[] word_selection) {
-		
+
+		if (word_selection == null) return;
+
 		ArrayList<Match> matches = new ArrayList<>();
 		try {
 			int[] indexes = CQPSearchEngine.getCqiClient().str2Id(corpus.getProperty("id").getQualifiedName(), word_selection);
@@ -297,19 +328,29 @@
 		catch (Exception e) {
 			e.printStackTrace();
 		}
-		
+
 	}
-	
+
 	protected void deleteAnnotationValues(final List<Match> matches) {
 		final AnnotationType type = getSelectedAnnotationType();
-		
+
 		JobHandler job = new JobHandler(Messages.annotatingConcordanceSelection, true) {
-			
+
 			@Override
 			protected IStatus run(IProgressMonitor monitor) {
 				this.runInit(monitor);
 				try {
 					deleteAnnotationValues(matches, type, this);
+					
+					this.syncExec(new Runnable() {
+						
+						@Override
+						public void run() {
+							updateHighlights(null);
+							editor.updateWordStyles();
+						}
+					});
+					
 				}
 				catch (Exception e) {
 					Log.severe(NLS.bind(Messages.errorWhileAnnotatingConcordanceSelectionColonP0, e));
@@ -320,28 +361,28 @@
 					Log.info(Messages.annotationCanceledByUser);
 					return Status.CANCEL_STATUS;
 				}
-				
+
 				return Status.OK_STATUS;
 			}
 		};
 		job.startJob(true);
 	}
-	
+
 	protected void deleteAnnotationValues(List<Match> matches, AnnotationType type, JobHandler job) {
-		
+
 		if (matches.size() == 0) {
 			Log.warning("No lines selected. Aborting.");
 			return;
 		}
-		
+
 		if (type == null) {
 			return;
 		}
-		
+
 		try {
 			if (annotManager != null && annotManager.deleteAnnotations(type, matches, job)) {
 				if (Log.getLevel().intValue() < Level.INFO.intValue()) annotManager.checkData();
-				
+
 			}
 			else {
 				return;
@@ -352,13 +393,14 @@
 			Log.printStackTrace(e1);
 			return;
 		}
-		
+
 		job.syncExec(new Runnable() {
-			
+
 			@Override
 			public void run() {
 				try {
-					editor.refresh(false);
+					updateHighlights(null);
+					editor.updateWordStyles();
 				}
 				catch (Exception e) {
 					Log.printStackTrace(e);
@@ -366,18 +408,28 @@
 			}
 		});
 	}
-	
+
 	protected void affectAnnotationsToMatches(final List<? extends Match> matches) {
 		final AnnotationType type = getSelectedAnnotationType();
 		final String svalue = annotationValuesText.getText();
-		
+
 		JobHandler job = new JobHandler(Messages.annotatingConcordanceSelection, true) {
-			
+
 			@Override
 			protected IStatus run(IProgressMonitor monitor) {
 				this.runInit(monitor);
 				try {
 					affectAnnotationValues(matches, type, svalue, this);
+					updateHighlights(null);
+					
+					this.syncExec(new Runnable() {
+						
+						@Override
+						public void run() {
+							editor.updateWordStyles();
+						}
+					});
+					
 				}
 				catch (Exception e) {
 					Log.severe(NLS.bind(Messages.errorWhileAnnotatingConcordanceSelectionColonP0, e));
@@ -388,28 +440,28 @@
 					Log.info(Messages.annotationCanceledByUser);
 					return Status.CANCEL_STATUS;
 				}
-				
+
 				return Status.OK_STATUS;
 			}
 		};
 		job.startJob(true);
 	}
-	
+
 	@Override
 	public boolean install(TXMEditor<? extends TXMResult> txmeditor, AnnotationExtension ext, Composite parent, int position) throws Exception {
-		
+
 		this.extension = ext;
 		this.editor = (SynopticEditionEditor) txmeditor;
 		this.corpus = editor.getCorpus();
 		this.annotManager = KRAnnotationEngine.getAnnotationManager(corpus);
 		this.annotations = new EditionAnnotations(this.editor);
-		
+
 		// TODO install browser listeners here
-		
+
 		List<KnowledgeRepository> krs = InitializeKnowledgeRepository.get(corpus.getMainCorpus());
 		typesList.clear();
 		Log.fine("Corpus KRs: " + krs); //$NON-NLS-1$
-		
+
 		currentKnowledgeRepository = KnowledgeRepositoryManager.getKnowledgeRepository(corpus.getMainCorpus().getID());
 		if (currentKnowledgeRepository == null) {
 			HashMap<String, HashMap<String, ?>> conf = new HashMap<>();
@@ -419,14 +471,14 @@
 			conf.put(KRAnnotationEngine.KNOWLEDGE_TYPES, fields);
 			HashMap<String, HashMap<String, String>> strings = new HashMap<>();
 			conf.put(KRAnnotationEngine.KNOWLEDGE_STRINGS, strings);
-			
+
 			access.put("mode", DatabasePersistenceManager.ACCESS_FILE); //$NON-NLS-1$
 			access.put("version", "0"); //$NON-NLS-1$ //$NON-NLS-2$
 			currentKnowledgeRepository = KnowledgeRepositoryManager.createKnowledgeRepository(corpus.getMainCorpus().getID(), conf);
 			KnowledgeRepositoryManager.registerKnowledgeRepository(currentKnowledgeRepository);
 			// KRAnnotationEngine.registerKnowledgeRepositoryName(corpus, corpus.getMainCorpus().getID());
 		}
-		
+
 		List<WordProperty> wordProperties = corpus.getProperties();
 		for (WordProperty p : wordProperties) {
 			if (p.getName().equals("id")) continue; //$NON-NLS-1$
@@ -439,7 +491,7 @@
 				type.setEffect(AnnotationEffect.TOKEN);
 			}
 		}
-		
+
 		Log.fine("KR: " + currentKnowledgeRepository); //$NON-NLS-1$
 		List<AnnotationType> krtypes = currentKnowledgeRepository.getAllAnnotationTypes();
 		for (AnnotationType type : krtypes) {
@@ -447,29 +499,29 @@
 				typesList.add(type);
 			}
 		}
-		
+
 		Log.fine(NLS.bind(Messages.availableAnnotationTypesColonP0, typesList));
-		
+
 		annotationArea = new GLComposite(parent, SWT.NONE, Messages.concordanceAnnotationArea);
 		annotationArea.getLayout().numColumns = 12;
 		annotationArea.getLayout().horizontalSpacing = 2;
 		annotationArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-		
+
 		GridData gdata = new GridData(SWT.CENTER, SWT.CENTER, false, false);
 		gdata.widthHint = 90;
-		
+
 		new Label(annotationArea, SWT.NONE).setText(TXMCoreMessages.common_property);
-		
+
 		// Display combo with list of Annotation Type
 		annotationTypesCombo = new ComboViewer(annotationArea, SWT.READ_ONLY);
 		annotationTypesCombo.setContentProvider(new ArrayContentProvider());
 		annotationTypesCombo.setLabelProvider(new SimpleLabelProvider() {
-			
+
 			@Override
 			public String getColumnText(Object element, int columnIndex) {
 				return ((AnnotationType) element).getName();
 			}
-			
+
 			@Override
 			public String getText(Object element) {
 				return ((AnnotationType) element).getName();
@@ -498,10 +550,10 @@
 		// @Override
 		// public void keyPressed(KeyEvent e) { }
 		// });
-		
+
 		gdata = new GridData(SWT.CENTER, SWT.CENTER, false, false);
 		gdata.widthHint = 200;
-		
+
 		annotationTypesCombo.getCombo().setLayoutData(gdata);
 		annotationTypesCombo.setInput(typesList);
 		annotationTypesCombo.getCombo().select(0);
@@ -513,29 +565,29 @@
 		// annotationColumn.setText(name);
 		// }
 		// }
-		
+
 		annotationTypesCombo.addSelectionChangedListener(new ISelectionChangedListener() {
-			
+
 			@Override
 			public void selectionChanged(SelectionChangedEvent event) {
 				onAnnotationTypeSelected(event);
 			}
 		});
-		
+
 		addAnnotationTypeLink = new Button(annotationArea, SWT.PUSH);
 		addAnnotationTypeLink.setToolTipText(Messages.addANewCategory);
 		addAnnotationTypeLink.setImage(IImageKeys.getImage(IImageKeys.ACTION_ADD));
 		addAnnotationTypeLink.setEnabled(true);
 		addAnnotationTypeLink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
 		addAnnotationTypeLink.addSelectionListener(new SelectionListener() {
-			
+
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				if (currentKnowledgeRepository == null) return;
 				if (!(currentKnowledgeRepository instanceof LocalKnowledgeRepository)) return;
-				
+
 				LocalKnowledgeRepository kr = (LocalKnowledgeRepository) currentKnowledgeRepository;
-				
+
 				InputDialog dialog = new InputDialog(e.widget.getDisplay().getActiveShell(), "New property", "Enter the new property name", "", null);
 				if (dialog.open() == InputDialog.OK) {
 					String name = dialog.getValue();
@@ -549,11 +601,11 @@
 					}
 					AnnotationType type = kr.addType(name, id, "", AnnotationEffect.TOKEN); //$NON-NLS-1$
 					typesList.add(type);
-					
+
 					if (annotationTypesCombo != null) annotationTypesCombo.refresh();
 					if (typesList.size() == 1) {
 						if (annotationTypesCombo != null) annotationTypesCombo.getCombo().select(typesList.size() - 1);
-						
+
 						annotations.setViewAnnotation(type);
 						annotations.setAnnotationOverlap(true);
 						try {
@@ -564,7 +616,7 @@
 							e1.printStackTrace();
 						}
 						annotationArea.layout(true);
-						
+
 					}
 					else {
 						if (typesList.size() > 1) {
@@ -583,57 +635,57 @@
 					Log.info("Creation aborted.");
 				}
 			}
-			
+
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {}
 		});
-		
+
 		equalLabel = new Label(annotationArea, SWT.NONE);
 		equalLabel.setText("="); //$NON-NLS-1$
 		equalLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
-		
+
 		annotationValuesText = new Text(annotationArea, SWT.BORDER);
 		annotationValuesText.setToolTipText(Messages.enterAValueForAnId);
 		GridData gdata2 = new GridData(SWT.FILL, SWT.CENTER, false, false);
 		gdata2.widthHint = 200;
 		annotationValuesText.setLayoutData(gdata2);
 		annotationValuesText.addKeyListener(new KeyListener() {
-			
+
 			@Override
 			public void keyReleased(KeyEvent e) {
 				if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
 					affectAnnotationToSelection(editor.getEditionPanel(0).getWordSelection());
 				}
 			}
-			
+
 			@Override
 			public void keyPressed(KeyEvent e) {}
 		});
-		
+
 		addTypedValueLink = new Button(annotationArea, SWT.PUSH);
 		addTypedValueLink.setText("..."); //$NON-NLS-1$
 		addTypedValueLink.setToolTipText(Messages.selectAValueAmongTheList);
 		addTypedValueLink.setEnabled(true);
 		addTypedValueLink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
 		addTypedValueLink.addSelectionListener(new SelectionListener() {
-			
+
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				if (currentKnowledgeRepository == null) return;
 				if (!(currentKnowledgeRepository instanceof LocalKnowledgeRepository)) return;
-				
+
 				AnnotationType type = getSelectedAnnotationType();
 				if (type == null) return;
-				
+
 				LocalKnowledgeRepository kr = (LocalKnowledgeRepository) currentKnowledgeRepository;
-				
+
 				ListDialog dialog = new ListDialog(e.widget.getDisplay().getActiveShell());
 				String title = currentKnowledgeRepository.getString(editor.getCorpus().getLang(), "ConcordancesEditor_100"); //$NON-NLS-1$
 				if (title == null) title = Messages.availableValuesForP0;
 				dialog.setTitle(ConcordanceUIMessages.bind(title, type.getName()));// +"valeurs de "+type.getName());
 				dialog.setContentProvider(new ArrayContentProvider());
 				dialog.setLabelProvider(new SimpleLabelProvider() {
-					
+
 					@Override
 					public String getColumnText(Object element, int columnIndex) {
 						if (element instanceof TypedValue) {
@@ -655,77 +707,203 @@
 					TypedValue value = (TypedValue) dialog.getResult()[0];
 					String name = value.getId();
 					if (name.trim().length() == 0) return;
-					
+
 					annotationValuesText.setText(name);
 				}
 				else {
-					
+
 				}
 			}
-			
+
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {}
 		});
-		
+
 		new Label(annotationArea, SWT.NONE).setText(" ");
-		
+
 		affectAnnotationButton = new Button(annotationArea, SWT.PUSH);
 		affectAnnotationButton.setText(Messages.oK);
 		affectAnnotationButton.setToolTipText(Messages.proceedToAnnotation);
 		affectAnnotationButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
 		affectAnnotationButton.addSelectionListener(new SelectionListener() {
-			
+
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				affectAnnotationToSelection(editor.getEditionPanel(0).getWordSelection());
 			}
-			
+
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {}
 		});
-		
+
 		deleteAnnotationButton = new Button(annotationArea, SWT.PUSH);
 		deleteAnnotationButton.setText(Messages.delete);
 		deleteAnnotationButton.setToolTipText(Messages.delete);
 		deleteAnnotationButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
 		deleteAnnotationButton.addSelectionListener(new SelectionListener() {
-			
+
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				deleteAnnotationValues(editor.getEditionPanel(0).getWordSelection());
+				
 			}
-			
+
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {}
 		});
-		
+
 		Button closeButton = new Button(annotationArea, SWT.PUSH);
 		closeButton.setToolTipText(Messages.closeTheToolbarWithoutSaving);
 		closeButton.setImage(IImageKeys.getImage(IImageKeys.ACTION_DELETE));
-		
+
 		closeButton.addSelectionListener(new SelectionListener() {
-			
+
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				extension.closeArea(WordAnnotationToolbar.this, true);
 			}
-			
+
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {}
 		});
-		
+
+
+		colorsLabel = new Label(annotationArea, SWT.NONE);
+		colorsLabel.setText("Colors"); //$NON-NLS-1$
+		colorsLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+
+		colorsValuesText = new Text(annotationArea, SWT.BORDER);
+		colorsValuesText.setToolTipText(Messages.enterAValueForAnId);
+		gdata2 = new GridData(SWT.FILL, SWT.CENTER, false, false);
+		gdata2.widthHint = 200;
+		colorsValuesText.setLayoutData(gdata2);
+		colorsValuesText.addKeyListener(new KeyListener() {
+
+			@Override
+			public void keyReleased(KeyEvent e) {
+				if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
+					
+					updateHighlights(colorsValuesText.getText());
+					
+					editor.updateWordStyles();
+				}
+			}
+
+			@Override
+			public void keyPressed(KeyEvent e) {}
+		});
+
+
 		updateAnnotationWidgetStates();
 		editor.layout(true);
-//		ext.getSaveButton().setEnabled(true);
+		//		ext.getSaveButton().setEnabled(true);
 		return true;
 	}
 	
+	HashMap<RGBA, String> colorsRules;
+	public void updateHighlights(String rules) {
+		
+		if (rules != null) {
+			String[] couples = rules.split(",");
+			
+			colorsRules = new HashMap<RGBA, String>();
+			if (couples.length > 0) {
+				for (String couple : couples) {
+					String[] colorValue = couple.split("=", 2);
+
+					if (colorValue[0].startsWith("#")) {
+						colorsRules.put(new RGBA(colorValue[0]), colorValue[1]);
+					} else {
+						colorsRules.put(new RGBA(RGBA.nameToHex(colorValue[0])), colorValue[1]);
+					}
+				}
+			}
+		}
+		
+		if (colorsRules == null) return; // nothing to do
+		
+		clearHighlight();
+
+		AbstractCqiClient CQI = CQPSearchEngine.getCqiClient();
+		
+		try {
+			WordProperty property = corpus.getProperty(getSelectedAnnotationType().getId());
+			WordProperty idproperty = corpus.getProperty("id");
+			
+//			// Page word positions range (start, end)
+//			String idstart = editor.getEditionPanel(0).getCurrentPage().getWordId();
+//			String idend = editor.getEditionPanel(0).getCurrentPage().getLastWordID();
+//			
+//			int pStart = CQI.str2Id(idproperty.getQualifiedName(), new String[] {idstart})[0];
+//			int pEnd = corpus.getSize()-1;
+//			if (!idstart.equals(idend)) {
+//				pEnd = CQI.str2Id(idproperty.getQualifiedName(), new String[] {idend})[0];
+//			} else {
+//				String text = editor.getEditionPanel(0).getCurrentText().getName();
+//				org.txm.objects.Text nextText = editor.getEditionPanel(0).getNextText();
+//				String nextTextName = nextText.getName();
+//				if (!text.equals(nextTextName)) {
+//					idend = nextText.getEdition(editor.getEditionPanel(0).getEdition().getName()).getFirstPage().getWordId();
+//					pEnd = CQI.str2Id(idproperty.getQualifiedName(), new String[] {idend})[0];
+//				}
+//			}
+//			//System.out.println("start="+pStart+" end="+pEnd);
+//			
+//			List<Match> matches = new ArrayList<Match>();
+//			for (int p = pStart ; p <=pEnd ; p++) {
+//				matches.add(new Match2P(p));
+//			}
+			
+			List<Annotation> annotations = annotManager.getAnnotations(getSelectedAnnotationType(), false);
+						
+			//System.out.println("annotations="+annotations);
+			previousSelectedTypeUnitIDS = new HashMap<RGBA, HashSet<String>>();
+			for (RGBA color : colorsRules.keySet()) {
+				
+				Pattern regex = Pattern.compile(colorsRules.get(color));
+				// get words per value
+//				System.out.println("FIND WORDS FOR COLOR AND VALUE "+color+"="+colorsRules.get(color));
+//				int[] ids = CQI.regex2Id(property.getQualifiedName(), colorsRules.get(color));
+//				System.out.println("ids="+Arrays.toString(ids));
+//				int[] positions = CQI.idList2Cpos(property.getQualifiedName(), ids);
+//				System.out.println("positions="+Arrays.toString(positions));
+				
+				// get annotations for the current page range and select those who matches the
+				List<Integer> positionsList = new ArrayList<Integer>();
+				
+				for (Annotation annot : annotations) {
+					if (regex.matcher(annot.getValue()).matches()) {
+						positionsList.add(annot.getStart());
+					}
+				}
+				
+				int[] positions = new int[positionsList.size()];
+				for (int i = 0 ; i < positionsList.size() ; i++) {
+					positions[i] = positionsList.get(i);
+				}
+				String[] wordIds = CQI.cpos2Str(idproperty.getQualifiedName(), positions);
+				HashSet<String> h = new HashSet<String>();
+				for (String a : wordIds) {
+					h.add(a);
+				}
+				//System.out.println("h="+h);
+				
+				previousSelectedTypeUnitIDS.put(color, h);
+				editor.setHighlightWordsById(color, h);
+				//System.out.println("SET "+h);
+			}
+		} catch (Exception e1) {
+			// TODO Auto-generated catch block
+			e1.printStackTrace();
+		}
+	}
+
 	protected void onAnnotationTypeSelected(SelectionChangedEvent event) {
-		
+
 		IStructuredSelection sel = (IStructuredSelection) annotationTypesCombo.getSelection();
 		AnnotationType type = (AnnotationType) sel.getFirstElement();
 		if (type == null) return;
-		
+
 		if (type.getSize() != AnnotationType.ValuesSize.LARGE) {
 			try {
 				KnowledgeRepository kr = KnowledgeRepositoryManager.getKnowledgeRepository(type.getKnowledgeRepository());
@@ -736,7 +914,7 @@
 				e.printStackTrace();
 			}
 		}
-		
+
 		annotations.setViewAnnotation(type);
 		annotations.setAnnotationOverlap(true);
 		try {
@@ -746,15 +924,15 @@
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
-		
+
 		updateAnnotationWidgetStates();
 	}
-	
+
 	protected void createNewType(TypedEvent e, String typeName) {
-		
+
 		if (currentKnowledgeRepository == null) return;
 		if (!(currentKnowledgeRepository instanceof LocalKnowledgeRepository)) return;
-		
+
 		LocalKnowledgeRepository kr = (LocalKnowledgeRepository) currentKnowledgeRepository;
 		if (typeName == null) typeName = ""; //$NON-NLS-1$
 		InputDialog dialog = new InputDialog(e.widget.getDisplay().getActiveShell(), Messages.nouvelleProprit, Messages.nomDeLaPropritPatternEqualsazaz09Plus, typeName,
@@ -773,7 +951,7 @@
 			annotationTypesCombo.refresh();
 			StructuredSelection selection = new StructuredSelection(type);
 			annotationTypesCombo.setSelection(selection, true);
-			
+
 			// if (annotationTypesCombo != null) annotationTypesCombo.refresh();
 			// if (typesList.size() == 1) {
 			// if (annotationTypesCombo != null) annotationTypesCombo.getCombo().select(0);
@@ -795,14 +973,14 @@
 			// }
 			// KRView.refresh();
 			// updateAnnotationWidgetStates();
-			
+
 			// onAnnotationTypeSelected(null);
 		}
 		else {
 			Log.info("Creation aborted.");
 		}
 	}
-	
+
 	@Override
 	public boolean save() {
 		try {
@@ -828,7 +1006,7 @@
 			return false;
 		}
 	}
-	
+
 	@Override
 	public boolean hasChanges() {
 		AnnotationManager am;
@@ -847,70 +1025,70 @@
 			return false;
 		}
 	}
-	
+
 	@Override
 	public boolean notifyStartOfCompute() throws Exception {
 		if (annotationArea == null) return false;
 		if (annotationArea.isDisposed()) return false;
-		
+
 		AnnotationType type = getSelectedAnnotationType();
 		if (type != null) {
 			annotations.setViewAnnotation(type);
 			annotations.setAnnotationOverlap(true);
 		}
-		
+
 		return true;
 	}
-	
+
 	@Override
 	public boolean notifyEndOfCompute() throws Exception {
 		return true;
 	}
-	
+
 	@Override
 	public boolean isAnnotationEnable() {
 		return annotationArea != null;
 	}
-	
+
 	@Override
 	public void notifyStartOfRefresh() throws Exception {
 		if (annotationArea == null) return;
 		if (annotationArea.isDisposed()) return;
-		
+
 		Page currentPage = editor.getEditionPanel(0).getCurrentPage();
 		if (currentPage == null) return;
-		
+
 		String startID = currentPage.getWordId();
 		Page nextPage = currentPage.getEdition().getNextPage(currentPage);
 		String endID = nextPage.getWordId();
-		
+
 		annotations.computeStrings(startID, endID);
-		
+
 		updateAnnotationWidgetStates();
-		
+
 	}
-	
+
 	@Override
 	protected void _close() {
 		if (!annotationArea.isDisposed()) annotationArea.dispose();
 		extension.layout();
 	}
-	
+
 	@Override
 	public void notifyEndOfRefresh() throws Exception {
 		// TODO Auto-generated method stub
 	}
-	
+
 	@Override
 	public void notifyStartOfCreatePartControl() throws Exception {
 		// TODO Auto-generated method stub
 	}
-	
+
 	@Override
 	public Class<? extends TXMResult> getAnnotatedTXMResultClass() {
 		return org.txm.objects.Text.class;
 	}
-	
+
 	@Override
 	public boolean isDirty() {
 		if (annotManager != null) {
@@ -918,17 +1096,17 @@
 		}
 		return false;
 	}
-	
+
 	@Override
 	public boolean discardChanges() {
 		return false;
 	}
-	
+
 	@Override
 	public boolean needToUpdateIndexes() {
 		return KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE);
 	}
-	
+
 	@Override
 	public boolean needToUpdateEditions() {
 		return KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_EDITION);
Index: TXM/trunk/bundles/org.txm.annotation.kr.rcp/plugin.xml
===================================================================
--- TXM/trunk/bundles/org.txm.annotation.kr.rcp/plugin.xml	(revision 4026)
+++ TXM/trunk/bundles/org.txm.annotation.kr.rcp/plugin.xml	(revision 4027)
@@ -395,5 +395,9 @@
            class="org.txm.annotation.kr.rcp.concordance.SimpleKRAnnotation"
            position="2">
      </annotationtoolbar>
+     <annotationtoolbar
+           class="org.txm.annotation.kr.rcp.edition.WordAnnotationToolbar"
+           position="3">
+     </annotationtoolbar>
   </extension>
 </plugin>
Index: TXM/trunk/bundles/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/UnitToolbar.java
===================================================================
--- TXM/trunk/bundles/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/UnitToolbar.java	(revision 4026)
+++ TXM/trunk/bundles/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/UnitToolbar.java	(revision 4027)
@@ -292,7 +292,7 @@
 	@Override
 	public void clearHighlight() {
 		if (previousSelectedUnitIDS != null) {
-			if (editor.isDisposed()) {
+			if (!editor.isDisposed()) {
 				editor.removeHighlightWordsById(selected_unit_color, previousSelectedUnitIDS);
 				editor.removeFontWeightWordsById(previousSelectedUnitIDS);
 			}
Index: TXM/trunk/bundles/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionPanel.java
===================================================================
--- TXM/trunk/bundles/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionPanel.java	(revision 4026)
+++ TXM/trunk/bundles/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionPanel.java	(revision 4027)
@@ -1,6 +1,7 @@
 package org.txm.edition.rcp.editors;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -50,6 +51,8 @@
 import org.txm.rcp.editors.TXMBrowserEditor;
 import org.txm.rcp.editors.menu.PagePropertiesMenu;
 import org.txm.rcp.utils.IOClipboard;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.serverException.CqiServerError;
 import org.txm.utils.io.IOUtils;
 import org.txm.utils.logger.Log;
 
@@ -1154,30 +1157,43 @@
 	/**
 	 * Next text.
 	 */
-	public void nextText() {
+	public Text getNextText() {
 		
 		// Text current = this.currentPage.getEdition().getText();
 		Project project = currentText.getProject();
 		String id;
-		try {
-			String[] ids = this.synopticEditionEditor.getCorpus().getCorpusTextIdsList();
-			String currentId = currentText.getName();
-			int idx = 0;
-			for (int i = 0; i < ids.length; i++) {
-				if (currentId.equals(ids[i])) {
-					idx = i;
-					break;
+		
+			String[] ids;
+			try {
+				ids = this.synopticEditionEditor.getCorpus().getCorpusTextIdsList();
+				
+				String currentId = currentText.getName();
+				int idx = 0;
+				for (int i = 0; i < ids.length; i++) {
+					if (currentId.equals(ids[i])) {
+						idx = i;
+						break;
+					}
 				}
+				if (idx < ids.length - 1) idx++;
+				id = ids[idx];
+			} catch (Exception e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+				return currentText;
 			}
-			if (idx < ids.length - 1) idx++;
-			id = ids[idx];
-		}
-		catch (Exception e) {
-			e.printStackTrace();
-			return;
-		}
-		Text nextText = project.getText(id);
+			
 		
+		return project.getText(id);
+	}
+	
+	/**
+	 * Next text.
+	 */
+	public void nextText() {
+		
+		Text nextText = getNextText();
+		
 		if (nextText != null) {
 			String editionName = currentEdition.getName();
 			Edition tmp = nextText.getEdition(editionName);
Index: TXM/trunk/bundles/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/RGBA.java
===================================================================
--- TXM/trunk/bundles/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/RGBA.java	(revision 4026)
+++ TXM/trunk/bundles/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/RGBA.java	(revision 4027)
@@ -1,6 +1,7 @@
 package org.txm.edition.rcp.editors;
 
 import java.awt.Color;
+import java.util.HashMap;
 
 public class RGBA {
 	public int r=0, g=0, b=0;
@@ -17,7 +18,7 @@
 	public RGBA(String rgbOrrgba) {
 		if (rgbOrrgba.startsWith("#")) { //$NON-NLS-1$
 			
-			Color c = HexToColor(rgbOrrgba);
+			Color c = hexToColor(rgbOrrgba);
 			
 			this.r = c.getRed();
 			this.g = c.getGreen();
@@ -40,14 +41,51 @@
 		this.a = a;
 	}
 	
+	static HashMap<String, String> nameToHex;
+	static {
+		nameToHex = new HashMap<String, String>();
+		String[] ss = {"AliceBlue","#F0F8FF","AntiqueWhite","#FAEBD7","Aqua","#00FFFF","Aquamarine","#7FFFD4","Azure","#F0FFFF","Beige","#F5F5DC","Bisque","#FFE4C4","Black","#000000","BlanchedAlmond","#FFEBCD","Blue","#0000FF","BlueViolet","#8A2BE2","Brown","#A52A2A","BurlyWood","#DEB887","CadetBlue","#5F9EA0","Chartreuse","#7FFF00","Chocolate","#D2691E","Coral","#FF7F50","CornflowerBlue","#6495ED","Cornsilk","#FFF8DC","Crimson","#DC143C","Cyan","#00FFFF","DarkBlue","#00008B","DarkCyan","#008B8B","DarkGoldenRod","#B8860B","DarkGray","#A9A9A9","DarkGrey","#A9A9A9","DarkGreen","#006400","DarkKhaki","#BDB76B","DarkMagenta","#8B008B","DarkOliveGreen","#556B2F","DarkOrange","#FF8C00","DarkOrchid","#9932CC","DarkRed","#8B0000","DarkSalmon","#E9967A","DarkSeaGreen","#8FBC8F","DarkSlateBlue","#483D8B","DarkSlateGray","#2F4F4F","DarkSlateGrey","#2F4F4F","DarkTurquoise","#00CED1","DarkViolet","#9400D3","DeepPink","#FF1493","DeepSkyBlue","#00BFFF","DimGray","#696969","DimGrey","#696969","DodgerBlue","#1E90FF","FireBrick","#B22222","FloralWhite","#FFFAF0","ForestGreen","#228B22","Fuchsia","#FF00FF","Gainsboro","#DCDCDC","GhostWhite","#F8F8FF","Gold","#FFD700","GoldenRod","#DAA520","Gray","#808080","Grey","#808080","Green","#008000","GreenYellow","#ADFF2F","HoneyDew","#F0FFF0","HotPink","#FF69B4","IndianRed","#CD5C5C","Indigo","#4B0082","Ivory","#FFFFF0","Khaki","#F0E68C","Lavender","#E6E6FA","LavenderBlush","#FFF0F5","LawnGreen","#7CFC00","LemonChiffon","#FFFACD","LightBlue","#ADD8E6","LightCoral","#F08080","LightCyan","#E0FFFF","LightGoldenRodYellow","#FAFAD2","LightGray","#D3D3D3","LightGrey","#D3D3D3","LightGreen","#90EE90","LightPink","#FFB6C1","LightSalmon","#FFA07A","LightSeaGreen","#20B2AA","LightSkyBlue","#87CEFA","LightSlateGray","#778899","LightSlateGrey","#778899","LightSteelBlue","#B0C4DE","LightYellow","#FFFFE0","Lime","#00FF00","LimeGreen","#32CD32","Linen","#FAF0E6","Magenta","#FF00FF","Maroon","#800000","MediumAquaMarine","#66CDAA","MediumBlue","#0000CD","MediumOrchid","#BA55D3","MediumPurple","#9370DB","MediumSeaGreen","#3CB371","MediumSlateBlue","#7B68EE","MediumSpringGreen","#00FA9A","MediumTurquoise","#48D1CC","MediumVioletRed","#C71585","MidnightBlue","#191970","MintCream","#F5FFFA","MistyRose","#FFE4E1","Moccasin","#FFE4B5","NavajoWhite","#FFDEAD","Navy","#000080","OldLace","#FDF5E6","Olive","#808000","OliveDrab","#6B8E23","Orange","#FFA500","OrangeRed","#FF4500","Orchid","#DA70D6","PaleGoldenRod","#EEE8AA","PaleGreen","#98FB98","PaleTurquoise","#AFEEEE","PaleVioletRed","#DB7093","PapayaWhip","#FFEFD5","PeachPuff","#FFDAB9","Peru","#CD853F","Pink","#FFC0CB","Plum","#DDA0DD","PowderBlue","#B0E0E6","Purple","#800080","RebeccaPurple","#663399","Red","#FF0000","RosyBrown","#BC8F8F","RoyalBlue","#4169E1","SaddleBrown","#8B4513","Salmon","#FA8072","SandyBrown","#F4A460","SeaGreen","#2E8B57","SeaShell","#FFF5EE","Sienna","#A0522D","Silver","#C0C0C0","SkyBlue","#87CEEB","SlateBlue","#6A5ACD","SlateGray","#708090","SlateGrey","#708090","Snow","#FFFAFA","SpringGreen","#00FF7F","SteelBlue","#4682B4","Tan","#D2B48C","Teal","#008080","Thistle","#D8BFD8","Tomato","#FF6347","Turquoise","#40E0D0","Violet","#EE82EE","Wheat","#F5DEB3","White","#FFFFFF","WhiteSmoke","#F5F5F5","Yellow","#FFFF00","Color Mixer","Color Picker","YellowGreen","#9ACD32"};
+		for (int i = 0 ; i < ss.length ; i = i+2) {
+			nameToHex.put(ss[i].toLowerCase(), ss[i+1]);
+		}
+	}
+	
 	/**
+	 * Convert a CSS color name to its HEX code
+	 * @return Hex color code
+	 */
+	public static String nameToHex(String name) {
+		
+		String hex = nameToHex.get(name.toLowerCase());
+		if (hex != null) {
+			return hex+"FF";
+		}
+		return "#FF FF FF FF";
+	}
+	
+	/**
+	 * Convert a CSS color name to a java.awt.Color
+	 * 
+	 * @return Color
+	 */
+	public static Color nameToColor(String name) {
+		
+		String hex = nameToHex.get(name);
+		if (hex != null) {
+			return hexToColor(nameToHex.get(name)+"FF");
+		}
+		return new Color(255,255,255);
+	}
+	
+	/**
 	 * Converts a hex string to a color. If it can't be converted null is returned.
 	 * @param hex (i.e. #CCCCCCFF or CCCCCC)
 	 * @return Color
 	 */
-	public static Color HexToColor(String hex) 
-	{
+	public static Color hexToColor(String hex) {
+		
 	    hex = hex.replace("#", ""); //$NON-NLS-1$ //$NON-NLS-2$
+	    hex = hex.replace(" ", ""); //$NON-NLS-1$ //$NON-NLS-2$
 	    switch (hex.length()) {
 	        case 6:
 	            return new Color(
