Index: tmp/org.txm.statsengine.r.rcp/src/org/txm/rcp/commands/R/ShowSvgHelp.java
===================================================================
--- tmp/org.txm.statsengine.r.rcp/src/org/txm/rcp/commands/R/ShowSvgHelp.java	(revision 2979)
+++ tmp/org.txm.statsengine.r.rcp/src/org/txm/rcp/commands/R/ShowSvgHelp.java	(revision 2980)
@@ -32,34 +32,37 @@
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
 import org.txm.rcp.messages.TXMUIMessages;
+
 // TODO: Auto-generated Javadoc
 /**
  * The Class ShowSvgHelp.
  */
 public class ShowSvgHelp extends AbstractHandler {
-
-	/* (non-Javadoc)
+	
+	/*
+	 * (non-Javadoc)
 	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 	 */
 	@Override
 	public Object execute(ExecutionEvent event) throws ExecutionException {
 		
-		MessageDialog.openInformation(new Shell(), TXMUIMessages.graphicsKeyboardShortcuts, 
+		MessageDialog.openInformation(HandlerUtil.getActiveShell(event), TXMUIMessages.graphicsKeyboardShortcuts,
 				TXMUIMessages.panColonRightMousePlusDrag +
-				TXMUIMessages.zoomInAmpoutColonMouseWheelORShiftPlusRightMousePlusDrag +
-				TXMUIMessages.zoomToSelectionColonCtrlPlusLeftMousePlusdrag +
-				TXMUIMessages.EMPTY +
-				TXMUIMessages.resetTheViewColonF5);
+						TXMUIMessages.zoomInAmpoutColonMouseWheelORShiftPlusRightMousePlusDrag +
+						TXMUIMessages.zoomToSelectionColonCtrlPlusLeftMousePlusdrag +
+						TXMUIMessages.EMPTY +
+						TXMUIMessages.resetTheViewColonF5);
 		return event;
 		
 		/*
 		 * <li>Faire glisser : Shif t+Left Mouse+drag</li>
-<li>Zoom avant et arrière : Shif t+Right Mouse+drag</li>
-<li>Zoom par sélection : Ctrl+Left Mouse+drag</li>
-<li>Rotation : Ctrl+Right Mouse+drag</li>
-<li>Retour à la vue initiale : F5</li>
+		 * <li>Zoom avant et arrière : Shif t+Right Mouse+drag</li>
+		 * <li>Zoom par sélection : Ctrl+Left Mouse+drag</li>
+		 * <li>Rotation : Ctrl+Right Mouse+drag</li>
+		 * <li>Retour à la vue initiale : F5</li>
 		 */
 	}
-
-}
\ No newline at end of file
+	
+}
Index: tmp/org.txm.statsengine.r.rcp/src/org/txm/statsengine/r/rcp/handlers/CheckRPackages.java
===================================================================
--- tmp/org.txm.statsengine.r.rcp/src/org/txm/statsengine/r/rcp/handlers/CheckRPackages.java	(revision 2979)
+++ tmp/org.txm.statsengine.r.rcp/src/org/txm/statsengine/r/rcp/handlers/CheckRPackages.java	(revision 2980)
@@ -10,6 +10,7 @@
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.util.Util;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.rosuda.REngine.REXP;
 import org.rosuda.REngine.REXPInteger;
@@ -19,20 +20,23 @@
 import org.txm.core.engines.EngineType;
 import org.txm.core.messages.TXMCoreMessages;
 import org.txm.rcp.handlers.BaseAbstractHandler;
+import org.txm.rcp.utils.SWTUtils;
 import org.txm.statsengine.r.core.RWorkspace;
 import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
 import org.txm.statsengine.r.rcp.messages.RUIMessages;
 import org.txm.utils.logger.Log;
 
 public class CheckRPackages extends BaseAbstractHandler {
-
+	
 	public static HashMap<String, String> packages;
+	
 	public static HashMap<String, String> errorMessages;
+	
 	public static HashMap<String, List<String>> depends;
 	{
-		packages = new HashMap<String,String>();
-		errorMessages = new HashMap<String,String>();
-		depends = new HashMap<String,List<String>>();
+		packages = new HashMap<>();
+		errorMessages = new HashMap<>();
+		depends = new HashMap<>();
 		
 		packages.put("textometry", "0.1.4"); //$NON-NLS-1$ //$NON-NLS-2$
 		packages.put("FactoMineR", "1.24"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -50,40 +54,41 @@
 		errorMessages.put("textometry", RUIMessages.tXMCouldNotLoadTheTextometryRPackageTheCooccurenceSpecificityAndProgressionCommandsWontBeAvailable); //$NON-NLS-1$
 		errorMessages.put("FactoMineR", RUIMessages.tXMCouldNotLoadTheFactoMineRRPackageTheCorrespondanceAnalysisClassificationCommandsWontBeAvailable); //$NON-NLS-1$
 	}
-
+	
 	@Override
 	public Object execute(ExecutionEvent event) throws ExecutionException {
 		
-		if(!super.checkStatsEngine())	{
+		if (!super.checkStatsEngine()) {
 			return null;
 		}
 		
-		Shell shell = new Shell();
+		Shell shell = SWTUtils.getShell(event);
 		if (check()) {
 			MessageDialog.openInformation(shell, RUIMessages.rPackageDiagnostic, RUIMessages.necessaryPackagesAreReady);
-		} else {
+		}
+		else {
 			MessageDialog.openError(shell, RUIMessages.rPackageDiagnostic, RUIMessages.somePackagesAreMissingSeeConsoleForDetails);
 		}
 		return null;
 	}
-
+	
 	public static String buildVersion(REXPInteger rExpInteger) throws REXPMismatchException {
 		StringBuffer buff = new StringBuffer(""); //$NON-NLS-1$
 		
-		//RList list = rExpInteger.asList();
+		// RList list = rExpInteger.asList();
 		int[] ints = rExpInteger.asIntegers();
-		for (int i = 0 ; i < rExpInteger.length() ;i++) {
-			buff.append("."+ints[i]); //$NON-NLS-1$
+		for (int i = 0; i < rExpInteger.length(); i++) {
+			buff.append("." + ints[i]); //$NON-NLS-1$
 		}
 		if (buff.length() > 0)
 			return buff.substring(1); // first "."
-
+		
 		return ""; //$NON-NLS-1$
 	}
-
+	
 	public static boolean check() {
 		System.out.print(RUIMessages.checkingRPackages);
-		//Log.info("Checking R packages...");
+		// Log.info("Checking R packages...");
 		
 		String method = "internal"; // default method is internal //$NON-NLS-1$
 		if (Util.isMac()) method = "curl"; //$NON-NLS-1$
@@ -94,58 +99,88 @@
 			RWorkspace rw = null;
 			try {
 				rw = RWorkspace.getRWorkspaceInstance();
-			} catch (RWorkspaceException e) {
+			}
+			catch (RWorkspaceException e) {
+				Log.warning(TXMCoreMessages.bind(RUIMessages.anErrorOccuredWhileGettingRWorkspaceInsanceColon, e));
 				Log.printStackTrace(e);
-				System.out.println(TXMCoreMessages.bind(RUIMessages.anErrorOccuredWhileGettingRWorkspaceInsanceColon, e));
 				return false;
 			}
+			
 			for (String p : packages.keySet()) {
-				//String v = packages.get(p);
-				//String error = errorMessages.get(p);
+				// String v = packages.get(p);
+				// String error = errorMessages.get(p);
 				try {
-					rw.eval("library(\""+p+"\")"); //$NON-NLS-1$ //$NON-NLS-2$
-				} catch (Exception e) {
+					rw.eval("installed.packages(\"" + p + "\")"); //$NON-NLS-1$ //$NON-NLS-2$
+				}
+				catch (Exception e) {
 					Log.printStackTrace(e);
 					Log.severe(TXMCoreMessages.bind("{0} package not installed. Error={1}.", p, e));
 					ret = false;
 				}
+				
 				if (ret) { // check the version and install if possible
 					try {
-						String currentVersion = getVersion(rw,p);
-						ret = updateIfNecessary(rw, p, currentVersion);				
-					} catch (Exception e) {
+						String currentVersion = getVersion(rw, p);
+						ret = updateIfNecessary(rw, p, currentVersion);
+					}
+					catch (Exception e) {
 						Log.printStackTrace(e);
-						System.out.println(TXMCoreMessages.bind("Error while testing package: {0}.", e));
+						Log.warning(TXMCoreMessages.bind("Error while testing package: {0}.", e));
 						ret = false;
 					}
-				} else { // package is not present, install it
+				}
+				else { // package is not present, try installing it
 					try {
 						Log.info(TXMCoreMessages.bind("The '{0}' package is not installed. Trying to install it now...", p));
 						
-						try {rw.eval("detach(\"package:"+p+"\", character.only = TRUE)");} catch(Exception tmpE){} // unload package to be able to reinstall it //$NON-NLS-1$ //$NON-NLS-2$
+						try {
+							rw.eval("detach(\"package:" + p + "\", character.only = TRUE)"); //$NON-NLS-1$ //$NON-NLS-2$
+						}
+						catch (Exception tmpE) {
+						} // unload package to be able to reinstall it
 						
-						rw.eval("install.packages(\""+p+"\", dependencies=TRUE, method=\""+method+"\", repos=\"http://cran.rstudio.com\");"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+						// install depends if any
+						if (depends.containsKey(p)) {
+							for (String dep : depends.get(p)) {
+								try {
+									Log.info(TXMCoreMessages.bind("Trying to install the {0} dependency of {1} now...", dep, p));
+									rw.eval("install.packages(\"" + dep + "\", dependencies=TRUE, method=\"" + method + "\", repos=\"http://cran.rstudio.com\");"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+								}
+								catch (Exception e) {
+									Log.warning(TXMCoreMessages.bind("Error while installing R dependency of {0} : {1} : {2}", p, dep, e));
+									Log.printStackTrace(e);
+									ret = false;
+								}
+							}
+						}
 						
-						try {
-							rw.eval("library(\""+p+"\")"); //$NON-NLS-1$ //$NON-NLS-2$
+						// install the package itself
+						rw.eval("install.packages(\"" + p + "\", dependencies=TRUE, method=\"" + method + "\", repos=\"http://cran.rstudio.com\");"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+						
+						try { // now try loading the package
+							rw.eval("library(\"" + p + "\")"); //$NON-NLS-1$ //$NON-NLS-2$
 							Log.info(TXMCoreMessages.bind(RUIMessages.installedSuccessfully, p));
-						} catch (Exception e) {
+						}
+						catch (Exception e) {
 							Log.printStackTrace(e);
-							System.out.println(TXMCoreMessages.bind("The '{0}' package was not installed. Please install it manually:\n * Run R\n * and execute 'install.packages(\"{1}\"')", p, p));
+							Log.warning(TXMCoreMessages.bind("The '{0}' package was not installed correctly. Please install it manually:\n * Run R\n * and execute 'install.packages(\"{1}\"')", p, p));
 							ret = false;
 						}
-					} catch (Exception e) {
+					}
+					catch (Exception e) {
 						Log.printStackTrace(e);
 						System.out.println(TXMCoreMessages.bind(RUIMessages.errorWhileInstallingPackageColon, e));
 						ret = false;
 					}
 				}
 			}
-		} else {
+		}
+		else {
 			System.out.println(RUIMessages.theRStatEngineIsNotRunningTryingToReinstallThePackagesRServeFactoMineRTextometry);
 			try {
 				installRPAckagesViaRscript();
-			} catch(Exception e) {
+			}
+			catch (Exception e) {
 				System.out.println(RUIMessages.tXMCouldNotReinstallRPackagesPleaseDoItManuallySeeManual);
 			}
 			ret = false;
@@ -160,37 +195,42 @@
 		String cmd = ""; //$NON-NLS-1$
 		String installPath = Toolbox.getInstallDirectory();
 		if (Util.isMac() || Util.isLinux()) {
-			cmd = "R --no-save < \""+installPath+"/R/rlibs.R\""; //$NON-NLS-1$ //$NON-NLS-2$
-		} else if (Util.isWindows()) {
+			cmd = "R --no-save < \"" + installPath + "/R/rlibs.R\""; //$NON-NLS-1$ //$NON-NLS-2$
+		}
+		else if (Util.isWindows()) {
 			return false;
-		} else {
+		}
+		else {
 			return false;
 		}
 		Runtime.getRuntime().exec(cmd);
 		return true;
 	}
-
+	
 	private static String getVersion(RWorkspace rw, String p) throws REXPMismatchException, RWorkspaceException {
-		REXP rRez = rw.eval("packageVersion(\""+p+"\")"); //$NON-NLS-1$ //$NON-NLS-2$
+		REXP rRez = rw.eval("packageVersion(\"" + p + "\")"); //$NON-NLS-1$ //$NON-NLS-2$
 		if (rRez.isList()) {
 			RList rList = rRez.asList();
 			if (rList.size() > 0) {
 				Object elem = rList.get(0);
 				if (elem instanceof REXPInteger) {
-					REXPInteger rExpInt = (REXPInteger)elem;
+					REXPInteger rExpInt = (REXPInteger) elem;
 					return buildVersion(rExpInt);
-				} else {
+				}
+				else {
 					System.out.println(TXMCoreMessages.bind(RUIMessages.eRRORColonRlistFirstElementIsNotREXPIntegerColon, elem));
 				}
-			} else {
+			}
+			else {
 				System.out.println(TXMCoreMessages.bind(RUIMessages.eRRORColonREvalListSizeIs0Colon, rList));
 			}
-		} else {
+		}
+		else {
 			System.out.println(TXMCoreMessages.bind(RUIMessages.eRRORColonREvalIsNotAListColon, rRez));
-		}	
+		}
 		return ""; //$NON-NLS-1$
 	}
-
+	
 	/**
 	 * 
 	 * @param rw
@@ -202,19 +242,27 @@
 	 * @throws REXPMismatchException
 	 */
 	private static boolean updateIfNecessary(RWorkspace rw, String p, String currentVersion) throws RWorkspaceException, REXPMismatchException {
-		//System.out.println("Current version of "+p+" is "+v+" and need "+packages.get(p));
-		//System.out.println("comp "+(packages.get(p))+" to "+(v));
-		//System.out.println(packages.get(p).compareTo(v));
+		// System.out.println("Current version of "+p+" is "+v+" and need "+packages.get(p));
+		// System.out.println("comp "+(packages.get(p))+" to "+(v));
+		// System.out.println(packages.get(p).compareTo(v));
 		if (packages.get(p).compareTo(currentVersion) > 0) {
 			System.out.println(TXMCoreMessages.bind("Updating the '{0}' ({1}) R package up to version {2}...", p, currentVersion, packages.get(p)));
 			
-			try {rw.eval("detach(\"package:"+p+"\", character.only = TRUE)");} catch(Exception tmpE){} // unload package to be able to reinstall it //$NON-NLS-1$ //$NON-NLS-2$
+			try {
+				rw.eval("detach(\"package:" + p + "\", character.only = TRUE)"); //$NON-NLS-1$ //$NON-NLS-2$
+			}
+			catch (Exception tmpE) {
+			} // unload package to be able to reinstall it
 			
-			//update.packages don't work ?
-			//rw.eval("update.packages(\""+p+"\", dependencies=TRUE, ask=FALSE, repos=\"http://cran.rstudio.com\");"); //$NON-NLS-1$ //$NON-NLS-2$
-			rw.eval("install.packages(\""+p+"\", dependencies=TRUE, repos=\"http://cran.rstudio.com\");"); //$NON-NLS-1$ //$NON-NLS-2$
+			// update.packages don't work ?
+			// rw.eval("update.packages(\""+p+"\", dependencies=TRUE, ask=FALSE, repos=\"http://cran.rstudio.com\");"); //$NON-NLS-1$ //$NON-NLS-2$
+			rw.eval("install.packages(\"" + p + "\", dependencies=TRUE, repos=\"http://cran.rstudio.com\");"); //$NON-NLS-1$ //$NON-NLS-2$
 			
-			try {rw.eval("library(\""+p+"\")");} catch(Exception tmpE){} // reload it //$NON-NLS-1$ //$NON-NLS-2$
+			try {
+				rw.eval("library(\"" + p + "\")"); //$NON-NLS-1$ //$NON-NLS-2$
+			}
+			catch (Exception tmpE) {
+			} // reload it
 			String newVersion = getVersion(rw, p);
 			if (!newVersion.equals(packages.get(p))) {
 				System.out.println(TXMCoreMessages.bind("Update of '{0}' failed (current version is still {1}). Warning: Windows users need to restart TXM.", p, newVersion));
@@ -223,4 +271,4 @@
 		}
 		return true;
 	}
-}
\ No newline at end of file
+}
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/macro/projects/antract/PrepareAFVOIXOFFCorpusMacro.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/macro/projects/antract/PrepareAFVOIXOFFCorpusMacro.groovy	(revision 2979)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/macro/projects/antract/PrepareAFVOIXOFFCorpusMacro.groovy	(revision 2980)
@@ -60,7 +60,7 @@
 backtomedia/sync_mode=Structure
 concordance/context_limits=text
 concordance/context_limits_type=list
-concordance/view_reference_pattern={"format"\\:"%s, %s, %s","properties"\\:["text_date-de-diffusion","u_time","div_identifiant-de-la-notice"]}
+concordance/view_reference_pattern={"format"\\:"%s, %s, %s","properties"\\:["text_date-de-diffusion-tri","u_time","div_identifiant-de-la-notice"]}
 concordance/sort_reference_pattern={"format"\\:"","properties"\\:["text_date-de-diffusion-tri","u_time","div_identifiant-de-la-notice"]}
 concordance/name=concordance
 eclipse.preferences.version=1"""
Index: tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java
===================================================================
--- tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java	(revision 2979)
+++ tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java	(revision 2980)
@@ -27,9 +27,7 @@
 //
 package org.txm.edition.rcp.editors;
 
-import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -74,20 +72,16 @@
 import org.eclipse.ui.commands.ICommandService;
 import org.eclipse.ui.handlers.IHandlerService;
 import org.txm.core.messages.TXMCoreMessages;
-import org.txm.core.results.TXMResult;
 import org.txm.edition.rcp.messages.EditionUIMessages;
 import org.txm.objects.Edition;
 import org.txm.objects.Page;
 import org.txm.objects.Text;
 import org.txm.rcp.IImageKeys;
 import org.txm.rcp.editors.IEditionEditor;
-import org.txm.rcp.editors.ITXMResultEditor;
 import org.txm.rcp.editors.TXMEditor;
 import org.txm.rcp.swt.GLComposite;
-import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.corpus.CQPCorpus;
 import org.txm.searchengine.cqp.corpus.MainCorpus;
-import org.txm.searchengine.cqp.serverException.CqiServerError;
 import org.txm.utils.logger.Log;
 
 /**
@@ -97,41 +91,41 @@
  * 
  */
 public class SynopticEditionEditor extends TXMEditor<Text> implements IEditionEditor {
-
+	
 	/** The Constant ID. */
 	public final static String ID = SynopticEditionEditor.class.getName();
-
+	
 	LinkedHashMap<String, EditionPanel> editionPanels = new LinkedHashMap<>();
-
+	
 	/** The page_label: show current page name. */
 	org.eclipse.swt.widgets.Text page_text;
-
+	
 	Label page_label;
-
+	
 	GLComposite editionsArea;
-
+	
 	private List<String> editionNames;
-
+	
 	private CQPCorpus corpus;
-
+	
 	private MainCorpus mainCorpus;
-
+	
 	private Text text;
-
+	
 	private Button editionsChooser;
-
+	
 	// private Label editionsLabel;
 	private GLComposite controlsArea;
-
+	
 	// private GLComposite annotationWidgetsArea;
 	// private TXMEditorToolBar supplementaryButtonToolbar;
 	private ISelectionProvider selProvider;
-
+	
 	private org.eclipse.swt.widgets.Text text_text;
-
+	
 	// private Label text_label;
 	private TXMAutoCompleteField identifiantComboAutoCompleteField;
-
+	
 	// TODO finish editor conversion
 	@Override
 	public Text getResult() {
@@ -140,23 +134,23 @@
 		}
 		return text;
 	}
-
+	
 	/**
 	 * Instantiates a new txm browser.
 	 */
 	public SynopticEditionEditor() {
 		selProvider = new ISelectionProvider() {
-
+			
 			@Override
 			public void setSelection(ISelection selection) {}
-
+			
 			@Override
 			public void removeSelectionChangedListener(ISelectionChangedListener listener) {}
-
+			
 			@Override
 			public ISelection getSelection() {
 				ITextSelection sel = new ITextSelection() {
-
+					
 					@Override
 					public boolean isEmpty() {
 						for (EditionPanel panel : editionPanels.values()) {
@@ -165,7 +159,7 @@
 						}
 						return true;
 					}
-
+					
 					@Override
 					public String getText() {
 						for (EditionPanel panel : editionPanels.values()) {
@@ -174,22 +168,22 @@
 						}
 						return EditionUIMessages.CommandLink_empty;
 					}
-
+					
 					@Override
 					public int getStartLine() {
 						return 0;
 					}
-
+					
 					@Override
 					public int getOffset() {
 						return 0;
 					}
-
+					
 					@Override
 					public int getLength() {
 						return 0;
 					}
-
+					
 					@Override
 					public int getEndLine() {
 						return 0;
@@ -197,31 +191,31 @@
 				};
 				return sel;
 			}
-
+			
 			@Override
 			public void addSelectionChangedListener(ISelectionChangedListener listener) {}
 		};
-
+		
 	}
-
+	
 	public void setHighlightWordsById(RGBA color, HashSet<String> wordids) {
 		for (EditionPanel panel : editionPanels.values()) {
 			panel.setHighlightWordsById(color, wordids);
 		}
 	}
-
+	
 	public void addHighlightWordsById(RGBA color, String wordid) {
 		for (EditionPanel panel : editionPanels.values()) {
 			panel.addHighlightWordsById(color, wordid);
 		}
 	}
-
+	
 	public void addHighlightWordsById(RGBA color, Collection<String> wordids) {
 		for (EditionPanel panel : editionPanels.values()) {
 			panel.addHighlightWordsById(color, wordids);
 		}
 	}
-
+	
 	public void removeHighlightWordsById(RGBA color, Collection<String> wordids) {
 		for (EditionPanel panel : editionPanels.values()) {
 			if (!panel.isDisposed()) {
@@ -229,7 +223,7 @@
 			}
 		}
 	}
-
+	
 	public void removeHighlightWordsById(RGBA color, String wordid) {
 		for (EditionPanel panel : editionPanels.values()) {
 			if (!panel.isDisposed()) {
@@ -237,7 +231,7 @@
 			}
 		}
 	}
-
+	
 	// /**
 	// *
 	// * @param wordids2 all the words to highlight
@@ -259,7 +253,7 @@
 	//
 	//
 	// }
-
+	
 	/**
 	 * First page.
 	 */
@@ -269,7 +263,7 @@
 		}
 		updatePageLabel();
 	}
-
+	
 	/**
 	 * Last page.
 	 */
@@ -278,7 +272,7 @@
 			panel.lastPage();
 		updatePageLabel();
 	}
-
+	
 	/**
 	 * Previous page.
 	 */
@@ -287,7 +281,7 @@
 			panel.previousPage();
 		updatePageLabel();
 	}
-
+	
 	/**
 	 * Next page.
 	 */
@@ -296,7 +290,7 @@
 			panel.nextPage();
 		updatePageLabel();
 	}
-
+	
 	/**
 	 * Direct access to a page with a name.
 	 */
@@ -305,9 +299,9 @@
 			panel.goToPage(name);
 		}
 		updatePageLabel();
-
+		
 	}
-
+	
 	/**
 	 * Direct access to a text with a name.
 	 */
@@ -327,10 +321,10 @@
 		catch (Exception e) {
 			e.printStackTrace();
 		}
-
+		
 		Log.info(NLS.bind("No {0} text found.", id));
 	}
-
+	
 	/**
 	 * Previous text.
 	 */
@@ -340,7 +334,7 @@
 		}
 		updatePageLabel();
 	}
-
+	
 	/**
 	 * Next text.
 	 */
@@ -350,7 +344,7 @@
 		}
 		updatePageLabel();
 	}
-
+	
 	/**
 	 * Previous text.
 	 */
@@ -360,7 +354,7 @@
 		}
 		updatePageLabel();
 	}
-
+	
 	/**
 	 * Next text.
 	 */
@@ -370,63 +364,63 @@
 		}
 		updatePageLabel();
 	}
-
+	
 	public Composite getEditionArea() {
 		return editionsArea;
 	}
-
+	
 	// public Composite getUpperToolbarArea() {
 	// return annotationWidgetsArea;
 	// }
-
+	
 	public Composite getLowerToolbarArea() {
 		return controlsArea;
 	}
-
+	
 	@Override
 	public void _createPartControl() {
-
+		
 		// remove the compute button
 		this.removeComputeButton();
-
+		
 		editionsArea = getResultArea();
-
+		
 		controlsArea = getBottomToolbar().installGLComposite(EditionUIMessages.controls, 15, false);
 		controlsArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
 		// spacer
 		new Label(controlsArea, SWT.NONE).setText("  "); //$NON-NLS-1$
-
+		
 		// annotationWidgetsArea = new GLComposite(getBetweenTopToolbarsAndResultComposite(), SWT.NONE, "Edition annotation area");
 		// this.annotationWidgetsArea.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
-
+		
 		// supplementaryButtonToolbar = new TXMEditorToolBar(this, getTopToolbarContainer(), annotationWidgetsArea, SWT.NONE, "annotation urs");
-
+		
 		// Edition names label
 		editionsChooser = new Button(controlsArea, SWT.PUSH);
 		editionsChooser.setText(StringUtils.join(editionNames, " | ")); //$NON-NLS-1$
-
+		
 		if (mainCorpus.getProject().getBuiltEditionNames().size() > 1) {
-
+			
 			editionsChooser.addSelectionListener(new SelectionListener() {
-
+				
 				@Override
 				public void widgetSelected(SelectionEvent e) {
 					try {
 						List<String> availableEditions = mainCorpus.getProject().getBuiltEditionNames();
 						if (availableEditions.size() == 0) return;
 						if (availableEditions.size() == 1) return;
-
-
+						
+						
 						Shell shell = e.display.getActiveShell();
 						EditionSelectorDialog d = new EditionSelectorDialog(shell, mainCorpus, editionNames);
-
+						
 						if (d.open() == Window.OK) {
 							Object[] rez = d.getResult();
 							editionNames = new ArrayList<>();
 							for (int i = 0; i < rez.length; i++) {
 								editionNames.add(rez[i].toString());
 							}
-
+							
 							editionsChooser.setText(StringUtils.join(editionNames, " | ")); //$NON-NLS-1$
 							openEditions(text, editionNames);
 							firstPage();
@@ -437,7 +431,7 @@
 						System.out.println(NLS.bind(EditionUIMessages.errorWhileGettingAvailableEditionsColonP0, e2));
 					}
 				}
-
+				
 				@Override
 				public void widgetDefaultSelected(SelectionEvent e) {}
 			});
@@ -445,7 +439,7 @@
 		else {
 			editionsChooser.setEnabled(false);
 		}
-
+		
 		// Navigation buttons
 		GLComposite pageNavigationComposite = new GLComposite(controlsArea, SWT.NONE, EditionUIMessages.pageButtons);
 		pageNavigationComposite.getLayout().numColumns = 6;
@@ -457,7 +451,7 @@
 		Button next = new Button(pageNavigationComposite, SWT.FLAT | SWT.PUSH);
 		Button last = new Button(pageNavigationComposite, SWT.FLAT | SWT.PUSH);
 		pageNavigationComposite.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, true, false));
-
+		
 		GLComposite textNavigationComposite = new GLComposite(controlsArea, SWT.NONE, EditionUIMessages.textButtons);
 		textNavigationComposite.getLayout().numColumns = 7;
 		textNavigationComposite.getLayout().horizontalSpacing = 1;
@@ -497,9 +491,9 @@
 		Button lastText = new Button(textNavigationComposite, SWT.FLAT | SWT.PUSH);
 		textNavigationComposite.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, false, false));
 		// Layouts data
-
+		
 		editionsChooser.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
-
+		
 		// GridData buttonGridData = new GridData(GridData.END,GridData.CENTER, true, false);
 		// buttonGridData.widthHint = 30;
 		// buttonGridData.heightHint = 30;
@@ -513,12 +507,12 @@
 		// centerButtonGridData.heightHint = 30;
 		// first.setLayoutData(centerButtonGridData);
 		// previous.setLayoutData(buttonGridData);
-
+		
 		// set sizes
 		GridData gdata = new GridData(GridData.END, GridData.CENTER, false, false);
 		gdata.minimumWidth = 25;
 		gdata.widthHint = 25;
-
+		
 		page_text.setLayoutData(gdata);
 		// page_label.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, false));
 		//
@@ -529,11 +523,11 @@
 		// last.setLayoutData(centerButtonGridData);
 		// nextText.setLayoutData(buttonGridData);
 		// lastText.setLayoutData(buttonGridData);
-
+		
 		// if (editionsChooser != null)
 		// editionsChooser.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, true));
 		// else spacer.setLayoutData(new GridData(GridData.END,GridData.CENTER, true, true));
-
+		
 		// set labels
 		page_label.setText(""); //$NON-NLS-1$
 		// text_label.setText(""); //$NON-NLS-1$
@@ -553,30 +547,30 @@
 		nextText.setToolTipText(EditionUIMessages.nextText);
 		lastText.setImage(IImageKeys.getImage(IImageKeys.CTRLFASTFORWARDEND));
 		lastText.setToolTipText(EditionUIMessages.lastTextOfTheCorpus);
-
+		
 		page_text.addKeyListener(new KeyListener() {
-
+			
 			@Override
 			public void keyReleased(KeyEvent e) {
 				if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
 					goToPage(page_text.getText());
 				}
 			}
-
+			
 			@Override
 			public void keyPressed(KeyEvent e) {}
 		});
 		text_text.addKeyListener(new KeyListener() {
-
+			
 			@Override
 			public void keyReleased(KeyEvent e) {
 				if (identifiantComboAutoCompleteField.isOpen()) return;
-
+				
 				if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
 					if (identifiantComboAutoCompleteField.isOpen()) {
 						return; // ignore keys when content assist is opened
 					}
-
+					
 					goToText(text_text.getText());
 				}
 				else if (e.keyCode == SWT.ARROW_DOWN) {
@@ -586,18 +580,18 @@
 					previousText(false);
 				}
 			}
-
+			
 			@Override
 			public void keyPressed(KeyEvent e) {}
 		});
 		text_text.addMouseWheelListener(new MouseWheelListener() {
-
+			
 			@Override
 			public void mouseScrolled(MouseEvent e) {
 				if (identifiantComboAutoCompleteField.isOpen()) {
 					return;
 				}
-
+				
 				if (e.count > 0) {
 					previousText(false);
 				}
@@ -609,60 +603,60 @@
 		});
 		// set listeners
 		first.addSelectionListener(new SelectionListener() {
-
+			
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {
 				firstPage();
 			}
-
+			
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				firstPage();
 			}
 		});
 		previous.addSelectionListener(new SelectionListener() {
-
+			
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {
 				previousPage();
 			}
-
+			
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				previousPage();
 			}
 		});
 		next.addSelectionListener(new SelectionListener() {
-
+			
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {
 				nextPage();
 			}
-
+			
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				nextPage();
 			}
 		});
 		last.addSelectionListener(new SelectionListener() {
-
+			
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {
 				lastPage();
 			}
-
+			
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				lastPage();
 			}
 		});
 		nextText.addSelectionListener(new SelectionListener() {
-
+			
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {
 				nextText();
 			}
-
+			
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				nextText();
@@ -670,24 +664,24 @@
 		});
 		// set listeners
 		previousText.addSelectionListener(new SelectionListener() {
-
+			
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {
 				previousText(false);
 			}
-
+			
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				previousText(false);
 			}
 		});
 		lastText.addSelectionListener(new SelectionListener() {
-
+			
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {
 				lastText();
 			}
-
+			
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				lastText();
@@ -695,18 +689,18 @@
 		});
 		// set listeners
 		firstText.addSelectionListener(new SelectionListener() {
-
+			
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {
 				firstText();
 			}
-
+			
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				firstText();
 			}
 		});
-
+		
 		try {
 			// ensure all texts have build their page indexes
 			for (Text t : mainCorpus.getProject().getTexts()) {
@@ -720,7 +714,7 @@
 			e1.printStackTrace();
 		}
 	}
-
+	
 	// /**
 	// * Opens the default corpus edition with the first Text
 	// *
@@ -730,7 +724,7 @@
 	// if (corpus == null) return false;
 	// return openEditions(corpus, corpus.getProject().getFirstText(), corpus.getProject().getDefaultEdition());
 	// }
-
+	
 	/**
 	 * update editor title using the first panel only
 	 */
@@ -745,13 +739,13 @@
 				continue;
 			}
 			this.setPartName(e.getText().getName() + " - " + cpage.getName()); //$NON-NLS-1$
-
+			
 			if (page_text.isDisposed()) {
 				continue;
 			}
 			page_text.setText(cpage.getName());
 			page_label.setText(" / " + e.getNumPages()); //$NON-NLS-1$
-
+			
 			text_text.setText(p.getCurrentText().getName());
 			// try {
 			// text_label.setText(" / "+corpus.getCorpusTextIdsList().length);
@@ -759,18 +753,18 @@
 			// // TODO Auto-generated catch block
 			// e1.printStackTrace();
 			// }
-
+			
 			controlsArea.layout();
 			return;
 		}
 	}
-
+	
 	// public boolean openEditions(CQPCorpus corpus, String textID, String... editionNames) {
 	// Text text = corpus.getProject().getText(textID);
 	// if (text == null) return false;
 	// return openEditions(corpus, text, editionNames);
 	// }
-
+	
 	// /**
 	// * Opens a list of edition corpus
 	// * @param corpus
@@ -779,7 +773,7 @@
 	// public boolean openEditions(CQPCorpus corpus, Text text, String... editionNames) {
 	// return openEditions(corpus, text, Arrays.asList(editionNames));
 	// }
-
+	
 	/**
 	 * Opens a list of edition corpus
 	 * 
@@ -787,7 +781,7 @@
 	 * @param editionNames
 	 */
 	public boolean openEditions(Text text, List<String> editionNames) {
-
+		
 		try {
 			text.compute();
 		}
@@ -800,9 +794,9 @@
 			panel.dispose();
 		}
 		editionPanels = new LinkedHashMap<>();
-
+		
 		editionsArea.getLayout().numColumns = editionNames.size();
-
+		
 		for (int i = 0; i < editionNames.size(); i++) {
 			String editionName = editionNames.get(i);
 			// System.out.println("EDITION NAME: "+editionName);
@@ -812,15 +806,16 @@
 				try {
 					EditionPanel panel = new EditionPanel(this, container, SWT.BORDER, edition);
 					panel.initSelectionProvider();
-
+					
 					if (i == 0) { // TODO: how to manage multiple menumanager -> the text selection does not work only the first panel selection is used
 						panel.initMenu();
 						getSite().registerContextMenu(panel.getMenuManager(), panel.getSelectionProvider());
 					}
-
+					
 					editionPanels.put(editionName, panel);
-				} catch (SWTError e) {
-					Log.severe("TXM could not open the internal browser: "+e);
+				}
+				catch (SWTError e) {
+					Log.severe("TXM could not open the internal browser: " + e);
 					Log.printStackTrace(e);
 				}
 			}
@@ -831,7 +826,7 @@
 		editionsArea.layout();
 		return true;
 	}
-
+	
 	// /**
 	// *
 	// * //TODO: add getDefaultEditions to Corpus object
@@ -847,15 +842,15 @@
 	// return new String[]{defaultEdition};
 	// }
 	// }
-
+	
 	@Override
 	public void doSaveAs() {
 		return;
 	}
-
+	
 	@Override
 	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
-
+		
 		corpus = ((SynopticEditorInput) input).getCorpus(); // corpus focused when opening the editions
 		try {
 			corpus.compute(false);
@@ -867,24 +862,24 @@
 		mainCorpus = corpus.getMainCorpus(); // get the main corpus of the corpus
 		text = ((SynopticEditorInput) input).getText();
 		editionNames = ((SynopticEditorInput) input).getEditions();
-
+		
 		super.init(site, input);
 	}
-
+	
 	public boolean isDisposed() {
 		return editionsArea.isDisposed();
 	}
-
+	
 	@Override
 	public boolean isSaveAsAllowed() {
 		return false;
 	}
-
+	
 	@Override
 	public void _setFocus() {
 		this.getEditionPanel(0).setFocus();
 	}
-
+	
 	public void backToText(Text text, String line_wordid) {
 		try {
 			text.compute();
@@ -899,13 +894,13 @@
 			e.printStackTrace();
 		}
 	}
-
+	
 	public void reloadPage() {
 		for (EditionPanel p : editionPanels.values()) {
 			p.reloadPage();
 		}
 	}
-
+	
 	@Override
 	public String getTextSelection() {
 		String sel = null;
@@ -917,16 +912,16 @@
 		}
 		return EditionUIMessages.CommandLink_empty;
 	}
-
+	
 	@Override
 	public CQPCorpus getCorpus() {
 		return corpus;
 	}
-
+	
 	public CQPCorpus getMainCorpus() {
 		return mainCorpus;
 	}
-
+	
 	public EditionPanel getEditionPanel(int i) {
 		int n = 0;
 		for (EditionPanel p : editionPanels.values()) {
@@ -936,7 +931,7 @@
 		}
 		return null;
 	}
-
+	
 	/**
 	 * 
 	 * @return the first and last word ID covered by the text selection of the first EditionPanel
@@ -947,7 +942,7 @@
 		}
 		return null;
 	}
-
+	
 	/**
 	 * 
 	 * @param text2 the Text to set
@@ -959,14 +954,14 @@
 		}
 		updatePageLabel();
 	}
-
+	
 	public void setFocusedWordID(String focusid) {
 		for (EditionPanel p : editionPanels.values()) {
 			p.setFocusedWordID(focusid);
 		}
 		updatePageLabel();
 	}
-
+	
 	/**
 	 * TODO finish implementation in EditionPanel
 	 * 
@@ -977,29 +972,29 @@
 			p.setHighlightedArea(positions);
 		}
 	}
-
+	
 	public void updateWordStyles() {
 		for (EditionPanel p : editionPanels.values()) {
 			p.updateWordStyles();
 		}
 	}
-
+	
 	public void addFontWeightWordsById(String weight, List<String> previousSelectedUnitIDS) {
 		for (EditionPanel p : editionPanels.values()) {
 			p.addFontWeightWordsById(weight, previousSelectedUnitIDS);
 		}
 	}
-
+	
 	public void removeFontWeightWordsById(List<String> previousSelectedUnitIDS) {
 		for (EditionPanel p : editionPanels.values()) {
 			p.removeFontWeightWordsById(previousSelectedUnitIDS);
 		}
 	}
-
+	
 	public void fireIsDirty() {
 		this.firePropertyChange(IEditorPart.PROP_DIRTY);
 	}
-
+	
 	/**
 	 * Clears all highlighted words.
 	 */
@@ -1008,17 +1003,17 @@
 			p.removeHighlightWords();
 		}
 	}
-
+	
 	@Override
 	public void updateResultFromEditor() {
 		// TODO Auto-generated method stub
 	}
-
+	
 	@Override
 	public void updateEditorFromResult(boolean update) throws Exception {
 		this.firstPage();
 	}
-
+	
 	/**
 	 * Browser command that opens an edition
 	 * 
@@ -1029,7 +1024,7 @@
 		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
 		ICommandService cmdService = window.getService(ICommandService.class);
 		Command cmd = cmdService.getCommand(id);
-
+		
 		// get the parameter
 		ArrayList<Parameterization> parameters = new ArrayList<>();
 		ArrayList<String> failedParameters = new ArrayList<>();
@@ -1040,14 +1035,14 @@
 				parameters.add(p);
 			}
 			catch (NotDefinedException e) {
-				//Log.warning(NLS.bind(EditionUIMessages.warningColonUnknownedParameterIdEqualsP0, k));
+				// Log.warning(NLS.bind(EditionUIMessages.warningColonUnknownedParameterIdEqualsP0, k));
 				failedParameters.add(k);
 			}
 		}
-
+		
 		// build the parameterized command
 		ParameterizedCommand pc = new ParameterizedCommand(cmd, parameters.toArray(new Parameterization[parameters.size()]));
-
+		
 		// execute the command
 		IHandlerService handlerService = window.getService(IHandlerService.class);
 		try {
@@ -1059,7 +1054,7 @@
 		}
 		return null;
 	}
-
+	
 	/**
 	 * 
 	 * @param editor may be null, will be used by the command to display its result
@@ -1076,7 +1071,7 @@
 		for (int i = 0; i + 1 < arguments.length; i += 2) {
 			params.put(arguments[i].toString(), arguments[i + 1].toString());
 		}
-
+		
 		String id = params.get("id"); //$NON-NLS-1$
 		if (id != null) {
 			params.remove("id"); //$NON-NLS-1$
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/utils/SWTUtils.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/utils/SWTUtils.java	(revision 0)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/utils/SWTUtils.java	(revision 2980)
@@ -0,0 +1,41 @@
+package org.txm.rcp.utils;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.part.EditorPart;
+import org.txm.rcp.Activator;
+
+/**
+ * Utils :
+ * - getShell() from various SWT&Eclipse objects
+ * 
+ * @author mdecorde
+ *
+ */
+public class SWTUtils {
+	
+	public static Shell getShell() {
+		Shell shell = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
+		if (shell == null) {
+			return new Shell();
+		}
+		return shell;
+	}
+	
+	public static Shell getShell(EditorPart editor) {
+		if (editor == null) return getShell();
+		return editor.getSite().getShell();
+	}
+	
+	public static Shell getShell(ExecutionEvent event) {
+		if (event == null) return getShell();
+		return HandlerUtil.getActiveShell(event);
+	}
+	
+	public static Shell getShell(Widget widget) {
+		if (widget == null || widget.isDisposed()) return getShell();
+		return widget.getDisplay().getActiveShell();
+	}
+}

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

Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/editor/SetEncoding.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/editor/SetEncoding.java	(revision 2979)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/editor/SetEncoding.java	(revision 2980)
@@ -39,14 +39,16 @@
 import org.txm.core.messages.TXMCoreMessages;
 import org.txm.rcp.editors.TxtEditor;
 import org.txm.rcp.messages.TXMUIMessages;
+import org.txm.rcp.utils.SWTUtils;
 
 /**
  * @author mdecorde
- * Change the encoding of the currently selected text editor
+ *         Change the encoding of the currently selected text editor
  */
 public class SetEncoding extends AbstractHandler {
-
-	/* (non-Javadoc)
+	
+	/*
+	 * (non-Javadoc)
 	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 	 */
 	@Override
@@ -57,17 +59,17 @@
 			TxtEditor te = (TxtEditor) page;
 			setEncoding(te);
 		}
-
+		
 		return null;
 	}
-
+	
 	public static void setEncoding(TxtEditor te) {
 		try {
-			IEncodingSupport encodingSupport = (IEncodingSupport) te.getAdapter(IEncodingSupport.class);		
+			IEncodingSupport encodingSupport = te.getAdapter(IEncodingSupport.class);
 			String currentEncoding = encodingSupport.getEncoding();
 			String defaultEncoding = encodingSupport.getDefaultEncoding();
 			if (currentEncoding == null) currentEncoding = defaultEncoding;
-			Shell sh = new Shell();
+			Shell sh = SWTUtils.getShell(te);
 			InputDialog dlg = new InputDialog(sh,
 					TXMUIMessages.changeCharactersEncoding,
 					TXMCoreMessages.bind(TXMUIMessages.changeCharactersEncodingCurrentEncodingColon, currentEncoding, defaultEncoding),
@@ -78,8 +80,9 @@
 					encodingSupport.setEncoding(newEncoding);
 				}
 			}
-		} catch(Exception e) {
+		}
+		catch (Exception e) {
 			org.txm.utils.logger.Log.printStackTrace(e);
 		}
 	}
-}
\ No newline at end of file
+}
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/p2/plugins/TXMUpdateHandler.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/p2/plugins/TXMUpdateHandler.java	(revision 2979)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/p2/plugins/TXMUpdateHandler.java	(revision 2980)
@@ -43,6 +43,7 @@
 import org.eclipse.equinox.p2.ui.ProvisioningUI;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.MessageBox;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.handlers.HandlerUtil;
@@ -212,6 +213,12 @@
 	@Override
 	protected Shell getShell() {
 		// System.out.println("MY GETSHELL: "+Display.getCurrent().getActiveShell());
+		try {
+			return Display.getCurrent().getActiveShell();
+		}
+		catch (Exception e) {
+			Log.finer("Error: no active SWT shell available");
+		}
 		return new Shell();
 	}
 	
Index: tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/BackToMedia.java
===================================================================
--- tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/BackToMedia.java	(revision 2979)
+++ tmp/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/BackToMedia.java	(revision 2980)
@@ -369,8 +369,7 @@
 			}
 			
 			AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient();
-			int[] struc = cqiClient.cpos2Struc(startProperty.getQualifiedName(),
-					new int[] { keywordPosition, keywordEndPosition });
+			int[] struc = cqiClient.cpos2Struc(startProperty.getQualifiedName(), new int[] { keywordPosition, keywordEndPosition });
 			int[] struc2 = new int[] { struc[0], struc[1], struc[1] + 1 };
 			String[] times = cqiClient.struc2Str(startProperty.getQualifiedName(), struc2);
 			sStartTime = times[0];
