Index: TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/annotation/SampleWordsMacro.groovy
===================================================================
--- TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/annotation/SampleWordsMacro.groovy	(revision 0)
+++ TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/macro/annotation/SampleWordsMacro.groovy	(revision 3729)
@@ -0,0 +1,94 @@
+// Copyright © 2021 ENS Lyon
+// Licensed under the terms of the GNU General Public License version 3 (http://www.gnu.org/licenses/gpl-3.0.html)
+// @author mdecorde
+// @author sheiden
+
+package org.txm.macro.annotation
+
+// STANDARD DECLARATIONS
+import org.txm.rcpapplication.swt.widget.parameters.*
+import org.txm.searchengine.cqp.corpus.*
+import org.txm.xml.DOMIdentityHook
+import org.txm.xml.LocalNameHookActivator
+import org.txm.xml.XMLProcessor
+import org.txm.objects.*
+import org.txm.rcp.utils.JobHandler
+import org.txm.rcp.views.corpora.CorporaView
+import org.eclipse.core.runtime.Status
+import org.txm.annotation.kr.core.KRAnnotationEngine
+import org.txm.annotation.kr.core.repository.*
+import org.txm.annotation.kr.rcp.commands.SaveAnnotations
+import org.txm.annotation.kr.rcp.concordance.WordAnnotationToolbar
+import org.txm.importer.StaxIdentityParser
+
+def scriptName = this.class.getSimpleName()
+
+if (!(corpusViewSelection instanceof MainCorpus)) {
+	println "** $scriptName: please select a Corpus in the Corpus view."
+	return 0
+}
+
+MainCorpus mcorpus = corpusViewSelection
+Project project = mcorpus.getProject()
+File txmDir = new File(project.getProjectDirectory(), "txm/"+mcorpus.getName())
+
+@Field @Option(name="nWordsPerText", usage="the number of words per text", widget="Integer", required=true, def="")
+File nWordsPerText
+
+
+@Field @Option(name="debug", usage="Afficher les messages de debug", widget="Boolean", required=true, def="false")
+def debug
+
+// Open the parameters input dialog box
+if (!ParametersDialog.open(this)) return
+
+if (!outputDirectory.exists()) {
+	println "Error: output directory not found: "+outputDirectory
+	return false
+}
+
+values_to_ignore_regex = /$values_to_ignore_regex/
+
+project.compute();
+
+for (Text text : project.getChildren(Text.class)) {
+	println "Text: "+text
+	
+	File orig = text.getXMLTXMFile()
+	if ((orig == null) || !orig.exists()) {
+		println "** Error: no XML-TXM file found for "+text
+		return // next !
+	}
+	
+	File result = new File(outputDirectory, orig.getName())
+	
+	if (false && result.lastModified() > orig.lastModified()) {
+		println "Skipping $text: result file is more recent: $result"
+		continue // next !
+	}
+	
+	XMLProcessor xp = new XMLProcessor(orig);
+	LocalNameHookActivator activator = new LocalNameHookActivator("w")
+
+	nWords = 0
+	new DOMIdentityHook("word", activator, xp) {
+		@Override
+		public void processDom() {
+			//println dom
+			use(groovy.xml.dom.DOMCategory) {
+				nWords++
+				if (nWords >  nWordsPerText) {
+					dom = null
+				}
+			}
+		}
+	}
+	xp.process(result)
+	
+	if (nWords == 0) {
+		println "Removing empty <text>: $text: $result"
+		result.delete()
+	}
+}
+
+println "Done: update the corpus using the 'Corpus > Update' main menu to see the modifications in commnds."
Index: TXM/trunk/bundles/org.txm.searchengine.core/src/org/txm/searchengine/core/QueryHistory.java
===================================================================
--- TXM/trunk/bundles/org.txm.searchengine.core/src/org/txm/searchengine/core/QueryHistory.java	(revision 0)
+++ TXM/trunk/bundles/org.txm.searchengine.core/src/org/txm/searchengine/core/QueryHistory.java	(revision 3729)
@@ -0,0 +1,160 @@
+package org.txm.searchengine.core;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+
+import org.txm.core.preferences.TBXPreferences;
+import org.txm.core.results.TXMParameters;
+import org.txm.core.results.TXMResult;
+import org.txm.objects.Project;
+import org.txm.utils.TXMProgressMonitor;
+import org.txm.utils.io.IOUtils;
+
+public class QueryHistory extends TXMResult {
+	
+	LinkedHashSet<IQuery> queries = new LinkedHashSet<IQuery>(); // first is the older and last is the newer
+	
+	public QueryHistory(String parametersNodePath, TXMResult parent) {
+		super(parametersNodePath, parent);
+	}
+	
+	public QueryHistory(Project corpus) {
+		super(null, corpus);
+	}
+
+	@Override
+	public boolean saveParameters() throws Exception {
+
+		return true;
+	}
+	
+	@Override
+	public boolean isVisible() {
+
+		return true;
+	}
+
+	@Override
+	public boolean loadParameters() throws Exception {
+
+		return true;
+	}
+
+	@Override
+	public boolean setParameters(TXMParameters parameters) throws Exception {
+
+		return true;
+	}
+
+	@Override
+	public String getName() {
+
+		return "Query History";
+	}
+
+	@Override
+	public String getSimpleName() {
+
+		return "Query History";
+	}
+
+	@Override
+	public String getDetails() {
+
+		return "Query history of "+queries.size();
+	}
+
+	@Override
+	public void clean() {
+		
+	}
+
+	@Override
+	public boolean canCompute() throws Exception {
+
+		return true;
+	}
+	
+	public Project getParent() {
+		return (Project) super.getParent();
+	}
+
+	@Override
+	protected boolean _compute(TXMProgressMonitor monitor) throws Exception {
+		queries.clear();
+		
+		File logFile = new File(this.getParent().getProjectDirectory(), "queries.txt");
+		int MAX = TBXPreferences.getInstance().getInt(TBXPreferences.QUERY_HISTORY_SIZE);
+		
+		BufferedReader reader = IOUtils.getReader(logFile);
+		String line = reader.readLine();
+		while (line != null) {
+			line = line.trim();
+			if (line.length() > 0 && !line.startsWith("#")) {
+				IQuery q = Query.stringToQuery(line);
+				queries.add(q);
+			}
+			
+			if (queries.size() > MAX) break;
+			line = reader.readLine();
+		}
+		reader.close();
+		
+		return true;
+	}
+	
+	@SuppressWarnings("unchecked")
+	public <Q extends IQuery> ArrayList<Q> getQueries(Class<Q> clazz) {
+		ArrayList<Q> ret = new ArrayList<Q>();
+		for (IQuery q : queries) {
+			if (clazz == null || q.getClass().isInstance(clazz) || q.getClass().isAssignableFrom(clazz)) {
+				ret.add((Q) q);
+			}
+		}
+		return ret;
+		
+	}
+	
+	public void addQuery(IQuery query) {
+		
+		int MAX = TBXPreferences.getInstance().getInt(TBXPreferences.QUERY_HISTORY_SIZE);
+		reduceSize(MAX - 1); // ensure history size limit
+		queries.add(query);
+	}
+	
+	public void reduceSize(int MAX) {
+		
+		while (queries.size() > MAX && queries.size() > 0) {
+			for (IQuery q : queries) {
+				queries.remove(q);
+				break;  // remove 1 query
+			}
+		}
+	}
+
+	@Override
+	protected boolean _toTxt(File outfile, String encoding, String colseparator, String txtseparator) throws Exception {
+		
+		PrintWriter writer = IOUtils.getWriter(outfile, encoding);
+		for (IQuery q : queries) {
+			writer.println(q);
+		}
+		writer.close();
+		
+		return true;
+	}
+
+	@Override
+	public String getResultType() {
+
+		return "History";
+	}
+
+	public ArrayList<Query> getQueries() {
+		return getQueries(Query.class);
+	}
+
+}

Property changes on: TXM/trunk/bundles/org.txm.searchengine.core/src/org/txm/searchengine/core/QueryHistory.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: TXM/trunk/bundles/org.txm.searchengine.core/src/org/txm/searchengine/core/IQuery.java
===================================================================
--- TXM/trunk/bundles/org.txm.searchengine.core/src/org/txm/searchengine/core/IQuery.java	(revision 3728)
+++ TXM/trunk/bundles/org.txm.searchengine.core/src/org/txm/searchengine/core/IQuery.java	(revision 3729)
@@ -8,7 +8,7 @@
  * @author mdecorde
  *
  */
-public interface IQuery {
+public interface IQuery extends Comparable<IQuery>{
 	
 	public String getQueryString();
 	
Index: TXM/trunk/bundles/org.txm.searchengine.core/src/org/txm/searchengine/core/Query.java
===================================================================
--- TXM/trunk/bundles/org.txm.searchengine.core/src/org/txm/searchengine/core/Query.java	(revision 3728)
+++ TXM/trunk/bundles/org.txm.searchengine.core/src/org/txm/searchengine/core/Query.java	(revision 3729)
@@ -263,4 +263,20 @@
 		}
 		return str.toString();
 	}
+
+	@Override
+	public int compareTo(IQuery o) {
+		
+		int c = this.getSearchEngine().getName().compareTo(o.getSearchEngine().getName());
+		
+		if (c == 0) {
+			c = this.queryString.compareTo(o.getQueryString());
+		}
+		
+		if (c == 0) {
+			c = this.getName().compareTo(o.getName());
+		}
+		
+		return c;
+	}
 }
Index: TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/views/cmdparameters/TXMResultParametersView.java
===================================================================
--- TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/views/cmdparameters/TXMResultParametersView.java	(revision 3728)
+++ TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/views/cmdparameters/TXMResultParametersView.java	(revision 3729)
@@ -281,7 +281,7 @@
 				c = sp;
 			}
 			else if (clazz.equals(IQuery.class)) {
-				final QueryWidget qw = new QueryWidget(panel, SWT.NONE);
+				final QueryWidget qw = new QueryWidget(panel, SWT.NONE, null, null);
 				if (value != null) {
 					qw.setText(((IQuery) value).getQueryString());
 				}
Index: TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/actions/CreateSubcorpusDialog.java
===================================================================
--- TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/actions/CreateSubcorpusDialog.java	(revision 3728)
+++ TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/actions/CreateSubcorpusDialog.java	(revision 3729)
@@ -196,7 +196,7 @@
 		advancedPartLabel.setText(TXMUIMessages.ampQuery);
 		advancedPartLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
 		
-		queryText = new QueryWidget(compositeForAdvanced, SWT.DROP_DOWN);
+		queryText = new QueryWidget(compositeForAdvanced, SWT.DROP_DOWN, corpus.getProject(), null);
 		queryText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
 		GridData gridData = new GridData(GridData.FILL, GridData.CENTER, true, false);
 		gridData.widthHint = convertHeightInCharsToPixels(20);
Index: TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/actions/CreatePartitionDialog.java
===================================================================
--- TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/actions/CreatePartitionDialog.java	(revision 3728)
+++ TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/actions/CreatePartitionDialog.java	(revision 3729)
@@ -524,11 +524,9 @@
 		partNames.add(advancedPartLabel);
 		
 		final QueryWidget queryText;
-		queryText = new QueryWidget(compositeForAdvanced, SWT.DROP_DOWN);
-		queryText.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
-				true, false));
-		GridData gridData = new GridData(GridData.FILL, GridData.FILL, true,
-				false);
+		queryText = new QueryWidget(compositeForAdvanced, SWT.DROP_DOWN, corpus.getProject(), null);
+		queryText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
+		GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, false);
 		// gridData.widthHint = convertHeightInCharsToPixels(20);
 		queryText.setLayoutData(gridData);
 		queries.add(queryText);
Index: TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/preferences/UserPreferencePage.java
===================================================================
--- TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/preferences/UserPreferencePage.java	(revision 3728)
+++ TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/preferences/UserPreferencePage.java	(revision 3729)
@@ -30,7 +30,10 @@
 import org.eclipse.jface.preference.BooleanFieldEditor;
 import org.eclipse.jface.preference.IntegerFieldEditor;
 import org.txm.core.preferences.TBXPreferences;
+import org.txm.objects.Project;
+import org.txm.objects.Workspace;
 import org.txm.rcp.messages.TXMUIMessages;
+import org.txm.searchengine.core.QueryHistory;
 
 /**
  * User preferences page.
@@ -69,5 +72,24 @@
 				.getFieldEditorParent()));
 		
 		this.addField(new IntegerFieldEditor(RCPPreferences.MAX_NUMBER_OF_COLUMNS, "The maximum number of columns shown in tables", this.getFieldEditorParent()));
+		
+		this.addField(new IntegerFieldEditor(TBXPreferences.QUERY_HISTORY_SIZE, "The maximum number of query stored in the query history", this.getFieldEditorParent()));
 	}
+	
+	@Override
+	public boolean performOk() {
+		boolean ret = super.performOk();
+		if (ret) {
+			
+			int MAX = TBXPreferences.getInstance().getInt(TBXPreferences.QUERY_HISTORY_SIZE);
+			for (Project p : Workspace.getInstance().getProjects()) {
+				QueryHistory h = p.getFirstChild(QueryHistory.class);
+				if (h != null) {
+					h.reduceSize(MAX);
+				}
+			}
+		}
+		
+		return ret;
+	}
 }
Index: TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/QueryWidget.java
===================================================================
--- TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/QueryWidget.java	(revision 3728)
+++ TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/QueryWidget.java	(revision 3729)
@@ -27,14 +27,19 @@
 //
 package org.txm.rcp.swt.widget;
 
+import java.util.ArrayList;
 import java.util.Deque;
 import java.util.LinkedList;
 
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
+import org.txm.objects.Project;
 import org.txm.searchengine.core.IQuery;
+import org.txm.searchengine.core.Query;
+import org.txm.searchengine.core.QueryHistory;
 import org.txm.searchengine.core.SearchEngine;
 import org.txm.searchengine.core.SearchEnginesManager;
+import org.txm.searchengine.cqp.CQPSearchEngine;
 
 // TODO: Auto-generated Javadoc
 /**
@@ -46,56 +51,111 @@
  * 
  */
 public class QueryWidget extends Combo {
-	
+
 	SearchEngine se;
-	
+	Project project;
+	private QueryHistory h;
+
 	/** The history. */
 	private static Deque<String> history = new LinkedList<>();
-	
+
 	/**
 	 * Instantiates a new query widget.
 	 *
 	 * @param parent the parent
-	 * @param style the style
+	 * @param style  the style
 	 */
-	public QueryWidget(Composite parent, int style, SearchEngine se) {
+	public QueryWidget(Composite parent, int style, Project project, SearchEngine se) {
+		
 		super(parent, style);
 		this.se = se;
-		this.setItems(history.toArray(new String[history.size()]));
+		this.project = project;
+
+		loadHistory();
 	}
 	
-	public QueryWidget(Composite composite, int style) {
-		this(composite, style, SearchEnginesManager.getCQPSearchEngine());
+	public void loadHistory() {
+
+		h = null;
+		
+//		if (this.project != null) {
+//			h = this.project.getFirstChild(QueryHistory.class);
+//
+//			if (h == null) {
+//				h = new QueryHistory(project);
+//			}
+//		}
+//		
+//		try { // load history from queries.txt file
+//			h.compute(false);
+//		} catch (InterruptedException e) {
+//			// TODO Auto-generated catch block
+//			e.printStackTrace();
+//		}
+		
+		setHistoryItems();
 	}
 	
+	private void setHistoryItems() {
+		
+		if (this.h != null) {
+
+			ArrayList<? extends Query> queries = null;
+			if (se != null) { // get onlny the queries of the current searchengine
+				queries = h.getQueries(se.newQuery().getClass());
+			} else { // get all queries
+				queries = h.getQueries();
+			}
+
+			String[] strings = new String[queries.size()];
+			for (int i = 0; i < queries.size(); i++) {
+				strings[i] = queries.get(queries.size() - i - 1).getQueryString();
+			}
+			this.setItems(strings);
+		} else { // get the general query history
+			this.setItems(history.toArray(new String[history.size()]));
+		}
+	}
+
+	// public QueryWidget(Composite composite, int style) {
+	// this(composite, style, SearchEnginesManager.getCQPSearchEngine());
+	// }
+
 	/**
 	 * Set the SearchEngine to use with query
+	 * 
 	 * @param se
 	 */
 	public void setSearchEngine(SearchEngine se) {
+		
+		if (this.se == se) return;
+		
 		this.se = se;
-//		if (se.newQuery().canBeMultiLine()) {
-//			Object l = this.getLayoutData(); // cannot change the widget style -> maybe use a ComboViewer OR recreate a widget (so the setSearchEngine must be moved)
-//			if (l instanceof GridData) {
-//				GridData gd = (GridData)l;
-//				gd.minimumHeight = this.getSize().y * 2;
-//			}
-//			this.layout();
-//		} else {
-//			Object l = this.getLayoutData(); // cannot change the widget style -> maybe use a ComboViewer  OR recreate a widget (so the setSearchEngine must be moved)
-//			if (l instanceof GridData) {
-//				GridData gd = (GridData)l;
-//				gd.minimumHeight = this.getSize().y / 2;
-//			}
-//			this.layout();
-//		}
+
+		loadHistory();
+		// if (se.newQuery().canBeMultiLine()) {
+		// Object l = this.getLayoutData(); // cannot change the widget style -> maybe
+		// use a ComboViewer OR recreate a widget (so the setSearchEngine must be moved)
+		// if (l instanceof GridData) {
+		// GridData gd = (GridData)l;
+		// gd.minimumHeight = this.getSize().y * 2;
+		// }
+		// this.layout();
+		// } else {
+		// Object l = this.getLayoutData(); // cannot change the widget style -> maybe
+		// use a ComboViewer OR recreate a widget (so the setSearchEngine must be moved)
+		// if (l instanceof GridData) {
+		// GridData gd = (GridData)l;
+		// gd.minimumHeight = this.getSize().y / 2;
+		// }
+		// this.layout();
+		// }
 	}
-	
-	
+
 	public SearchEngine getSearchEngine() {
 		return this.se;
 	}
-	
+
 	/**
 	 * Gets the CQP query string inferred from the user input.
 	 *
@@ -105,64 +165,87 @@
 		String rawQuery;
 		if (getSelectionIndex() < 0) {
 			rawQuery = getText();
-		}
-		else {
+		} else {
 			rawQuery = this.getItem(this.getSelectionIndex());
 		}
 		return se.newQuery().setQuery(rawQuery).getQueryString();
 	}
-	
+
 	/**
 	 * Memorize.
 	 */
 	public void memorize() {
+		
 		String inputString;
 		if (getSelectionIndex() == -1) {
 			inputString = getText();
-		}
-		else {
+		} else {
 			inputString = getItems()[getSelectionIndex()];
 		}
-		history.remove(inputString);
-		history.addFirst(inputString);
-		this.setItems(history.toArray(new String[history.size()]));
+		
+		if (inputString == null || inputString.length() == 0) return;
+		
+		if (h != null && se != null && project != null) {
+			Query q = se.newQuery();
+			q.setQuery(inputString);
+			h.addQuery(q);
+		} else {
+			history.remove(inputString);
+			history.addFirst(inputString);
+		}
+		
+		setHistoryItems();
 		this.setText(this.getItem(0));
 	}
-	
+
 	/**
 	 * Memorize.
 	 *
 	 * @param query the query to memorize
 	 */
 	public void memorize(String query) {
+		
 		String inputString = query;
 		this.setText(query);
 		history.remove(inputString);
 		history.addFirst(inputString);
 		this.setItems(history.toArray(new String[history.size()]));
 		this.setText(this.getItem(0));
+
+		if (h != null && se != null && project != null) {
+			Query q = se.newQuery();
+			q.setQuery(inputString);
+			h.addQuery(q);
+		}
 	}
-	
+
 	/*
 	 * (non-Javadoc)
+	 * 
 	 * @see org.eclipse.swt.widgets.Combo#checkSubclass()
 	 */
 	@Override
 	protected void checkSubclass() {
-		
+
 	}
-	
+
 	/**
 	 * Gets the query.
 	 *
-	 * @return the query
+	 * @return the query or null if no query is set
 	 */
 	public IQuery getQuery() {
-		if (!this.getQueryString().isEmpty()) {
+
+		if (this.getQueryString().isEmpty()) {
+			return null;
+		}
+
+		if (se != null) {
 			return se.newQuery().setQuery(this.getQueryString());
+		} else {
+			Query q = new Query();
+			q.setQuery(this.getQueryString());
+			return q;
 		}
-		else {
-			return null;
-		}
 	}
 }
Index: TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/AssistedQueryWidget.java
===================================================================
--- TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/AssistedQueryWidget.java	(revision 3728)
+++ TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/AssistedQueryWidget.java	(revision 3729)
@@ -101,7 +101,7 @@
 			public void widgetDefaultSelected(SelectionEvent e) {}
 		});
 		
-		querywidget = new QueryWidget(this, style, se);
+		querywidget = new QueryWidget(this, style, corpus.getProject(), se);
 		querywidget.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
 	}
 	
Index: TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/NamedAssistedQueryWidget.java
===================================================================
--- TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/NamedAssistedQueryWidget.java	(revision 3728)
+++ TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/NamedAssistedQueryWidget.java	(revision 3729)
@@ -45,7 +45,6 @@
 import org.txm.searchengine.cqp.corpus.CQPCorpus;
 
 
-// TODO: Auto-generated Javadoc
 /**
  * the QueryWidget plus the button to open the QueryAssisDialog @ author
  * mdecorde.
@@ -88,8 +87,7 @@
 		magicstick.addSelectionListener(new SelectionListener() {
 			@Override
 			public void widgetSelected(SelectionEvent e) {
-				QueryAssistDialog d = new QueryAssistDialog(e.display
-						.getActiveShell(), corpus);
+				QueryAssistDialog d = new QueryAssistDialog(e.display.getActiveShell(), corpus);
 				// System.out.println(d);
 				if (d.open() == Window.OK) {
 					querywidget.setText(d.getQuery());
@@ -102,7 +100,7 @@
 			}
 		});
 		
-		querywidget = new QueryWidget(this, style);
+		querywidget = new QueryWidget(this, style, corpus.getProject(), null);
 		querywidget.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, true));
 	}
 
Index: TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/parameters/QueryField.java
===================================================================
--- TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/parameters/QueryField.java	(revision 3728)
+++ TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/parameters/QueryField.java	(revision 3729)
@@ -25,7 +25,7 @@
 		gd.widthHint = 100;
 		l.setLayoutData(gd);
 
-		w = new QueryWidget(this, SWT.BORDER);
+		w = new QueryWidget(this, SWT.BORDER, null, null);
 		w.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, false));
 		resetToDefault();
 	}
Index: TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/AssistedChoiceQueryWidget.java
===================================================================
--- TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/AssistedChoiceQueryWidget.java	(revision 3728)
+++ TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/AssistedChoiceQueryWidget.java	(revision 3729)
@@ -173,7 +173,7 @@
 		
 		setMagicEnabled("CQP".equals(initialEngine.getName())); //$NON-NLS-1$
 		
-		querywidget = new QueryWidget(this, style, initialEngine);
+		querywidget = new QueryWidget(this, style, corpus.getProject(), initialEngine);
 		querywidget.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
 	}
 	
Index: TXM/trunk/bundles/org.txm.core/src/java/org/txm/core/preferences/TBXPreferences.java
===================================================================
--- TXM/trunk/bundles/org.txm.core/src/java/org/txm/core/preferences/TBXPreferences.java	(revision 3728)
+++ TXM/trunk/bundles/org.txm.core/src/java/org/txm/core/preferences/TBXPreferences.java	(revision 3729)
@@ -174,6 +174,8 @@
 
 	public static final String CLIPBOARD_IMPORT_ASK_LANG = "clipboard_import_ask_lang";
 
+	public static final String QUERY_HISTORY_SIZE = "query_history_size";
+
 	/**
 	 * Gets the instance.
 	 * 
@@ -236,5 +238,6 @@
 		preferences.put(RAWFILESSITE, "https://gitlab.huma-num.fr/txm/txm-software/-/raw/master/files/");
 		preferences.put(FILESSITE, "https://txm.gitpages.huma-num.fr/textometrie/files/");
 
+		preferences.putInt(TBXPreferences.QUERY_HISTORY_SIZE, 100);
 	}
 }
Index: TXM/trunk/bundles/org.txm.core/src/java/org/txm/core/results/TXMResult.java
===================================================================
--- TXM/trunk/bundles/org.txm.core/src/java/org/txm/core/results/TXMResult.java	(revision 3728)
+++ TXM/trunk/bundles/org.txm.core/src/java/org/txm/core/results/TXMResult.java	(revision 3729)
@@ -1607,7 +1607,7 @@
 	 * @param clazz
 	 * @return the first child if exists otherwise null
 	 */
-	public <T extends TXMResult> TXMResult getFirstChild(Class<T> clazz) {
+	public <T extends TXMResult> T getFirstChild(Class<T> clazz) {
 		List<T> children = this.getChildren(clazz, false);
 		try {
 			return children.get(0);
Index: TXM/trunk/bundles/org.txm.core/src/java/org/txm/objects/SavedQuery.java
===================================================================
--- TXM/trunk/bundles/org.txm.core/src/java/org/txm/objects/SavedQuery.java	(revision 3728)
+++ TXM/trunk/bundles/org.txm.core/src/java/org/txm/objects/SavedQuery.java	(revision 3729)
@@ -55,7 +55,6 @@
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 
-// TODO: Auto-generated Javadoc
 /**
  * contains a query and examples of results @ author mdecorde.
  */
@@ -100,6 +99,7 @@
 	}
 	
 	protected boolean setParameters(Element pElement) {
+		
 		this.setUserName(pElement.getAttribute("name")); //$NON-NLS-1$
 		this.pValue = pElement.getAttribute("value"); //$NON-NLS-1$
 		this.examples = new ArrayList<>();
