Index: tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/chartsengine/events/ProgressionEventCallBack.java
===================================================================
--- tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/chartsengine/events/ProgressionEventCallBack.java	(revision 3250)
+++ tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/chartsengine/events/ProgressionEventCallBack.java	(revision 3251)
@@ -467,8 +467,7 @@
 					SWTEditorsUtils.addEditor(parentEditor, linkedEditor, position);
 				}
 				
-				linkedEditor.setText(text, true);
-				linkedEditor.goToPage(openPage.getName());
+				linkedEditor.goToPage(text.getName(), openPage.getName());
 				
 				// Highlight tokens by series
 				for (int i = 0; i < allWordIds.size(); i++) {
Index: tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java
===================================================================
--- tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java	(revision 3250)
+++ tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java	(revision 3251)
@@ -25,7 +25,6 @@
 //
 package org.txm.concordance.rcp.editors;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -130,19 +129,17 @@
 import org.txm.searchengine.cqp.CQPSearchEngine;
 import org.txm.searchengine.cqp.ReferencePattern;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
-import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException;
 import org.txm.searchengine.cqp.core.messages.CQPSearchEngineCoreMessages;
 import org.txm.searchengine.cqp.corpus.CQPCorpus;
 import org.txm.searchengine.cqp.corpus.Property;
 import org.txm.searchengine.cqp.corpus.WordProperty;
-import org.txm.searchengine.cqp.serverException.CqiServerError;
 import org.txm.utils.TXMProgressMonitor;
 import org.txm.utils.logger.Log;
 
 /**
  * Displays the concordances parameters and results in the same editor
  * 
- * @author mdecorde.
+ * @author mdecorde
  */
 public class ConcordanceEditor extends TXMEditor<Concordance> {
 	
Index: tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationWriter.java
===================================================================
--- tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationWriter.java	(revision 3250)
+++ tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationWriter.java	(revision 3251)
@@ -48,14 +48,19 @@
 			Log.severe(NLS.bind("** Error: no knowledge repository found in {0} corpus.", corpus));
 			throw new IllegalArgumentException("No kr in " + corpus);
 		}
-		String t = krnames.get(0);
-		defaultKR = KRAnnotationEngine.getKnowledgeRepository(corpus, t);
+		String firtsKRName = krnames.get(0);
+		defaultKR = KRAnnotationEngine.getKnowledgeRepository(corpus, firtsKRName);
 		if (defaultKR == null) {
 			Log.severe(NLS.bind("** Error: no knowledge repository {0} found in {0} corpus.", defaultKR, corpus));
 			throw new IllegalArgumentException("No kr " + defaultKR + " in " + corpus);
 		}
-		types = defaultKR.getAllAnnotationTypes();
 		
+		types = new ArrayList<AnnotationType>();
+		for (AnnotationType type : defaultKR.getAllAnnotationTypes()) {
+			if (type.getEffect().equals(AnnotationEffect.SEGMENT)) {
+				types.add(type);
+			}
+		}
 	}
 	
 	/**
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZImporter.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZImporter.groovy	(revision 3250)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZImporter.groovy	(revision 3251)
@@ -235,16 +235,22 @@
 			cpb.tick()
 			
 			for (File inputFile : filesToProcess) {
-				File outputFile = File.createTempFile("tmp", inputFile.getName(),inputFile.getParentFile());
+				File outputFile = new File(inputFile.getParentFile(), "tmp"+inputFile.getName());
 				println "$inputFile, 'text', $wordTag, $milestone, $outputFile"
 				MileStoneProjection msp = new MileStoneProjection(inputFile, "text", wordTag, milestone)
 				if (!msp.process(outputFile)) {
-					println "Fail to encode $milestone in $inputFile"
+					println "** Fail to encode $milestone in $inputFile"
 					return false
 				} else {
 					if (inputFile.delete()) {
-						FileCopy.copy(outputFile, inputFile)
-						//outputFile.renameTo(inputFile)
+						if (!FileCopy.copy(outputFile, inputFile)) {
+							println "** Fail to copy $outputFile to ${inputFile}."
+							return false
+						}
+						if (!outputFile.delete()) {
+							println "** Fail to delete $outputFile temporary file."
+							return false
+						}
 					} else {
 						println "Fail to encode $milestone in ${inputFile}: could not replace the file with the $outputFile file."
 						return false
Index: tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/BackToText.java
===================================================================
--- tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/BackToText.java	(revision 3250)
+++ tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/BackToText.java	(revision 3251)
@@ -238,7 +238,6 @@
 				}
 			}
 			
-			
 			String projectid = ""; //$NON-NLS-1$
 			try {
 				textS = corpus.getStructuralUnit("text"); //$NON-NLS-1$
Index: tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/OpenEdition.java
===================================================================
--- tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/OpenEdition.java	(revision 3250)
+++ tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/OpenEdition.java	(revision 3251)
@@ -149,6 +149,30 @@
 	 * @return the object
 	 */
 	public static SynopticEditionEditor openEdition(CQPCorpus corpus, List<String> editions) {
+		return openEdition(corpus, editions, null, null, null);
+	}
+	
+	/**
+	 * Open edition, but don't show a page
+	 *
+	 * @param corpus the corpus
+	 * @return the object
+	 */
+	public static SynopticEditionEditor openEdition(CQPCorpus corpus, String[] editions, String textId) {
+		return openEdition(corpus, Arrays.asList(editions), textId, null, null);
+	}
+	
+	/**
+	 * Open edition, but don't show a page
+	 *
+	 * @param corpus the corpus
+	 * @param editions the editions to show
+	 * @param textId the ID of the Text to show
+	 * @param pageId the ID of the page to show. textId must be specified to work
+	 * @param wordId the wordId of the word to focus&show. textId must be specified to work
+	 * @return the SynopticEditionEditor (not shown yet)
+	 */
+	public static SynopticEditionEditor openEdition(CQPCorpus corpus, List<String> editions, String textId, String pageId, String wordId) {
 		
 		Log.fine("Opening edition of " + corpus); //$NON-NLS-1$
 		try {
@@ -177,7 +201,7 @@
 			IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
 			IWorkbenchPage page = window.getActivePage();
 			
-			SynopticEditorInput editorInput = new SynopticEditorInput(text, corpus, editions);
+			SynopticEditorInput editorInput = new SynopticEditorInput(text, corpus, editions, textId, pageId, wordId);
 			SynopticEditionEditor editor = (SynopticEditionEditor) page.openEditor(editorInput, SynopticEditionEditor.ID, true);
 			
 			return editor;
Index: tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditorInput.java
===================================================================
--- tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditorInput.java	(revision 3250)
+++ tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditorInput.java	(revision 3251)
@@ -3,6 +3,7 @@
 import java.util.Arrays;
 import java.util.List;
 
+import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IPersistableElement;
@@ -20,6 +21,8 @@
 	
 	private List<String> editions;
 	
+	private String textId, pageId, wordId;
+	
 	/**
 	 * Instantiates a new SynopticEditorInput
 	 *
@@ -27,11 +30,14 @@
 	 * @param text, the text to show
 	 * @param editions, the editions to show
 	 */
-	public SynopticEditorInput(Text text, CQPCorpus corpus, List<String> editions) {
+	public SynopticEditorInput(Text text, CQPCorpus corpus, List<String> editions, String textId, String pageId, String wordId) {
 		super(text);
 		
 		this.corpus = corpus;
 		this.editions = editions;
+		this.textId = textId;
+		this.pageId = pageId;
+		this.wordId = wordId;
 		
 		// if (text == null) {
 		// this.text = corpus.getProject().getFirstText();
@@ -100,6 +106,18 @@
 		return corpus;
 	}
 	
+	public String getTextID() {
+		return textId;
+	}
+	
+	public String getPageID() {
+		return pageId;
+	}
+	
+	public String getWordId() {
+		return wordId;
+	}
+	
 	public Text getText() {
 		return getResult();
 	}
Index: tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionPanel.java
===================================================================
--- tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionPanel.java	(revision 3250)
+++ tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionPanel.java	(revision 3251)
@@ -54,9 +54,8 @@
 	// private List<String> lineids;
 	/** The edition. */
 	Text currentText;
-	
+	String editionName;
 	Edition currentEdition;
-	
 	Page currentPage;
 	
 	protected SynopticEditionEditor synopticEditionEditor;
@@ -278,11 +277,12 @@
 		return getBrowser().execute(code);
 	}
 	
-	public EditionPanel(SynopticEditionEditor synopticEditionEditor, Composite parent, int style, Edition edition) {
+	public EditionPanel(SynopticEditionEditor synopticEditionEditor, Composite parent, int style, String editionName) {
 		super(parent, style);
 		this.synopticEditionEditor = synopticEditionEditor;
-		this.currentEdition = edition;
-		this.currentText = currentEdition.getText();
+		this.editionName = editionName;
+//		this.currentEdition = edition;
+//		this.currentText = currentEdition.getText();
 		
 		File functionsFile = null;
 		try {
@@ -291,7 +291,6 @@
 			URL r = FileLocator.resolve(fileURL);
 			Log.fine("Load JS functions from: " + r);
 			functions = IOUtils.getText(r, "UTF-8"); //$NON-NLS-1$
-			
 		}
 		catch (Exception e) {
 			Log.severe(EditionUIMessages.bind(EditionUIMessages.error_while_reading, functionsFile, e.getLocalizedMessage()));
@@ -714,12 +713,12 @@
 	 */
 	public boolean backToText(Text text, String line_wordid) {
 		
-		String name = currentEdition.getName();
-		Edition edition = text.getEdition(name);
+		//String name = currentEdition.getName();
+		Edition edition = text.getEdition(editionName);
 		
 		if (edition == null) {
-			String s = EditionUIMessages.bind(EditionUIMessages.noEditionFoundForTextEqualsP0AndEditionEqualsP1, text, name);
-			System.out.println(s);
+			String s = EditionUIMessages.bind(EditionUIMessages.noEditionFoundForTextEqualsP0AndEditionEqualsP1, text, editionName);
+			Log.warning(s);
 			StatusLine.setMessage(s);
 			Log.severe(s);
 		}
@@ -731,7 +730,7 @@
 			else {
 				openedPage = edition.getFirstPage();
 			}
-			if (openedPage == null || !openedPage.equals(currentPage)) {
+			if (currentPage == null || !openedPage.equals(currentPage)) {
 				this.showPage(openedPage);
 				return true;
 			}
@@ -1000,22 +999,23 @@
 	
 	
 	public void setText(Text text, boolean refresh) {
-		String editionName = currentEdition.getName();
-		Edition tmp = text.getEdition(editionName);
+		//String editionName = currentEdition.getName();
+		Edition tmp = text.getEdition(this.editionName);
 		if (tmp == null) {
-			System.out.println(EditionUIMessages.bind(EditionUIMessages.noEditionWithNameEqualsP0AvailableForTextEqualsP1, editionName, text.getName()));
+			System.out.println(EditionUIMessages.bind(EditionUIMessages.noEditionWithNameEqualsP0AvailableForTextEqualsP1, this.editionName, text.getName()));
 			return;
 		}
 		
 		currentEdition = tmp;
-		currentPage = currentEdition.getFirstPage();
+		
 		currentText = text;
-		if (currentPage == null) {
-			StatusLine.setMessage("No text next"); //$NON-NLS-1$
-			return;
-		}
 		
 		if (refresh) {
+			currentPage = currentEdition.getFirstPage();
+			if (currentPage == null) {
+				StatusLine.setMessage("No text next"); //$NON-NLS-1$
+				return;
+			}
 			reloadPage();
 		}
 		// page_label.setText(makePageLabel());
@@ -1377,8 +1377,16 @@
 	
 	
 	
-	public void goToPage(String name) {
+	public void goToPage(String text, String name) {
+		Text newText = this.synopticEditionEditor.getCorpus().getProject().getText(text);
+		if (newText == null) {
+			return;
+		}
+		if (!newText.equals(currentText)) {
+			setText(newText, false);
+		}
 		
+		
 		Page next = currentEdition.getPageForName(name);
 		// System.out.println(Messages.TxmBrowser_4+currentPage);
 		if (next != null) {
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 3250)
+++ tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java	(revision 3251)
@@ -28,18 +28,13 @@
 package org.txm.edition.rcp.editors;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
 
 import org.apache.commons.lang.StringUtils;
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.IParameter;
-import org.eclipse.core.commands.Parameterization;
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.core.commands.common.NotDefinedException;
 import org.eclipse.jface.bindings.keys.KeyStroke;
 import org.eclipse.jface.fieldassist.TXMAutoCompleteField;
 import org.eclipse.jface.fieldassist.TextContentAdapter;
@@ -66,15 +61,10 @@
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.handlers.IHandlerService;
-import org.txm.core.messages.TXMCoreMessages;
+import org.txm.edition.rcp.handlers.BackToText;
 import org.txm.edition.rcp.messages.EditionUIMessages;
 import org.txm.objects.Edition;
-import org.txm.objects.Match;
 import org.txm.objects.Page;
 import org.txm.objects.Project;
 import org.txm.objects.Text;
@@ -106,10 +96,11 @@
 	GLComposite editionsArea;
 	
 	private List<String> editionNames;
+	private String textIdToOpen, pageIdToOpen, wordIdToOpen;
 	
 	private CQPCorpus corpus;
 	
-	private Text text;
+	//private Text text;
 	
 	private Button editionsChooser;
 	
@@ -135,10 +126,12 @@
 	// TODO finish editor conversion
 	@Override
 	public Text getResult() {
+		
 		for (EditionPanel panel : editionPanels.values()) {
 			return panel.getCurrentText();
 		}
-		return text;
+		if (textIdToOpen != null) return this.getCorpus().getProject().getText(textIdToOpen);
+		return this.getCorpus().getProject().getFirstText();
 	}
 	
 	public SearchEditionToolbar getSearchEditionToolbar() {
@@ -278,8 +271,9 @@
 	 * Last page.
 	 */
 	public void lastPage() {
-		for (EditionPanel panel : editionPanels.values())
+		for (EditionPanel panel : editionPanels.values()) {
 			panel.lastPage();
+		}
 		updatePageLabel();
 	}
 	
@@ -287,8 +281,9 @@
 	 * Previous page.
 	 */
 	public void previousPage() {
-		for (EditionPanel panel : editionPanels.values())
+		for (EditionPanel panel : editionPanels.values()) {
 			panel.previousPage();
+		}
 		updatePageLabel();
 	}
 	
@@ -296,43 +291,34 @@
 	 * Next page.
 	 */
 	public void nextPage() {
-		for (EditionPanel panel : editionPanels.values())
+		for (EditionPanel panel : editionPanels.values()) {
 			panel.nextPage();
+		}
 		updatePageLabel();
 	}
 	
 	/**
 	 * Direct access to a page with a name.
 	 */
-	public void goToPage(String name) {
+	public void goToPage(String textId, String name) {
+		
 		for (EditionPanel panel : editionPanels.values()) {
-			panel.goToPage(name);
+			panel.goToPage(textId, name);
 		}
 		updatePageLabel();
-		
 	}
 	
 	/**
 	 * Direct access to a text with a name.
 	 */
-	public void goToText(String id) {
-		try {
-			String[] texts = corpus.getCorpusTextIdsList();
-			for (String text_id : texts) {
-				if (text_id.equals(id)) {
-					Text text = project.getText(text_id);
-					if (text != null) {
-						setText(text, true);
-						return;
-					}
-				}
-			}
+	public void goToText(String textId) {
+		Text newText = this.project.getText(textId);
+		if (newText == null) {
+			Log.warning("** Error: not text found with ID="+textId);
+			return;
+		} else {
+			setText(newText, true);
 		}
-		catch (Exception e) {
-			e.printStackTrace();
-		}
-		
-		Log.info(NLS.bind("No {0} text found.", id));
 	}
 	
 	/**
@@ -456,7 +442,7 @@
 							}
 							
 							editionsChooser.setText(StringUtils.join(editionNames, " | ")); //$NON-NLS-1$
-							openEditions(text, editionNames);
+							openEditions(editionNames, null, null, null);
 							firstPage();
 						}
 					}
@@ -685,7 +671,7 @@
 			@Override
 			public void keyReleased(KeyEvent e) {
 				if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
-					goToPage(page_text.getText());
+					goToPage(null, page_text.getText());
 				}
 			}
 			
@@ -749,7 +735,7 @@
 			for (Text t : project.getTexts()) {
 				t.compute();
 			}
-			if (openEditions(text, editionNames)) {
+			if (openEditions(editionNames, textIdToOpen, pageIdToOpen, wordIdToOpen)) {
 				firstPage();
 			}
 		}
@@ -823,15 +809,8 @@
 	 * @param corpus
 	 * @param editionNames
 	 */
-	public boolean openEditions(Text text, List<String> editionNames) {
+	public boolean openEditions(List<String> editionNames, String textId, String pageId, String wordId) {
 		
-		try {
-			text.compute();
-		}
-		catch (Exception e) {
-			System.out.println("Error: " + text.getName() + " is not ready to use");
-			return false;
-		}
 		// remove previous EditionPanel
 		for (EditionPanel panel : editionPanels.values()) {
 			panel.dispose();
@@ -844,10 +823,9 @@
 			String editionName = editionNames.get(i);
 			// System.out.println("EDITION NAME: "+editionName);
 			Composite container = editionsArea;// .getContainer(i);
-			Edition edition = text.getEdition(editionName);
-			if (edition != null) {
+			if (corpus.getProject().hasEditionDefinition(editionName)) {
 				try {
-					EditionPanel panel = new EditionPanel(this, container, SWT.BORDER, edition);
+					EditionPanel panel = new EditionPanel(this, container, SWT.BORDER, editionName);
 					panel.initSelectionProvider();
 					
 					if (i == 0) { // TODO: how to manage multiple menumanager -> the text selection does not work only the first panel selection is used
@@ -867,9 +845,52 @@
 			}
 		}
 		editionsArea.layout();
+		
+		Text text = null;
+		if (textId != null) {
+			text = this.corpus.getProject().getText(textId);
+		} else {
+			text = this.corpus.getProject().getFirstText();
+		}
+		
+		if (text == null) {
+			Log.warning("** Error: no text found with id="+textId);
+			return false;
+		}
+		try {
+			text.compute();
+			setText(text,  false);
+		}
+		catch (Exception e) {
+			System.out.println("Error: " + text.getName() + " is not ready to use");
+			return false;
+		}
+		
+		if (pageId != null) {
+			this.goToPage(textId, pageId);
+		}
+		
+		if (wordId != null) {
+			if (pageId == null) {
+				this.goToWord(textId, pageId);
+			}
+			this.addHighlightWordsById(BackToText.lightred, Arrays.asList(wordId));
+			this.setFocusedWordID(wordId);
+		}
 		return true;
 	}
 	
+	private boolean goToWord(String textId, String wordId) {
+		
+		Text text = this.corpus.getProject().getText(textId);
+		if (text == null) {
+			Log.warning("** Error: no text found with ID="+textId);
+			return false;
+		}
+		
+		return backToText(text, wordId);
+	}
+	
 	// /**
 	// *
 	// * //TODO: add getDefaultEditions to Corpus object
@@ -905,8 +926,14 @@
 		
 		project = corpus.getProject();
 		
-		text = ((SynopticEditorInput) input).getText();
+		//text = ((SynopticEditorInput) input).getText();
 		editionNames = ((SynopticEditorInput) input).getEditions();
+		textIdToOpen = ((SynopticEditorInput) input).getTextID();
+		if (textIdToOpen == null) {
+			textIdToOpen = corpus.getProject().getFirstText().getName();
+		}
+		pageIdToOpen = ((SynopticEditorInput) input).getPageID();
+		wordIdToOpen = ((SynopticEditorInput) input).getWordId();
 		
 		super.init(site, input);
 	}
@@ -922,21 +949,26 @@
 	
 	@Override
 	public void _setFocus() {
+		if (this.getEditionPanel(0) == null) return;
 		this.getEditionPanel(0).setFocus();
 	}
 	
-	public void backToText(Text text, String line_wordid) {
+	public boolean backToText(Text text, String line_wordid) {
 		try {
 			text.compute();
+			this.setText(text, false);
+			
 			for (EditionPanel p : editionPanels.values()) {
 				p.backToText(text, line_wordid);
 			}
 			updatePageLabel();
 			updateWordStyles();
 			notifyExtensions("onBackToText"); //$NON-NLS-1$
+			return true;
 		}
 		catch (Exception e) {
 			e.printStackTrace();
+			return false;
 		}
 	}
 	
@@ -986,14 +1018,17 @@
 	
 	/**
 	 * 
-	 * @param text2 the Text to set
+	 * @param newText the Text to set
 	 * @param refresh if true set the first Text page
 	 */
-	public void setText(Text text2, boolean refresh) {
+	public void setText(Text newText, boolean refresh) {
 		for (EditionPanel p : editionPanels.values()) {
-			p.setText(text2, refresh);
+			p.setText(newText, refresh);
 		}
-		updatePageLabel();
+		
+		if (refresh) {
+			updatePageLabel();
+		}
 	}
 	
 	public void setFocusedWordID(String focusid) {
Index: tmp/org.txm.properties.core/src/org/txm/properties/core/preferences/PropertiesPreferences.java
===================================================================
--- tmp/org.txm.properties.core/src/org/txm/properties/core/preferences/PropertiesPreferences.java	(revision 3250)
+++ tmp/org.txm.properties.core/src/org/txm/properties/core/preferences/PropertiesPreferences.java	(revision 3251)
@@ -26,7 +26,7 @@
 		super.initializeDefaultPreferences();
 		Preferences preferences = DefaultScope.INSTANCE.getNode(getPreferencesNodeQualifier());
 		
-		preferences.putInt(MAX_PROPERTIES_TO_DISPLAY, 100);
+		preferences.putInt(MAX_PROPERTIES_TO_DISPLAY, 10);
 		
 	}
 	
Index: tmp/org.txm.properties.core/src/org/txm/properties/core/functions/CorpusPropertiesComputer.java
===================================================================
--- tmp/org.txm.properties.core/src/org/txm/properties/core/functions/CorpusPropertiesComputer.java	(revision 3250)
+++ tmp/org.txm.properties.core/src/org/txm/properties/core/functions/CorpusPropertiesComputer.java	(revision 3251)
@@ -1,9 +1,11 @@
 package org.txm.properties.core.functions;
 
+import java.io.IOException;
 import java.text.NumberFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
@@ -16,15 +18,19 @@
 import org.txm.objects.Project;
 import org.txm.properties.core.messages.PropertiesCoreMessages;
 import org.txm.searchengine.cqp.AbstractCqiClient;
+import org.txm.searchengine.cqp.CQPSearchEngine;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.corpus.CQPCorpus;
 import org.txm.searchengine.cqp.corpus.CorpusManager;
 import org.txm.searchengine.cqp.corpus.MainCorpus;
 import org.txm.searchengine.cqp.corpus.Property;
+import org.txm.searchengine.cqp.corpus.QueryResult;
 import org.txm.searchengine.cqp.corpus.StructuralUnit;
 import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
 import org.txm.searchengine.cqp.corpus.WordProperty;
+import org.txm.searchengine.cqp.corpus.query.CQLQuery;
 import org.txm.searchengine.cqp.corpus.query.Match;
+import org.txm.searchengine.cqp.serverException.CqiServerError;
 import org.txm.utils.TXMProgressMonitor;
 import org.txm.utils.logger.Log;
 
@@ -209,6 +215,31 @@
 				}
 			}
 		}
+		
+		HashMap<String, org.txm.utils.Tuple<Integer>> firstPositionOfStructures = new HashMap<>();
+		for (String su : internalArchitecture) {
+			try {
+				QueryResult r = result.query(new CQLQuery("<"+su+">[]+ </"+su+"> cut 1"), "tmp", false);
+				firstPositionOfStructures.put(su, new org.txm.utils.Tuple<Integer>(r.getStarts()[0], r.getEnds()[0]));
+			}
+			catch (Exception e) {
+				e.printStackTrace();
+				firstPositionOfStructures.put(su, new org.txm.utils.Tuple<Integer>(Integer.MAX_VALUE, 0));
+			}
+		}
+		System.out.println(firstPositionOfStructures);
+		internalArchitecture.sort(new Comparator<String>() {
+
+			@Override
+			public int compare(String arg0, String arg1) {
+				
+				int r = firstPositionOfStructures.get(arg0).a - firstPositionOfStructures.get(arg1).a;
+				if (r == 0) {
+					return -(firstPositionOfStructures.get(arg0).b - firstPositionOfStructures.get(arg1).b);
+				}
+				return r;
+			}
+		});
 	}
 	
 	/**
Index: tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/editor/AnnotationExtension.java
===================================================================
--- tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/editor/AnnotationExtension.java	(revision 3250)
+++ tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/editor/AnnotationExtension.java	(revision 3251)
@@ -11,6 +11,7 @@
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
@@ -32,23 +33,23 @@
 import org.txm.utils.logger.Log;
 
 public class AnnotationExtension extends TXMEditorExtension<TXMResult> {
-
+	
 	/** The annotation area. */
 	protected ArrayList<AnnotationArea> annotationAreas = new ArrayList<>();
-
+	
 	private Group controlArea;
-
+	
 	private SelectionListener defaultListener;
-
+	
 	private ToolItem saveButton;
-
+	
 	public static final String GROUP_NAME = "Annotation";
-
+	
 	@Override
 	public String getName() {
 		return GROUP_NAME;
 	}
-
+	
 	/**
 	 * use this to enable/disable the button
 	 * 
@@ -57,37 +58,37 @@
 	public ToolItem getSaveButton() {
 		return saveButton;
 	}
-
+	
 	/**
 	 * install the annotation start button and dropdown list
 	 */
 	@Override
 	public void notifyEndOfCreatePartControl() throws Exception {
-
+		
 		IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(AnnotationArea.class.getName());
 		Arrays.sort(config, new Comparator<IConfigurationElement>() {
-
+			
 			@Override
 			public int compare(IConfigurationElement o1, IConfigurationElement o2) {
 				return o1.getAttribute("position").compareTo(o2.getAttribute("position"));
 			}
 		});
-
+		
 		ArrayList<String> modes = new ArrayList<>();
 		ArrayList<SelectionListener> listeners = new ArrayList<>();
 		for (final IConfigurationElement celement : config) {
 			try {
 				Object o = celement.createExecutableExtension("class"); //$NON-NLS-1$
 				AnnotationArea aa = (AnnotationArea) o;
-
+				
 				if (!aa.getAnnotatedTXMResultClass().equals(editor.getResult().getClass())) {
 					continue;
 				}
 				Log.finer("Installing AnnotationExtension: " + aa.getName());
 				modes.add(aa.getName()); // get the annotation name
-
+				
 				listeners.add(new SelectionListener() { // create alistener to instantiate a new AnnotationArea
-
+					
 					@Override
 					public void widgetSelected(SelectionEvent e) {
 						try {
@@ -99,7 +100,7 @@
 							e1.printStackTrace();
 						}
 					}
-
+					
 					@Override
 					public void widgetDefaultSelected(SelectionEvent e) {}
 				});
@@ -108,13 +109,13 @@
 				exx.printStackTrace();
 			}
 		}
-
+		
 		if (modes.size() == 0) {
 			return; // no need to show the buttons
 		}
-
+		
 		SelectionListener openCloseSelectionListener = new SelectionListener() {
-
+			
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				// if (editor.getTopToolbar().isVisible(GROUP_NAME)) {
@@ -125,16 +126,16 @@
 				// else {
 				// annotationAreas.clear();
 				// }
-
+				
 				if (annotationAreas.size() == 0) { // if no annotation mode is opened, opens the default mode
 					openDefaultAnnotationMode(e);
 				}
 			}
-
+			
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {}
 		};
-
+		
 		defaultListener = listeners.get(0);
 		String defaultMode = modes.get(0);
 		controlArea = editor.getTopToolbar().installAlternativesGroup(GROUP_NAME, AnnotationUIMessages.annotateWordProperty,
@@ -142,11 +143,12 @@
 				"platform:/plugin/org.txm.rcp/icons/functions/pencil_close.png", false,
 				openCloseSelectionListener, modes, listeners);
 		controlArea.setLayout(new GridLayout(1, true));
-
+		
 		saveButton = new ToolItem(editor.getTopToolbar(), SWT.PUSH);
-		saveButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL_SAVE));
+		saveButton.setText("Save annotations");
+		//saveButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL_SAVE));
 		saveButton.addSelectionListener(new SelectionListener() {
-
+			
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				try {
@@ -157,19 +159,19 @@
 					e1.printStackTrace();
 				}
 			}
-
+			
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {}
 		});
 		saveButton.setEnabled(false);
 	}
-
+	
 	public void closeAreasPanel() {
 		editor.getTopToolbar().setVisible(GROUP_NAME, false);
 		editor.getTopToolbar().getOpenCloseButton().setSelection(false);
 		saveButton.setEnabled(false);
 	}
-
+	
 	public void openAnnotationMode(AnnotationArea aa, int position) throws Exception {
 		// AnnotationArea aa = (AnnotationArea)o;
 		if (!aa.allowMultipleAnnotations()) {
@@ -181,16 +183,16 @@
 			removed.addAll(closeAllAreas(aa.getClass()));
 			annotationAreas.removeAll(removed);
 		}
-
+		
 		// System.out.println("Starting "+aa.getName());
-
+		
 		aa.install(editor, AnnotationExtension.this, controlArea, position);
-
+		
 		editor.getTopToolbar().setVisible(GROUP_NAME, true);
 		annotationAreas.add(aa);
 		editor.refresh(false); // refresh the concordance display
 	}
-
+	
 	/**
 	 * 
 	 * @param areaToAvoid
@@ -208,63 +210,63 @@
 		}
 		return removed;
 	}
-
+	
 	public void closeArea(AnnotationArea area, boolean closeExtensionIfEmpty) {
 		if (area != null && !area.getAnnotationArea().isDisposed()) {
 			area.getAnnotationArea().dispose();
 		}
 		area._close();
-
+		
 		this.annotationAreas.remove(area);
 		if (this.annotationAreas.size() == 0 && closeExtensionIfEmpty) {
 			this.closeAreasPanel();
 		}
 	}
-
+	
 	protected void openDefaultAnnotationMode(SelectionEvent e) {
 		defaultListener.widgetSelected(e);
 	}
-
+	
 	@Override
 	public void notifyStartOfCompute() throws Exception {
 		for (AnnotationArea aa : annotationAreas) {
 			aa.notifyStartOfCompute();
 		}
 	}
-
+	
 	@Override
 	public void notifyEndOfCompute() throws Exception {
 		for (AnnotationArea aa : annotationAreas) {
 			aa.notifyEndOfCompute();
 		}
 	}
-
-
+	
+	
 	public boolean isAnnotationEnable() {
 		return annotationAreas != null;
 	}
-
+	
 	@Override
 	public void notifyEndOfRefresh() throws Exception {
 		for (AnnotationArea aa : annotationAreas) {
 			aa.notifyEndOfRefresh();
 		}
 	}
-
+	
 	@Override
 	public void notifyStartOfCreatePartControl() throws Exception {
 		for (AnnotationArea aa : annotationAreas) {
 			aa.notifyStartOfCreatePartControl();
 		}
 	}
-
+	
 	@Override
 	public void notifyStartOfRefresh() throws Exception {
 		for (AnnotationArea aa : annotationAreas) {
 			aa.notifyStartOfRefresh();
 		}
 	}
-
+	
 	@Override
 	public boolean isDirty() throws Exception {
 		boolean dirty = false;
@@ -273,26 +275,26 @@
 		}
 		return dirty;
 	}
-
+	
 	@Override
 	public boolean isSaveOnCloseNeeded() throws Exception {
 		return true;
 	}
-
+	
 	@Override
 	public void notifyDoSave() throws Exception {
-
+		
 		//		if (needToUpdateIndexes) {
 		JobHandler job = new JobHandler("Updating corpus indexes and editions", true) {
-
+			
 			@Override
 			protected IStatus run(IProgressMonitor monitor) {
-
+				
 				this.runInit(monitor);
-
+				
 				try {
 					monitor.setTaskName("Updating corpus XML-TXM files");
-
+					
 					Log.info("Saving annotations...");
 					boolean needToUpdateIndexes = false;
 					// System.out.println("Saving annotations...");
@@ -311,7 +313,7 @@
 						if (corpus != null && UpdateCorpus.update(corpus) != null) {
 							monitor.worked(50);
 							this.syncExec(new Runnable() {
-
+								
 								@Override
 								public void run() {
 									Log.info("Done.");
@@ -331,7 +333,7 @@
 						}
 					} else {
 						this.syncExec(new Runnable() {
-
+							
 							@Override
 							public void run() {
 								Log.info("Done.");
@@ -351,24 +353,41 @@
 		job.schedule();
 		//		}
 	}
-
+	
 	@Override
 	public void notifyDispose() throws Exception {
+		
+		//FIXME MD: I have to do this because Eclipse is not asking for editor saves before exiting the app - BUG
+		try {
+			boolean annotationsDirty = false;
+			for (AnnotationArea aa : annotationAreas) {
+				annotationsDirty = annotationsDirty || aa.isDirty();
+			}
+			if (annotationsDirty) {
+				boolean doSave = MessageDialog.openQuestion(this.editor.getShell(), "Annotations not saved", "Do you want to save the annotations before closing the editor?");
+				if (doSave) {
+					notifyDoSave();
+				}
+			}
+		} catch(Exception e) {
+			e.printStackTrace();
+		}
+		
 		for (AnnotationArea aa : annotationAreas) {
 			aa._close();
 		}
 	}
-
+	
 	public void layout() {
 		if (!controlArea.isDisposed()) {
 			editor.layout(true);
 		}
 	}
-
+	
 	public int getNumberOfAnnotationArea() {
 		return annotationAreas.size();
 	}
-
+	
 	@Override
 	public Set<Class<? extends TXMResult>> getTXMResultValidClasses() {
 		HashSet<Class<? extends TXMResult>> h = new HashSet<>();
@@ -376,6 +395,6 @@
 		h.add(Text.class);
 		return h;
 	}
-
-
+	
+	
 }
Index: tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/view/PropertyField.java
===================================================================
--- tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/view/PropertyField.java	(revision 3250)
+++ tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/view/PropertyField.java	(revision 3251)
@@ -62,8 +62,11 @@
 					first = false;
 					return;
 				}
-				
-				t.setBackground(new Color(t.getDisplay(),255,0,0));
+				if (!t.getText().equals(view.getAnalecVue().getValeurChamp(view.element, t.getToolTipText()))) {
+					t.setBackground(new Color(t.getDisplay(),255,0,0));
+				} else {
+					t.setBackground(null);
+				}
 			}
 		});
 		t.addSelectionListener(new SelectionListener() {
@@ -84,15 +87,13 @@
 			public void keyReleased(KeyEvent e) {
 				if (!(e.widget instanceof Combo)) return;
 				if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
+					view.saveFieldValue(PropertyField.this);
+					
+				} else if (e.keyCode == SWT.ESC) {
 					//								System.out.println("w:"+e.widget+" key pressed2.");
 					
-					view.saveFieldValue(PropertyField.this);
-					
+					t.setText(view.getAnalecVue().getValeurChamp(view.element, t.getToolTipText()));
 				}
-				//							else if (e.keyCode == SWT.DEL) {
-				//								String value =((Combo) e.widget).getText();
-				//								System.out.println("DEL prop="+textWidgets.get(e.widget)+" value="+value);
-				//							}
 			}
 			
 			@Override
@@ -147,5 +148,10 @@
 		
 		return t.getText();
 	}
+
+	public void setTextBackground(Color color) {
+		
+		t.setBackground(color);
+	}
 	
 }
Index: tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/view/ElementSearchView.java
===================================================================
--- tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/view/ElementSearchView.java	(revision 3250)
+++ tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/view/ElementSearchView.java	(revision 3251)
@@ -9,6 +9,7 @@
 import java.util.LinkedHashSet;
 import java.util.List;
 
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 import org.eclipse.e4.ui.workbench.modeling.EModelService;
 import org.eclipse.jface.bindings.keys.KeyStroke;
 import org.eclipse.jface.fieldassist.ComboContentAdapter;
@@ -30,6 +31,8 @@
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IViewReference;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
@@ -143,23 +146,15 @@
 	private Concordance concordance;
 	
 	public static void closeView() {
-		try {
 			IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
 			ElementSearchView view = (ElementSearchView) page.findView(ElementSearchView.ID);
 			
 			// close Element View if opened
 			if (view != null) {
-				view = (ElementSearchView) page.showView(ElementSearchView.ID);
 				page.hideView(view);
 			}
 			
 			return;
-		}
-		catch (PartInitException e1) {
-			System.out.println("Part initialisation error: " + e1.getLocalizedMessage());
-			Log.printStackTrace(e1);
-		}
-		return;
 	}
 	
 	public static ElementSearchView openView() {
@@ -174,7 +169,9 @@
 			}
 			if (view == null) {
 				System.out.println("Error ElementPropertiesView view not found: " + ElementSearchView.ID);
+				return null;
 			}
+			view.getSite().getPage().activate(view);
 			return view;
 		}
 		catch (PartInitException e1) {
@@ -262,6 +259,8 @@
 			
 			@Override
 			public void widgetSelected(SelectionEvent e) {
+				
+				splitViewIfNecessary();
 				int current = Integer.parseInt(text.getText());
 				current--;
 				if (current < 1) current = 1;
@@ -406,6 +405,20 @@
 		updateCurrentLabel();
 	}
 	
+	protected void splitViewIfNecessary() {
+		
+//		for (IViewReference ref : ElementSearchView.this.getSite().getPage().getViewReferences()) {
+//			System.out.println("ref="+ref+" id="+ref.getId());
+//			if (ref.getId().equals(ElementPropertiesView.class.getName())) {
+//				IWorkbenchPage p = ref.getView(true).getSite().getPage();
+//				MPart mp1 = ref.getView(true).getSite().getService(MPart.class);
+//				MPart mp2 = this.getSite().getService(MPart.class);
+//				SWTEditorsUtils.addPart(mp1, mp2, EModelService.RIGHT_OF, 0.5f);
+//				return;
+//			}
+//		}
+	}
+
 	protected void updateCurrentLabel() {
 		if (currentIndex >= 0) {
 			this.setPartName("" + (currentIndex + 1) + " / " + matchingElements.size() + " " + typeSearched);
Index: tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/view/ElementPropertiesView.java
===================================================================
--- tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/view/ElementPropertiesView.java	(revision 3250)
+++ tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/view/ElementPropertiesView.java	(revision 3251)
@@ -71,7 +71,7 @@
 					} else if (e.getType() == TypeMessage.CORPUS_SAVED) {
 						for (PropertyField c : textWidgets.values()) {
 							if (c.isDisposed()) continue;
-							c.setForeground(null);
+							c.setBackground(null);
 							c.update();
 						}
 					}
@@ -86,21 +86,14 @@
 	//	private KeyListener allControlsKeyListener;
 	
 	public static void closeView() {
-		try {
-			IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
-			ElementPropertiesView view = (ElementPropertiesView) page.findView(ElementPropertiesView.ID);
-			
-			// close Element View if opened
-			if (view != null) {
-				view = (ElementPropertiesView) page.showView(ElementPropertiesView.ID);
-				page.hideView(view);
-			}
-			
-			return;
-		} catch (PartInitException e1) {
-			System.out.println("Part initialisation error: "+e1.getLocalizedMessage());
-			Log.printStackTrace(e1);
+		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+		ElementPropertiesView view = (ElementPropertiesView) page.findView(ElementPropertiesView.ID);
+		
+		// close Element View if opened
+		if (view != null) {
+			page.hideView(view);
 		}
+		
 		return;
 	}
 	public static ElementPropertiesView openView() {
@@ -110,12 +103,15 @@
 			ElementPropertiesView view = (ElementPropertiesView) page.findView(ElementPropertiesView.ID);
 			if (view == null) {
 				view = (ElementPropertiesView) page.showView(ElementPropertiesView.ID);
+				
 				if (view != null && !view.fields.isDisposed() && view.fields.getParent() != null) 
 					view.fields.getParent().layout(); // sometimes the part layout is broken
 			}
 			if (view == null) {
 				System.out.println("Error ElementPropertiesView view not found: "+ElementPropertiesView.ID);
+				return null;
 			}
+			view.getSite().getPage().activate(view);
 			return view;
 		} catch (PartInitException e1) {
 			System.out.println("Part initialisation error: "+e1.getLocalizedMessage());
@@ -242,26 +238,33 @@
 			this.analecCorpus.removeEventListener(corpusListener);
 		}
 		
-		clear();
-		
 		this.corpus = corpus;
 		this.analecCorpus = analecCorpus;
 		this.analecCorpus.addEventListener(corpusListener);
 		this.vue = URSCorpora.getVue(analecCorpus);
 		
+		if (this.element != newElement) {
+			System.out.println("CLEAR FIELDS");
+			clear();
+		}
+		
 		//if (this.element == null || (!this.element.getType().equals(newElement.getType()))) { // no need to rebuild the widgets
 		//clear(); // remove all previous widgets
 		String[][] props = vue.getChamps(newElement.getClass(), newElement.getType());
 		for (int l = 0 ; l < props.length ; l++) {
 			for (String p : props[l]) { // the first is the prop names
+				PropertyField c = null;
+				if (textWidgets.containsKey(p)) {
+					c = textWidgets.get(p);
+				} else {
+					c = new PropertyField(fields, SWT.NONE, p, this);
+					
+					c.setLayoutData(cData);
+					c.setLayout(new GridLayout(2, false));
+					textWidgets.put(p, c);
+				}
 				
-				PropertyField c = new PropertyField(fields, SWT.NONE, p, this);
-				
-				c.setLayoutData(cData);
-				c.setLayout(new GridLayout(2, false));
 				c.setItems(c, newElement);
-				
-				textWidgets.put(p, c);
 			}
 		}
 		
@@ -313,7 +316,7 @@
 			if (toolbar != null && !toolbar.isDisposed()) this.toolbar.fireIsDirty(); // the Analec corpus should be saved
 			
 			if (!c.isDisposed()) {
-				c.setBackground(new Color(c.getDisplay(), 255,0,0));
+				c.setTextBackground(new Color(c.getDisplay(), 255,255,255));
 				c.update();
 			}
 		}
Index: tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/preferences/URSPreferences.java
===================================================================
--- tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/preferences/URSPreferences.java	(revision 3250)
+++ tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/preferences/URSPreferences.java	(revision 3251)
@@ -14,6 +14,7 @@
 	public static final String COLOR_PALETTE = "color_palette";
 	public static final String PREFIX_AUTOCOMPLETION = "prefix_autocompletion"; //$NON-NLS-1$
 	public static final String ANALEC_LIMIT_CORRECTION_SCHEME = "urs_limit_correction_scheme"; //$NON-NLS-1$
+	public static final String SAVE_TIMER = "save_timer_duration"; //$NON-NLS-1$
 
 	
 	@Override
@@ -24,6 +25,7 @@
 		preferences.put(COLOR_PALETTE, "green");
 		preferences.putBoolean(ANALEC_LIMIT_CORRECTION_SCHEME, false);
 		preferences.putBoolean(PREFIX_AUTOCOMPLETION, false);
+		preferences.putInt(SAVE_TIMER, 5);
 	}
 	
 	/**
Index: tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/preferences/URSPreferencePage.java
===================================================================
--- tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/preferences/URSPreferencePage.java	(revision 3250)
+++ tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/preferences/URSPreferencePage.java	(revision 3251)
@@ -1,21 +1,23 @@
 package org.txm.annotation.urs.preferences;
 
 import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.IntegerFieldEditor;
 import org.eclipse.jface.preference.RadioGroupFieldEditor;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
 import org.eclipse.ui.preferences.ScopedPreferenceStore;
 import org.txm.annotation.urs.Messages;
-import org.txm.rcp.Application;
 import org.txm.rcp.preferences.TXMPreferencePage;
+import org.txm.rcp.preferences.TXMPreferenceStore;
 
-public class URSPreferencePage extends TXMPreferencePage
-		implements IWorkbenchPreferencePage {
+public class URSPreferencePage extends TXMPreferencePage implements IWorkbenchPreferencePage {
 	
 	private BooleanFieldEditor analec_limit_scheme_field;
 	
 	private BooleanFieldEditor prefix_autocompletion_field;
 	
+	private IntegerFieldEditor save_timer_field;
+	
 	// public static final String SELECTED_UNIT_COLOR = "selected_unit_color";
 	// private ColorFieldEditor selected_unit_color;
 	// public static final String HIGHLIGHTED_UNIT_COLOR = "hightlighted_unit_color";
@@ -27,14 +29,6 @@
 	
 	private RadioGroupFieldEditor color_palette;
 	
-	public URSPreferencePage() {
-		super();
-		
-		preferences = new ScopedPreferenceStore(org.eclipse.core.runtime.preferences.InstanceScope.INSTANCE,
-				Application.PLUGIN_ID);
-		setPreferenceStore(preferences);
-	}
-	
 	/**
 	 * Creates the field editors. Field editors are abstractions of the common
 	 * GUI blocks needed to manipulate various types of preferences. Each field
@@ -52,6 +46,11 @@
 				getFieldEditorParent());
 		addField(prefix_autocompletion_field);
 		
+		save_timer_field = new IntegerFieldEditor(
+				URSPreferences.SAVE_TIMER, "Save timer duration (0 desactivate the timer)",
+				getFieldEditorParent());
+		addField(save_timer_field);
+		
 		// hightlighted_unit_color = new ColorFieldEditor(
 		// HIGHLIGHTED_UNIT_COLOR, "Highlighted units background color",
 		// getFieldEditorParent());
@@ -66,13 +65,12 @@
 		String[][] values = { { "green", "green" }, { "yellow", "yellow" } }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
 		color_palette = new RadioGroupFieldEditor(COLOR_PALETTE, Messages.AnalecPreferencePage_9, 2, values, getFieldEditorParent());
 		addField(color_palette);
-		
-		preferences = new ScopedPreferenceStore(org.eclipse.core.runtime.preferences.InstanceScope.INSTANCE,
-				Application.PLUGIN_ID);
-		setPreferenceStore(preferences);
-		setTitle("URS"); //$NON-NLS-1$
 	}
 	
 	@Override
-	public void init(IWorkbench workbench) {}
+	public void init(IWorkbench workbench) {
+		this.setPreferenceStore(new TXMPreferenceStore(URSPreferences.getInstance().getPreferencesNodeQualifier()));
+		this.setTitle("URS");
+		//this.setImageDescriptor(IndexAdapterFactory.ICON);
+	}
 }
Index: tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/commands/OpenDemocratTools.java
===================================================================
--- tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/commands/OpenDemocratTools.java	(revision 3250)
+++ tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/commands/OpenDemocratTools.java	(revision 3251)
@@ -42,6 +42,7 @@
 			// close Element View if opened
 			if (view == null) {
 				view = (MacroExplorer) page.showView(MacroExplorer.ID);
+				page.activate(view);
 			}
 
 			if (view == null) {
Index: tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/URSAnnotationToolbar.java
===================================================================
--- tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/URSAnnotationToolbar.java	(revision 3250)
+++ tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/URSAnnotationToolbar.java	(revision 3251)
@@ -1,6 +1,8 @@
 package org.txm.annotation.urs.toolbar;
 
 import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
 
 import org.apache.commons.lang.StringUtils;
 import org.eclipse.swt.SWT;
@@ -16,6 +18,7 @@
 import org.txm.annotation.rcp.editor.AnnotationArea;
 import org.txm.annotation.rcp.editor.AnnotationExtension;
 import org.txm.annotation.urs.URSCorpora;
+import org.txm.annotation.urs.preferences.URSPreferences;
 import org.txm.annotation.urs.view.ElementPropertiesView;
 import org.txm.annotation.urs.view.ElementSearchView;
 import org.txm.core.results.TXMResult;
@@ -59,6 +62,8 @@
 	
 	protected Corpus analecCorpus;
 	
+	protected Timer saveTimer;
+	
 	protected Vue vue;
 	
 	protected MainCorpus maincorpus;
@@ -68,6 +73,8 @@
 	protected ToolItem button;
 	
 	private Button closeButton;
+
+	private TimerTask saveTask;
 	
 	public URSAnnotationToolbar() {}
 	
@@ -87,7 +94,8 @@
 	
 	@Override
 	public boolean save() {
-		// System.out.println();
+		if (!analecCorpus.isModifie()) return false;
+		
 		Log.info("Saving URS annotation...");
 		if (URSCorpora.saveCorpus(analecCorpus)) {
 			Log.info("Done: URS annotations saved.");
@@ -107,6 +115,36 @@
 		analecCorpus = URSCorpora.getCorpus(maincorpus);
 		vue = URSCorpora.getVue(maincorpus);
 		
+		if (URSPreferences.getInstance().getInt(URSPreferences.SAVE_TIMER) > 0) {
+			saveTimer = new Timer(true);
+			
+			Log.info("URS auto-save timer is activated (set to "+URSPreferences.getInstance().getInt(URSPreferences.SAVE_TIMER)+" minutes).");
+			
+			saveTask = new TimerTask() {
+				
+				@Override
+				public void run() {
+					
+					Log.fine("URS auto-saving... ", false);
+					if (save()) {
+						Log.fine("Annotations saved.");
+						editor.getParent().getDisplay().syncExec(new Runnable() {
+							
+							@Override
+							public void run() {
+								editor.fireIsDirty();
+							}
+						});
+						
+					} else {
+						//Log.info("Annotations were already saved.");
+					}
+					
+				}
+			};
+			
+			saveTimer.scheduleAtFixedRate(saveTask, URSPreferences.getInstance().getInt(URSPreferences.SAVE_TIMER) * 60L * 1000L, URSPreferences.getInstance().getInt(URSPreferences.SAVE_TIMER) * 60L * 1000L);
+		}
 		annotationArea = new GLComposite(parent, SWT.NONE, "Unit annotation");
 		annotationArea.getLayout().horizontalSpacing = 1;
 		
@@ -316,6 +354,10 @@
 		}
 		if (annotationArea != null && annotationArea.isDisposed()) annotationArea.dispose();
 		
+		if (saveTimer != null) {
+			saveTimer.cancel();
+		}
+		
 		ElementPropertiesView.closeView();
 		ElementSearchView.closeView();
 		analecCorpus.removeEventListener(corpusListener);
Index: tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/UnitToolbar.java
===================================================================
--- tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/UnitToolbar.java	(revision 3250)
+++ tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/UnitToolbar.java	(revision 3251)
@@ -156,8 +156,9 @@
 		typeCombo = new Combo(annotationArea, SWT.NONE | SWT.READ_ONLY);
 		typeCombo.setToolTipText(Messages.UnitToolbar_7);
 		GridData gdata = new GridData(GridData.CENTER, GridData.CENTER, false, false);
-		gdata.minimumWidth = 100;
+		gdata.minimumWidth = 150;
 		//gdata.widthHint = 100;
+		typeCombo.setSize(150, SWT.DEFAULT);
 		typeCombo.setLayoutData(gdata);
 		typeCombo.addSelectionListener(new SelectionListener() {
 			
@@ -283,7 +284,7 @@
 		
 		ElementPropertiesView.openView();
 		editor.updateWordStyles();
-		
+		annotationArea.layout();
 		return true;
 	}
 	
@@ -435,8 +436,8 @@
 						editor.updateWordStyles();
 					}
 					else { // a word have been clicked
-						testIfAwordSpanIsSelected(ids);
-						panel.expandSelectionTo(ids);
+						//testIfAwordSpanIsSelected(ids);
+						//panel.expandSelectionTo(ids);
 					}
 				}
 				catch (Exception ex) {
@@ -787,7 +788,7 @@
 			// System.out.println("firstWordTextId="+firstWordTextId);
 			// System.out.println("newText="+newText+" e="+e);
 			Edition newEdition = newText.getEdition(e.getName()); // get the edition of the new text
-			Page p = newEdition.getPageForWordId(firstWordId); // find out the page containing the word
+			Page newPage = newEdition.getPageForWordId(firstWordId); // find out the page containing the word
 			// System.out.println("page="+p+" current page="+panel.getCurrentPage());
 			
 			previousSelectedUnitIDS = Arrays.asList(ids);
@@ -799,14 +800,9 @@
 			}
 			Page cp = panel.getCurrentPage();
 			// System.out.println("Word page= "+p+" current="+panel.getCurrentPage());
-			if (!panel.getCurrentText().equals(newText)) { // text changed
-				// System.out.println("TEXT CHANGED");
-				editor.setText(newText, false); // don't refresh right now
-				editor.goToPage(p.getName());
+			if (!cp.equals(newPage) || !panel.getCurrentText().equals(newText)) { // do we need to change page ?
+				editor.goToPage(newText.getName(), newPage.getName());
 			}
-			else if (!cp.equals(p)) { // do we need to change page ?
-				editor.goToPage(p.getName());
-			}
 			else { // just reload the page to highlight words
 				// System.out.println("NO CHANGE");
 			}
@@ -1105,9 +1101,10 @@
 			return true;
 		}
 		
+		if (navigationField.getSelectionIndex() != 0) { // is the navigationField already at 0 ?
+			navigationField.setSelectionIndex(0);
+		}
 		
-		navigationField.setSelectionIndex(0);
-		
 		return false;
 	}
 	
Index: tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/SchemaToolbar.java
===================================================================
--- tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/SchemaToolbar.java	(revision 3250)
+++ tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/SchemaToolbar.java	(revision 3251)
@@ -555,7 +555,7 @@
 			Project corpus = e.getText().getProject();
 			Text newText = corpus.getText(firstWordTextId); // get the new text
 			Edition newEdition = newText.getEdition(e.getName()); // get the edition of the new text
-			Page p = newEdition.getPageForWordId(firstWordId); // find out the page containing the word
+			Page newPage = newEdition.getPageForWordId(firstWordId); // find out the page containing the word
 
 			previousSelectedUniteIDS = Arrays.asList(ids);
 //			System.out.println("HU: "+previousSelectedUniteIDS);
@@ -564,13 +564,10 @@
 			
 			if (previousSelectedUniteIDS.size() > 0)	editor.setFocusedWordID(previousSelectedUniteIDS.get(0));
 			//System.out.println("Word page= "+p+" current="+panel.getCurrentPage());
-			if (panel.getCurrentText() != newText) { // text changed
-				//System.out.println("TEXT CHANGED");
-				editor.setText(newText, false); // don't refresh right now
-			} else if (panel.getCurrentPage() != p) { // do we need to change page ?
-				//System.out.println("PAGE CHANGED");
-				editor.goToPage(p.getName());
-			} else { // just reload the page to highlight words
+			if (panel.getCurrentPage() != newPage || panel.getCurrentText() != newText) { // do we need to change page ?
+				//System.out.println("PAGE&TEXT CHANGED");
+				editor.goToPage(newText.getName(), newPage.getName());
+			} else  { // just reload the page to highlight words
 				//editor.updateWordStyles();
 			}
 			
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/corpora/CorporaView.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/corpora/CorporaView.java	(revision 3250)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/corpora/CorporaView.java	(revision 3251)
@@ -589,6 +589,8 @@
 			}
 			if (view == null) {
 				System.out.println("Error Unite view not found: " + CorporaView.ID);
+			} else {
+				view.getSite().getPage().activate(view);
 			}
 			return view;
 		}
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/utils/SWTEditorsUtils.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/utils/SWTEditorsUtils.java	(revision 3250)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/utils/SWTEditorsUtils.java	(revision 3251)
@@ -31,6 +31,7 @@
 import org.txm.core.results.TXMResult;
 import org.txm.rcp.editors.ITXMResultEditor;
 import org.txm.rcp.editors.TXMMultiPageEditor;
+import org.txm.utils.logger.Log;
 
 /**
  * Utility class to manage EditorPart.
@@ -333,8 +334,11 @@
 		EModelService service = window.getService(EModelService.class);
 		
 		MUIElement parent = parentPart.getParent();
+		if (parent == null) {
+			Log.warning("Cannot addPart "+partToAdd+" into "+parentPart);
+			return;
+		}
 		
-		
 		while (!(parent instanceof MPartSashContainerElement)) {
 			parent = parent.getParent();
 		}
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java	(revision 3250)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java	(revision 3251)
@@ -1900,8 +1900,9 @@
 		if (this.linkedEditors != null) {
 			if (this.linkedEditors.remove(editor)) {
 				// Debug
-				Log.finest(this.getClass().getSimpleName() + ": A linked editor of type \"" + editor.getClass().getSimpleName() + "\" has been removed from this one. Linked editors count: " //$NON-NLS-1$ //$NON-NLS-2$
-						+ this.linkedEditors.size() + ".");  //$NON-NLS-1$
+				Log.finest(this.getClass().getSimpleName() + ": A linked editor of type \"" + editor.getClass().getSimpleName() + "\" has been removed from this one. Linked editors count: " + this.linkedEditors.size() + "."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+				
+				//this.disconnected(editor);
 			}
 		}
 		if (this.linkedEditors.isEmpty()) {
Index: tmp/org.txm.rcp/plugin.xml
===================================================================
--- tmp/org.txm.rcp/plugin.xml	(revision 3250)
+++ tmp/org.txm.rcp/plugin.xml	(revision 3251)
@@ -1027,8 +1027,9 @@
             <command
                   commandId="org.txm.rcp.commands.workspace.UpdateCorpus"
                   icon="icons/functions/update.png"
-                  label="Re-import corpus"
-                  style="push">
+                  label="Update corpus"
+                  style="push"
+                  tooltip="Only the modified XML-TXM files will update the texts">
                <visibleWhen
                      checkEnabled="false">
                   <or>
@@ -1041,8 +1042,9 @@
             <command
                   commandId="org.txm.rcp.commands.workspace.UpdateCorpus"
                   icon="icons/functions/update.png"
-                  label="Force re-import corpus"
-                  style="push">
+                  label="Force corpus update"
+                  style="push"
+                  tooltip="All texts will be updated from the XML-TXM files">
                <visibleWhen
                      checkEnabled="false">
                   <or>
