Index: tmp/org.txm.core/src/java/org/txm/xml/XMLProcessor.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/xml/XMLProcessor.java	(revision 2999)
+++ tmp/org.txm.core/src/java/org/txm/xml/XMLProcessor.java	(revision 3000)
@@ -2,7 +2,6 @@
 
 import java.io.BufferedOutputStream;
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.net.URL;
@@ -34,7 +33,7 @@
 	/**
 	 * list of XML elements that are always milestones elements
 	 */
-	protected HashSet<String> milestoneElements = new HashSet<String>();
+	protected HashSet<String> milestoneElements = new HashSet<>();
 	
 	/**
 	 * 
@@ -71,7 +70,7 @@
 			return parser.getAttributeValue(null, name);
 		}
 		
-		//no luck try all attributes 
+		// no luck try all attributes
 		int c = parser.getAttributeCount();
 		for (int i = 0; i < c; i++) {
 			if (name.equals(parser.getAttributeLocalName(i))) {
@@ -95,7 +94,7 @@
 	protected void after(boolean allWentWell) throws XMLStreamException, IOException {
 		
 		super.after(allWentWell); // close parser, inputData and factory
-				
+		
 		if (writer != null) writer.close();
 		
 		if (output != null) output.close();
@@ -106,22 +105,21 @@
 	 *
 	 * @param outfile the outfile
 	 * @return true, if successful
-	 * @throws XMLStreamException 
-	 * @throws IOException 
+	 * @throws XMLStreamException
+	 * @throws IOException
 	 */
 	private boolean createOutput(File f) throws XMLStreamException, IOException {
-			if (writer != null) { // process from a file
-				writer.close();
-			}
-			if (output != null) { // process from a file
-				output.close();
-			}
-			
-			output = new BufferedOutputStream(new FileOutputStream(f), 16 * 1024);
-			
-			writer = outfactory.createXMLStreamWriter(output, "UTF-8");// create a new file
-			writer.setNamespaceContext(Nscontext);
-			return true;
+		if (writer != null) { // process from a file
+			writer.close();
+		}
+		if (output != null) { // process from a file
+			output.close();
+		}
+		
+		output = new BufferedOutputStream(new FileOutputStream(f), 16 * 1024);
+		
+		// create writer later
+		return true;
 	}
 	
 	public boolean process(File outFile) throws XMLStreamException, IOException {
@@ -167,13 +165,13 @@
 				switch (event) {
 					case XMLStreamConstants.START_DOCUMENT:
 						processStartDocument();
-					break;
+						break;
 					case XMLStreamConstants.SPACE:
 						processSpace();
-					break;
+						break;
 					case XMLStreamConstants.NOTATION_DECLARATION:
 						processNotationDeclaration();
-					break;
+						break;
 					case XMLStreamConstants.NAMESPACE:
 						processNamespace();
 						break;
@@ -232,11 +230,20 @@
 		return true;
 	}
 	
+	@Override
 	protected void processStartDocument() throws XMLStreamException {
-		writer.writeStartDocument(parser.getCharacterEncodingScheme(), parser.getVersion());
+		
+		String encoding = parser.getCharacterEncodingScheme();
+		if (encoding == null) {
+			encoding = "UTF-8";
+		}
+		writer = outfactory.createXMLStreamWriter(output, encoding);// create a new file
+		writer.setNamespaceContext(Nscontext);
+		
+		writer.writeStartDocument(encoding, parser.getVersion());
 		writer.writeCharacters("\n");
 	}
-
+	
 	@Override
 	protected void processNamespace() throws XMLStreamException {
 		this.Nscontext.addNamespace(parser.getPrefix(), parser.getNamespaceURI());
@@ -250,14 +257,16 @@
 		if (prefix != null && prefix.length() > 0) {
 			if (milestoneElements.contains(localname)) {
 				writer.writeEmptyElement(Nscontext.getNamespaceURI(prefix), localname);
-			} else {
+			}
+			else {
 				writer.writeStartElement(Nscontext.getNamespaceURI(prefix), localname);
 			}
 		}
 		else {
 			if (milestoneElements.contains(localname)) {
 				writer.writeEmptyElement(localname);
-			} else {
+			}
+			else {
 				writer.writeStartElement(localname);
 			}
 		}
@@ -366,37 +375,37 @@
 			// parentParser.writer.writeAttribute("hook", name);
 			// }
 			// };
-//			XPathHookActivator xpathActivator = new XPathHookActivator(null, "//p");
-//			XPathsHookActivator xpathsActivator = new XPathsHookActivator(null, Arrays.asList("//p", "//p"));
-//			IdentityHook hook2 = new IdentityHook("hook2", xpathsActivator, builder) {
-//				
-//				@Override
-//				public boolean _activate() {
-//					System.out.println("ACTIVATING " + name + " AT " + getLocation());
-//					return true;
-//				}
-//				
-//				@Override
-//				public boolean deactivate() {
-//					System.out.println("DEACTIVATING " + name + " AT " + getLocation());
-//					return true;
-//				}
-//				
-//				@Override
-//				public void processStartElement() throws XMLStreamException, IOException {
-//					super.processStartElement();
-//					parentParser.writer.writeAttribute("hook", name);
-//				}
-//			};
-//			
-//			// DOMIdentityHook hook3 = new DOMIdentityHook("hook3", xpathsActivator, builder) {
+			// XPathHookActivator xpathActivator = new XPathHookActivator(null, "//p");
+			// XPathsHookActivator xpathsActivator = new XPathsHookActivator(null, Arrays.asList("//p", "//p"));
+			// IdentityHook hook2 = new IdentityHook("hook2", xpathsActivator, builder) {
 			//
+			// @Override
+			// public boolean _activate() {
+			// System.out.println("ACTIVATING " + name + " AT " + getLocation());
+			// return true;
+			// }
+			//
+			// @Override
+			// public boolean deactivate() {
+			// System.out.println("DEACTIVATING " + name + " AT " + getLocation());
+			// return true;
+			// }
+			//
+			// @Override
+			// public void processStartElement() throws XMLStreamException, IOException {
+			// super.processStartElement();
+			// parentParser.writer.writeAttribute("hook", name);
+			// }
 			// };
+			//
+			// // DOMIdentityHook hook3 = new DOMIdentityHook("hook3", xpathsActivator, builder) {
+			//
+			// };
 			
 			long time = System.currentTimeMillis();
 			if (builder.process(output)) {
 				System.out.println("Time=" + (System.currentTimeMillis() - time));
-				//System.out.println("XPaths activator has done working ? " + xpathsActivator.hasAllXpathsBeenProcessed());
+				// System.out.println("XPaths activator has done working ? " + xpathsActivator.hasAllXpathsBeenProcessed());
 			}
 			else {
 				System.out.println("failure !");
@@ -419,7 +428,7 @@
 			milestoneElements.remove(e);
 		}
 	}
-
+	
 	/**
 	 * 
 	 * @return the actual hooks hash
Index: tmp/org.txm.core/src/java/org/txm/Toolbox.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/Toolbox.java	(revision 2999)
+++ tmp/org.txm.core/src/java/org/txm/Toolbox.java	(revision 3000)
@@ -81,20 +81,20 @@
  * 
  */
 public class Toolbox {
-
+	
 	public static final DateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
-	//public static final DateFormat shortUKDateformat = new SimpleDateFormat("dd-MM-yy");
-
-	private static LinkedHashMap<EngineType, EnginesManager<?>> enginesManagers = new LinkedHashMap<EngineType, EnginesManager<?>>();
-
+	// public static final DateFormat shortUKDateformat = new SimpleDateFormat("dd-MM-yy");
+	
+	private static LinkedHashMap<EngineType, EnginesManager<?>> enginesManagers = new LinkedHashMap<>();
+	
 	private static boolean initializing = false;
-
+	
 	/** The state. */
 	private static boolean state = false;
-
+	
 	/** Root of all TXMResults and manages the corpus */
 	public static Workspace workspace;
-
+	
 	/**
 	 * 
 	 * @param enginesManager
@@ -102,7 +102,7 @@
 	private static void addEngineManager(EnginesManager<?> enginesManager) {
 		enginesManagers.put(enginesManager.getEnginesType(), enginesManager);
 	}
-
+	
 	/**
 	 * If search engine or stats engine or workspace is not ready then the toolbox is not ready.
 	 *
@@ -111,38 +111,39 @@
 	private static boolean checkState() {
 		return state;
 	}
-
+	
 	private static boolean fetchEnginesManagers() {
 		Log.finest("Fetching engines managers...");
 		enginesManagers.clear();
-		//System.out.println("Contributions of "+EnginesManager.ENGINEMANAGER_EXTENSION_POINT_ID);
-		//Platform.getExtensionRegistry().getExtensionPoints();
+		// System.out.println("Contributions of "+EnginesManager.ENGINEMANAGER_EXTENSION_POINT_ID);
+		// Platform.getExtensionRegistry().getExtensionPoints();
 		IConfigurationElement[] contributions = RegistryFactory.getRegistry().getConfigurationElementsFor(EnginesManager.ENGINES_MANAGER_EXTENSION_POINT_ID);
-		//System.out.println("contributions: "+Arrays.toString(contributions));
-
+		// System.out.println("contributions: "+Arrays.toString(contributions));
+		
 		Log.fine(contributions.length + " engines managers found.");
-
+		
 		for (int i = 0; i < contributions.length; i++) {
 			try {
-				EnginesManager<?> enginesManager = (EnginesManager<?>)contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
-
+				EnginesManager<?> enginesManager = (EnginesManager<?>) contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
+				
 				Log.fine("Registering " + enginesManager.getEnginesDescription() + " engines manager...");
 				addEngineManager(enginesManager);
 				if (enginesManager.fetchEngines()) {
-					//System.out.println("add engine: "+engine);
-
+					// System.out.println("add engine: "+engine);
+					
 				}
 				else {
 					Log.warning("No engine found for " + enginesManager + ", installation failed.");
 				}
-			} catch(Throwable e) {
+			}
+			catch (Throwable e) {
 				e.printStackTrace();
-			} 
+			}
 		}
-
+		
 		return true;
 	}
-
+	
 	/**
 	 * Gets a preference from the Toolbox Preferences node.
 	 * 
@@ -152,37 +153,40 @@
 	public static String getPreference(String key) {
 		return TBXPreferences.getInstance().getString(key);
 	}
-
+	
 	/**
 	 * Sets a preference of the Toolbox Preferences node.
+	 * 
 	 * @param key
 	 * @param value
 	 */
 	public static void setPreference(String key, Object value) {
 		TBXPreferences.getInstance().put(key, value);
 	}
-
+	
 	/**
 	 * Gets the manager of the specified engine type.
+	 * 
 	 * @param engineType
 	 * @return
 	 */
 	public static EnginesManager<? extends Engine> getEngineManager(EngineType engineType) {
-
+		
 		if (enginesManagers == null) {
 			return null;
 		}
 		return enginesManagers.get(engineType);
 	}
-
+	
 	/**
 	 * Gets the TXM working directory.
-	 * @return the TXM working directory set with the USER_TXM_HOME preference key 
+	 * 
+	 * @return the TXM working directory set with the USER_TXM_HOME preference key
 	 */
 	public static String getTxmHomePath() {
 		return getPreference(TBXPreferences.USER_TXM_HOME);
 	}
-
+	
 	/**
 	 * Initializes the Toolbox with the parameters read in the file
 	 * textometrie.properties found in the user home directory
@@ -200,16 +204,16 @@
 		File configFile = new File(txmDirectory, "textometrie.properties"); //$NON-NLS-1$
 		if (!configFile.exists()) {
 			initializing = false;
-			throw new IllegalArgumentException(TXMCoreMessages.file 
+			throw new IllegalArgumentException(TXMCoreMessages.file
 					+ configFile.getAbsolutePath()
-					+ TXMCoreMessages.doesNotExists); 
+					+ TXMCoreMessages.doesNotExists);
 		}
-
+		
 		boolean ret = initialize(configFile);
 		initializing = false;
 		return ret;
 	}
-
+	
 	/**
 	 * 
 	 * @param preferencesStore
@@ -219,34 +223,36 @@
 	public static boolean initialize(Class preferencesStore) throws Exception {
 		return initialize(preferencesStore, new LogMonitor("initializing Toolbox"));
 	}
-
+	
 	/**
 	 * Initializes the Toolbox using the INSTANCE SCOPE preferences of TXMPreferences
 	 *
 	 * @param props the props
 	 * @param monitor the optional monitor
 	 * @return true, if successful
-	 * @throws Exception 
+	 * @throws Exception
 	 */
 	public static boolean initialize(Class preferencesStore, IProgressMonitor monitor) throws Exception {
 		initializing = true;
-
+		
 		try {
 			Log.fine("Initializing logger...");
 			Log.setLevel(Level.parse(getPreference(TBXPreferences.LOG_LEVEL)));
 			Log.setPrintInConsole(TBXPreferences.getInstance().getBoolean(TBXPreferences.ADD_TECH_LOGS));
 			Log.log_stacktrace_boolean = TBXPreferences.getInstance().getBoolean(TBXPreferences.LOG_STACKTRACE);
-
+			
 			if (!getPreference(TBXPreferences.LOG_DIR).isEmpty()) {
 				Log.setPrintInFile(TBXPreferences.getInstance().getBoolean(TBXPreferences.LOG_IN_FILE), new File(getPreference(TBXPreferences.LOG_DIR)));
-			} else {
+			}
+			else {
 				Log.setPrintInFile(TBXPreferences.getInstance().getBoolean(TBXPreferences.LOG_IN_FILE));
 			}
-		} catch(Exception e) {
-			System.out.println("Error while initializing logger: "+e);
+		}
+		catch (Exception e) {
+			System.out.println("Error while initializing logger: " + e);
 			e.printStackTrace();
 		}
-
+		
 		if (monitor != null) {
 			monitor.setTaskName(TXMCoreMessages.initializingToolbox);
 		}
@@ -255,63 +261,67 @@
 				monitor.subTask(TXMCoreMessages.loadingExtensionPreInstallation);
 			}
 			pluginsPreinstallation(monitor);
-		} catch(Exception e) {
+		}
+		catch (Exception e) {
 			Log.warning(NLS.bind(TXMCoreMessages.errorWhilePreInstallingPluginsP0, e.getLocalizedMessage()));
 		}
-
+		
 		if (monitor != null && monitor.isCanceled()) return false;
-
+		
 		try {
 			// initialize workspace : list of corpus loaded in TXM
 			// copy shared files if needed
 			state = startWorkspace(monitor);
 			if (monitor != null && monitor.isCanceled()) return false;
-
-
-
-		} catch (Exception e) {
+			
+			
+			
+		}
+		catch (Exception e) {
 			initializing = false;
 			throw e;
 		}
-
+		
 		try {
 			startEnginesManagers(monitor);
 			if (monitor != null && monitor.isCanceled()) return false;
-		} catch (Exception e) {
+		}
+		catch (Exception e) {
 			Log.warning("Error while starting engines.");
 			e.printStackTrace();
 			initializing = false;
 			throw e;
 		}
-
+		
 		Log.finest(TXMCoreMessages.bind(TXMCoreMessages.ToolboxStatesWorkspaceColonP0, state));
-
+		
 		try {
 			if (monitor != null) {
 				monitor.subTask(TXMCoreMessages.loadingExtensionPostInstallation);
-
 			}
 			pluginsPostinstallation(monitor);
 			if (monitor != null && monitor.isCanceled()) return false;
-		} catch(Exception e) {
+		}
+		catch (Exception e) {
 			Log.warning(NLS.bind(TXMCoreMessages.errorWhilePostInstallingPluginsP0, e.getLocalizedMessage()));
 		}
-
+		
 		// loads and recreate the existing projects, loadParameters() needs engines to be ready
 		if (workspace != null) {
 			workspace.loadProjectsFromProjectScopes(monitor);
 			monitor.subTask("");
-		} else {
+		}
+		else {
 			System.out.println("Error: Toolbox not correctly initialized. Aborting workspace initialization.");
 		}
-
+		
 		initializing = false;
 		if (monitor != null) {
 			monitor.setTaskName("");
 		}
 		return checkState();
 	}
-
+	
 	/**
 	 * initialize the toolbox from a UTF-8 file
 	 * 
@@ -325,17 +335,17 @@
 	public static boolean initialize(File file) throws Exception {
 		initializing = true;
 		String encoding = "UTF-8"; //$NON-NLS-1$
-
+		
 		// Windows OS
 		if (OSDetector.isFamilyWindows()) {
 			encoding = "ISO-8859-1"; //$NON-NLS-1$
-		}		
-
+		}
+		
 		boolean ret = initialize(file, encoding);
 		initializing = false;
 		return ret;
 	}
-
+	
 	/**
 	 * Initializes the toolbox with the parameters read in the properties file
 	 * passed in argument.
@@ -348,7 +358,7 @@
 	 */
 	public static boolean initialize(File file, String encoding) throws Exception {
 		initializing = true;
-
+		
 		try {
 			BufferedReader input = new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding));
 			String line = input.readLine();
@@ -356,7 +366,8 @@
 				String[] split = line.split("="); //$NON-NLS-1$
 				if (split.length == 2) {
 					setPreference(split[0], split[1]);
-				} else if (split.length > 2) {
+				}
+				else if (split.length > 2) {
 					String[] subsplit = new String[split.length - 1];
 					System.arraycopy(split, 1, subsplit, 0, split.length - 1);
 					setPreference(split[0], StringUtils.join(subsplit, "="));
@@ -364,14 +375,15 @@
 				line = input.readLine();
 			}
 			input.close();
-		} catch (Exception e) {
+		}
+		catch (Exception e) {
 			initializing = false;
 			System.err.println(e);
 			throw e;
 		}
 		return initialize(TBXPreferences.class);
 	}
-
+	
 	/**
 	 * test if searchEngine and statEngine and Workspace are initialized.
 	 *
@@ -380,35 +392,37 @@
 	public static boolean isInitialized() {
 		return checkState();
 	}
-
+	
 	public static boolean isInitializing() {
 		return initializing;
 	}
-
+	
 	/**
 	 * Allow to install a TXM extension AFTER the Toolbox is initialized
-	 * @param monitor 
+	 * 
+	 * @param monitor
 	 */
 	private static void pluginsPostinstallation(IProgressMonitor monitor) {
-
+		
 		IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(PostInstallationStep.EXTENSION_ID);
-
+		
 		Log.fine(TXMCoreMessages.loadingExtensions);
 		Log.fine(Arrays.toString(config));
-
+		
 		for (IConfigurationElement e : config) {
 			if (monitor != null && monitor.isCanceled()) return;
 			try {
 				Log.fine(NLS.bind(TXMCoreMessages.evaluatingExtensionColonP0FromP1, e.getName(), e.getContributor().getName()));
-
+				
 				final Object o = e.createExecutableExtension("class"); //$NON-NLS-1$
 				if (o instanceof PostInstallationStep) {
 					ISafeRunnable runnable = new ISafeRunnable() {
+						
 						@Override
 						public void handleException(Throwable exception) {
 							Log.severe(NLS.bind(TXMCoreMessages.exceptionColonP0, exception));
 						}
-
+						
 						@Override
 						public void run() throws Exception {
 							((PostInstallationStep) o).install();
@@ -416,35 +430,37 @@
 					};
 					SafeRunner.run(runnable);
 				}
-			} catch (Exception ex) {
+			}
+			catch (Exception ex) {
 				Log.severe("Exception while installing " + e.getName() + ".");
 				ex.printStackTrace();
 			}
 		}
 	}
-
+	
 	/**
 	 * Allow to install a TXM extension BEFORE the Toolbox is initialized
 	 */
 	private static void pluginsPreinstallation(IProgressMonitor monitor) {
-
+		
 		IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(PostInstallationStep.EXTENSION_ID);
 		Log.fine(TXMCoreMessages.loadingExtensions);
 		Log.fine(Arrays.toString(config));
-
+		
 		for (IConfigurationElement e : config) {
 			if (monitor != null && monitor.isCanceled()) return;
 			try {
 				Log.fine(NLS.bind(TXMCoreMessages.evaluatingExtensionColonP0FromP1, e.getName(), e.getContributor().getName()));
-
+				
 				final Object o = e.createExecutableExtension("class"); //$NON-NLS-1$
 				if (o instanceof PostInstallationStep) {
 					ISafeRunnable runnable = new ISafeRunnable() {
+						
 						@Override
 						public void handleException(Throwable exception) {
 							Log.severe(NLS.bind(TXMCoreMessages.exceptionColonP0, exception));
 						}
-
+						
 						@Override
 						public void run() throws Exception {
 							((PostInstallationStep) o).preInstall();
@@ -452,68 +468,70 @@
 					};
 					SafeRunner.run(runnable);
 				}
-			} catch (Exception ex) {
+			}
+			catch (Exception ex) {
 				Log.severe("Exception while installing " + e.getName() + ".");
 				ex.printStackTrace();
 			}
 		}
 	}
-
+	
 	/**
 	 * Removes an engines manager.
+	 * 
 	 * @param enginesManager
 	 */
 	private static void removeEngineManager(EnginesManager<?> enginesManager) {
 		enginesManagers.remove(enginesManager.getEnginesType());
 		Log.finest("Engines manager removed: " + enginesManager);
 	}
-
+	
 	/**
 	 * Restarts the toolbox.
 	 *
 	 * @return true, if successful
-	 * @throws Exception 
+	 * @throws Exception
 	 */
 	public static boolean restart() throws Exception {
 		Toolbox.shutdown();
 		Toolbox.initialize(TBXPreferences.class);
 		return checkState();
 	}
-
-	//	/**
-	//	 * Restart the toolbox's workspace.
-	//	 *
-	//	 * @return true, if successful
-	//	 */
-	//	public static boolean restartWorkspace(IProgressMonitor monitor) {
-	//		try {
-	//			shutdownWorkspace();
-	//			startWorkspace(monitor);
-	//		} catch (Exception e) {
-	//			Log.severe("Error while restarting workspace.");
-	//			e.printStackTrace();
-	//		}
-	//		return checkState();
-	//	}
-
+	
+	// /**
+	// * Restart the toolbox's workspace.
+	// *
+	// * @return true, if successful
+	// */
+	// public static boolean restartWorkspace(IProgressMonitor monitor) {
+	// try {
+	// shutdownWorkspace();
+	// startWorkspace(monitor);
+	// } catch (Exception e) {
+	// Log.severe("Error while restarting workspace.");
+	// e.printStackTrace();
+	// }
+	// return checkState();
+	// }
+	
 	/**
 	 * Shut the toolbox down.
 	 */
 	public static void shutdown() {
-
+		
 		stopEnginesManagers();
-
+		
 		try {
 			// FIXME: tmp solution before IProject: remove all not persistable result nodes
-			//TXMPreferences.deleteAllNotPersistableResultsNodes();
+			// TXMPreferences.deleteAllNotPersistableResultsNodes();
 			// FIXME: tmp solution before IProject: remove result local nodes if persistence preference is disabled
-			//			if (!TBXPreferences.getInstance().getBoolean(TBXPreferences.AUTO_PERSISTENCE_ENABLED)) {
-			//				TXMPreferences.deleteAllResultsNodes();
-			//			}
+			// if (!TBXPreferences.getInstance().getBoolean(TBXPreferences.AUTO_PERSISTENCE_ENABLED)) {
+			// TXMPreferences.deleteAllResultsNodes();
+			// }
 			// FIXME: other tmp solution
-			//TODO iterates over opened projects to save them (not close); add this code to project.close
+			// TODO iterates over opened projects to save them (not close); add this code to project.close
 			
-
+			
 			// save projects parameters
 			if (Toolbox.workspace != null) {
 				TXMResult.deleteAllNonPersistentResults(Toolbox.workspace);
@@ -521,58 +539,60 @@
 			}
 			Toolbox.workspace = null;
 			state = false;
-
-			//save global preferences
+			
+			// save global preferences
 			TXMPreferences.saveAll();
-		} catch (Exception e) {
+		}
+		catch (Exception e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
 	}
-
-	//	/**
-	//	 * Shut the toolbox workspace down.
-	//	 */
-	//	public static void shutdownWorkspace() {
-	//		try {
-	//			Toolbox.workspace.saveParameters();
-	//			Toolbox.workspace = null;
-	//			state = false;
-	//		} catch (Exception e) {
-	//			Log.severe("Error while closing workspace.");
-	//			e.printStackTrace();
-	//		}
-	//	}
-
+	
+	// /**
+	// * Shut the toolbox workspace down.
+	// */
+	// public static void shutdownWorkspace() {
+	// try {
+	// Toolbox.workspace.saveParameters();
+	// Toolbox.workspace = null;
+	// state = false;
+	// } catch (Exception e) {
+	// Log.severe("Error while closing workspace.");
+	// e.printStackTrace();
+	// }
+	// }
+	
 	public static boolean startEnginesManagers(IProgressMonitor monitor) {
-
+		
 		fetchEnginesManagers();
-
+		
 		Log.finest("Starting engines of the " + enginesManagers.keySet().size() + " engines managers...");
-
+		
 		boolean result = true;
 		for (EngineType et : enginesManagers.keySet()) {
 			EnginesManager<?> enginesManager = enginesManagers.get(et);
 			try {
 				Log.finest(enginesManager.getClass().getSimpleName() + ": starting " + enginesManager.getEngines().size() + " " + enginesManager.getEnginesDescription() + " engine(s)...");
 				result = enginesManager.startEngines(monitor) && result; // order is important
-			} catch(Exception e) {
+			}
+			catch (Exception e) {
 				Log.severe("Error while starting engines of the " + enginesManager.getEnginesDescription() + " engines manager.");
 				e.printStackTrace();
 			}
 		}
 		return result;
 	}
-
+	
 	public static boolean stopEnginesManagers() {
-
+		
 		Log.finest("Stopping engines of the " + enginesManagers.keySet().size() + " engines managers...");
-
+		
 		if (enginesManagers == null) return true;
 		if (enginesManagers.size() == 0) return true;
-
+		
 		boolean result = true;
-		HashSet<EngineType> ets = new HashSet<EngineType>();
+		HashSet<EngineType> ets = new HashSet<>();
 		ets.addAll(enginesManagers.keySet());
 		for (EngineType et : ets) {
 			EnginesManager<?> enginesManager = enginesManagers.get(et);
@@ -580,20 +600,20 @@
 			result = result && enginesManager.stopEngines();
 			removeEngineManager(enginesManager); // remove the engine manager anyway
 		}
-
+		
 		return true;
 	}
-
-
-
+	
+	
+	
 	private static boolean startWorkspace(IProgressMonitor monitor) {
-
+		
 		String txmhomedir = getPreference(TBXPreferences.USER_TXM_HOME);
 		if (txmhomedir == null || txmhomedir.length() == 0) {
 			state = false;
 			return false;
 		}
-
+		
 		Version currentVersion = BundleUtils.getBundleVersion("org.txm.core");
 		Log.fine(TXMCoreMessages.bind("Current toolbox version: {0}.", currentVersion));
 		String installedVersionString = getPreference(TBXPreferences.VERSION);
@@ -603,81 +623,88 @@
 		Version installedVersion = new Version(installedVersionString);
 		Log.fine(TXMCoreMessages.bind("Installed toolbox version: {0}.", installedVersion));
 		try {
-			//System.out.println("Toolbox.startWorkspace(): workspace location = " + location);
-
+			// System.out.println("Toolbox.startWorkspace(): workspace location = " + location);
+			
 			boolean doUpdateworkspace = currentVersion.compareTo(installedVersion) > 0;
-
+			
 			if (doUpdateworkspace) { // newer install
 				Log.fine("Updating Toolbox workspace...");
-
+				
 				// create or update the workspace & create TXM default.xml workspace file
-				Toolbox.workspace = createOrUpdate(new File(txmhomedir)); //$NON-NLS-1$
-
+				Toolbox.workspace = createOrUpdate(new File(txmhomedir));
+				
 				// test
 				if (Toolbox.workspace == null) {
 					Log.severe("Error: workspace not updated (is null).");
 					return false;
 				}
 				setPreference(TBXPreferences.VERSION, currentVersion.toString());
-			} else { // already existing workspace
+			}
+			else { // already existing workspace
 				workspace = Workspace.getInstance();
 			}
-
-			Log.fine(NLS.bind(TXMCoreMessages.loadingWorkspaceFromFileColonP0, txmhomedir)); 
+			
+			Log.fine(NLS.bind(TXMCoreMessages.loadingWorkspaceFromFileColonP0, txmhomedir));
 			state = true;
-
-			if (workspace == null) { //$NON-NLS-1$
-				Log.severe(NLS.bind(TXMCoreMessages.errorLoadingWorkspaceFromFileColonP0, txmhomedir)); 
+			
+			if (workspace == null) {
+				Log.severe(NLS.bind(TXMCoreMessages.errorLoadingWorkspaceFromFileColonP0, txmhomedir));
 				state = false;
-				//System.out.println(TXMCoreMessages.FAILED);
+				// System.out.println(TXMCoreMessages.FAILED);
 				return false;
-			} else {
-				//System.out.println(TXMCoreMessages.DONE);
+			}
+			else {
+				// System.out.println(TXMCoreMessages.DONE);
 				// updating extension files
 				IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(PostTXMHOMEInstallationStep.EXTENSION_ID);
-				//System.out.println("contributions: "+Arrays.toString(contributions));
-				Log.fine("Installing extensions ("+contributions.length+")");
+				// System.out.println("contributions: "+Arrays.toString(contributions));
+				Log.fine("Installing extensions (" + contributions.length + ")");
 				for (int i = 0; i < contributions.length; i++) {
 					try {
 						Log.fine(TXMCoreMessages.bind("Installing extentions: {0}...", contributions[i].getName()));
-						PostTXMHOMEInstallationStep extp = (PostTXMHOMEInstallationStep)contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
-
+						PostTXMHOMEInstallationStep extp = (PostTXMHOMEInstallationStep) contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
+						
 						if (!extp.install(workspace)) {
-							Log.severe("Fail to install "+extp.getName()+" files in "+workspace.getLocation());
+							Log.severe("Fail to install " + extp.getName() + " files in " + workspace.getLocation());
 						}
-					} catch(CoreException e) {
+					}
+					catch (CoreException e) {
 						e.printStackTrace();
-					} 
+					}
 				}
 			}
-		} catch (Exception e) {
-			Log.warning(NLS.bind(TXMCoreMessages.errorDuringWorkspaceInitializationColonP0, txmhomedir)); 
+		}
+		catch (Exception e) {
+			Log.warning(NLS.bind(TXMCoreMessages.errorDuringWorkspaceInitializationColonP0, txmhomedir));
 			Log.warning(NLS.bind(TXMCoreMessages.errorColonP0, Log.toString(e)));
 			Log.printStackTrace(e);
 			state = false;
 		}
 		return workspace != null;
 	}
-
-	/* (non-Javadoc)
+	
+	/*
+	 * (non-Javadoc)
 	 * @see java.lang.Object#finalize()
 	 */
 	@Override
 	protected void finalize() throws Throwable {
 		try {
 			Toolbox.shutdown();
-		} finally {
+		}
+		finally {
 			super.finalize();
 		}
 	}
-
+	
 	/**
 	 * Gets a Collator for the specified result.
 	 * The collator is created from the parent of the result if exists and if its a TXMObject (from "lang" attribute) otherwise it is created from the default locale.
+	 * 
 	 * @param result
-	 * @return 
+	 * @return
 	 */
-	public static Collator getCollator(TXMResult result)	{
+	public static Collator getCollator(TXMResult result) {
 		Locale locale = Locale.getDefault();
 		String lang = result.getStringParameterValue(TBXPreferences.LANG);
 		if (lang != null) {
@@ -687,21 +714,23 @@
 		collator.setStrength(Collator.TERTIARY);
 		return collator;
 	}
-
+	
 	public static String getMetadataEncoding() {
 		return getPreference(TBXPreferences.METADATA_ENCODING);
 	}
-	public static String getMetadataColumnSeparator(){
+	
+	public static String getMetadataColumnSeparator() {
 		return getPreference(TBXPreferences.METADATA_COLSEPARATOR);
 	}
+	
 	public static String getMetadataTextSeparator() {
 		return getPreference(TBXPreferences.METADATA_TXTSEPARATOR);
 	}
-
+	
 	public static String getInstallDirectory() {
 		return getPreference(TBXPreferences.INSTALL_DIR);
 	}
-
+	
 	/**
 	 * Creates&Update workspace directory.
 	 * 
@@ -713,69 +742,71 @@
 	public static Workspace createOrUpdate(File txmhomedir) {
 		try {
 			txmhomedir.mkdirs();
-
+			
 			if (!txmhomedir.exists()) {
 				System.out.println(NLS.bind(TXMCoreMessages.couldNotCreateTXMHOMEDirectoryColonP0, txmhomedir));
 				return null;
 			}
-
+			
 			// create folders
 			String createfolders[] = {
 					"corpora", "clipboard", //$NON-NLS-1$ //$NON-NLS-2$
-					"css", "xsl", "schema", "scripts"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-			String deletefolders[] = {"clipboard"}; //$NON-NLS-1$
-
+					"css", "xsl", "schema", "scripts" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+			String deletefolders[] = { "clipboard" }; //$NON-NLS-1$
+			
 			for (String folder : deletefolders) {
 				DeleteDir.deleteDirectory(new File(txmhomedir, folder));
 			}
-
+			
 			for (String folder : createfolders) {
 				new File(txmhomedir, folder).mkdir();
 			}
-
-			//			if (!xmlfile.exists()) {
-			//				if (!writeEmptyWorkspaceFile(xmlfile)) {
-			//					System.out.println("Error while creating workspace definition file: "+xmlfile);
-			//				}
-			//			}
-
+			
+			// if (!xmlfile.exists()) {
+			// if (!writeEmptyWorkspaceFile(xmlfile)) {
+			// System.out.println("Error while creating workspace definition file: "+xmlfile);
+			// }
+			// }
+			
 			String path = Toolbox.getPreference(TBXPreferences.INSTALL_DIR);
 			File installDirectory = new File(path);
 			if (!installDirectory.exists()) {
-				Log.warning("Error: Workspace cannot found install directory: "+installDirectory.getAbsolutePath());
+				Log.warning("Error: Workspace cannot found install directory: " + installDirectory.getAbsolutePath());
 				return null;
 			}
-
+			
 			File redistDirectory = new File(installDirectory, "redist");
 			if (!redistDirectory.exists()) {
-				Log.warning("Warning: Workspace cannot found redist directory: "+redistDirectory.getAbsolutePath());
-			} else {
+				Log.warning("Warning: Workspace cannot found redist directory: " + redistDirectory.getAbsolutePath());
+			}
+			else {
 				FileCopy.copyFiles(redistDirectory, txmhomedir);
 			}
-
-			//			// the folders to copy from TXM install dir
-			//			BundleUtils.copyFiles("org.txm.core", "res", "org/txm/xml", "xsl", txmhomedir);
-			//			BundleUtils.copyFiles("org.txm.core", "res", "org/txm/xml", "schema", txmhomedir);
-			//			BundleUtils.copyFiles("org.txm.core", "res", "org/txm", "css", txmhomedir);
-
+			
+			// // the folders to copy from TXM install dir
+			// BundleUtils.copyFiles("org.txm.core", "res", "org/txm/xml", "xsl", txmhomedir);
+			// BundleUtils.copyFiles("org.txm.core", "res", "org/txm/xml", "schema", txmhomedir);
+			// BundleUtils.copyFiles("org.txm.core", "res", "org/txm", "css", txmhomedir);
+			
 			workspace = Workspace.getInstance();
-
+			
 			return workspace;
-		} catch (Exception e) {
+		}
+		catch (Exception e) {
 			Log.warning(NLS.bind(TXMCoreMessages.failedToCopyTXMFilesFromTXMINSTALLDIRToTXMHOMEColonP0, e.getLocalizedMessage()));
 			e.printStackTrace();
 			return null;
 		}
 	}
-
+	
 	public static ImportEngines getImportEngines() {
 		return (ImportEngines) getEngineManager(EngineType.IMPORT);
 	}
-
+	
 	public static LinkedHashMap<EngineType, EnginesManager<?>> getEngineManagers() {
 		return enginesManagers;
 	}
-
+	
 	/**
 	 * Notify all engines about a result state
 	 * 
@@ -783,7 +814,7 @@
 	 * @param state
 	 */
 	public static void notifyEngines(TXMResult r, String state) {
-		Log.fine("Toolbox.notifyEngines "+r+" -> "+state);
+		Log.fine("Toolbox.notifyEngines " + r + " -> " + state);
 		for (EnginesManager<?> em : enginesManagers.values()) {
 			if (em == null) continue;
 			for (Engine e : em.getEngines().values()) {
@@ -792,4 +823,4 @@
 			}
 		}
 	}
-}
\ No newline at end of file
+}
