Index: TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Intersection.java
===================================================================
--- TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Intersection.java	(revision 3349)
+++ TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Intersection.java	(revision 3350)
@@ -81,7 +81,7 @@
 			return null;
 		}
 		else if (list.size() != 1) {
-			Log.info("Substraction need a selection of 1 corpus");
+			Log.info("Intersection need a selection of 1 corpus");
 			return null;
 		}
 		Object firstElement = list.get(0);
Index: TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Union.java
===================================================================
--- TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Union.java	(revision 3349)
+++ TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Union.java	(revision 3350)
@@ -81,7 +81,7 @@
 			return null;
 		}
 		else if (list.size() != 1) {
-			Log.info("Substraction need a selection of 1 corpus");
+			Log.info("Union need a selection of 1 corpus");
 			return null;
 		}
 		Object firstElement = list.get(0);
Index: TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Complementary.java
===================================================================
--- TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Complementary.java	(revision 0)
+++ TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Complementary.java	(revision 3350)
@@ -0,0 +1,195 @@
+// Copyright © 2010-2020 ENS de Lyon., University of Franche-Comté
+// 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 java.util.Arrays;
+import java.util.List;
+
+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.messages.TXMUIMessages;
+import org.txm.rcp.swt.dialog.TextDialog;
+import org.txm.rcp.utils.JobHandler;
+import org.txm.rcp.views.corpora.CorporaView;
+import org.txm.searchengine.cqp.AbstractCqiClient;
+import org.txm.searchengine.cqp.CQPSearchEngine;
+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.rcp.dialogs.SetOperationsDialog;
+import org.txm.utils.logger.Log;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Command which creates a subcorpus from a Corpus @ author mdecorde.
+ */
+public class Complementary 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;
+		}
+		List list = selection.toList();
+		if (list.size() == 0) {
+			Log.info("No corpus selected");
+			return null;
+		}
+		else if (list.size() != 1) {
+			Log.info("Complementary need a selection of 1 corpus");
+			return null;
+		}
+		Object firstElement = list.get(0);
+		// Object secondElement = list.get(1);
+		
+		if (!(firstElement instanceof CQPCorpus)) {
+			System.out.println(TXMUIMessages.selectionIsNotACorpusColon + firstElement);
+			return null;
+		}
+		
+		// if (!(secondElement instanceof CQPCorpus)) {
+		// System.out.println(TXMUIMessages.selectionIsNotACorpusColon+secondElement);
+		// return null;
+		// }
+		
+		final CQPCorpus corpus = (CQPCorpus) firstElement;
+		try {
+			corpus.compute(false);
+		}
+		catch (InterruptedException e2) {
+			// TODO Auto-generated catch block
+			e2.printStackTrace();
+			return null;
+		}
+		// final CQPCorpus corpus2 = (CQPCorpus) secondElement;
+		// corpus2.compute(false);
+		
+		Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell();
+		final SetOperationsDialog d = new SetOperationsDialog(shell, "COMPL", 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);
+						Subcorpus subcorpus = null;
+						String name = d.getName();
+						if (name.length() == 0) {
+							name = d.getDefaultName();
+						}
+						
+						AbstractCqiClient cqi = CQPSearchEngine.getCqiClient();
+						
+						String cqpid = "S" + Subcorpus.getNextSubcorpusCounter();
+						CQPCorpus[] order = d.getCorpusOrder();
+						order[1].compute(false);
+						String query = cqpid + "=join " + order[0].getQualifiedCqpId() + " " + order[1].getQualifiedCqpId() + ";";
+						System.out.println("QUERY=" + query);
+						cqi.query(query);
+						
+						if (cqi.subCorpusSize(order[0].getMainCorpus() + ":" + cqpid) == 0) {
+							Log.info("The created subcorpus was empty. Aborting.");
+							return Status.CANCEL_STATUS;
+						}
+						
+						subcorpus = corpus.getCorpusParent().createSubcorpus(name, cqpid);
+						
+						if (subcorpus == null) {
+							monitor.done();
+							Log.warning(TXMUIMessages.errorColonSubcorpusWasNotCreated);
+							return Status.CANCEL_STATUS;
+						}
+						
+						System.out.println(NLS.bind(TXMUIMessages.doneColonP0Created, subcorpus.getName()));
+						monitor.worked(50);
+						
+						monitor.subTask(TXMUIMessages.refreshingCorpora);
+						final Subcorpus subcorpus2 = subcorpus;
+						syncExec(new Runnable() {
+							
+							@Override
+							public void run() {
+								CorporaView.refresh();
+								CorporaView.expand(subcorpus2.getParent());
+							}
+						});
+						
+						monitor.worked(100);
+					}
+					catch (ThreadDeath td) {
+						return Status.CANCEL_STATUS;
+					}
+					catch (Exception 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: TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Complementary.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/dialogs/SetOperationsDialog.java
===================================================================
--- TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/dialogs/SetOperationsDialog.java	(revision 3349)
+++ TXM/trunk/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/dialogs/SetOperationsDialog.java	(revision 3350)
@@ -1,6 +1,7 @@
 package org.txm.searchengine.cqp.rcp.dialogs;
 
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
@@ -143,7 +144,10 @@
 				if (inputElement == null) return new Object[0];
 				
 				if (inputElement instanceof CQPCorpus) {
-					return ((CQPCorpus)inputElement).getSubcorpora().toArray();
+					List<Subcorpus> c = ((CQPCorpus)inputElement).getSubcorpora();
+					ArrayList<Subcorpus> corpora = new ArrayList<Subcorpus>(c);
+					corpora.remove(corpus[0]);
+					return corpora.toArray();
 				}
 				return null;
 			}
@@ -173,7 +177,7 @@
 
 		nameColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
 		nameColumn.getColumn().setText("Availables Subcorpus");
-		nameColumn.getColumn().pack();
+		nameColumn.getColumn().setWidth(150);
 		nameColumn.setLabelProvider(new CellLabelProvider() {
 			@Override
 			public void update(ViewerCell cell) {
@@ -212,9 +216,9 @@
 	public String getDefaultName() {
 		String s = "[select a subcorpus in the list]";
 		if (corpus[1] != null) {
-			s = corpus[1].getName();
+			s = corpus[1].getSimpleName();
 		}
-		previousDefaultName = NLS.bind(symbols.get(operation), corpus[0].getName(), s);
+		previousDefaultName = NLS.bind(symbols.get(operation), corpus[0].getSimpleName(), s);
 		return previousDefaultName;
 	}
 
Index: TXM/trunk/org.txm.searchengine.cqp.rcp/plugin.xml
===================================================================
--- TXM/trunk/org.txm.searchengine.cqp.rcp/plugin.xml	(revision 3349)
+++ TXM/trunk/org.txm.searchengine.cqp.rcp/plugin.xml	(revision 3350)
@@ -186,6 +186,39 @@
                </or>
             </visibleWhen>
          </command>
+         <command
+               commandId="org.txm.searchengine.cqp.rcp.handlers.base.Substraction"
+               label="Substract"
+               style="push">
+            <visibleWhen
+                  checkEnabled="false">
+               <reference
+                     definitionId="OneSubCorpusSelected">
+               </reference>
+            </visibleWhen>
+         </command>
+         <command
+               commandId="org.txm.searchengine.cqp.rcp.handlers.base.Intersection"
+               label="Intersect"
+               style="push">
+            <visibleWhen
+                  checkEnabled="false">
+               <reference
+                     definitionId="OneSubCorpusSelected">
+               </reference>
+            </visibleWhen>
+         </command>
+         <command
+               commandId="org.txm.searchengine.cqp.rcp.handlers.base.Union"
+               label="Add"
+               style="push">
+            <visibleWhen
+                  checkEnabled="false">
+               <reference
+                     definitionId="OneSubCorpusSelected">
+               </reference>
+            </visibleWhen>
+         </command>
       </menuContribution>
       <menuContribution
             locationURI="menu:menu.file.export?after=menu.file.export.begin">
@@ -228,7 +261,7 @@
          </command>
          <command
                commandId="org.txm.searchengine.cqp.rcp.handlers.base.Substraction"
-               label="MINUS"
+               label="Substract"
                style="push">
             <visibleWhen
                   checkEnabled="false">
@@ -239,7 +272,7 @@
          </command>
          <command
                commandId="org.txm.searchengine.cqp.rcp.handlers.base.Intersection"
-               label="INTER"
+               label="Intersect"
                style="push">
             <visibleWhen
                   checkEnabled="false">
@@ -250,7 +283,7 @@
          </command>
          <command
                commandId="org.txm.searchengine.cqp.rcp.handlers.base.Union"
-               label="UNION"
+               label="Add"
                style="push">
             <visibleWhen
                   checkEnabled="false">
