Index: tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ExportCorpus.java
===================================================================
--- tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ExportCorpus.java	(revision 2484)
+++ tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ExportCorpus.java	(revision 2485)
@@ -37,6 +37,7 @@
 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;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.FileDialog;
@@ -47,22 +48,23 @@
 import org.txm.rcp.swt.dialog.LastOpened;
 import org.txm.rcp.utils.JobHandler;
 import org.txm.searchengine.cqp.corpus.MainCorpus;
+import org.txm.searchengine.cqp.rcp.dialogs.ExportCorpusDialog;
 
 /**
  * Export a corpus to the .txm binary format (Zip)
  */
 public class ExportCorpus extends AbstractHandler {
-
+	
 	public final static String ID = "org.txm.rcp.commands.base.ExportCorpus"; //$NON-NLS-1$
+	
 	/** The selection. */
 	private IStructuredSelection selection;
-
+	
 	/** The lastopenedfile. */
 	private static String lastopenedfile;
-
+	
 	/*
 	 * (non-Javadoc)
-	 * 
 	 * @see
 	 * org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands
 	 * .ExecutionEvent)
@@ -70,65 +72,46 @@
 	@Override
 	public Object execute(ExecutionEvent event) throws ExecutionException {
 		selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
-
+		
 		Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event)
 				.getShell();
-
+		
 		String txmhome = Toolbox.getTxmHomePath();
 		if (!(selection.getFirstElement() instanceof MainCorpus))
 			return null;
-
+		
 		final MainCorpus corpus = (MainCorpus) selection.getFirstElement();
-
+		
 		if (corpus.isModified()) {
-			boolean ret = MessageDialog.openConfirm(shell, "Export - "+corpus.getName()+" annotations not saved", "Do you wish to export without the current annotations?\n\n(to include the current annotations in the exported corpus, you need to save them before calling the \"Export\" command)");
+			boolean ret = MessageDialog.openConfirm(shell, "Export - " + corpus.getName() + " annotations not saved",
+					"Do you wish to export without the current annotations?\n\n(to include the current annotations in the exported corpus, you need to save them before calling the \"Export\" command)");
 			if (!ret) return null;
 		}
 		
-		FileDialog dialog = new FileDialog(shell, SWT.SAVE);
-		String[] exts = {"*.txm", "*.zip"}; //$NON-NLS-1$ //$NON-NLS-2$
-		dialog.setFilterExtensions(exts);
-		if (LastOpened.getFile(ID) != null) {
-			lastopenedfile = LastOpened.getFolder(ID)
-					+ "/" + LastOpened.getFile(ID); //$NON-NLS-1$
-		} else if (lastopenedfile != null) {
-			dialog.setFilterPath(new File(lastopenedfile).getAbsolutePath());
-		} else {
-			dialog.setFilterPath(txmhome + "/samples"); //$NON-NLS-1$
-		}
-
-		dialog.setFileName(corpus.getName()+".txm");
+		ExportCorpusDialog dialog = new ExportCorpusDialog(shell, corpus);
 		
-		if (dialog.open() != null) {
-			String filepath = dialog.getFilterPath()
-					+ "/" + dialog.getFileName(); //$NON-NLS-1$
-			if (!(filepath.endsWith(".txm") || filepath.endsWith(".zip"))) { //$NON-NLS-1$ //$NON-NLS-2$
-				filepath += ".txm"; //$NON-NLS-1$
-			}
-			LastOpened.set(ID, dialog.getFilterPath(), dialog.getFileName());
-			lastopenedfile = filepath;
-			final File outfile = new File(filepath);
-			JobHandler jobhandler = new JobHandler(NLS.bind(
-					TXMUIMessages.exportingP0ThisMayTakeAWhile, corpus.getName())) {
+		if (dialog.open() == Window.OK) {
+			
+			final File outfile = dialog.getZipFile();
+			JobHandler jobhandler = new JobHandler(NLS.bind(TXMUIMessages.exportingP0ThisMayTakeAWhile, corpus.getName())) {
+				
 				@Override
 				protected IStatus run(IProgressMonitor monitor) {
 					this.runInit(monitor);
 					try {
-						monitor.beginTask(
-								NLS.bind(TXMUIMessages.exportingP0ThisMayTakeAWhile,
-										corpus.getName()), 100);
+						monitor.beginTask(NLS.bind(TXMUIMessages.exportingP0ThisMayTakeAWhile, corpus.getName()), 100);
 						
-
-						if (!corpus.export(outfile, this)) {
-							System.out.println(NLS.bind(
-									TXMUIMessages.failedToExportCorpusP0, corpus.getName()));
+						if (!corpus.export(outfile, this, dialog.getIgnoreNames())) {
+							System.out.println(NLS.bind(TXMUIMessages.failedToExportCorpusP0, corpus.getName()));
 						}
-
-						System.out.println(TXMUIMessages.bind(TXMUIMessages.doneTheCreatedBinaryFileIsP0,outfile.getAbsolutePath()));
+						
+						System.out.println(TXMUIMessages.bind(TXMUIMessages.doneTheCreatedBinaryFileIsP0, outfile.getAbsolutePath()));
 						monitor.worked(100);
-					} catch (ThreadDeath td) {
+					}
+					catch (ThreadDeath td) {
 						return Status.CANCEL_STATUS;
-					} finally {
+					}
+					finally {
 						monitor.done();
 					}
 					return Status.OK_STATUS;
@@ -136,7 +119,7 @@
 			};
 			jobhandler.startJob();
 		}
-
+		
 		return null;
 	}
-}
\ No newline at end of file
+}
Index: tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/dialogs/ExportCorpusDialog.java
===================================================================
--- tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/dialogs/ExportCorpusDialog.java	(revision 0)
+++ tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/dialogs/ExportCorpusDialog.java	(revision 2485)
@@ -0,0 +1,297 @@
+package org.txm.searchengine.cqp.rcp.dialogs;
+
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CellLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+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.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.txm.Toolbox;
+import org.txm.objects.Project;
+import org.txm.rcp.swt.dialog.LastOpened;
+import org.txm.searchengine.cqp.corpus.CQPCorpus;
+
+/**
+ * Allow to select the file to create and select elements to include in the binary
+ * 
+ *
+ */
+public class ExportCorpusDialog extends Dialog {
+	
+	private List<String> defaultFiles = Arrays.asList("HTML", "txm", "data", "registry", "annotations", "analec", "temporary_annotations");
+	
+	private File zipFile;
+	
+	private LinkedHashMap<File, Boolean> selectedFiles;
+	
+	private CQPCorpus corpus;
+	
+	private TableViewer treeViewer;
+	
+	private TableViewerColumn nameColumn;
+	
+	private Text textField;
+	
+	private Button selectButton;
+	
+	public final static String ID = ExportCorpusDialog.class.getName();
+	
+	private static String lastopenedfile;
+	
+	/**
+	 * 
+	 * @param parentShell
+	 * @param title
+	 * @param question
+	 * @param text
+	 */
+	public ExportCorpusDialog(Shell parentShell, CQPCorpus corpus) {
+		super(parentShell);
+		this.corpus = corpus;
+	}
+	
+	@Override
+	protected void configureShell(Shell newShell) {
+		super.configureShell(newShell);
+		newShell.setText(NLS.bind("Exporting {0}...", corpus.getName()));
+		newShell.setMinimumSize(400, 200);
+	}
+	
+	@Override
+	protected Control createButtonBar(Composite parent) {
+		Control c = super.createButtonBar(parent);
+		getButton(IDialogConstants.OK_ID).setEnabled(false);
+		return c;
+	}
+	
+	@Override
+	protected Control createDialogArea(Composite parent) {
+		Composite comp = (Composite) super.createDialogArea(parent);
+		
+		GridLayout layout = (GridLayout) comp.getLayout();
+		layout.numColumns = 3;
+		
+		Label l = new Label(comp, SWT.LEFT);
+		l.setText("Output file");
+		l.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
+		
+		textField = new Text(comp, SWT.SINGLE | SWT.BORDER);
+		textField.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
+		
+		selectButton = new Button(comp, SWT.PUSH);
+		selectButton.setText("...");
+		selectButton.addSelectionListener(new SelectionListener() {
+			
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				FileDialog dialog = new FileDialog(selectButton.getShell());
+				
+				String[] exts = { "*.txm", "*.zip" }; //$NON-NLS-1$ //$NON-NLS-2$
+				dialog.setFilterExtensions(exts);
+				if (LastOpened.getFile(ID) != null) {
+					lastopenedfile = LastOpened.getFolder(ID) + "/" + LastOpened.getFile(ID); //$NON-NLS-1$
+				}
+				else if (lastopenedfile != null) {
+					dialog.setFilterPath(new File(lastopenedfile).getAbsolutePath());
+				}
+				else {
+					dialog.setFilterPath(Toolbox.getTxmHomePath() + "/samples"); //$NON-NLS-1$
+				}
+				
+				dialog.setFileName(corpus.getName() + ".txm");
+				
+				String path = dialog.open();
+				if (path != null) {
+					textField.setText(path);
+					getButton(IDialogConstants.OK_ID).setEnabled(true);
+				}
+				else {
+					textField.setText("");
+					getButton(IDialogConstants.OK_ID).setEnabled(false);
+				}
+			}
+			
+			@Override
+			public void widgetDefaultSelected(SelectionEvent e) {}
+		});
+		
+		selectedFiles = new LinkedHashMap<>();
+		Project project = corpus.getProject();
+		File directory = project.getProjectDirectory();
+		if (directory.exists()) {
+			
+			File[] files = directory.listFiles(new FileFilter() {
+				
+				@Override
+				public boolean accept(File f) {
+					return !f.isHidden() && f.isDirectory() && !defaultFiles.contains(f.getName());
+				}
+			});
+			Arrays.sort(files, new Comparator<File>() {
+				
+				@Override
+				public int compare(File arg0, File arg1) {
+					if (arg0.isDirectory() && arg1.isDirectory()) {
+						return arg0.getName().compareTo(arg1.getName());
+					}
+					else if (arg0.isFile() && arg1.isFile()) {
+						return arg0.getName().compareTo(arg1.getName());
+					}
+					else {
+						if (arg0.isDirectory()) {
+							return -1;
+						}
+						else {
+							return 1;
+						}
+					}
+				}
+			});
+			for (File f : files) {
+				if (!f.isHidden() && f.isDirectory()) {
+					
+					if (defaultFiles.contains(f.getName())) {
+						selectedFiles.put(f, true);
+					}
+					else {
+						selectedFiles.put(f, false);
+					}
+				}
+			}
+			
+			if (files.length > 0) {
+				treeViewer = new TableViewer(comp, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+				
+				treeViewer.setContentProvider(new ArrayContentProvider());
+				
+				treeViewer.getTable().addListener(SWT.Selection, event -> {
+					
+					if (event.detail == SWT.CHECK) {
+						TableItem item = (TableItem) event.item;
+						selectedFiles.put((File) event.item.getData(), item.getChecked());
+					}
+				});
+				
+				treeViewer.getTable().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 3, 1));
+				treeViewer.getTable().setHeaderVisible(true);
+				treeViewer.getTable().setLinesVisible(true);
+				
+				nameColumn = new TableViewerColumn(treeViewer, SWT.NONE);
+				nameColumn.getColumn().setText("Extra files");
+				nameColumn.getColumn().pack();
+				nameColumn.setLabelProvider(new CellLabelProvider() {
+					
+					@Override
+					public void update(ViewerCell cell) {
+						Object element = cell.getElement();
+						
+						if (element instanceof File) {
+							File f = (File) element;
+							cell.setText(f.getName());
+						}
+						else {
+							cell.setText("" + element.getClass());
+						}
+					}
+				});
+				
+				treeViewer.setInput(files);
+				for (int i = 0; i < files.length; i++) {
+					treeViewer.getTable().getItem(i).setChecked(selectedFiles.get(files[i]));
+				}
+				
+				Button selectAllButton = new Button(comp, SWT.PUSH);
+				selectAllButton.setText("Select All");
+				selectAllButton.addSelectionListener(new SelectionListener() {
+					
+					@Override
+					public void widgetSelected(SelectionEvent e) {
+						massSelect(true);
+					}
+					
+					@Override
+					public void widgetDefaultSelected(SelectionEvent e) {}
+				});
+				
+				Button clearAllButton = new Button(comp, SWT.PUSH);
+				clearAllButton.setText("Deselect All");
+				clearAllButton.addSelectionListener(new SelectionListener() {
+					
+					@Override
+					public void widgetSelected(SelectionEvent e) {
+						massSelect(false);
+					}
+					
+					@Override
+					public void widgetDefaultSelected(SelectionEvent e) {}
+				});
+			}
+		}
+		
+		return comp;
+	}
+	
+	protected void massSelect(boolean b) {
+		for (int i = 0; i < treeViewer.getTable().getItems().length; i++) {
+			treeViewer.getTable().getItem(i).setChecked(b);
+		}
+		for (File f : selectedFiles.keySet()) {
+			selectedFiles.put(f, b);
+		}
+	}
+	
+	@Override
+	protected boolean isResizable() {
+		return true;
+	}
+	
+	@Override
+	protected void buttonPressed(int buttonId) {
+		if (buttonId == Dialog.OK) {
+			zipFile = new File(textField.getText());
+		}
+		super.buttonPressed(buttonId);
+	}
+	
+	public File getZipFile() {
+		return zipFile;
+	}
+	
+	public LinkedHashMap<File, Boolean> getFileSelection() {
+		return selectedFiles;
+	}
+	
+	public HashSet<String> getIgnoreNames() {
+		HashSet<String> ignore = new HashSet<>();
+		for (File f : selectedFiles.keySet()) {
+			if (!selectedFiles.get(f)) {
+				ignore.add(f.getName());
+			}
+		}
+		return ignore;
+	}
+}

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

