Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/corpuswizard/SourceDirectoryPage.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/corpuswizard/SourceDirectoryPage.java	(revision 1675)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/corpuswizard/SourceDirectoryPage.java	(revision 1676)
@@ -23,6 +23,8 @@
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
+import org.txm.Toolbox;
+import org.txm.objects.Project;
 import org.txm.rcp.messages.TXMUIMessages;
 import org.txm.rcp.preferences.RCPPreferences;
 import org.txm.utils.AsciiUtils;
@@ -142,7 +144,12 @@
 		if (corpusName.getText().length() > 0) {
 			//File srcProjectLink = ResourcesPlugin.getWorkspace().getRoot().getProject(corpusName.getText()).getFolder("src").getRawLocation().toFile();
 			if (ResourcesPlugin.getWorkspace().getRoot().getProject(getCorpusName()).exists()) {
-				newOrEdit.setText(NLS.bind("The ''{0}'' corpus will be replaced.", getCorpusName()));
+				Project p = Toolbox.workspace.getProject();
+				if (p != null && p.getChildren().size() > 0) {
+					newOrEdit.setText(NLS.bind("The ''{0}'' corpus will be replaced.", getCorpusName()));
+				} else {
+					newOrEdit.setText(NLS.bind("The ''{0}'' corpus import will be resumed.", getCorpusName()));
+				}
 			} else {
 				newOrEdit.setText(NLS.bind("The ''{0}'' corpus will be created.", getCorpusName()));
 			}
@@ -156,7 +163,6 @@
 		}
 
 		return getCorpusName().length() > 0 && getSourcePath().length() > 0;
-		//    	return getSourcePath().length() > 0;
 	}
 
 	public String getCorpusName() {
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/ImportSelectedText.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/ImportSelectedText.java	(revision 1675)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/ImportSelectedText.java	(revision 1676)
@@ -99,19 +99,19 @@
 	 * Import text.
 	 *
 	 * @param text the text
-	 * @param basename the basename
+	 * @param corpusname the basename
 	 * @return the object
 	 * @throws Exception 
 	 */
-	public static Object importText(String text, String basename) throws Exception {
-		basename = basename.toUpperCase();
+	public static Object importText(String text, String corpusname) throws Exception {
+		corpusname = corpusname.toUpperCase();
 		if (text.length() == 0) {
 			System.err.println(TXMUIMessages.clipboardIsEmpty);
 			return null;
 		}
 		String txmhome = Toolbox.getTxmHomePath();
 		new File(txmhome, "clipboard").mkdir(); //$NON-NLS-1$
-		File clipboardDirectory = new File(txmhome, "clipboard/" + basename); //$NON-NLS-1$
+		File clipboardDirectory = new File(txmhome, "clipboard/" + corpusname); //$NON-NLS-1$
 		
 		if (CorpusManager.getCorpusManager().hasCorpus(clipboardDirectory.getName())) {
 			Shell shell = new Shell();
@@ -124,7 +124,7 @@
 		org.txm.utils.DeleteDir.deleteDirectory(clipboardDirectory);
 		clipboardDirectory.mkdirs();
 		
-		File quicksrc = new File(clipboardDirectory, basename + ".txt"); //$NON-NLS-1$
+		File quicksrc = new File(clipboardDirectory, corpusname + ".txt"); //$NON-NLS-1$
 		try {
 			Writer writer = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(quicksrc)), "UTF-8"); //$NON-NLS-1$ 
 			writer.write(text.replace("\t", "    ")); //$NON-NLS-1$ //$NON-NLS-2$
Index: tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TSCorpus.java
===================================================================
--- tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TSCorpus.java	(revision 1675)
+++ tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TSCorpus.java	(revision 1676)
@@ -32,6 +32,7 @@
 import ims.tiger.gui.tigergraphviewer.TIGERGraphViewerConfiguration;
 import ims.tiger.query.internalapi.InternalCorpusQueryManager;
 import ims.tiger.query.internalapi.InternalCorpusQueryManagerLocal;
+import ims.tiger.query.processor.CorpusQueryProcessor;
 
 import java.util.HashMap;
 import java.util.List;
@@ -48,7 +49,7 @@
 
 	/** The managers. */
 	public TSCorpusManager tsmanager;
-	InternalCorpusQueryManager manager = null;
+	InternalCorpusQueryManagerLocal2 manager = null;
 	ExportManager exporter;
 	
 	/** The config. */
@@ -74,7 +75,9 @@
 		String confpath = tsmanager.getconfPath();
 		try {
 			this.tsmanager = tsmanager;
-			manager = new InternalCorpusQueryManagerLocal(regpath);
+			manager = new InternalCorpusQueryManagerLocal2(regpath);
+			
+			manager.getQueryProcessor();
 			config = new TIGERGraphViewerConfiguration(confpath, confpath, confpath);
 			this.id = corpusId;		
 			initok = opencorpus();
Index: tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/InternalCorpusQueryManagerLocal2.java
===================================================================
--- tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/InternalCorpusQueryManagerLocal2.java	(revision 0)
+++ tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/InternalCorpusQueryManagerLocal2.java	(revision 1676)
@@ -0,0 +1,16 @@
+package org.txm.searchengine.ts;
+
+import ims.tiger.query.api.CorpusQueryManagerException;
+import ims.tiger.query.internalapi.InternalCorpusQueryManagerLocal;
+import ims.tiger.query.processor.CorpusQueryProcessor;
+
+public class InternalCorpusQueryManagerLocal2 extends InternalCorpusQueryManagerLocal {
+
+	public InternalCorpusQueryManagerLocal2(String corpus_base_directory) throws CorpusQueryManagerException {
+		super(corpus_base_directory);
+	}
+
+	public CorpusQueryProcessor getQueryProcessor() {
+		return query_processor;
+	}
+}

Property changes on: tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/InternalCorpusQueryManagerLocal2.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERSearchEngine.java
===================================================================
--- tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERSearchEngine.java	(revision 1675)
+++ tmp/org.txm.tigersearch.rcp/src/org/txm/searchengine/ts/TIGERSearchEngine.java	(revision 1676)
@@ -1,6 +1,7 @@
 package org.txm.searchengine.ts;
 
 import java.io.File;
+import java.util.ArrayList;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.txm.core.results.TXMResult;
@@ -14,8 +15,14 @@
 import org.txm.searchengine.cqp.corpus.MainCorpus;
 import org.txm.utils.DeleteDir;
 
+import cern.colt.Arrays;
+import ims.tiger.corpus.Sentence;
+import ims.tiger.gui.tigergraphviewer.draw.Display_Sentence;
 import ims.tiger.gui.tigergraphviewer.forest.ResultForest;
+import ims.tiger.index.reader.Index;
 import ims.tiger.query.api.MatchResult;
+import ims.tiger.query.internalapi.InternalCorpusQueryManager;
+import ims.tiger.query.processor.CorpusQueryProcessor;
 
 public class TIGERSearchEngine extends SearchEngine {
 
@@ -49,12 +56,99 @@
 		File tigerDirectory = new File(corpus.getProjectDirectory(), "tiger");
 		File configfile = new File(tigerDirectory, "tigersearch.logprop");
 		TSCorpusManager manager = new TSCorpusManager(tigerDirectory, configfile);
-		
-		TSResult result = manager.getCorpus(corpus.getID()).query(query.getQueryString());
+
+		TSCorpus tcorpus = manager.getCorpus(corpus.getID());
+		TSResult result = tcorpus.query(query.getQueryString());
 		ResultForest forest = result.getForest();
 		System.out.println("TIGERSearch: forest size="+forest.getForestSize());
 		MatchResult mresult = result.getMatchResult();
 		
+		InternalCorpusQueryManagerLocal2 tigermanager = tcorpus.manager;
+		CorpusQueryProcessor processor = tigermanager.getQueryProcessor();
+		Index index = processor.getIndex();
+		
+		System.out.println("MANAGER="+tigermanager.getClass());
+		int nsentences = 0;
+		int sentence_sizes[] = new int[nsentences];
+		int size = mresult.size();
+		System.out.println("size: "+size);
+		int subsize = mresult.submatchSize();
+		System.out.println("submatchSize: "+subsize);
+		for (int imatch = 0 ; imatch < size; imatch++) { // the matching sentences
+			int sent = mresult.getSentenceNumberAt(imatch);
+			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);
+				//System.out.println("  match="+Arrays.toString(match));
+				
+				
+				for (int inode : match) {
+					System.out.println("  match="+ sentence.getNode(inode).getFeatures());
+				}
+			}
+		}
+		
+//		
+//		int size = result.getNumberOfMatch();
+//		for (int match_no = 0 ; match_no < size ; match_no++) {
+//			TSMatch match = result.getMatch(match_no);
+////			int sentno = result.getSentenceNumberAt(match_no);
+////			int n = result.getSentenceSubmatchSize(sentno);
+//			System.out.println("Sent: "+match);
+//			int n = match.getNumberOfSubGraph();
+//			for (int iSubMatch=0 ; iSubMatch<n ; iSubMatch++) {
+//				System.out.println("   Sub: "+iSubMatch+" -> "+match.getResult().getMatchResult().getSentenceSubmatchSize(sentence));
+//				match.getCurrentSubMatchNo()
+//			}
+//		}
+
+		//		Display_Sentence match = forest.getCurrentMatch();
+		//		while (match != null) {
+		////			int s = match.getTerminalsSize();
+		////			ArrayList<ims.tiger.corpus.T_Node> terms = match.getTerminals();
+		////			System.out.print("M="+s+"\t");
+		////			for (ims.tiger.corpus.T_Node term : terms) {
+		////				System.out.print(" "+term.getFeature("word"));
+		////			}
+		////			match.get
+		////			System.out.println();
+		//			match.getSe
+		//			match = forest.nextMatch();
+		//		}
+
+		//		int size = forest.getForestSize();
+		//		for ( int match_no = 0 ; match_no < size ; match_no++) {
+		//			int sentno = mresult.getSentenceNumberAt(match_no);
+		//			Sentence sentence = manager.getSentence(sentno);
+		//
+		//			mresult.orderSentenceSubmatches(sentno); 
+		//			int n = mresult.getSentenceSubmatchSize(sentno);
+		//
+		//			for (int iSubMatch=0; iSubMatch<n; iSubMatch++) {
+		//				int[] var_values = mresult.getSentenceSubmatchAt(sentno, iSubMatch);
+		//				int value;
+		//				for (int j=0; j<var_values.length; j++) {
+		//					value = var_values[j];
+		//					if (value>=0) {
+		//						String var_name = mresult.getVariableName(j);
+		//						Node referred = sentence.getNode(value);
+		//						if (p.matcher(var_name).matches()) {
+		//							if (referred instanceof T_Node) {
+		//								matchingTnodesID.add(referred.getFeature(EDITIONID));
+		//							} else if (referred instanceof NT_Node) {
+		//								for (T_Node c : getTerminals((NT_Node) referred, sentence)) {
+		//									matchingTnodesID.add(c.getFeature(EDITIONID));
+		//								}
+		//							}
+		//						}
+		//					}
+		//				}
+		//			}
+		//		}
+
 		System.out.println("FIXME return EmptySelection for now...");
 		return new EmptySelection(query);
 	}
@@ -69,7 +163,7 @@
 		//TODO implement a corpora of TIGER corpus
 		File buildDirectory = new File(corpus.getProjectDirectory(), "tiger");
 		return	new File(buildDirectory, "tigersearch.logprop").exists() && 
-		 new File(buildDirectory, corpus.getID()).exists();
+				new File(buildDirectory, corpus.getID()).exists();
 	}
 
 	@Override
Index: tmp/org.txm.tigersearch.rcp/src/org/txm/tigersearch/editors/TIGERSearchEditor.java
===================================================================
--- tmp/org.txm.tigersearch.rcp/src/org/txm/tigersearch/editors/TIGERSearchEditor.java	(revision 1675)
+++ tmp/org.txm.tigersearch.rcp/src/org/txm/tigersearch/editors/TIGERSearchEditor.java	(revision 1676)
@@ -360,7 +360,7 @@
 			System.out.println("Error: "+e.getLocalizedMessage());
 			Log.printStackTrace(e);
 		} //$NON-NLS-1$ //$NON-NLS-2$
-		Log.severe(svgFile.toString());
+		Log.fine(svgFile.toString());
 		
 		TXMResultEditorInput<TIGERSearch> ii = (TXMResultEditorInput<TIGERSearch>) input;
 		ts = ii.getResult();
Index: tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/RWorkspace.java
===================================================================
--- tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/RWorkspace.java	(revision 1675)
+++ tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/RWorkspace.java	(revision 1676)
@@ -1488,6 +1488,9 @@
 	 * @throws RWorkspaceException the r workspace exception
 	 */
 	public void removeVariableFromWorkspace(String variableName) throws RWorkspaceException {
+		
+		if (variableName == null) return;
+		
 		try {
 			connection.voidEval("rm(" + variableName + ")"); //$NON-NLS-1$ //$NON-NLS-2$
 		} catch (RserveException e) {
Index: tmp/org.txm.ca.core/src/org/txm/ca/core/functions/CA.java
===================================================================
--- tmp/org.txm.ca.core/src/org/txm/ca/core/functions/CA.java	(revision 1675)
+++ tmp/org.txm.ca.core/src/org/txm/ca/core/functions/CA.java	(revision 1676)
@@ -46,6 +46,8 @@
 import org.txm.lexicaltable.core.functions.LexicalTable;
 import org.txm.searchengine.cqp.corpus.Property;
 import org.txm.statsengine.core.StatException;
+import org.txm.statsengine.r.core.RWorkspace;
+import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
 import org.txm.utils.logger.Log;
 
 /**
@@ -161,7 +163,13 @@
 
 	@Override
 	public void clean() {
-		// TODO Auto-generated method stub
+		try {
+			if (this.getCA() != null)	{
+				RWorkspace.getRWorkspaceInstance().removeVariableFromWorkspace(this.getCA().getSymbol());
+			}
+		} catch (RWorkspaceException e) {
+			e.printStackTrace();
+		}
 	}
 
 	@Override
@@ -177,6 +185,14 @@
 			this.rowtabledata = null;
 			
 			
+			try {
+				if (this.getCA() != null)	{
+					RWorkspace.getRWorkspaceInstance().removeVariableFromWorkspace(this.getCA().getSymbol());
+				}
+			} catch (RWorkspaceException e) {
+				e.printStackTrace();
+			}
+			
 			if (this.useFactoMineR) {
 				this.r_ca = new FactoMineRCA(this.getLexicalTable().getData());
 			}
Index: tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java
===================================================================
--- tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java	(revision 1675)
+++ tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java	(revision 1676)
@@ -208,6 +208,13 @@
 				}
 			}
 		}
+		try {
+			if (statsData != null)	{
+				RWorkspace.getRWorkspaceInstance().removeVariableFromWorkspace(statsData.getSymbol());
+			}
+		} catch (RWorkspaceException e) {
+			e.printStackTrace();
+		}
 		this.statsData = new LexicalTableImpl(mat, filteredForms.toArray(new String[]{}), partition.getPartNames().toArray(new String[] {}));
 
 	}
Index: tmp/TXMReleasePlugins.site/site.xml
===================================================================
--- tmp/TXMReleasePlugins.site/site.xml	(revision 1675)
+++ tmp/TXMReleasePlugins.site/site.xml	(revision 1676)
@@ -3,22 +3,22 @@
    <description name="TXM Extensions - RELEASE" url="http://txm.textometrie.org/updates/plugins">
       This update site contains the Release plugins for TXM
    </description>
-   <feature url="features/org.txm.backtomedia.feature_1.0.0.1660.jar" id="org.txm.backtomedia.feature" version="1.0.0.1660">
+   <feature url="features/org.txm.backtomedia.feature_1.0.0.1674.jar" id="org.txm.backtomedia.feature" version="1.0.0.1674">
       <category name="Commands"/>
    </feature>
-   <feature url="features/org.txm.wordcloud.feature_1.0.0.1660.jar" id="org.txm.wordcloud.feature" version="1.0.0.1660">
+   <feature url="features/org.txm.wordcloud.feature_1.0.0.1674.jar" id="org.txm.wordcloud.feature" version="1.0.0.1674">
       <category name="Commands"/>
    </feature>
-   <feature url="features/org.txm.treetagger.binaries.feature_1.0.0.1669.jar" id="org.txm.treetagger.binaries.feature" version="1.0.0.1669" os="" ws="">
+   <feature url="features/org.txm.treetagger.binaries.feature_1.0.0.1674.jar" id="org.txm.treetagger.binaries.feature" version="1.0.0.1674" os="" ws="">
       <category name="Annotation"/>
    </feature>
-   <feature url="features/org.txm.treetagger.models.feature_1.0.0.1660.jar" id="org.txm.treetagger.models.feature" version="1.0.0.1660">
+   <feature url="features/org.txm.treetagger.models.feature_1.0.0.1674.jar" id="org.txm.treetagger.models.feature" version="1.0.0.1674">
       <category name="Annotation"/>
    </feature>
-   <feature url="features/org.txm.annotation.urs.feature_1.0.0.1660.jar" id="org.txm.annotation.urs.feature" version="1.0.0.1660">
+   <feature url="features/org.txm.annotation.urs.feature_1.0.0.1674.jar" id="org.txm.annotation.urs.feature" version="1.0.0.1674">
       <category name="Annotation"/>
    </feature>
-   <feature url="features/org.txm.tigersearch.feature_1.0.0.1668.jar" id="org.txm.tigersearch.feature" version="1.0.0.1668">
+   <feature url="features/org.txm.tigersearch.feature_1.0.0.1674.jar" id="org.txm.tigersearch.feature" version="1.0.0.1674">
       <category name="Annotation"/>
    </feature>
    <category-def name="Commands" label="Commands"/>
Index: tmp/org.txm.ahc.core/src/org/txm/ahc/core/functions/AHC.java
===================================================================
--- tmp/org.txm.ahc.core/src/org/txm/ahc/core/functions/AHC.java	(revision 1675)
+++ tmp/org.txm.ahc.core/src/org/txm/ahc/core/functions/AHC.java	(revision 1676)
@@ -205,6 +205,12 @@
 
 			if (this.symbol == null)	{
 				this.symbol = prefixR + (ahcCounter++);
+			} else {
+				try {
+					RWorkspace.getRWorkspaceInstance().removeVariableFromWorkspace(this.symbol);
+				} catch (RWorkspaceException e) {
+					e.printStackTrace();
+				}
 			}
 
 			RWorkspace rw = RWorkspace.getRWorkspaceInstance();
@@ -376,8 +382,11 @@
 
 	@Override
 	public void clean() {
-		// TODO Auto-generated method stub
-
+		try {
+			RWorkspace.getRWorkspaceInstance().removeVariableFromWorkspace(this.symbol);
+		} catch (RWorkspaceException e) {
+			e.printStackTrace();
+		}
 	}
 
 	/**
Index: tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificities.java
===================================================================
--- tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificities.java	(revision 1675)
+++ tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificities.java	(revision 1676)
@@ -61,6 +61,7 @@
 import org.txm.statsengine.core.utils.ArrayIndex;
 import org.txm.statsengine.core.utils.CheckArray;
 import org.txm.statsengine.r.core.RWorkspace;
+import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
 import org.txm.utils.logger.Log;
 
 /**
@@ -198,6 +199,13 @@
 	 */
 	protected void init(String symbol, double[][] specIndex) throws Exception {
 
+		if (this.symbol != null && this.symbol.equals(symbol)) {
+			try {
+				RWorkspace.getRWorkspaceInstance().removeVariableFromWorkspace(this.symbol);
+			} catch (RWorkspaceException e) {
+				e.printStackTrace();
+			}
+		}
 		this.symbol = symbol;
 
 		if (this.lexicalTable == null) {
@@ -555,6 +563,15 @@
 	@Override
 	public void clean() {
 		try {
+			if (symbol != null)	{
+				RWorkspace.getRWorkspaceInstance().removeVariableFromWorkspace(symbol);
+			}
+		} catch (RWorkspaceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		
+		try {
 			if(this.writer != null)	{
 				this.writer.flush();
 				this.writer.close();
