Index: tmp/org.txm.concordance.rcp/plugin.xml
===================================================================
--- tmp/org.txm.concordance.rcp/plugin.xml	(revision 516)
+++ tmp/org.txm.concordance.rcp/plugin.xml	(revision 517)
@@ -2,7 +2,7 @@
 <?eclipse version="3.4"?>
 <plugin>
   <extension-point id="org.txm.rcp.extensionpoint.backtotext" name="Back to text" schema="schema/org.txm.rcp.extensionpoint.backtotext.exsd"/>
-  <extension-point id="org.txm.concordance.rcp.concordanceeditor.button" name="concordance column" schema="schema/org.txm.concordance.rcp.concordanceeditor.button.exsd"/>
+  <extension-point id="org.txm.concordance.rcp.editors.ConcordanceEditorExtension" name="concordance extension" schema="schema/org.txm.concordance.rcp.concordanceeditor.extension.exsd"/>
 
    <extension
          point="org.eclipse.core.runtime.adapters">
Index: tmp/org.txm.concordance.rcp/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.concordance.rcp/META-INF/MANIFEST.MF	(revision 516)
+++ tmp/org.txm.concordance.rcp/META-INF/MANIFEST.MF	(revision 517)
@@ -6,7 +6,6 @@
 Bundle-Vendor: Textometrie.org
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Require-Bundle: org.txm.searchengine.core;bundle-version="1.0.0",
- org.txm.annotation.core;bundle-version="1.0.0",
  org.eclipse.core.runtime;bundle-version="3.10.0",
  org.eclipse.ui;bundle-version="3.106.1",
  org.txm.cooccurrence.core;bundle-version="1.0.0";visibility:=reexport,
@@ -19,10 +18,11 @@
  org.txm.rcp,
  org.eclipse.core.expressions;bundle-version="3.4.600",
  org.txm.internalview.core;bundle-version="1.0.0",
- org.txm.internalview.rcp;bundle-version="1.0.0",
- org.txm.annotation.rcp;bundle-version="1.0.0"
-Export-Package: org.txm.concordance.rcp.adapters,
+ org.txm.internalview.rcp;bundle-version="1.0.0"
+Export-Package: org.txm.concordance.rcp.actions,
+ org.txm.concordance.rcp.adapters,
  org.txm.concordance.rcp.editors,
  org.txm.concordance.rcp.handlers,
+ org.txm.concordance.rcp.messages,
  org.txm.concordance.rcp.preferences,
  org.txm.concordance.rcp.widgets
Index: tmp/org.txm.concordance.rcp/schema/org.txm.concordance.rcp.concordanceeditor.button.exsd
===================================================================
--- tmp/org.txm.concordance.rcp/schema/org.txm.concordance.rcp.concordanceeditor.button.exsd	(revision 516)
+++ tmp/org.txm.concordance.rcp/schema/org.txm.concordance.rcp.concordanceeditor.button.exsd	(revision 517)
@@ -1,109 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.txm.concordance.rcp" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
-      <appinfo>
-         <meta.schema plugin="org.txm.concordance.rcp" id="org.txm.concordance.rcp.concordanceeditor.button" name="concordance column"/>
-      </appinfo>
-      <documentation>
-         Supplementary concordance bottom toolbar button
-      </documentation>
-   </annotation>
-
-   <element name="extension">
-      <annotation>
-         <appinfo>
-            <meta.element />
-         </appinfo>
-      </annotation>
-      <complexType>
-         <choice minOccurs="1" maxOccurs="unbounded">
-            <element ref="button"/>
-         </choice>
-         <attribute name="point" type="string" use="required">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-            </annotation>
-         </attribute>
-         <attribute name="id" type="string">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-            </annotation>
-         </attribute>
-         <attribute name="name" type="string">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-               <appinfo>
-                  <meta.attribute translatable="true"/>
-               </appinfo>
-            </annotation>
-         </attribute>
-      </complexType>
-   </element>
-
-   <element name="button">
-      <complexType>
-         <attribute name="class" type="string">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-               <appinfo>
-                  <meta.attribute kind="java" basedOn="org.txm.concordance.rcp.editors.ConcordanceEditorButton:"/>
-               </appinfo>
-            </annotation>
-         </attribute>
-         <attribute name="name" type="string">
-            <annotation>
-               <documentation>
-                  
-               </documentation>
-            </annotation>
-         </attribute>
-      </complexType>
-   </element>
-
-   <annotation>
-      <appinfo>
-         <meta.section type="since"/>
-      </appinfo>
-      <documentation>
-         [Enter the first release in which this extension point appears.]
-      </documentation>
-   </annotation>
-
-   <annotation>
-      <appinfo>
-         <meta.section type="examples"/>
-      </appinfo>
-      <documentation>
-         [Enter extension point usage example here.]
-      </documentation>
-   </annotation>
-
-   <annotation>
-      <appinfo>
-         <meta.section type="apiinfo"/>
-      </appinfo>
-      <documentation>
-         [Enter API information here.]
-      </documentation>
-   </annotation>
-
-   <annotation>
-      <appinfo>
-         <meta.section type="implementation"/>
-      </appinfo>
-      <documentation>
-         [Enter information about supplied implementation of this extension point.]
-      </documentation>
-   </annotation>
-
-
-</schema>
Index: tmp/org.txm.concordance.rcp/schema/org.txm.concordance.rcp.concordanceeditor.extension.exsd
===================================================================
--- tmp/org.txm.concordance.rcp/schema/org.txm.concordance.rcp.concordanceeditor.extension.exsd	(revision 0)
+++ tmp/org.txm.concordance.rcp/schema/org.txm.concordance.rcp.concordanceeditor.extension.exsd	(revision 517)
@@ -0,0 +1,109 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.txm.concordance.rcp" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="org.txm.concordance.rcp" id="org.txm.concordance.rcp.editors.ConcordanceEditorExtension" name="concordance extension"/>
+      </appinfo>
+      <documentation>
+         Supplementary concordance widgets that can be installed after the Concordance editor has set its own widgets
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appinfo>
+            <meta.element />
+         </appinfo>
+      </annotation>
+      <complexType>
+         <choice minOccurs="1" maxOccurs="unbounded">
+            <element ref="concextension"/>
+         </choice>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="concextension">
+      <complexType>
+         <attribute name="class" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn="org.txm.concordance.rcp.editors.ConcordanceEditorExtension:"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  The extension name
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="since"/>
+      </appinfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="examples"/>
+      </appinfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="apiinfo"/>
+      </appinfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="implementation"/>
+      </appinfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>

Property changes on: tmp/org.txm.concordance.rcp/schema/org.txm.concordance.rcp.concordanceeditor.extension.exsd
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/widgets/ComplexSortSelector.java
===================================================================
--- tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/widgets/ComplexSortSelector.java	(revision 516)
+++ tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/widgets/ComplexSortSelector.java	(revision 517)
@@ -228,6 +228,6 @@
 		fourthKey.select(0);
 		editor.getUserDefinedComparators().add(defaultComparator);
 		editor.setCurrentComparator(defaultComparator);
-		editor.sort();
+//		editor.sort(); // do it later 
 	}
 }
Index: tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditorButton.java
===================================================================
--- tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditorButton.java	(revision 516)
+++ tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditorButton.java	(revision 517)
@@ -1,32 +0,0 @@
-package org.txm.concordance.rcp.editors;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Button;
-
-/**
- * Extension point class to add a column to the concordance result.
- * 
- * You need to :
- * - define the ColumnLabelProvider methods
- * - set a Comparator called by the ColumnSorter
- * 
- * @author mdecorde
- *
- */
-public abstract class ConcordanceEditorButton extends Button {
-	
-	protected ConcordanceEditor editor;
-	
-	public ConcordanceEditorButton(ConcordanceEditor editor) {
-		super(editor.getExtensionButtonComposite(), SWT.PUSH);
-		this.editor = editor;
-	}
-
-	/**
-	 * 
-	 * @return the column name displayed in the concordance table widget
-	 */
-	public abstract String getName();
-	
-	public abstract boolean install();
-}
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 0)
+++ tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditorExtension.java	(revision 517)
@@ -0,0 +1,51 @@
+package org.txm.concordance.rcp.editors;
+
+
+
+/**
+ * Extension point class to add a stuff to the concordance editor.
+ * 
+ * All widgets creation are done after the editor widgets creation
+ * 
+ * @author mdecorde
+ *
+ */
+public abstract class ConcordanceEditorExtension {
+	
+	public static final String EXTENSION_ID = ConcordanceEditorExtension.class.getName();
+	protected ConcordanceEditor editor;
+	
+	public ConcordanceEditorExtension() {
+		
+	}
+
+	/**
+	 * 
+	 * @return the column name displayed in the concordance table widget
+	 */
+	public abstract String getName();
+	
+	/**
+	 * implement this command to add widgets to the concordance interface using the 2 available area : editor.getQueryArea() and editor.getDisplayArea()
+	 * @return
+	 */
+	public abstract boolean installWidgets() throws Exception;
+	
+	/**
+	 * implement this command to do something when the EditorPart.init(IEditorSite site, IEditorInput input) is called
+	 * @return
+	 */
+	public abstract boolean initialiseInput(ConcordanceEditor editor) throws Exception;
+	
+	/**
+	 * implement this command to do set something before computing the result
+	 * @return
+	 */
+	public abstract boolean notifyStartOfCompute() throws Exception;
+	
+	/**
+	 * implement this command to do set something after computing the result
+	 * @return
+	 */
+	public abstract boolean notifyEndOfCompute() throws Exception;
+}

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

Index: tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/LineLabelProvider.java
===================================================================
--- tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/LineLabelProvider.java	(revision 516)
+++ tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/LineLabelProvider.java	(revision 517)
@@ -30,9 +30,6 @@
 import org.eclipse.jface.viewers.ILabelProviderListener;
 import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.swt.graphics.Image;
-import org.txm.annotation.core.Annotation;
-import org.txm.concordance.core.functions.Line;
-import org.txm.rcp.RCPMessages;
 
 // TODO: Auto-generated Javadoc
 /**
@@ -40,7 +37,7 @@
  * 
  * @author mdecorde.
  */
-public class LineLabelProvider implements ITableLabelProvider {
+public abstract class LineLabelProvider implements ITableLabelProvider {
 
 	private ConcordanceEditor editor;
 
@@ -60,44 +57,8 @@
 	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
 	 */
 	@Override
-	public String getColumnText(Object element, int columnIndex) {
-		Line line = (Line) element;
+	public abstract String getColumnText(Object element, int columnIndex);
 
-		switch (columnIndex) {
-		case 0:
-		case 6:
-			return ""; //this is the fake column used to work around the fact that MS windows refuses to right align the 1st column  //$NON-NLS-1$
-//		case 1: // moved to the left table
-//			return line.getViewRef().toString();
-		case 1:
-			return line.leftContextToString();
-		case 2:
-			return line.keywordToString();
-		case 3:
-			if (line.getAnnotation()!=null) {
-				String value = line.getAnnotationValue().getStandardName();
-				Annotation a = line.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 "";
-			}
-		case 4:
-			return line.rightContextToString();
-		default:
-			throw new RuntimeException(RCPMessages.LineLabelProvider_1);
-		}
-
-	}
-
 	/* (non-Javadoc)
 	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
 	 */
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 516)
+++ tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java	(revision 517)
@@ -25,19 +25,19 @@
 //
 package org.txm.concordance.rcp.editors;
 
-import java.io.File;
 import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.Arrays;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Vector;
-import java.util.logging.Level;
 
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.ISafeRunnable;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SafeRunner;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.e4.ui.workbench.modeling.EModelService;
 import org.eclipse.jface.action.Action;
@@ -45,16 +45,10 @@
 import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-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.ColumnLabelProvider;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.browser.ProgressListener;
@@ -79,7 +73,6 @@
 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.Event;
@@ -90,28 +83,12 @@
 import org.eclipse.swt.widgets.ScrollBar;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorSite;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchPartSite;
-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.views.knowledgerepositories.KRView;
 import org.txm.concordance.core.functions.Concordance;
 import org.txm.concordance.core.functions.Line;
 import org.txm.concordance.core.functions.comparators.CompositeComparator;
@@ -145,15 +122,12 @@
 import org.txm.rcp.RCPMessages;
 import org.txm.rcp.StatusLine;
 import org.txm.rcp.TXMWindows;
-import org.txm.rcp.commands.OpenBrowser;
 import org.txm.rcp.editors.TXMBrowser;
 import org.txm.rcp.editors.TXMEditorPart;
 import org.txm.rcp.editors.TXMResultEditorInput;
 import org.txm.rcp.editors.TableKeyListener;
 import org.txm.rcp.preferences.RCPPreferences;
-import org.txm.rcp.swt.dialog.ConfirmDialog;
 import org.txm.rcp.swt.dialog.ViewPropertySelectionDialog;
-import org.txm.rcp.swt.provider.SimpleLabelProvider;
 import org.txm.rcp.swt.widget.AssistedQueryWidget;
 import org.txm.rcp.swt.widget.NavigationWidget;
 import org.txm.rcp.utils.JobHandler;
@@ -166,9 +140,7 @@
 import org.txm.searchengine.cqp.corpus.Corpus;
 import org.txm.searchengine.cqp.corpus.Property;
 import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
-import org.txm.searchengine.cqp.corpus.query.Match;
 import org.txm.searchengine.cqp.corpus.query.Query;
-import org.txm.utils.AsciiUtils;
 import org.txm.utils.logger.Log;
 
 /**
@@ -180,11 +152,6 @@
 
 	public static final String ID = ConcordanceEditor.class.getName();
 
-	/**
-	 * the limit number of annotation when a confirm dialog box is shown
-	 */
-	private static final int NALERTAFFECTANNOTATIONS = 100;
-
 	String locale = TXMPreferences.getString(RCPPreferences.UI_LOCALE, RCPPreferences.PREFERENCES_NODE);
 
 	/** The lineids. */
@@ -230,11 +197,7 @@
 	/** The concordance. */
 	private Concordance concordance;
 
-	/** The annotation service */
-	private AnnotationManager  annotManager;
 
-	//boolean annotation_expert_mode = TxmPreferences.getBoolean(AnnotationPreferencePage.MODE, false);
-
 	/** The standard comparator class name. */
 	private LineComparator[] standardComparatorClassName = {
 			new NullComparator(), new LexicographicKeywordComparator(),
@@ -324,31 +287,20 @@
 	/** The query area. */
 	private Composite queryArea;
 
-	/** The annotation area. */
-	private Composite annotationArea;
-
 	/** The navigation area. */
-	private NavigationWidget navigationArea;
+	private NavigationWidget navigationWidget;
 
 	/** The is setup shown. */
 	private boolean isSetupShown = true;
 
-
-	/** The hide btn. */
+	/** The hide btn: hides the form
+	 * TODO: remove the button when the TXMEditorToolbar is fully functionnal. */
 	private Button hideBtn;
 	private Button deleteLineButton;
 
 	/** The query size. */
 	protected Point querySize;
 
-	protected Point annotationSize;
-
-	/** The annot btn. */
-	private Button annotationButton;
-
-	private Text annotationValuesText;
-	private ComboViewer annotationTypesCombo;
-
 	/** The parent. */
 	private Composite parent;
 
@@ -356,19 +308,9 @@
 
 	private ArrayList<Property> availableRightSortProperties;
 
-	private List<TypedValue> typeValuesList;
-
-	protected Point annotSize;
-
-	private TableColumn annotationColumn;
-
-	private Combo addRemoveCombo;
-	private Combo affectCombo;
-	private Button affectAnnotationButton;
-
-	private Button infosAnnotTypeSelectedLink;
-
 	private Sash sash;
+	
+	HashSet<ConcordanceEditorExtension> extensions = new HashSet<ConcordanceEditorExtension>();
 
 	/* (non-Javadoc)
 	 * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
@@ -414,8 +356,41 @@
 			throws PartInitException {
 		setSite(site);
 		setInput(input);
-
+		
 		initializeEditor();
+		
+		// fetch extensions
+		IConfigurationElement[] config = Platform.getExtensionRegistry()
+				.getConfigurationElementsFor(ConcordanceEditorExtension.EXTENSION_ID);
+		Log.warning("Installing ConcordanceEditorExtension...");
+		Log.warning(Arrays.toString(config));
+		
+		for (IConfigurationElement e : config) {
+			try {
+				Log.warning(" "+e.getName()+" from "+e.getContributor().getName());
+				final Object o = e.createExecutableExtension("class"); //$NON-NLS-1$
+				if (o instanceof ConcordanceEditorExtension) {
+					ISafeRunnable runnable = new ISafeRunnable() {
+
+						@Override
+						public void handleException(Throwable exception) {
+							System.out.println("Error while installing: "+o+": "+ exception.getLocalizedMessage());
+						}
+
+						@Override
+						public void run() throws Exception {
+							ConcordanceEditorExtension ext = ((ConcordanceEditorExtension) o);
+							if (ext.initialiseInput(ConcordanceEditor.this)) {
+								extensions.add(ext);
+							}
+						}
+					};
+					SafeRunner.run(runnable);
+				}
+			} catch (Exception ex) {
+				System.out.println("Exception while installing "+e.getName()+": "+ex.getLocalizedMessage());
+			}
+		}
 	}
 
 	private void initializeEditor() throws PartInitException {
@@ -427,7 +402,6 @@
 		}
 		this.concordance = (Concordance)result;
 		this.corpus = concordance.getCorpus();
-		this.annotManager = KRAnnotationEngine.getAnnotationManager(corpus);
 
 		this.standardComparators = new ArrayList<LineComparator>();
 		this.userDefinedComparators = new ArrayList<LineComparator>();
@@ -484,12 +458,41 @@
 		try {
 			composeControlArea(controlArea);
 			composeDisplayArea(getDisplayArea());
+			composeExtraAreas(controlArea, getDisplayArea());
+			// finally set the sorter to fill the tables
+			if (complexsorter != null) {
+				complexsorter.setComparators(this);
+			}
+			
+			fillDisplayArea(topLine, bottomLine); // init columns and show first results if any
+			resetColumnWidths();
+			
 		} catch(Exception e) {
 			System.out.println("Error while building interface: "+e.getLocalizedMessage());
 			Log.printStackTrace(e);
 		}
 	}
 
+	private void composeExtraAreas(Composite controlArea, Composite displayArea) {
+		
+		for (final ConcordanceEditorExtension ext : extensions) {
+			ISafeRunnable runnable = new ISafeRunnable() {
+				@Override
+				public void handleException(Throwable exception) {
+					System.out.println("Error while installing: "+ext+": "+ exception.getLocalizedMessage());
+				}
+
+				@Override
+				public void run() throws Exception {
+					if (!ext.installWidgets()) {
+						extensions.remove(ext);
+					}
+				}
+			};
+			SafeRunner.run(runnable);
+		}
+	}
+
 	/**
 	 * Compose display area.
 	 *
@@ -504,20 +507,16 @@
 		viewer2.setLabelProvider(new LineLabelProvider(this) {
 			@Override
 			public String getColumnText(Object element, int columnIndex) {
-				if (columnIndex == 1) {
 					Line line = (Line) element;
 					return line.getViewRef().toString();
-				} else {
-					return "";
-				}
 			}
 		});
 		viewer2.setContentProvider(new ConcordancesProvider());
 		viewer2.getTable().setLinesVisible(true);
 		viewer2.getTable().setHeaderVisible(true);
 
-		firstColumn = new TableColumn(viewer2.getTable(), SWT.LEFT);
-		firstColumn.setWidth(0);
+//		firstColumn = new TableColumn(viewer2.getTable(), SWT.LEFT);
+//		firstColumn.setWidth(10);
 
 		referenceColumn = new TableColumn(viewer2.getTable(), SWT.LEFT);
 		refreshReferenceColumnTitle();
@@ -549,10 +548,7 @@
 			}
 		});
 		referenceColumn.setWidth(100);
-		
-		firstColumn = new TableColumn(viewer2.getTable(), SWT.LEFT);
-		firstColumn.setWidth(0);
-		
+				
 		sash = new Sash(displayArea, SWT.VERTICAL);
 		sash.addSelectionListener(new SelectionAdapter() {
 		      public void widgetSelected(SelectionEvent event) {
@@ -562,7 +558,7 @@
 		    });
 		viewer = new TableViewer(displayArea, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.VIRTUAL);
 		viewer.getTable().addKeyListener(new TableKeyListener(viewer));
-		viewer.setLabelProvider(new LineLabelProvider(this));
+		//viewer.setLabelProvider(new LineLabelProvider(this));
 		viewer.setContentProvider(new ConcordancesProvider());
 		viewer.getTable().setLinesVisible(true);
 		viewer.getTable().setHeaderVisible(true);
@@ -575,6 +571,7 @@
 			viewer2.getTable().setFont(font);
 		}
 
+		// try to center on keyword column
 		viewer.getTable().addListener(SWT.Resize, new Listener() {
 			@Override
 			public void handleEvent(Event event) {
@@ -603,13 +600,22 @@
 		viewer.getTable().addKeyListener(kldelete);
 		viewer2.getTable().addKeyListener(kldelete);
 
-		firstColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
-		firstColumn.setWidth(0);
+//		firstColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
+//		firstColumn.setWidth(0);
+//		firstColumn.setResizable(false);
 
-		leftContextColumn = new TableColumn(viewer.getTable(), SWT.RIGHT);
+		TableViewerColumn leftColumnViewer = new TableViewerColumn(viewer, SWT.RIGHT);
+		leftContextColumn = leftColumnViewer.getColumn();
 		leftContextColumn.setText(Messages.ConcordancesEditor_2);
 		leftContextColumn.setToolTipText(Messages.ConcordancesEditor_2);
 		leftContextColumn.setAlignment(SWT.RIGHT);
+		leftColumnViewer.setLabelProvider(new ColumnLabelProvider() {
+			@Override
+			public String getText(Object element) {
+				Line line = (Line) element;
+				return line.leftContextToString();
+			}
+		});
 		leftContextColumn.addSelectionListener(new SelectionListener() {
 			@Override
 			public void widgetSelected(SelectionEvent e) {
@@ -635,10 +641,18 @@
 			}
 		});
 
-		keywordColumn = new TableColumn(viewer.getTable(), SWT.CENTER);
+		TableViewerColumn keywordColumnViewer = new TableViewerColumn(viewer, SWT.CENTER);
+		keywordColumn = keywordColumnViewer.getColumn();
 		keywordColumn.setText(Messages.ConcordancesEditor_3);
 		keywordColumn.setToolTipText(Messages.ConcordancesEditor_3);
 		keywordColumn.setAlignment(SWT.CENTER);
+		keywordColumnViewer.setLabelProvider(new ColumnLabelProvider() {
+			@Override
+			public String getText(Object element) {
+				Line line = (Line) element;
+				return line.keywordToString();
+			}
+		});
 		keywordColumn.addSelectionListener(new SelectionListener() {
 			@Override
 			public void widgetSelected(SelectionEvent e) {
@@ -664,15 +678,19 @@
 			}
 		});
 
-		annotationColumn = new TableColumn(viewer.getTable(), SWT.CENTER);
-		annotationColumn.setText(Messages.ConcordancesEditor_15);
-		annotationColumn.setToolTipText(Messages.ConcordancesEditor_17);
-		annotationColumn.setAlignment(SWT.CENTER);
-
-		rightContextColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
+		
+		TableViewerColumn rightContextColumnViewer = new TableViewerColumn(viewer, SWT.LEFT);
+		rightContextColumn = rightContextColumnViewer.getColumn();
 		rightContextColumn.setText(Messages.ConcordancesEditor_4);
 		rightContextColumn.setToolTipText(Messages.ConcordancesEditor_4);
 		rightContextColumn.setAlignment(SWT.LEFT);
+		rightContextColumnViewer.setLabelProvider(new ColumnLabelProvider() {
+			@Override
+			public String getText(Object element) {
+				Line line = (Line) element;
+				return line.rightContextToString();
+			}
+		});
 		rightContextColumn.addSelectionListener(new SelectionListener() {
 			@Override
 			public void widgetSelected(SelectionEvent e) {
@@ -699,28 +717,36 @@
 			}
 		});
 
-		resetColumnWidths(); // set column widths
+//		firstColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
+//		firstColumn.setWidth(0);
+//		firstColumn.setResizable(false);
+		
+		leftContextColumn.setWidth(200);
+		keywordColumn.setWidth(100);
+		rightContextColumn.setWidth(200);
+		
+		//resetColumnWidths(); // set column widths
 
 		createContextMenu();
 
-		// And now, a sweet piece of code :)
-		// When the window is resized, the scrollbar is adjusted so that the
-		// keywords remain centered
-		viewer.getTable().addListener(SWT.Resize, new Listener() {
-			@Override
-			public void handleEvent(Event event) {
-				ScrollBar bar = viewer.getTable().getHorizontalBar();
-				//float l = leftContextColumn.getWidth();
-				//float k = keywordColumn.getWidth();
-				rightContextColumn.getWidth();
-				//float t = lineTableViewer.getTable().getClientArea().width;
-				bar.getMaximum();
-				bar.getThumb();
-			}
-		});
+//		// And now, a sweet piece of code :)
+//		// When the window is resized, the scrollbar is adjusted so that the
+//		// keywords remain centered
+//		viewer.getTable().addListener(SWT.Resize, new Listener() {
+//			@Override
+//			public void handleEvent(Event event) {
+//				ScrollBar bar = viewer.getTable().getHorizontalBar();
+//				//float l = leftContextColumn.getWidth();
+//				//float k = keywordColumn.getWidth();
+//				rightContextColumn.getWidth();
+//				//float t = lineTableViewer.getTable().getClientArea().width;
+//				bar.getMaximum();
+//				bar.getThumb();
+//			}
+//		});
 
 		// back to text mouse listener
-		viewer.getTable().addMouseListener(new MouseListener() {
+		MouseListener ms = new MouseListener() {
 			@Override
 			public void mouseDoubleClick(MouseEvent e) {
 				StatusLine.setMessage(Messages.ConcordancesEditor_50);
@@ -732,8 +758,10 @@
 			public void mouseDown(MouseEvent e) { }
 			@Override
 			public void mouseUp(MouseEvent e) {	}
-		});
-
+		};
+		viewer.getTable().addMouseListener(ms);
+		viewer2.getTable().addMouseListener(ms);
+		
 		// On Windows, the selection is gray if the table does not have focus.
 		// To make both tables appear in focus, draw the selection background
 		// here.
@@ -756,52 +784,11 @@
 		};
 
 		// Listeners to avoid 0 width columns
-		referenceColumn.addControlListener(new ControlListener() {
-			@Override
-			public void controlMoved(ControlEvent e) { }
-			@Override
-			public void controlResized(ControlEvent e) {
-				if (referenceColumn.getWidth() < 5) referenceColumn.setWidth(5);
+		referenceColumn.addControlListener(new ConcordanceColumnSizeControlListener(referenceColumn));
+		leftContextColumn.addControlListener(new ConcordanceColumnSizeControlListener(leftContextColumn));
+		keywordColumn.addControlListener(new ConcordanceColumnSizeControlListener(keywordColumn));
+		rightContextColumn.addControlListener(new ConcordanceColumnSizeControlListener(rightContextColumn));
 
-			}
-		});
-		leftContextColumn.addControlListener(new ControlListener() {
-			@Override
-			public void controlMoved(ControlEvent e) { }
-			@Override
-			public void controlResized(ControlEvent e) {
-				if (leftContextColumn.getWidth() < 5) leftContextColumn.setWidth(5);
-
-			}
-		});
-		keywordColumn.addControlListener(new ControlListener() {
-			@Override
-			public void controlMoved(ControlEvent e) { }
-			@Override
-			public void controlResized(ControlEvent e) {
-				if (keywordColumn.getWidth() < 5) keywordColumn.setWidth(5);
-
-			}
-		});
-		annotationColumn.addControlListener(new ControlListener() {
-			@Override
-			public void controlMoved(ControlEvent e) { }
-			@Override
-			public void controlResized(ControlEvent e) {
-				if (annotationArea != null && annotationColumn.getWidth() < 5) annotationColumn.setWidth(5);
-
-			}
-		});
-		rightContextColumn.addControlListener(new ControlListener() {
-			@Override
-			public void controlMoved(ControlEvent e) { }
-			@Override
-			public void controlResized(ControlEvent e) {
-				if (rightContextColumn.getWidth() < 5) rightContextColumn.setWidth(5);
-
-			}
-		});
-
 		viewer.getTable().addListener(SWT.EraseItem, eraseListener);
 		
 		leftTable = viewer2.getTable();
@@ -944,27 +931,19 @@
 
 		viewer.setInput(lines);
 		viewer2.setInput(lines);
-//		referenceColumn.pack();
-		leftContextColumn.pack();
-		keywordColumn.pack();
-		rightContextColumn.pack();
-		viewer.getTable().pack(true);
-		viewer.getTable().getParent().layout();
-//		viewer2.getTable().pack(true);
-		viewer2.getTable().getParent().layout();
 
 		topLine = from;
 		bottomLine = to;
 
-		navigationArea.setInfoLineText(""+(from + 1), //$NON-NLS-1$
+		navigationWidget.setInfoLineText(""+(from + 1), //$NON-NLS-1$
 				" - "+(to + 1) + " / " + concordance.getNLines()); //$NON-NLS-1$ //$NON-NLS-2$
 
-		navigationArea.setPreviousEnabled(topLine > 0);
-		navigationArea.setFirstEnabled(topLine > 0);
-		navigationArea.setNextEnabled(bottomLine < concordance.getNLines() - 1);
-		navigationArea.setLastEnabled(bottomLine < concordance.getNLines() - 1);
-		navigationArea.layout();
-		navigationArea.getParent().layout();
+		navigationWidget.setPreviousEnabled(topLine > 0);
+		navigationWidget.setFirstEnabled(topLine > 0);
+		navigationWidget.setNextEnabled(bottomLine < concordance.getNLines() - 1);
+		navigationWidget.setLastEnabled(bottomLine < concordance.getNLines() - 1);
+		navigationWidget.layout();
+		navigationWidget.getParent().layout();
 
 		refreshReferenceColumnTitle();
 
@@ -972,22 +951,7 @@
 		viewer2.getControl().setRedraw(true);
 	}
 
-	HashMap<AnnotationType, ArrayList<TypedValue>> history = new HashMap<AnnotationType, ArrayList<TypedValue>>();
 
-	private Button addAnnotationTypeLink;
-
-	private KnowledgeRepository currentKnowledgeRepository = null;
-	Vector<AnnotationType> typesList = new Vector<AnnotationType>(); 
-
-	private Button addTypedValueLink;
-
-	private Label withLabel;
-
-	private AnnotationType tagAnnotationType; // the tag annotation type if annotation mode is simple
-
-	private Label equalLabel;
-	Boolean advanced_annotation_mode = false;
-
 	private Table leftTable;
 
 	private Table rightTable;
@@ -996,649 +960,32 @@
 
 	private ScrollBar vBarRight;
 
-	private void composeAnnotationArea(final Composite parent){ 
-		advanced_annotation_mode = "advanced".equals(TXMPreferences.getString(AnnotationPreferences.ANNOTATION_MODE, RCPPreferences.PREFERENCES_NODE));
+	private Label queryLabel;
 
-		List<KnowledgeRepository> krs = InitializeKnowledgeRepository.get(corpus.getMainCorpus());
-		typesList.clear();
-		Log.warning("Corpus KRs: "+krs); //$NON-NLS-1$
+	private Composite navigationArea;
 
-		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(locale, "ConcordancesEditor_22");
-		if (affectLabel == null) affectLabel= Messages.ConcordancesEditor_22;
-		String removeLabel = currentKnowledgeRepository.getString(locale, "ConcordancesEditor_24");
-		if (removeLabel == null) removeLabel= Messages.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(locale, "ConcordancesEditor_83");
-					if (withLabelText == null) withLabelText= Messages.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(locale, "ConcordancesEditor_83");
-		if (withLabelText == null) withLabelText= Messages.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(RCPMessages.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) {
-						concordance.setViewAnnotation(type);
-						concordance.setAnnotationOverlap(true);
-						fillDisplayArea(topLine, bottomLine);
-					}
-
-					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 = 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(Messages.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(), Messages.ConcordancesEditor_82, Messages.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) {
-									concordance.setViewAnnotation(type);
-									concordance.setAnnotationOverlap(true);
-									fillDisplayArea(topLine, bottomLine);
-								}
-								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(locale, "ConcordancesEditor_80");
-			if (valueLabelText == null) valueLabelText= Messages.ConcordancesEditor_80;
-			valueLabel.setText(valueLabelText);
-			valueLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
-		}
-
-		annotationValuesText = new Text(annotationArea, SWT.BORDER);
-		annotationValuesText.setToolTipText(Messages.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(viewer.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(RCPMessages.AnnotationPreferences_2)) {
-				addTypedValueLink.setToolTipText(Messages.ConcordancesEditor_79);
-			}else {
-				addTypedValueLink.setToolTipText(Messages.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(RCPMessages.AnnotationPreferences_2)) {
-						String title = currentKnowledgeRepository.getString(locale, "ConcordancesEditor_100");
-						if (title == null) title = Messages.ConcordancesEditor_100;
-						dialog.setTitle(Messages.bind(title, type.getName()));//+"valeurs de "+type.getName());
-					}else {
-						dialog.setTitle(Messages.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[] = {Messages.ConcordancesEditor_35, Messages.ConcordancesEditor_42, Messages.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(Messages.ConcordancesEditor_85);
-		affectAnnotationButton.setToolTipText(Messages.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(viewer.getSelection());
-				} else if (isel == 1) { // page
-					try {
-						List<Match> matches = concordance.getMatches().subList(topLine, bottomLine+1);
-						affectMatchesToSelection(matches);
-					} catch (CqiClientException e1) {
-						Log.severe(Messages.ConcordancesEditor_53+e1);
-						Log.printStackTrace(e1);
-						return;
-					}
-				} else { // all
-					try {
-						List<Match> matches = concordance.getMatches();
-						affectMatchesToSelection(matches);
-					} catch (CqiClientException e1) {
-						Log.severe(Messages.ConcordancesEditor_53+e1);
-						Log.printStackTrace(e1);
-						return;
-					}
-				}
-			}
-
-			@Override
-			public void widgetDefaultSelected(SelectionEvent e) { }
-		});
-		Button cancelAnnotateButton = new Button(annotationArea, SWT.PUSH);
-		cancelAnnotateButton.setText(Messages.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(Messages.ConcordancesEditor_75);
-				annotationButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL));
-				annotationColumn.setWidth(0);
-				annotationColumn.setResizable(false);
-			}
-
-			@Override
-			public void widgetDefaultSelected(SelectionEvent e) { }
-		});
-
-
-		updateAnnotationWidgetStates();
-		
-		
-
-		parent.layout();
+	/**
+	 * Get the Composite that contains the query and sort forms
+	 * 
+	 * GridLayout with 4 columns
+	 * 
+	 * @return
+	 */
+	public Composite getQueryArea() {
+		return queryArea;
 	}
-
-	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);
+	
+	/**
+	 * Get the Composite that contains the navigation buttons
+	 * 
+	 * GridLayout with 7 columns
+	 * 
+	 * @return
+	 */
+	public Composite getNavigationArea() {
+		return queryArea;
 	}
-
-	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(Messages.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(Messages.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(RCPMessages.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(topLine, bottomLine);
-				} else {
-					return;
-				}
-			} catch (Exception e1) {
-				System.out.println(Messages.ConcordancesEditor_54+e1);
-				Log.printStackTrace(e1);
-				return;
-			}
-
-			job.syncExec(new Runnable() {
-				@Override
-				public void run() {
-					fillDisplayArea(topLine, bottomLine+1);
-					CorporaView.refreshObject(corpus);
-				}
-			});
-		}
-	}
-
-	TypedValue value_to_add;
-	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$
-							Messages.ConcordancesEditor_86, 
-							Messages.ConcordancesEditor_87+matches.size()+Messages.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(Messages.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(locale, "ConcordancesEditor_110");
-					String content = kr.getString(locale, "ConcordancesEditor_112");
-					if (title == null ) title = Messages.ConcordancesEditor_110;
-					if (content == null ) content = Messages.ConcordancesEditor_112;
-					ConfirmDialog dialog = new ConfirmDialog(Display.getCurrent().getActiveShell(), 
-							"create_value", //$NON-NLS-1$
-							Messages.bind(title, svalue, type.getName()),  
-							Messages.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 = Messages.bind(Messages.ConcordancesEditor_58, svalue);
-					System.out.println(mess);
-					MessageDialog.openError(Display.getCurrent().getActiveShell(), "Annotation canceled", mess); //$NON-NLS-1$
-				}
-			});
-			return;
-		}
-
-		Log.info(Messages.ConcordancesEditor_59+value_to_add+Messages.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 = Messages.ConcordancesEditor_61+value_to_add.getStandardName()+
-						Messages.ConcordancesEditor_62;
-				for (Match m : existingAnnots.keySet()) {
-					message += Messages.ConcordancesEditor_63+m+Messages.ConcordancesEditor_64;
-
-					for (Annotation existingAnnot : existingAnnots.get(m)) {
-						if (existingAnnot.getStart() < m.getStart()){
-							message += Messages.ConcordancesEditor_65+existingAnnot.getType()+Messages.ConcordancesEditor_66+existingAnnot.getStart()+Messages.ConcordancesEditor_67+existingAnnot.getEnd()+Messages.ConcordancesEditor_68;
-						} else {
-							message += Messages.ConcordancesEditor_69+existingAnnot.getType()+Messages.ConcordancesEditor_70+existingAnnot.getStart()+Messages.ConcordancesEditor_71+existingAnnot.getEnd()+Messages.ConcordancesEditor_72;
-						}
-					}
-				}
-				final String final_message = message;
-				job.syncExec(new Runnable() {
-					@Override
-					public void run() {
-						MessageDialog.openInformation(getSite().getShell(), Messages.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(topLine, bottomLine+1);
-		} catch (Exception e1) {
-			System.out.println(Messages.ConcordancesEditor_74+e1);
-			Log.printStackTrace(e1);
-			return;
-		}
-
-		job.syncExec(new Runnable() {
-			@Override
-			public void run() {
-				fillDisplayArea(topLine, bottomLine+1);
-				CorporaView.refreshObject(corpus);
-			}
-		});
-
-	}
-
+	
 	/**
 	 * Compose control area.
 	 *
@@ -1660,18 +1007,18 @@
 		//composeAnnotationArea(controlArea);
 		//////////////////////////////////
 
-		Composite navigationPanel = new Composite(controlArea, SWT.NONE);
-		navigationPanel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
+		navigationArea = new Composite(controlArea, SWT.NONE);
+		navigationArea.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
 		GridLayout navigationLayout = new GridLayout(7, false); 
 		navigationLayout.verticalSpacing = 0;
 		navigationLayout.marginWidth = 0;
 		navigationLayout.marginHeight = 0;
-		navigationPanel.setLayout(navigationLayout);
+		navigationArea.setLayout(navigationLayout);
 		///////////////////////////
 		// | Query: [ (v)] [Search] |
 
 		// Query:
-		Label queryLabel = new Label(queryArea, SWT.NONE);
+		queryLabel = new Label(queryArea, SWT.NONE);
 		queryLabel.setText(RCPMessages.CreateSubcorpusDialog_10);
 		queryLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
 				false));
@@ -1765,7 +1112,7 @@
 				true, 4, 1));
 
 		// Delete line button
-		deleteLineButton = new Button(navigationPanel, SWT.PUSH);
+		deleteLineButton = new Button(navigationArea, SWT.PUSH);
 		deleteLineButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false,
 				false));
 		deleteLineButton.setToolTipText(Messages.ConcordancesEditor_88);
@@ -1781,67 +1128,13 @@
 		});
 
 
-		if (KRAnnotationEngine.getKnowledgeRepositoryNames(corpus).size() > 0) { // shown only if corpus has a registered KR
-
-			annotationButton = new Button(navigationPanel, SWT.PUSH);
-			annotationButton.setToolTipText(Messages.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(Messages.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);
-						parent.layout();
-
-						if (concordance != null) {
-							AnnotationType type = getSelectedAnnotationType();
-							if (type != null) {
-								concordance.setViewAnnotation(type);
-								concordance.setAnnotationOverlap(true);
-								fillDisplayArea(topLine, bottomLine+1);
-							}
-						}
-
-						CorporaView.refreshObject(corpus);
-					}
-				}
-
-				@Override
-				public void widgetDefaultSelected(SelectionEvent e) {	}
-			});
-		}
 		// Navigation Area: infoLine and buttons
-		navigationArea = new NavigationWidget(navigationPanel, SWT.NONE);
-		navigationArea.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, false, 4, 1));
+		navigationWidget = new NavigationWidget(navigationArea, SWT.NONE);
+		navigationWidget.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, false, 4, 1));
 
 		// | [|<] [<] infos [>] [>|] |
 		// [|<]
-		navigationArea.addFirstListener(new SelectionListener() {
+		navigationWidget.addFirstListener(new SelectionListener() {
 			@Override
 			public void widgetDefaultSelected(SelectionEvent arg0) {
 			}
@@ -1853,7 +1146,7 @@
 		});
 
 		// [<]
-		navigationArea.addPreviousListener(new SelectionListener() {
+		navigationWidget.addPreviousListener(new SelectionListener() {
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {
 			}
@@ -1869,7 +1162,7 @@
 		});
 
 		// [>]
-		navigationArea.addNextListener(new SelectionListener() {
+		navigationWidget.addNextListener(new SelectionListener() {
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {
 			}
@@ -1881,7 +1174,7 @@
 		});
 
 		// [>|]
-		navigationArea.addLastListener(new SelectionListener() {
+		navigationWidget.addLastListener(new SelectionListener() {
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {
 			}
@@ -1894,7 +1187,7 @@
 				//fillDisplayArea(concordance.getNLines() - 1 - nLinePerPage,concordance.getNLines() - 1);
 			}
 		});
-		hideBtn = new Button(navigationPanel, SWT.PUSH);
+		hideBtn = new Button(navigationArea, SWT.PUSH);
 		hideBtn.setText(Messages.ConcordancesEditor_38);
 		hideBtn.addSelectionListener(new SelectionListener() {
 			@Override
@@ -1944,8 +1237,8 @@
 		//		}
 
 		queryArea.layout();
-		if (complexsorter != null)
-			complexsorter.setComparators(this);
+		
+
 	}
 
 	/**
@@ -1980,14 +1273,6 @@
 					leftContextSize, rightContextSize);
 			concordance.setCQLSeparator(cql_limit);
 
-			if (annotationArea != null) {
-				AnnotationType type = getSelectedAnnotationType();
-				if (type != null) {
-					concordance.setViewAnnotation(type);
-					concordance.setAnnotationOverlap(true);
-				}
-			}
-
 			concordance.compute(null);
 
 			StatusLine.setMessage(NLS.bind(Messages.ConcordancesEditor_19, concordance.getNLines()));
@@ -2019,8 +1304,6 @@
 
 			resetColumnWidths();
 
-			updateAnnotationWidgetStates();
-
 			JobsTimer.stopAndPrint();
 
 		} catch (Exception e1) {
@@ -2193,6 +1476,7 @@
 			//fillDisplayArea(top, bottom); // we return to the previously
 
 			// displayed page
+			this.resetLeftTableColumnWidths();
 		}
 	}
 
@@ -2254,6 +1538,7 @@
 				//				System.out.println("Col: "+getPointedColumn());
 			}
 		});
+		
 		MenuManager menuManager = new MenuManager(); //$NON-NLS-1$
 		Menu menu = menuManager.createContextMenu(viewer.getTable());
 		menuManager.setRemoveAllWhenShown(true);
@@ -2262,25 +1547,32 @@
 			public void menuAboutToShow(IMenuManager manager) {
 				IWorkbenchPartSite site = ConcordanceEditor.this.getSite();
 				site.getPage().activate(ConcordanceEditor.this);
-				// manager.add(computeCoocAction);
-
-				//manager.add(computeIndexAction);
-				manager.add(defineViewReferencePatternAction);
-				manager.add(defineSortReferencePatternAction);
 				manager.add(setViewPropertyAction);
 				manager.add(setSortPropertyAction);
 				manager.add(new Separator());
-				//manager.add(complexSortAction);
 				manager.add(setContextSizeAction);
-				//manager.add(resetColumnWidths); // don't work properly
 				manager.add(setLineNumberAction);
 				manager.add(new Separator());
-				//manager.add(backToTextAction);
 			}
 		});
-
-		//viewer.getTable().setMenu(menuManager.createContextMenu(viewer.getTable()));
 		viewer.getTable().setMenu(menu);
+		
+		MenuManager menuManagerLeft = new MenuManager(); //$NON-NLS-1$
+		Menu menuLeft = menuManagerLeft.createContextMenu(viewer2.getTable());
+		menuManagerLeft.setRemoveAllWhenShown(true);
+		menuManagerLeft.addMenuListener(new IMenuListener() {
+			@Override
+			public void menuAboutToShow(IMenuManager manager) {
+				IWorkbenchPartSite site = ConcordanceEditor.this.getSite();
+				site.getPage().activate(ConcordanceEditor.this);
+				manager.add(defineViewReferencePatternAction);
+				manager.add(defineSortReferencePatternAction);
+			}
+		});
+		viewer2.getTable().setMenu(menuLeft);
+		
+		//viewer.getTable().setMenu(menuManager.createContextMenu(viewer.getTable()));
+		//register the right menu to the editor site
 		getSite().registerContextMenu(menuManager, viewer);
 		getSite().setSelectionProvider(viewer);
 	}
@@ -2861,33 +2153,61 @@
 		//		}
 	}
 
-	public boolean isAnnotationEnable() {
-		return annotationArea != null;
+	public void resetLeftTableColumnWidths() {
+		
+		int refMax = referenceColumn.getText().length();
+		for (TableItem item : viewer2.getTable().getItems()) {
+			if (refMax < item.getText(0).length()) refMax = item.getText(0).length();
+		}
+		
+		//System.out.println("Size="+queryLabel.getSize().x +" label="+queryLabel.getText()+" l size"+ queryLabel.getText().length());
+		float W = 1f+(float)(queryLabel.getSize().x / (float)queryLabel.getText().length());
+		//System.out.println("W= "+W+" Maxs "+refMax+ " " +leftMax+" " +keywordMax+" "+rightMax);
+		
+		((FormData) sash.getLayoutData()).left = new FormAttachment(0, 25+(int) (refMax*W));
+		referenceColumn.setWidth(2*(int) (refMax*W));
+		displayArea.layout(true, true);
 	}
-
-	public void resetColumnWidths() {
-
-		//		tableLayout.setColumnData(referenceColumn, new ColumnWeightData(10, true)); 
-		//		tableLayout.setColumnData(leftContextColumn, new ColumnWeightData(50, true));  
-		//		tableLayout.setColumnData(keywordColumn, new ColumnWeightData(10, true)); 
-		//		tableLayout.setColumnData(rightContextColumn, new ColumnWeightData(50, true));  
-		if (annotationArea != null) {
-			annotationColumn.pack();
-
-			annotationColumn.setResizable(true);
-			//			tableLayout.setColumnData(annotationColumn, new ColumnWeightData(10, true));
-		} else { 
-			annotationColumn.setWidth(0);
-			//			tableLayout.setColumnData(annotationColumn, new ColumnWeightData(0, false));
+	
+	/*
+	 * 
+	 */
+	public void resetRightTableColumnWidths() {
+		
+		float W = 1f+(float)(queryLabel.getSize().x / (float)queryLabel.getText().length());
+		
+		TableColumn[] columns = viewer.getTable().getColumns();
+		for (int i = 0 ; i < columns.length ; i++) {
+			TableColumn column = columns[i];
+			if (column.getWidth() == 0) continue; // skip closed columns
+			
+			int max = column.getText().length();
+			if (max == 0) continue; // skip no-title columns
+			
+			int n = 0;
+			for (TableItem item : viewer.getTable().getItems()) {
+				if (max < item.getText(i).length()) max = item.getText(i).length();
+				if (n++ > 100) break; // stop testing after 100 lines
+			}
+			
+			column.setWidth(15+(int) (max*W));
 		}
-//
-//		referenceColumn.pack();
-//		leftContextColumn.pack();
-//		keywordColumn.pack();
-//		rightContextColumn.pack();
 
-		//viewer.getTable().layout(true, true);
+		viewer.getTable().layout(true, true);
 	}
+	
+	/**
+	 * Computes the column widths using the max length of each column (title+lines)
+	 * 
+	 * Use this method after recomputing a result
+	 * 
+	 * The characters width is estimated using the queryLabel length
+	 */
+	public void resetColumnWidths() {
+		resetLeftTableColumnWidths();
+		resetRightTableColumnWidths();
+		
+	}
 
 	@Override
 	public boolean isResultUsingParent(TXMResult parent) {
@@ -2993,4 +2313,28 @@
 		// TODO Auto-generated method stub
 		return null;
 	}
+	
+	/**
+	 * ControlerListener to maintain the width of a TableColumn superior to 5
+	 * 
+	 * @author mdecorde
+	 *
+	 */
+	public static class ConcordanceColumnSizeControlListener implements ControlListener {
+		private TableColumn column;
+		public ConcordanceColumnSizeControlListener(TableColumn column) {
+			this.column = column;
+		}
+		@Override
+		public void controlMoved(ControlEvent e) { }
+		@Override
+		public void controlResized(ControlEvent e) {
+			if (column != null && !column.isDisposed() &&column.getWidth() < 5) column.setWidth(5);
+
+		}
+	}
+
+	public String getLocale() {
+		return locale;
+	}
 }
Index: tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/actions/DefineViewReferencePattern.java
===================================================================
--- tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/actions/DefineViewReferencePattern.java	(revision 516)
+++ tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/actions/DefineViewReferencePattern.java	(revision 517)
@@ -127,6 +127,7 @@
 				concordanceEditor.setRefViewPattern(new ReferencePattern(d
 						.getSelectesdReferenceItems()));
 			//System.out.println(concordanceEditor.getViewReferencePattern());
+			
 		}
 	}
 
Index: tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/actions/ViewPropertySelection.java
===================================================================
--- tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/actions/ViewPropertySelection.java	(revision 516)
+++ tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/actions/ViewPropertySelection.java	(revision 517)
@@ -135,5 +135,7 @@
 			concordanceEditor.setKeywordViewProperties(selectedViewProperties);
 			break;
 		}
+		
+		concordanceEditor.resetRightTableColumnWidths();
 	}
 }
Index: tmp/org.txm.rcp.feature/feature.xml
===================================================================
--- tmp/org.txm.rcp.feature/feature.xml	(revision 516)
+++ tmp/org.txm.rcp.feature/feature.xml	(revision 517)
@@ -84,64 +84,36 @@
          version="0.0.0"/>
 
    <requires>
-      <import plugin="org.eclipse.persistence.jpa" version="2.6.0" match="greaterOrEqual"/>
-      <import plugin="org.eclipse.persistence.jpa.jpql" version="2.6.0" match="greaterOrEqual"/>
-      <import plugin="javax.persistence" version="2.1.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.utils" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.eclipse.osgi" version="3.10.2" match="greaterOrEqual"/>
-      <import plugin="org.txm.core" version="0.7.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.searchengine.core" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.eclipse.ui.workbench"/>
-      <import plugin="org.txm.statsengine.r.core" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.statsengine.core" version="1.0.0" match="greaterOrEqual"/>
       <import plugin="org.eclipse.core.runtime" version="3.10.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.chartsengine.r.core" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.chartsengine.jfreechart.core" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.searchengine.cqp.core" version="1.1.0" match="greaterOrEqual"/>
+      <import plugin="org.txm.lexicaltable.core"/>
+      <import plugin="org.eclipse.osgi" version="3.10.2" match="greaterOrEqual"/>
       <import plugin="org.eclipse.ui" version="3.106.1" match="greaterOrEqual"/>
-      <import plugin="org.txm.lexicaltable.core" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.lexicaltable.rcp" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.ca.core" version="1.0.0" match="greaterOrEqual"/>
+      <import plugin="org.txm.chartsengine.rcp"/>
       <import plugin="org.eclipse.core.expressions" version="3.4.600" match="greaterOrEqual"/>
-      <import plugin="org.txm.statsengine.r.rcp" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.cah.core" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.chartsengine.rcp" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.rcp" version="0.7.8" match="greaterOrEqual"/>
-      <import plugin="org.txm.libs.jfreechart" version="1.0.17" match="greaterOrEqual"/>
-      <import plugin="org.txm.libs.jfreesvg" version="1.7.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.chartsengine.core" version="1.0.0" match="greaterOrEqual"/>
+      <import plugin="org.txm.ca.core"/>
+      <import plugin="org.txm.utils"/>
+      <import plugin="org.txm.libs.itext"/>
+      <import plugin="org.txm.libs.jfreechart"/>
+      <import plugin="org.txm.chartsengine.core"/>
       <import plugin="org.eclipse.core.resources"/>
       <import plugin="org.eclipse.swt"/>
-      <import plugin="org.txm.libs.itext" version="2.1.5" match="greaterOrEqual"/>
       <import plugin="org.eclipse.swt" version="3.103.2" match="greaterOrEqual"/>
-      <import plugin="org.txm.annotation.core" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.cooccurrence.core" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.cooccurrence.rcp" version="1.0.0" match="greaterOrEqual"/>
       <import plugin="org.eclipse.e4.ui.workbench" version="1.2.2" match="greaterOrEqual"/>
-      <import plugin="org.txm.internalview.core" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.internalview.rcp" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.annotation.rcp" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.concordance.core" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.specificities.core" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.index.core" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.libs.groovy-all" version="1.0.0" match="greaterOrEqual"/>
+      <import plugin="org.txm.concordance.core"/>
       <import plugin="org.eclipse.osgi.util" version="3.2.0" match="greaterOrEqual"/>
       <import plugin="org.eclipse.core.net"/>
-      <import plugin="org.txm.libs.groovy-all" version="2.3.3" match="greaterOrEqual"/>
-      <import plugin="org.txm.lexicon.core" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.libs.colt" version="1.2.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.libs.saxon" version="9.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.partition.core" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.progression.core" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.referencer.core" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.libs.cqp" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.core" version="0.8.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.rcp" version="0.8.0" match="greaterOrEqual"/>
+      <import plugin="org.txm.libs.rserve"/>
+      <import plugin="org.txm.statsengine.r.rcp"/>
+      <import plugin="org.txm.searchengine.cqp.core"/>
       <import plugin="org.apache.xerces" version="2.9.0" match="greaterOrEqual"/>
       <import plugin="org.eclipse.jface"/>
-      <import plugin="org.txm.groovy.core" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.concordance.rcp" version="1.0.0" match="greaterOrEqual"/>
-      <import plugin="org.txm.chartsengine.svgbatik.rcp" version="1.0.0" match="greaterOrEqual"/>
+      <import plugin="org.eclipse.ui.workbench"/>
+      <import plugin="org.txm.index.rcp"/>
+      <import plugin="org.txm.progression.rcp"/>
+      <import plugin="org.txm.lexicaltable.rcp"/>
+      <import plugin="org.txm.partition.core"/>
+      <import plugin="org.txm.concordance.rcp"/>
+      <import plugin="org.txm.synopticeditor.rcp"/>
       <import plugin="org.eclipse.core.filesystem" version="1.2.0" match="greaterOrEqual"/>
       <import plugin="org.eclipse.ui.ide"/>
       <import plugin="org.eclipse.ui.console" version="3.4.0" match="greaterOrEqual"/>
@@ -188,197 +160,190 @@
       <import plugin="org.eclipse.osgi.util" version="3.3.0" match="greaterOrEqual"/>
       <import plugin="org.eclipse.equinox.p2.reconciler.dropins" version="1.1.200" match="greaterOrEqual"/>
       <import plugin="org.eclipse.ui.views.log" version="1.0.500" match="greaterOrEqual"/>
+      <import plugin="org.txm.groovy.core"/>
       <import plugin="org.eclipse.core.commands" version="3.6.100" match="greaterOrEqual"/>
       <import plugin="org.eclipse.ui.workbench" version="3.106.2" match="greaterOrEqual"/>
-      <import plugin="org.txm.libs.colt" version="1.0.0" match="greaterOrEqual"/>
+      <import plugin="org.txm.statsengine.r.core"/>
       <import plugin="org.eclipse.jface.text" version="3.9.2" match="greaterOrEqual"/>
       <import plugin="org.eclipse.ui.console" version="3.5.300" match="greaterOrEqual"/>
       <import plugin="org.eclipse.ui.ide" version="3.10.2" match="greaterOrEqual"/>
-      <import plugin="org.txm.rcp" version="0.7.5" match="greaterOrEqual"/>
       <import plugin="org.eclipse.ui.browser" version="3.4.100" match="greaterOrEqual"/>
       <import plugin="org.eclipse.jface.databinding" version="1.6.200" match="greaterOrEqual"/>
       <import plugin="org.eclipse.core.net" version="1.2.200" match="greaterOrEqual"/>
    </requires>
 
    <plugin
-         id="org.txm.annotation.core"
-         download-size="0"
-         install-size="0"
-         version="0.0.0"
-         unpack="false"/>
-
-   <plugin
          id="org.txm.ca.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.ca.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.cah.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.cah.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.chartsengine.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.chartsengine.jfreechart.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.chartsengine.jfreechart.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.chartsengine.r.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.chartsengine.r.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.chartsengine.raster.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.chartsengine.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.chartsengine.svgbatik.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.concordance.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.concordance.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.cooccurrence.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.cooccurrence.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"/>
+         version="0.8.0.qualifier"/>
 
    <plugin
          id="org.txm.groovy.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.index.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.index.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.internalview.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.internalview.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.lexicaltable.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.lexicaltable.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.lexicon.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
@@ -391,178 +356,178 @@
          id="org.txm.libs.colt"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.2.0"
          unpack="false"/>
 
    <plugin
          id="org.txm.libs.cqp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.libs.groovy-all"
          download-size="0"
          install-size="0"
-         version="0.0.0"/>
+         version="2.3.3"/>
 
    <plugin
          id="org.txm.libs.itext"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="2.1.5"
          unpack="false"/>
 
    <plugin
          id="org.txm.libs.jfreechart"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.17"
          unpack="false"/>
 
    <plugin
          id="org.txm.libs.jfreesvg"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.7.0"
          unpack="false"/>
 
    <plugin
          id="org.txm.libs.rserve"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.4.0"
          unpack="false"/>
 
    <plugin
          id="org.txm.libs.saxon"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="9.0.0"
          unpack="false"/>
 
    <plugin
          id="org.txm.links.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.partition.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.partition.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.progression.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.progression.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="0.8.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.referencer.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.referencer.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.searchengine.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.searchengine.cqp.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.1.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.searchengine.cqp.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.specificities.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.statsengine.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.statsengine.r.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.statsengine.r.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.synopticeditor.rcp"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
          id="org.txm.utils"
          download-size="0"
          install-size="0"
-         version="0.0.0"
+         version="1.0.0.qualifier"
          unpack="false"/>
 
    <plugin
-         id="org.txm.annotation.rcp"
+         id="javax.persistence"
          download-size="0"
          install-size="0"
          version="0.0.0"
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorPart.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorPart.java	(revision 516)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorPart.java	(revision 517)
@@ -110,8 +110,8 @@
 		if (parent.getLayout() instanceof GridLayout)
 		parametersGroupsComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
 		
-		
 		computingParametersGroup = topToolBar.installGroup("Computing parameters", "Show/Hide command parameters", "icons/show_computing_parameters.png");
+		topToolBar.setVisible(computingParametersGroup, true);
 		
 		displayArea = new Composite(parent, SWT.NONE);
 		displayArea.setLayoutData(new GridData(GridData.FILL_BOTH));
Index: tmp/org.txm.rcp/plugin.xml
===================================================================
--- tmp/org.txm.rcp/plugin.xml	(revision 516)
+++ tmp/org.txm.rcp/plugin.xml	(revision 517)
@@ -174,13 +174,6 @@
             name="%view.name.8"
             restorable="true">
       </view>
-      <view
-            category="org.txm.rcp"
-            class="org.txm.rcp.views.knowledgerepositories.KRView"
-            id="org.txm.rcp.views.knowledgerepositories.KRView"
-            name="%view.name.9"
-            restorable="true">
-      </view>
    </extension>
    <extension
          point="org.eclipse.core.runtime.adapters">
@@ -3109,31 +3102,4 @@
             name="Corpora view">
       </context>
    </extension>
-   <extension
-         point="org.eclipse.ui.intro">
-      <intro
-            class="org.eclipse.ui.intro.config.CustomizableIntroPart"
-            id="org.txm.rcp.intro">
-      </intro>
-      <introProductBinding
-            introId="org.txm.rcp.intro"
-            productId="org.txm.rcp.product">
-      </introProductBinding>
-   </extension>
-   <extension
-         point="org.eclipse.ui.intro.config">
-      <config
-            content="introContent.xml"
-            id="org.txm.rcp.introConfigId"
-            introId="org.txm.rcp.intro">
-         <presentation
-               home-page-id="root">
-            <implementation
-                  kind="html"
-                  os="win32,linux,macosx"
-                  style="content/shared.css">
-            </implementation>
-         </presentation>
-      </config>
-   </extension>
 </plugin>
Index: tmp/org.txm.links.rcp/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.links.rcp/META-INF/MANIFEST.MF	(revision 516)
+++ tmp/org.txm.links.rcp/META-INF/MANIFEST.MF	(revision 517)
@@ -6,7 +6,6 @@
 Bundle-Vendor: Textometrie.org
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Require-Bundle: org.eclipse.ui;bundle-version="3.106.1",
- org.txm.annotation.core;bundle-version="1.0.0";visibility:=reexport,
  org.txm.ca.core;bundle-version="1.0.0";visibility:=reexport,
  org.txm.cah.core;bundle-version="1.0.0";visibility:=reexport,
  org.txm.chartsengine.core;bundle-version="1.0.0";visibility:=reexport,
Index: tmp/org.txm.annotation.core/.classpath
===================================================================
--- tmp/org.txm.annotation.core/.classpath	(revision 516)
+++ tmp/org.txm.annotation.core/.classpath	(revision 517)
@@ -1,7 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
-	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry exported="true" kind="con" path="org.eclipse.pde.core.requiredPlugins">
+		<accessrules>
+			<accessrule kind="accessible" pattern="**"/>
+		</accessrules>
+	</classpathentry>
 	<classpathentry kind="src" path="src"/>
+	<classpathentry exported="true" kind="lib" path="libs/hsqldb.jar"/>
+	<classpathentry exported="true" kind="lib" path="libs/postgresql-9.4.1207.jre6.jar"/>
+	<classpathentry exported="true" kind="lib" path="libs/sqlite-jdbc-3.8.11.2.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
Index: tmp/org.txm.annotation.core/META-INF/persistence.xml
===================================================================
--- tmp/org.txm.annotation.core/META-INF/persistence.xml	(revision 516)
+++ tmp/org.txm.annotation.core/META-INF/persistence.xml	(revision 517)
@@ -1,37 +1,42 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<persistence version="2.0" 
-	xmlns="http://java.sun.com/xml/ns/persistence" 
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">	
+<MAIS FUCK QUOI
+<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">
 		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
 		
-		<class>org.txm.annotation.Annotation</class>
-		<class>org.txm.annotation.repository.AnnotationType</class>
-		<class>org.txm.annotation.repository.TypedValue</class>
-<!--	<class>org.txm.functions.dictionary_jpa.EntryId</class>
+		<class>org.txm.annotation.core.Annotation</class>
+		<class>org.txm.annotation.core.repository.AnnotationType</class>
+		<class>org.txm.annotation.core.repository.TypedValue</class>
+<!--	
+		<class>org.txm.functions.dictionary_jpa.EntryId</class>
 		<class>org.txm.functions.dictionary_jpa.EntryProperty</class>
-		<class>org.txm.functions.dictionary_jpa.EntryPropertyType</class>-->
+		<class>org.txm.functions.dictionary_jpa.EntryPropertyType</class>
+-->
 		<properties>
 			<property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
 			<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.level" value="OFF" />
+ 			<property name="eclipselink.logging.level" value="ON" />
  			
-<!-- 			<property name="eclipselink.jdbc.read-connections.min" value="1" />
+<!-- 		
+			<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" />
-  -->
-			<!-- Logging 
+-->
+
+<!-- Logging 
 			<property name="eclipselink.logging.file" value="output.log"/>
 			<property name="eclipselink.logging.logger" value="JavaLogger"/>
-			-->
+-->
 		
-<!-- 		<property name="eclipselink.logging.level" value="FINE" />
+<!-- 		
+			<property name="eclipselink.logging.level" value="FINE" />
 			<property name="eclipselink.logging.timestamp" value="false" />
 			<property name="eclipselink.logging.session" value="false" />
-			<property name="eclipselink.logging.thread" value="false" /> -->
+			<property name="eclipselink.logging.thread" value="false" /> 
+-->
 			
 			<!-- <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/> -->
 			<!-- <property name="eclipselink.ddl-generation.output-mode" value="database"/> -->
Index: tmp/org.txm.annotation.core/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.annotation.core/META-INF/MANIFEST.MF	(revision 516)
+++ tmp/org.txm.annotation.core/META-INF/MANIFEST.MF	(revision 517)
@@ -4,20 +4,81 @@
 Bundle-SymbolicName: org.txm.annotation.core;singleton:=true
 Bundle-Version: 1.0.0.qualifier
 Bundle-Activator: org.txm.annotation.core.Activator
-Require-Bundle: org.txm.searchengine.cqp.core;visibility:=reexport,
+Meta-Persistence: META-INF/persistence.xml
+Require-Bundle: javax.persistence;bundle-version="2.1.0";visibility:=reexport,
+ org.txm.searchengine.cqp.core;visibility:=reexport,
+ org.eclipse.persistence.asm;bundle-version="3.3.1";visibility:=reexport,
  org.eclipse.persistence.jpa;bundle-version="2.6.0";visibility:=reexport,
  org.eclipse.persistence.jpa.jpql;bundle-version="2.6.0";visibility:=reexport,
- javax.persistence;bundle-version="2.1.0";visibility:=reexport,
+ org.eclipse.persistence.antlr;bundle-version="3.2.0";visibility:=reexport,
  org.txm.utils;bundle-version="1.0.0";visibility:=reexport,
  org.eclipse.osgi;bundle-version="3.10.2";visibility:=reexport,
  org.txm.core;bundle-version="0.7.0";visibility:=reexport,
  org.txm.searchengine.core;bundle-version="1.0.0";visibility:=reexport,
- org.eclipse.ui.workbench;visibility:=reexport
+ org.eclipse.ui.workbench;visibility:=reexport,
+ osgi.enterprise;bundle-version="4.2.0";visibility:=reexport,
+ org.eclipse.jst.common.frameworks;bundle-version="1.1.601",
+ org.eclipse.gemini.jpa;bundle-version="1.1.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
-Export-Package: org.txm.annotation.core,
+Export-Package: org.hsqldb,
+ org.hsqldb.auth,
+ org.hsqldb.dbinfo,
+ org.hsqldb.error,
+ org.hsqldb.index,
+ org.hsqldb.jdbc,
+ org.hsqldb.jdbc.pool,
+ org.hsqldb.lib,
+ org.hsqldb.lib.java,
+ org.hsqldb.lib.tar,
+ org.hsqldb.map,
+ org.hsqldb.navigator,
+ org.hsqldb.persist,
+ org.hsqldb.resources,
+ org.hsqldb.result,
+ org.hsqldb.rights,
+ org.hsqldb.rowio,
+ org.hsqldb.scriptio,
+ org.hsqldb.server,
+ org.hsqldb.types,
+ org.hsqldb.util,
+ org.postgresql,
+ org.postgresql.copy,
+ org.postgresql.core,
+ org.postgresql.core.v2,
+ org.postgresql.core.v3,
+ org.postgresql.ds,
+ org.postgresql.ds.common,
+ org.postgresql.fastpath,
+ org.postgresql.geometric,
+ org.postgresql.gss,
+ org.postgresql.hostchooser,
+ org.postgresql.jdbc,
+ org.postgresql.jdbc2,
+ org.postgresql.jdbc2.optional,
+ org.postgresql.jdbc3,
+ org.postgresql.largeobject,
+ org.postgresql.osgi,
+ org.postgresql.ssl,
+ org.postgresql.ssl.jdbc4,
+ org.postgresql.sspi,
+ org.postgresql.translation,
+ org.postgresql.util,
+ org.postgresql.xa,
+ org.sqlite,
+ org.sqlite.core,
+ org.sqlite.date,
+ org.sqlite.javax,
+ org.sqlite.jdbc3,
+ org.sqlite.jdbc4,
+ org.sqlite.util,
+ org.txm.annotation.core,
  org.txm.annotation.core.conversion,
  org.txm.annotation.core.preferences,
  org.txm.annotation.core.repository,
  org.txm.annotation.core.storage.temporary,
  org.txm.annotation.core.temporary
+Bundle-ClassPath: .,
+ libs/hsqldb.jar,
+ libs/postgresql-9.4.1207.jre6.jar,
+ libs/sqlite-jdbc-3.8.11.2.jar
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 516)
+++ tmp/org.txm.annotation.core/src/org/txm/annotation/core/KRAnnotationEngine.java	(revision 517)
@@ -8,6 +8,7 @@
 import org.txm.annotation.core.repository.KnowledgeRepository;
 import org.txm.annotation.core.repository.KnowledgeRepositoryManager;
 import org.txm.annotation.core.repository.SQLKnowledgeRepository;
+import org.txm.objects.Base;
 import org.txm.objects.BaseParameters;
 import org.txm.searchengine.cqp.corpus.Corpus;
 import org.txm.searchengine.cqp.corpus.MainCorpus;
@@ -196,7 +197,10 @@
 	 * @return the repository names
 	 */
 	public static List<String> getKnowledgeRepositoryNames(Corpus corpus) {
-		BaseParameters params = corpus.getBase().getBaseParameters();
+		if (corpus == null) return new ArrayList<String>();
+		Base base = corpus.getBase();
+		if (base == null) return new ArrayList<String>();
+		BaseParameters params = base.getBaseParameters();
 		return getKnowledgeRepositoryNames(params);
 	}
 	
Index: tmp/org.txm.annotation.core/src/org/txm/annotation/core/repository/AnnotationEffect.java
===================================================================
--- tmp/org.txm.annotation.core/src/org/txm/annotation/core/repository/AnnotationEffect.java	(revision 516)
+++ tmp/org.txm.annotation.core/src/org/txm/annotation/core/repository/AnnotationEffect.java	(revision 517)
@@ -1,10 +1,20 @@
 package org.txm.annotation.core.repository;
 
+/**
+ * Defines is the annotation target is a segment, a single token or another annotation 
+ * @author mdecorde
+ *
+ */
 public enum AnnotationEffect {
 	SEGMENT, // annotate a token sequence
 	TOKEN, // annotate a token position
 	ANNOTATION; // annotate an annotation
 	
+	/**
+	 * 
+	 * 
+	 * @return Effet suffix used to display the annotation type in messages
+	 */
 	public String toSuffix() {
 		if (this.equals(TOKEN)) return " (T)";
 		else if (this.equals(ANNOTATION)) return " (A)";
Index: tmp/org.txm.annotation.core/src/org/txm/annotation/core/repository/AnnotationType.java
===================================================================
--- tmp/org.txm.annotation.core/src/org/txm/annotation/core/repository/AnnotationType.java	(revision 516)
+++ tmp/org.txm.annotation.core/src/org/txm/annotation/core/repository/AnnotationType.java	(revision 517)
@@ -5,6 +5,12 @@
 import javax.persistence.Entity;
 import javax.persistence.Id;
 
+/**
+ * An annotation typed defined in a named Knowledge repository
+ * 
+ * @author mdecorde
+ *
+ */
 @Entity
 public class AnnotationType implements Serializable {
 
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 516)
+++ tmp/org.txm.annotation.core/src/org/txm/annotation/core/repository/KnowledgeRepository.java	(revision 517)
@@ -3,6 +3,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
@@ -67,29 +68,31 @@
 		//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("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()) {
-			urlProperty += "";
-		} else {
-			urlProperty += "hsqldb.applog=0;hsqldb.sqllog=0";
-		}
-		properties.put("javax.persistence.jdbc.url", urlProperty);
-		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
-		if (Log.getLevel().intValue() < Level.WARNING.intValue()) {
-			properties.put(PersistenceUnitProperties.LOGGING_LEVEL, "WARNING");
-			properties.put(PersistenceUnitProperties.LOGGING_PARAMETERS, "true");
-		} else {
-			properties.put(PersistenceUnitProperties.LOGGING_LEVEL, "OFF");
-			properties.put(PersistenceUnitProperties.LOGGING_PARAMETERS, "false");
-		}
+//		//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("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()) {
+//			urlProperty += "";
+//		} else {
+//			urlProperty += "hsqldb.applog=0;hsqldb.sqllog=0";
+//		}
+//		properties.put("javax.persistence.jdbc.url", urlProperty);
+//		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
+//		if (Log.getLevel().intValue() < Level.WARNING.intValue()) {
+//			properties.put(PersistenceUnitProperties.LOGGING_LEVEL, "WARNING");
+//			properties.put(PersistenceUnitProperties.LOGGING_PARAMETERS, "true");
+//		} else {
+//			properties.put(PersistenceUnitProperties.LOGGING_LEVEL, "OFF");
+//			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);
 		if (emf == null) {
 			System.out.println("Error: could not create the PersistenceProvider with name: "+DatabasePersistenceManager.PERSISTENCE_UNIT_NAME);
Index: tmp/org.txm.annotation.core/src/org/txm/annotation/core/repository/TypedValue.java
===================================================================
--- tmp/org.txm.annotation.core/src/org/txm/annotation/core/repository/TypedValue.java	(revision 516)
+++ tmp/org.txm.annotation.core/src/org/txm/annotation/core/repository/TypedValue.java	(revision 517)
@@ -4,6 +4,12 @@
 
 import javax.persistence.*;
 
+/**
+ * A value defined in a Knowledge repository
+ * 
+ * @author mdecorde
+ *
+ */
 @Entity
 public class TypedValue implements Serializable {
 	
Index: tmp/org.txm.annotation.core/src/org/txm/annotation/core/AnnotationManager.java
===================================================================
--- tmp/org.txm.annotation.core/src/org/txm/annotation/core/AnnotationManager.java	(revision 516)
+++ tmp/org.txm.annotation.core/src/org/txm/annotation/core/AnnotationManager.java	(revision 517)
@@ -14,14 +14,15 @@
 import org.txm.searchengine.cqp.corpus.MainCorpus;
 import org.txm.searchengine.cqp.corpus.query.Match;
 import org.txm.utils.logger.Log;
+import org.txm.Engine;
 
 /**
- * Manage annotations and is able to return annotation saved in JPA temporarythe CQP corpus
+ * Manage annotations and is able to return annotation saved in JPA
  * 
  * @author mdecorde
  *
  */
-public class AnnotationManager {
+public class AnnotationManager implements Engine {
 
 	MainCorpus corpus;
 	TemporaryAnnotationManager tempManager;
@@ -29,8 +30,6 @@
 
 	public AnnotationManager(MainCorpus mainCorpus){
 		this.corpus = mainCorpus;
-		tempManager = new TemporaryAnnotationManager(mainCorpus);
-		cqpManager = new CQPAnnotationManager(mainCorpus);
 	}
 
 	public TemporaryAnnotationManager getTemporaryManager(){
@@ -301,6 +300,33 @@
 	}
 
 	public boolean isOpen() {
-		return tempManager.getEntityManager().isOpen();
+		return tempManager.getEntityManager() != null && tempManager.getEntityManager().isOpen();
 	}
+
+	@Override
+	public String getName() {
+		return "Annotation";
+	}
+
+	@Override
+	public boolean getState() {
+		return isOpen();
+	}
+
+	@Override
+	public boolean initialize() throws Exception {
+		tempManager = new TemporaryAnnotationManager(corpus);
+		cqpManager = new CQPAnnotationManager(corpus);
+		return false;
+	}
+
+	@Override
+	public boolean start(IProgressMonitor arg0) throws Exception {
+		return true;
+	}
+
+	@Override
+	public boolean stop() throws Exception {
+		return true;
+	}
 }
Index: tmp/org.txm.annotation.core/src/org/txm/annotation/core/AnnotationEngines.java
===================================================================
--- tmp/org.txm.annotation.core/src/org/txm/annotation/core/AnnotationEngines.java	(revision 516)
+++ tmp/org.txm.annotation.core/src/org/txm/annotation/core/AnnotationEngines.java	(revision 517)
@@ -1,6 +1,5 @@
 package org.txm.annotation.core;
 
-import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.Platform;
@@ -8,7 +7,7 @@
 import org.txm.EngineType;
 import org.txm.EnginesManager;
 
-public abstract class AnnotationEngines extends EnginesManager<AnnotationEngine> {
+public abstract class AnnotationEngines extends EnginesManager<Engine> {
 	
 	public AnnotationEngines() {
 		
@@ -18,13 +17,13 @@
 	public boolean startEngines(IProgressMonitor monitor) {
 		
 		for (Engine e : engines.values()) {
-			AnnotationEngine se = (AnnotationEngine)e;
-			if (monitor != null) monitor.subTask("Starting "+ se.getName()+" annotation engine.");
-			try {
-				se.start(monitor);
-			} catch (Exception ex) {
-				System.out.println("Error: failed to start annotation engine: "+se.getName()+": "+ex.getLocalizedMessage());
-			}
+//			AnnotationEngine se = (AnnotationEngine)e;
+//			if (monitor != null) monitor.subTask("Starting "+ se.getName()+" annotation engine.");
+//			try {
+//				se.start(monitor);
+//			} catch (Exception ex) {
+//				System.out.println("Error: failed to start annotation engine: "+se.getName()+": "+ex.getLocalizedMessage());
+//			}
 		}
 		return true;
 	}
@@ -32,13 +31,13 @@
 	@Override
 	public boolean stopEngines() {
 		for (Engine e : engines.values()) {
-			AnnotationEngine se = (AnnotationEngine)e;
-			System.out.println("Stoping "+ se.getName()+" annotation engine.");
-			try {
-				se.stop();
-			} catch (Exception ex) {
-				System.out.println("Error: failed to stop annotation engine: "+se.getName()+": "+ex.getLocalizedMessage());
-			}
+//			AnnotationEngine se = (AnnotationEngine)e;
+//			System.out.println("Stoping "+ se.getName()+" annotation engine.");
+//			try {
+//				se.stop();
+//			} catch (Exception ex) {
+//				System.out.println("Error: failed to stop annotation engine: "+se.getName()+": "+ex.getLocalizedMessage());
+//			}
 		}
 		return true;
 	}
@@ -51,21 +50,21 @@
 	@Override
 	protected boolean fetchEngines() {
 		
-		IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(AnnotationEngine.EXTENSION_POINT_ID);
-		//System.out.println("search engine contributions: "+SearchEngine.EXTENSION_POINT_ID);
-		for (int i = 0; i < contributions.length; i++) {
-			try {
-				AnnotationEngine e = (AnnotationEngine)contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
-				if (e.initialize()) {
-					engines.put(e.getName(), e);
-				} else {
-					System.out.println("Fail to initialize "+e.getName()+" annotation engine.");
-				}
-			} catch(Exception e) {
-				System.out.println("Error: fail instanciate "+contributions[i].getName()+": "+e.getLocalizedMessage());
-				e.printStackTrace();
-			} 
-		}
+//		IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(AnnotationEngine.EXTENSION_POINT_ID);
+//		//System.out.println("search engine contributions: "+SearchEngine.EXTENSION_POINT_ID);
+//		for (int i = 0; i < contributions.length; i++) {
+//			try {
+//				AnnotationEngine e = (AnnotationEngine)contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
+//				if (e.initialize()) {
+//					engines.put(e.getName(), e);
+//				} else {
+//					System.out.println("Fail to initialize "+e.getName()+" annotation engine.");
+//				}
+//			} catch(Exception e) {
+//				System.out.println("Error: fail instanciate "+contributions[i].getName()+": "+e.getLocalizedMessage());
+//				e.printStackTrace();
+//			} 
+//		}
 		
 		return engines.size() > 0;
 	}
Index: tmp/org.txm.annotation.core/libs/sqlite-jdbc-3.8.11.2.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tmp/org.txm.annotation.core/libs/sqlite-jdbc-3.8.11.2.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tmp/org.txm.annotation.core/libs/postgresql-9.4.1207.jre6.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tmp/org.txm.annotation.core/libs/postgresql-9.4.1207.jre6.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tmp/org.txm.annotation.core/libs/hsqldb.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tmp/org.txm.annotation.core/libs/hsqldb.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tmp/org.txm.annotation.core/build.properties
===================================================================
--- tmp/org.txm.annotation.core/build.properties	(revision 516)
+++ tmp/org.txm.annotation.core/build.properties	(revision 517)
@@ -1,2 +1,8 @@
 output.. = bin/
-bin.includes = plugin.xml
+bin.includes = plugin.xml,\
+               libs/hsqldb.jar,\
+               libs/postgresql-9.4.1207.jre6.jar,\
+               libs/sqlite-jdbc-3.8.11.2.jar,\
+               .,\
+               org.eclipse.gemini.jpa-1.1.0.RELEASE.jar
+source.. = src/
Index: tmp/org.txm.groovy.core/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.groovy.core/META-INF/MANIFEST.MF	(revision 516)
+++ tmp/org.txm.groovy.core/META-INF/MANIFEST.MF	(revision 517)
@@ -33,7 +33,6 @@
  org.txm.specificities.core;bundle-version="1.0.0",
  org.txm.statsengine.core;bundle-version="1.0.0",
  org.txm.referencer.core;bundle-version="1.0.0",
- org.txm.annotation.core;bundle-version="1.0.0",
  org.txm.libs.cqp;bundle-version="1.0.0",
  org.txm.searchengine.core;bundle-version="1.0.0",
  org.eclipse.swt;bundle-version="3.103.2"
Index: tmp/org.txm.core/src/java/org/txm/EnginesManager.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/EnginesManager.java	(revision 516)
+++ tmp/org.txm.core/src/java/org/txm/EnginesManager.java	(revision 517)
@@ -14,7 +14,7 @@
  */
 public abstract class EnginesManager<T extends Engine> {
 	
-	public static final String ENGINEMANAGER_EXTENSION_POINT_ID = EnginesManager.class.getCanonicalName();
+	public static final String ENGINEMANAGER_EXTENSION_POINT_ID = EnginesManager.class.getName();
 	
 	protected HashMap<String, T> engines = new HashMap<String, T>();
 	
Index: tmp/org.txm.core/src/java/org/txm/Toolbox.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/Toolbox.java	(revision 516)
+++ tmp/org.txm.core/src/java/org/txm/Toolbox.java	(revision 517)
@@ -86,7 +86,7 @@
 		return state;
 	}
 
-	private static boolean fetchEngines() {
+	private static boolean fetchEngineManagers() {
 		Log.info("Fetching engine managers...");
 		engines.clear();
 		//System.out.println("Contributions of "+EnginesManager.ENGINEMANAGER_EXTENSION_POINT_ID);
@@ -416,7 +416,7 @@
 
 	private static boolean startsEngineManagers(IProgressMonitor monitor) {
 		
-		fetchEngines();
+		fetchEngineManagers();
 
 		Log.info("Starting "+engines.keySet().size()+" engines managers...");
 		
Index: tmp/org.txm.core/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.core/META-INF/MANIFEST.MF	(revision 516)
+++ tmp/org.txm.core/META-INF/MANIFEST.MF	(revision 517)
@@ -278,5 +278,3 @@
  lib/jodconverter-core-3.1-beta.jar
 Bundle-ActivationPolicy: lazy
 Bundle-Vendor: Textometrie.org
-JPA-PersistenceUnits: MyPUWithHSQL
-Meta-Persistence: META-INF/persistence.xml
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 0)
+++ tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/ConcordanceAnnotations.java	(revision 517)
@@ -0,0 +1,225 @@
+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;
+
+import org.txm.annotation.core.Annotation;
+import org.txm.annotation.core.AnnotationManager;
+import org.txm.annotation.core.KRAnnotationEngine;
+import org.txm.annotation.core.repository.AnnotationType;
+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 {
+	
+	Concordance concordance;
+	
+	private AnnotationType viewAnnotation;
+	
+	public ConcordanceAnnotations(Concordance concordance) {
+		
+	}
+	
+	private boolean overlapAnnotation;
+
+	private ArrayList<AnnotationLine> lines;
+
+	private List<Line> concordanceLines;
+	public void setAnnotationOverlap(boolean overlap) {
+		overlapAnnotation = overlap;
+	}
+	public boolean getAnnotationOverlap() {
+		return overlapAnnotation;
+	}
+	
+	public List<AnnotationLine> getLines(int from, int to) throws CqiClientException, IOException, CqiServerError {
+
+		concordanceLines = concordance.getLines(from, to);
+		ArrayList<Match> matches = new ArrayList<Match>();
+		for (Line line : concordanceLines) matches.add(line.getMatch());
+		
+		List<Annotation> ann = getAnnotationForMatches(matches, overlapAnnotation);
+		
+		lines = new ArrayList<AnnotationLine>();
+		
+		for (Annotation a : ann) {
+			AnnotationLine aline = new AnnotationLine(a, getAnnotationTypedValue(a));
+			lines.add(aline);
+		}
+		
+		return lines; // TODO find a way to add 
+	}
+	
+	private String findAnnotationForLine(Match match, List<Annotation> annots, boolean overlap) {
+		String annotationValue = "";
+		if (annots!=null) {
+			if (!annots.isEmpty()) {
+				for (Annotation annot : annots) {
+					if (overlap) {
+						if ((annot.getStart()<=match.getStart() && annot.getEnd()>=match.getEnd()) || (annot.getStart()>match.getStart() && annot.getEnd()<match.getEnd())
+								) {
+							annotationValue = annot.getValue(); 
+							// use the first Annotation found, the one stored in the temporary HSQL database
+							//should be modified to display a list of annotation values corresponding to the match positions (or wrapped if overlap is admitted)
+						}
+					} else {
+						if (annot.getStart()==match.getStart() && annot.getEnd()==match.getEnd()) {
+							annotationValue = annot.getValue(); 
+							// use the first Annotation found, the one stored in the temporary HSQL database
+						}
+					}
+				}
+			}
+		}
+		return annotationValue;
+	}
+	
+	public TypedValue getAnnotationTypedValue(Annotation annotation) { 
+
+		TypedValue annotationValue = null;
+		if (annotation!=null) {
+			annotationValue = viewAnnotation.getTypedValue(annotation.getValue());
+			if (annotationValue == null) { // the annotation is not stored in the KR type -> the annotation is surely built with the CQPAnnotationManager
+				//System.out.println("WARNING: no annotation value found for value id="+annotation.getValue()+" - will be created.");
+				annotationValue = new TypedValue(annotation.getValue(), annotation.getValue(), annotation.getType());
+			}
+		}
+		
+		return annotationValue;
+	}
+
+	public AnnotationType getViewAnnotation(AnnotationType type) {
+		return viewAnnotation;
+	}
+
+
+	private List<Annotation> prepareAnnotationsList(List<Match> matches, List<Annotation> annotations, boolean overlap){
+		List<Annotation> annotsList = new ArrayList<Annotation>();
+
+		int iMatch = 0;
+		int iAnnotation = 0;
+		int nMatch = matches.size();
+		int nAnnotations = annotations.size();
+
+		while (iMatch < nMatch && iAnnotation < nAnnotations) {
+			if (overlap) {
+				if (matches.get(iMatch).getEnd() < annotations.get(iAnnotation).getStart()) {
+					iMatch++;
+					annotsList.add(null); // nothing for this match
+				} else if (annotations.get(iAnnotation).getEnd() < matches.get(iMatch).getStart()) {
+					iAnnotation++;
+				} else {
+					annotsList.add(annotations.get(iAnnotation));
+					iMatch++;
+				}
+			} else {
+				if (matches.get(iMatch).getEnd() < annotations.get(iAnnotation).getStart()) {
+					iMatch++;
+					annotsList.add(null); // nothing for this match
+				} else if (annotations.get(iAnnotation).getEnd() < matches.get(iMatch).getStart()) {
+					iAnnotation++;
+				} else if (annotations.get(iAnnotation).getStart() == matches.get(iMatch).getStart() && 
+						annotations.get(iAnnotation).getEnd() == matches.get(iMatch).getEnd()) {
+					annotsList.add(annotations.get(iAnnotation));
+					iMatch++;
+					iAnnotation++;
+				} else {
+					iAnnotation++;
+				}
+			}
+		}
+
+		while (annotsList.size() < matches.size() ) annotsList.add(null); // fill matches that were not process due to no more annotations
+
+		return annotsList;
+	}
+
+	private HashMap<Match, Annotation> prepareAnnotationsMap(List<Match> matches, List<Annotation> annots, boolean overlap){
+		HashMap<Match, Annotation> annotsList = new HashMap<Match, Annotation>();
+		for (Match m : matches) {
+			boolean hasAnnotations = false;
+			if (annots!=null) {
+				if (!annots.isEmpty()) {
+					for (Annotation annot : annots) {
+						if (overlap){
+							if ((annot.getStart() <= m.getStart() && m.getStart() <= annot.getEnd() && m.getEnd() >= annot.getEnd()) || 
+									(annot.getStart() <= m.getEnd() && m.getEnd() <= annot.getEnd() && m.getStart() <= annot.getStart()) 
+									|| !(annot.getEnd() < m.getStart() || annot.getStart() > m.getEnd())){
+								annotsList.put(m, annot);
+								hasAnnotations = true;
+							}
+						} else {
+							if (annot.getStart()==m.getStart() && annot.getEnd()==m.getEnd()) {
+								annotsList.put(m, annot); 
+								hasAnnotations = true;
+							}
+						}
+					}
+				}
+			}
+			if (!hasAnnotations) {
+				annotsList.put(m, null);
+			}
+		}
+		return annotsList;
+	}
+
+	public List<Annotation> getAnnotationForMatches(List<Match> subsetMatch, boolean overlapAnnotation) {
+		
+		AnnotationManager am = KRAnnotationEngine.getAnnotationManager(concordance.getCorpus());
+		
+		//List<Annotation> allAnnotations = null;
+		List<Annotation> annotationsPerMatch = null;;
+		if (viewAnnotation != null && am != null) {
+			try {
+				annotationsPerMatch = am.getAnnotationsForMatches(viewAnnotation, subsetMatch, overlapAnnotation);
+				//System.out.println("annotationsPerMatch: "+annotationsPerMatch);
+			} catch (Exception e) {
+				System.out.println("Error while reading annotation "+viewAnnotation+" and with "+subsetMatch.size()+" matches");
+				Log.printStackTrace(e);
+			}
+		}
+		return annotationsPerMatch;
+	}
+	
+
+	public void setViewAnnotation(AnnotationType type) {
+		viewAnnotation = type;
+		concordance.resetLines();
+	}
+	
+	/**
+	 * 
+	 * @param i the relative position of the AnnotationLine in the lines list
+	 * 
+	 * @return the AnnotationLine pointed by 'i'. May return null if i is wrong.
+	 */
+	public AnnotationLine getAnnotationLine(Line line) {
+		int i = concordanceLines.indexOf(line);
+		if (i < 0) return null;
+		return getAnnotationLine(i);
+	}
+	
+	/**
+	 * 
+	 * @param i the relative position of the AnnotationLine in the lines list
+	 * 
+	 * @return the AnnotationLine pointed by 'i'. May return null if i is wrong.
+	 */
+	public AnnotationLine getAnnotationLine(int i) {
+		if (lines.size() < i) return null;
+		if (i < 0) return null;
+		
+		return lines.get(i);
+	}
+}

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

Index: tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/AnnotationLine.java
===================================================================
--- tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/AnnotationLine.java	(revision 0)
+++ tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/AnnotationLine.java	(revision 517)
@@ -0,0 +1,26 @@
+package org.txm.annotation.rcp.concordance;
+
+import org.txm.annotation.core.Annotation;
+import org.txm.annotation.core.repository.TypedValue;
+
+public class AnnotationLine {
+
+	private TypedValue annotationValue;
+
+	private Annotation annotation;
+	
+	public AnnotationLine(Annotation annotation, TypedValue annotationValue) {
+		this.annotation = annotation;
+		this.annotationValue = annotationValue; 
+	}
+	
+
+	public Annotation getAnnotation() {
+		return annotation;
+	}
+	
+
+	public TypedValue getAnnotationValue() {
+		return annotationValue;
+	}
+}

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

Index: tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/AnnotationLineDecorator.java
===================================================================
--- tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/AnnotationLineDecorator.java	(revision 0)
+++ tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/AnnotationLineDecorator.java	(revision 517)
@@ -0,0 +1,29 @@
+package org.txm.annotation.rcp.concordance;
+
+import org.txm.annotation.core.Annotation;
+import org.txm.concordance.core.functions.LineDecorator;
+
+public class AnnotationLineDecorator extends LineDecorator {
+	ConcordanceAnnotations annotations;
+	
+	public AnnotationLineDecorator(ConcordanceAnnotations annotations) {
+		this.annotations = annotations;
+	}
+	
+	/**
+	 * Add "<" or ">" depending of the current position of the match and the annotation start end positions
+	 */
+	@Override
+	public String decorate(int i, int currentPos, String str) {
+		Annotation annotation = annotations.getAnnotationLine(i).getAnnotation();
+		
+		if (annotation != null) {
+			if (currentPos == annotation.getStart()) {
+				return "< "+str;
+			} else if (currentPos == annotation.getEnd()) {
+				return str+" >";
+			}
+		}
+		return str;
+	}
+}

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

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 0)
+++ tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/ConcordanceAnnotationExtension.java	(revision 517)
@@ -0,0 +1,936 @@
+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.jface.viewers.ViewerCell;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+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.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.Messages;
+import org.txm.core.preferences.TXMPreferences;
+import org.txm.rcp.IImageKeys;
+import org.txm.rcp.RCPMessages;
+import org.txm.rcp.commands.OpenBrowser;
+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;
+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.views.knowledgerepositories.KRView;
+
+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(Messages.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(Messages.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(editor.getTopLine(), editor.getBottomLine()+1);
+							}
+						}
+
+						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(Messages.ConcordancesEditor_15);
+		annotationColumn.setToolTipText(Messages.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= Messages.ConcordancesEditor_22;
+		String removeLabel = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_24");
+		if (removeLabel == null) removeLabel= Messages.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= Messages.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= Messages.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(RCPMessages.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(editor.getTopLine(), editor.getBottomLine()+1);
+					}
+
+					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(Messages.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(), Messages.ConcordancesEditor_82, Messages.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(editor.getTopLine(), editor.getBottomLine()+1);
+								}
+								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= Messages.ConcordancesEditor_80;
+			valueLabel.setText(valueLabelText);
+			valueLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+		}
+
+		annotationValuesText = new Text(annotationArea, SWT.BORDER);
+		annotationValuesText.setToolTipText(Messages.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(RCPMessages.AnnotationPreferences_2)) {
+				addTypedValueLink.setToolTipText(Messages.ConcordancesEditor_79);
+			}else {
+				addTypedValueLink.setToolTipText(Messages.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(RCPMessages.AnnotationPreferences_2)) {
+						String title = currentKnowledgeRepository.getString(editor.getLocale(), "ConcordancesEditor_100");
+						if (title == null) title = Messages.ConcordancesEditor_100;
+						dialog.setTitle(Messages.bind(title, type.getName()));//+"valeurs de "+type.getName());
+					}else {
+						dialog.setTitle(Messages.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[] = {Messages.ConcordancesEditor_35, Messages.ConcordancesEditor_42, Messages.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(Messages.ConcordancesEditor_85);
+		affectAnnotationButton.setToolTipText(Messages.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(Messages.ConcordancesEditor_53+e1);
+						Log.printStackTrace(e1);
+						return;
+					}
+				} else { // all
+					try {
+						List<Match> matches = concordance.getMatches();
+						affectMatchesToSelection(matches);
+					} catch (CqiClientException e1) {
+						Log.severe(Messages.ConcordancesEditor_53+e1);
+						Log.printStackTrace(e1);
+						return;
+					}
+				}
+			}
+
+			@Override
+			public void widgetDefaultSelected(SelectionEvent e) { }
+		});
+		Button cancelAnnotateButton = new Button(annotationArea, SWT.PUSH);
+		cancelAnnotateButton.setText(Messages.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(Messages.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(Messages.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(Messages.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(RCPMessages.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(Messages.ConcordancesEditor_54+e1);
+				Log.printStackTrace(e1);
+				return;
+			}
+
+			job.syncExec(new Runnable() {
+				@Override
+				public void run() {
+					editor.fillDisplayArea(editor.getTopLine(), editor.getBottomLine()+1);
+					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$
+							Messages.ConcordancesEditor_86, 
+							Messages.ConcordancesEditor_87+matches.size()+Messages.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(Messages.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 = Messages.ConcordancesEditor_110;
+					if (content == null ) content = Messages.ConcordancesEditor_112;
+					ConfirmDialog dialog = new ConfirmDialog(Display.getCurrent().getActiveShell(), 
+							"create_value", //$NON-NLS-1$
+							Messages.bind(title, svalue, type.getName()),  
+							Messages.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 = Messages.bind(Messages.ConcordancesEditor_58, svalue);
+					System.out.println(mess);
+					MessageDialog.openError(Display.getCurrent().getActiveShell(), "Annotation canceled", mess); //$NON-NLS-1$
+				}
+			});
+			return;
+		}
+
+		Log.info(Messages.ConcordancesEditor_59+value_to_add+Messages.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 = Messages.ConcordancesEditor_61+value_to_add.getStandardName()+
+						Messages.ConcordancesEditor_62;
+				for (Match m : existingAnnots.keySet()) {
+					message += Messages.ConcordancesEditor_63+m+Messages.ConcordancesEditor_64;
+
+					for (Annotation existingAnnot : existingAnnots.get(m)) {
+						if (existingAnnot.getStart() < m.getStart()){
+							message += Messages.ConcordancesEditor_65+existingAnnot.getType()+Messages.ConcordancesEditor_66+existingAnnot.getStart()+Messages.ConcordancesEditor_67+existingAnnot.getEnd()+Messages.ConcordancesEditor_68;
+						} else {
+							message += Messages.ConcordancesEditor_69+existingAnnot.getType()+Messages.ConcordancesEditor_70+existingAnnot.getStart()+Messages.ConcordancesEditor_71+existingAnnot.getEnd()+Messages.ConcordancesEditor_72;
+						}
+					}
+				}
+				final String final_message = message;
+				job.syncExec(new Runnable() {
+					@Override
+					public void run() {
+						MessageDialog.openInformation(editor.getSite().getShell(), Messages.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(Messages.ConcordancesEditor_74+e1);
+			Log.printStackTrace(e1);
+			return;
+		}
+
+		job.syncExec(new Runnable() {
+			@Override
+			public void run() {
+				editor.fillDisplayArea(editor.getTopLine(), editor.getBottomLine()+1);
+				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;
+	}
+}

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

Index: tmp/org.txm.annotation.rcp/plugin.xml
===================================================================
--- tmp/org.txm.annotation.rcp/plugin.xml	(revision 516)
+++ tmp/org.txm.annotation.rcp/plugin.xml	(revision 517)
@@ -7,48 +7,48 @@
             categoryId="org.txm.rcp.category.txm"
             defaultHandler="org.txm.rcp.commands.workspace.RecodeCorpus"
             id="org.txm.rcp.commands.workspace.RecodeCorpus"
-            name="%command.name.100">
+            name="Recode Corpus">
       </command>
             <command
             categoryId="org.txm.rcp.category.txm"
             defaultHandler="org.txm.annotation.rcp.commands.SaveAnnotations"
             id="org.txm.rcp.commands.annotation.SaveAnnotations"
-            name="%command.name.97">
+            name="Save annotations">
       </command>
             <command
             defaultHandler="org.txm.annotation.rcp.commands.krview.OpenKRView"
             id="org.txm.rcp.commands.krview.OpenKRView"
-            name="%command.name.99">
+            name="Open KR View">
       </command>
       <command
             defaultHandler="org.txm.annotation.rcp.commands.krview.Copy"
             id="org.txm.rcp.commands.krview.Copy"
-            name="%command.name.101">
+            name="Copy">
       </command>
       <command
             defaultHandler="org.txm.annotation.rcp.commands.krview.Reload"
             id="org.txm.rcp.commands.krview.Reload"
-            name="%command.name.102">
+            name="Reload">
       </command>
       <command
             defaultHandler="org.txm.annotation.rcp.commands.krview.Informations"
             id="org.txm.rcp.commands.krview.Informations"
-            name="%command.name.103">
+            name="Informations">
       </command>
       <command
             defaultHandler="org.txm.annotation.rcp.commands.krview.Delete"
             id="org.txm.rcp.commands.krview.Delete"
-            name="%command.name.104">
+            name="Delete">
       </command>
       <command
             defaultHandler="org.txm.annotation.rcp.commands.krview.Add"
             id="org.txm.rcp.commands.krview.Add"
-            name="%command.name.105">
+            name="Add">
       </command>
       <command
             defaultHandler="org.txm.annotation.rcp.commands.ExportStandoff"
             id="org.txm.rcp.commands.annotation.ExportStandoff"
-            name="%command.name.107">
+            name="Export annotations">
       </command>
    </extension>
   <extension
@@ -57,9 +57,19 @@
            category="org.txm.rcp.preferences.UserPreferencePage"
            class="org.txm.annotation.rcp.preferences.AnnotationPreferencePage"
            id="org.txm.rcp.preferences.AnnotationPreferencePage"
-           name="%page.name.23">
+           name="Annotation">
      </page>
   </extension>
+     <extension
+         point="org.eclipse.ui.views">
+      <view
+            category="org.txm.rcp"
+            class="org.txm.annotation.rcp.views.knowledgerepositories.KRView"
+            id="org.txm.rcp.views.knowledgerepositories.KRView"
+            name="KR"
+            restorable="true">
+      </view>
+   </extension>
   <extension
          point="org.eclipse.ui.bindings">
       <key
@@ -100,7 +110,7 @@
            locationURI="menu:menu.display.views">
            <command
                      commandId="org.txm.rcp.commands.krview.OpenKRView"
-                     label="%command.label.150"
+                     label="KR"
                      style="push">
                </command>
      </menuContribution>
@@ -108,13 +118,11 @@
             locationURI="popup:org.txm.rcp.views.knowledgerepositories.KRView">
          <command
                commandId="org.txm.rcp.commands.krview.Copy"
-               label="%command.label.188"
                style="push"
                tooltip="%command.tooltip.89">
          </command>
          <command
                commandId="org.txm.rcp.commands.krview.Reload"
-               label="%command.label.189"
                style="push"
                tooltip="%command.tooltip.90">
             <visibleWhen
@@ -126,13 +134,11 @@
          </command>
          <command
                commandId="org.txm.rcp.commands.krview.Informations"
-               label="%command.label.190"
                style="push"
                tooltip="%command.tooltip.93">
          </command>
          <command
                commandId="org.txm.rcp.commands.krview.Add"
-               label="%command.label.191"
                style="push"
                tooltip="%command.tooltip.94">
             <visibleWhen
@@ -149,7 +155,6 @@
          </command>
          <command
                commandId="org.txm.rcp.commands.krview.Delete"
-               label="%command.label.192"
                style="push"
                tooltip="%command.tooltip.95">
             <visibleWhen
@@ -171,7 +176,7 @@
            <command
                      commandId="org.txm.rcp.commands.annotation.ExportStandoff"
                      id="menu.file.export.exporttei"
-                     label="%command.label.193"
+                     label="Export annotations"
                      style="push">
                   <visibleWhen
                         checkEnabled="false">
@@ -309,10 +314,10 @@
             </definition>
   </extension>
   <extension
-        point="org.txm.concordance.rcp.concordanceeditor.button">
-     <button
-           class="org.txm.annoation.rcp.concordance.AnnotationButton"
+        point="org.txm.concordance.rcp.editors.ConcordanceEditorExtension">
+     <concextension
+           class="org.txm.annotation.rcp.concordance.ConcordanceAnnotationExtension"
            name="Annotation">
-     </button>
+     </concextension>
   </extension>
 </plugin>
Index: tmp/org.txm.annotation.rcp/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.annotation.rcp/META-INF/MANIFEST.MF	(revision 516)
+++ tmp/org.txm.annotation.rcp/META-INF/MANIFEST.MF	(revision 517)
@@ -12,9 +12,9 @@
  org.txm.rcp;bundle-version="0.8.0";visibility:=reexport,
  org.txm.concordance.core;bundle-version="1.0.0",
  org.txm.concordance.rcp;bundle-version="1.0.0"
-Export-Package: org.txm.annoation.rcp.concordance,
- org.txm.annotation.rcp.commands,
+Export-Package: org.txm.annotation.rcp.commands,
  org.txm.annotation.rcp.commands.krview,
+ org.txm.annotation.rcp.concordance,
  org.txm.annotation.rcp.editors.imports.sections,
  org.txm.annotation.rcp.preferences,
  org.txm.annotation.rcp.views.knowledgerepositories,
Index: tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Line.java
===================================================================
--- tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Line.java	(revision 516)
+++ tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Line.java	(revision 517)
@@ -35,8 +35,6 @@
 import java.util.Map;
 
 import org.apache.commons.lang.StringUtils;
-import org.txm.annotation.core.Annotation;
-import org.txm.annotation.core.repository.TypedValue;
 import org.txm.searchengine.cqp.Reference;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.corpus.Corpus;
@@ -97,10 +95,6 @@
 	 */
 	private int targetpos;
 
-	private TypedValue annotationValue;
-
-	private Annotation annotation;
-
 	/**
 	 * Instantiates a new line.
 	 *
@@ -126,7 +120,7 @@
 			HashMap<Property, List<String>> lineLeftCtxAnaPropValue,
 			HashMap<Property, List<String>> lineKeywordsAnaPropValue,
 			HashMap<Property, List<String>> lineRightCtxAnaPropValue, Reference refView,
-			Reference refAna, Match matchs, Annotation annotation, TypedValue annotationValue, int targetpos) {
+			Reference refAna, Match matchs, int targetpos) {
 		this.textId = textId;
 		this.targetpos = targetpos;
 		this.keywordsIdValues = keywordsIdValues;
@@ -141,8 +135,6 @@
 		this.refAna = refAna;
 		this.match = matchs;
 		this.keywordpos = matchs.getStart();
-		this.annotationValue = annotationValue;
-		this.annotation = annotation;
 	}
 
 	/**
@@ -153,10 +145,6 @@
 	public HashMap<Property, List<String>> getKeywordsAnalysisProperty() {
 		return keywordsAnalysisProperty;
 	}
-
-	public TypedValue getAnnotationValue() {
-		return annotationValue;
-	}
 	
 	/**
 	 * Gets the left context analysis property.
@@ -315,6 +303,20 @@
 	 */
 	public String leftContextToString(String propertySeparator,
 			String wordSeparator, int limit) {
+		return leftContextToString(propertySeparator, wordSeparator, limit, null);
+	}
+	
+	/**
+	 * Returns a string representing the left context.
+	 *
+	 * @param propertySeparator The string used to separate the dif ferent view properties for
+	 * each word
+	 * @param wordSeparator The string used to separate the dif ferent words
+	 * @param limit the limit
+	 * @return The string representation
+	 */
+	public String leftContextToString(String propertySeparator,
+			String wordSeparator, int limit, LineDecorator decorator) {
 		int currentPos = keywordpos - getLeftContextSize();
 		
 		List<String> words = new ArrayList<String>();
@@ -329,12 +331,8 @@
 			
 			words.add(StringUtils.join(word, propertySeparator));
 			
-			if (annotation != null) {
-				if (currentPos == annotation.getStart()) {
-					words.set(i, "< "+words.get(i));
-				} else if (currentPos == annotation.getEnd()) {
-					words.set(i, words.get(i)+" >");
-				}
+			if (decorator != null) {
+				words.set(i, decorator.decorate(i, currentPos, words.get(i)));
 			}
 			
 			currentPos++; // next position
@@ -355,6 +353,18 @@
 	 * @return The string representation
 	 */
 	public String keywordToString(String propertySeparator, String wordSeparator) {
+		return keywordToString(propertySeparator, wordSeparator, null);
+	}
+	
+	/**
+	 * Returns a string representing the keywords.
+	 *
+	 * @param propertySeparator The string used to separate the dif ferent view properties for
+	 * each word
+	 * @param wordSeparator The string used to separate the dif ferent words
+	 * @return The string representation
+	 */
+	public String keywordToString(String propertySeparator, String wordSeparator, LineDecorator decorator) {
 		
 		int currentPos = keywordpos;
 		
@@ -373,13 +383,9 @@
 			} else {
 				words.add(StringUtils.join(word, propertySeparator));
 			}
-			if (annotation != null && (annotation.getStart() != keywordpos || annotation.getEnd() != keywordEndPos)) {
-				if (currentPos == annotation.getStart()) {
-					words.set(i, "< "+words.get(i));
-				}
-				if (currentPos == annotation.getEnd()) {
-					words.set(i, words.get(i)+" >");
-				}
+			
+			if (decorator != null) {
+				words.set(i, decorator.decorate(i, currentPos, words.get(i)));
 			}
 			
 			currentPos++; // next position
@@ -401,6 +407,20 @@
 	 */
 	public String rightContextToString(String propertySeparator,
 			String wordSeparator, int limit) {
+		return rightContextToString(propertySeparator, wordSeparator, limit, null);
+	}
+	
+	/**
+	 * Returns a string representing the right context.
+	 *
+	 * @param propertySeparator The string used to separate the dif ferent view properties for
+	 * each word
+	 * @param wordSeparator The string used to separate the dif ferent words
+	 * @param limit the limit
+	 * @return The string representation
+	 */
+	public String rightContextToString(String propertySeparator,
+			String wordSeparator, int limit, LineDecorator decorator) {
 		List<String> words = new ArrayList<String>();
 		Map<Property, List<String>> values = getRightCtxViewProperties();
 		int max = (limit == -1) ? (values.get(concordance.getRightViewProperties().get(0)).size()) : (limit);
@@ -414,12 +434,8 @@
 				word.add(values.get(property).get(i));
 			words.add(StringUtils.join(word, propertySeparator));
 			
-			if (annotation != null) {
-				if (currentPos == annotation.getStart()) {
-					words.set(i, "< "+words.get(i));
-				} else if (currentPos == annotation.getEnd()) {
-					words.set(i, words.get(i)+" >");
-				}
+			if (decorator != null) {
+				words.set(i, decorator.decorate(i, currentPos, words.get(i)));
 			}
 			currentPos++;
 		}
@@ -691,8 +707,4 @@
 	public int getKeywordPosition() {
 		return keywordpos;
 	}
-
-	public Annotation getAnnotation() {
-		return annotation;
-	}
 }
Index: tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/LineDecorator.java
===================================================================
--- tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/LineDecorator.java	(revision 0)
+++ tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/LineDecorator.java	(revision 517)
@@ -0,0 +1,16 @@
+package org.txm.concordance.core.functions;
+
+public abstract class LineDecorator {
+	/**
+	 * 
+	 * decorate the String str.
+	 * 
+	 * 
+	 * @param i the relative position of 'str'
+	 * @param currentPos the position of 'str' in the corpus
+	 * @param str the String to decorate
+	 * 
+	 * @return the decorated String
+	 */
+	public abstract String decorate(int i, int currentPos, String str);
+}

Property changes on: tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/LineDecorator.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

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 516)
+++ tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java	(revision 517)
@@ -43,11 +43,6 @@
 import java.util.Map;
 
 import org.eclipse.core.runtime.IProgressMonitor;
-import org.txm.annotation.core.Annotation;
-import org.txm.annotation.core.AnnotationManager;
-import org.txm.annotation.core.KRAnnotationEngine;
-import org.txm.annotation.core.repository.AnnotationType;
-import org.txm.annotation.core.repository.TypedValue;
 import org.txm.concordance.core.functions.comparators.LineComparator;
 import org.txm.concordance.core.messages.ConcordanceMessages;
 import org.txm.concordance.core.preferences.ConcordancePreferences;
@@ -91,8 +86,6 @@
 	/** The n lines. */
 	private int nLines;
 
-	private boolean overlapAnnotation;
-
 	String pCQLLimit;
 	/** The keyword analysis property. */
 	private List<Property> pKeywordAnalysisProperties;
@@ -123,8 +116,6 @@
 	/** The symbol. */
 	private String symbol;
 
-	private AnnotationType viewAnnotation;
-
 	/** The writer. */
 	private Writer writer;
 
@@ -284,30 +275,6 @@
 		return true;
 	}
 
-	private String findAnnotationForLine(Match match, List<Annotation> annots, boolean overlap) {
-		String annotationValue = "";
-		if (annots!=null) {
-			if (!annots.isEmpty()) {
-				for (Annotation annot : annots) {
-					if (overlap) {
-						if ((annot.getStart()<=match.getStart() && annot.getEnd()>=match.getEnd()) || (annot.getStart()>match.getStart() && annot.getEnd()<match.getEnd())
-								) {
-							annotationValue = annot.getValue(); 
-							// use the first Annotation found, the one stored in the temporary HSQL database
-							//should be modified to display a list of annotation values corresponding to the match positions (or wrapped if overlap is admitted)
-						}
-					} else {
-						if (annot.getStart()==match.getStart() && annot.getEnd()==match.getEnd()) {
-							annotationValue = annot.getValue(); 
-							// use the first Annotation found, the one stored in the temporary HSQL database
-						}
-					}
-				}
-			}
-		}
-		return annotationValue;
-	}
-
 	/**
 	 * Gets the analysis property.
 	 *
@@ -317,10 +284,6 @@
 		return pKeywordAnalysisProperties;
 	}
 
-	public boolean getAnnotationOverlap() {
-		return overlapAnnotation;
-	}
-
 	/**
 	 * Gets the corpus.
 	 *
@@ -437,8 +400,6 @@
 
 		Log.info(ConcordanceMessages.Concordance_6 + (to - from + 1) + ConcordanceMessages.Concordance_7);
 
-		AnnotationManager am = KRAnnotationEngine.getAnnotationManager(this.getCorpus());
-
 		AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient();
 
 		long start = System.currentTimeMillis();
@@ -565,18 +526,6 @@
 					//System.out.println("right: "+ctxPosition+" len: "+(ctxPosition - match.getEnd() + 1)+"\n");
 				}
 
-				//List<Annotation> allAnnotations = null;
-				List<Annotation> annotationsPerMatch = null;;
-				if (viewAnnotation != null && am != null) {
-					try {
-						annotationsPerMatch = am.getAnnotationsForMatches(viewAnnotation, subsetMatch, overlapAnnotation);
-						//System.out.println("annotationsPerMatch: "+annotationsPerMatch);
-					} catch (Exception e) {
-						System.out.println("Error while reading annotation "+viewAnnotation+" and with "+subsetMatch.size()+" matches");
-						Log.printStackTrace(e);
-					}
-				}
-
 				//System.out.println("RIGHT ctx lengths: "+lengthOfRightCtx);
 				// get all view property values of all lines
 				Map<Property, List<List<String>>> keywordsViewPropValues = new HashMap<Property, List<List<String>>>();
@@ -705,19 +654,7 @@
 					int targetpos = targetPositions.get(k);
 
 
-					Annotation annotation = null;
 					Match match = matches.get(i- from + k);
-					if (annotationsPerMatch != null) {
-						annotation = annotationsPerMatch.get(k);
-					}
-					TypedValue annotationValue = null;
-					if (annotation!=null) {
-						annotationValue = viewAnnotation.getTypedValue(annotation.getValue());
-						if (annotationValue == null) { // the annotation is not stored in the KR type -> the annotation is surely built with the CQPAnnotationManager
-							//System.out.println("WARNING: no annotation value found for value id="+annotation.getValue()+" - will be created.");
-							annotationValue = new TypedValue(annotation.getValue(), annotation.getValue(), annotation.getType());
-						}
-					}
 
 					Line line = new Line(this, wordids, TextId,
 							lineLeftCtxViewPropValue,
@@ -727,8 +664,6 @@
 							new Reference(ref, pRefViewPattern), 
 							new Reference(refAna, pRefAnalysePattern), 
 							match, 
-							annotation,
-							annotationValue,
 							targetpos);
 					lines.set(i + k, line);
 				}
@@ -834,10 +769,6 @@
 		return symbol;
 	}
 
-	public AnnotationType getViewAnnotation(AnnotationType type) {
-		return viewAnnotation;
-	}
-
 	/**
 	 * Gets the view properties.
 	 *
@@ -929,77 +860,6 @@
 		return index;
 	}
 
-	private List<Annotation> prepareAnnotationsList(List<Match> matches, List<Annotation> annotations, boolean overlap){
-		List<Annotation> annotsList = new ArrayList<Annotation>();
-
-		int iMatch = 0;
-		int iAnnotation = 0;
-		int nMatch = matches.size();
-		int nAnnotations = annotations.size();
-
-		while (iMatch < nMatch && iAnnotation < nAnnotations) {
-			if (overlap) {
-				if (matches.get(iMatch).getEnd() < annotations.get(iAnnotation).getStart()) {
-					iMatch++;
-					annotsList.add(null); // nothing for this match
-				} else if (annotations.get(iAnnotation).getEnd() < matches.get(iMatch).getStart()) {
-					iAnnotation++;
-				} else {
-					annotsList.add(annotations.get(iAnnotation));
-					iMatch++;
-				}
-			} else {
-				if (matches.get(iMatch).getEnd() < annotations.get(iAnnotation).getStart()) {
-					iMatch++;
-					annotsList.add(null); // nothing for this match
-				} else if (annotations.get(iAnnotation).getEnd() < matches.get(iMatch).getStart()) {
-					iAnnotation++;
-				} else if (annotations.get(iAnnotation).getStart() == matches.get(iMatch).getStart() && 
-						annotations.get(iAnnotation).getEnd() == matches.get(iMatch).getEnd()) {
-					annotsList.add(annotations.get(iAnnotation));
-					iMatch++;
-					iAnnotation++;
-				} else {
-					iAnnotation++;
-				}
-			}
-		}
-
-		while (annotsList.size() < matches.size() ) annotsList.add(null); // fill matches that were not process due to no more annotations
-
-		return annotsList;
-	}
-
-	private HashMap<Match, Annotation> prepareAnnotationsMap(List<Match> matches, List<Annotation> annots, boolean overlap){
-		HashMap<Match, Annotation> annotsList = new HashMap<Match, Annotation>();
-		for (Match m : matches) {
-			boolean hasAnnotations = false;
-			if (annots!=null) {
-				if (!annots.isEmpty()) {
-					for (Annotation annot : annots) {
-						if (overlap){
-							if ((annot.getStart() <= m.getStart() && m.getStart() <= annot.getEnd() && m.getEnd() >= annot.getEnd()) || 
-									(annot.getStart() <= m.getEnd() && m.getEnd() <= annot.getEnd() && m.getStart() <= annot.getStart()) 
-									|| !(annot.getEnd() < m.getStart() || annot.getStart() > m.getEnd())){
-								annotsList.put(m, annot);
-								hasAnnotations = true;
-							}
-						} else {
-							if (annot.getStart()==m.getStart() && annot.getEnd()==m.getEnd()) {
-								annotsList.put(m, annot); 
-								hasAnnotations = true;
-							}
-						}
-					}
-				}
-			}
-			if (!hasAnnotations) {
-				annotsList.put(m, null);
-			}
-		}
-		return annotsList;
-	}
-
 	public List<Line> reloadLines(int topLine, int bottomLine) throws CqiClientException, IOException, CqiServerError {
 		for (int i = topLine; i < bottomLine; i++) {
 			lines.set(i, null);
@@ -1118,10 +978,6 @@
 		this.lines = new ArrayList<Line>(Collections.nCopies(nLines, (Line) null)); // empty lines
 	}
 
-	public void setAnnotationOverlap(boolean overlap) {
-		overlapAnnotation = overlap;
-	}
-
 	/**
 	 * Set both left and right contexts size.
 	 * 
@@ -1384,12 +1240,6 @@
 		// is cached anyway...
 	}
 
-	public void setViewAnnotation(AnnotationType type) {
-		viewAnnotation = type;
-		this.lines = new ArrayList<Line>(Collections.nCopies(nLines,
-				(Line) null)); // empty lines
-	}
-
 	/**
 	 * Set the same view properties for left context, right context and keyword.
 	 * 
@@ -1670,4 +1520,12 @@
 		/** The CONTEXT. */
 		CONTEXT
 	}
+
+	/**
+	 * Brutal way to reset the concordance lines. they will be recomputed when getLines(...) is called
+	 */
+	public void resetLines() {
+		lines = new ArrayList<Line>(Collections.nCopies(nLines,
+				(Line) null)); // empty lines
+	}
 }
Index: tmp/org.txm.concordance.core/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.concordance.core/META-INF/MANIFEST.MF	(revision 516)
+++ tmp/org.txm.concordance.core/META-INF/MANIFEST.MF	(revision 517)
@@ -4,8 +4,7 @@
 Bundle-SymbolicName: org.txm.concordance.core;singleton:=true
 Bundle-Version: 1.0.0.qualifier
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Require-Bundle: org.txm.annotation.core;bundle-version="1.0.0";visibility:=reexport,
- org.txm.utils;bundle-version="1.0.0";visibility:=reexport,
+Require-Bundle: org.txm.utils;bundle-version="1.0.0";visibility:=reexport,
  org.txm.searchengine.cqp.core;bundle-version="1.1.0";visibility:=reexport,
  org.eclipse.osgi;bundle-version="3.10.2",
  org.eclipse.core.runtime;bundle-version="3.10.0",
