Index: TXM/trunk/bundles/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputeSubCorpus.java
===================================================================
--- TXM/trunk/bundles/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputeSubCorpus.java	(revision 3975)
+++ TXM/trunk/bundles/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputeSubCorpus.java	(revision 3976)
@@ -34,6 +34,7 @@
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.window.Window;
 import org.eclipse.osgi.util.NLS;
@@ -171,11 +172,17 @@
 						monitor.beginTask(TXMUIMessages.creatingASubcorpusInTheSearchEngine, 100);
 						final Subcorpus subcorpus;
 						
-						if (d.isAdvancedSelected() || d.isAssistedSelected()) {
+						if (d.getMode() == 1 || d.getMode() == 2 || d.getMode() == 3) {
+							
+							// test if a query has been set
+							if (d.getQuery().length() == 0) {
+								Log.warning(TXMUIMessages.queryCannotBeLeftEmpty);
+								return Status.CANCEL_STATUS;
+							}
+							
 							CQLQuery q = new CQLQuery(d.getQuery());
 							
 							// System.out.println(NLS.bind(TXMUIMessages.computeSubCorpusOnP0QueryColonP1, corpus.getName(), q.getQueryString()));
-							
 							subcorpus = corpus.createSubcorpus(q, d.getName());
 						}
 						else {
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 3975)
+++ TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/actions/CreateSubcorpusDialog.java	(revision 3976)
@@ -49,6 +49,7 @@
 import org.eclipse.swt.widgets.Text;
 import org.txm.rcp.messages.TXMUIMessages;
 import org.txm.rcp.swt.widget.ComplexSubcorpusPanel;
+import org.txm.rcp.swt.widget.ContextsSubcorpusPanel;
 import org.txm.rcp.swt.widget.QueryWidget;
 import org.txm.rcp.swt.widget.structures.SimpleSubcorpusPanel;
 import org.txm.searchengine.cqp.CQPSearchEngine;
@@ -70,39 +71,38 @@
 	// List<StructuralUnitProperty> selectableStructuralUnitProperties = null;
 	/** The selected structural unit property. */
 	// private StructuralUnitProperty selectedStructuralUnitProperty;
-	
+
 	/** The selected values. */
 	// private List<String> selectedValues;
-	
+
 	// For the assisted tab
 	/** The simple and complex panels. */
 	SimpleSubcorpusPanel simplePanel;
-	
+
 	ComplexSubcorpusPanel complexPanel;
-	
+
+	ContextsSubcorpusPanel contextsPanel;
+
 	// For the "advanced" tab
 	/** The query text. */
 	private QueryWidget queryText;
-	
+
 	/** The query string. */
 	private String queryString;
-	
+
 	// for both tab
 	/** The name. */
 	private Text name;
-	
+
 	/** The name string. */
 	private String nameString;
-	
+
 	/** The corpus. */
 	private CQPCorpus corpus;
-	
-	/** The is advanced selected. */
-	private boolean isAdvancedSelected = false;
-	
+
 	/** The assisted selected. */
-	private boolean assistedSelected = false;
-	
+	private int subcorpusMode = 0;
+
 	/**
 	 * Instantiates a new creates the subcorpus dialog.
 	 *
@@ -114,7 +114,7 @@
 		this.corpus = corpus;
 		this.setShellStyle(this.getShellStyle() | SWT.RESIZE);
 	}
-	
+
 	/*
 	 * (non-Javadoc)
 	 * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
@@ -125,26 +125,26 @@
 		newShell.setText(TXMUIMessages.createSubcorpus);
 		newShell.setMinimumSize(300, 300);
 	}
-	
+
 	/** The structural units final. */
 	List<StructuralUnit> structuralUnitsFinal;
-	
+
 	/** The structural units combo. */
 	Combo structuralUnitsCombo;
-	
+
 	/** The property combo. */
 	Combo propertyCombo;
-	
+
 	/** The value combo. */
 	org.eclipse.swt.widgets.List valueCombo;
-	
+
 	/*
 	 * (non-Javadoc)
 	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
 	 */
 	@Override
 	protected Control createDialogArea(Composite parent) {
-		
+
 		Composite inclosing = new Composite(parent, SWT.NONE);
 		// TODO : we just put a composite into another composite. Everything
 		// should be directly put into parent
@@ -153,130 +153,122 @@
 		layout4inclosing.horizontalSpacing = 0;
 		inclosing.setLayout(layout4inclosing);
 		inclosing.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
-		
+
 		// name panel
 		Composite nameComposite = new Composite(inclosing, SWT.NONE);
 		nameComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
 		GridLayout layout4nameComposite = new GridLayout(2, false);
 		nameComposite.setLayout(layout4nameComposite);
-		
+
 		Label nameLabel = new Label(nameComposite, SWT.NONE);
 		nameLabel.setText(TXMUIMessages.ampNameColon);
 		nameLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
-		
+
 		name = new Text(nameComposite, SWT.BORDER);
 		name.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
-		
+
 		// Param panel
 		final TabFolder tabFolder = new TabFolder(inclosing, SWT.NONE);
 		tabFolder.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
-		
+
 		// First tab
 		TabItem simpleTab = new TabItem(tabFolder, SWT.NONE);
 		simpleTab.setText(TXMUIMessages.simple);
 		simplePanel = new SimpleSubcorpusPanel(tabFolder, SWT.NONE, this.getButton(IDialogConstants.OK_ID), corpus);
 		simpleTab.setControl(simplePanel);
-		
+
 		// Second tab: assisted mode
 		TabItem secondTab = new TabItem(tabFolder, SWT.NONE);
 		secondTab.setText(TXMUIMessages.assisted);
 		this.complexPanel = new ComplexSubcorpusPanel(tabFolder, SWT.NONE, this.corpus);
 		secondTab.setControl(complexPanel);
-		
+
+		// Third tab: assisted mode
+		TabItem thirdTab = new TabItem(tabFolder, SWT.NONE);
+		thirdTab.setText(TXMUIMessages.contexts);
+		this.contextsPanel = new ContextsSubcorpusPanel(tabFolder, SWT.NONE, this.corpus);
+		thirdTab.setControl(contextsPanel);
+
 		// Third tab: advanced mode
 		TabItem advancedTab = new TabItem(tabFolder, SWT.NONE);
 		advancedTab.setText(TXMUIMessages.advanced);
-		
+
 		Composite compositeForAdvanced = new Composite(tabFolder, SWT.NONE);
 		advancedTab.setControl(compositeForAdvanced);
-		
+
 		GridLayout layoutForAdvanced = new GridLayout(3, false);
 		compositeForAdvanced.setLayout(layoutForAdvanced);
-		
+
 		Label advancedPartLabel = new Label(compositeForAdvanced, SWT.NONE);
 		advancedPartLabel.setText(TXMUIMessages.ampQuery);
 		advancedPartLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
-		
+
 		queryText = new QueryWidget(compositeForAdvanced, SWT.DROP_DOWN, corpus.getProject(), CQPSearchEngine.getEngine());
 		queryText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
 		GridData gridData = new GridData(GridData.FILL, GridData.CENTER, true, false);
 		gridData.widthHint = convertHeightInCharsToPixels(20);
 		queryText.setLayoutData(gridData);
-		
+
 		// check the state of the OK button according to the change of tab
 		// --------------------------------
-		
+
 		tabFolder.addSelectionListener(new SelectionListener() {
-			
+
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {}
-			
+
 			@Override
 			public void widgetSelected(SelectionEvent e) {
-				if (tabFolder.getSelectionIndex() == 0) {
-					isAdvancedSelected = false;
-					assistedSelected = false;
-				}
-				else if (tabFolder.getSelectionIndex() == 1) {
-					isAdvancedSelected = false;
-					assistedSelected = true;
-				}
-				else {
-					isAdvancedSelected = true;
-					assistedSelected = false;
-				}
+
+				subcorpusMode = tabFolder.getSelectionIndex();
 			}
 		});
-		
+
 		return tabFolder;
 	}
-	
-	
-	
+
+
+
 	@Override
 	public Button getButton(int id) {
 		return super.getButton(id);
 	}
-	
+
 	/*
 	 * (non-Javadoc)
 	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
 	 */
 	@Override
 	protected void okPressed() {
-		
+
 		// auto-naming if needed
 		if (name.getText().length() == 0) {
 			String autoName = "subcorpus"; //$NON-NLS-1$
-			
+
 			// Advanced mode
-			if (isAdvancedSelected()) {
-				autoName += "" + (this.corpus.getSubcorpora().size() + 1); //$NON-NLS-1$
+			if (subcorpusMode == 0) {
+				autoName = this.simplePanel.getGeneratedName();
 			}
 			// Assisted mode (structure@property=1st_value)
-			else if (assistedSelected) {
+			else if (subcorpusMode == 1) {
 				autoName = this.complexPanel.getGeneratedName();
 			}
-			// Simple mode (structure@property=1st_value)
-			else {
-				autoName = getStructuralUnitProperty().asFullNameString() + "=" + getValues().get(0); //$NON-NLS-1$
+			else if (subcorpusMode == 2) {
+				autoName = this.contextsPanel.getGeneratedName();
+			} 
+			else if (subcorpusMode == 3) {
+				autoName += "" + (this.corpus.getSubcorpora().size() + 1); //$NON-NLS-1$
+			} else {
+				autoName = this.complexPanel.getGeneratedName();
 			}
 			
 			Log.info(NLS.bind(TXMUIMessages.noSubcorpusNameWasSpecifiedWeveGeneratedOneP0, autoName));
-			
+
 			name.setText(autoName);
 		}
-		
-		// test if a query has been set
-		if ((isAdvancedSelected()) && queryText.getText().length() == 0) {
-			MessageDialog.openError(getShell(), TXMUIMessages.invalidQuery, TXMUIMessages.queryCannotBeLeftEmpty);
-			return;
-		}
-		
-		queryString = queryText.getQueryString();
-		// queryText.memorize();
-		
-		if (assistedSelected) {
+
+		if (subcorpusMode == 1) {
+
 			// System.out.println("1 "+queryString);
 			queryString = this.complexPanel.getQueryFieldValue();
 			// System.out.println("2 "+queryString);
@@ -288,78 +280,67 @@
 					return;
 				}
 			}
+
+		} else if (subcorpusMode == 2) {
+
+			queryString = this.contextsPanel.getQueryString();
+		} else if (subcorpusMode == 3) {
+
+			queryString = queryText.getQueryString();
 		}
-		
+
 		nameString = name.getText();
 		super.okPressed();
 	}
-	
+
 	/**
-	 * Tell if the user is using the "advanced" tab.
-	 *
-	 * @return true, if is advanced selected
-	 */
-	public boolean isAdvancedSelected() {
-		return isAdvancedSelected;
-	}
-	
-	/**
-	 * Tell if the user is using the "assisted" tab.
-	 *
-	 * @return true, if is assisted selected
-	 */
-	public boolean isAssistedSelected() {
-		return assistedSelected;
-	}
-	
-	/**
 	 * Gets the structural unit.
 	 *
 	 * @return the structural unit
 	 */
 	public StructuralUnit getStructuralUnit() {
-		if (isAdvancedSelected()) {
+		if (subcorpusMode == 3) {
 			throw new IllegalStateException(TXMUIMessages.cannotAskForTheSimpleTabWhenTheUserHasSelectedTheAdvancedTab);
 		}
 		return simplePanel.selectedStructuralUnit;
 	}
-	
+
 	/**
 	 * Gets the structural unit property.
 	 *
 	 * @return the structural unit property
 	 */
 	public StructuralUnitProperty getStructuralUnitProperty() {
-		if (isAdvancedSelected()) {
+		if (subcorpusMode == 2 || subcorpusMode == 3) {
 			throw new IllegalStateException(TXMUIMessages.cannotAskForTheSimpleTabWhenTheUserHasSelectedTheAdvancedTab);
 		}
 		return simplePanel.selectedStructuralUnitProperty;
 	}
-	
+
 	/**
 	 * Gets the values.
 	 *
 	 * @return the values
 	 */
 	public List<String> getValues() {
-		if (isAdvancedSelected()) {
+		if (subcorpusMode == 2 || subcorpusMode == 3) {
 			throw new IllegalStateException(TXMUIMessages.cannotAskForTheSimpleTabWhenTheUserHasSelectedTheAdvancedTab);
 		}
 		return simplePanel.selectedValues;
 	}
-	
+
 	/**
 	 * Gets the query.
 	 *
 	 * @return the query
 	 */
 	public String getQuery() {
-		if (isAdvancedSelected() == false && isAssistedSelected() == false) {
+		if (subcorpusMode == 0 ) {
 			throw new IllegalStateException(TXMUIMessages.cannotAskForTheSimpleTabWhenTheUserHasSelectedTheAdvancedTab);
 		}
 		return queryString;
 	}
-	
+
 	/**
 	 * Gets the name.
 	 *
@@ -368,7 +349,7 @@
 	public String getName() {
 		return nameString;
 	}
-	
+
 	/**
 	 * Gets the sub corpus name.
 	 *
@@ -377,4 +358,9 @@
 	public String getSubCorpusName() {
 		return name.getText();
 	}
+
+	public int getMode() {
+
+		return subcorpusMode;
+	}
 }
Index: TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/messages/TXMUIMessages.java
===================================================================
--- TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/messages/TXMUIMessages.java	(revision 3975)
+++ TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/messages/TXMUIMessages.java	(revision 3976)
@@ -278,6 +278,8 @@
 	public static String contextColon;
 	
 	public static String contextsDisplayOptions;
+	
+	public static String contexts;
 
 
 	public static String contextSize;
Index: TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages.properties
===================================================================
--- TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages.properties	(revision 3975)
+++ TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages.properties	(revision 3976)
@@ -527,6 +527,7 @@
 downloadingTheP0File=Downloading file {0}...
 noTextInCorpusColonP0=** No {0} text in the corpus.
 contextsDisplayOptions=Contexts display options
+contexts=Contexts
 errorWhileComputingCorpusSummary=** Error while computing corpus properties
 selectValuesToAssignColon=Select the values to assign\: 
 CopingFilesP0=Copying files\: {0}
Index: TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages_fr.properties
===================================================================
--- TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages_fr.properties	(revision 3975)
+++ TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages_fr.properties	(revision 3976)
@@ -528,6 +528,7 @@
 downloadingTheP0File=Téléchargement du fichier {0}...
 noTextInCorpusColonP0=** Aucun texte {0} dans le corpus.
 contextsDisplayOptions=Options d'affichage des contextes
+contexts=Contextes
 errorWhileComputingCorpusSummary=** Erreur lors du calcul des propriétés du corpus
 selectValuesToAssignColon=Sélectionner les valeurs à affecter \: 
 CopingFilesP0=Copie des fichiers \: {0}
Index: TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/structures/SimpleSubcorpusPanel.java
===================================================================
--- TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/structures/SimpleSubcorpusPanel.java	(revision 3975)
+++ TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/structures/SimpleSubcorpusPanel.java	(revision 3976)
@@ -4,6 +4,7 @@
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.commons.lang.StringUtils;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.ISelection;
@@ -29,6 +30,8 @@
 import org.txm.searchengine.cqp.corpus.query.SubcorpusCQLQuery;
 import org.txm.utils.logger.Log;
 
+import cern.colt.Arrays;
+
 public class SimpleSubcorpusPanel extends Composite {
 
 	public StructuralUnit selectedStructuralUnit;
@@ -200,8 +203,7 @@
 	 */
 	protected void reloadProperties() {
 
-		selectedStructuralUnit = structuralUnitsFinal.get(structuralUnitsCombo
-				.getSelectionIndex());
+		selectedStructuralUnit = structuralUnitsFinal.get(structuralUnitsCombo.getSelectionIndex());
 
 		selectableStructuralUnitProperties = 
 				new ArrayList<StructuralUnitProperty>(selectedStructuralUnit.getOrderedProperties());
@@ -242,4 +244,9 @@
 		return query.getQueryString();
 	}
 
+	public String getGeneratedName() {
+
+		return structuralUnitsCombo.getText()+"@"+propertyCombo.getText() + "="+StringUtils.join(valueCombo.getList().getSelection(), ", ");
+	}
+
 }
\ No newline at end of file
