Index: TXM/trunk/org.txm.treesearch.rcp/src/org/txm/treesearch/command/SendToTreeSearch.java
===================================================================
--- TXM/trunk/org.txm.treesearch.rcp/src/org/txm/treesearch/command/SendToTreeSearch.java	(revision 3555)
+++ TXM/trunk/org.txm.treesearch.rcp/src/org/txm/treesearch/command/SendToTreeSearch.java	(revision 3556)
@@ -27,10 +27,12 @@
 //
 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.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.ui.handlers.HandlerUtil;
@@ -44,6 +46,13 @@
 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.rcp.Messages;
@@ -74,17 +83,52 @@
 		if (editor instanceof ConcordanceEditor) {
 			return concordancetoTree(editor, s);
 		} else if (editor instanceof SynopticEditionEditor) {
-			return editiontoTree(editor, s);
+			try {
+				return editiontoTree((SynopticEditionEditor) editor, s);
+			}
+			catch (Exception e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+		
+		return null;
+	}
+	
+	public Object editiontoTree(SynopticEditionEditor editor, ISelection s) throws Exception {
+		
+		if (editor.getEditionPanels().size() == 0) { // broken or no edition
+			return null;
+		}
+		
+		int kp = -1;
+		System.out.println("s="+s.getClass()+" "+s);
+
+		String[] words = editor.getEditionPanel(0).getWordSelection();
+		String word_id = null;
+		if (words[0] != null && !words[0].isEmpty()) {
+			word_id = words[0];
+		
 		} else {
+			word_id = editor.getEditionPanel(0).getCurrentPage().getWordId();
+		}
+		
+		if (word_id != null) {
+			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();
+			}
+		}
+		
+		if (kp == -1) {
+			Log.warning("No word found to show");
 			return null;
 		}
+		
+		return toTree(editor, s, kp, editor.getCorpus());
 	}
 	
-	public Object editiontoTree(ITXMResultEditor<? extends TXMResult> editor, ISelection s) {
-		System.out.println("Send EDITION TO TREE");
-		return null;
-	}
-	
 	public Object concordancetoTree(ITXMResultEditor<? extends TXMResult> editor, ISelection s) {
 		TXMResult r = editor.getResult();
 		
@@ -114,14 +158,24 @@
 		}
 		Line l = (Line)o;
 		//TreeSearchSelector selector = ComputeTreeSearch.getSelectorForCorpus(concordance.getCorpus(), "UD");
+	
+		int kp = l.getKeywordPosition();
 		
+		return toTree(editor, s, kp, concordance.getCorpus());
+	}
+	
+	public Object toTree(ITXMResultEditor<? extends TXMResult> editor, ISelection s, int kp, CQPCorpus corpus) {
+		TXMResult r = editor.getResult();
+		
+		//TreeSearchSelector selector = ComputeTreeSearch.getSelectorForCorpus(concordance.getCorpus(), "UD");
+		
 		TreeSearchEditor leditor = editor.getLinkedEditor(TreeSearchEditor.class);
 		TreeSearch ts = null;
 		if (leditor != null) {
 			ts = leditor.getResult();
 			ts.setQuery(null);
 		} else {
-			ts = ComputeTreeSearch.getTreeSearchFor(concordance.getCorpus());
+			ts = ComputeTreeSearch.getTreeSearchFor(corpus);
 			ts.setQuery(null);
 		}
 		//ts.setQuery(concordance.getQuery());
@@ -129,7 +183,7 @@
 		try {
 			boolean c = ts.compute();
 			Selection sel = ts.getSelection();
-			int kp = l.getKeywordPosition();
+			
 //			System.out.println("KP="+kp);
 			if (c &&  sel != null) {
 				int i = 0;
