Index: tmp/org.txm.utils/src/org/txm/utils/StreamConsumer.java
===================================================================
--- tmp/org.txm.utils/src/org/txm/utils/StreamConsumer.java	(revision 0)
+++ tmp/org.txm.utils/src/org/txm/utils/StreamConsumer.java	(revision 924)
@@ -0,0 +1,44 @@
+package org.txm.utils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.txm.utils.logger.Log;
+
+/**
+ * Consumer for dumping stdout and stderr from a native process.
+ * @author sjacquot
+ *
+ */
+public class StreamConsumer extends Thread {
+    
+	InputStream is;
+	int type;
+    
+    public StreamConsumer(InputStream is, int type) {
+        this.is = is;
+        this.type = type;
+    }
+    
+    @Override
+    public void run() {
+        try {
+            InputStreamReader isr = new InputStreamReader(this.is);
+            BufferedReader br = new BufferedReader(isr);
+            String line = null;
+            while ((line = br.readLine()) != null) {
+            	if(this.type == 0)	{
+            		Log.finest(line);
+            	}
+            	else	{
+            		Log.severe(line);
+            	}
+            }
+        }
+        catch (IOException e) {
+        	e.printStackTrace();  
+        }
+    }
+}
\ No newline at end of file

Property changes on: tmp/org.txm.utils/src/org/txm/utils/StreamConsumer.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

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 923)
+++ tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/RWorkspace.java	(revision 924)
@@ -340,11 +340,10 @@
 				throw new RWorkspaceException(RCoreMessages.error_rservePathNotSet); 
 			}
 		} else {
-			Log.info(RCoreMessages.bind(RCoreMessages.info_startingRUsingPath, pathToRExecutable));
 			isRServerOk = StartRserve.launchRserve(pathToRExecutable, port, debug, rargs, rServeArgs);
 			// System.out.println("ap launchRserve");
 			if (!isRServerOk) {
-				System.out.println("Rserve not started with "+pathToRExecutable+". Trying with commons R installation paths (will works if Rserve, textometry and FactoMineR are installed).");
+				Log.severe("Rserve not started with " + pathToRExecutable + ". Trying with commons R installation paths (will works if Rserve, textometry and FactoMineR are installed).");
 				isRServerOk = StartRserve.checkLocalRserve(port, debug, rargs, rServeArgs);
 			}
 			
@@ -356,7 +355,7 @@
 		if (isRServerOk) {
 			Log.finest("RSERVE_ACTIVATED"); //$NON-NLS-1$
 			System.out.println(RCoreMessages.info_connected); 
-			RserveProcess = StartRserve.Rserveprocess;
+			RserveProcess = StartRserve.rProcess;
 		}
 		return isRServerOk;
 	}
@@ -485,7 +484,7 @@
 			initRserve(pathToRExecutable, port, debug, rArgs, rServeArgs);
 			return true;
 		} catch (RWorkspaceException e) {
-			System.out.println(RCoreMessages.error_failedToStartRServe);
+			Log.severe(RCoreMessages.error_failedToStartRServe);
 			org.txm.utils.logger.Log.printStackTrace(e);
 		}
 		return false;
Index: tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/StartRserve.java
===================================================================
--- tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/StartRserve.java	(revision 923)
+++ tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/StartRserve.java	(revision 924)
@@ -29,6 +29,7 @@
 
 import java.io.File;
 
+import org.apache.commons.lang.StringUtils;
 import org.eclipse.osgi.util.NLS;
 import org.rosuda.REngine.Rserve.RConnection;
 import org.txm.statsengine.r.core.messages.RCoreMessages;
@@ -59,7 +60,7 @@
 public class StartRserve {
 
 	/** shortcut to <code>launchRserve(cmd, "--no-save --slave", "--no-save --slave", false)</code>. */
-	public static Process Rserveprocess;
+	public static Process rProcess;
 
 	/**
 	 * Launch rserve.
@@ -72,7 +73,7 @@
 		if (new File(cmd).exists() && !new File(cmd).isDirectory()
 				&& new File(cmd).canExecute())
 			return launchRserve(cmd,
-					"--no-save --slave --encoding utf8 "+rArgs, "--RS-encoding utf8 --no-save --slave --encoding utf8 "+rServeArgs, port, debug); //$NON-NLS-1$ //$NON-NLS-2$
+					"--no-save --slave --encoding utf8 " + rArgs, "--RS-encoding utf8 --no-save --slave --encoding utf8 " + rServeArgs, port, debug); //$NON-NLS-1$ //$NON-NLS-2$
 		return false;//checkLocalRserve(port, debug, rArgs, rServeArgs);
 	}
 
@@ -140,21 +141,22 @@
 //			Rserveprocess = builder.start();
 
 			Runtime runtime = Runtime.getRuntime();
-			Rserveprocess = runtime.exec(cmdline);
+			Log.info(RCoreMessages.bind(RCoreMessages.info_startingRWithCommandLine, StringUtils.join(cmdline, " "))); //$NON-NLS-1$
+			rProcess = runtime.exec(cmdline);
 			
 			//Log.info(Messages.StartRserve_0+Arrays.toString(cmdline));
-			StreamHog errStream = new StreamHog(Rserveprocess.getErrorStream(), debug);
-			StreamHog inStream = new StreamHog(Rserveprocess.getInputStream(), debug);
+			StreamHog errStream = new StreamHog(rProcess.getErrorStream(), debug);
+			StreamHog inStream = new StreamHog(rProcess.getInputStream(), debug);
 			RWorkspace.getRWorkspaceInstance().registerLogger(errStream, inStream);
 
 			//if (!debug && !isWindows) Rserveprocess.waitFor();
 			// System.out.println("call terminated, let us try to connect ...");
 		} catch (Exception x) {
-			System.err.println(RCoreMessages.error_failedToStartRServeWithCommand + x.getMessage());
+			Log.severe(RCoreMessages.error_failedToStartRServeWithCommand + x.getMessage());
 			return false;
 		}
 
-		System.err.print(RCoreMessages.info_statisticsEngineLaunched);
+		Log.info(RCoreMessages.info_statisticsEngineLaunched);
 
 		try {
 			Thread.sleep(200);
Index: tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/RStatsEngine.java
===================================================================
--- tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/RStatsEngine.java	(revision 923)
+++ tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/RStatsEngine.java	(revision 924)
@@ -9,6 +9,7 @@
 import org.txm.statsengine.r.core.messages.RCoreMessages;
 import org.txm.statsengine.r.core.preferences.RPreferences;
 import org.txm.utils.OSDetector;
+import org.txm.utils.StreamConsumer;
 import org.txm.utils.logger.Log;
 
 /**
@@ -83,7 +84,7 @@
 			//	System.out.println("success");
 			//System.out.println("file transfert ? "+RWorkspace.isFileTranfert());
 		} catch (RWorkspaceException e) {
-			System.err.println(RCoreMessages.error_connectionFailed); 
+			Log.severe(RCoreMessages.error_connectionFailed); 
 			started = false;
 		}
 
@@ -91,6 +92,8 @@
 	}
 
 	
+
+	
 	/**
 	 * kill Rserve process.
 	 */
@@ -98,8 +101,9 @@
 		if (!TXMPreferences.getBoolean(RPreferences.REMOTE, RPreferences.PREFERENCES_NODE))	{
 			
 			try {
-				if (StartRserve.Rserveprocess != null) {
-					StartRserve.Rserveprocess.destroy();
+				if (StartRserve.rProcess != null) {
+					Log.finest("Quitting R process.");
+					StartRserve.rProcess.destroy();
 				}
 			} catch (Exception e1) {
 				// TODO Auto-generated catch block
@@ -109,34 +113,46 @@
 			// Windows OS
 			if (OSDetector.isFamilyWindows()) {
 				try {
+					String cmd = "taskkill /IM Rterm.exe /F"; //$NON-NLS-1$
+					//String cmd = "cmd /c FOR /F \"tokens=5 delims= \" %P IN ('netstat -ano ^| findstr :6330 ^| findstr LISTENING') DO taskkill /F /PID %P"; //$NON-NLS-1$ 
+					Log.finest("Executing command: " + cmd);
+
 					Process p = Runtime.getRuntime().exec(
 							//"taskkill /IM Rserve.exe /F"); //$NON-NLS-1$
-							"cmd /c FOR /F \"tokens=5 delims= \" %P IN ('netstat -ano ^| findstr :6330 ^| findstr LISTENING') DO taskkill /F /PID %P"); //$NON-NLS-1$
+							cmd
+							);
 
+					// consumes streams
+		            new StreamConsumer(p.getErrorStream(), -1).start();;            
+		            new StreamConsumer(p.getInputStream(), 0).start();
+		            
 					p.waitFor();
 					started = false;
 				} catch (IOException e) {
 					Log.severe(RCoreMessages.error_failedToKillRServe+Log.toString(e));
 					System.out.println(RCoreMessages.error_failedToKillRServe+Log.toString(e));
 					try {
+						
+						String cmd = "cmd /c FOR /F \"tokens=5 delims= \" %P IN ('netstat -ano ^| findstr :6330 ^| findstr LISTENING') DO tskill %P"; //$NON-NLS-1$
+						Log.finest("Executing command: " + cmd);
+						
 						Process p = Runtime.getRuntime().exec(
 								//"tskill Rserve.exe"); //$NON-NLS-1$
-								"cmd /c FOR /F \"tokens=5 delims= \" %P IN ('netstat -ano ^| findstr :6330 ^| findstr LISTENING') DO tskill %P"); //$NON-NLS-1$
+								cmd
+								);
 						p.waitFor();
 						started = false;
 					} catch (IOException e2) {
 						Log.severe(RCoreMessages.error_failedToKillRServe2+Log.toString(e2));
-						System.out.println(RCoreMessages.error_failedToKillRServe2+Log.toString(e2));
 						Log.printStackTrace(e2);
 					} catch (InterruptedException e3) {
 						Log.severe(Log.toString(e3));
-						System.out.println(Log.toString(e3));
-						org.txm.utils.logger.Log.printStackTrace(e3);
+						Log.printStackTrace(e3);
 					}
-				} catch (InterruptedException e) {
+				}
+				catch (InterruptedException e) {
 					Log.severe("Error while closing R: " + e.getLocalizedMessage());
-					System.out.println(Log.toString(e));
-					org.txm.utils.logger.Log.printStackTrace(e);
+					Log.printStackTrace(e);
 				}
 			}
 			// Mac, Linux
Index: tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/messages/RCoreMessages.java
===================================================================
--- tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/messages/RCoreMessages.java	(revision 923)
+++ tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/messages/RCoreMessages.java	(revision 924)
@@ -12,6 +12,8 @@
  */
 public class RCoreMessages extends NLS {
 
+	private static final String BUNDLE_NAME = "org.txm.statsengine.r.core.messages.messages"; //$NON-NLS-1$
+	
 	public static String error_cantFindRServeInPath;
 	public static String error_connectionFailed;
 	public static String error_errorDuringItemsListExtraction;
@@ -37,7 +39,7 @@
 	public static String info_lastSafeEvalExpression;
 	public static String info_rPathNotSetTryingToFindIt;
 	public static String info_savingChartToFile;
-	public static String info_startingRUsingPath;
+	public static String info_startingRWithCommandLine;
 	public static String info_startingStatsEngine;
 	public static String info_statisticsEngineLaunched;
 	public static String info_tryingToStartRFrom;
@@ -47,7 +49,7 @@
 
 	static {
 		// initialize resource bundle
-		Utf8NLS.initializeMessages(RCoreMessages.class);
+		Utf8NLS.initializeMessages(BUNDLE_NAME, RCoreMessages.class);
 	}
 
 	private RCoreMessages() {
Index: tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/messages/messages.properties
===================================================================
--- tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/messages/messages.properties	(revision 923)
+++ tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/messages/messages.properties	(revision 924)
@@ -26,7 +26,7 @@
 info_lastSafeEvalExpression    = Last safeeval expression: {0}.
 info_rPathNotSetTryingToFindIt = R path is not set, trying to find it...
 info_savingChartToFile         = Saving chart to file: {0}.
-info_startingRUsingPath        = Starting R using path: {0}.
+info_startingRWithCommandLine  = Starting R with command line: {0}.
 info_startingStatsEngine       = Starting Statistics Engine: user: {0}, remote: {1}, port: {2}, debug: {3}
 info_statisticsEngineLaunched  = Statistical Engine launched
 info_tryingToStartRFrom        = Try to start R from: {0}...
Index: tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/messages/messages_fr.properties
===================================================================
--- tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/messages/messages_fr.properties	(revision 923)
+++ tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/messages/messages_fr.properties	(revision 924)
@@ -26,7 +26,7 @@
 info_lastSafeEvalExpression    = Dernier 'safeeval' : {0}.
 info_rPathNotSetTryingToFindIt = Chemin d'accès à R non fourni, tentative de résolution...
 info_savingChartToFile         = Sauvegarde du graphique dans le fichier : {0}.
-info_startingRUsingPath        = Démarrage de R avec le chemin d'accès : {0}.
+info_startingRWithCommandLine  = Démarrage de R avec la ligne de commande : {0}.
 info_startingStatsEngine       = Démarrage du moteur de statistiques : utilisateur : {0}, distant : {1}, port : {2}, debug : {3}
 info_statisticsEngineLaunched  = Moteur statistique lancé
 info_tryingToStartRFrom        = Tentative de démarrage de R depuis : {0}...
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/TxmPreferences.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/TxmPreferences.java	(revision 923)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/TxmPreferences.java	(revision 924)
@@ -46,6 +46,7 @@
  *
  * @author mdecorde
  */
+@Deprecated
 public class TxmPreferences {
 
 	
Index: tmp/org.txm.core/src/java/org/txm/objects/Workspace.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/objects/Workspace.java	(revision 923)
+++ tmp/org.txm.core/src/java/org/txm/objects/Workspace.java	(revision 924)
@@ -51,6 +51,7 @@
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.osgi.util.NLS;
 import org.txm.PostTXMHOMEInstallationStep;
+import org.txm.Toolbox;
 import org.txm.core.messages.TXMCoreMessages;
 import org.txm.core.preferences.TBXPreferences;
 import org.txm.core.preferences.TXMPreferences;
@@ -124,7 +125,7 @@
 				}
 			}
 
-			String path = TXMPreferences.getString(TBXPreferences.INSTALL_DIR, TBXPreferences.PREFERENCES_NODE);
+			String path = Toolbox.getPreference(TBXPreferences.INSTALL_DIR);
 			File installDirectory = new File(path);
 			if (!installDirectory.exists()) {
 				System.out.println("Error: Workspace cannot found install directory: "+installDirectory.getAbsolutePath());
@@ -133,7 +134,7 @@
 
 			File redistDirectory = new File(installDirectory, "redist");
 			if (!redistDirectory.exists()) {
-				System.out.println("Warning: Workspace cannot found redist directory: "+redistDirectory.getAbsolutePath());
+				System.err.println("Warning: Workspace cannot found redist directory: "+redistDirectory.getAbsolutePath());
 			} else {
 				FileCopy.copyFiles(redistDirectory, txmhomedir);
 			}
@@ -190,7 +191,7 @@
 		xmlfile.getParentFile().mkdir();
 		try {
 			OutputStreamWriter writer = new OutputStreamWriter(
-					new FileOutputStream(xmlfile), "UTF-8"); //$NON-NLS-1$
+					new FileOutputStream(xmlfile), TXMPreferences.DEFAULT_ENCODING);
 			writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); //$NON-NLS-1$
 			writer.write("<workspace>\n"); //$NON-NLS-1$
 			writer.write("<projects>\n"); //$NON-NLS-1$
@@ -319,14 +320,14 @@
 
 			// Création du fichier de sortie
 			Writer writer = new BufferedWriter(new OutputStreamWriter(
-					new FileOutputStream(xmlDefinitionFile), "UTF-8")); //$NON-NLS-1$
+					new FileOutputStream(xmlDefinitionFile), TXMPreferences.DEFAULT_ENCODING));
 			Result resultat = new StreamResult(writer);
 
 			// Configuration du transformer
 			TransformerFactory fabrique = new net.sf.saxon.TransformerFactoryImpl();
 			Transformer transformer = fabrique.newTransformer();
 			transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
-			transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
+			transformer.setOutputProperty(OutputKeys.ENCODING, TXMPreferences.DEFAULT_ENCODING);
 
 			// Transformation
 			transformer.transform(source, resultat);
Index: tmp/org.txm.core/src/java/org/txm/Toolbox.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/Toolbox.java	(revision 923)
+++ tmp/org.txm.core/src/java/org/txm/Toolbox.java	(revision 924)
@@ -447,10 +447,11 @@
 
 	/**
 	 * Removes an engines manager.
-	 * @param engine
+	 * @param enginesManager
 	 */
-	private static void removeEngineManager(EnginesManager<?> engine) {
-		enginesManagers.remove(engine.getClass());
+	private static void removeEngineManager(EnginesManager<?> enginesManager) {
+		enginesManagers.remove(enginesManager.getClass());
+		Log.finest("Engines manager removed: " + enginesManager);
 	}
 
 	/**
@@ -489,22 +490,28 @@
 		stopEnginesManagers();
 
 		
-		// FIXME: tmp solution before IProject: remove all not persistable result nodes
-		TXMPreferences.deleteAllNotPersistableResultsNodes();
-		// FIXME: tmp solution before IProject: remove result local nodes if persistence preference is disabled
-		if (!TBXPreferences.getBoolean(TBXPreferences.PERSISTENCE_ENABLED, TBXPreferences.PREFERENCES_NODE)) {
-			TXMPreferences.deleteAllResultsNodes();
-		}
+		try {
+			// FIXME: tmp solution before IProject: remove all not persistable result nodes
+			//TXMPreferences.deleteAllNotPersistableResultsNodes();
+			// FIXME: tmp solution before IProject: remove result local nodes if persistence preference is disabled
+			if (!TBXPreferences.getBoolean(TBXPreferences.PERSISTENCE_ENABLED, TBXPreferences.PREFERENCES_NODE)) {
+				TXMPreferences.deleteAllResultsNodes();
+			}
 
-		
-		if(Toolbox.workspace != null) {
-			Toolbox.workspace.save();
+			
+			if(Toolbox.workspace != null) {
+				Toolbox.workspace.save();
+			}
+			Toolbox.workspace = null;
+			state = false;
+
+			//save preferences
+			TXMPreferences.saveAll();
 		}
-		Toolbox.workspace = null;
-		state = false;
-
-		//save preferences
-		TXMPreferences.saveAll();
+		catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
 	}
 
 	/**
@@ -553,7 +560,7 @@
 			EnginesManager<?> enginesManager = enginesManagers.get(et);
 			Log.finest(enginesManager.getClass().getSimpleName() + ": stopping " + enginesManager.getEngines().size() + " " + enginesManager.getEnginesDescription() + " engine(s)...");
 			result = result && enginesManager.stopEngines();
-			removeEngineManager(enginesManager); // remove the engine anyway
+			removeEngineManager(enginesManager); // remove the engines manager anyway
 		}
 
 		return true;
Index: tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java	(revision 923)
+++ tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java	(revision 924)
@@ -61,6 +61,9 @@
 	 */
 	public static ArrayList<String> alternativeNodesQualifiers = new ArrayList<String>();
 
+	
+	public final static String DEFAULT_ENCODING = "UTF-8"; //$NON-NLS-1$
+	
 	/**
 	 * Default unit/token property String.
 	 */
@@ -164,6 +167,8 @@
 	 * Save all preferences in the default app directory
 	 */
 	public static void saveAll() {
+		
+		Log.info("Saving preferences and session results.");
 		IPreferencesService service = Platform.getPreferencesService();
 		try {
 			service.getRootNode().flush();
