Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchAdvisor.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchAdvisor.java	(revision 2555)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchAdvisor.java	(revision 2556)
@@ -113,6 +113,7 @@
 import org.txm.rcp.perspective.TXMPerspective;
 import org.txm.rcp.preferences.RCPPreferences;
 import org.txm.rcp.utils.JobHandler;
+import org.txm.rcp.utils.SWTEditorsUtils;
 import org.txm.utils.BundleUtils;
 import org.txm.utils.DeleteDir;
 import org.txm.utils.io.IOUtils;
@@ -122,25 +123,28 @@
  * Manages the opening and closing of TXM
  */
 public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
-
+	
 	private boolean installPreferenceRestored;
+	
 	private IOConsoleOutputStream stream;
+	
 	private IOConsoleInputStream streamInput;
-
-	/* (non-Javadoc)
+	
+	/*
+	 * (non-Javadoc)
 	 * @see org.eclipse.ui.application.WorkbenchAdvisor#createWorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)
 	 */
 	@Override
 	public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
 		return new ApplicationWorkbenchWindowAdvisor(configurer);
 	}
-
+	
 	@Override
 	public IAdaptable getDefaultPageInput() {
 		org.eclipse.core.resources.IWorkspace workspace = org.eclipse.core.resources.ResourcesPlugin.getWorkspace();
 		return workspace.getRoot();
 	}
-
+	
 	/**
 	 * initialization code done after the splash screen.
 	 *
@@ -149,22 +153,22 @@
 	@Override
 	public void initialize(IWorkbenchConfigurer configurer) {
 		org.eclipse.ui.ide.IDE.registerAdapters();
-
-		//WorkbenchAdapterBuilder.registerAdapters(); // deprecated
+		
+		// WorkbenchAdapterBuilder.registerAdapters(); // deprecated
 		PlatformUI.getPreferenceStore().setValue(
 				IWorkbenchPreferenceConstants.SHOW_PROGRESS_ON_STARTUP, true);
 		InitializeLogger();
-
+		
 		configurer.setSaveAndRestore(true);
 	}
-
+	
 	@Override
 	public void preStartup() {
-
+		
 	}
-
-
-
+	
+	
+	
 	/**
 	 * Set Eclipse Theme depending on the OS
 	 */
@@ -172,23 +176,24 @@
 	private void setDefaultTheme() {
 		Bundle b = FrameworkUtil.getBundle(getClass());
 		BundleContext context = b.getBundleContext();
-
+		
 		ServiceReference serviceRef = context.getServiceReference(IThemeManager.class.getName());
 		@SuppressWarnings("unchecked")
 		IThemeManager themeManager = (IThemeManager) context.getService(serviceRef);
 		IThemeEngine engine = themeManager.getEngineForDisplay(Display.getDefault());
-
+		
 		String theme = "org.txm.rcp.theme.default.linux"; //$NON-NLS-1$
-
-		if (Util.isWindows()) { //$NON-NLS-1$
+		
+		if (Util.isWindows()) {
 			theme = "org.txm.rcp.theme.default.windows"; //$NON-NLS-1$
-		} else if (Util.isMac()) { //$NON-NLS-1$
+		}
+		else if (Util.isMac()) {
 			theme = "org.txm.rcp.theme.default.mac"; //$NON-NLS-1$
 		}
-
+		
 		engine.setTheme(theme, true);
 	}
-
+	
 	/**
 	 * initialization code done after the splash screen call a job which does the
 	 * post installation the TXMHOME, checks the TreeTagger and finally
@@ -196,18 +201,19 @@
 	 */
 	@Override
 	public void postStartup() {
-
-		try {			
+		
+		try {
 			// create the Toolbox initialization job
 			JobHandler jobhandler = new JobHandler(TXMUIMessages.initializationOfThePlatform, true) {
+				
 				@Override
 				protected IStatus run(final IProgressMonitor monitor) {
 					JobsTimer.start();
 					this.runInit(monitor);
 					try {
-
+						
 						monitor.beginTask(TXMUIMessages.startingTxm, 100);
-
+						
 						monitor.setTaskName(TXMUIMessages.loadingTXMInstallPreferences);
 						Log.fine(TXMUIMessages.startJobColonLoadInstallPreferences);
 						if (!checkInstallDirectory(this)) {
@@ -216,7 +222,7 @@
 							return Status.CANCEL_STATUS;
 						}
 						monitor.worked(10);
-
+						
 						monitor.setTaskName(TXMUIMessages.checkingForExistingWorkspaceDirectory);
 						Log.warning(TXMUIMessages.startJobColonCheckTXMHOME);
 						if (!checkTXMHOME(this, monitor)) {
@@ -224,56 +230,59 @@
 							System.err.println(TXMUIMessages.errorsOccuredDuringTXMPostInstallation);
 						}
 						monitor.worked(30);
-
-						//INITIALIZE TBX AND UI
+						
+						// INITIALIZE TBX AND UI
 						monitor.setTaskName(TXMUIMessages.initializingPlatform);
 						Log.warning(TXMUIMessages.startJobColonInitializeUI);
 						if (!initializeUI(this)) {
 							monitor.done();
 							return Status.CANCEL_STATUS;
 						}
-
+						
 						Log.info(TXMUIMessages.info_txmIsReady);
 						monitor.done();
-					} catch (Exception e) {
+					}
+					catch (Exception e) {
 						System.out.println(TXMCoreMessages.bind(TXMUIMessages.errorWhileLoadingTXMColon, e));
 						org.txm.utils.logger.Log.printStackTrace(e);
-					} catch(ThreadDeath td) {
+					}
+					catch (ThreadDeath td) {
 						System.out.println(TXMUIMessages.TXMInitializationHasBeenCanceledByUserDotPleaseRestartTXM);
 					}
-
+					
 					JobsTimer.stopAndPrint();
 					return Status.OK_STATUS;
 				}
 			};
 			jobhandler.startJob();
-
+			
 			// start update NOT IN A JOB
 			startUpdateLookUpJob(false);
-
-		} catch (Exception e) {
+			
+		}
+		catch (Exception e) {
 			Log.severe(TXMCoreMessages.bind(TXMUIMessages.startupFailedPleaseCheckTXMPreferencesInTheFileSupPreferencesMenuOrContactTxmusersMailingListMenuColonHelpSup, e.getMessage()));
 			System.out.println(TXMCoreMessages.bind(TXMUIMessages.startupFailedPleaseCheckTXMPreferencesInTheFileSupPreferencesMenuOrContactTxmusersMailingListMenuColonHelpSup, e.getMessage()));
 			Log.printStackTrace(e);
 		}
 	}
-
+	
 	public static void closeEmptyEditors(boolean closeOthersEditors) {
 		Log.fine("Closing empty editors..."); //$NON-NLS-1$
 		String REF = "org.eclipse.ui.internal.emptyEditorTab"; //$NON-NLS-1$
-
-		for (final IWorkbenchPage page : DeleteObject.getPages()) {
-			ArrayList<IEditorReference> editorRefsList = new ArrayList<IEditorReference>();
+		
+		for (final IWorkbenchPage page : SWTEditorsUtils.getPages()) {
+			ArrayList<IEditorReference> editorRefsList = new ArrayList<>();
 			for (IEditorReference editorref : page.getEditorReferences()) {
 				if (closeOthersEditors || editorref.getId().equals(REF)) {
-					Log.fine(TXMUIMessages.closingColon+editorref.getId());
+					Log.fine(TXMUIMessages.closingColon + editorref.getId());
 					editorRefsList.add(editorref);
 				}
 			}
-
+			
 			final IEditorReference[] editorRefs = editorRefsList.toArray(new IEditorReference[editorRefsList.size()]);
 			Display.getDefault().syncExec(new Runnable() {
-
+				
 				@Override
 				public void run() {
 					page.closeEditors(editorRefs, false);
@@ -281,143 +290,150 @@
 			});
 		}
 	}
-
+	
 	public static void printTXMVersion() {
-
+		
 		String version = null;
 		
 		// try finding build date from the p2 artifacts file in installation directory
 		String path = BundleUtils.getInstallDirectory();
 		if (path != null) {
 			File installDirectory = new File(path);
-			//println "installDirectory=$installDirectory"
+			// println "installDirectory=$installDirectory"
 			if (installDirectory.exists()) {
 				File artifacts = new File(installDirectory, "p2/org.eclipse.equinox.p2.core/cache/artifacts.xml");
-				//println "artifacts=$artifacts"
+				// println "artifacts=$artifacts"
 				if (artifacts.exists() && artifacts.canRead()) {
 					try {
 						String content = IOUtils.getText(artifacts);
 						String ARTIFACT = "<artifact classifier='binary' id='org.txm.rcp.app_root";
 						int start = content.indexOf(ARTIFACT);
-						//println "start=$start"
+						// println "start=$start"
 						if (start > 0) {
 							String VERSION = "version='";
-							int versionStart = content.indexOf(VERSION, start+ARTIFACT.length());
-							//println "versionStart=$versionStart"
+							int versionStart = content.indexOf(VERSION, start + ARTIFACT.length());
+							// println "versionStart=$versionStart"
 							if (versionStart > 0) {
-								int versionEnd = content.indexOf("'", versionStart+VERSION.length());
+								int versionEnd = content.indexOf("'", versionStart + VERSION.length());
 								if (versionEnd > 0) {
-									version = content.substring(versionStart+VERSION.length(), versionEnd);
-//									System.out.println("VERSION="+version);
+									version = content.substring(versionStart + VERSION.length(), versionEnd);
+									// System.out.println("VERSION="+version);
 								}
 							}
 						}
-					} catch (IOException e) {
+					}
+					catch (IOException e) {
 						// TODO Auto-generated catch block
 						e.printStackTrace();
 					}
 				}
 			}
 		}
-
-
+		
+		
 		if (version == null) {
-			version =  Activator.getDefault().getBundle().getVersion().toString();
+			version = Activator.getDefault().getBundle().getVersion().toString();
 		}
 		
 		String date = version.replaceAll("(.\\..\\..)\\.(....)(..)(..)(..)(..)", "$2-$3-$4 $5h$6"); //$NON-NLS-1$ //$NON-NLS-2$
 		
-		System.out.println(NLS.bind(TXMUIMessages.startingUpP0, 
-			Activator.getDefault().getBundle().getVersion().toString(), date));
+		System.out.println(NLS.bind(TXMUIMessages.startingUpP0,
+				Activator.getDefault().getBundle().getVersion().toString(), date));
 	}
-
+	
 	private void setPreferencesConfiguration() {
 		PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager();
-
+		
 		// Remove RCP Update preference page
 		if (!TBXPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER)) {
 			Log.fine(TXMUIMessages.removeUnusedEclipseRCPPreferencePage);
 			pm.remove("org.eclipse.equinox.internal.p2.ui.sdk.ProvisioningPreferencePage"); //$NON-NLS-1$
-
+			
 			// Remove the Team menu
 			pm.remove("org.eclipse.team.ui.TeamPreferences"); //$NON-NLS-1$
-
+			
 			// XML
-			//pm.remove("org.eclipse.wst.xml.ui.preferences.xml"); //$NON-NLS-1$
-
+			// pm.remove("org.eclipse.wst.xml.ui.preferences.xml"); //$NON-NLS-1$
+			
 			// Validation
-			//pm.remove("ValidationPreferencePage"); //$NON-NLS-1$
-
+			// pm.remove("ValidationPreferencePage"); //$NON-NLS-1$
+			
 			// Debug
-			//pm.remove("org.eclipse.debug.ui.DebugPreferencePage"); //$NON-NLS-1$
+			// pm.remove("org.eclipse.debug.ui.DebugPreferencePage"); //$NON-NLS-1$
 		}
 		// Remove RCP Web browser preference page
 		IPreferenceNode[] arr = pm.getRootSubNodes();
-		for(IPreferenceNode pn : arr){
-			//			System.out.println("Label:" + pn.getLabelText() + " ID:" + pn.getId()+" Type: "+pn.getClass());
-			//			for (IPreferenceNode subn : pn.getSubNodes()) {
-			//				System.out.println(" SLabel:" + subn.getLabelText() + " ID:" + subn.getId());
-			//			}
+		for (IPreferenceNode pn : arr) {
+			// System.out.println("Label:" + pn.getLabelText() + " ID:" + pn.getId()+" Type: "+pn.getClass());
+			// for (IPreferenceNode subn : pn.getSubNodes()) {
+			// System.out.println(" SLabel:" + subn.getLabelText() + " ID:" + subn.getId());
+			// }
 			if ("org.eclipse.ui.preferencePages.Workbench".equals(pn.getId())) { //$NON-NLS-1$
-				WorkbenchPreferenceNode pwn = (WorkbenchPreferenceNode)pn;
+				WorkbenchPreferenceNode pwn = (WorkbenchPreferenceNode) pn;
 				pwn.remove("org.eclipse.ui.browser.preferencePage"); //$NON-NLS-1$
 			}
 		}
 	}
-
+	
 	public void startUpdateLookUpJob(boolean updateCalledFromCommandLine) {
 		if (needToRestoreTXMHOME) return; // don't call for update for the first run of TXM
-
+		
 		try {
 			boolean doUpdate = TBXPreferences.getInstance().getBoolean(TBXPreferences.FETCH_UPDATES_AT_STARTUP);
 			if (!doUpdate) return;
 			//
-			//				this.syncExec(new Runnable() {
-			//					@Override
-			//					public void run() {
-
+			// this.syncExec(new Runnable() {
+			// @Override
+			// public void run() {
+			
 			try {
 				URL url = new URL("http://textometrie.ens-lyon.fr/dist/index.html"); //$NON-NLS-1$
 				Log.fine(TXMCoreMessages.bind("Testing if update site is available: {0}...", url)); //$NON-NLS-1$
 				InputStream data = url.openStream();
 				data.read();
 				data.close();
-			} catch(Exception e){
+			}
+			catch (Exception e) {
 				Log.warning(TXMCoreMessages.bind(TXMUIMessages.TXMCanNotFetchUpdatesP0, e));
 				doUpdate = false;
 				return;
 			}
-
+			
 			Log.info(TXMUIMessages.startingUpdateFetch);
-
+			
 			Display.getDefault().syncExec(new Runnable() {
+				
 				@Override
 				public void run() {
-					IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
+					IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class);
 					if (handlerService != null) {
 						try {
 							Event e = new Event();
 							e.display = Display.getDefault();
 							handlerService.executeCommand(TXMUpdateHandler.ID, e);
-						} catch (Exception e) {
+						}
+						catch (Exception e) {
 							System.out.println(TXMCoreMessages.bind(TXMUIMessages.errorWhileUpdatingTXMColon, e));
 							Log.printStackTrace(e);
 						}
-					} else {
+					}
+					else {
 						System.out.println(TXMUIMessages.errorWhileUpdatingTXMColonNoHandlerServiceFound);
 					}
 				}
 			});
-		} catch(Exception e) {
+		}
+		catch (Exception e) {
 			System.out.println(NLS.bind(TXMUIMessages.errorWhileFetchingUpdatesP0, e));
-		} catch(ThreadDeath td) {
+		}
+		catch (ThreadDeath td) {
 			System.out.println(TXMUIMessages.updateCanceled);
 		}
 	}
-
+	
 	public static boolean testTXMHOMEPreferenceAndDirectory() {
 		String path = Toolbox.getTxmHomePath();
-
+		
 		if (path == null || path.trim().equals("")) { //$NON-NLS-1$
 			Log.warning(TXMCoreMessages.bind(TXMUIMessages.TXMUserDirectoryIsNotSetP0PreferenceIsNotSet, TBXPreferences.USER_TXM_HOME));
 			return true;
@@ -426,53 +442,58 @@
 		if (!dir.exists()) {
 			Log.warning(TXMCoreMessages.bind(TXMUIMessages.TXMUserDirectoryIsSetToP0ButDoesNotExist, dir));
 			return true;
-		} else if (!dir.canWrite()) {
+		}
+		else if (!dir.canWrite()) {
 			Log.warning(TXMCoreMessages.bind(TXMUIMessages.TXMUserDirectoryIsSetToP0ButTXMCantWriteInThisDirectory, dir));
 			return true;
-		} else if (!dir.canExecute()) {
+		}
+		else if (!dir.canExecute()) {
 			Log.warning(TXMCoreMessages.bind(TXMUIMessages.TXMUserDirectoryIsSetToP0ButTXMCantCdInThisDirectory, dir));
 			return true;
 		}
-
+		
 		return false;
 	}
-
+	
 	public static boolean testTXMINSTALLPreferenceAndDirectory() {
-		//		TxmPreferences.dump();
+		// TxmPreferences.dump();
 		if (Toolbox.getInstallDirectory() == null) {
 			Log.warning(TXMCoreMessages.bind(TXMUIMessages.TXMInstallDirectoryIsNotSetP0PreferenceIsNotSet, TBXPreferences.INSTALL_DIR));
 			return true;
 		}
-
+		
 		File installdir = new File(Toolbox.getInstallDirectory().trim());
 		if (Toolbox.getInstallDirectory().equals("")) { //$NON-NLS-1$
 			Log.warning(TXMUIMessages.TXMInstallDirectoryIsSetToQuoteQuote);
 			return true;
-		} else if (!installdir.exists()) {
+		}
+		else if (!installdir.exists()) {
 			Log.warning(TXMCoreMessages.bind(TXMUIMessages.TXMInstallDirectoryIsSetToP0ButDoesNotExist, installdir));
 			return true;
-		} else if (!installdir.canRead()) {
+		}
+		else if (!installdir.canRead()) {
 			Log.warning(TXMCoreMessages.bind(TXMUIMessages.TXMInstallDirectoryIsSetToP0ButIsNotReadable, installdir));
 			return true;
-		} else if (!installdir.canExecute()) {
+		}
+		else if (!installdir.canExecute()) {
 			Log.warning(TXMCoreMessages.bind(TXMUIMessages.TXMInstallDirectoryIsSetToP0ButTXMCantCdInThisDirectory, installdir));
 			return true;
 		}
 		return false;
 	}
-
+	
 	/**
 	 * shutdown code.
 	 */
 	@Override
 	public void postShutdown() {
 		callPreStopScript();
-
+		
 		Toolbox.shutdown();
-
+		
 		callStopScript();
 	}
-
+	
 	/**
 	 * shutdown code.
 	 */
@@ -480,19 +501,20 @@
 	public boolean preShutdown() {
 		try {
 			closeEmptyEditors(true);
-		} catch(Exception e) {
+		}
+		catch (Exception e) {
 			e.printStackTrace();
 		}
 		
 		return continueShutDownForPersistedResults();
 	}
-
+	
 	private boolean continueShutDownForPersistedResults() {
 		if (Toolbox.workspace == null) return true; // nothing to do
-
+		
 		StringBuffer messages = new StringBuffer();
 		for (Project project : Toolbox.workspace.getProjects()) {
-			ArrayList<String> bugs = new ArrayList<String>();
+			ArrayList<String> bugs = new ArrayList<>();
 			for (TXMResult result : project.getDeepChildren()) {
 				if (result.mustBePersisted() && result.isAltered()) {
 					bugs.add(result.getSimpleName() + " (" + result.getResultType() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -502,52 +524,53 @@
 				messages.append("- " + project.getName() + ": " + bugs + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 			}
 		}
-
+		
 		if (messages.length() > 0) {
 			return MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "", NLS.bind(TXMUIMessages.warning_popup_editedResultsWillBelostP0, messages)); //$NON-NLS-1$
 		}
 		return true;
 	}
-
-	/* (non-Javadoc)
+	
+	/*
+	 * (non-Javadoc)
 	 * @see org.eclipse.ui.application.WorkbenchAdvisor#getInitialWindowPerspectiveId()
 	 */
 	@Override
 	public String getInitialWindowPerspectiveId() {
 		return TXMPerspective.ID;
 	}
-
+	
 	/**
 	 * initialize TXM log in console by redirecting stderr and stdout.
 	 */
 	private void InitializeLogger() {
 		IOConsole console = new IOConsole(TXMUIMessages.systemOutput, null);
-		ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] {console});
-
+		ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { console });
+		
 		// Enable or disable the outputs redirection to the RCP console according to the command line argument "-noredirection"
 		boolean outputsRedirection = true;
 		String[] args = Platform.getCommandLineArgs();
 		for (int i = 0; i < args.length; i++) {
-			if (args[i].equals("-noredirection"))	{ //$NON-NLS-1$
+			if (args[i].equals("-noredirection")) { //$NON-NLS-1$
 				outputsRedirection = false;
 				break;
 			}
 		}
-		if (outputsRedirection)	{
+		if (outputsRedirection) {
 			stream = console.newOutputStream();
 			streamInput = console.getInputStream();
-
+			
 			System.setOut(new PrintStream(stream));
 			System.setErr(new PrintStream(stream));
 			System.setIn(streamInput);
 		}
 		// System.out.println(Messages.ApplicationWorkbenchAdvisor_3);
 	}
-
+	
 	public void setConsoleOutputColor(Color newColor) {
 		if (stream != null) stream.setColor(newColor);
 	}
-
+	
 	/**
 	 * if INSTALLDIR preference is not set or empty, read the install.prefs file and set the
 	 *
@@ -566,250 +589,276 @@
 			boolean needTosetInstallPreference = testTXMINSTALLPreferenceAndDirectory();
 			// check if the install preference file has been loaded
 			if (needTosetInstallPreference) {
-
+				
 				installPreferenceRestored = false; // reset and finally set true if the process ended correctly
-
+				
 				try {
 					Display.getDefault().syncExec(new Runnable() {
+						
 						@Override
-						public void run() { OpenWelcomePage.openWelcomePage(); }
+						public void run() {
+							OpenWelcomePage.openWelcomePage();
+						}
 					});
-				} catch(Exception e2) {}
-
+				}
+				catch (Exception e2) {
+				}
+				
 				// set the install directory preference
 				String installpath = Platform.getInstallLocation().getURL().getFile(); // the TXM.exe file path
 				File installDirectory = new File(installpath);
-				//installDirectory = installDirectory.getCanonicalFile();
-
-				//TODO: ensure all preferences of install.prefs file are now stored in the default preferences
-				//				File preferenceFile = new File(installDirectory, "install.prefs"); //$NON-NLS-1$
-				//				if (preferenceFile.exists()) {
-				//					System.out.println(NLS.bind(RCPMessages.ApplicationWorkbenchAdvisor_25, preferenceFile));
-				//					if (Util.isWindows()) //NSIS has generated ISO-8859-1 preference file
-				//						TxmPreferences.importFromFile(preferenceFile, "ISO-8859-1", false); //$NON-NLS-1$
-				//					else
-				//						TxmPreferences.importFromFile(preferenceFile);
-				//				} else {
-				//					System.out.println("No installation preference file found in the installation directory: "+preferenceFile);
-				//					installPreferenceRestored = false;
-				//					return true;
-				//				}
-				//				// restore previous TreeTagger preferences
-				//				File previousPreferenceFile = new File(System.getProperty("java.io.tmpdir"),  //$NON-NLS-1$
-				//						"org.txm.rcp.prefs"); //$NON-NLS-1$
+				// installDirectory = installDirectory.getCanonicalFile();
+				
+				// TODO: ensure all preferences of install.prefs file are now stored in the default preferences
+				// File preferenceFile = new File(installDirectory, "install.prefs"); //$NON-NLS-1$
+				// if (preferenceFile.exists()) {
+				// System.out.println(NLS.bind(RCPMessages.ApplicationWorkbenchAdvisor_25, preferenceFile));
+				// if (Util.isWindows()) //NSIS has generated ISO-8859-1 preference file
+				// TxmPreferences.importFromFile(preferenceFile, "ISO-8859-1", false); //$NON-NLS-1$
+				// else
+				// TxmPreferences.importFromFile(preferenceFile);
+				// } else {
+				// System.out.println("No installation preference file found in the installation directory: "+preferenceFile);
+				// installPreferenceRestored = false;
+				// return true;
+				// }
+				// // restore previous TreeTagger preferences
+				// File previousPreferenceFile = new File(System.getProperty("java.io.tmpdir"), //$NON-NLS-1$
+				// "org.txm.rcp.prefs"); //$NON-NLS-1$
 				//
-				//				if (System.getProperty("os.name").indexOf("Mac") >= 0) { //$NON-NLS-1$ //$NON-NLS-2$
-				//					previousPreferenceFile = new File("/tmp/org.txm.rcp.prefs"); //$NON-NLS-1$
-				//				}
+				// if (System.getProperty("os.name").indexOf("Mac") >= 0) { //$NON-NLS-1$ //$NON-NLS-2$
+				// previousPreferenceFile = new File("/tmp/org.txm.rcp.prefs"); //$NON-NLS-1$
+				// }
 				//
-				//				if (previousPreferenceFile.exists()) {
-				//					System.out.println("Restoring preferences (from "+previousPreferenceFile+").");
-				//					Properties previousProperties = new Properties();
-				//					BufferedReader reader = IOUtils.getReader(previousPreferenceFile, "ISO-8859-1");
-				//					previousProperties.load(reader);
-				//					String [] keys= {TBXPreferences.TREETAGGER_INSTALL_PATH,
-				//							TBXPreferences.TREETAGGER_MODELS_PATH,
-				//							TBXPreferences.TREETAGGER_OPTIONS};
-				//					for (String k : keys) {
-				//						if (previousProperties.getProperty(k) != null) {
-				//							TxmPreferences.set(k, previousProperties.getProperty(k));
-				//						}
-				//					}
-				//				}
-
+				// if (previousPreferenceFile.exists()) {
+				// System.out.println("Restoring preferences (from "+previousPreferenceFile+").");
+				// Properties previousProperties = new Properties();
+				// BufferedReader reader = IOUtils.getReader(previousPreferenceFile, "ISO-8859-1");
+				// previousProperties.load(reader);
+				// String [] keys= {TBXPreferences.TREETAGGER_INSTALL_PATH,
+				// TBXPreferences.TREETAGGER_MODELS_PATH,
+				// TBXPreferences.TREETAGGER_OPTIONS};
+				// for (String k : keys) {
+				// if (previousProperties.getProperty(k) != null) {
+				// TxmPreferences.set(k, previousProperties.getProperty(k));
+				// }
+				// }
+				// }
+				
 				installPreferenceRestored = true;
-
+				
 				if (installDirectory == null || !installDirectory.exists()) {
 					Log.severe(TXMUIMessages.errorTheProvidedInstallDirectoryDoesNotExistAborting);
 					return false;
 				}
-
+				
 				TBXPreferences.getInstance().put(TBXPreferences.INSTALL_DIR, installDirectory.getAbsolutePath());
 				TBXPreferences.getInstance().flush();
 				return true;
 			}
-		} catch (Exception e) {
+		}
+		catch (Exception e) {
 			Log.severe(TXMCoreMessages.bind(TXMUIMessages.couldNotReadInstallPreferencesFile, e));
 			Log.printStackTrace(e);
 			return false;
 		}
 		return true;
 	}
-
+	
 	boolean go = false;
+	
 	File backup;
+	
 	File oldbackup;
+	
 	File errorbackup;
+	
 	File corporaDir;
+	
 	/**
 	 * if TXMHOME path is not set or wrong
-	 *  - set default theme
-	 *  - restore old corpora
-	 *  - creates TXMHOME and copy "scripts", "samples" directories from TXMINSTALLDIR and mkdirs workspaces, registry,
-	 *    clipboard plus an empty Workspace (TXMObject) is created then load the sample corpora.
+	 * - set default theme
+	 * - restore old corpora
+	 * - creates TXMHOME and copy "scripts", "samples" directories from TXMINSTALLDIR and mkdirs workspaces, registry,
+	 * clipboard plus an empty Workspace (TXMObject) is created then load the sample corpora.
 	 *
 	 *
 	 */
 	private static boolean needToRestoreTXMHOME;
+	
 	public static boolean getWasFirstLaunch() {
 		return needToRestoreTXMHOME;
 	}
-
+	
 	File txmhomedir = null;
+	
 	File installDirectory = null;
+	
 	private Handler severeDialobBoxHandler = new Handler() {
-
+		
 		@Override
 		public void publish(final LogRecord record) {
-			//System.out.println("severeDialobBoxHandler.publish()");
+			// System.out.println("severeDialobBoxHandler.publish()");
 			boolean showSevereDialobBox = RCPPreferences.getInstance().getBoolean(RCPPreferences.SHOW_SEVERE_DIALOG);
 			if (showSevereDialobBox) {
 				if (record.getLevel() != Level.SEVERE) return;
-
+				
 				final IWorkbench w = PlatformUI.getWorkbench();
 				if (w == null) {
 					System.out.println("no workbench"); //$NON-NLS-1$
 					return;
 				}
-
+				
 				w.getDisplay().syncExec(new Runnable() {
+					
 					@Override
 					public void run() {
 						try {
 							IWorkbenchWindow aww = w.getActiveWorkbenchWindow();
-							if (aww == null) {System.out.println(TXMUIMessages.noActiveWorkbenchWindow);return;}
+							if (aww == null) {
+								System.out.println(TXMUIMessages.noActiveWorkbenchWindow);
+								return;
+							}
 							IWorkbenchPage page = aww.getActivePage();
-							if (page == null) {System.out.println(TXMUIMessages.noActivePage);return;}
+							if (page == null) {
+								System.out.println(TXMUIMessages.noActivePage);
+								return;
+							}
 							IViewPart view = page.findView("org.eclipse.pde.runtime.LogView"); //$NON-NLS-1$
 							if (view == null) {
 								view = page.showView("org.eclipse.pde.runtime.LogView"); //$NON-NLS-1$
 							}
-						} catch (Exception e1) {
-							System.out.println(TXMUIMessages.partInitializationErrorColon+e1);
+						}
+						catch (Exception e1) {
+							System.out.println(TXMUIMessages.partInitializationErrorColon + e1);
 							e1.printStackTrace();
 							return;
 						}
 					}
 				});
-
+				
 				IStatus s = new Status(Status.ERROR, Application.PLUGIN_ID, Status.OK, record.getMessage(), null);
 				StatusManager.getManager().handle(s, StatusManager.LOG);
 			}
 		}
-
+		
 		@Override
-		public void flush() { }
-
+		public void flush() {}
+		
 		@Override
-		public void close() throws SecurityException { }
+		public void close() throws SecurityException {}
 	};
+	
 	/**
 	 * internal variable to know if the txm home directory has been created
 	 */
 	private boolean txmHomeRestored;
-
+	
 	{
 		Log.addHandler(severeDialobBoxHandler);
 		severeDialobBoxHandler.setLevel(Level.SEVERE);
 	}
-
+	
 	private boolean checkTXMHOME(JobHandler jobHandler, IProgressMonitor monitor) {
 		txmhomedir = null;
 		installDirectory = null;
-
+		
 		// check if TXMHOME of the user is set and exists
 		needToRestoreTXMHOME = testTXMHOMEPreferenceAndDirectory();
-		Log.fine("needToRestoreTXMHOME="+needToRestoreTXMHOME+" installPreferenceRestored="+installPreferenceRestored); //$NON-NLS-1$ //$NON-NLS-2$
+		Log.fine("needToRestoreTXMHOME=" + needToRestoreTXMHOME + " installPreferenceRestored=" + installPreferenceRestored); //$NON-NLS-1$ //$NON-NLS-2$
 		if (needToRestoreTXMHOME || installPreferenceRestored) {
-
+			
 			System.out.println(TXMUIMessages.creatingTXMUserWorkingDirectory);
-
+			
 			try {
 				Log.info(NLS.bind(TXMUIMessages.installPathColonP0, Toolbox.getInstallDirectory()));
-
+				
 				txmhomedir = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getCanonicalFile();
 				txmhomedir.mkdirs(); // creates the directory if needed
-
+				
 				txmhomedir.mkdirs(); // creates the directory if needed
-
+				
 				if (!txmhomedir.exists()) {
 					Log.severe(TXMCoreMessages.bind(TXMUIMessages.errorTheProvidedTXMHOMEDirectoryDoesNotExistsP0Aborting, txmhomedir));
 					return false;
 				}
-
+				
 				// save preference if USER_TXM_HOME has changed
 				TBXPreferences.getInstance().put(TBXPreferences.USER_TXM_HOME, txmhomedir.getAbsolutePath());
 				DefaultScope.INSTANCE.getNode("org.eclipse.ui.workbench").putBoolean("RUN_IN_BACKGROUND", false); //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-2$
 				DefaultScope.INSTANCE.getNode("org.eclipse.ui.workbench").flush(); //$NON-NLS-1$
 				TBXPreferences.getInstance().flush();
-				//TXMPreferences.saveAll();
-
+				// TXMPreferences.saveAll();
+				
 				Log.info(TXMCoreMessages.bind(TXMUIMessages.TXMUserDirectoryIsSetToP0, txmhomedir));
-
+				
 				txmHomeRestored = true;
-			} catch (Exception e) {
+			}
+			catch (Exception e) {
 				org.txm.utils.logger.Log.printStackTrace(e);
 				System.out.println(TXMCoreMessages.bind(TXMUIMessages.failedToBackupExistingCorporaColon, e.getLocalizedMessage()));
 				Log.severe(TXMCoreMessages.bind(TXMUIMessages.failedToBackupExistingCorporaColon, e.getLocalizedMessage()));
 				return false;
 			}
-
-
-
-
-
+			
+			
+			
+			
+			
 		} // end if
-
+		
 		return true;
 	}
-
+	
 	/**
 	 * Install the sample corpora and previous TXM version corpora in TXM corpora directory
+	 * 
 	 * @param monitor
 	 */
 	private void installCorporaDirectory(IProgressMonitor monitor) {
-		//		if (org.eclipse.core.runtime.Platform.inDevelopmentMode()) {
-		//			System.out.println("DEV MODE: no corpus restored!");
-		//			return; // dev mode
-		//		}
+		// if (org.eclipse.core.runtime.Platform.inDevelopmentMode()) {
+		// System.out.println("DEV MODE: no corpus restored!");
+		// return; // dev mode
+		// }
 		monitor.setTaskName(TXMUIMessages.restoringCorpora);
 		String installdirpath = Toolbox.getInstallDirectory();
 		File sampleCorporaDirectory = new File(installdirpath, "samples"); //$NON-NLS-1$
-
+		
 		if (txmhomedir == null) {
 			txmhomedir = new File(Toolbox.getTxmHomePath().trim());
 		}
 		corporaDir = new File(txmhomedir, "corpora"); //$NON-NLS-1$
 		corporaDir.mkdir();
-
+		
 		File previousCorporaDirectory = new File(System.getProperty("user.home"), "TXM/corpora"); //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-2$
-
+		
 		Version v = Activator.getDefault().getBundle().getVersion();
-		String vv = v.getMajor()+"."+v.getMinor()+"."+v.getMicro(); //$NON-NLS-1$ //$NON-NLS-2$  $NON-NLS-2$
-		String SAMPLES = "1. "+TXMUIMessages.bind(TXMUIMessages.sampleCorporaOfCurrentTXMP0, vv);//$NON-NLS-1$
-		String V080 = "2. "+TXMUIMessages.bind(TXMUIMessages.corporaOfPreviousTXMP0, vv);//$NON-NLS-1$
-		String V079 = "3. "+TXMUIMessages.bind(TXMUIMessages.corporaOfPreviousTXMP0, "0.7.9"); //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-2$
-		String OTHER = "4. "+TXMUIMessages.selectAnotherTXMCorporaToRestore;//$NON-NLS-1$
-
-
-		final ArrayList<Object> corporaDirs = new ArrayList<Object>();
+		String vv = v.getMajor() + "." + v.getMinor() + "." + v.getMicro(); //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-2$
+		String SAMPLES = "1. " + TXMUIMessages.bind(TXMUIMessages.sampleCorporaOfCurrentTXMP0, vv);//$NON-NLS-1$
+		String V080 = "2. " + TXMUIMessages.bind(TXMUIMessages.corporaOfPreviousTXMP0, vv);//$NON-NLS-1$
+		String V079 = "3. " + TXMUIMessages.bind(TXMUIMessages.corporaOfPreviousTXMP0, "0.7.9"); //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-2$
+		String OTHER = "4. " + TXMUIMessages.selectAnotherTXMCorporaToRestore;//$NON-NLS-1$
+		
+		
+		final ArrayList<Object> corporaDirs = new ArrayList<>();
 		corporaDirs.add(SAMPLES);
 		corporaDirs.add(V080);
 		corporaDirs.add(V079);
 		corporaDirs.add(OTHER);
-
-		final ArrayList<Object> initialCorporaDirs = new ArrayList<Object>();
+		
+		final ArrayList<Object> initialCorporaDirs = new ArrayList<>();
 		initialCorporaDirs.add(SAMPLES);
 		initialCorporaDirs.add(V080);
 		initialCorporaDirs.add(V079);
-
-
+		
+		
 		Display.getDefault().syncExec(new Runnable() {
+			
 			@Override
 			public void run() {
 				Display display = Display.getDefault();
 				Shell shell = display.getActiveShell();
-				ListSelectionDialog dialog = new ListSelectionDialog(shell, corporaDirs, 
+				ListSelectionDialog dialog = new ListSelectionDialog(shell, corporaDirs,
 						new ArrayContentProvider(), new LabelProvider(), TXMUIMessages.corporaWillBeRestoredInTheFollowingOrderCorporaAlreadyRestoredWillNotBeReplaced);
 				dialog.setTitle(TXMUIMessages.selectThecorporaSetsToRestore);
 				dialog.setInitialElementSelections(initialCorporaDirs);
@@ -817,14 +866,15 @@
 					corporaDirs.clear();
 					List<Object> selection = Arrays.asList(dialog.getResult());
 					corporaDirs.addAll(selection);
-				} else {
+				}
+				else {
 					corporaDirs.clear();
 				}
 			}
 		});
-
+		
 		// move previous TXM 0.8.0 corpora
-		File backupDir = new File(corporaDir.getAbsolutePath()+"-previous"); //$NON-NLS-1$
+		File backupDir = new File(corporaDir.getAbsolutePath() + "-previous"); //$NON-NLS-1$
 		if (corporaDir.exists()) {
 			backupDir.mkdirs();
 			for (File dir : corporaDir.listFiles(IOUtils.HIDDENFILE_FILTER)) {
@@ -833,47 +883,51 @@
 				dir.renameTo(bdir);
 			}
 		}
-
+		
 		// load TXM-0.8.0 sample corpora (from the install directory)
 		if (corporaDirs.contains(SAMPLES) && sampleCorporaDirectory.exists()) {
-
+			
 			Log.info(TXMUIMessages.installingSampleCorpus);
-
+			
 			JobHandler job = LoadBinaryCorporaDirectory.loadBinaryCorpusFromCorporaDirectory(sampleCorporaDirectory, false, true, false);
 			try {
 				job.join();
-			} catch (InterruptedException e) {
+			}
+			catch (InterruptedException e) {
 				// TODO Auto-generated catch block
 				e.printStackTrace();
 			}
 		}
-
+		
 		// TXM-0.8.0 previous installation corpora
 		if (corporaDirs.contains(V080) && backupDir.listFiles(IOUtils.HIDDENFILE_FILTER).length > 0) { // not a new install, restore corpus from the corpora-previous directory
 			Log.info(NLS.bind(TXMUIMessages.installingPreviousCorpusFromP0, "0.8.0", corporaDir)); //$NON-NLS-1$
 			JobHandler job = LoadBinaryCorporaDirectory.loadBinaryCorpusFromCorporaDirectory(backupDir, false, false, true);
 			try {
 				job.join();
-			} catch (InterruptedException e) {
+			}
+			catch (InterruptedException e) {
 				e.printStackTrace();
 			}
 		}
-
+		
 		// TXM previous installation corpora
 		if (corporaDirs.contains(V079) && previousCorporaDirectory.exists()) { // new installation (empty corpora directory)
 			Log.info(NLS.bind(TXMUIMessages.installingPreviousCorpusFromP0, "0.7.9", previousCorporaDirectory)); //$NON-NLS-1$
 			JobHandler job = LoadBinaryCorporaDirectory.loadBinaryCorpusFromCorporaDirectory(previousCorporaDirectory, false, false, true);
 			try {
 				job.join();
-			} catch (InterruptedException e) {
+			}
+			catch (InterruptedException e) {
 				e.printStackTrace();
 			}
 		}
-
+		
 		// TXM previous installation corpora
 		if (corporaDirs.contains(OTHER)) { // new installation (empty corpora directory)
-			final HashMap<String, String> bindings = new HashMap<String, String>();
+			final HashMap<String, String> bindings = new HashMap<>();
 			Display.getDefault().syncExec(new Runnable() {
+				
 				@Override
 				public void run() {
 					Display display = Display.getDefault();
@@ -881,7 +935,7 @@
 					DirectoryDialog dialog = new DirectoryDialog(shell);
 					String path = dialog.open();
 					if (path == null) return;
-
+					
 					bindings.put("path", path); //$NON-NLS-1$
 				}
 			});
@@ -892,25 +946,28 @@
 					JobHandler job = LoadBinaryCorporaDirectory.loadBinaryCorpusFromCorporaDirectory(dir, true, true, true);
 					try {
 						job.join();
-					} catch (InterruptedException e) {
+					}
+					catch (InterruptedException e) {
 						e.printStackTrace();
 					}
 				}
 			}
 		}
-
+		
 		Display.getDefault().syncExec(new Runnable() {
+			
 			@Override
 			public void run() {
 				RestartTXM.reloadViews();
 			}
 		});
-
+		
 		monitor.setTaskName(""); //$NON-NLS-1$
 	}
-
+	
 	/**
 	 * Executes the specified Groovy script file.
+	 * 
 	 * @param script
 	 */
 	private void callGroovyScript(File script) {
@@ -919,41 +976,41 @@
 				ExecuteGroovyScript.executeScript(script.getAbsolutePath(), null, null, true, ""); //$NON-NLS-1$
 			}
 		}
-		catch(Exception e) {
+		catch (Exception e) {
 			Log.severe(TXMCoreMessages.bind(TXMUIMessages.failedToExecuteTheP0ScriptColonP1, script, e));
 			Log.printStackTrace(e);
 		}
 	}
-
-
+	
+	
 	/**
 	 * Called just before the Toolbox is initialized
 	 */
 	private void callPreStartScript() {
 		this.callGroovyScript(new File(Toolbox.getTxmHomePath(), "scripts/groovy/user/prestart.groovy")); //$NON-NLS-1$
 	}
-
+	
 	/**
 	 * Called just after Toolbox is initialized
 	 */
 	private void callStartScript() {
 		this.callGroovyScript(new File(Toolbox.getTxmHomePath(), "scripts/groovy/user/start.groovy")); //$NON-NLS-1$
 	}
-
+	
 	/**
 	 * Called just before Toolbox is stop call
 	 */
 	private void callPreStopScript() {
 		this.callGroovyScript(new File(Toolbox.getTxmHomePath(), "scripts/groovy/user/prestop.groovy")); //$NON-NLS-1$
 	}
-
+	
 	/**
 	 * Called just after Toolbox is stop call
 	 */
 	private void callStopScript() {
 		this.callGroovyScript(new File(Toolbox.getTxmHomePath(), "scripts/groovy/user/stop.groovy")); //$NON-NLS-1$
 	}
-
+	
 	/**
 	 * after TXMHOME AND INSTALLDIR are ok, we can start the Toolbox
 	 * <p>
@@ -970,90 +1027,92 @@
 	 * @throws Exception
 	 */
 	private boolean initializeUI(final JobHandler jobHandler) throws Exception {
-
+		
 		// Fix the freeze at splash screen on Mac OS X/Cocoa because of a deadlock between AWT/SWT threads (bug #894)
 		Display.getDefault().syncExec(new Runnable() {
+			
 			@Override
 			public void run() {
 				try {
 					printTXMVersion();
-
+					
 					jobHandler.setTaskName(TXMUIMessages.setDefaultTheme);
 					setDefaultTheme();
-
+					
 					// CLOSE Empty&Error editors
 					jobHandler.setTaskName(TXMUIMessages.closingEmptyEditors);
 					closeEmptyEditors(false);
-
+					
 					// remove some preference pages
-					setPreferencesConfiguration(); 
-
+					setPreferencesConfiguration();
+					
 					new ProgressMonitorDialog(Display.getDefault().getActiveShell()).run(true, true, new IRunnableWithProgress() {
-
+						
 						@Override
 						public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
-
+							
 							if (!Toolbox.isInitialized()) {
 								try {
 									monitor.worked(1);
-
+									
 									monitor.setTaskName(TXMUIMessages.callingGroovyPrestartScript);
 									callPreStartScript();
 									monitor.worked(20);
-
+									
 									monitor.setTaskName(TXMUIMessages.initializingToolboxEnginesAndCorpora);
 									if (Toolbox.initialize(TBXPreferences.class, monitor)) {
-										//StatusLine.setMessage(TXMUIMessages.ready);
+										// StatusLine.setMessage(TXMUIMessages.ready);
 									}
 									else {
 										StatusLine.setMessage(TXMUIMessages.startupFailedPleaseCheckTXMPreferencesInTheFileSupPreferencesMenuOrContactTxmusersMailingListMenuColonHelpSup);
 										Log.severe(TXMUIMessages.startupFailedPleaseCheckTXMPreferencesInTheFileSupPreferencesMenuOrContactTxmusersMailingListMenuColonHelpSup);
-
+										
 										monitor.done();
 										return;
 									}
 									monitor.worked(20);
-
+									
 									monitor.setTaskName(TXMUIMessages.callingGroovyStartScript);
 									callStartScript();
 									monitor.worked(20);
-
+									
 									// restore corpora if TXMHOME has been created
 									if (txmHomeRestored) {
 										installCorporaDirectory(monitor);
-
+										
 										Toolbox.workspace.saveParameters(true);
 										ResourcesPlugin.getWorkspace().save(true, null);
 									}
 									monitor.worked(20);
-
+									
 									jobHandler.setTaskName(TXMUIMessages.toolboxReady);
-								} catch (Exception e) {
+								}
+								catch (Exception e) {
 									// TODO Auto-generated catch block
 									e.printStackTrace();
 								}
 							}
-
-							monitor.done(); 
+							
+							monitor.done();
 						}
-
-
+						
+						
 					});
-
+					
 					Log.fine(TXMUIMessages.loadingViews);
 					RestartTXM.reloadViews(); // reload views
-
-
+					
+					
 				}
-				catch(Exception e) {
+				catch (Exception e) {
 					Log.severe(TXMCoreMessages.bind(TXMUIMessages.errorDuringUIInitializationP0, e.getLocalizedMessage()));
 					e.printStackTrace();
 				}
 			}
 		});
-
-		jobHandler.setTaskName(""); //$NON-NLS-1$s
-		//TxmPreferences.dump();
+		
+		jobHandler.setTaskName(""); //$NON-NLS-1$ s
+		// TxmPreferences.dump();
 		return true;
 	}
-}
\ No newline at end of file
+}
