Index: tmp/org.txm.partition.rcp/.classpath
===================================================================
--- tmp/org.txm.partition.rcp/.classpath	(revision 2549)
+++ tmp/org.txm.partition.rcp/.classpath	(revision 2550)
@@ -1,13 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry kind="con"
-		path="org.eclipse.jdt.launching.JRE_CONTAINER" />
-	<classpathentry kind="con"
-		path="org.eclipse.pde.core.requiredPlugins">
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry exported="true" kind="con" path="org.eclipse.pde.core.requiredPlugins">
 		<accessrules>
-			<accessrule kind="accessible" pattern="**" />
+			<accessrule kind="accessible" pattern="**"/>
 		</accessrules>
 	</classpathentry>
-	<classpathentry kind="src" path="src" />
-	<classpathentry kind="output" path="bin" />
-</classpath>
\ No newline at end of file
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
Index: tmp/org.txm.partition.rcp/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.partition.rcp/META-INF/MANIFEST.MF	(revision 2549)
+++ tmp/org.txm.partition.rcp/META-INF/MANIFEST.MF	(revision 2550)
@@ -11,4 +11,3 @@
 Bundle-ManifestVersion: 2
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-Vendor: Textometrie.org
-
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/actions/CreateSubcorpusDialog.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/actions/CreateSubcorpusDialog.java	(revision 2549)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/actions/CreateSubcorpusDialog.java	(revision 2550)
@@ -30,6 +30,7 @@
 import java.util.List;
 
 import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionEvent;
@@ -168,7 +169,7 @@
 		// First tab
 		TabItem simpleTab = new TabItem(tabFolder, SWT.NONE);
 		simpleTab.setText(TXMUIMessages.simple);
-		simplePanel = new SimpleSubcorpusPanel(tabFolder, SWT.NONE, this, corpus);
+		simplePanel = new SimpleSubcorpusPanel(tabFolder, SWT.NONE, this.getButton(IDialogConstants.OK_ID), corpus);
 		simpleTab.setControl(simplePanel);
 		
 		// Second tab: assisted mode
@@ -229,7 +230,7 @@
 	
 	@Override
 	public Button getButton(int id) {
-		return this.getButton(id);
+		return super.getButton(id);
 	}
 	
 	/*
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorToolBar.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorToolBar.java	(revision 2549)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorToolBar.java	(revision 2550)
@@ -200,6 +200,7 @@
 			public void widgetSelected(SelectionEvent e) {
 				if (e.doit) {
 					setVisible(groupTitle, openCloseButton.getSelection());
+					selectionListener.widgetSelected(e);
 				}
 			}
 
@@ -208,7 +209,7 @@
 		});
 		
 		org.txm.rcp.swt.listeners.DropdownSelectionListener listenerOne = openCloseButton.getDropDownListener();
-		listenerOne.setDefaultSelectionListener(selectionListener);
+		//listenerOne.setDefaultSelectionListener(selectionListener);
 		for (int i = 0 ; i < modes.size() && i < modeSelectionListeners.size(); i++) {
 			MenuItem item1 = new MenuItem(listenerOne.getMenu(), SWT.PUSH);
 			item1.setText(modes.get(i));
@@ -334,5 +335,12 @@
 		    c.setEnabled(enabled);
 		}
 	}
-	
+
+	public boolean isVisible(String id) {
+		if (!groups.containsKey(id)) return false;
+		
+		if (groups.get(id).isDisposed()) return false;
+		
+		return groups.get(id).isVisible();
+	}
 }
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/listeners/DropdownSelectionListener.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/listeners/DropdownSelectionListener.java	(revision 2549)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/listeners/DropdownSelectionListener.java	(revision 2550)
@@ -34,7 +34,9 @@
 			menu.setVisible(true);
 			event.doit = false;
 		} else {
-			defaultListener.widgetSelected(event);
+			if (defaultListener != null) {
+				defaultListener.widgetSelected(event);
+			}
 		}
 	}
 }
\ No newline at end of file
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/toolbar/DropDownCheckToolItem.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/toolbar/DropDownCheckToolItem.java	(revision 2549)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/toolbar/DropDownCheckToolItem.java	(revision 2550)
@@ -53,13 +53,7 @@
 					return; // drop down clicked
 				}
 				selected = !selected;
-				if (closeIcon != null) {
-					if (getSelection()) {
-						setImage(closeIcon);
-					} else {
-						setImage(openIcon);
-					}
-				}
+				updateIcon();
 			}
 			
 			@Override
@@ -70,6 +64,16 @@
 		this.addSelectionListener(listener);
 	}
 	
+	public void updateIcon() {
+		if (closeIcon != null) {
+			if (getSelection()) {
+				setImage(closeIcon);
+			} else {
+				setImage(openIcon);
+			}
+		}
+	}
+
 	public boolean getSelection() {
 		return selected;
 	}
@@ -80,6 +84,7 @@
 	
 	public void setSelection(boolean selected) {
 		this.selected = selected;
+		updateIcon();
 	}
 	
 	@Override
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/structures/SimpleSubcorpusPanel.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/structures/SimpleSubcorpusPanel.java	(revision 2549)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/structures/SimpleSubcorpusPanel.java	(revision 2550)
@@ -14,6 +14,7 @@
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
@@ -24,6 +25,8 @@
 import org.txm.searchengine.cqp.corpus.CQPCorpus;
 import org.txm.searchengine.cqp.corpus.StructuralUnit;
 import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
+import org.txm.searchengine.cqp.corpus.query.CQLQuery;
+import org.txm.searchengine.cqp.corpus.query.SubcorpusCQLQuery;
 import org.txm.utils.logger.Log;
 
 public class SimpleSubcorpusPanel extends Composite {
@@ -36,15 +39,15 @@
 	Combo structuralUnitsCombo;
 	Combo propertyCombo;
 	ListViewer valueCombo;
-	
+
 	List<StructuralUnit> structuralUnitsFinal;
-	private CreateSubcorpusDialog dialog;
+	private Button validationButton;
 	private CQPCorpus corpus;
 
-	public SimpleSubcorpusPanel(Composite parent, int style, CreateSubcorpusDialog dialog, CQPCorpus corpus) {
+	public SimpleSubcorpusPanel(Composite parent, int style, Button validationButton, CQPCorpus corpus) {
 		super(parent, style);
 
-		this.dialog = dialog;
+		this.validationButton = validationButton;
 		this.corpus = corpus;
 
 		GridLayout layout = new GridLayout(2, false);
@@ -71,19 +74,19 @@
 
 		valueCombo = new ListViewer(this, SWT.MULTI |SWT.V_SCROLL | SWT.BORDER | SWT.VIRTUAL);
 		valueCombo.setContentProvider(new ArrayContentProvider());
-//		valueCombo.setLabelProvider(new LabelProvider() {
-//
-//	        @Override
-//	        public String getText(Object element) {
-//	            return Activator.getSomeService().key2Value((Integer) element);
-//	        }
-//
-//	    });
+		//		valueCombo.setLabelProvider(new LabelProvider() {
+		//
+		//	        @Override
+		//	        public String getText(Object element) {
+		//	            return Activator.getSomeService().key2Value((Integer) element);
+		//	        }
+		//
+		//	    });
 		GridData data = new GridData(GridData.FILL,GridData.FILL, true, false);
 		data.heightHint = 100;
 		valueCombo.getList().setLayoutData(data);
-	
 
+
 		// Load StructuralUnit
 		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 		List<StructuralUnit> structuralUnits = null;
@@ -108,7 +111,9 @@
 		}
 
 		if (structuralUnitsCombo.getItemCount() == 0) {
-			dialog.getButton(IDialogConstants.OK_ID).setEnabled(false);
+			if(validationButton != null) {
+				validationButton.setEnabled(false);
+			}
 		} else {
 			String[] items = structuralUnitsCombo.getItems();
 			structuralUnitsCombo.select(0);
@@ -165,11 +170,11 @@
 					selectedValues = ((IStructuredSelection)sel).toList();
 				}
 			}
-			
+
 			@Override
 			public void widgetDefaultSelected(SelectionEvent e) {
 				// TODO Auto-generated method stub
-				
+
 			}
 		});
 
@@ -196,7 +201,7 @@
 
 
 		valueCombo.setInput(values);
-		
+
 		if (valueCombo.getList().getItemCount() > 0) {
 			valueCombo.getList().select(0);
 			selectedValues = new ArrayList<String>();
@@ -242,5 +247,17 @@
 		}
 		reloadValues();
 	}
+	
+	public String getQueryString() {
+		String regexp = ""; //$NON-NLS-1$
+		for (String v : selectedValues) {
+			regexp += CQLQuery.addBackSlash(v) + "|"; //$NON-NLS-1$
+		}
+		regexp = regexp.substring(0, regexp.length() - 1);
+		
+		SubcorpusCQLQuery query = new SubcorpusCQLQuery(this.selectedStructuralUnit, this.selectedStructuralUnitProperty, regexp, selectedValues);
+		
+		return query.getQueryString();
+	}
 
 }
\ No newline at end of file
Index: tmp/org.txm.searchengine.cqp.rcp/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.searchengine.cqp.rcp/META-INF/MANIFEST.MF	(revision 2549)
+++ tmp/org.txm.searchengine.cqp.rcp/META-INF/MANIFEST.MF	(revision 2550)
@@ -1,7 +1,10 @@
 Manifest-Version: 1.0
-Export-Package: org.txm.searchengine.cqp.rcp.adapters,org.txm.searchen
- gine.cqp.rcp.handlers.base,org.txm.searchengine.cqp.rcp.messages,org.
- txm.searchengine.cqp.rcp.preferences
+Export-Package: org.txm.searchengine.cqp.rcp.adapters,
+ org.txm.searchengine.cqp.rcp.dialogs,
+ org.txm.searchengine.cqp.rcp.editor,
+ org.txm.searchengine.cqp.rcp.handlers.base,
+ org.txm.searchengine.cqp.rcp.messages,
+ org.txm.searchengine.cqp.rcp.preferences
 Bundle-SymbolicName: org.txm.searchengine.cqp.rcp;singleton:=true
 Bundle-Version: 1.0.0.qualifier
 Bundle-Name: %Bundle-Name
Index: tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/editor/SubcorpusEditor.java
===================================================================
--- tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/editor/SubcorpusEditor.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/editor/SubcorpusEditor.java	(revision 2550)
@@ -0,0 +1,248 @@
+package org.txm.searchengine.cqp.rcp.editor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.txm.core.preferences.TXMPreferences;
+import org.txm.core.results.Parameter;
+import org.txm.core.results.TXMResult;
+import org.txm.rcp.IImageKeys;
+import org.txm.rcp.editors.TXMEditor;
+import org.txm.rcp.editors.listeners.ComputeKeyListener;
+import org.txm.rcp.messages.TXMUIMessages;
+import org.txm.rcp.swt.widget.AssistedChoiceQueryWidget;
+import org.txm.rcp.swt.widget.ComplexSubcorpusPanel;
+import org.txm.rcp.swt.widget.structures.SimpleSubcorpusPanel;
+import org.txm.rcp.views.corpora.CorporaView;
+import org.txm.searchengine.cqp.corpus.Subcorpus;
+import org.txm.searchengine.cqp.corpus.query.Match;
+
+public class SubcorpusEditor extends TXMEditor<Subcorpus> {
+
+	protected static final String ASSISTANTS_GROUPNAME = "Assistants";
+	private Label nameLabel;
+	@Parameter(key = TXMPreferences.USER_NAME)
+
+	private Text nameText;
+
+	private Label queryLabel;
+
+	@Parameter(key = TXMPreferences.QUERY)
+	private AssistedChoiceQueryWidget queryWidget;
+
+	Label matchesInfo;
+	Text matchStartsEndsInfo;
+	private Group modeGroups;
+	private ToolItem refreshQueryButton;
+
+	@Override
+	public void _createPartControl() throws Exception {
+
+		getSite().getPage().addPartListener(new IPartListener() {
+
+			@Override
+			public void partOpened(IWorkbenchPart part) { }
+
+			@Override
+			public void partDeactivated(IWorkbenchPart part) { }
+
+			@Override
+			public void partClosed(IWorkbenchPart part) {
+				TXMResult r = getResult();
+				if (!r.hasBeenComputedOnce()) {
+					r.delete();
+					CorporaView.refresh();
+				}
+			}
+
+			@Override
+			public void partBroughtToTop(IWorkbenchPart part) { }
+
+			@Override
+			public void partActivated(IWorkbenchPart part) { }
+		});
+
+		// Modified computing listeners to manage multi lines query widgets
+				ComputeKeyListener computeKeyListener = new ComputeKeyListener(this) {
+
+					@Override
+					public void keyPressed(KeyEvent e) {
+
+						if (queryWidget.getQuery() == null) return;
+						if (!queryWidget.getQuery().getSearchEngine().hasMultiLineQueries()) super.keyPressed(e);
+					}
+				};
+		
+		getMainParametersComposite().getLayout().numColumns = 4;
+
+		nameLabel = new Label(getMainParametersComposite(), SWT.NONE);
+		nameLabel.setText(TXMUIMessages.name);
+		nameLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+
+		nameText = new Text(this.getMainParametersComposite(), SWT.BORDER);
+		GridData gdata = new GridData(SWT.FILL, SWT.CENTER, true, false);
+		nameText.setLayoutData(gdata);
+		gdata.widthHint = 150;
+		nameText.addModifyListener(computeKeyListener);
+
+		queryLabel = new Label(getMainParametersComposite(), SWT.NONE);
+		queryLabel.setText(TXMUIMessages.ampQuery);
+		queryLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+
+		queryWidget = new AssistedChoiceQueryWidget(this.getMainParametersComposite(), SWT.BORDER|SWT.DROP_DOWN | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL, getResult());
+		queryWidget.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
+		queryWidget.addKeyListener(computeKeyListener);
+		queryWidget.getQueryWidget().addModifyListener(computeKeyListener);
+
+		ArrayList<String> modes = new ArrayList<String>();
+		final ArrayList<SelectionListener> listeners = new ArrayList<SelectionListener>();
+
+		// MODE TABS
+		SelectionListener openCloseSelectionListener = new SelectionListener() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+
+				boolean v = getTopToolbar().isVisible(ASSISTANTS_GROUPNAME);
+				if (!v) { // not visible remove all composites
+					if (modeGroups.getChildren().length > 0) {
+						Control c = modeGroups.getChildren()[0];
+						if (c instanceof SimpleSubcorpusPanel) {
+							SimpleSubcorpusPanel ssp = (SimpleSubcorpusPanel)c;
+							String q = ssp.getQueryString();
+							if (q.length() > 0) {
+								queryWidget.setText(q);
+							}
+						} else if (c instanceof ComplexSubcorpusPanel) {
+							ComplexSubcorpusPanel ssp = (ComplexSubcorpusPanel)c;
+							GridData gdata = new GridData(GridData.FILL, GridData.FILL, true, true);
+							ssp.setLayoutData(gdata);
+							gdata.heightHint = 600;
+							String q = ssp.getQueryString();
+							if (q.length() > 0) {
+								queryWidget.setText(q);
+							}
+						}
+						for (Control c2 : modeGroups.getChildren()) c2.dispose();
+					}
+				} else { 
+					
+					for (Control c : modeGroups.getChildren()) c.dispose();
+					
+					if (modeGroups.getChildren().length  == 0) {
+						listeners.get(0).widgetSelected(e);
+					}
+				}
+			}
+
+			@Override
+			public void widgetDefaultSelected(SelectionEvent e) {	}
+		};
+
+		modes.add("Simple");
+		modes.add("Assisted");
+
+		listeners.add(new SelectionListener() { // create alistener to instantiate a new AnnotationArea
+
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				try {
+					for (Control c : modeGroups.getChildren()) c.dispose();
+
+					getTopToolbar().setVisible(ASSISTANTS_GROUPNAME, true);
+
+					SimpleSubcorpusPanel panel = new SimpleSubcorpusPanel(modeGroups, SWT.BORDER, null, getResult().getCorpusParent());
+					panel.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
+
+					modeGroups.layout(true);
+					getResultArea().getParent().layout(true);
+
+				} catch (Exception e1) {
+					// TODO Auto-generated catch block
+					e1.printStackTrace();
+				}
+			}
+
+			@Override
+			public void widgetDefaultSelected(SelectionEvent e) {}
+		});
+		listeners.add(new SelectionListener() { // create alistener to instantiate a new AnnotationArea
+
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				try {
+					for (Control c : modeGroups.getChildren()) c.dispose();
+
+					getTopToolbar().setVisible(ASSISTANTS_GROUPNAME, true);
+
+					ComplexSubcorpusPanel panel = new ComplexSubcorpusPanel(modeGroups, SWT.BORDER, getResult().getCorpusParent());
+					panel.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
+
+					modeGroups.layout(true);
+					getResultArea().getParent().layout(true);
+
+				} catch (Exception e1) {
+					// TODO Auto-generated catch block
+					e1.printStackTrace();
+				}
+			}
+
+			@Override
+			public void widgetDefaultSelected(SelectionEvent e) {}
+		});
+		modeGroups = this.getTopToolbar().installAlternativesGroup(ASSISTANTS_GROUPNAME, ASSISTANTS_GROUPNAME, IImageKeys.ACTION_ASSISTQUERY, null, false, openCloseSelectionListener, modes, listeners);
+		modeGroups.setLayout(new GridLayout(1, true));
+
+		// RESULT AREA
+
+		matchesInfo = new Label(this.getResultArea(), SWT.NONE);
+		matchesInfo.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
+
+		matchStartsEndsInfo = new Text(this.getResultArea(), SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+		matchStartsEndsInfo.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, true));
+	}
+
+	protected void refreshQuery() {
+		System.out.println("Refresh query...");
+	}
+
+	@Override
+	public void updateResultFromEditor() {
+		// nothing to do
+	}
+
+	@Override
+	public void updateEditorFromResult(boolean update) throws Exception {
+
+		List<Match> matches = getResult().getMatches();
+		if (matches == null || matches.size() == 0) {
+
+			if (getResult().hasBeenComputedOnce()) {
+				matchesInfo.setText(NLS.bind("{0} match and {1} token", 0, 0));
+			} else {
+				matchesInfo.setText("(not computed yes)");
+			}
+			matchStartsEndsInfo.setText("");
+		} else {
+			matchesInfo.setText(NLS.bind("{0} match(s) for {1} tokens", this.getResult().getNMatch(), this.getResult().getSize()));
+			matchStartsEndsInfo.setText(StringUtils.join(getResult().getMatches(), "\n"));
+		}
+		matchesInfo.redraw();
+		matchStartsEndsInfo.redraw();
+		matchStartsEndsInfo.getParent().layout(true);
+	}
+}

Property changes on: tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/editor/SubcorpusEditor.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/editor/PartitionEditor.java
===================================================================
--- tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/editor/PartitionEditor.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/editor/PartitionEditor.java	(revision 2550)
@@ -0,0 +1,35 @@
+package org.txm.searchengine.cqp.rcp.editor;
+
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Label;
+import org.txm.rcp.editors.TXMEditor;
+import org.txm.searchengine.cqp.corpus.Partition;
+import org.txm.searchengine.cqp.corpus.Subcorpus;
+
+public class PartitionEditor extends TXMEditor<Partition> {
+
+	Label partitionInfo;
+	Label partsInfo;
+	
+	@Override
+	public void _createPartControl() throws Exception {
+		partitionInfo = new Label(this.getResultArea(), SWT.NONE);
+		partitionInfo.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
+		
+		partsInfo = new Label(this.getResultArea(), SWT.NONE);
+		partitionInfo.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, true));
+	}
+
+	@Override
+	public void updateResultFromEditor() {
+		// nothing to do
+	}
+
+	@Override
+	public void updateEditorFromResult(boolean update) throws Exception {
+		partitionInfo.setText(getResult().getDetails());
+		partsInfo.setText(StringUtils.join(getResult().getParts(), "\n"));
+	}
+}

Property changes on: tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/editor/PartitionEditor.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/CreateSubCorpus.java
===================================================================
--- tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/CreateSubCorpus.java	(revision 2549)
+++ tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/CreateSubCorpus.java	(revision 2550)
@@ -1,170 +0,0 @@
-// Copyright © 2010-2013 ENS de Lyon.
-// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
-// Lyon 2, University of Franche-Comté, University of Nice
-// Sophia Antipolis, University of Paris 3.
-// 
-// The TXM platform is free software: you can redistribute it
-// and/or modify it under the terms of the GNU General Public
-// License as published by the Free Software Foundation,
-// either version 2 of the License, or (at your option) any
-// later version.
-// 
-// The TXM platform is distributed in the hope that it will be
-// useful, but WITHOUT ANY WARRANTY; without even the implied
-// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-// PURPOSE. See the GNU General Public License for more
-// details.
-// 
-// You should have received a copy of the GNU General
-// Public License along with the TXM platform. If not, see
-// http://www.gnu.org/licenses.
-// 
-// 
-// 
-// $LastChangedDate:$
-// $LastChangedRevision:$
-// $LastChangedBy:$ 
-//
-package org.txm.searchengine.cqp.rcp.handlers.base;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.txm.Toolbox;
-import org.txm.rcp.JobsTimer;
-import org.txm.rcp.actions.CreateSubcorpusDialog;
-import org.txm.rcp.messages.TXMUIMessages;
-import org.txm.rcp.utils.JobHandler;
-import org.txm.rcp.views.corpora.CorporaView;
-import org.txm.searchengine.cqp.CQPSearchEngine;
-import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
-import org.txm.searchengine.cqp.core.messages.CQPSearchEngineCoreMessages;
-import org.txm.searchengine.cqp.corpus.CQPCorpus;
-import org.txm.searchengine.cqp.corpus.Subcorpus;
-import org.txm.searchengine.cqp.corpus.query.CQLQuery;
-import org.txm.utils.logger.Log;
-
-// TODO: Auto-generated Javadoc
-/**
- * Command which creates a subcorpus from a Corpus @ author mdecorde.
- */
-public class CreateSubCorpus extends AbstractHandler {
-	
-	/** The selection. */
-	private IStructuredSelection selection;
-	
-	/*
-	 * (non-Javadoc)
-	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
-	 */
-	@Override
-	public Object execute(ExecutionEvent event) throws ExecutionException {
-		
-		selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
-		if (selection == null) {
-			System.out.println(TXMUIMessages.noSelectionForColon + HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor());
-			return null;
-		}
-		Object firstElement = selection.getFirstElement();
-		
-		if (!(firstElement instanceof CQPCorpus)) {
-			System.out.println(TXMUIMessages.selectionIsNotACorpusColon + firstElement);
-			return null;
-		}
-		
-		final CQPCorpus corpus = (CQPCorpus) firstElement;
-		Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell();
-		final CreateSubcorpusDialog d = new CreateSubcorpusDialog(shell, corpus);
-		int code = d.open();
-		if (code == Window.OK) {
-			JobHandler jobhandler = new JobHandler(NLS.bind(TXMUIMessages.creatingASubcorpusOnP0, corpus.getName())) {
-				
-				@Override
-				protected IStatus run(IProgressMonitor monitor) {
-					this.runInit(monitor);
-					JobsTimer.start();
-					try {
-						monitor.beginTask(TXMUIMessages.creatingASubcorpusInTheSearchEngine, 100);
-						final Subcorpus subcorpus;
-						
-						if (d.isAdvancedSelected() || d.isAssistedSelected()) {
-							CQLQuery q = new CQLQuery(d.getQuery());
-							
-							// System.out.println(NLS.bind(TXMUIMessages.computeSubCorpusOnP0QueryColonP1, corpus.getName(), q.getQueryString()));
-							
-							subcorpus = corpus.createSubcorpus(q, d.getName());
-						}
-						else {
-							// System.out.println(NLS.bind(TXMUIMessages.computeSubCorpusOnP0StructsColonP1AmpPropsP2ColonP3,
-							// new Object[] { corpus.getName(), d.getStructuralUnit(),
-							// d.getStructuralUnitProperty(), d.getValues() }));
-							
-							// Escape regex char of prop values
-							// List<String> values = d.getValues();
-							// for(int i = 0 ; i < values.size() ; i++)
-							// values.set(i, Query.addBackSlash(values.get(i)));
-							
-							subcorpus = corpus.createSubcorpus(
-									d.getStructuralUnit(), d.getStructuralUnitProperty(),
-									d.getValues(), d.getName());
-						}
-						
-						if (subcorpus == null) {
-							monitor.done();
-							Log.severe(TXMUIMessages.errorColonSubcorpusWasNotCreated);
-							return Status.CANCEL_STATUS;
-						}
-						
-						// System.out.println(NLS.bind(TXMUIMessages.doneColonP0Created, subcorpus.getName()));
-						monitor.worked(50);
-						
-						monitor.subTask(TXMUIMessages.refreshingCorpora);
-						syncExec(new Runnable() {
-							
-							@Override
-							public void run() {
-								CorporaView.refresh();
-								// System.out.println("expand");
-								CorporaView.expand(subcorpus.getParent());
-							}
-						});
-						
-						monitor.worked(100);
-					}
-					catch (ThreadDeath td) {
-						return Status.CANCEL_STATUS;
-					}
-					catch (CqiClientException e) {
-						org.txm.utils.logger.Log.printStackTrace(e);
-						Log.severe(e.toString());
-						
-						try {
-							System.out.println(NLS.bind(CQPSearchEngineCoreMessages.lastCQPErrorColon, CQPSearchEngine.getCqiClient().getLastCQPError()));
-						}
-						catch (Exception e1) {
-							System.out.println(TXMUIMessages.failedToGetLastCQPErrorColon + e1);
-							org.txm.utils.logger.Log.printStackTrace(e1);
-						}
-					}
-					finally {
-						monitor.done();
-						JobsTimer.stopAndPrint();
-					}
-					return Status.OK_STATUS;
-				}
-			};
-			jobhandler.startJob();
-		}
-		return null;
-	}
-	
-}
Index: tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputeSubCorpus.java
===================================================================
--- tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputeSubCorpus.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputeSubCorpus.java	(revision 2550)
@@ -0,0 +1,204 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate:$
+// $LastChangedRevision:$
+// $LastChangedBy:$ 
+//
+package org.txm.searchengine.cqp.rcp.handlers.base;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.txm.rcp.JobsTimer;
+import org.txm.rcp.actions.CreateSubcorpusDialog;
+import org.txm.rcp.editors.TXMEditor;
+import org.txm.rcp.messages.TXMUIMessages;
+import org.txm.rcp.utils.JobHandler;
+import org.txm.rcp.views.corpora.CorporaView;
+import org.txm.searchengine.cqp.CQPSearchEngine;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.core.messages.CQPSearchEngineCoreMessages;
+import org.txm.searchengine.cqp.core.preferences.SubcorpusPreferences;
+import org.txm.searchengine.cqp.corpus.CQPCorpus;
+import org.txm.searchengine.cqp.corpus.Subcorpus;
+import org.txm.searchengine.cqp.corpus.query.CQLQuery;
+import org.txm.searchengine.cqp.rcp.editor.SubcorpusEditor;
+import org.txm.utils.logger.Log;
+
+/**
+ * Command which creates a subcorpus from a Corpus @ author mdecorde.
+ */
+public class ComputeSubCorpus extends AbstractHandler {
+	
+	/** The selection. */
+	private IStructuredSelection selection;
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+	 */
+	@Override
+	public Object execute(ExecutionEvent event) throws ExecutionException {
+		if (SubcorpusPreferences.getInstance().getBoolean(SubcorpusPreferences.EDITORMODE)) {
+			return execute_editor(event);
+		} else {
+			return execute_dialog(event);
+		}
+	}
+	
+	public Object execute_editor(ExecutionEvent event) throws ExecutionException {
+		
+		selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
+		if (selection == null) {
+			System.out.println(TXMUIMessages.noSelectionForColon + HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor());
+			return null;
+		}
+		
+		String edit = event.getParameter("edit"); //$NON-NLS-1$
+		
+		Object firstElement = selection.getFirstElement();
+		Subcorpus sub = null;
+		if (firstElement instanceof CQPCorpus) {
+			if (firstElement instanceof Subcorpus && "true".equals(edit)) {
+				sub = (Subcorpus) firstElement;
+			} else {
+				sub = new Subcorpus((CQPCorpus)firstElement);
+			}
+		}
+		return TXMEditor.openEditor(sub , SubcorpusEditor.class.getName());
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+	 */
+	public Object execute_dialog(ExecutionEvent event) throws ExecutionException {
+		
+		selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
+		if (selection == null) {
+			System.out.println(TXMUIMessages.noSelectionForColon + HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor());
+			return null;
+		}
+		Object firstElement = selection.getFirstElement();
+		
+		if (!(firstElement instanceof CQPCorpus)) {
+			System.out.println(TXMUIMessages.selectionIsNotACorpusColon + firstElement);
+			return null;
+		}
+		
+		final CQPCorpus corpus = (CQPCorpus) firstElement;
+		Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell();
+		final CreateSubcorpusDialog d = new CreateSubcorpusDialog(shell, corpus);
+		int code = d.open();
+		if (code == Window.OK) {
+			JobHandler jobhandler = new JobHandler(NLS.bind(TXMUIMessages.creatingASubcorpusOnP0, corpus.getName())) {
+				
+				@Override
+				protected IStatus run(IProgressMonitor monitor) {
+					this.runInit(monitor);
+					JobsTimer.start();
+					try {
+						monitor.beginTask(TXMUIMessages.creatingASubcorpusInTheSearchEngine, 100);
+						final Subcorpus subcorpus;
+						
+						if (d.isAdvancedSelected() || d.isAssistedSelected()) {
+							CQLQuery q = new CQLQuery(d.getQuery());
+							
+							// System.out.println(NLS.bind(TXMUIMessages.computeSubCorpusOnP0QueryColonP1, corpus.getName(), q.getQueryString()));
+							
+							subcorpus = corpus.createSubcorpus(q, d.getName());
+						}
+						else {
+							// System.out.println(NLS.bind(TXMUIMessages.computeSubCorpusOnP0StructsColonP1AmpPropsP2ColonP3,
+							// new Object[] { corpus.getName(), d.getStructuralUnit(),
+							// d.getStructuralUnitProperty(), d.getValues() }));
+							
+							// Escape regex char of prop values
+							// List<String> values = d.getValues();
+							// for(int i = 0 ; i < values.size() ; i++)
+							// values.set(i, Query.addBackSlash(values.get(i)));
+							
+							subcorpus = corpus.createSubcorpus(
+									d.getStructuralUnit(), d.getStructuralUnitProperty(),
+									d.getValues(), d.getName());
+						}
+						
+						if (subcorpus == null) {
+							monitor.done();
+							Log.severe(TXMUIMessages.errorColonSubcorpusWasNotCreated);
+							return Status.CANCEL_STATUS;
+						}
+						
+						// System.out.println(NLS.bind(TXMUIMessages.doneColonP0Created, subcorpus.getName()));
+						monitor.worked(50);
+						
+						monitor.subTask(TXMUIMessages.refreshingCorpora);
+						syncExec(new Runnable() {
+							
+							@Override
+							public void run() {
+								CorporaView.refresh();
+								// System.out.println("expand");
+								CorporaView.expand(subcorpus.getParent());
+							}
+						});
+						
+						monitor.worked(100);
+					}
+					catch (ThreadDeath td) {
+						return Status.CANCEL_STATUS;
+					}
+					catch (CqiClientException e) {
+						org.txm.utils.logger.Log.printStackTrace(e);
+						Log.severe(e.toString());
+						
+						try {
+							System.out.println(NLS.bind(CQPSearchEngineCoreMessages.lastCQPErrorColon, CQPSearchEngine.getCqiClient().getLastCQPError()));
+						}
+						catch (Exception e1) {
+							System.out.println(TXMUIMessages.failedToGetLastCQPErrorColon + e1);
+							org.txm.utils.logger.Log.printStackTrace(e1);
+						}
+					}
+					finally {
+						monitor.done();
+						JobsTimer.stopAndPrint();
+					}
+					return Status.OK_STATUS;
+				}
+			};
+			jobhandler.startJob();
+		}
+		return null;
+	}
+	
+}

Property changes on: tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputeSubCorpus.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputePartition.java
===================================================================
--- tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputePartition.java	(revision 2549)
+++ tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputePartition.java	(revision 2550)
@@ -43,12 +43,17 @@
 import org.eclipse.ui.handlers.HandlerUtil;
 import org.txm.rcp.JobsTimer;
 import org.txm.rcp.actions.CreatePartitionDialog;
+import org.txm.rcp.editors.TXMEditor;
 import org.txm.rcp.messages.TXMUIMessages;
 import org.txm.rcp.utils.JobHandler;
 import org.txm.rcp.views.corpora.CorporaView;
+import org.txm.searchengine.cqp.core.preferences.PartitionPreferences;
 import org.txm.searchengine.cqp.corpus.CQPCorpus;
 import org.txm.searchengine.cqp.corpus.Part;
 import org.txm.searchengine.cqp.corpus.Partition;
+import org.txm.searchengine.cqp.corpus.Subcorpus;
+import org.txm.searchengine.cqp.rcp.editor.PartitionEditor;
+import org.txm.searchengine.cqp.rcp.editor.SubcorpusEditor;
 import org.txm.utils.logger.Log;
 
 /**
@@ -72,7 +77,42 @@
 	 */
 	@Override
 	public Object execute(ExecutionEvent event) throws ExecutionException {
+		if (PartitionPreferences.getInstance().getBoolean(PartitionPreferences.EDITORMODE)) {
+			return execute_editor(event);
+		} else {
+			return execute_dialog(event);
+		}
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see
+	 * org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands
+	 * .ExecutionEvent)
+	 */
+	public Object execute_editor(ExecutionEvent event) throws ExecutionException {
 		selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
+		if (selection == null) {
+			System.out.println(TXMUIMessages.noSelectionForColon + HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor());
+			return null;
+		}
+		Object firstElement = selection.getFirstElement();
+		Partition part = null;
+		if (firstElement instanceof CQPCorpus) {
+			part = new Partition((CQPCorpus)firstElement);
+		} else if (firstElement instanceof Partition) {
+			part = (Partition)firstElement;
+		}
+		return TXMEditor.openEditor(part , PartitionEditor.class.getName());
+	}
+	/*
+	 * (non-Javadoc)
+	 * @see
+	 * org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands
+	 * .ExecutionEvent)
+	 */
+	public Object execute_dialog(ExecutionEvent event) throws ExecutionException {
+		selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
 		
 		final CQPCorpus corpus = (CQPCorpus) selection.getFirstElement();
 		Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell();
Index: tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/preferences/SubcorpusPreferencePage.java
===================================================================
--- tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/preferences/SubcorpusPreferencePage.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/preferences/SubcorpusPreferencePage.java	(revision 2550)
@@ -0,0 +1,88 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate:$
+// $LastChangedRevision:$
+// $LastChangedBy:$ 
+//
+package org.txm.searchengine.cqp.rcp.preferences;
+
+
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.DirectoryFieldEditor;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.preference.FileFieldEditor;
+import org.eclipse.jface.preference.IntegerFieldEditor;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.ui.IWorkbench;
+import org.osgi.service.prefs.Preferences;
+import org.txm.libs.cqp.CQPLibPreferences;
+import org.txm.rcp.Application;
+import org.txm.rcp.preferences.TXMPreferencePage;
+import org.txm.rcp.preferences.TXMPreferenceStore;
+import org.txm.searchengine.cqp.core.preferences.SubcorpusPreferences;
+import org.txm.searchengine.cqp.rcp.messages.CQPUIMessages;
+
+/**
+ * CQP search engine preferences page.
+ *  
+ * @author mdecorde
+ * @author sjacquot
+ *
+ */
+public class SubcorpusPreferencePage extends TXMPreferencePage {
+
+	/** The cqi_server_is_remote. */
+	private BooleanFieldEditor editor_mode;
+
+	/**
+	 * Instantiates a new cQP preference page.
+	 */
+	public SubcorpusPreferencePage() {
+		super();
+	}
+
+	/**
+	 * Creates the field editors. Field editors are abstractions of the common
+	 * GUI blocks needed to manipulate various types of preferences. Each field
+	 * editor knows how to save and restore itself.
+	 */
+	@Override
+	public void createFieldEditors() {
+
+		editor_mode = new BooleanFieldEditor(SubcorpusPreferences.EDITORMODE, "Create subcorpus using the editor mode", BooleanFieldEditor.DEFAULT, getFieldEditorParent());
+		addField(editor_mode);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+	 */
+	@Override
+	public void init(IWorkbench workbench) {
+		this.setPreferenceStore(new TXMPreferenceStore(new SubcorpusPreferences().getPreferencesNodeQualifier()));
+	}
+}
\ No newline at end of file

Property changes on: tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/preferences/SubcorpusPreferencePage.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/preferences/PartitionPreferencePage.java
===================================================================
--- tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/preferences/PartitionPreferencePage.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/preferences/PartitionPreferencePage.java	(revision 2550)
@@ -0,0 +1,88 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+// 
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+// 
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+// 
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+// 
+// 
+// 
+// $LastChangedDate:$
+// $LastChangedRevision:$
+// $LastChangedBy:$ 
+//
+package org.txm.searchengine.cqp.rcp.preferences;
+
+
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.DirectoryFieldEditor;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.preference.FileFieldEditor;
+import org.eclipse.jface.preference.IntegerFieldEditor;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.ui.IWorkbench;
+import org.osgi.service.prefs.Preferences;
+import org.txm.libs.cqp.CQPLibPreferences;
+import org.txm.rcp.Application;
+import org.txm.rcp.preferences.TXMPreferencePage;
+import org.txm.rcp.preferences.TXMPreferenceStore;
+import org.txm.searchengine.cqp.core.preferences.PartitionPreferences;
+import org.txm.searchengine.cqp.rcp.messages.CQPUIMessages;
+
+/**
+ * CQP search engine preferences page.
+ *  
+ * @author mdecorde
+ * @author sjacquot
+ *
+ */
+public class PartitionPreferencePage extends TXMPreferencePage {
+
+	/** The cqi_server_is_remote. */
+	private BooleanFieldEditor editor_mode;
+
+	/**
+	 * Instantiates a new cQP preference page.
+	 */
+	public PartitionPreferencePage() {
+		super();
+	}
+
+	/**
+	 * Creates the field editors. Field editors are abstractions of the common
+	 * GUI blocks needed to manipulate various types of preferences. Each field
+	 * editor knows how to save and restore itself.
+	 */
+	@Override
+	public void createFieldEditors() {
+
+		editor_mode = new BooleanFieldEditor(PartitionPreferences.EDITORMODE, "Create partitions using the editor mode", BooleanFieldEditor.DEFAULT, getFieldEditorParent());
+		addField(editor_mode);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+	 */
+	@Override
+	public void init(IWorkbench workbench) {
+		this.setPreferenceStore(new TXMPreferenceStore(new PartitionPreferences().getPreferencesNodeQualifier()));
+	}
+}
\ No newline at end of file

Property changes on: tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/preferences/PartitionPreferencePage.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.rcp/plugin.xml
===================================================================
--- tmp/org.txm.searchengine.cqp.rcp/plugin.xml	(revision 2549)
+++ tmp/org.txm.searchengine.cqp.rcp/plugin.xml	(revision 2550)
@@ -25,7 +25,7 @@
          </commandParameter>
       </command>
       <command
-            defaultHandler="org.txm.searchengine.cqp.rcp.handlers.base.CreateSubCorpus"
+            defaultHandler="org.txm.searchengine.cqp.rcp.handlers.base.ComputeSubCorpus"
             id="org.txm.searchengine.cqp.rcp.handlers.base.CreateSubCorpus"
             name="%command.name">
          <commandParameter
@@ -33,6 +33,11 @@
                name="%commandParameter.name.0"
                optional="true">
          </commandParameter>
+         <commandParameter
+               id="edit"
+               name="edit"
+               optional="true">
+         </commandParameter>
       </command>
       <command
             defaultHandler="org.txm.searchengine.cqp.rcp.handlers.base.Substraction"
@@ -155,6 +160,22 @@
             </visibleWhen>
          </command>
          <command
+               commandId="org.txm.searchengine.cqp.rcp.handlers.base.CreateSubCorpus"
+               icon="icons/functions/subcorpus.png"
+               label="Edit..."
+               style="push">
+            <visibleWhen
+                  checkEnabled="false">
+               <reference
+                     definitionId="OneCorpusSelected">
+               </reference>
+            </visibleWhen>
+            <parameter
+                  name="edit"
+                  value="true">
+            </parameter>
+         </command>
+         <command
                commandId="org.txm.searchengine.cqp.rcp.handlers.base.ComputePartition"
                icon="icons/functions/partition.png"
                style="push">
@@ -292,6 +313,18 @@
             id="org.txm.searchengine.cqp.rcp.preferences.CQPPreferencePage"
             name="CQP">
       </page>
+      <page
+            category="org.txm.rcp.preferences.UserPreferencePage"
+            class="org.txm.searchengine.cqp.rcp.preferences.SubcorpusPreferencePage"
+            id="org.txm.searchengine.cqp.rcp.preferences.SubcorpusPreferencePage"
+            name="Subcorpus">
+      </page>
+      <page
+            category="org.txm.rcp.preferences.UserPreferencePage"
+            class="org.txm.searchengine.cqp.rcp.preferences.PartitionPreferencePage"
+            id="org.txm.searchengine.cqp.rcp.preferences.PartitionPreferencePage"
+            name="Partition">
+      </page>
    </extension>
    <extension
          point="org.eclipse.core.runtime.adapters">
@@ -345,5 +378,22 @@
          </with>
       </definition>
    </extension>
+   <extension
+         point="org.eclipse.ui.editors">
+      <editor
+            class="org.txm.searchengine.cqp.rcp.editor.SubcorpusEditor"
+            default="false"
+            icon="icons/functions/subcorpus.png"
+            id="org.txm.searchengine.cqp.rcp.editor.SubcorpusEditor"
+            name="Subcorpus">
+      </editor>
+      <editor
+            class="org.txm.searchengine.cqp.rcp.editor.PartitionEditor"
+            default="false"
+            icon="icons/functions/partition.png"
+            id="org.txm.searchengine.cqp.rcp.editor.PartitionEditor"
+            name="Partition">
+      </editor>
+   </extension>
 
 </plugin>
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 2549)
+++ tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/editor/AnnotationExtension.java	(revision 2550)
@@ -109,10 +109,15 @@
 		SelectionListener openCloseSelectionListener = new SelectionListener() {
 			@Override
 			public void widgetSelected(SelectionEvent e) {
-				if (annotationAreas.size() > 0) {
-					return; // do nothing
+				if (editor.getTopToolbar().isVisible(GROUP_NAME)) {
+					if (annotationAreas.size() == 0) {
+						openDefaultAnnotationMode(e);
+					}
 				} else {
-					openDefaultAnnotationMode(e);
+					for (AnnotationArea a : annotationAreas) {
+						a.close();
+					}
+					annotationAreas.clear();
 				}
 			}
 
Index: tmp/org.txm.searchengine.cqp.core/plugin.xml
===================================================================
--- tmp/org.txm.searchengine.cqp.core/plugin.xml	(revision 2549)
+++ tmp/org.txm.searchengine.cqp.core/plugin.xml	(revision 2550)
@@ -12,6 +12,12 @@
       <initializer
             class="org.txm.searchengine.cqp.CQPPreferences">
       </initializer>
+      <initializer
+            class="org.txm.searchengine.cqp.core.preferences.SubcorpusPreferences">
+      </initializer>
+      <initializer
+            class="org.txm.searchengine.cqp.core.preferences.PartitionPreferences">
+      </initializer>
    </extension>
 
 
Index: tmp/org.txm.searchengine.cqp.core/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.searchengine.cqp.core/META-INF/MANIFEST.MF	(revision 2549)
+++ tmp/org.txm.searchengine.cqp.core/META-INF/MANIFEST.MF	(revision 2550)
@@ -1,11 +1,16 @@
 Manifest-Version: 1.0
-Export-Package: org.txm.importer.cwb,org.txm.searchengine.cqp,org.txm.
- searchengine.cqp.clientExceptions,org.txm.searchengine.cqp.core.funct
- ions.preview,org.txm.searchengine.cqp.core.functions.selection,org.tx
- m.searchengine.cqp.core.functions.summary,org.txm.searchengine.cqp.co
- re.messages,org.txm.searchengine.cqp.core.tests,org.txm.searchengine.
- cqp.corpus,org.txm.searchengine.cqp.corpus.query,org.txm.searchengine
- .cqp.serverException
+Export-Package: org.txm.importer.cwb,
+ org.txm.searchengine.cqp,
+ org.txm.searchengine.cqp.clientExceptions,
+ org.txm.searchengine.cqp.core.functions.preview,
+ org.txm.searchengine.cqp.core.functions.selection,
+ org.txm.searchengine.cqp.core.functions.summary,
+ org.txm.searchengine.cqp.core.messages,
+ org.txm.searchengine.cqp.core.preferences,
+ org.txm.searchengine.cqp.core.tests,
+ org.txm.searchengine.cqp.corpus,
+ org.txm.searchengine.cqp.corpus.query,
+ org.txm.searchengine.cqp.serverException
 Bundle-SymbolicName: org.txm.searchengine.cqp.core;singleton:=true
 Bundle-Version: 1.1.0.qualifier
 Bundle-Name: %Bundle-Name
Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Part.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Part.java	(revision 2549)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Part.java	(revision 2550)
@@ -78,10 +78,10 @@
 	}
 	
 	@Override
-	protected boolean _compute() throws Exception {
+	protected boolean __compute() throws Exception {
 
 		try {
-			super._compute();
+			super.__compute();
 		}
 		catch (Exception e) {
 			try {
Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java	(revision 2549)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java	(revision 2550)
@@ -106,7 +106,7 @@
 	 * @param parent
 	 * @throws NullPointerException
 	 */
-	public Partition(CQPCorpus parent) throws NullPointerException {
+	public Partition(CQPCorpus parent) {
 		super(parent);
 	}
 	
@@ -118,7 +118,6 @@
 		super(parametersNodePath);
 	}
 	
-	
 	/**
 	 * Computes the Partition using a list of queries.
 	 *
Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPCorpus.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPCorpus.java	(revision 2549)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPCorpus.java	(revision 2550)
@@ -226,7 +226,7 @@
 	 */
 	protected String lang = null;
 	
-	/** The corpus lexical units properties. */
+	/** stores The corpus lexical units properties. */
 	protected List<WordProperty> lexicalUnitsProperties;
 	
 	/** The size in token */
@@ -675,6 +675,27 @@
 		return createSubcorpus(query, subcorpusName);
 	}
 	
+	protected final boolean _compute() throws Exception {
+		//reset the internal variable that store information
+		
+		lexicalUnitsProperties = null;
+		size = -1;
+		nbtext = -1;
+		textEndLimits = null;
+		textids = null;
+		structuralUnits = null;
+		symbol = null;
+		textIdStructuralUnitProperty = null;
+		textLimits = null;
+		textStructuralUnit = null;
+		wordProperty = null;
+		
+		
+		return __compute();
+	}
+	
+	protected abstract boolean __compute() throws Exception;
+	
 	/**
 	 * Create a subcorpus from a structural unit, a property on this structural unit
 	 * and a value for this property.
Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/MainCorpus.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/MainCorpus.java	(revision 2549)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/MainCorpus.java	(revision 2550)
@@ -115,7 +115,7 @@
 	}
 	
 	@Override
-	protected boolean _compute() throws Exception {
+	protected boolean __compute() throws Exception {
 		
 		if (!CQPSearchEngine.isInitialized()) {
 			Log.warning("** TXM can't load MainCorpus when CQP search engine is not ready.");
Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Subcorpus.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Subcorpus.java	(revision 2549)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Subcorpus.java	(revision 2550)
@@ -112,12 +112,16 @@
 	 *             {@link CQPCorpus#createSubcorpus(CQLQuery, String)}
 	 */
 	@Override
-	protected boolean _compute() throws Exception {
+	protected boolean __compute() throws Exception {
+		if (pID == null || pID.length() == 0) {
+			pID = subcorpusNamePrefix + getNextSubcorpusCounter().toString();
+		}
+		
 		if (this.pQuery != null) {
 			this.qresult = null; // reset
+			String parent_id = this.getCorpusParent().getQualifiedCqpId();
+			CorpusManager.getCorpusManager().getCqiClient().cqpQuery(parent_id, this.pID, CQLQuery.fixQuery(this.pQuery.getQueryString()));
 			
-			CorpusManager.getCorpusManager().getCqiClient().cqpQuery(this.getCorpusParent().getQualifiedCqpId(), this.pID, CQLQuery.fixQuery(this.pQuery.getQueryString()));
-			
 			this.qresult = new QueryResult(this.pID, this.userName, this.getCorpusParent(), this.pQuery); // getCorpusParent().query(pQuery, this.pID, true);
 		}
 		return qresult != null;
@@ -134,11 +138,10 @@
 		}
 		// created directly from a query
 		else {
-			return TXMCoreMessages.bind(SearchEngineCoreMessages.info_computingTheP0SubCorpusOfP1CommaQueryP2, this.getSimpleName(), this.getParent().getName(), this.getQuery().getQueryString());
+			return TXMCoreMessages.bind(SearchEngineCoreMessages.info_computingTheP0SubCorpusOfP1CommaQueryP2, this.getSimpleName(), this.getParent().getName(), this.getQuery());
 		}
 	}
 	
-	
 	/*
 	 * retro compatibility method for import.xml file
 	 * @see org.txm.searchengine.cqp.corpus.Corpus#getLocale()
@@ -198,7 +201,8 @@
 	
 	@Override
 	public boolean canCompute() {
-		return pID != null && userName != null && (pQuery != null || qresult != null);
+		return userName != null && userName.length() > 0 && 
+				((pQuery != null  && pQuery.getQueryString().length() > 0 ) || qresult != null);
 	}
 	
 	/*
@@ -249,6 +253,9 @@
 	
 	@Override
 	public List<Match> getMatches() {
+		if (qresult == null) { // not computed
+			return new ArrayList<>();
+		}
 		try {
 			return qresult.getMatches();
 		}
Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/core/preferences/PartitionPreferences.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/core/preferences/PartitionPreferences.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/core/preferences/PartitionPreferences.java	(revision 2550)
@@ -0,0 +1,33 @@
+package org.txm.searchengine.cqp.core.preferences;
+
+import org.osgi.service.prefs.Preferences;
+import org.txm.core.preferences.TXMPreferences;
+
+public class PartitionPreferences extends TXMPreferences {
+
+	public static String EDITORMODE = "editor_mode";
+	
+	public PartitionPreferences() {
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * Gets the instance.
+	 * @return the instance
+	 */
+	public static TXMPreferences getInstance()	{
+		if (!TXMPreferences.instances.containsKey(PartitionPreferences.class)) {
+			new PartitionPreferences();
+		}
+		return TXMPreferences.instances.get(PartitionPreferences.class);
+	}
+	
+	@Override
+	public void initializeDefaultPreferences() {
+		super.initializeDefaultPreferences();
+		
+		Preferences preferences = this.getDefaultPreferencesNode();
+		
+		preferences.putBoolean(EDITORMODE, false);
+	}
+}

Property changes on: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/core/preferences/PartitionPreferences.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/core/preferences/SubcorpusPreferences.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/core/preferences/SubcorpusPreferences.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/core/preferences/SubcorpusPreferences.java	(revision 2550)
@@ -0,0 +1,33 @@
+package org.txm.searchengine.cqp.core.preferences;
+
+import org.osgi.service.prefs.Preferences;
+import org.txm.core.preferences.TXMPreferences;
+
+public class SubcorpusPreferences extends TXMPreferences {
+
+	public static String EDITORMODE = "editor_mode";
+	
+	public SubcorpusPreferences() {
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * Gets the instance.
+	 * @return the instance
+	 */
+	public static TXMPreferences getInstance()	{
+		if (!TXMPreferences.instances.containsKey(SubcorpusPreferences.class)) {
+			new SubcorpusPreferences();
+		}
+		return TXMPreferences.instances.get(SubcorpusPreferences.class);
+	}
+	
+	@Override
+	public void initializeDefaultPreferences() {
+		super.initializeDefaultPreferences();
+		
+		Preferences preferences = this.getDefaultPreferencesNode();
+		
+		preferences.putBoolean(EDITORMODE, false);
+	}
+}

Property changes on: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/core/preferences/SubcorpusPreferences.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

