Index: tmp/org.txm.annotation.core/META-INF/persistence.xml
===================================================================
--- tmp/org.txm.annotation.core/META-INF/persistence.xml	(revision 781)
+++ tmp/org.txm.annotation.core/META-INF/persistence.xml	(revision 782)
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<
 <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">	
-		<persistence-unit name="MyPUWithHSQL" transaction-type="RESOURCE_LOCAL">
+		<persistence-unit name="HSQLKRPERSISTENCE" transaction-type="RESOURCE_LOCAL">
 		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
 		
 		<class>org.txm.annotation.core.Annotation</class>
@@ -17,10 +16,10 @@
 			<property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:file:txmdb/db;shutdown=true;hsqldb.write_delay=false;hsqldb.lock_file=false;hsqldb.applog=0;hsqldb.sqllog=0"/>
 			<property name="javax.persistence.jdbc.user" value="SA"/>
 			
-			<property name="eclipselink.logging.parameters" value="false"/>
+<!-- 			<property name="eclipselink.logging.parameters" value="false"/>
  			<property name="eclipselink.logging.level" value="ON" />
  			
-<!-- 		
+		
 			<property name="eclipselink.jdbc.read-connections.min" value="1" />
 			<property name="eclipselink.jdbc.write-connections.min" value="1" />
 			<property name="eclipselink.jdbc.batch-writing" value="JDBC" />
Index: tmp/org.txm.annotation.core/src/org/txm/annotation/core/storage/temporary/TemporaryAnnotationManager.java
===================================================================
--- tmp/org.txm.annotation.core/src/org/txm/annotation/core/storage/temporary/TemporaryAnnotationManager.java	(revision 781)
+++ tmp/org.txm.annotation.core/src/org/txm/annotation/core/storage/temporary/TemporaryAnnotationManager.java	(revision 782)
@@ -21,18 +21,25 @@
 import org.txm.annotation.core.repository.AnnotationEffect;
 import org.txm.annotation.core.repository.AnnotationType;
 import org.txm.annotation.core.repository.TypedValue;
+import org.txm.annotation.core.temporary.CreateAnnotation;
 import org.txm.searchengine.cqp.corpus.MainCorpus;
 import org.txm.searchengine.cqp.corpus.query.Match;
 import org.txm.utils.logger.Log;
 
 public class TemporaryAnnotationManager {
 
-	public static HashMap<String, Object> getInitialisationProperties(MainCorpus corpus) {
+	/**
+	 * 
+	 * @param clazz persistence.xml location depends on the classloader
+	 * @param corpus
+	 * @return
+	 */
+	public static HashMap<String, Object> getInitialisationProperties(Class clazz, MainCorpus corpus) {
 		String path = corpus.getBaseDirectory().getAbsolutePath()+"/temporary_annotations/db";
 		
 		HashMap<String, Object> properties = new HashMap<String, Object>();
 		//System.out.println("CLASSLOADER: "+Toolbox.class.getClassLoader());
-		properties.put(PersistenceUnitProperties.CLASSLOADER, Toolbox.class.getClassLoader());
+		properties.put(PersistenceUnitProperties.CLASSLOADER, clazz.getClassLoader());
 		properties.put("javax.persistence.jdbc.driver", "org.hsqldb.jdbcDriver");
 		
 		String urlProperty = "jdbc:hsqldb:file:"+path+";shutdown=true;hsqldb.write_delay=false;hsqldb.lock_file=false;";
@@ -422,7 +429,7 @@
 	}
 	
 	public EntityManager initTemporaryAnnotationDatabase(){	
-		HashMap<String, Object> properties = TemporaryAnnotationManager.getInitialisationProperties(corpus);
+		HashMap<String, Object> properties = TemporaryAnnotationManager.getInitialisationProperties(this.getClass(), corpus);
 
 		return initTemporaryAnnotationDatabase(properties);
 	}
@@ -439,7 +446,7 @@
 //		infos.getManagedClassNames().add("org.txm.annotation.Annotation");
 //		infos.getManagedClassNames().add("org.txm.annotation.TypedValue");
 //		pp.generateSchema(infos, properties);
-		
+
 		EntityManagerFactory emf = pp.createEntityManagerFactory(DatabasePersistenceManager.PERSISTENCE_UNIT_NAME, properties);
 		
 		em = (EntityManager) emf.createEntityManager();
Index: tmp/org.txm.annotation.core/src/org/txm/annotation/core/KRAnnotationEngine.java
===================================================================
--- tmp/org.txm.annotation.core/src/org/txm/annotation/core/KRAnnotationEngine.java	(revision 781)
+++ tmp/org.txm.annotation.core/src/org/txm/annotation/core/KRAnnotationEngine.java	(revision 782)
@@ -31,15 +31,23 @@
 		return getKnowledgeRepositoryNames(corpus).size() > 0;
 	}
 
-	public static AnnotationManager getAnnotationManager(Corpus corpus){
-		return ams.get(corpus.getMainCorpus());
+	public static AnnotationManager getAnnotationManager(Corpus corpus) throws Exception{
+		return getAnnotationManager(corpus.getMainCorpus());
 	}
 
-	public static AnnotationManager getAnnotationManager(MainCorpus corpus) {
+	/**
+	 * get the corpus Annotation Manager and Lazy load if created
+	 * 
+	 * @param corpus
+	 * @return
+	 * @throws Exception
+	 */
+	public static AnnotationManager getAnnotationManager(MainCorpus corpus) throws Exception {
 		AnnotationManager am = ams.get(corpus);
 		if (am == null) {
 			if (getKnowledgeRepositoryNames(corpus).size() > 0) {
 				am = new AnnotationManager(corpus);
+				am.initialize();
 				ams.put(corpus, am);
 			}
 				
Index: tmp/org.txm.annotation.core/src/org/txm/annotation/core/repository/KnowledgeRepository.java
===================================================================
--- tmp/org.txm.annotation.core/src/org/txm/annotation/core/repository/KnowledgeRepository.java	(revision 781)
+++ tmp/org.txm.annotation.core/src/org/txm/annotation/core/repository/KnowledgeRepository.java	(revision 782)
@@ -1,5 +1,6 @@
 package org.txm.annotation.core.repository;
 
+import java.net.URL;
 import java.util.HashMap;
 import java.util.List;
 import java.util.logging.Level;
@@ -9,12 +10,17 @@
 import javax.persistence.EntityManagerFactory;
 import javax.persistence.Query;
 import javax.persistence.TypedQuery;
+import javax.persistence.spi.PersistenceUnitInfo;
 
 import org.eclipse.persistence.config.PersistenceUnitProperties;
+import org.eclipse.persistence.internal.jpa.deployment.JPAInitializer;
+import org.eclipse.persistence.internal.jpa.deployment.SEPersistenceUnitInfo;
 import org.eclipse.persistence.jpa.PersistenceProvider;
+import org.osgi.framework.Bundle;
 import org.txm.Toolbox;
 import org.txm.annotation.core.DatabasePersistenceManager;
 import org.txm.core.preferences.TBXPreferences;
+import org.txm.utils.BundleUtils;
 import org.txm.utils.logger.Log;
 
 public abstract class KnowledgeRepository  { //extends Vector<AnnotationType>
@@ -68,8 +74,11 @@
 		//System.out.println("KnowledgeRepository.initializeEntityManager [DB @ "+dbPath+"]");
 		EntityManagerFactory emf;
 		HashMap<String, Object> properties = new HashMap<String, Object>();
-//		//properties.put(PersistenceUnitProperties.CLASSLOADER, Toolbox.class.getClassLoader());
-		properties.put(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, "/home/mdecorde/workspace079/org.txm.annotation.core/META-INF/persistence.xml");
+		properties.put(PersistenceUnitProperties.CLASSLOADER, this.getClass().getClassLoader());
+//		ClassLoader loader = BundleUtils.getLoader("org.txm.annotation.core");
+//		URL res = loader.getResource("META-INF/persistence.xml");
+//		
+		//properties.put(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, "/home/mdecorde/workspace079/org.txm.annotation.core/META-INF");
 //		//properties.put("javax.persistence.jdbc.driver", "org.hsqldb.jdbcDriver");
 //		String urlProperty = "jdbc:hsqldb:file:"+dbPath+"/db;shutdown=true;hsqldb.lock_file=false;";
 //		if (Log.getLevel().intValue() < Level.WARNING.intValue()) {
@@ -81,7 +90,7 @@
 //		properties.put("javax.persistence.jdbc.username", "SA");
 //		properties.put(PersistenceUnitProperties.DDL_GENERATION_MODE, "database");
 //		properties.put(PersistenceUnitProperties.DDL_GENERATION, "create-or-extend-tables"); // create&update table if needed
-//		//properties.put(PersistenceUnitProperties.DDL_GENERATION, "drop-and-create-tables"); // create&update table if needed
+		properties.put(PersistenceUnitProperties.DDL_GENERATION, "drop-and-create-tables"); // drop all and recreate
 //		if (Log.getLevel().intValue() < Level.WARNING.intValue()) {
 //			properties.put(PersistenceUnitProperties.LOGGING_LEVEL, "WARNING");
 //			properties.put(PersistenceUnitProperties.LOGGING_PARAMETERS, "true");
@@ -90,12 +99,12 @@
 //			properties.put(PersistenceUnitProperties.LOGGING_PARAMETERS, "false");
 //		}
 
-		//System.out.println("PROPERTIES: "+properties);
-		// <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
-		Logger.getLogger("org").setLevel(Level.ALL);
-		emf = new PersistenceProvider().createEntityManagerFactory(DatabasePersistenceManager.PERSISTENCE_UNIT_NAME, properties);
+//		Logger.getLogger("org").setLevel(Level.ALL);
+		PersistenceProvider pp = new PersistenceProvider();
+
+		emf = pp.createEntityManagerFactory(DatabasePersistenceManager.PERSISTENCE_UNIT_NAME, properties);
 		if (emf == null) {
-			System.out.println("Error: could not create the PersistenceProvider with name: "+DatabasePersistenceManager.PERSISTENCE_UNIT_NAME);
+			System.out.println("Error: could not create the EntityManagerFactory with name: "+DatabasePersistenceManager.PERSISTENCE_UNIT_NAME+" and PersistenceProvider="+pp);
 			return null;
 		}
 		EntityManager entityManager = (EntityManager) emf.createEntityManager();
Index: tmp/org.txm.annotation.core/src/org/txm/annotation/core/temporary/CreateAnnotation.java
===================================================================
--- tmp/org.txm.annotation.core/src/org/txm/annotation/core/temporary/CreateAnnotation.java	(revision 781)
+++ tmp/org.txm.annotation.core/src/org/txm/annotation/core/temporary/CreateAnnotation.java	(revision 782)
@@ -20,7 +20,7 @@
 		MainCorpus corpus = CorpusManager.getCorpusManager().getCorpus("VOEUX");
 		if (corpus == null) fail("Corpus Voeux not loaded.");
 		
-		HashMap<String, Object> properties = TemporaryAnnotationManager.getInitialisationProperties(corpus);
+		HashMap<String, Object> properties = TemporaryAnnotationManager.getInitialisationProperties(this.getClass(), corpus);
 		properties.put("eclipselink.persistencexml", System.getProperty("user.home")+"/workspace442/org.txm.toolbox/META-INF/persistence.xml");
 		
 		TemporaryAnnotationManager tam = new TemporaryAnnotationManager(corpus, properties);
Index: tmp/org.txm.annotation.core/src/org/txm/annotation/core/DatabasePersistenceManager.java
===================================================================
--- tmp/org.txm.annotation.core/src/org/txm/annotation/core/DatabasePersistenceManager.java	(revision 781)
+++ tmp/org.txm.annotation.core/src/org/txm/annotation/core/DatabasePersistenceManager.java	(revision 782)
@@ -8,7 +8,7 @@
 
 	//Object can be Corpus or KnowledgeRepository
 	protected HashMap<Object, EntityManager> managers;
-	public static final String PERSISTENCE_UNIT_NAME = "MyPUWithHSQL";
+	public static final String PERSISTENCE_UNIT_NAME = "HSQLKRPERSISTENCE";
 	public static String ACCESS_SQL = "sql";
 	public static String ACCESS_FILE = "file";
 	public static String ACCESS_SPARQL = "sparql";
Index: tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java
===================================================================
--- tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java	(revision 781)
+++ tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java	(revision 782)
@@ -443,6 +443,10 @@
 	 */
 	public List<Line> getLines(int from, int to) throws CqiClientException, IOException, CqiServerError {
 
+		if (nLines == 0) {
+			return new ArrayList<Line>();
+		}
+		
 		Log.info(ConcordanceMessages.Concordance_6 + (to - from + 1) + ConcordanceMessages.Concordance_7);
 
 		AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient();
@@ -451,11 +455,9 @@
 
 		// check asked lines numbers
 		if (from < 0) from = 0;
+		if (to < 0) to = 0;
 		if (from > to) from = to;
 		if (to >= nLines) to = nLines - 1;
-		if (from < 0 || from > to || to >= nLines) {
-			throw new IndexOutOfBoundsException();
-		}
 
 		List<Match> matches = queryResult.getMatches(from, to);
 
@@ -927,8 +929,26 @@
 
 		return getLines(topLine, bottomLine);
 	}
+	
+	/**
+	 * reload a part of the concordance lines
+	 * 
+	 * @param topLine
+	 * @param bottomLine
+	 * @return
+	 * @throws CqiClientException
+	 * @throws IOException
+	 * @throws CqiServerError
+	 */
+	public List<Line> reloadCurrentLines() throws CqiClientException, IOException, CqiServerError {
+		for (int i = this.pTopIndex; i < this.pTopIndex+this.pNLinesPerPage && i < lines.size(); i++) {
+			lines.set(i, null);
+		}
 
+		return getLines(this.pTopIndex, this.pTopIndex+this.pNLinesPerPage);
+	}
 
+
 	/**
 	 * Update the QueryResult removing the match of the given line.
 	 * 
Index: tmp/org.txm.annotation.rcp/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.annotation.rcp/META-INF/MANIFEST.MF	(revision 781)
+++ tmp/org.txm.annotation.rcp/META-INF/MANIFEST.MF	(revision 782)
@@ -16,6 +16,7 @@
  org.txm.annotation.rcp.commands.krview,
  org.txm.annotation.rcp.concordance,
  org.txm.annotation.rcp.editors.imports.sections,
+ org.txm.annotation.rcp.messages,
  org.txm.annotation.rcp.preferences,
  org.txm.annotation.rcp.views.knowledgerepositories,
  org.txm.rcp.tests
Index: tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/ConcordanceAnnotationExtension.java
===================================================================
--- tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/ConcordanceAnnotationExtension.java	(revision 781)
+++ tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/ConcordanceAnnotationExtension.java	(revision 782)
@@ -1,947 +0,0 @@
-package org.txm.annotation.rcp.concordance;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Vector;
-import java.util.logging.Level;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.dialogs.ListDialog;
-import org.txm.annotation.core.Annotation;
-import org.txm.annotation.core.AnnotationManager;
-import org.txm.annotation.core.KRAnnotationEngine;
-import org.txm.annotation.core.preferences.AnnotationPreferences;
-import org.txm.annotation.core.repository.AnnotationType;
-import org.txm.annotation.core.repository.KnowledgeRepository;
-import org.txm.annotation.core.repository.KnowledgeRepositoryManager;
-import org.txm.annotation.core.repository.LocalKnowledgeRepository;
-import org.txm.annotation.core.repository.SQLKnowledgeRepository;
-import org.txm.annotation.core.repository.TypedValue;
-import org.txm.annotation.rcp.commands.InitializeKnowledgeRepository;
-import org.txm.annotation.rcp.commands.SaveAnnotations;
-import org.txm.annotation.rcp.commands.krview.OpenKRView;
-import org.txm.annotation.rcp.messages.AnnotationUIMessages;
-import org.txm.annotation.rcp.views.knowledgerepositories.KRView;
-import org.txm.concordance.core.functions.Concordance;
-import org.txm.concordance.core.functions.Line;
-import org.txm.concordance.rcp.editors.ConcordanceEditor;
-import org.txm.concordance.rcp.editors.ConcordanceEditor.ConcordanceColumnSizeControlListener;
-import org.txm.concordance.rcp.editors.ConcordanceEditorExtension;
-import org.txm.concordance.rcp.messages.ConcordanceUIMessages;
-import org.txm.core.preferences.TXMPreferences;
-import org.txm.rcp.IImageKeys;
-import org.txm.rcp.commands.OpenBrowser;
-import org.txm.rcp.messages.TXMUIMessages;
-import org.txm.rcp.preferences.RCPPreferences;
-import org.txm.rcp.swt.dialog.ConfirmDialog;
-import org.txm.rcp.swt.provider.SimpleLabelProvider;
-import org.txm.rcp.utils.JobHandler;
-import org.txm.rcp.views.corpora.CorporaView;
-import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
-import org.txm.searchengine.cqp.corpus.Corpus;
-import org.txm.searchengine.cqp.corpus.query.Match;
-import org.txm.utils.AsciiUtils;
-import org.txm.utils.logger.Log;
-
-public class ConcordanceAnnotationExtension extends ConcordanceEditorExtension {
-
-	/**
-	 * the limit number of annotation when a confirm dialog box is shown
-	 */
-	protected static final int NALERTAFFECTANNOTATIONS = 100;
-
-	/** The annotation service */
-	protected AnnotationManager  annotManager;
-	
-	//boolean annotation_expert_mode = TxmPreferences.getBoolean(AnnotationPreferencePage.MODE, false);
-
-	/** The annotation area. */
-	protected Composite annotationArea;
-	
-	protected Point annotationSize;
-
-	/** The annot btn. */
-	protected Button annotationButton;
-	private Button addAnnotationTypeLink;
-
-	protected Text annotationValuesText;
-	protected ComboViewer annotationTypesCombo;
-	
-	protected List<TypedValue> typeValuesList;
-
-	protected Point annotSize;
-
-	protected TableColumn annotationColumn;
-
-	protected Combo addRemoveCombo;
-	protected Combo affectCombo;
-	protected Button affectAnnotationButton;
-
-	protected Button infosAnnotTypeSelectedLink;
-	
-	protected HashMap<AnnotationType, ArrayList<TypedValue>> history = new HashMap<AnnotationType, ArrayList<TypedValue>>();
-
-	protected KnowledgeRepository currentKnowledgeRepository = null;
-	protected Vector<AnnotationType> typesList = new Vector<AnnotationType>(); 
-
-	protected Button addTypedValueLink;
-
-	protected Label withLabel;
-
-	protected AnnotationType tagAnnotationType; // the tag annotation type if annotation mode is simple
-
-	protected Label equalLabel;
-	protected Boolean advanced_annotation_mode = false;
-	
-	protected TypedValue value_to_add;
-
-	protected Concordance concordance;
-
-	private Corpus corpus;
-
-	private ConcordanceAnnotations annotations;
-	
-	public ConcordanceAnnotationExtension() {
-		
-	}
-
-	@Override
-	public String getName() {
-		return "Annotation";
-	}
-
-	@Override
-	public boolean installWidgets() throws Exception {
-		
-		final Composite controlArea = editor.getNavigationArea();
-		final Composite navigationArea = editor.getNavigationArea();
-		TableViewer viewer = editor.getLineTableViewer();
-		
-		// CONTROLS
-		if (KRAnnotationEngine.getKnowledgeRepositoryNames(corpus).size() > 0) { // shown only if corpus has a registered KR
-
-			annotationButton = new Button(navigationArea, SWT.PUSH);
-			annotationButton.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_75);
-			annotationButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL));
-			annotationButton.addSelectionListener(new SelectionListener() {
-				@Override
-				public void widgetSelected(SelectionEvent e) {
-					if (annotationArea != null) {
-						AnnotationManager am = KRAnnotationEngine.getAnnotationManager(corpus);
-						if (am != null && am.hasChanges()) {
-							// && MessageDialog.openConfirm(e.display.getActiveShell(), "Confirm annotation save", "Saving annotation will close this editor. Are you sure you want to save annotations right now ?")
-							JobHandler saveJob = SaveAnnotations.save(corpus.getMainCorpus());
-							if (saveJob.getResult() == Status.CANCEL_STATUS) {
-								// update editor corpus
-								System.out.println("Fail to save annotations of the corpus."); //$NON-NLS-1$
-							}
-						}
-
-					} else {
-						if (annotationArea == null) composeAnnotationArea(controlArea);
-						if (annotationArea == null) return;
-
-						annotationColumn.pack();
-						annotationButton.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_76);
-						annotationButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL_SAVE));
-
-						annotSize = annotationArea.getSize();
-						Point size = controlArea.getSize();
-						controlArea.setSize(size.x, size.y + annotSize.y);
-						GridData data = (GridData) annotationArea.getLayoutData();
-						data.heightHint = annotSize.y;
-						data.minimumHeight = annotSize.y;
-						annotationArea.setSize(annotSize);
-						controlArea.layout(true);
-						controlArea.getParent().layout();
-
-						if (concordance != null) {
-							AnnotationType type = getSelectedAnnotationType();
-							if (type != null) {
-								annotations.setViewAnnotation(type);
-								annotations.setAnnotationOverlap(true);
-								editor.fillDisplayArea();
-							}
-						}
-
-						CorporaView.refreshObject(corpus);
-					}
-				}
-
-				@Override
-				public void widgetDefaultSelected(SelectionEvent e) {	}
-			});
-		}
-		
-		// RESULT
-		
-		int position = 3;
-		TableViewerColumn annotationColumnViewer = new TableViewerColumn(viewer, SWT.CENTER, position);
-		annotationColumn = annotationColumnViewer.getColumn();
-		annotationColumn.setText(ConcordanceUIMessages.ConcordancesEditor_15);
-		annotationColumn.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_17);
-		annotationColumn.setAlignment(SWT.CENTER);
-		
-		annotationColumn.addControlListener(new ConcordanceColumnSizeControlListener(annotationColumn));
-		annotationColumnViewer.setLabelProvider(new ColumnLabelProvider() {
-			@Override
-			public String getText(Object element) {
-				Line line = (Line)element;
-				AnnotationLine annotationLine = annotations.getAnnotationLine(line);
-				if (annotationLine.getAnnotation()!=null) {
-					String value = annotationLine.getAnnotationValue().getStandardName();
-					Annotation a = annotationLine.getAnnotation();
-					if (value == null) value = a.getValue();
-									
-					if (a.getStart() < line.matchGetStart() - line.getLeftContextSize()) {
-						value = "… "+value;
-					}
-					
-					if (a.getEnd() > line.matchGetEnd() + line.getRightContextSize()) {
-						value = value+" …";
-					} 
-					return value;
-				} else {
-					return "";
-				}
-			}
-		});
-		
-		
-		return true;
-	}
-	
-	public boolean initialiseInput(ConcordanceEditor editor) throws Exception {
-		this.editor = editor;
-		concordance = editor.getConcordance();
-		annotations = new ConcordanceAnnotations(concordance);
-		corpus = concordance.getCorpus();
-		
-		Corpus corpus = editor.getCorpus();
-		
-		this.annotManager = KRAnnotationEngine.getAnnotationManager(corpus);
-		
-		return true;
-		
-	}
-	
-	private void composeAnnotationArea(final Composite parent){ 
-		advanced_annotation_mode = "advanced".equals(TXMPreferences.getString(AnnotationPreferences.ANNOTATION_MODE, RCPPreferences.PREFERENCES_NODE));
-
-		List<KnowledgeRepository> krs = InitializeKnowledgeRepository.get(corpus.getMainCorpus());
-		typesList.clear();
-		Log.warning("Corpus KRs: "+krs); //$NON-NLS-1$
-
-		for (KnowledgeRepository kr : krs) {
-			if (kr == null) continue;
-
-			currentKnowledgeRepository = kr;
-			Log.warning(" KR: "+kr); //$NON-NLS-1$
-			List<AnnotationType> krtypes = kr.getAllAnnotationTypes();
-			Log.warning("Advanced annotation mode ? "+advanced_annotation_mode);
-			if (!advanced_annotation_mode) { // creates the "span" annotation type
-				boolean createTagAnnotationType = true;
-				for (AnnotationType type : krtypes) {
-					if (type.getName().equals("span")) { //$NON-NLS-1$
-						createTagAnnotationType = false;
-					}
-				}
-				if (createTagAnnotationType) {
-					tagAnnotationType = kr.addType("span", "span");//corresponds to an "undef" type //$NON-NLS-1$ //$NON-NLS-2$
-					typesList.add(tagAnnotationType);
-				} else {
-					tagAnnotationType = kr.getType("span"); //$NON-NLS-1$
-				}
-			} else {
-				typesList.addAll(krtypes);
-			}
-			Log.warning("Available annotation types: "+typesList);
-			break;
-		}
-
-		if (currentKnowledgeRepository == null) {
-			System.out.println("Error: no suitable KnowledgeRepository found");
-			return;
-		}
-
-		annotationArea = new Composite(parent, SWT.NONE);
-		annotationArea.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, false, false));
-
-		GridLayout annotLayout = new GridLayout(12, false);
-		annotLayout.verticalSpacing = 0;
-		annotLayout.marginWidth = 0;
-		annotLayout.marginHeight = 0;
-		annotationArea.setLayout(annotLayout);
-
-		//init values history
-		for (AnnotationType type : typesList) {
-			history.put(type, new ArrayList<TypedValue>());
-		}
-
-		addRemoveCombo = new Combo(annotationArea, SWT.READ_ONLY);
-		String affectLabel = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_22");
-		if (affectLabel == null) affectLabel= ConcordanceUIMessages.ConcordancesEditor_22;
-		String removeLabel = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_24");
-		if (removeLabel == null) removeLabel= ConcordanceUIMessages.ConcordancesEditor_24;
-		String items[] = {affectLabel, removeLabel};
-		addRemoveCombo.setItems(items);
-		addRemoveCombo.select(0);
-		addRemoveCombo.addSelectionListener(new SelectionListener() {
-			@Override
-			public void widgetSelected(SelectionEvent e) {
-				if (addRemoveCombo.getSelectionIndex() == 0) { // add
-					annotationValuesText.setEnabled(true);
-					String withLabelText = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_83");
-					if (withLabelText == null) withLabelText= ConcordanceUIMessages.ConcordancesEditor_83;
-					withLabel.setText(withLabelText);
-					if (equalLabel != null) equalLabel.setText("=");
-				} else { // remove
-					annotationValuesText.setEnabled(false);
-					withLabel.setText(""); //$NON-NLS-1$
-					if (equalLabel != null) equalLabel.setText("");
-				}
-				withLabel.redraw();
-				annotationArea.layout();
-				updateAnnotationWidgetStates();
-			}
-			@Override
-			public void widgetDefaultSelected(SelectionEvent e) { }
-		});
-		GridData gdata = new GridData(SWT.CENTER, SWT.CENTER, false, true);
-		gdata.widthHint = 90;
-		addRemoveCombo.setLayoutData(gdata);
-
-		withLabel = new Label(annotationArea, SWT.NONE);
-		String withLabelText = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_83");
-		if (withLabelText == null) withLabelText= ConcordanceUIMessages.ConcordancesEditor_83;
-		withLabel.setText(withLabelText);
-		withLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
-
-		if (advanced_annotation_mode) {
-			equalLabel = new Label(annotationArea, SWT.NONE);
-			equalLabel.setText("="); //$NON-NLS-1$
-			equalLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
-		}
-
-		//Display combo with list of Annotation Type 
-		if (advanced_annotation_mode) {
-			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(); //$NON-NLS-1$
-				}
-				@Override
-				public String getText(Object element) {
-					return ((AnnotationType)element).getName(); //$NON-NLS-1$
-				}
-			});
-			gdata = new GridData(SWT.CENTER, SWT.CENTER, false, true);
-			gdata.widthHint = 200;
-
-			annotationTypesCombo.getCombo().setLayoutData(gdata);
-			annotationTypesCombo.setInput(typesList);
-			if (advanced_annotation_mode.equals(AnnotationUIMessages.AnnotationPreferences_2)) {
-				annotationTypesCombo.getCombo().select(0);
-			}
-
-			annotationTypesCombo.addSelectionChangedListener(new ISelectionChangedListener() {
-				@Override
-				public void selectionChanged(SelectionChangedEvent event) {
-					AnnotationType type = getSelectedAnnotationType();
-					if (type == null) return;
-					if (type.getSize() != AnnotationType.ValuesSize.LARGE) {
-						try {
-							KnowledgeRepository kr = KnowledgeRepositoryManager.getKnowledgeRepository(type.getKnowledgeRepository());
-							typeValuesList = kr.getValues(type);
-						} catch (Exception e) {
-							// TODO Auto-generated catch block
-							e.printStackTrace();
-						}
-					} else { // set history values
-						typeValuesList = history.get(type);
-					}
-
-					annotationColumn.setText(type.getName());
-					if (concordance != null) {
-						annotations.setViewAnnotation(type);
-						annotations.setAnnotationOverlap(true);
-						editor.fillDisplayArea();
-					}
-
-					updateAnnotationWidgetStates();
-				}
-			});
-		}
-
-		if (advanced_annotation_mode) {
-			if (currentKnowledgeRepository instanceof SQLKnowledgeRepository) {
-				infosAnnotTypeSelectedLink = new Button(annotationArea, SWT.PUSH);
-				infosAnnotTypeSelectedLink.setImage(IImageKeys.getImage(IImageKeys.ACTION_INFO));
-				infosAnnotTypeSelectedLink.setEnabled(true);
-				infosAnnotTypeSelectedLink.setLayoutData(new GridData(SWT.FILL,	SWT.CENTER, false, true));
-				infosAnnotTypeSelectedLink.addSelectionListener(new SelectionListener() {
-					@Override
-					public void widgetSelected(SelectionEvent e) {
-						AnnotationType type = getSelectedAnnotationType();
-						if (type == null) return;
-
-						String typedValueURL = type.getURL(); // may be null/empty
-						if (typedValueURL != null && typedValueURL.length() > 0) {
-							KnowledgeRepository kr = KnowledgeRepositoryManager.getKnowledgeRepository(type.getKnowledgeRepository());
-							kr.getTypeURL(type);
-						}
-						if (typedValueURL != null && typedValueURL.length() > 0) {
-							OpenBrowser.openfile(typedValueURL, new File(typedValueURL).getName());
-						} else {
-							IWorkbenchWindow window = editor.getSite().getWorkbenchWindow();
-							try {
-								OpenKRView.openView(window, type);
-							} catch (PartInitException e1) {
-								e1.printStackTrace();
-							}
-						}
-					}
-
-					@Override
-					public void widgetDefaultSelected(SelectionEvent e) { }
-				});
-			}
-
-			if (currentKnowledgeRepository instanceof LocalKnowledgeRepository) {
-				addAnnotationTypeLink = new Button(annotationArea, SWT.PUSH);
-				addAnnotationTypeLink.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_115);
-				addAnnotationTypeLink.setImage(IImageKeys.getImage(IImageKeys.ACTION_ADD));
-				addAnnotationTypeLink.setEnabled(true);
-				addAnnotationTypeLink.setLayoutData(new GridData(SWT.FILL,	SWT.CENTER, false, true));
-				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(), ConcordanceUIMessages.ConcordancesEditor_82, ConcordanceUIMessages.ConcordancesEditor_81, "", null); //$NON-NLS-3$
-						if (dialog.open() == InputDialog.OK) {
-							String name = dialog.getValue();
-							if (name.trim().length() == 0) return;
-							String baseid = AsciiUtils.buildId(name);
-							String id = AsciiUtils.buildId(name);
-							int c = 1;
-							while (kr.getType(id) != null) {
-								id = baseid+"_"+(c++); //$NON-NLS-1$
-							}
-							AnnotationType type = kr.addType(name, id, ""); //$NON-NLS-1$
-							typesList.add(type);
-							history.put(type, new ArrayList<TypedValue>());
-
-							if (annotationTypesCombo != null) annotationTypesCombo.refresh();
-							if (typesList.size() == 1) {
-								if (annotationTypesCombo != null) annotationTypesCombo.getCombo().select(0);
-								if (concordance != null) {
-									annotations.setViewAnnotation(type);
-									annotations.setAnnotationOverlap(true);
-									editor.fillDisplayArea();
-								}
-								annotationArea.layout(true);
-							} else {
-								if (typesList.size() > 1) {
-									if (annotationTypesCombo != null) {
-										annotationTypesCombo.getCombo().select(typesList.size()-1);
-									}
-								}
-							}
-							KRView.refresh();
-							updateAnnotationWidgetStates();
-						} else {
-							System.out.println("Creation aborted."); //$NON-NLS-1$
-						}
-					}
-
-					@Override
-					public void widgetDefaultSelected(SelectionEvent e) { }
-				});
-			}
-		}
-		if (advanced_annotation_mode) {
-			Label valueLabel = new Label(annotationArea, SWT.NONE);
-			String valueLabelText = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_80");
-			if (valueLabelText == null) {
-				valueLabelText= ConcordanceUIMessages.ConcordancesEditor_80;
-			}
-			valueLabel.setText(valueLabelText);
-			valueLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
-		}
-
-		annotationValuesText = new Text(annotationArea, SWT.BORDER);
-		annotationValuesText.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_32);
-		GridData gdata2 = new GridData(SWT.FILL, SWT.CENTER, false, true);
-		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.getLineTableViewer().getSelection());
-				}
-			}
-
-			@Override
-			public void keyPressed(KeyEvent e) { }
-		});
-
-		if (currentKnowledgeRepository instanceof LocalKnowledgeRepository) {
-			addTypedValueLink = new Button(annotationArea, SWT.PUSH);
-			addTypedValueLink.setText("..."); //$NON-NLS-1$
-			if (advanced_annotation_mode.equals(AnnotationUIMessages.AnnotationPreferences_2)) {
-				addTypedValueLink.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_79);
-			} else {
-				addTypedValueLink.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_77);
-			}
-			addTypedValueLink.setEnabled(true);
-			addTypedValueLink.setLayoutData(new GridData(SWT.FILL,	SWT.CENTER, false, true));
-			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());
-					if (advanced_annotation_mode.equals(AnnotationUIMessages.AnnotationPreferences_2)) {
-						String title = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_100");
-						if (title == null) title = ConcordanceUIMessages.ConcordancesEditor_100;
-						dialog.setTitle(ConcordanceUIMessages.bind(title, type.getName()));//+"valeurs de "+type.getName());
-					} else {
-						dialog.setTitle(ConcordanceUIMessages.ConcordancesEditor_99);//+"valeurs de "+type.getName());
-					}
-					dialog.setContentProvider(new ArrayContentProvider());
-					dialog.setLabelProvider(new SimpleLabelProvider() {
-						public String getColumnText(Object element, int columnIndex) {
-							if (element instanceof TypedValue)
-								return ((TypedValue)element).getId();
-							return element.toString();
-						}
-					});
-					List<TypedValue> values;
-					try {
-						values = kr.getValues(type);
-					} catch (Exception e1) {
-						e1.printStackTrace();
-						return;
-					}
-					dialog.setInput(values);
-					if (dialog.open() == InputDialog.OK) {
-						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) { }
-			});
-		}
-
-		affectCombo = new Combo(annotationArea, SWT.READ_ONLY);
-		affectCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true));
-		String items2[] = {ConcordanceUIMessages.ConcordancesEditor_35, ConcordanceUIMessages.ConcordancesEditor_42, ConcordanceUIMessages.ConcordancesEditor_49};
-		affectCombo.setItems(items2);
-		affectCombo.select(0);
-		gdata = new GridData(SWT.CENTER, SWT.CENTER, false, true);
-		gdata.widthHint = 140;
-		affectCombo.setLayoutData(gdata);
-
-		affectAnnotationButton = new Button(annotationArea, SWT.PUSH);
-		affectAnnotationButton.setText(ConcordanceUIMessages.ConcordancesEditor_85);
-		affectAnnotationButton.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_116);
-		affectAnnotationButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true));
-		affectAnnotationButton.addSelectionListener(new SelectionListener() {
-			@Override
-			public void widgetSelected(SelectionEvent e) {
-				int isel = affectCombo.getSelectionIndex();
-				if (isel == 0) { // selected line
-					affectAnnotationToSelection(editor.getLineTableViewer().getSelection());
-				} else if (isel == 1) { // page
-					try {
-						List<Match> matches = concordance.getMatches().subList(editor.getTopLine(), editor.getBottomLine()+1);
-						affectMatchesToSelection(matches);
-					} catch (CqiClientException e1) {
-						Log.severe(ConcordanceUIMessages.ConcordancesEditor_53+e1);
-						Log.printStackTrace(e1);
-						return;
-					}
-				} else { // all
-					try {
-						List<Match> matches = concordance.getMatches();
-						affectMatchesToSelection(matches);
-					} catch (CqiClientException e1) {
-						Log.severe(ConcordanceUIMessages.ConcordancesEditor_53+e1);
-						Log.printStackTrace(e1);
-						return;
-					}
-				}
-			}
-
-			@Override
-			public void widgetDefaultSelected(SelectionEvent e) { }
-		});
-		Button cancelAnnotateButton = new Button(annotationArea, SWT.PUSH);
-		cancelAnnotateButton.setText(ConcordanceUIMessages.ConcordancesEditor_101);
-		cancelAnnotateButton.addSelectionListener(new SelectionListener() {
-			@Override
-			public void widgetSelected(SelectionEvent e) {
-				//@TODO Closing the annotation tool bar 
-				//System.out.println("must hide");
-				annotationSize = annotationArea.getSize();
-				annotationArea.dispose();
-				annotationArea = null;
-				parent.layout(true);
-				parent.layout();
-				annotationButton.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_75);
-				annotationButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL));
-				annotationColumn.setWidth(0);
-				annotationColumn.setResizable(false);
-			}
-
-			@Override
-			public void widgetDefaultSelected(SelectionEvent e) { }
-		});
-
-		updateAnnotationWidgetStates();
-		
-		parent.layout();
-	}
-
-	protected void affectAnnotationToSelection(ISelection selection) {
-
-		final IStructuredSelection lineSelection = (IStructuredSelection) selection;
-		List<Line> lines = lineSelection.toList();
-		ArrayList<Match> matches = new ArrayList<Match>();
-		for (Line l : lines) {
-			matches.add(l.getMatch());
-		}
-
-		affectMatchesToSelection(matches);
-	}
-
-	protected AnnotationType getSelectedAnnotationType() {
-		if (annotationTypesCombo != null) {
-			IStructuredSelection isel = (IStructuredSelection)annotationTypesCombo.getSelection();
-			if (isel.isEmpty()) {
-				return null;
-			}
-			return (AnnotationType) isel.getFirstElement();
-		} else { // simple mode
-			return tagAnnotationType;
-		}
-	}
-
-	protected void affectMatchesToSelection(final List<Match> matches) {
-		final AnnotationType type = getSelectedAnnotationType();
-		final String svalue = annotationValuesText.getText();
-		final boolean doAffect = addRemoveCombo.getSelectionIndex() == 0; // add is default
-
-		JobHandler job = new JobHandler(ConcordanceUIMessages.ConcordancesEditor_36, true) {
-			@Override
-			protected IStatus run(IProgressMonitor monitor) {
-				this.runInit(monitor);
-				try {
-					if (doAffect) {
-						affectAnnotationValues(matches, type, svalue, this);
-					} else {
-						deleteAnnotationValues(matches, type, this);
-					}
-				} catch(Exception e) {
-					Log.severe(ConcordanceUIMessages.ConcordancesEditor_40+e);
-					Log.printStackTrace(e);
-					return Status.CANCEL_STATUS;
-				} catch(ThreadDeath td) {
-					System.out.println("Annotation canceled by user.");
-					return Status.CANCEL_STATUS;
-				}
-
-				return Status.OK_STATUS;
-			}
-		};
-		job.startJob(true);
-	}
-
-	public void updateAnnotationWidgetStates() {
-		if (annotationArea == null) return; // :)
-
-		if (addRemoveCombo.getSelectionIndex() == 0) { // add is default
-
-			if (getSelectedAnnotationType() != null) {
-				annotationValuesText.setEnabled(true);
-
-				affectAnnotationButton.setEnabled(true);
-				affectCombo.setEnabled(true);
-			} else {
-				annotationValuesText.setEnabled(false);
-
-				affectAnnotationButton.setEnabled(false);
-				affectCombo.setEnabled(false);
-			}
-		} else {
-			annotationValuesText.setEnabled(false);
-
-			if (getSelectedAnnotationType() != null) {
-				affectAnnotationButton.setEnabled(true);
-				affectCombo.setEnabled(true);
-			} else {
-				affectAnnotationButton.setEnabled(false);
-				affectCombo.setEnabled(false);
-			}
-		}
-
-		if (advanced_annotation_mode.equals(AnnotationUIMessages.AnnotationPreferences_2)) {
-			if (infosAnnotTypeSelectedLink != null) {
-				infosAnnotTypeSelectedLink.setEnabled(getSelectedAnnotationType() != null);
-			}
-		}
-		if (addTypedValueLink != null) {
-			addTypedValueLink.setEnabled(getSelectedAnnotationType() != null);
-		}
-
-		if (concordance == null) {
-			affectAnnotationButton.setEnabled(false);
-			affectCombo.setEnabled(false);
-		}
-	}
-
-	protected void deleteAnnotationValues(List<Match> matches, AnnotationType type, JobHandler job) {
-		if (concordance == null) {
-			return;
-		}
-		
-		if (matches.size() == 0) {
-			System.out.println("No lines selected. Aborting."); //$NON-NLS-1$
-			return;
-		}
-		
-		if (type == null) {
-			return;
-		}
-
-		if (concordance != null) {
-			try {
-				if (annotManager != null && annotManager.deleteAnnotations(type, matches, job)) {
-					if (Log.getLevel().intValue() < Level.WARNING.intValue()) annotManager.checkData();
-					concordance.reloadLines(editor.getTopLine(), editor.getBottomLine()+1);
-				} else {
-					return;
-				}
-			} catch (Exception e1) {
-				System.out.println(ConcordanceUIMessages.ConcordancesEditor_54+e1);
-				Log.printStackTrace(e1);
-				return;
-			}
-
-			job.syncExec(new Runnable() {
-				@Override
-				public void run() {
-					editor.fillDisplayArea();
-					CorporaView.refreshObject(corpus);
-				}
-			});
-		}
-	}
-	
-	protected void affectAnnotationValues(final List<Match> matches,  final AnnotationType type, final String svalue, JobHandler job) {
-		value_to_add = null; // reset
-		if (concordance == null) {
-			System.out.println("No concordance done. Aborting."); //$NON-NLS-1$
-			return;
-		}
-		if (matches.size() == 0) {
-			System.out.println("No line selected. Aborting."); //$NON-NLS-1$
-			return;
-		}
-		if (type == null) return; // no type, no annotation
-
-		job.syncExec(new Runnable() {
-			@Override
-			public void run() {
-				if (matches.size() > NALERTAFFECTANNOTATIONS) {
-					ConfirmDialog dialog = new ConfirmDialog(Display.getCurrent().getActiveShell(), 
-							"confirm_annotate",  //$NON-NLS-1$
-							ConcordanceUIMessages.ConcordancesEditor_86, 
-							ConcordanceUIMessages.ConcordancesEditor_87+matches.size()+ConcordanceUIMessages.ConcordancesEditor_108);
-
-					if (dialog.open() == ConfirmDialog.CANCEL) {
-						System.out.println("Annotation aborted by user."); //$NON-NLS-1$
-						matches.clear();
-					}
-				}
-			}
-		});
-
-		// get value from combo text value
-		Log.warning(ConcordanceUIMessages.ConcordancesEditor_57+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
-			job.syncExec(new Runnable() {
-				@Override
-				public void run() {
-					String title = kr.getString(editor.getLocale(), "ConcordancesEditor_110");
-					String content = kr.getString(editor.getLocale(), "ConcordancesEditor_112");
-					if (title == null ) title = ConcordanceUIMessages.ConcordancesEditor_110;
-					if (content == null ) content = ConcordanceUIMessages.ConcordancesEditor_112;
-					ConfirmDialog dialog = new ConfirmDialog(Display.getCurrent().getActiveShell(), 
-							"create_value", //$NON-NLS-1$
-							ConcordanceUIMessages.bind(title, svalue, type.getName()),  
-							ConcordanceUIMessages.bind(content, svalue, type.getName()));
-					if (dialog.open() == ConfirmDialog.CANCEL) {
-						System.out.println("Annotation aborted by user."); //$NON-NLS-1$
-						return;
-					} else {
-						value_to_add = kr.addValue(svalue, svalue, type.getId());
-						KRView.refresh();
-					}
-				}
-			});
-		}
-
-		if (value_to_add == null && kr instanceof LocalKnowledgeRepository) return; // canceled
-
-		if (value_to_add == null) {	
-			job.syncExec(new Runnable() {
-				@Override
-				public void run() {
-					String mess = ConcordanceUIMessages.bind(ConcordanceUIMessages.ConcordancesEditor_58, svalue);
-					System.out.println(mess);
-					MessageDialog.openError(Display.getCurrent().getActiveShell(), "Annotation canceled", mess); //$NON-NLS-1$
-				}
-			});
-			return;
-		}
-
-		Log.info(ConcordanceUIMessages.ConcordancesEditor_59+value_to_add+ConcordanceUIMessages.ConcordancesEditor_60+matches);
-
-		// 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 = ConcordanceUIMessages.ConcordancesEditor_61+value_to_add.getStandardName()+
-						ConcordanceUIMessages.ConcordancesEditor_62;
-				for (Match m : existingAnnots.keySet()) {
-					message += ConcordanceUIMessages.ConcordancesEditor_63+m+ConcordanceUIMessages.ConcordancesEditor_64;
-
-					for (Annotation existingAnnot : existingAnnots.get(m)) {
-						if (existingAnnot.getStart() < m.getStart()){
-							message += ConcordanceUIMessages.ConcordancesEditor_65+existingAnnot.getType()+ConcordanceUIMessages.ConcordancesEditor_66+existingAnnot.getStart()+ConcordanceUIMessages.ConcordancesEditor_67+existingAnnot.getEnd()+ConcordanceUIMessages.ConcordancesEditor_68;
-						} else {
-							message += ConcordanceUIMessages.ConcordancesEditor_69+existingAnnot.getType()+ConcordanceUIMessages.ConcordancesEditor_70+existingAnnot.getStart()+ConcordanceUIMessages.ConcordancesEditor_71+existingAnnot.getEnd()+ConcordanceUIMessages.ConcordancesEditor_72;
-						}
-					}
-				}
-				final String final_message = message;
-				job.syncExec(new Runnable() {
-					@Override
-					public void run() {
-						MessageDialog.openInformation(editor.getSite().getShell(), ConcordanceUIMessages.ConcordancesEditor_73, final_message);
-					}
-				});
-			}
-			//				if (history != null && !history.get(type).contains(value_to_add))
-			//					history.get(type).add(value_to_add);
-
-			if (Log.getLevel().intValue() < Level.WARNING.intValue() && annotManager != null) annotManager.checkData();
-			concordance.reloadLines(editor.getTopLine(), editor.getBottomLine()+1);
-		} catch (Exception e1) {
-			System.out.println(ConcordanceUIMessages.ConcordancesEditor_74+e1);
-			Log.printStackTrace(e1);
-			return;
-		}
-
-		job.syncExec(new Runnable() {
-			@Override
-			public void run() {
-				editor.fillDisplayArea();
-				CorporaView.refreshObject(corpus);
-			}
-		});
-
-	}
-
-	@Override
-	public boolean notifyStartOfCompute() throws Exception {
-		if (annotationArea != null) {
-			AnnotationType type = getSelectedAnnotationType();
-			if (type != null) {
-				annotations.setViewAnnotation(type);
-				annotations.setAnnotationOverlap(true);
-			}
-		}
-		return true;
-	}
-
-	@Override
-	public boolean notifyEndOfCompute() throws Exception {
-		updateAnnotationWidgetStates();
-		
-		// update annotation column width
-		if (annotationArea != null) {
-			annotationColumn.pack();
-
-			annotationColumn.setResizable(true);
-		} else { 
-			annotationColumn.setWidth(0);
-		}
-		
-		return true;
-	}
-	
-
-	public boolean isAnnotationEnable() {
-		return annotationArea != null;
-	}
-}
Index: tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/KRConcordanceAnnotationExtension.java
===================================================================
--- tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/KRConcordanceAnnotationExtension.java	(revision 0)
+++ tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/KRConcordanceAnnotationExtension.java	(revision 782)
@@ -0,0 +1,968 @@
+package org.txm.annotation.rcp.concordance;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Vector;
+import java.util.logging.Level;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.dialogs.ListDialog;
+import org.txm.annotation.core.Annotation;
+import org.txm.annotation.core.AnnotationManager;
+import org.txm.annotation.core.KRAnnotationEngine;
+import org.txm.annotation.core.preferences.AnnotationPreferences;
+import org.txm.annotation.core.repository.AnnotationType;
+import org.txm.annotation.core.repository.KnowledgeRepository;
+import org.txm.annotation.core.repository.KnowledgeRepositoryManager;
+import org.txm.annotation.core.repository.LocalKnowledgeRepository;
+import org.txm.annotation.core.repository.SQLKnowledgeRepository;
+import org.txm.annotation.core.repository.TypedValue;
+import org.txm.annotation.rcp.commands.InitializeKnowledgeRepository;
+import org.txm.annotation.rcp.commands.SaveAnnotations;
+import org.txm.annotation.rcp.commands.krview.OpenKRView;
+import org.txm.annotation.rcp.messages.AnnotationUIMessages;
+import org.txm.annotation.rcp.views.knowledgerepositories.KRView;
+import org.txm.concordance.core.functions.Concordance;
+import org.txm.concordance.core.functions.Line;
+import org.txm.concordance.rcp.editors.ConcordanceEditor;
+import org.txm.concordance.rcp.editors.ConcordanceEditor.ConcordanceColumnSizeControlListener;
+import org.txm.concordance.rcp.editors.ConcordanceEditorExtension;
+import org.txm.concordance.rcp.messages.ConcordanceUIMessages;
+import org.txm.core.preferences.TXMPreferences;
+import org.txm.rcp.IImageKeys;
+import org.txm.rcp.commands.OpenBrowser;
+import org.txm.rcp.editors.TXMEditorToolBar.OpenCloseButton;
+import org.txm.rcp.preferences.RCPPreferences;
+import org.txm.rcp.swt.GLComposite;
+import org.txm.rcp.swt.dialog.ConfirmDialog;
+import org.txm.rcp.swt.provider.SimpleLabelProvider;
+import org.txm.rcp.utils.JobHandler;
+import org.txm.rcp.views.corpora.CorporaView;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.corpus.Corpus;
+import org.txm.searchengine.cqp.corpus.query.Match;
+import org.txm.utils.AsciiUtils;
+import org.txm.utils.logger.Log;
+
+public class KRConcordanceAnnotationExtension extends ConcordanceEditorExtension {
+
+	/**
+	 * the limit number of annotation when a confirm dialog box is shown
+	 */
+	protected static final int NALERTAFFECTANNOTATIONS = 100;
+	public static final String EMPTYTEXT = "";
+
+	/** The annotation service */
+	protected AnnotationManager annotManager;
+
+	//boolean annotation_expert_mode = TxmPreferences.getBoolean(AnnotationPreferencePage.MODE, false);
+
+	/** The annotation area. */
+	protected GLComposite annotationArea;
+
+	protected Point annotationSize;
+
+	/** The annot btn : starts the annotation */
+	protected OpenCloseButton annotationButton;
+	private Button addAnnotationTypeLink;
+
+	protected Text annotationValuesText;
+	protected ComboViewer annotationTypesCombo;
+
+	protected List<TypedValue> typeValuesList;
+
+	protected Point annotSize;
+
+	protected TableColumn annotationColumn;
+
+	protected Combo addRemoveCombo;
+	protected Combo affectCombo;
+	protected Button affectAnnotationButton;
+
+	protected Button infosAnnotTypeSelectedLink;
+
+	protected HashMap<AnnotationType, ArrayList<TypedValue>> history = new HashMap<AnnotationType, ArrayList<TypedValue>>();
+
+	protected KnowledgeRepository currentKnowledgeRepository = null;
+	protected Vector<AnnotationType> typesList = new Vector<AnnotationType>(); 
+
+	protected Button addTypedValueLink;
+
+	protected Label withLabel;
+
+	protected AnnotationType tagAnnotationType; // the tag annotation type if annotation mode is simple
+
+	protected Label equalLabel;
+	protected Boolean advanced_annotation_mode = false;
+
+	protected TypedValue value_to_add;
+
+	protected Concordance concordance;
+
+	private Corpus corpus;
+
+	private ConcordanceAnnotations annotations = null;
+
+	public KRConcordanceAnnotationExtension() {
+
+	}
+
+	@Override
+	public String getName() {
+		return "Annotation";
+	}
+
+	@Override
+	public boolean installWidgets() throws Exception {
+
+		List<String> krlist = KRAnnotationEngine.getKnowledgeRepositoryNames(corpus);
+		// CONTROLS
+		if (krlist.size() == 0) { // shown only if corpus has a registered KR
+			return false;
+		}
+		
+		final Group controlArea = editor.getTopToolbar().installGroup("annotation", "annotation tools",
+				"platform:/plugin/org.txm.annotation.rcp/icons/functions/pencil.png", null, false);
+		controlArea.setLayout(new GridLayout(1, true));
+		//final Composite navigationArea = editor.getNavigationArea();
+		TableViewer viewer = editor.getLineTableViewer();
+		
+		annotationButton = editor.getTopToolbar().getGroupButton("annotation");
+		annotationButton.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_75);
+		annotationButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL));
+		annotationButton.addSelectionListener(new SelectionListener() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				if (annotationArea != null) {
+					try {
+						AnnotationManager am = KRAnnotationEngine.getAnnotationManager(corpus);
+						if (am != null && am.hasChanges()) {
+							// && MessageDialog.openConfirm(e.display.getActiveShell(), "Confirm annotation save", "Saving annotation will close this editor. Are you sure you want to save annotations right now ?")
+							JobHandler saveJob = SaveAnnotations.save(corpus.getMainCorpus());
+							if (saveJob.getResult() == Status.CANCEL_STATUS) {
+								// update editor corpus
+								System.out.println("Fail to save annotations of the corpus."); //$NON-NLS-1$
+							}
+						}
+					} catch(Exception ex) {
+						ex.printStackTrace();
+					}
+				} else {
+					if (annotationArea == null) {
+						if (!composeAnnotationArea(controlArea)) {
+							return;
+						}
+					}
+					if (annotationArea == null) return;
+
+					annotationColumn.pack();
+					annotationButton.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_76);
+					annotationButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL_SAVE));
+
+					annotSize = annotationArea.getSize();
+					Point size = controlArea.getSize();
+					controlArea.setSize(size.x, size.y + annotSize.y);
+					GridData data = (GridData) annotationArea.getLayoutData();
+					data.heightHint = annotSize.y;
+					data.minimumHeight = annotSize.y;
+					annotationArea.setSize(annotSize);
+					controlArea.layout(true);
+					controlArea.getParent().layout();
+
+					if (concordance != null) {
+						AnnotationType type = getSelectedAnnotationType();
+						if (type != null) {
+							annotations.setViewAnnotation(type);
+							annotations.setAnnotationOverlap(true);
+							editor.fillDisplayArea();
+						}
+					}
+
+					CorporaView.refreshObject(corpus);
+				}
+			}
+
+			@Override
+			public void widgetDefaultSelected(SelectionEvent e) {	}
+		});
+
+
+		// RESULT
+
+		int position = 2; // after keyword column
+		TableViewerColumn annotationColumnViewer = new TableViewerColumn(viewer, SWT.CENTER, position);
+		annotationColumn = annotationColumnViewer.getColumn();
+		annotationColumn.setText(ConcordanceUIMessages.ConcordancesEditor_15);
+		annotationColumn.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_17);
+		annotationColumn.setAlignment(SWT.CENTER);
+
+		annotationColumn.addControlListener(new ConcordanceColumnSizeControlListener(annotationColumn));
+		annotationColumnViewer.setLabelProvider(new ColumnLabelProvider() {
+
+			@Override
+			public String getText(Object element) {
+				Line line = (Line)element;
+				AnnotationLine annotationLine = annotations.getAnnotationLine(line);
+				if (annotationLine == null) return EMPTYTEXT ;
+				if (annotationLine.getAnnotation()!=null) {
+					String value = annotationLine.getAnnotationValue().getStandardName();
+					Annotation a = annotationLine.getAnnotation();
+					if (value == null) value = a.getValue();
+
+					if (a.getStart() < line.matchGetStart() - line.getLeftContextSize()) {
+						value = "… "+value;
+					}
+
+					if (a.getEnd() > line.matchGetEnd() + line.getRightContextSize()) {
+						value = value+" …";
+					} 
+					return value;
+				} else {
+					return EMPTYTEXT;
+				}
+			}
+		});
+		
+
+		return true;
+	}
+
+	public boolean initialiseInput(ConcordanceEditor editor) throws Exception {
+		this.editor = editor;
+		concordance = editor.getConcordance();
+		annotations = new ConcordanceAnnotations(concordance);
+		corpus = concordance.getCorpus();
+
+		Corpus corpus = editor.getCorpus();
+
+		this.annotManager = KRAnnotationEngine.getAnnotationManager(corpus);
+
+		return true;
+
+	}
+
+	private boolean composeAnnotationArea(final Composite parent){ 
+		advanced_annotation_mode = "advanced".equals(TXMPreferences.getString(AnnotationPreferences.ANNOTATION_MODE, RCPPreferences.PREFERENCES_NODE));
+
+		List<KnowledgeRepository> krs = InitializeKnowledgeRepository.get(corpus.getMainCorpus());
+		typesList.clear();
+		Log.warning("Corpus KRs: "+krs); //$NON-NLS-1$
+
+		for (KnowledgeRepository kr : krs) {
+			if (kr == null) continue;
+
+			currentKnowledgeRepository = kr;
+			Log.warning(" KR: "+kr); //$NON-NLS-1$
+			List<AnnotationType> krtypes = kr.getAllAnnotationTypes();
+			Log.warning("Advanced annotation mode ? "+advanced_annotation_mode);
+			if (!advanced_annotation_mode) { // creates the "span" annotation type
+				boolean createTagAnnotationType = true;
+				for (AnnotationType type : krtypes) {
+					if (type.getName().equals("span")) { //$NON-NLS-1$
+						createTagAnnotationType = false;
+					}
+				}
+				if (createTagAnnotationType) {
+					tagAnnotationType = kr.addType("span", "span");//corresponds to an "undef" type //$NON-NLS-1$ //$NON-NLS-2$
+					typesList.add(tagAnnotationType);
+				} else {
+					tagAnnotationType = kr.getType("span"); //$NON-NLS-1$
+				}
+			} else {
+				typesList.addAll(krtypes);
+			}
+			Log.warning("Available annotation types: "+typesList);
+			break;
+		}
+
+		if (currentKnowledgeRepository == null) {
+			System.out.println("Error: no suitable KnowledgeRepository found");
+			return false;
+		}
+
+		annotationArea = new GLComposite(parent, SWT.NONE);
+		annotationArea.getLayout().numColumns = 12;
+		annotationArea.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, false, false));
+
+		//init values history
+		for (AnnotationType type : typesList) {
+			history.put(type, new ArrayList<TypedValue>());
+		}
+
+		addRemoveCombo = new Combo(annotationArea, SWT.READ_ONLY);
+		String affectLabel = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_22");
+		if (affectLabel == null) affectLabel= ConcordanceUIMessages.ConcordancesEditor_22;
+		String removeLabel = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_24");
+		if (removeLabel == null) removeLabel= ConcordanceUIMessages.ConcordancesEditor_24;
+		String items[] = {affectLabel, removeLabel};
+		addRemoveCombo.setItems(items);
+		addRemoveCombo.select(0);
+		addRemoveCombo.addSelectionListener(new SelectionListener() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				if (addRemoveCombo.getSelectionIndex() == 0) { // add
+					annotationValuesText.setEnabled(true);
+					String withLabelText = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_83");
+					if (withLabelText == null) withLabelText= ConcordanceUIMessages.ConcordancesEditor_83;
+					withLabel.setText(withLabelText);
+					if (equalLabel != null) equalLabel.setText("=");
+				} else { // remove
+					annotationValuesText.setEnabled(false);
+					withLabel.setText(""); //$NON-NLS-1$
+					if (equalLabel != null) equalLabel.setText("");
+				}
+				withLabel.redraw();
+				annotationArea.layout();
+				updateAnnotationWidgetStates();
+			}
+			@Override
+			public void widgetDefaultSelected(SelectionEvent e) { }
+		});
+		GridData gdata = new GridData(SWT.CENTER, SWT.CENTER, false, true);
+		gdata.widthHint = 90;
+		addRemoveCombo.setLayoutData(gdata);
+
+		withLabel = new Label(annotationArea, SWT.NONE);
+		String withLabelText = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_83");
+		if (withLabelText == null) withLabelText= ConcordanceUIMessages.ConcordancesEditor_83;
+		withLabel.setText(withLabelText);
+		withLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+
+		if (advanced_annotation_mode) {
+			equalLabel = new Label(annotationArea, SWT.NONE);
+			equalLabel.setText("="); //$NON-NLS-1$
+			equalLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+		}
+
+		//Display combo with list of Annotation Type 
+		if (advanced_annotation_mode) {
+			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(); //$NON-NLS-1$
+				}
+				@Override
+				public String getText(Object element) {
+					return ((AnnotationType)element).getName(); //$NON-NLS-1$
+				}
+			});
+			gdata = new GridData(SWT.CENTER, SWT.CENTER, false, true);
+			gdata.widthHint = 200;
+
+			annotationTypesCombo.getCombo().setLayoutData(gdata);
+			annotationTypesCombo.setInput(typesList);
+			if (advanced_annotation_mode.equals(AnnotationUIMessages.AnnotationPreferences_2)) {
+				annotationTypesCombo.getCombo().select(0);
+			}
+
+			annotationTypesCombo.addSelectionChangedListener(new ISelectionChangedListener() {
+				@Override
+				public void selectionChanged(SelectionChangedEvent event) {
+					AnnotationType type = getSelectedAnnotationType();
+					if (type == null) return;
+					if (type.getSize() != AnnotationType.ValuesSize.LARGE) {
+						try {
+							KnowledgeRepository kr = KnowledgeRepositoryManager.getKnowledgeRepository(type.getKnowledgeRepository());
+							typeValuesList = kr.getValues(type);
+						} catch (Exception e) {
+							// TODO Auto-generated catch block
+							e.printStackTrace();
+						}
+					} else { // set history values
+						typeValuesList = history.get(type);
+					}
+
+					annotationColumn.setText(type.getName());
+					if (concordance != null) {
+						annotations.setViewAnnotation(type);
+						annotations.setAnnotationOverlap(true);
+						editor.fillDisplayArea();
+					}
+
+					updateAnnotationWidgetStates();
+				}
+			});
+		}
+
+		if (advanced_annotation_mode) {
+			if (currentKnowledgeRepository instanceof SQLKnowledgeRepository) {
+				infosAnnotTypeSelectedLink = new Button(annotationArea, SWT.PUSH);
+				infosAnnotTypeSelectedLink.setImage(IImageKeys.getImage(IImageKeys.ACTION_INFO));
+				infosAnnotTypeSelectedLink.setEnabled(true);
+				infosAnnotTypeSelectedLink.setLayoutData(new GridData(SWT.FILL,	SWT.CENTER, false, true));
+				infosAnnotTypeSelectedLink.addSelectionListener(new SelectionListener() {
+					@Override
+					public void widgetSelected(SelectionEvent e) {
+						AnnotationType type = getSelectedAnnotationType();
+						if (type == null) return;
+
+						String typedValueURL = type.getURL(); // may be null/empty
+						if (typedValueURL != null && typedValueURL.length() > 0) {
+							KnowledgeRepository kr = KnowledgeRepositoryManager.getKnowledgeRepository(type.getKnowledgeRepository());
+							kr.getTypeURL(type);
+						}
+						if (typedValueURL != null && typedValueURL.length() > 0) {
+							OpenBrowser.openfile(typedValueURL, new File(typedValueURL).getName());
+						} else {
+							IWorkbenchWindow window = editor.getSite().getWorkbenchWindow();
+							try {
+								OpenKRView.openView(window, type);
+							} catch (PartInitException e1) {
+								e1.printStackTrace();
+							}
+						}
+					}
+
+					@Override
+					public void widgetDefaultSelected(SelectionEvent e) { }
+				});
+			}
+
+			if (currentKnowledgeRepository instanceof LocalKnowledgeRepository) {
+				addAnnotationTypeLink = new Button(annotationArea, SWT.PUSH);
+				addAnnotationTypeLink.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_115);
+				addAnnotationTypeLink.setImage(IImageKeys.getImage(IImageKeys.ACTION_ADD));
+				addAnnotationTypeLink.setEnabled(true);
+				addAnnotationTypeLink.setLayoutData(new GridData(SWT.FILL,	SWT.CENTER, false, true));
+				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(), ConcordanceUIMessages.ConcordancesEditor_82, ConcordanceUIMessages.ConcordancesEditor_81, "", null); //$NON-NLS-3$
+						if (dialog.open() == InputDialog.OK) {
+							String name = dialog.getValue();
+							if (name.trim().length() == 0) return;
+							String baseid = AsciiUtils.buildId(name);
+							String id = AsciiUtils.buildId(name);
+							int c = 1;
+							while (kr.getType(id) != null) {
+								id = baseid+"_"+(c++); //$NON-NLS-1$
+							}
+							AnnotationType type = kr.addType(name, id, ""); //$NON-NLS-1$
+							typesList.add(type);
+							history.put(type, new ArrayList<TypedValue>());
+
+							if (annotationTypesCombo != null) annotationTypesCombo.refresh();
+							if (typesList.size() == 1) {
+								if (annotationTypesCombo != null) annotationTypesCombo.getCombo().select(0);
+								if (concordance != null) {
+									annotations.setViewAnnotation(type);
+									annotations.setAnnotationOverlap(true);
+									editor.fillDisplayArea();
+								}
+								annotationArea.layout(true);
+							} else {
+								if (typesList.size() > 1) {
+									if (annotationTypesCombo != null) {
+										annotationTypesCombo.getCombo().select(typesList.size()-1);
+									}
+								}
+							}
+							KRView.refresh();
+							updateAnnotationWidgetStates();
+						} else {
+							System.out.println("Creation aborted."); //$NON-NLS-1$
+						}
+					}
+
+					@Override
+					public void widgetDefaultSelected(SelectionEvent e) { }
+				});
+			}
+		}
+		if (advanced_annotation_mode) {
+			Label valueLabel = new Label(annotationArea, SWT.NONE);
+			String valueLabelText = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_80");
+			if (valueLabelText == null) {
+				valueLabelText= ConcordanceUIMessages.ConcordancesEditor_80;
+			}
+			valueLabel.setText(valueLabelText);
+			valueLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+		}
+
+		annotationValuesText = new Text(annotationArea, SWT.BORDER);
+		annotationValuesText.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_32);
+		GridData gdata2 = new GridData(SWT.FILL, SWT.CENTER, false, true);
+		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.getLineTableViewer().getSelection());
+				}
+			}
+
+			@Override
+			public void keyPressed(KeyEvent e) { }
+		});
+
+		if (currentKnowledgeRepository instanceof LocalKnowledgeRepository) {
+			addTypedValueLink = new Button(annotationArea, SWT.PUSH);
+			addTypedValueLink.setText("..."); //$NON-NLS-1$
+			if (advanced_annotation_mode.equals(AnnotationUIMessages.AnnotationPreferences_2)) {
+				addTypedValueLink.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_79);
+			} else {
+				addTypedValueLink.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_77);
+			}
+			addTypedValueLink.setEnabled(true);
+			addTypedValueLink.setLayoutData(new GridData(SWT.FILL,	SWT.CENTER, false, true));
+			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());
+					if (advanced_annotation_mode.equals(AnnotationUIMessages.AnnotationPreferences_2)) {
+						String title = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_100");
+						if (title == null) title = ConcordanceUIMessages.ConcordancesEditor_100;
+						dialog.setTitle(ConcordanceUIMessages.bind(title, type.getName()));//+"valeurs de "+type.getName());
+					} else {
+						dialog.setTitle(ConcordanceUIMessages.ConcordancesEditor_99);//+"valeurs de "+type.getName());
+					}
+					dialog.setContentProvider(new ArrayContentProvider());
+					dialog.setLabelProvider(new SimpleLabelProvider() {
+						public String getColumnText(Object element, int columnIndex) {
+							if (element instanceof TypedValue)
+								return ((TypedValue)element).getId();
+							return element.toString();
+						}
+					});
+					List<TypedValue> values;
+					try {
+						values = kr.getValues(type);
+					} catch (Exception e1) {
+						e1.printStackTrace();
+						return;
+					}
+					dialog.setInput(values);
+					if (dialog.open() == InputDialog.OK) {
+						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) { }
+			});
+		}
+
+		affectCombo = new Combo(annotationArea, SWT.READ_ONLY);
+		affectCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true));
+		String items2[] = {ConcordanceUIMessages.ConcordancesEditor_35, ConcordanceUIMessages.ConcordancesEditor_42, ConcordanceUIMessages.ConcordancesEditor_49};
+		affectCombo.setItems(items2);
+		affectCombo.select(0);
+		gdata = new GridData(SWT.CENTER, SWT.CENTER, false, true);
+		gdata.widthHint = 140;
+		affectCombo.setLayoutData(gdata);
+
+		affectAnnotationButton = new Button(annotationArea, SWT.PUSH);
+		affectAnnotationButton.setText(ConcordanceUIMessages.ConcordancesEditor_85);
+		affectAnnotationButton.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_116);
+		affectAnnotationButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true));
+		affectAnnotationButton.addSelectionListener(new SelectionListener() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				int isel = affectCombo.getSelectionIndex();
+				if (isel == 0) { // selected line
+					affectAnnotationToSelection(editor.getLineTableViewer().getSelection());
+				} else if (isel == 1) { // page
+					try {
+						List<Match> matches = concordance.getMatches().subList(editor.getTopLine(), editor.getBottomLine()+1);
+						affectMatchesToSelection(matches);
+					} catch (CqiClientException e1) {
+						Log.severe(ConcordanceUIMessages.ConcordancesEditor_53+e1);
+						Log.printStackTrace(e1);
+						return;
+					}
+				} else { // all
+					try {
+						List<Match> matches = concordance.getMatches();
+						affectMatchesToSelection(matches);
+					} catch (CqiClientException e1) {
+						Log.severe(ConcordanceUIMessages.ConcordancesEditor_53+e1);
+						Log.printStackTrace(e1);
+						return;
+					}
+				}
+			}
+
+			@Override
+			public void widgetDefaultSelected(SelectionEvent e) { }
+		});
+		Button cancelAnnotateButton = new Button(annotationArea, SWT.PUSH);
+		cancelAnnotateButton.setText(ConcordanceUIMessages.ConcordancesEditor_101);
+		cancelAnnotateButton.addSelectionListener(new SelectionListener() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				//@TODO Closing the annotation tool bar 
+				//System.out.println("must hide");
+				annotationSize = annotationArea.getSize();
+				annotationArea.dispose();
+				annotationArea = null;
+				parent.layout(true);
+				parent.layout();
+				annotationButton.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_75);
+				annotationButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL));
+				annotationColumn.setWidth(0);
+				annotationColumn.setResizable(false);
+			}
+
+			@Override
+			public void widgetDefaultSelected(SelectionEvent e) { }
+		});
+
+		updateAnnotationWidgetStates();
+
+		parent.layout();
+		
+		return true;
+	}
+
+	protected void affectAnnotationToSelection(ISelection selection) {
+
+		final IStructuredSelection lineSelection = (IStructuredSelection) selection;
+		List<Line> lines = lineSelection.toList();
+		ArrayList<Match> matches = new ArrayList<Match>();
+		for (Line l : lines) {
+			matches.add(l.getMatch());
+		}
+
+		affectMatchesToSelection(matches);
+	}
+
+	protected AnnotationType getSelectedAnnotationType() {
+		if (annotationTypesCombo != null) {
+			IStructuredSelection isel = (IStructuredSelection)annotationTypesCombo.getSelection();
+			if (isel.isEmpty()) {
+				return null;
+			}
+			return (AnnotationType) isel.getFirstElement();
+		} else { // simple mode
+			return tagAnnotationType;
+		}
+	}
+
+	protected void affectMatchesToSelection(final List<Match> matches) {
+		final AnnotationType type = getSelectedAnnotationType();
+		final String svalue = annotationValuesText.getText();
+		final boolean doAffect = addRemoveCombo.getSelectionIndex() == 0; // add is default
+
+		JobHandler job = new JobHandler(ConcordanceUIMessages.ConcordancesEditor_36, true) {
+			@Override
+			protected IStatus run(IProgressMonitor monitor) {
+				this.runInit(monitor);
+				try {
+					if (doAffect) {
+						affectAnnotationValues(matches, type, svalue, this);
+					} else {
+						deleteAnnotationValues(matches, type, this);
+					}
+				} catch(Exception e) {
+					Log.severe(ConcordanceUIMessages.ConcordancesEditor_40+e);
+					Log.printStackTrace(e);
+					return Status.CANCEL_STATUS;
+				} catch(ThreadDeath td) {
+					System.out.println("Annotation canceled by user.");
+					return Status.CANCEL_STATUS;
+				}
+
+				return Status.OK_STATUS;
+			}
+		};
+		job.startJob(true);
+	}
+
+	public void updateAnnotationWidgetStates() {
+		if (annotationArea == null) return; // :)
+
+		if (addRemoveCombo.getSelectionIndex() == 0) { // add is default
+
+			if (getSelectedAnnotationType() != null) {
+				annotationValuesText.setEnabled(true);
+
+				affectAnnotationButton.setEnabled(true);
+				affectCombo.setEnabled(true);
+			} else {
+				annotationValuesText.setEnabled(false);
+
+				affectAnnotationButton.setEnabled(false);
+				affectCombo.setEnabled(false);
+			}
+		} else {
+			annotationValuesText.setEnabled(false);
+
+			if (getSelectedAnnotationType() != null) {
+				affectAnnotationButton.setEnabled(true);
+				affectCombo.setEnabled(true);
+			} else {
+				affectAnnotationButton.setEnabled(false);
+				affectCombo.setEnabled(false);
+			}
+		}
+
+		if (advanced_annotation_mode.equals(AnnotationUIMessages.AnnotationPreferences_2)) {
+			if (infosAnnotTypeSelectedLink != null) {
+				infosAnnotTypeSelectedLink.setEnabled(getSelectedAnnotationType() != null);
+			}
+		}
+		if (addTypedValueLink != null) {
+			addTypedValueLink.setEnabled(getSelectedAnnotationType() != null);
+		}
+
+		if (concordance == null) {
+			affectAnnotationButton.setEnabled(false);
+			affectCombo.setEnabled(false);
+		}
+	}
+
+	protected void deleteAnnotationValues(List<Match> matches, AnnotationType type, JobHandler job) {
+		if (concordance == null) {
+			return;
+		}
+
+		if (matches.size() == 0) {
+			System.out.println("No lines selected. Aborting."); //$NON-NLS-1$
+			return;
+		}
+
+		if (type == null) {
+			return;
+		}
+
+		if (concordance != null) {
+			try {
+				if (annotManager != null && annotManager.deleteAnnotations(type, matches, job)) {
+					if (Log.getLevel().intValue() < Level.WARNING.intValue()) annotManager.checkData();
+					concordance.reloadLines(editor.getTopLine(), editor.getBottomLine()+1);
+				} else {
+					return;
+				}
+			} catch (Exception e1) {
+				System.out.println(ConcordanceUIMessages.ConcordancesEditor_54+e1);
+				Log.printStackTrace(e1);
+				return;
+			}
+
+			job.syncExec(new Runnable() {
+				@Override
+				public void run() {
+					editor.fillDisplayArea();
+					CorporaView.refreshObject(corpus);
+				}
+			});
+		}
+	}
+
+	protected void affectAnnotationValues(final List<Match> matches,  final AnnotationType type, final String svalue, JobHandler job) {
+		value_to_add = null; // reset
+		if (concordance == null) {
+			System.out.println("No concordance done. Aborting."); //$NON-NLS-1$
+			return;
+		}
+		if (matches.size() == 0) {
+			System.out.println("No line selected. Aborting."); //$NON-NLS-1$
+			return;
+		}
+		if (type == null) return; // no type, no annotation
+
+		job.syncExec(new Runnable() {
+			@Override
+			public void run() {
+				if (matches.size() > NALERTAFFECTANNOTATIONS) {
+					ConfirmDialog dialog = new ConfirmDialog(Display.getCurrent().getActiveShell(), 
+							"confirm_annotate",  //$NON-NLS-1$
+							ConcordanceUIMessages.ConcordancesEditor_86, 
+							ConcordanceUIMessages.ConcordancesEditor_87+matches.size()+ConcordanceUIMessages.ConcordancesEditor_108);
+
+					if (dialog.open() == ConfirmDialog.CANCEL) {
+						System.out.println("Annotation aborted by user."); //$NON-NLS-1$
+						matches.clear();
+					}
+				}
+			}
+		});
+
+		// get value from combo text value
+		Log.warning(ConcordanceUIMessages.ConcordancesEditor_57+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
+			job.syncExec(new Runnable() {
+				@Override
+				public void run() {
+					String title = kr.getString(editor.getLocale(), "ConcordancesEditor_110");
+					String content = kr.getString(editor.getLocale(), "ConcordancesEditor_112");
+					if (title == null ) title = ConcordanceUIMessages.ConcordancesEditor_110;
+					if (content == null ) content = ConcordanceUIMessages.ConcordancesEditor_112;
+					ConfirmDialog dialog = new ConfirmDialog(Display.getCurrent().getActiveShell(), 
+							"create_value", //$NON-NLS-1$
+							ConcordanceUIMessages.bind(title, svalue, type.getName()),  
+							ConcordanceUIMessages.bind(content, svalue, type.getName()));
+					if (dialog.open() == ConfirmDialog.CANCEL) {
+						System.out.println("Annotation aborted by user."); //$NON-NLS-1$
+						return;
+					} else {
+						value_to_add = kr.addValue(svalue, svalue, type.getId());
+						KRView.refresh();
+					}
+				}
+			});
+		}
+
+		if (value_to_add == null && kr instanceof LocalKnowledgeRepository) return; // canceled
+
+		if (value_to_add == null) {	
+			job.syncExec(new Runnable() {
+				@Override
+				public void run() {
+					String mess = ConcordanceUIMessages.bind(ConcordanceUIMessages.ConcordancesEditor_58, svalue);
+					System.out.println(mess);
+					MessageDialog.openError(Display.getCurrent().getActiveShell(), "Annotation canceled", mess); //$NON-NLS-1$
+				}
+			});
+			return;
+		}
+
+		Log.info(ConcordanceUIMessages.ConcordancesEditor_59+value_to_add+ConcordanceUIMessages.ConcordancesEditor_60+matches);
+
+		// 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 = ConcordanceUIMessages.ConcordancesEditor_61+value_to_add.getStandardName()+
+						ConcordanceUIMessages.ConcordancesEditor_62;
+				for (Match m : existingAnnots.keySet()) {
+					message += ConcordanceUIMessages.ConcordancesEditor_63+m+ConcordanceUIMessages.ConcordancesEditor_64;
+
+					for (Annotation existingAnnot : existingAnnots.get(m)) {
+						if (existingAnnot.getStart() < m.getStart()){
+							message += ConcordanceUIMessages.ConcordancesEditor_65+existingAnnot.getType()+ConcordanceUIMessages.ConcordancesEditor_66+existingAnnot.getStart()+ConcordanceUIMessages.ConcordancesEditor_67+existingAnnot.getEnd()+ConcordanceUIMessages.ConcordancesEditor_68;
+						} else {
+							message += ConcordanceUIMessages.ConcordancesEditor_69+existingAnnot.getType()+ConcordanceUIMessages.ConcordancesEditor_70+existingAnnot.getStart()+ConcordanceUIMessages.ConcordancesEditor_71+existingAnnot.getEnd()+ConcordanceUIMessages.ConcordancesEditor_72;
+						}
+					}
+				}
+				final String final_message = message;
+				job.syncExec(new Runnable() {
+					@Override
+					public void run() {
+						MessageDialog.openInformation(editor.getSite().getShell(), ConcordanceUIMessages.ConcordancesEditor_73, final_message);
+					}
+				});
+			}
+			//				if (history != null && !history.get(type).contains(value_to_add))
+			//					history.get(type).add(value_to_add);
+
+			if (Log.getLevel().intValue() < Level.WARNING.intValue() && annotManager != null) {
+				annotManager.checkData();
+			}
+			concordance.reloadCurrentLines();
+		} catch (Exception e1) {
+			System.out.println(ConcordanceUIMessages.ConcordancesEditor_74+e1);
+			Log.printStackTrace(e1);
+			return;
+		}
+
+		job.syncExec(new Runnable() {
+			@Override
+			public void run() {
+				editor.fillDisplayArea();
+				CorporaView.refreshObject(corpus);
+			}
+		});
+
+	}
+
+	@Override
+	public boolean notifyStartOfCompute() throws Exception {
+		if (annotationArea != null) {
+			AnnotationType type = getSelectedAnnotationType();
+			if (type != null) {
+				annotations.setViewAnnotation(type);
+				annotations.setAnnotationOverlap(true);
+			}
+		}
+		return true;
+	}
+
+	@Override
+	public boolean notifyEndOfCompute() throws Exception {
+		updateAnnotationWidgetStates();
+
+		// update annotation column width
+		if (annotationArea != null) {
+			annotationColumn.pack();
+
+			annotationColumn.setResizable(true);
+		} else { 
+			annotationColumn.setWidth(0);
+		}
+
+		return true;
+	}
+
+
+	public boolean isAnnotationEnable() {
+		return annotationArea != null;
+	}
+
+	@Override
+	public void update(List<Line> lines, int from, int to) throws Exception {
+		annotations.getLines(lines, from, to);
+	}
+}

Property changes on: tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/KRConcordanceAnnotationExtension.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/ConcordanceAnnotations.java
===================================================================
--- tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/ConcordanceAnnotations.java	(revision 781)
+++ tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/ConcordanceAnnotations.java	(revision 782)
@@ -1,9 +1,6 @@
 package org.txm.annotation.rcp.concordance;
 
-import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 
@@ -14,10 +11,7 @@
 import org.txm.annotation.core.repository.TypedValue;
 import org.txm.concordance.core.functions.Concordance;
 import org.txm.concordance.core.functions.Line;
-import org.txm.concordance.core.messages.ConcordanceMessages;
-import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.corpus.query.Match;
-import org.txm.searchengine.cqp.serverException.CqiServerError;
 import org.txm.utils.logger.Log;
 
 public class ConcordanceAnnotations {
@@ -27,7 +21,7 @@
 	private AnnotationType viewAnnotation;
 	
 	public ConcordanceAnnotations(Concordance concordance) {
-		
+		this.concordance = concordance;
 	}
 	
 	private boolean overlapAnnotation;
@@ -42,9 +36,10 @@
 		return overlapAnnotation;
 	}
 	
-	public List<AnnotationLine> getLines(int from, int to) throws CqiClientException, IOException, CqiServerError {
+	public List<AnnotationLine> getLines(List<Line> lines2, int from, int to) throws Exception {
 
 		concordanceLines = concordance.getLines(from, to);
+		
 		ArrayList<Match> matches = new ArrayList<Match>();
 		for (Line line : concordanceLines) matches.add(line.getMatch());
 		
@@ -57,7 +52,7 @@
 			lines.add(aline);
 		}
 		
-		return lines; // TODO find a way to add 
+		return lines; // TODO find a way to add with lazy method
 	}
 	
 	private String findAnnotationForLine(Match match, List<Annotation> annots, boolean overlap) {
@@ -174,12 +169,12 @@
 		return annotsList;
 	}
 
-	public List<Annotation> getAnnotationForMatches(List<Match> subsetMatch, boolean overlapAnnotation) {
+	public List<Annotation> getAnnotationForMatches(List<Match> subsetMatch, boolean overlapAnnotation) throws Exception {
 		
 		AnnotationManager am = KRAnnotationEngine.getAnnotationManager(concordance.getCorpus());
 		
 		//List<Annotation> allAnnotations = null;
-		List<Annotation> annotationsPerMatch = null;;
+		List<Annotation> annotationsPerMatch = new ArrayList<Annotation>();
 		if (viewAnnotation != null && am != null) {
 			try {
 				annotationsPerMatch = am.getAnnotationsForMatches(viewAnnotation, subsetMatch, overlapAnnotation);
@@ -205,6 +200,7 @@
 	 * @return the AnnotationLine pointed by 'i'. May return null if i is wrong.
 	 */
 	public AnnotationLine getAnnotationLine(Line line) {
+		if (concordanceLines == null) return null;
 		int i = concordanceLines.indexOf(line);
 		if (i < 0) return null;
 		return getAnnotationLine(i);
@@ -217,6 +213,8 @@
 	 * @return the AnnotationLine pointed by 'i'. May return null if i is wrong.
 	 */
 	public AnnotationLine getAnnotationLine(int i) {
+		if (lines == null) return null;
+		if (lines.size() == 0) return null;
 		if (lines.size() < i) return null;
 		if (i < 0) return null;
 		
Index: tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/commands/ExportStandoff.java
===================================================================
--- tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/commands/ExportStandoff.java	(revision 781)
+++ tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/commands/ExportStandoff.java	(revision 782)
@@ -93,12 +93,18 @@
 			final File resultZipFile = new File(filepath, filename);
 			LastOpened.set(ID, resultZipFile.getParent(), resultZipFile.getName());
 			
-			exportAnnotations(corpus, resultZipFile);
+			try {
+				exportAnnotations(corpus, resultZipFile);
+			} catch (Exception e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+				return null;
+			}
 		}
 		return corpus;
 	}
 
-	public static boolean exportAnnotations(final MainCorpus corpus, final File resultZipFile) {
+	public static boolean exportAnnotations(final MainCorpus corpus, final File resultZipFile) throws Exception {
 		final AnnotationManager am = KRAnnotationEngine.getAnnotationManager(corpus);
 		if (am == null) return true; // nothing to do
 		
Index: tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/commands/SaveAnnotations.java
===================================================================
--- tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/commands/SaveAnnotations.java	(revision 781)
+++ tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/commands/SaveAnnotations.java	(revision 782)
@@ -37,12 +37,18 @@
 		if (!(s instanceof MainCorpus))
 			return null;
 		MainCorpus corpus = (MainCorpus) s;
-		save(corpus);
+		try {
+			save(corpus);
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			return null;
+		}
 
 		return corpus;
 	}
 
-	public static JobHandler save(final MainCorpus corpus) {
+	public static JobHandler save(final MainCorpus corpus) throws Exception {
 		final AnnotationManager am = KRAnnotationEngine.getAnnotationManager(corpus);
 		if (am == null) return null; // nothing to do
 		
Index: tmp/org.txm.annotation.rcp/src/org/txm/rcp/tests/AnnotationLookUp.java
===================================================================
--- tmp/org.txm.annotation.rcp/src/org/txm/rcp/tests/AnnotationLookUp.java	(revision 781)
+++ tmp/org.txm.annotation.rcp/src/org/txm/rcp/tests/AnnotationLookUp.java	(revision 782)
@@ -163,7 +163,7 @@
 				}
 			}
 
-			System.out.println("============== CLean all ==============");
+			System.out.println("============== Clean all ==============");
 			am.getTemporaryManager().deleteAnnotations();
 		} catch (Exception e) {
 			// TODO Bloc catch généré automatiquement
Index: tmp/org.txm.annotation.rcp/plugin.xml
===================================================================
--- tmp/org.txm.annotation.rcp/plugin.xml	(revision 781)
+++ tmp/org.txm.annotation.rcp/plugin.xml	(revision 782)
@@ -316,7 +316,7 @@
   <extension
         point="org.txm.concordance.rcp.editors.ConcordanceEditorExtension">
      <concextension
-           class="org.txm.annotation.rcp.concordance.ConcordanceAnnotationExtension"
+           class="org.txm.annotation.rcp.concordance.KRConcordanceAnnotationExtension"
            name="Annotation">
      </concextension>
   </extension>
Index: tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditorExtension.java
===================================================================
--- tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditorExtension.java	(revision 781)
+++ tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditorExtension.java	(revision 782)
@@ -1,7 +1,11 @@
 package org.txm.concordance.rcp.editors;
 
+import java.util.List;
 
+import org.txm.concordance.core.functions.Line;
 
+
+
 /**
  * Extension point class to add a stuff to the concordance editor.
  * 
@@ -48,4 +52,6 @@
 	 * @return
 	 */
 	public abstract boolean notifyEndOfCompute() throws Exception;
+
+	public abstract void update(List<Line> lines, int from, int to) throws Exception;
 }
Index: tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java
===================================================================
--- tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java	(revision 781)
+++ tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java	(revision 782)
@@ -820,7 +820,7 @@
 		from = Math.max(from, 0);
 		
 		int to = from + concordance.getNLinePerPage() - 1;
-		to = Math.min(to, concordance.getNLines() - 1);
+		to = Math.min(to, concordance.getNLines());
 		
 		viewer.getControl().setRedraw(false);
 		viewer2.getControl().setRedraw(false);
@@ -838,6 +838,14 @@
 			lines = new ArrayList<Line>();
 		}
 
+		for (ConcordanceEditorExtension ext : extensions) {
+			try {
+				ext.update(lines, from, to);
+			} catch (Exception e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
 		viewer.setInput(lines);
 		viewer2.setInput(lines);
 
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorToolBar.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorToolBar.java	(revision 781)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorToolBar.java	(revision 782)
@@ -312,4 +312,8 @@
 			this.buttons.get(groupTitle).dispose();			
 		}
 	}
+
+	public OpenCloseButton getGroupButton(String groupTitle) {
+		return this.buttons.get(groupTitle);
+	}
 }
Index: tmp/org.txm.core/src/java/org/txm/utils/BundleUtils.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/utils/BundleUtils.java	(revision 781)
+++ tmp/org.txm.core/src/java/org/txm/utils/BundleUtils.java	(revision 782)
@@ -6,6 +6,7 @@
 import org.eclipse.core.runtime.Platform;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Version;
+import org.osgi.framework.wiring.BundleWiring;
 import org.txm.core.preferences.TBXPreferences;
 import org.txm.core.preferences.TXMPreferences;
 import org.txm.utils.io.FileCopy;
@@ -179,4 +180,16 @@
 		}
 		return path;
 	}
+
+	public static ClassLoader getLoader(String bundle_id) {
+		Bundle bundle = Platform.getBundle(bundle_id);
+		if (bundle == null) {
+			System.out.println("Error while initializing Oriflamms plugin: bundle not found.");
+			return null;
+		}
+		
+		BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
+		ClassLoader classLoader = bundleWiring.getClassLoader();
+		return classLoader;
+	}
 }
