Index: TXM/trunk/bundles/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/RGBA.java
===================================================================
--- TXM/trunk/bundles/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/RGBA.java	(revision 3707)
+++ TXM/trunk/bundles/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/RGBA.java	(revision 3708)
@@ -1,17 +1,37 @@
 package org.txm.edition.rcp.editors;
 
+import java.awt.Color;
+
 public class RGBA {
 	public int r=0, g=0, b=0;
 	public float a = 1f;
+	
 	public RGBA(int r, int g, int b) {
 		this.r =r;this.g=g; this.b =b;
 	}
-	public RGBA(String rgb) {
-		String[] split = rgb.split(","); //$NON-NLS-1$
-		try{this.r =Integer.parseInt(split[0]);}catch(Exception e){}
-		try{this.g =Integer.parseInt(split[1]);}catch(Exception e){}
-		try{this.b =Integer.parseInt(split[2]);}catch(Exception e){}
+	
+	public RGBA(int r, int g, int b, float a) {
+		this.r =r;this.g=g; this.b =b;this.a =a;
 	}
+	
+	public RGBA(String rgbOrrgba) {
+		if (rgbOrrgba.startsWith("#")) {
+			
+			Color c = HexToColor(rgbOrrgba);
+			
+			this.r = c.getRed();
+			this.g = c.getGreen();
+			this.b = c.getBlue();
+			this.a = c.getAlpha();
+		} else {
+			String[] split = rgbOrrgba.split(","); //$NON-NLS-1$
+			try{this.r =Integer.parseInt(split[0]);}catch(Exception e){}
+			try{this.g =Integer.parseInt(split[1]);}catch(Exception e){}
+			try{this.b =Integer.parseInt(split[2]);}catch(Exception e){}
+			try{this.a =Float.parseFloat(split[3]);}catch(Exception e){}
+		}
+	}
+	
 	public RGBA(String rgb, float a) {
 		String[] split = rgb.split(","); //$NON-NLS-1$
 		try{this.r =Integer.parseInt(split[0]);}catch(Exception e){}
@@ -19,9 +39,30 @@
 		try{this.b =Integer.parseInt(split[2]);}catch(Exception e){}
 		this.a = a;
 	}
-	public RGBA(int r, int g, int b, float a) {
-		this.r =r;this.g=g; this.b =b;this.a =a;
+	
+	/**
+	 * Converts a hex string to a color. If it can't be converted null is returned.
+	 * @param hex (i.e. #CCCCCCFF or CCCCCC)
+	 * @return Color
+	 */
+	public static Color HexToColor(String hex) 
+	{
+	    hex = hex.replace("#", "");
+	    switch (hex.length()) {
+	        case 6:
+	            return new Color(
+	            Integer.valueOf(hex.substring(0, 2), 16),
+	            Integer.valueOf(hex.substring(2, 4), 16),
+	            Integer.valueOf(hex.substring(4, 6), 16));
+	        case 8:
+	            return new Color(
+	            Integer.valueOf(hex.substring(0, 2), 16),
+	            Integer.valueOf(hex.substring(2, 4), 16),
+	            Integer.valueOf(hex.substring(4, 6), 16),
+	            Integer.valueOf(hex.substring(6, 8), 16));
+	    }
+	    return null;
 	}
-
-	public String toString() {return "{"+r+", "+g+","+b+", "+a+"}";} //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+	
+	public String toString() {return ""+r+","+g+","+b+","+a+"f";} //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
 }
Index: TXM/trunk/bundles/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java
===================================================================
--- TXM/trunk/bundles/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java	(revision 3707)
+++ TXM/trunk/bundles/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java	(revision 3708)
@@ -514,7 +514,7 @@
 				// public void widgetDefaultSelected(SelectionEvent e) { }
 				// });
 				if (!text_text.isDisposed()) {
-					Cursor cursor = new Cursor(text_text.getDisplay(), SWT.CURSOR_SIZENS);
+					Cursor cursor = text_text.getDisplay().getSystemCursor(SWT.CURSOR_SIZENS);
 					text_text.setCursor(cursor);
 				}
 			}
Index: TXM/trunk/bundles/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/BackToText.java
===================================================================
--- TXM/trunk/bundles/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/BackToText.java	(revision 3707)
+++ TXM/trunk/bundles/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/BackToText.java	(revision 3708)
@@ -37,7 +37,9 @@
 import org.apache.commons.lang.StringUtils;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.e4.ui.workbench.modeling.EModelService;
 import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Point;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchWindow;
@@ -287,6 +289,14 @@
 				editor.addLinkedEditor(attachedBrowserEditor);
 				
 				int position = SynopticEditionPreferences.getInstance().getInt(SynopticEditionPreferences.BACKTOTEXT_POSITION);
+				if (position == -2) {
+					Point s = editor.getParent().getSize();
+					if (s.x < s.y) {
+						position = EModelService.ABOVE;
+					} else {
+						position = EModelService.RIGHT_OF;
+					}
+				}
 				if (editor != null && position >= 0) {
 					SWTEditorsUtils.addEditor(editor, attachedBrowserEditor, position);
 				}
Index: TXM/trunk/bundles/org.txm.edition.rcp/src/org/txm/edition/rcp/preferences/SynopticEditionPreferencePage.java
===================================================================
--- TXM/trunk/bundles/org.txm.edition.rcp/src/org/txm/edition/rcp/preferences/SynopticEditionPreferencePage.java	(revision 3707)
+++ TXM/trunk/bundles/org.txm.edition.rcp/src/org/txm/edition/rcp/preferences/SynopticEditionPreferencePage.java	(revision 3708)
@@ -34,13 +34,14 @@
 		addField(fast_highlight);
 		
 		String[][] values = {
+				{"RATIO", "-2"}, 
 				{"OVER", "-1"}, 
 				{"ABOVE", ""+EModelService.ABOVE}, 
 				{"BELOW", ""+EModelService.BELOW}, 
 				{"LEFT_OF", ""+EModelService.LEFT_OF}, 
 				{"RIGHT_OF", ""+EModelService.RIGHT_OF}};
 		
-		backtotext_position = new ComboFieldEditor(SynopticEditionPreferences.BACKTOTEXT_POSITION, "new editor position", values, getFieldEditorParent());
+		backtotext_position = new ComboFieldEditor(SynopticEditionPreferences.BACKTOTEXT_POSITION, "Linked editor position", values, getFieldEditorParent());
 		addField(backtotext_position);
 	}
 	
Index: TXM/trunk/bundles/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/BackToMedia.java
===================================================================
--- TXM/trunk/bundles/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/BackToMedia.java	(revision 3707)
+++ TXM/trunk/bundles/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/BackToMedia.java	(revision 3708)
@@ -38,9 +38,11 @@
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.e4.ui.workbench.modeling.EModelService;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.window.Window;
 import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.handlers.HandlerUtil;
@@ -552,6 +554,14 @@
 				
 				// move the editor in the window
 				int position = BackToMediaPreferences.getInstance().getInt(BackToMediaPreferences.BACKTOMEDIA_POSITION);
+				if (position == -2) {
+					Point s = editor.getParent().getSize();
+					if (s.x < s.y) {
+						position = EModelService.ABOVE;
+					} else {
+						position = EModelService.RIGHT_OF;
+					}
+				}
 				if (editor != null && position >= 0) {
 					SWTEditorsUtils.addEditor((EditorPart) editor, mediaPlayerEditor, position);
 				}
Index: TXM/trunk/bundles/org.txm.tigersearch.rcp/src/org/txm/function/tigersearch/TIGERSearch.java
===================================================================
--- TXM/trunk/bundles/org.txm.tigersearch.rcp/src/org/txm/function/tigersearch/TIGERSearch.java	(revision 3707)
+++ TXM/trunk/bundles/org.txm.tigersearch.rcp/src/org/txm/function/tigersearch/TIGERSearch.java	(revision 3708)
@@ -3,8 +3,6 @@
 import java.io.File;
 import java.io.IOException;
 import java.nio.MappedByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
 import org.apache.commons.lang.StringUtils;
@@ -17,7 +15,6 @@
 import org.txm.searchengine.cqp.corpus.WordProperty;
 import org.txm.searchengine.ts.TIGERQuery;
 import org.txm.searchengine.ts.TIGERSearchEngine;
-import org.txm.searchengine.ts.TIGERSelection;
 import org.txm.searchengine.ts.TSCorpus;
 import org.txm.searchengine.ts.TSCorpusManager;
 import org.txm.searchengine.ts.TSMatch;
@@ -25,7 +22,6 @@
 import org.txm.tigersearch.rcp.Messages;
 import org.txm.treesearch.function.TreeSearch;
 import org.txm.treesearch.function.TreeSearchSelector;
-import org.txm.treesearch.preferences.TreeSearchPreferences;
 import org.txm.utils.TXMProgressMonitor;
 import org.txm.utils.logger.Log;
 
@@ -55,7 +51,7 @@
 		
 		this.corpus = getParent();
 		
-		String id = corpus.getRootCorpusBuild().getName();
+		String id = corpus.getRootCorpusBuild().getID();
 		
 		File tsRegistryDirectory = new File(corpus.getProjectDirectory(), "tiger"); //$NON-NLS-1$
 		File configfile = new File(tsRegistryDirectory, "tigersearch.logprop"); //$NON-NLS-1$
Index: TXM/trunk/bundles/org.txm.tigersearch.rcp/src/org/txm/function/tigersearch/TIGERTreeSearchSelector.java
===================================================================
--- TXM/trunk/bundles/org.txm.tigersearch.rcp/src/org/txm/function/tigersearch/TIGERTreeSearchSelector.java	(revision 3707)
+++ TXM/trunk/bundles/org.txm.tigersearch.rcp/src/org/txm/function/tigersearch/TIGERTreeSearchSelector.java	(revision 3708)
@@ -4,11 +4,9 @@
 import org.txm.searchengine.core.SearchEnginesManager;
 import org.txm.searchengine.cqp.corpus.CQPCorpus;
 import org.txm.searchengine.ts.TIGERQuery;
-import org.txm.searchengine.ts.TIGERSearchEngine;
 import org.txm.treesearch.function.TreeSearch;
 import org.txm.treesearch.function.TreeSearchSelector;
 
-
 public class TIGERTreeSearchSelector extends TreeSearchSelector {
 	
 	public static String TIGER = "TIGER"; //$NON-NLS-1$
Index: TXM/trunk/bundles/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERSearchEngine.java
===================================================================
--- TXM/trunk/bundles/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERSearchEngine.java	(revision 3707)
+++ TXM/trunk/bundles/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERSearchEngine.java	(revision 3708)
@@ -10,10 +10,12 @@
 import java.nio.MappedByteBuffer;
 import java.nio.channels.FileChannel;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.BasicConfigurator;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.txm.core.results.TXMResult;
@@ -40,6 +42,8 @@
 import org.txm.utils.io.IOUtils;
 import org.txm.utils.logger.Log;
 
+import ims.tiger.corpus.Feature;
+import ims.tiger.corpus.Header;
 import ims.tiger.corpus.Sentence;
 import ims.tiger.corpus.T_Node;
 import ims.tiger.index.reader.Index;
@@ -52,18 +56,18 @@
 import ims.tiger.query.processor.CorpusQueryProcessor;
 
 public class TIGERSearchEngine extends SearchEngine {
-	
+
 	public static final String NAME = "TIGER";
-	
+
 	HashMap<CorpusBuild, TSCorpus> corpora = null;
-	
+
 	public TSCorpus getTSCorpus(CorpusBuild corpus) {
 		CorpusBuild root = corpus.getRootCorpusBuild();
 		TSCorpus tscorpus = corpora.get(root);
 		if (tscorpus != null) {
 			return tscorpus;
 		}
-		
+
 		File tigerDirectory = new File(root.getProjectDirectory(), "tiger");
 		File configfile = new File(tigerDirectory, "tigersearch.logprop");
 		if (!tigerDirectory.exists()) {
@@ -72,7 +76,7 @@
 		if (!configfile.exists()) {
 			return null;
 		}
-		
+
 		TSCorpusManager manager = new TSCorpusManager(tigerDirectory, configfile);
 		tscorpus = manager.getCorpus(root.getID());
 		if (tscorpus != null) {
@@ -83,22 +87,22 @@
 			return null;
 		}
 	}
-	
+
 	public TSCorpus removeTSCorpus(CorpusBuild corpus) {
 		CorpusBuild root = corpus.getRootCorpusBuild();
 		return corpora.remove(root);
 	}
-	
+
 	@Override
 	public boolean isRunning() {
 		return true;
 	}
-	
+
 	@Override
 	public boolean initialize() throws Exception {
 		return true;
 	}
-	
+
 	/**
 	 * 
 	 * @param cqpCorpus the targeted CQPCorpus
@@ -114,10 +118,10 @@
 		if (matches.size() == 0) {
 			return new int[] { 0, 0 };
 		}
-		
+
 		return getSentMinMax(cqpCorpus, matches.get(0).getStart(), matches.get(matches.size() - 1).getEnd());
 	}
-	
+
 	/**
 	 * 
 	 * @param cqpCorpus the targeted CQPCorpus
@@ -143,7 +147,7 @@
 		int sent_max = structs[structs.length - 1];
 		return new int[] { sent_min, sent_max };
 	}
-	
+
 	/**
 	 * 
 	 * @return true because TIGER queries are frequently multi lines
@@ -152,13 +156,13 @@
 	public boolean hasMultiLineQueries() {
 		return true;
 	}
-	
+
 	@Override
 	public boolean start(IProgressMonitor monitor) throws Exception {
 		corpora = new HashMap<>();
 		return true;
 	}
-	
+
 	@Override
 	public boolean stop() throws Exception {
 		if (corpora != null) {
@@ -169,15 +173,15 @@
 		}
 		return true;
 	}
-	
+
 	@Override
 	public String getName() {
 		return NAME;
 	}
-	
+
 	@Override
 	public Selection query(CorpusBuild corpus, IQuery query, String name, boolean saveQuery) throws Exception {
-		
+
 		TSCorpus tcorpus = this.getTSCorpus(corpus);
 		TSResult result = null;
 		if (corpus == corpus.getRootCorpusBuild() || !(corpus instanceof CQPCorpus)) { // root corpus or something not a CQPCorpus
@@ -200,12 +204,12 @@
 			Log.finest("QUERYING sentences: " + sent_min + " -> " + sent_max);
 			result = tcorpus.query(query.getQueryString().replace("\n", " "), sent_min, sent_max + 1, -1);
 		}
-		
+
 		return fromTIGERMatchToSelection(tcorpus, result, query, corpus);
 	}
-	
+
 	public static Selection fromTIGERMatchToSelection(TSCorpus tcorpus, TSResult result, IQuery query, CorpusBuild corpus) throws IndexException {
-		
+
 		MatchResult mresult = result.getMatchResult();
 		int size = mresult.size();
 		// System.out.println("size: "+size);
@@ -213,43 +217,43 @@
 		if (size == 0 || subsize == 0) {
 			return new EmptySelection(query);
 		}
-		
+
 		Index index = tcorpus.getIndex();
-		
+
 		// compute sentence positions
 		// TODO move it to TSCorpus
 		int[] starts = tcorpus.getSentenceStartPositions();
-		
+
 		LinkedHashSet<TIGERMatch> tigerMatchesList = new LinkedHashSet<>();
-		
+
 		List<String> variables = java.util.Arrays.asList(mresult.getVariableNames());
 		// System.out.println("Variables: "+variables+" iPivot="+variables.indexOf("pivot"));
 		int iPivot = variables.indexOf("pivot");
-		
+
 		MappedByteBuffer offsetsMapped = tcorpus.getOffsetsMapped();
 		// MappedByteBuffer offsetsMapped = tcorpus.getOffsetsMapped();
-		
+
 		boolean useSubMatches = TigerSearchTreePreferences.getInstance().getBoolean(TigerSearchTreePreferences.USESUBMATCHES);
-		
+
 		// System.out.println("submatchSize: "+subsize);
 		for (int isentMatch = 0; isentMatch < size; isentMatch++) { // the matching sentences
 			int sent = mresult.getSentenceNumberAt(isentMatch);
 			// Sentence sentence = tcorpus.manager.getSentence(sent);
-			
+
 			// System.out.println(" sent: "+sent);
 			int sent_submatch = mresult.getSentenceSubmatchSize(sent);
-			
+
 			// System.out.println(" sent submatch size: "+sent_submatch);
 			for (int iSubMatch = 0; iSubMatch < sent_submatch; iSubMatch++) { // the matches in the sentence
 				int[] match = mresult.getSentenceSubmatchAt(sent, iSubMatch);
-				
+
 				int sent_start = starts[sent];
-				
+
 				// System.out.println(" sent="+sent_start+ " matches="+Arrays.toString(match)+" ipivot="+iPivot);
 				for (int i = 0; i < match.length; i++) {
-					
+
 					if (iPivot != -1 && i != iPivot) continue; // skip match that are not 'pivot'
-					
+
 					int left = sent_start + index.getLeftCorner(sent, match[i]);
 					if (offsetsMapped != null) { // the TIGER token is not in the CQP corpus
 						left += offsetsMapped.getInt(left * Integer.BYTES);
@@ -260,51 +264,51 @@
 						right += offsetsMapped.getInt(right * Integer.BYTES);
 					}
 					// System.out.println(" M="+match[i]+" ("+left+", "+right+")");
-					
+
 					TIGERMatch tigerMatch = new TIGERMatch(left, right);
-					
+
 					// System.out.println(" ajusted="+(tigerMatch));
 					tigerMatchesList.add(tigerMatch);
-					
+
 					if (!useSubMatches) { // use only the first submatch
 						break;
 					}
 				}
 			}
 		}
-		
+
 		// intersect with corpus matches
 		List<? extends Match> result2 = Match.intersect(corpus.getMatches(), new ArrayList<>(tigerMatchesList), true);
-		
+
 		return new TIGERSelection(query, result2);
 	}
-	
+
 	@Override
 	public Query newQuery() {
 		return new TIGERQuery();
 	}
-	
+
 	@Override
 	public boolean hasIndexes(CorpusBuild corpus) {
 		if (corpus == null) return false;
-		
+
 		// TODO implement a corpora of TIGER corpus
 		CorpusBuild root = corpus.getRootCorpusBuild();
 		File buildDirectory = new File(root.getProjectDirectory(), "tiger");
 		return new File(buildDirectory, "tigersearch.logprop").exists() &&
 				new File(buildDirectory, root.getID()).exists();
 	}
-	
+
 	@Override
 	public void notify(TXMResult r, String state) {
-//		if (r instanceof MainCorpus && "clean".equals(state)) { // the CQP corpus has been deleted by the user
-//			MainCorpus c = (MainCorpus) r;
-//			File buildDirectory = new File(c.getProjectDirectory(), "tiger/" + c.getID());
-//			if (buildDirectory.exists()) {
-//				DeleteDir.deleteDirectory(buildDirectory);
-//			}
-//		}
-//		else
+		//		if (r instanceof MainCorpus && "clean".equals(state)) { // the CQP corpus has been deleted by the user
+		//			MainCorpus c = (MainCorpus) r;
+		//			File buildDirectory = new File(c.getProjectDirectory(), "tiger/" + c.getID());
+		//			if (buildDirectory.exists()) {
+		//				DeleteDir.deleteDirectory(buildDirectory);
+		//			}
+		//		}
+		//		else
 		if (r instanceof Project && "clean".equals(state)) {  // the Project has been deleted by the user
 			Project c = (Project) r;
 			File buildDirectory = new File(c.getProjectDirectory(), "tiger");
@@ -313,19 +317,19 @@
 			}
 		}
 	}
-	
+
 	@Override
 	public String getValueForProperty(Match match, SearchEngineProperty property) {
 		// TODO Auto-generated method stub
 		return null;
 	}
-	
+
 	@Override
 	public List<String> getValuesForProperty(Match match, SearchEngineProperty property) {
 		// TODO Auto-generated method stub
 		return null;
 	}
-	
+
 	/**
 	 * 
 	 * @param sourceDirectory must contain the main.xml file
@@ -335,12 +339,12 @@
 	 * @throws UnsupportedEncodingException 
 	 */
 	public static boolean buildTIGERCorpus(File sourceDirectory, File binaryDirectory, String corpusName) throws UnsupportedEncodingException, FileNotFoundException {
-		
+
 		File tigerDir = new File(binaryDirectory, "tiger");
 		tigerDir.mkdir();
-		
+
 		File logprop = new File(tigerDir, "tigersearch.logprop");
-		
+
 		PrintWriter writer = IOUtils.getWriter(logprop, "UTF-8");
 		writer.println("# Default log configuration of the TIGERSearch suite"+"\n"+
 				"log4j.rootLogger=SEVERE,Logfile"+"\n"+
@@ -351,25 +355,25 @@
 				"log4j.appender.Logfile.MaxBackupIndex=1"+"\n"+
 				"log4j.appender.Logfile.layout=org.apache.log4j.PatternLayout"+"\n"+
 				"log4j.appender.Logfile.layout.ConversionPattern=%5r %-5p [%t] %c{2} - %m%n");
-		
+
 		BasicConfigurator.configure();
-		
+
 		String driverFilename = TigerSearchPreferences.getInstance().getString(TigerSearchPreferences.DRIVER_FILENAME);
-		
+
 		File master = new File(sourceDirectory, driverFilename);
 		if (!master.exists()) {
 			File[] xmlFiles = sourceDirectory.listFiles(new FileFilter() {
-						public boolean accept(File file) {
-							if (file.isDirectory()) return false;
-							if (file.isHidden()) return false;
-							String filename = file.getName();
-							if (filename.equals("import.xml")) return false;
-							if (!filename.endsWith(".xml")) return false;
-							
-							return true;
-						}
-					});
-			
+				public boolean accept(File file) {
+					if (file.isDirectory()) return false;
+					if (file.isHidden()) return false;
+					String filename = file.getName();
+					if (filename.equals("import.xml")) return false;
+					if (!filename.endsWith(".xml")) return false;
+
+					return true;
+				}
+			});
+
 			if (xmlFiles == null) {
 				System.out.println("No master file found in: "+sourceDirectory);
 				return false;
@@ -381,10 +385,10 @@
 		tigerBinDir.mkdir();
 		try {
 			IndexBuilderErrorHandler handler = new SimpleErrorHandler(tigerBinDir.getAbsolutePath()) {
-						public void setMessage(String message) { }
-						public void setNumberOfSentences(int number) { }
-						public void setProgressBar(int value) { }
-					};
+				public void setMessage(String message) { }
+				public void setNumberOfSentences(int number) { }
+				public void setProgressBar(int value) { }
+			};
 			XMLIndexing indexing = new XMLIndexing(corpusName, uri, tigerBinDir.getAbsolutePath(), handler, false);
 			indexing.startIndexing();
 			File logs = new File(tigerBinDir, "indexing.log");
@@ -400,32 +404,32 @@
 		}
 		return true;
 	}
-	
 
+
 	public static int writeOffsetDataFiles(MainCorpus corpus, String wordIdAttribute, File tigerCorpusDirectory, File tigerDirectory, File tigerCorpusExistingDirectory) throws IndexException, QueryIndexException, UnexpectedAnswerException, IOException, CqiServerError, CqiClientException {
-		
+
 		// TXM corpus files
 		File configfile = new File(tigerDirectory, "tigersearch.logprop");
-		
+
 		TSCorpusManager manager = new TSCorpusManager(tigerCorpusDirectory.getParentFile(), configfile);
 		TSCorpus tcorpus = manager.getCorpus(tigerCorpusDirectory.getName());
 		InternalCorpusQueryManagerLocal2 tigermanager = tcorpus.manager;
 		CorpusQueryProcessor processor = tigermanager.getQueryProcessor();
 		AbstractCqiClient CQI = CQPSearchEngine.getCqiClient();
-		
+
 		Index index = processor.getIndex();
 		int size = 0;
 		for (int nr = 0; nr < index.getNumberOfGraphs(); nr++) {
 			size += index.getNumberOfTNodes(nr);
 		}
-		
+
 		if (size == 0) {
 			Log.warning("No word found in the TIGERSearch corpus: " + tigerCorpusDirectory + ". Aborting.");
 			return 0;
 		}
-		
+
 		Log.info("Importing " + size + " word annotations...");
-		
+
 		// compute start position of sentences
 		int[] starts = new int[index.getNumberOfGraphs()];
 		for (int i = 0; i < index.getNumberOfGraphs(); i++) {
@@ -434,33 +438,33 @@
 				starts[i] += index.getNumberOfTNodes(i - 1) + starts[i - 1];
 			}
 		}
-		
+
 		File offsetsFile = new File(tigerCorpusExistingDirectory, "offsets.data");
 		RandomAccessFile offsetsRAFile = new RandomAccessFile(offsetsFile, "rw");
 		FileChannel offsetsFileChannel = offsetsRAFile.getChannel();
 		MappedByteBuffer offsetsMapped = offsetsFileChannel.map(FileChannel.MapMode.READ_WRITE, 0, size * Integer.BYTES);
 		// out.putInt(positions[i])
-		
+
 		File presencesFile = new File(tigerCorpusExistingDirectory, "presences.data");
 		RandomAccessFile presencesRAFile = new RandomAccessFile(presencesFile, "rw");
 		FileChannel presencesFileChannel = presencesRAFile.getChannel();
 		MappedByteBuffer presencesMapped = presencesFileChannel.map(FileChannel.MapMode.READ_WRITE, 0, size);
-		
+
 		int numberOfWordsAnnotated = 0;
-		
+
 		// for each sentence
 		ConsoleProgressBar cpb = new ConsoleProgressBar(index.getNumberOfGraphs());
 		for (int nr = 0; nr < index.getNumberOfGraphs(); nr++) {
 			cpb.tick();
 			int sent_size = index.getNumberOfTNodes(nr);
 			Sentence sent = tcorpus.manager.getSentence(nr);
-			
+
 			String[] ids = new String[sent_size];
 			int[] tigerPositions = new int[sent_size];
 			for (int t = 0; t < sent_size; t++) {
 				T_Node terminal = (T_Node) sent.getTerminalAt(t);
 				ids[t] = terminal.getFeature(wordIdAttribute);
-				
+
 				// try fixing ID
 				if (ids[t].startsWith("w")) {
 					if (!ids[t].startsWith("w_")) {
@@ -473,7 +477,7 @@
 				tigerPositions[t] = starts[nr] + t;
 				// System.out.println("T id="+terminal.getID());
 			}
-			
+
 			int[] ids_idx = CQI.str2Id(corpus.getProperty("id").getQualifiedName(), ids);
 			Integer[] cqpPositions = new Integer[sent_size];
 			Integer[] offsets = new Integer[sent_size];
@@ -489,7 +493,7 @@
 					Log.warning("Could not find word for id=" + ids[t]);
 					cqpPositions[t] = null;
 				}
-				
+
 				if (cqpPositions[t] != null) {
 					offsets[t] = cqpPositions[t] - tigerPositions[t];
 				}
@@ -502,10 +506,10 @@
 			// System.out.println("tiger positions="+Arrays.toString(tigerPositions));
 			// System.out.println("cqp positions="+Arrays.toString(cqpPositions));
 			// System.out.println("offsets="+Arrays.toString(offsets));
-			
+
 			// writing data to offset and presences files
 			for (int t = 0; t < sent_size; t++) {
-				
+
 				if (offsets[t] != null) {
 					numberOfWordsAnnotated++;
 					presencesMapped.put((byte) 1);
@@ -518,12 +522,103 @@
 			}
 		}
 		cpb.done();
-		
+
 		offsetsFileChannel.close();
 		offsetsRAFile.close();
 		presencesFileChannel.close();
 		presencesRAFile.close();
-		
+
 		return numberOfWordsAnnotated;
 	}
+
+	public String hasAdditionalDetailsForResult(TXMResult result) {
+		if (result instanceof CQPCorpus) {
+			return hasIndexes((CQPCorpus)result)?"Syntax":null;
+		}
+		return null;
+	}
+
+	public String getAdditionalDetailsForResult(TXMResult result) {
+		if (result instanceof CQPCorpus) {
+			TSCorpus tscorpus = this.getTSCorpus((CQPCorpus)result);
+			Index index = tscorpus.getIndex();
+			Header header = tscorpus.getHeader();
+			StringBuilder buffer = new StringBuilder();
+			buffer.append("<h3>TIGERSearch informations</h3>\n");
+			buffer.append("<h4>Commons</h4>\n");
+			buffer.append("<p>Name: "+header.getCorpus_Name()+"</p>\n");
+			buffer.append("<p>Id: "+header.getCorpus_ID()+"</p>\n");
+			buffer.append("<p>Date: "+header.getCorpus_Date()+"</p>\n");
+			buffer.append("<p>Format: "+header.getCorpus_Format()+"</p>\n");
+			buffer.append("<p>History: "+header.getCorpus_History()+"</p>\n");
+			buffer.append("<h4>Statiticss</h4>\n");
+			buffer.append("<p>Edges: "+header.getNumberOfEdges()+"</p>\n");
+			buffer.append("<p>Sentences: "+header.getNumberOfSentences()+"</p>\n");
+			buffer.append("<p>NT Nodes: "+header.getNumberOfNTNodes()+"</p>\n");
+			buffer.append("<p>T Nodes: "+header.getNumberOfTNodes()+"</p>\n");
+			buffer.append("<h4>Terminals</h4>\n");
+			//buffer.append("<p>"+header.getAllTerminalFeatures()+"</p>\n");
+			buffer.append("<p>"+header.getAllTerminalFeaturesSize()+" "+StringUtils.join(header.getAllTFeatureNames(), ", ")+"</p>\n");
+			if (header.getAllTFeatureNames().size() > 0) {
+				buffer.append("<ul>\n");
+				for (Object name : header.getAllTFeatureNames()) {
+					Feature f = header.getTFeature(name.toString());
+					buffer.append("<li>"+f.getName());
+					List desc = f.getDescriptions();
+					List vals = f.getItems();
+					if (f.getItems().size() > 0) {
+						buffer.append(":");
+						for (int i = 0 ; i < vals.size() ; i++) {
+							if (i > 0) buffer.append(",");
+							buffer.append(" ("+vals.get(i)+": "+desc.get(i)+")");
+						}
+					} else { // not defined
+						try {
+							LinkedHashSet<String> values = new LinkedHashSet<String>();
+							for (int p = 0 ; p < 20 ; p++) {
+								values.add(index.getTFeatureValueAt(name.toString(), p));
+							}
+							if (values.size() > 0) {
+								buffer.append(": "+StringUtils.join(values, ", "));
+							}
+						} catch (IndexException e) {
+							// TODO Auto-generated catch block
+							e.printStackTrace();
+						}
+					}
+					buffer.append("</li>\n");
+				}
+				buffer.append("</ul>\n");
+			}
+
+			buffer.append("<h4>Non-Terminals</h4>\n");
+			//buffer.append("<p>"+header.getAllNonterminalFeatures()+"</p>\n");
+			buffer.append("<p>"+header.getAllNonterminalFeaturesSize()+" "+StringUtils.join(header.getAllNTFeatureNames(), ", ")+"</p>\n");
+			if (header.getAllNTFeatureNames().size() > 0) {
+				buffer.append("<ul>\n");
+				for (Object name : header.getAllNTFeatureNames()) {
+					Feature f = header.getNTFeature(name.toString());
+					buffer.append("<li>"+f.getName());
+					List desc = f.getDescriptions();
+					List vals = f.getItems();
+					if (f.getItems().size() > 0) {
+						buffer.append(":");
+						for (int i = 0 ; i < vals.size() ; i++) {
+							if (i > 0) buffer.append(",");
+							if (vals.get(i).equals(desc.get(i))) {
+								buffer.append(" "+vals.get(i));
+							} else {
+								buffer.append(" "+vals.get(i)+" ("+desc.get(i)+")");
+							}
+						}
+					}
+					buffer.append("</li>\n");
+				}
+				buffer.append("</ul>\n");
+			}
+
+			return buffer.toString();
+		}
+		return null;
+	}
 }
Index: TXM/trunk/bundles/org.txm.texts.rcp/src/org/txm/texts/rcp/TextsViewEditor.java
===================================================================
--- TXM/trunk/bundles/org.txm.texts.rcp/src/org/txm/texts/rcp/TextsViewEditor.java	(revision 3707)
+++ TXM/trunk/bundles/org.txm.texts.rcp/src/org/txm/texts/rcp/TextsViewEditor.java	(revision 3708)
@@ -3,6 +3,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.eclipse.e4.ui.workbench.modeling.EModelService;
 import org.eclipse.jface.viewers.ColumnLabelProvider;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
@@ -14,6 +15,7 @@
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Label;
@@ -261,6 +263,14 @@
 				if (o != null && o instanceof Text) {
 					SynopticEditionEditor editor = OpenEdition.openEdition(getResult().getCorpus(), new String[] {getResult().getProject().getDefaultEditionName()}, ((Text)o).getName());
 					int position = SynopticEditionPreferences.getInstance().getInt(SynopticEditionPreferences.BACKTOTEXT_POSITION);
+					if (position == -2) {
+						Point s = editor.getParent().getSize();
+						if (s.x < s.y) {
+							position = EModelService.ABOVE;
+						} else {
+							position = EModelService.RIGHT_OF;
+						}
+					}
 					if (editor != null && position >= 0) {
 						SWTEditorsUtils.addEditor(editor, TextsViewEditor.this, position);
 					}
Index: TXM/trunk/bundles/org.txm.treesearch.rcp/src/org/txm/treesearch/command/ComputeTreeSearch.java
===================================================================
--- TXM/trunk/bundles/org.txm.treesearch.rcp/src/org/txm/treesearch/command/ComputeTreeSearch.java	(revision 3707)
+++ TXM/trunk/bundles/org.txm.treesearch.rcp/src/org/txm/treesearch/command/ComputeTreeSearch.java	(revision 3708)
@@ -187,7 +187,6 @@
 			}
 		}
 		else {
-			
 			Log.warning(Messages.bind(Messages.SelectionIsNotACorpusP0, obj));
 			return null;
 		}
Index: TXM/trunk/bundles/org.txm.treesearch.rcp/src/org/txm/treesearch/command/SendToTreeSearch.java
===================================================================
--- TXM/trunk/bundles/org.txm.treesearch.rcp/src/org/txm/treesearch/command/SendToTreeSearch.java	(revision 3707)
+++ TXM/trunk/bundles/org.txm.treesearch.rcp/src/org/txm/treesearch/command/SendToTreeSearch.java	(revision 3708)
@@ -27,15 +27,16 @@
 //
 package org.txm.treesearch.command;
 
-import java.io.IOException;
 import java.util.List;
 
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.text.TextSelection;
+import org.eclipse.e4.ui.workbench.modeling.EModelService;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.graphics.Point;
 import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.part.EditorPart;
 import org.txm.concordance.core.functions.Concordance;
 import org.txm.concordance.core.functions.Line;
 import org.txm.concordance.rcp.editors.ConcordanceEditor;
@@ -43,18 +44,17 @@
 import org.txm.edition.rcp.editors.SynopticEditionEditor;
 import org.txm.objects.Match;
 import org.txm.rcp.editors.ITXMResultEditor;
+import org.txm.rcp.editors.TXMEditor;
 import org.txm.rcp.handlers.BaseAbstractHandler;
 import org.txm.rcp.utils.SWTEditorsUtils;
 import org.txm.searchengine.core.Selection;
 import org.txm.searchengine.cqp.CQPSearchEngine;
-import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
-import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException;
 import org.txm.searchengine.cqp.corpus.CQPCorpus;
 import org.txm.searchengine.cqp.corpus.WordProperty;
 import org.txm.searchengine.cqp.corpus.query.CQLQuery;
-import org.txm.searchengine.cqp.serverException.CqiServerError;
 import org.txm.treesearch.editor.TreeSearchEditor;
 import org.txm.treesearch.function.TreeSearch;
+import org.txm.treesearch.preferences.TreeSearchPreferences;
 import org.txm.treesearch.rcp.Messages;
 import org.txm.utils.logger.Log;
 
@@ -113,7 +113,7 @@
 		}
 		
 		if (word_id != null) {
-			WordProperty p_id = editor.getCorpus().getProperty("id");
+			//WordProperty p_id = editor.getCorpus().getProperty("id");
 			Selection sel = CQPSearchEngine.getEngine().query(editor.getCorpus(), new CQLQuery("[id=\""+word_id+"\" & _.text_id=\""+editor.getResult().getName()+"\"]"), "TMP", false);
 			if (sel.getNMatch() > 0) {
 				kp = sel.getMatches().get(0).getStart();
@@ -187,32 +187,49 @@
 		
 		try {
 			boolean c = ts.compute();
-			Selection sel = ts.getSelection();
 			
 //			System.out.println("KP="+kp);
-			if (c &&  sel != null) {
-				int i = 0;
-				List<? extends Match> matches = ts.getSelection().getMatches();
-				
-				for (Match m : matches) {
-					if (m.getStart() <= kp && kp <= m.getEnd()) {
-//						System.out.println("set index "+(i+1));
-						ts.setIndexAndSubIndex(i+1, 1);
-						break;
+			if (c) {
+				Selection sel = ts.getSelection();
+				if (sel != null) {
+					int i = 0;
+					List<? extends Match> matches = ts.getSelection().getMatches();
+					
+					for (Match m : matches) {
+						if (m.getStart() <= kp && kp <= m.getEnd()) {
+//							System.out.println("set index "+(i+1));
+							ts.setIndexAndSubIndex(i+1, 1);
+							break;
+						}
+						i++;
 					}
-					i++;
 				}
 			}
 		}
 		catch (Exception e) {
-			// TODO Auto-generated catch block
 			e.printStackTrace();
+			return null;
 		}
 		
 		if (leditor == null) {
-			ITXMResultEditor<TXMResult> openedEditor = ComputeTreeSearch.openEditor(ts);
+			
+			TreeSearchEditor openedEditor = ComputeTreeSearch.openEditor(ts);
+			
 			if (openedEditor != null) {
 				editor.addLinkedEditor(openedEditor);
+
+				int position = TreeSearchPreferences.getInstance().getInt(TreeSearchPreferences.BACKTOTREE_POSITION);
+				if (position == -2 && editor instanceof TXMEditor) {
+					Point p = ((TXMEditor)editor).getParent().getSize();
+					if (p.x < p.y) {
+						position = EModelService.ABOVE;
+					} else {
+						position = EModelService.RIGHT_OF;
+					}
+				}
+				if (editor != null && position >= 0 && editor instanceof EditorPart) {
+					SWTEditorsUtils.addEditor((EditorPart)editor, openedEditor, position);
+				}
 			}
 			return openedEditor;
 		} else {
Index: TXM/trunk/bundles/org.txm.treesearch.rcp/src/org/txm/treesearch/preferences/TreeSearchPreferencePage.java
===================================================================
--- TXM/trunk/bundles/org.txm.treesearch.rcp/src/org/txm/treesearch/preferences/TreeSearchPreferencePage.java	(revision 3707)
+++ TXM/trunk/bundles/org.txm.treesearch.rcp/src/org/txm/treesearch/preferences/TreeSearchPreferencePage.java	(revision 3708)
@@ -1,5 +1,7 @@
 package org.txm.treesearch.preferences;
 
+import org.eclipse.e4.ui.workbench.modeling.EModelService;
+import org.eclipse.jface.preference.ComboFieldEditor;
 import org.eclipse.jface.preference.StringFieldEditor;
 import org.eclipse.ui.IWorkbench;
 import org.txm.rcp.IImageKeys;
@@ -15,10 +17,23 @@
  */
 public class TreeSearchPreferencePage extends TXMPreferencePage {
 
+	private ComboFieldEditor backtotext_position;
+	
 	@Override
 	public void createFieldEditors() {
 		
 		this.addField(new StringFieldEditor(TreeSearchPreferences.DEFAULT_VISUALISATION, Messages.DefaultSyntacticVisualisation, this.getFieldEditorParent()));
+		
+		String[][] values = {
+				{"RATIO", "-2"},
+				{"OVER", "-1"}, 
+				{"ABOVE", ""+EModelService.ABOVE}, 
+				{"BELOW", ""+EModelService.BELOW}, 
+				{"LEFT_OF", ""+EModelService.LEFT_OF}, 
+				{"RIGHT_OF", ""+EModelService.RIGHT_OF}};
+		
+		backtotext_position = new ComboFieldEditor(TreeSearchPreferences.BACKTOTREE_POSITION, "Linked editor position", values, getFieldEditorParent());
+		addField(backtotext_position);
 	}
 	
 	/*
Index: TXM/trunk/bundles/org.txm.treesearch.rcp/src/org/txm/treesearch/editor/TreeSearchEditor.java
===================================================================
--- TXM/trunk/bundles/org.txm.treesearch.rcp/src/org/txm/treesearch/editor/TreeSearchEditor.java	(revision 3707)
+++ TXM/trunk/bundles/org.txm.treesearch.rcp/src/org/txm/treesearch/editor/TreeSearchEditor.java	(revision 3708)
@@ -6,12 +6,16 @@
 import java.util.HashMap;
 import java.util.List;
 
+import org.eclipse.e4.ui.workbench.modeling.EModelService;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.events.MenuDetectEvent;
+import org.eclipse.swt.events.MenuDetectListener;
 import org.eclipse.swt.events.MouseEvent;
 import org.eclipse.swt.events.MouseWheelListener;
 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;
@@ -20,6 +24,8 @@
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
 import org.eclipse.swt.widgets.Spinner;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorSite;
@@ -129,7 +135,11 @@
 					}
 					updateFields = true;
 				}
+				
 				if (updateFields) {
+					
+					TreeSearch currentTreeSearch = tsPerRepresentation.get(currentSelector.getEngine());
+					
 					queryArea.setQueryClass(currentSelector.getQueryClass());
 					initializeFields();
 					getEditorInput().setResult(tsPerRepresentation.get(currentSelector.getEngine()));
@@ -186,24 +196,7 @@
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				
-				try {
-					String[] currentMatch = TreeSearchEditor.this.getResult().getTextAndWordIDSOfCurrentSentence();
-					if (currentMatch == null || currentMatch.length != 2 || currentMatch[0] == null || currentMatch[1] == null) {
-						return;
-					}
-					String textId = currentMatch[0];
-					String wordId = currentMatch[1];
-					
-					SynopticEditionEditor editor = OpenEdition.openEdition(corpus, null, textId, null, wordId);
-					int position = SynopticEditionPreferences.getInstance().getInt(SynopticEditionPreferences.BACKTOTEXT_POSITION);
-					if (editor != null && position >= 0) {
-						SWTEditorsUtils.addEditor(editor, TreeSearchEditor.this, position);
-					}
-				}
-				catch (Exception e1) {
-					// TODO Auto-generated catch block
-					e1.printStackTrace();
-				}
+				readText();
 			}
 			
 			@Override
@@ -375,10 +368,62 @@
 			}
 		});
 		
+//		svgPanel.addMenuDetectListener(new MenuDetectListener() {
+//			
+//			@Override
+//			public void menuDetected(MenuDetectEvent e) {
+//				
+//				Menu menu = svgPanel.getMenu();
+//				System.out.println(menu);
+//				MenuItem editionItem = new MenuItem(menu, SWT.PUSH);
+//				editionItem.setText("Read text");
+//				editionItem.addSelectionListener(new SelectionListener() {
+//					
+//					@Override
+//					public void widgetSelected(SelectionEvent e) {
+//						readText();
+//					}
+//					
+//					@Override
+//					public void widgetDefaultSelected(SelectionEvent e) { }
+//				});
+//			}
+//		});
+	
+		
 		// this.getTopToolbar().setVisible(COMPUTING_PARAMETERS_GROUP_ID, true);
 		initializeFields();
 	}
 	
+	protected void readText() {
+		try {
+			String[] currentMatch = TreeSearchEditor.this.getResult().getTextAndWordIDSOfCurrentSentence();
+			if (currentMatch == null || currentMatch.length != 2 || currentMatch[0] == null || currentMatch[1] == null) {
+				return;
+			}
+			String textId = currentMatch[0];
+			String wordId = currentMatch[1];
+			
+			SynopticEditionEditor editor = OpenEdition.openEdition(corpus, null, textId, null, wordId);
+			int position = SynopticEditionPreferences.getInstance().getInt(SynopticEditionPreferences.BACKTOTEXT_POSITION);
+			if (position == -2) {
+				Point s = editor.getParent().getSize();
+				if (s.x < s.y) {
+					position = EModelService.ABOVE;
+				} else {
+					position = EModelService.RIGHT_OF;
+				}
+			}
+			if (editor != null && position >= 0) {
+				SWTEditorsUtils.addEditor(editor, TreeSearchEditor.this, position);
+			}
+		}
+		catch (Exception e1) {
+			// TODO Auto-generated catch block
+			e1.printStackTrace();
+		}
+	}
+
 	protected void initializeFields() {
 		// String id = corpus.getID();
 		
