Index: tmp/org.txm.para.rcp/src/org/txm/para/rcp/Activator.java
===================================================================
--- tmp/org.txm.para.rcp/src/org/txm/para/rcp/Activator.java	(revision 0)
+++ tmp/org.txm.para.rcp/src/org/txm/para/rcp/Activator.java	(revision 349)
@@ -0,0 +1,50 @@
+package org.txm.para.rcp;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "org.txm.para.rcp"; //$NON-NLS-1$
+
+	// The shared instance
+	private static Activator plugin;
+	
+	/**
+	 * The constructor
+	 */
+	public Activator() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		super.start(context);
+		plugin = this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		plugin = null;
+		super.stop(context);
+	}
+
+	/**
+	 * Returns the shared instance
+	 *
+	 * @return the shared instance
+	 */
+	public static Activator getDefault() {
+		return plugin;
+	}
+
+}

Property changes on: tmp/org.txm.para.rcp/src/org/txm/para/rcp/Activator.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/DefineParaViewReferencePattern.java
===================================================================
--- tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/DefineParaViewReferencePattern.java	(revision 0)
+++ tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/DefineParaViewReferencePattern.java	(revision 349)
@@ -0,0 +1,383 @@
+// 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.para.rcp.editors;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
+import org.txm.functions.ReferencePattern;
+import org.txm.para.rcp.editors.ParaBrowserEditor;
+import org.txm.rcp.Messages;
+import org.txm.rcp.editors.concordances.ConcordancesEditor;
+import org.txm.searchengine.cqp.corpus.Property;
+import org.txm.searchengine.cqp.corpus.StructuralUnit;
+import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
+// TODO: Auto-generated Javadoc
+/**
+ * Action to build the reference pattern.
+ *
+ * @ author mdecorde
+ */
+public class DefineParaViewReferencePattern extends Action implements IWorkbenchAction {
+
+	/** The Constant ID. */
+	private static final String ID = "org.txm.rcp.editors.concordances.definereferencepattern"; //$NON-NLS-1$
+	
+	/** The window. */
+	private IWorkbenchWindow window;
+	
+	/** The concordance editor. */
+	private ConcordancesEditor concordanceEditor;
+	
+	/** The para browser editor. */
+	private ParaBrowserEditor paraBrowserEditor;
+
+	/**
+	 * Instantiates a new define reference pattern.
+	 *
+	 * @param window the window
+	 * @param concordanceEditor the concordance editor
+	 */
+	public DefineParaViewReferencePattern(IWorkbenchWindow window,
+			ConcordancesEditor concordanceEditor) {
+		this.window = window;
+		this.concordanceEditor = concordanceEditor;
+		setId(ID);
+		setText(Messages.DefineReferencePattern_1);
+		setToolTipText(Messages.DefineReferencePattern_2);
+	}
+
+	/**
+	 * Instantiates a new define reference pattern.
+	 *
+	 * @param window the window
+	 * @param paraBrowserEditor the para browser editor
+	 */
+	public DefineParaViewReferencePattern(IWorkbenchWindow window,
+			ParaBrowserEditor paraBrowserEditor) {
+		this.window = window;
+		this.paraBrowserEditor = paraBrowserEditor;
+		setId(ID);
+		setText(Messages.DefineReferencePattern_1);
+		setToolTipText(Messages.DefineReferencePattern_2);
+	}
+
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.ui.actions.ActionFactory.IWorkbenchAction#dispose()
+	 */
+	@Override
+	public void dispose() {
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.action.Action#run()
+	 */
+	@Override
+	public void run() {
+		List<StructuralUnit> structuralUnits = null;
+		List<Property> availableReferenceItems = new ArrayList<Property>();
+		try {
+			if (paraBrowserEditor != null) {
+				structuralUnits = paraBrowserEditor.getCorpus()
+						.getOrderedStructuralUnits();
+				availableReferenceItems.addAll(paraBrowserEditor.getCorpus()
+						.getOrderedProperties());
+
+			} else if (concordanceEditor != null) {
+				structuralUnits = concordanceEditor.getCorpus()
+						.getOrderedStructuralUnits();
+				availableReferenceItems.addAll(concordanceEditor.getCorpus()
+						.getOrderedProperties());
+
+			}
+
+		} catch (Exception e) {
+			org.txm.rcp.utils.Logger.printStackTrace(e);
+		}
+
+		for (StructuralUnit unit : structuralUnits) {
+			availableReferenceItems.addAll(unit.getProperties());
+		}
+
+		// System.out.println("selected "+concordanceEditor.getSelectedReferences());
+		// System.out.println("before avail"+availableReferenceItems);
+		if (paraBrowserEditor != null) {
+			availableReferenceItems.remove(paraBrowserEditor
+					.getSelectedReferences());
+		} else {
+			availableReferenceItems.remove(concordanceEditor
+					.getSelectedViewReferences());
+		}
+
+		// System.out.println("after avail"+availableReferenceItems);
+		DefineReferencePatternDialog d = null;
+		if (paraBrowserEditor != null) {
+			d = new DefineReferencePatternDialog(window.getShell(),
+					availableReferenceItems, paraBrowserEditor
+							.getSelectedReferences());
+		} else if (concordanceEditor != null) {
+			d = new DefineReferencePatternDialog(window.getShell(),
+					availableReferenceItems, concordanceEditor
+							.getSelectedViewReferences());
+		}
+
+		if (d.open() == Window.OK) {
+			if (paraBrowserEditor != null) {
+				paraBrowserEditor.setReferencePattern(new ReferencePattern(d
+						.getSelectesdReferenceItems()));
+			} else if (concordanceEditor != null) {
+				concordanceEditor.setRefViewPattern(new ReferencePattern(d
+						.getSelectesdReferenceItems()));
+			}
+			//System.out.println(concordanceEditor.getViewReferencePattern());
+		}
+	}
+
+	/**
+	 * The Class DefineReferencePatternDialog.
+	 */
+	private class DefineReferencePatternDialog extends Dialog {
+
+		/** The available reference items. */
+		private List<Property> availableReferenceItems;
+		
+		/** The selected reference items. */
+		private List<Property> selectedReferenceItems;
+
+		/**
+		 * Instantiates a new define reference pattern dialog.
+		 *
+		 * @param parentShell the parent shell
+		 * @param availableReferenceItems the available reference items
+		 * @param selectedReferences the selected references
+		 */
+		protected DefineReferencePatternDialog(Shell parentShell,
+				List<Property> availableReferenceItems,
+				List<Property> selectedReferences) {
+			super(parentShell);
+			
+			this.availableReferenceItems = availableReferenceItems;
+			this.selectedReferenceItems = selectedReferences;
+			this.availableReferenceItems.removeAll(selectedReferences);
+			this.setShellStyle(this.getShellStyle() | SWT.RESIZE);	
+		}
+
+		/**
+		 * Gets the selectesd reference items.
+		 *
+		 * @return the selectesd reference items
+		 */
+		public List<Property> getSelectesdReferenceItems() {
+			return selectedReferenceItems;
+		}
+
+		/* (non-Javadoc)
+		 * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+		 */
+		@Override
+		protected void configureShell(Shell shell) {
+		      super.configureShell(shell);
+		      shell.setText(Messages.DefineReferencePattern_0);
+		      
+		      shell.setSize(400, 500);
+		      shell.setLocation(shell.getParent().getLocation());
+		   }
+		
+		/* (non-Javadoc)
+		 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+		 */
+		@Override
+		protected Control createDialogArea(Composite parent) {
+
+			Composite mainArea = new Composite(parent, SWT.NONE);
+			mainArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
+					true, true));
+			mainArea.setLayout(new GridLayout(4, false));
+
+			final org.eclipse.swt.widgets.List availbleItems = new org.eclipse.swt.widgets.List(
+					mainArea, SWT.BORDER | SWT.V_SCROLL);
+			for (Property property : availableReferenceItems) {
+				if (property instanceof StructuralUnitProperty) {
+					StructuralUnitProperty sProperty = (StructuralUnitProperty) property;
+					availbleItems.add(sProperty.getStructuralUnit().getName()
+							+ ": " + property.getName()); //$NON-NLS-1$
+				} else {
+					availbleItems.add(property.getName());
+				}
+			}
+						
+			GridData gridData = new GridData(GridData.FILL, GridData.FILL,
+					true, true);
+			//Point size = availbleItems.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+			//gridData.widthHint = size.x;
+			availbleItems.setLayoutData(gridData);
+
+			Composite selectionButtons = new Composite(mainArea, SWT.NONE);
+			selectionButtons.setLayout(new GridLayout(1, false));
+			Button select = new Button(selectionButtons, SWT.ARROW | SWT.RIGHT);
+			Button unselect = new Button(selectionButtons, SWT.ARROW | SWT.LEFT);
+
+			final org.eclipse.swt.widgets.List selectedItems = new org.eclipse.swt.widgets.List(
+					mainArea, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
+			selectedItems.setLayoutData(gridData);
+			for (Property property : selectedReferenceItems) {
+				if (property instanceof StructuralUnitProperty) {
+					StructuralUnitProperty sProperty = (StructuralUnitProperty) property;
+					selectedItems.add(sProperty.getStructuralUnit().getName()
+							+ ": " + property.getName()); //$NON-NLS-1$
+				} else {
+					selectedItems.add(property.getName());
+				}
+			}
+			
+			//DBL CLICK Listeners
+			selectedItems.addMouseListener(new MouseListener() {
+				@Override
+				public void mouseUp(MouseEvent e) { }
+				
+				@Override
+				public void mouseDown(MouseEvent e) { }
+				
+				@Override
+				public void mouseDoubleClick(MouseEvent e) {
+					int ind = selectedItems.getSelectionIndex();
+					availbleItems.add(selectedItems.getItem(ind));
+					selectedItems.remove(ind);
+					availableReferenceItems
+							.add(selectedReferenceItems.get(ind));
+					selectedReferenceItems.remove(ind);
+					selectedItems.setSelection(ind);	
+				}
+			});
+			availbleItems.addMouseListener(new MouseListener() {
+				@Override
+				public void mouseUp(MouseEvent e) { }
+				
+				@Override
+				public void mouseDown(MouseEvent e) { }
+				
+				@Override
+				public void mouseDoubleClick(MouseEvent e) {
+					int ind = availbleItems.getSelectionIndex();
+					selectedItems.add(availbleItems.getItem(ind));
+					availbleItems.remove(ind);
+					selectedReferenceItems
+							.add(availableReferenceItems.get(ind));
+					availableReferenceItems.remove(ind);
+					availbleItems.setSelection(ind);
+				}
+			});
+
+			Composite orderButtons = new Composite(mainArea, SWT.NONE);
+			orderButtons.setLayout(new GridLayout(1, false));
+			Button up = new Button(orderButtons, SWT.ARROW | SWT.UP);
+			Button down = new Button(orderButtons, SWT.ARROW | SWT.DOWN);
+
+			select.addSelectionListener(new SelectionAdapter() {
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					int ind = availbleItems.getSelectionIndex();
+					selectedItems.add(availbleItems.getItem(ind));
+					availbleItems.remove(ind);
+					selectedReferenceItems
+							.add(availableReferenceItems.get(ind));
+					availableReferenceItems.remove(ind);
+					availbleItems.setSelection(ind);
+				}
+			});
+
+			unselect.addSelectionListener(new SelectionAdapter() {
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					int ind = selectedItems.getSelectionIndex();
+					availbleItems.add(selectedItems.getItem(ind));
+					selectedItems.remove(ind);
+					availableReferenceItems
+							.add(selectedReferenceItems.get(ind));
+					selectedReferenceItems.remove(ind);
+					selectedItems.setSelection(ind);					
+				}
+			});
+
+			up.addSelectionListener(new SelectionAdapter() {
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					int ind = selectedItems.getSelectionIndex();
+					if (ind > 0) {
+						String value = selectedItems.getItem(ind);
+						selectedItems.remove(ind);
+						selectedItems.add(value, ind -1);
+						
+						Property prop = selectedReferenceItems.get(ind);
+						selectedReferenceItems.remove(ind);
+						selectedReferenceItems.add(ind-1,prop);
+						
+						selectedItems.setSelection(ind -1);
+					}
+				}
+			});
+
+			down.addSelectionListener(new SelectionAdapter() {
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					int ind = selectedItems.getSelectionIndex();
+					if (ind < selectedItems.getItemCount() - 1) {
+						String value = selectedItems.getItem(ind);
+						selectedItems.remove(ind);
+						selectedItems.add(value, ind + 1);
+						
+						Property prop = selectedReferenceItems.get(ind);
+						selectedReferenceItems.remove(ind);
+						selectedReferenceItems.add(ind+1, prop);
+						
+						selectedItems.setSelection(ind + 1);
+					}
+				}
+			});
+
+			return mainArea;
+		}
+	}
+}

Property changes on: tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/DefineParaViewReferencePattern.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/CorpusReferenceDialog.java
===================================================================
--- tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/CorpusReferenceDialog.java	(revision 0)
+++ tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/CorpusReferenceDialog.java	(revision 349)
@@ -0,0 +1,177 @@
+// 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.para.rcp.editors;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+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.ui.IWorkbenchPartSite;
+import org.txm.searchengine.cqp.corpus.Property;
+import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CorpusReferenceDialog.
+ */
+public class CorpusReferenceDialog extends Dialog {
+
+	/** The available reference items. */
+	private List<Property> availableReferenceItems;
+	
+	/** The selected reference items. */
+	private List<Property> selectedReferenceItems;
+
+	/**
+	 * Instantiates a new corpus reference dialog.
+	 *
+	 * @param iWorkbenchPartSite the i workbench part site
+	 * @param availableReferenceItems the available reference items
+	 */
+	public CorpusReferenceDialog(IWorkbenchPartSite iWorkbenchPartSite,
+			List<Property> availableReferenceItems) {
+		super(iWorkbenchPartSite);
+		this.availableReferenceItems = availableReferenceItems;
+		this.selectedReferenceItems = new ArrayList<Property>();
+	}
+
+	/**
+	 * Gets the selectesd reference items.
+	 *
+	 * @return the selectesd reference items
+	 */
+	public List<Property> getSelectesdReferenceItems() {
+		return selectedReferenceItems;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+	 */
+	@Override
+	protected Control createDialogArea(Composite parent) {
+
+		Composite mainArea = new Composite(parent, SWT.NONE);
+		mainArea.setLayout(new GridLayout(4, false));
+
+		final org.eclipse.swt.widgets.List availbleItems = new org.eclipse.swt.widgets.List(
+				mainArea, SWT.BORDER | SWT.V_SCROLL);
+		for (Property property : availableReferenceItems) {
+			if (property instanceof StructuralUnitProperty) {
+				StructuralUnitProperty sProperty = (StructuralUnitProperty) property;
+				availbleItems.add(sProperty.getStructuralUnit().getName()
+						+ ": " + property.getName()); //$NON-NLS-1$
+			} else {
+				availbleItems.add(property.getName());
+			}
+		}
+		GridData gridData = new GridData(GridData.FILL, GridData.FILL, true,
+				false);
+		Point size = availbleItems.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+		gridData.widthHint = size.x;
+		availbleItems.setLayoutData(gridData);
+
+		Composite selectionButtons = new Composite(mainArea, SWT.NONE);
+		selectionButtons.setLayout(new GridLayout(1, false));
+		Button select = new Button(selectionButtons, SWT.ARROW | SWT.RIGHT);
+		Button unselect = new Button(selectionButtons, SWT.ARROW | SWT.LEFT);
+
+		final org.eclipse.swt.widgets.List selectedItems = new org.eclipse.swt.widgets.List(
+				mainArea, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
+		selectedItems.setLayoutData(gridData);
+
+		Composite orderButtons = new Composite(mainArea, SWT.NONE);
+		orderButtons.setLayout(new GridLayout(1, false));
+		Button up = new Button(orderButtons, SWT.ARROW | SWT.UP);
+		Button down = new Button(orderButtons, SWT.ARROW | SWT.DOWN);
+
+		select.addSelectionListener(new SelectionAdapter() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				int ind = availbleItems.getSelectionIndex();
+				selectedItems.add(availbleItems.getItem(ind));
+				availbleItems.remove(ind);
+				selectedReferenceItems.add(availableReferenceItems.get(ind));
+				availableReferenceItems.remove(ind);
+				availbleItems.setSelection(ind);
+			}
+		});
+
+		unselect.addSelectionListener(new SelectionAdapter() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				int ind = selectedItems.getSelectionIndex();
+				availbleItems.add(selectedItems.getItem(ind));
+				selectedItems.remove(ind);
+				availableReferenceItems.add(selectedReferenceItems.get(ind));
+				selectedReferenceItems.remove(ind);
+				selectedItems.setSelection(ind);
+			}
+		});
+
+		up.addSelectionListener(new SelectionAdapter() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				int ind = selectedItems.getSelectionIndex();
+				if (ind > 0) {
+					selectedItems.add(selectedItems.getItem(ind), ind - 1);
+					selectedItems.remove(ind + 1);
+					selectedReferenceItems.add(selectedReferenceItems
+							.get(ind - 1));
+					selectedReferenceItems.remove(ind + 1);
+					selectedItems.setSelection(ind - 1);
+				}
+			}
+		});
+
+		down.addSelectionListener(new SelectionAdapter() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				int ind = selectedItems.getSelectionIndex();
+				if (ind < selectedItems.getItemCount() - 1) {
+					selectedItems.add(selectedItems.getItem(ind), ind + 2);
+					selectedItems.remove(ind);
+					selectedReferenceItems.add(selectedReferenceItems
+							.get(ind + 2));
+					selectedReferenceItems.remove(ind);
+					selectedItems.setSelection(ind + 2);
+				}
+			}
+		});
+
+		return mainArea;
+	}
+}

Property changes on: tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/CorpusReferenceDialog.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/ParaBrowserEditor.java
===================================================================
--- tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/ParaBrowserEditor.java	(revision 0)
+++ tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/ParaBrowserEditor.java	(revision 349)
@@ -0,0 +1,807 @@
+// 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.para.rcp.editors;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+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.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.EditorPart;
+import org.txm.functions.ReferencePattern;
+import org.txm.para.functions.ParaBrowser;
+import org.txm.rcp.Messages;
+import org.txm.rcp.StatusLine;
+import org.txm.rcp.editors.input.ParaBrowserEditorInput;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.corpus.MainCorpus;
+import org.txm.searchengine.cqp.corpus.Property;
+import org.txm.searchengine.cqp.corpus.QueryResult;
+import org.txm.searchengine.cqp.corpus.StructuralUnit;
+import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
+import org.txm.utils.Pair;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ParaBrowserEditor.
+ */
+public class ParaBrowserEditor extends EditorPart {
+
+	/** The Constant ID. */
+	public static final String ID = "org.txm.rcp.editors.parabrowser.ParaBrowserEditor"; //$NON-NLS-1$
+
+	/** The display area. */
+	private Composite displayArea;
+	
+	/** The define reference pattern action. */
+	protected Action defineReferencePatternAction;
+	
+	/** The define order corpus action. */
+	protected Action defineOrderCorpusAction;
+
+	/** The corpus text areas. */
+	private Map<MainCorpus, StyledText> corpusTextAreas;
+	
+	/** The corpus ref areas. */
+	private Map<MainCorpus, Label> corpusRefAreas;
+	
+	/** The corpus query result areas. */
+	private Map<MainCorpus, QueryResult> corpusQueryResultAreas;
+
+	/** The selected structural unit. */
+	private StructuralUnit selectedStructuralUnit;
+	
+	/** The selected structural unit para id. */
+	private StructuralUnitProperty selectedStructuralUnitParaId;
+	
+	/** The selected value. */
+	private String selectedValue;
+
+	/** The structural units combo. */
+	private Combo structuralUnitsCombo;
+	
+	/** The structural units final. */
+	private List<StructuralUnit> structuralUnitsFinal;
+	
+	/** The para id combo. */
+	private Combo paraIdCombo;
+
+	/** The reference pattern. */
+	private ReferencePattern referencePattern = new ReferencePattern();
+	
+	/** The selected reference. */
+	private String selectedReference = ""; //$NON-NLS-1$
+
+	/** The selected view corpus. */
+	private List<MainCorpus> selectedViewCorpus;
+	
+	/** The available view corpus. */
+	private List<MainCorpus> availableViewCorpus;
+
+	/** The available view properties. */
+	private List<StructuralUnit> availableViewProperties;
+	
+	/** The selected view properties. */
+	private List<StructuralUnit> selectedViewProperties;
+	
+	private ParaBrowser paraBrowser = new ParaBrowser();
+	
+	/** The next. */
+	private Button next;
+	
+	/** The prev. */
+	private Button prev;
+
+	/**
+	 * Instantiates a new para browser editor.
+	 */
+	public ParaBrowserEditor() {
+	}
+
+	/**
+	 * Do save.
+	 *
+	 * @param arg0 the arg0
+	 * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
+	 */
+	@Override
+	public void doSave(IProgressMonitor arg0) {
+		// TODO Auto-generated method stub
+	}
+
+	/**
+	 * Do save as.
+	 *
+	 * @see org.eclipse.lyon gournd zeroui.part.EditorPart#doSaveAs()
+	 */
+	@Override
+	public void doSaveAs() {
+		// TODO Auto-generated method stub
+	}
+
+	/**
+	 * Inits the.
+	 *
+	 * @param site the site
+	 * @param input the input
+	 * @throws PartInitException the part init exception
+	 * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite,
+	 * org.eclipse.ui.IEditorInput)
+	 */
+	@Override
+	public void init(IEditorSite site, IEditorInput input)
+			throws PartInitException {
+		setSite(site);
+		setInput(input);
+
+		this.selectedViewCorpus = ((ParaBrowserEditorInput) input)
+				.getCorpusList();
+		List<MainCorpus> tempView = new ArrayList<MainCorpus>();
+		availableViewCorpus = new ArrayList<MainCorpus>();
+		if (selectedViewCorpus.size() > 3) {
+			int i = 0;
+			for (MainCorpus corpus : selectedViewCorpus) {
+				if (i < 4) {
+					tempView.add(corpus);
+				} else {
+					availableViewCorpus.add(corpus);
+				}
+				++i;
+			}
+			selectedViewCorpus = tempView;
+		}
+	}
+
+	/**
+	 * Checks if is dirty.
+	 *
+	 * @return true, if is dirty
+	 * @see org.eclipse.ui.part.EditorPart#isDirty()
+	 */
+	@Override
+	public boolean isDirty() {
+		return false;
+	}
+
+	/**
+	 * Checks if is save as allowed.
+	 *
+	 * @return true, if is save as allowed
+	 * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
+	 */
+	@Override
+	public boolean isSaveAsAllowed() {
+		return false;
+	}
+
+	/**
+	 * Creates the part control.
+	 *
+	 * @param parent the parent
+	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+	 */
+	@Override
+	public void createPartControl(final Composite parent) {
+		corpusTextAreas = new HashMap<MainCorpus, StyledText>();
+		corpusRefAreas = new HashMap<MainCorpus, Label>();
+		corpusQueryResultAreas = new HashMap<MainCorpus, QueryResult>();
+
+		parent.setLayout(new GridLayout(1, false));
+
+		Composite controlArea = new Composite(parent, SWT.BORDER);
+		controlArea
+				.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));// FILL,
+		composeControlArea(controlArea);
+
+		displayArea = new Composite(parent, SWT.NONE);
+		displayArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));// 2ème
+																				// arg
+																				// :
+																				// true
+		composeDisplayArea(displayArea);
+		reloadTexts();
+	}
+
+	/**
+	 * Compose display area.
+	 *
+	 * @param displayArea the display area
+	 */
+	private void composeDisplayArea(Composite displayArea) {
+
+		if (selectedViewCorpus != null) {
+			displayArea.setLayout(new GridLayout(selectedViewCorpus.size(),
+					true));
+
+			for (int i = 0; i < selectedViewCorpus.size(); ++i) {
+				composeSingleTextDisplayArea(displayArea, selectedViewCorpus
+						.get(i), selectedViewCorpus.size());
+			}
+		} else {
+			displayArea.setLayout(new GridLayout(1, false));
+
+			selectedViewCorpus = new ArrayList<MainCorpus>();
+			selectedViewCorpus.add(selectedViewCorpus.get(0));
+			composeSingleTextDisplayArea(displayArea,
+					selectedViewCorpus.get(0), 1);
+		}
+
+	}
+
+	/**
+	 * Compose single text display area.
+	 *
+	 * @param displayArea the display area
+	 * @param displayedCorpus the displayed corpus
+	 * @param nbtextDisplayAreas the nbtext display areas
+	 */
+	private void composeSingleTextDisplayArea(Composite displayArea,
+			MainCorpus displayedCorpus, int nbtextDisplayAreas) {
+		Composite singleCorpusArea = new Composite(displayArea, SWT.NONE);
+		singleCorpusArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
+				true));
+		GridLayout layout = new GridLayout(1, false);
+		singleCorpusArea.setLayout(layout);
+
+		// Corpus name Label
+		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+		Label nameCorpusLabel = new Label(singleCorpusArea, SWT.NONE);
+		nameCorpusLabel.setText(displayedCorpus.getName());
+		nameCorpusLabel.setLayoutData(new GridData(GridData.FILL,
+				GridData.FILL, true, false));
+
+		// Text
+		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+		StyledText corpusTextArea = new StyledText(singleCorpusArea, SWT.WRAP
+				| SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); // SWT.BORDER
+		corpusTextArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
+				true, true));
+		// String text = displayedCorpus.getTextRegion(selectedStructuralUnit,
+		// selectedStructuralUnitParaId, selectedValue);
+		corpusTextArea.setText(""); //$NON-NLS-1$
+		corpusTextAreas.put(displayedCorpus, corpusTextArea);
+
+		// Reference Label
+		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+		Label referenceLabel = new Label(singleCorpusArea, SWT.NONE);
+		referenceLabel.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
+				true, false));
+		if (referencePattern != null) {
+			// selectedStructuralUnit.getName()
+			List<Property> references = referencePattern.getProperties();
+			for (Property property : references) {
+				selectedReference += property.getName() + "/"; //$NON-NLS-1$
+			}
+		}
+		referenceLabel.setText(Messages.ParaBrowserEditor_3 + selectedReference);
+		corpusRefAreas.put(displayedCorpus, referenceLabel);
+	}
+
+	/**
+	 * Compose control area.
+	 *
+	 * @param controlArea the control area
+	 */
+	private void composeControlArea(Composite controlArea) {
+		controlArea.setLayout(new GridLayout(6, false));
+		// composeCorpusDisplay(controlArea);
+		composeStructuralNavigation(controlArea);
+		composeNavigation(controlArea);
+
+		createActions();
+
+		MenuManager menuManager = new MenuManager("#PopupMenu"); //$NON-NLS-1$
+		menuManager.setRemoveAllWhenShown(true);
+		menuManager.addMenuListener(new IMenuListener() {
+			@Override
+			public void menuAboutToShow(IMenuManager manager) {
+				manager.add(defineReferencePatternAction);
+				manager.add(defineOrderCorpusAction);
+			}
+		});
+		controlArea.setMenu(menuManager.createContextMenu(controlArea));
+		getSite().registerContextMenu(menuManager,
+				this.getSite().getSelectionProvider());
+	}
+
+	/*
+	 * private void composeCorpusDisplay(Composite controlArea){ //Manager for
+	 * corpus display Button buttonManager = new Button(controlArea, SWT.PUSH);
+	 * buttonManager.setText("manage view"); buttonManager.addMouseListener(new
+	 * MouseListener() {
+	 * 
+	 * @Override public void mouseUp(MouseEvent e) {
+	 * launchCorpusSelectionManager(); }
+	 * 
+	 * @Override public void mouseDown(MouseEvent e) {
+	 * launchCorpusSelectionManager(); }
+	 * 
+	 * @Override public void mouseDoubleClick(MouseEvent e) { // TODO
+	 * Auto-generated method stub
+	 * 
+	 * } });
+	 * 
+	 * //Manager to build reference Button buttonReference = new
+	 * Button(controlArea, SWT.PUSH); buttonReference.setText("reference");
+	 * buttonReference.addMouseListener(new MouseListener() {
+	 * 
+	 * @Override public void mouseUp(MouseEvent e) {
+	 * launchCorpusReferenceManager(); }
+	 * 
+	 * @Override public void mouseDown(MouseEvent e) {
+	 * launchCorpusReferenceManager(); }
+	 * 
+	 * @Override public void mouseDoubleClick(MouseEvent e) { // TODO
+	 * Auto-generated method stub
+	 * 
+	 * } }); }
+	 */
+
+	/**
+	 * Compose navigation.
+	 *
+	 * @param controlArea the control area
+	 */
+	private void composeNavigation(Composite controlArea) {
+		Composite navigationArea = new Composite(controlArea, SWT.NONE);
+		navigationArea.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false,
+				false));// false, false
+		navigationArea.setLayout(new GridLayout(2, false));
+		// [<] [>]
+
+		// [<]
+		prev = new Button(navigationArea, SWT.PUSH);
+		prev.setText(Messages.ConcordancesEditor_12);
+		prev.addListener(SWT.Selection, new Listener() {
+			@Override
+			public void handleEvent(Event event) {
+				nextorpreviousText(false);
+			}
+		});
+		prev.setEnabled(true);
+
+		// [>]
+		next = new Button(navigationArea, SWT.PUSH);
+		next.setText(Messages.ConcordancesEditor_13);
+		next.addListener(SWT.Selection, new Listener() {
+			@Override
+			public void handleEvent(Event event) {
+				nextorpreviousText(true);
+			}
+		});
+		next.setEnabled(true);
+
+	}
+
+	/**
+	 * Compose structural navigation.
+	 *
+	 * @param controlArea the control area
+	 */
+	private void composeStructuralNavigation(Composite controlArea) {
+		// StructuralUnit
+		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+		Button refButton = new Button(controlArea, SWT.PUSH);
+		refButton.setText(Messages.ParaBrowserEditor_4);
+		refButton
+				.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true));
+		refButton.addSelectionListener(new SelectionListener() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				defineReferencePatternAction.run();
+			}
+
+			@Override
+			public void widgetDefaultSelected(SelectionEvent e) {
+			}
+		});
+
+		Label structureLabel = new Label(controlArea, SWT.NONE);
+		structureLabel.setText(Messages.ParaBrowserEditor_5); // LEFT
+		structureLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
+				true));
+
+		structuralUnitsCombo = new Combo(controlArea, SWT.READ_ONLY);
+
+		List<StructuralUnit> structuralUnits = null;
+		if (selectedViewCorpus.size() > 0) {
+			try {
+				// same structure in all corpus, therefore use the first in the
+				// list
+				structuralUnits = selectedViewCorpus.get(0)
+						.getOrderedStructuralUnits();
+			} catch (CqiClientException e) {
+				System.err
+						.println(Messages.ObjectExplorer_9);
+				return;
+			}
+		}
+		structuralUnitsFinal = new ArrayList<StructuralUnit>();
+		if (structuralUnits != null) {
+			for (StructuralUnit unit : structuralUnits) {
+				if (unit.getOrderedProperties() != null
+						&& unit.getOrderedProperties().size() != 0) {
+					structuralUnitsCombo.add(unit.getName());
+					structuralUnitsFinal.add(unit);
+				}
+			}
+		}
+
+		if (structuralUnitsCombo.getItemCount() == 0) {
+			// this.getButton(IDialogConstants.OK_ID).setEnabled(false);
+		} else {
+			structuralUnitsCombo.select(0);
+			selectedStructuralUnit = structuralUnitsFinal.get(0);
+		}
+
+		// StructuralUnitParaId
+		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+		Label paraIdLabel = new Label(controlArea, SWT.NONE);
+		paraIdLabel.setText("paraid"); //$NON-NLS-1$
+		paraIdLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
+				true));
+
+		paraIdCombo = new Combo(controlArea, SWT.READ_ONLY);
+		paraIdCombo
+				.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
+
+		structuralUnitsCombo.addSelectionListener(new SelectionListener() {
+			@Override
+			public void widgetDefaultSelected(SelectionEvent e) {
+			}
+
+			@Override
+			public void widgetSelected(SelectionEvent event) {
+				reloadIds();
+			}
+		});
+
+		for (StructuralUnitProperty property : structuralUnitsFinal.get(0)
+				.getOrderedProperties()) {
+			if (property.getName().equals("id")) { //$NON-NLS-1$
+				selectedStructuralUnitParaId = property;
+				try {
+					for (String value : property.getValues()) {
+						paraIdCombo.add(value);
+					}
+				} catch (CqiClientException e1) {
+					// TODO Auto-generated catch block
+					org.txm.rcp.utils.Logger.printStackTrace(e1);
+				}
+			}
+		}
+		paraIdCombo.select(0);
+		try {
+			if (selectedStructuralUnitParaId != null)
+				selectedValue = selectedStructuralUnitParaId.getValues().get(0);
+		} catch (CqiClientException e1) {
+			// TODO Auto-generated catch block
+			org.txm.rcp.utils.Logger.printStackTrace(e1);
+		}
+
+		paraIdCombo.addSelectionListener(new SelectionListener() {
+			@Override
+			public void widgetDefaultSelected(SelectionEvent e) {
+			}
+
+			@Override
+			public void widgetSelected(SelectionEvent event) {
+				// selectedStructuralUnitParaId =
+				// selectedStructuralUnit.getProperties().get(paraIdCombo.getSelectionIndex());
+				if (selectedStructuralUnitParaId != null) {
+					try {
+						List<String> values = selectedStructuralUnitParaId
+								.getValues();
+						Collections.sort(values);
+						selectedValue = values.get(paraIdCombo
+								.getSelectionIndex());
+						// System.out.println("Selection of id = "+selectedValue);
+					} catch (CqiClientException e) {
+						// TODO Auto-generated catch block
+						org.txm.rcp.utils.Logger.printStackTrace(e);
+					}
+				}
+				reloadTexts();
+				reloadReferences();
+			}
+		});
+	}
+
+	/**
+	 * Creates the actions.
+	 */
+	private void createActions() {
+		defineReferencePatternAction = new DefineParaViewReferencePattern(getSite()
+				.getWorkbenchWindow(), this);
+		defineOrderCorpusAction = new CorpusSelection(getSite()
+				.getWorkbenchWindow(), this);
+	}
+
+	/**
+	 * Reload display.
+	 */
+	private void reloadDisplay() {
+		if (selectedViewCorpus != null) {
+			displayArea.setLayout(new GridLayout(selectedViewCorpus.size(),
+					true));
+
+			for (int i = 0; i < selectedViewCorpus.size(); ++i) {
+				composeSingleTextDisplayArea(displayArea, selectedViewCorpus
+						.get(i), selectedViewCorpus.size());
+			}
+		} else {
+			displayArea.setLayout(new GridLayout(1, false));
+
+			selectedViewCorpus = new ArrayList<MainCorpus>();
+			selectedViewCorpus.add(selectedViewCorpus.get(0));
+			composeSingleTextDisplayArea(displayArea,
+					selectedViewCorpus.get(0), 1);
+		}
+		displayArea.layout();
+		displayArea.pack(true);
+	}
+
+	/**
+	 * Reload texts.
+	 */
+	private void reloadTexts() {
+		Set keys = corpusTextAreas.keySet();
+		Iterator<MainCorpus> it = keys.iterator();
+		while (it.hasNext()) {
+			MainCorpus corpus = it.next();
+			StyledText textArea = corpusTextAreas.get(corpus);
+			Pair<String, QueryResult> pair = paraBrowser.getTextRegion(corpus,
+					selectedStructuralUnit, selectedStructuralUnitParaId,
+					selectedValue);
+			// corpusQueryResultAreas.put(corpus, pair.getSecond());
+			textArea.setText(pair.getFirst());
+			// Label ref = corpusRefAreas.get(corpus);
+			// ref.setText("Ref: ...");
+		}
+	}
+
+	/**
+	 * Reload ids.
+	 */
+	private void reloadIds() {
+		selectedStructuralUnit = structuralUnitsFinal.get(structuralUnitsCombo
+				.getSelectionIndex());
+		paraIdCombo.removeAll();
+
+		for (StructuralUnitProperty property : structuralUnitsFinal.get(
+				structuralUnitsCombo.getSelectionIndex()).getOrderedProperties()) {
+			if (property.getName().equals("id")) { //$NON-NLS-1$
+				selectedStructuralUnitParaId = property;
+				try {
+					List<String> values = property.getValues();
+					Collections.sort(values);
+					for (String value : values) {
+						paraIdCombo.add(value);
+					}
+				} catch (CqiClientException e1) {
+					// TODO Auto-generated catch block
+					org.txm.rcp.utils.Logger.printStackTrace(e1);
+				}
+			}
+		}
+
+		if (paraIdCombo.getItemCount() > 0) {
+			paraIdCombo.select(0);
+			try {
+				if (selectedStructuralUnitParaId != null) {
+					List<String> values = selectedStructuralUnitParaId
+							.getValues();
+					Collections.sort(values);
+					selectedValue = values.get(0);
+					reloadTexts();
+					reloadReferences();
+				}
+			} catch (CqiClientException e1) {
+				// TODO Auto-generated catch block
+				org.txm.rcp.utils.Logger.printStackTrace(e1);
+			}
+			// selectedStructuralUnitParaId =
+			// selectedStructuralUnit.getProperties().get(0);
+		}
+	}
+
+	/**
+	 * Reload references.
+	 */
+	private void reloadReferences() {
+		Set<MainCorpus> keys = corpusRefAreas.keySet();
+		Iterator<MainCorpus> it = keys.iterator();
+		while (it.hasNext()) {
+			MainCorpus corpus = it.next();
+
+			// get all reference values of all lines
+			/*
+			 * List<Integer> beginingOfKeywordsPositions = new
+			 * ArrayList<Integer>(j-i); Map<Property, List<List<String>>>
+			 * refValues = new HashMap<Property, List<List<String>>>(); for
+			 * (Property property : referencePattern){
+			 * refValues.put(property,cache
+			 * .get(property).getData(beginingOfKeywordsPositions,
+			 * Collections.nCopies(beginingOfKeywordsPositions.size(), 1))); }
+			 */
+
+			Label refArea = corpusRefAreas.get(corpus);
+			refArea.setText(NLS.bind(Messages.ParaBrowserEditor_9, corpus.getName(), selectedReference));
+		}
+
+	}
+
+	/**
+	 * Nextorprevious text.
+	 *
+	 * @param findNext the find next
+	 */
+	public void nextorpreviousText(boolean findNext) {
+		// get Property
+		System.out.println(NLS.bind(Messages.ParaBrowserEditor_11, 
+			new Object[]{findNext, selectedStructuralUnit, selectedStructuralUnitParaId, selectedValue}));
+		if (selectedStructuralUnit != null) {
+			// Multiple Query, as many as there are corpuses displayed
+			Set keys = corpusTextAreas.keySet();
+			Iterator<MainCorpus> it = keys.iterator();
+			String newValue = ""; //$NON-NLS-1$
+			for (int i = 0; it.hasNext(); ++i) {
+				// if (i==0){
+				MainCorpus corpus = it.next();
+				System.out.println("CORPUS ################### " //$NON-NLS-1$
+						+ corpus.getName());
+				newValue = paraBrowser.getNextOrPrevious(corpus, selectedStructuralUnit,
+						selectedStructuralUnitParaId, selectedValue, findNext);
+				// }
+			}
+			if (!newValue.equals("")) { //$NON-NLS-1$
+				System.out.println(Messages.ParaBrowserEditor_18 + newValue);
+				int index = paraIdCombo.indexOf(newValue);
+				if (index != -1) {
+					selectedValue = newValue;
+					paraIdCombo.select(index);
+				}
+			} else {
+				System.out.println(Messages.ParaBrowserEditor_19 + newValue);
+			}
+			reloadTexts();
+			reloadReferences();
+		}
+	}
+
+	/**
+	 * Sets the reference pattern.
+	 *
+	 * @param referencePattern the new reference pattern
+	 */
+	public void setReferencePattern(ReferencePattern referencePattern) {
+		this.referencePattern = referencePattern;
+		selectedReference = Messages.ObjectExplorer_9;
+		if (referencePattern != null) {
+			// selectedStructuralUnit.getName()
+			List<Property> references = referencePattern.getProperties();
+			for (Property property : references) {
+				selectedReference += property.getName() + Messages.ParaBrowserEditor_21;
+			}
+		}
+		reloadReferences();
+	}
+
+	/**
+	 * Sets the focus.
+	 *
+	 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+	 */
+	@Override
+	public void setFocus() {
+		StatusLine.setMessage(Messages.ParaBrowserEditor_22);
+	}
+
+	/**
+	 * Gets the corpus.
+	 *
+	 * @return the corpus
+	 */
+	public MainCorpus getCorpus() {
+		if (selectedViewCorpus.size() > 0) {
+			return selectedViewCorpus.get(0);
+		} else
+			return null;
+	}
+
+	/**
+	 * Gets the selected corpus.
+	 *
+	 * @return the selected corpus
+	 */
+	public List<MainCorpus> getSelectedCorpus() {
+		return selectedViewCorpus;
+	}
+
+	/**
+	 * Sets the selected corpus.
+	 *
+	 * @param corpus the corpus
+	 * @param corpusAvailable the corpus available
+	 */
+	public void setSelectedCorpus(List<MainCorpus> corpus,
+			List<MainCorpus> corpusAvailable) {
+		selectedViewCorpus = corpus;
+		availableViewCorpus = corpusAvailable;
+		reloadDisplay();
+	}
+
+	/**
+	 * Gets the available corpus.
+	 *
+	 * @return the available corpus
+	 */
+	public List<MainCorpus> getAvailableCorpus() {
+		if (availableViewCorpus == null) {
+			availableViewCorpus = new ArrayList<MainCorpus>();
+		}
+		return availableViewCorpus;
+	}
+
+	/**
+	 * Gets the selected references.
+	 *
+	 * @return the selected references
+	 */
+	public List<Property> getSelectedReferences() {
+		return referencePattern.getProperties();
+	}
+}

Property changes on: tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/ParaBrowserEditor.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/CorpusSelection.java
===================================================================
--- tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/CorpusSelection.java	(revision 0)
+++ tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/CorpusSelection.java	(revision 349)
@@ -0,0 +1,320 @@
+// 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.para.rcp.editors;
+
+import java.util.List;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
+import org.txm.searchengine.cqp.corpus.MainCorpus;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class CorpusSelection.
+ */
+public class CorpusSelection extends Action implements IWorkbenchAction {
+
+	/** The Constant ID. */
+	private static final String ID = "org.txm.rcp.editors.parabrowser.corpusselection"; //$NON-NLS-1$
+	
+	/** The window. */
+	private IWorkbenchWindow window;
+	
+	/** The para browser editor. */
+	private ParaBrowserEditor paraBrowserEditor;
+
+	/**
+	 * Instantiates a new corpus selection.
+	 *
+	 * @param window the window
+	 * @param paraBrowserEditor the para browser editor
+	 */
+	public CorpusSelection(IWorkbenchWindow window,
+			ParaBrowserEditor paraBrowserEditor) {
+		this.window = window;
+		this.paraBrowserEditor = paraBrowserEditor;
+		setId(ID);
+		setText("Définir les corpus à l'affichage"); //$NON-NLS-1$
+		setToolTipText("Corpus à l'affichage"); //$NON-NLS-1$
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.ui.actions.ActionFactory.IWorkbenchAction#dispose()
+	 */
+	@Override
+	public void dispose() {
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.action.Action#run()
+	 */
+	@Override
+	public void run() {
+		if (paraBrowserEditor != null) {
+			List<MainCorpus> selectedCorpus = paraBrowserEditor
+					.getSelectedCorpus();
+			List<MainCorpus> availableCorpus = paraBrowserEditor
+					.getAvailableCorpus();
+
+			CorpusSelectionDialog d = new CorpusSelectionDialog(window
+					.getShell(), availableCorpus, selectedCorpus);
+			if (d.open() == Window.OK) {
+				if (paraBrowserEditor == null) {
+					paraBrowserEditor.setSelectedCorpus(d.getSelectedCorpus(),
+							d.getAvailableCorpus());
+				}
+			}
+		}
+	}
+
+	/**
+	 * The Class CorpusSelectionDialog.
+	 */
+	private class CorpusSelectionDialog extends Dialog {
+
+		/** The available corpus. */
+		final private List<MainCorpus> availableCorpus;
+		
+		/** The selected corpus. */
+		final private List<MainCorpus> selectedCorpus;
+
+		/** The available corpus view. */
+		org.eclipse.swt.widgets.List availableCorpusView;
+		
+		/** The selected corpus view. */
+		org.eclipse.swt.widgets.List selectedCorpusView;
+
+		/**
+		 * Instantiates a new corpus selection dialog.
+		 *
+		 * @param parentShell the parent shell
+		 * @param availableCorpus the available corpus
+		 * @param selectedCorpus the selected corpus
+		 */
+		protected CorpusSelectionDialog(Shell parentShell,
+				List<MainCorpus> availableCorpus,
+				List<MainCorpus> selectedCorpus) {
+			super(parentShell);
+			this.availableCorpus = availableCorpus;
+			this.selectedCorpus = selectedCorpus;
+			// TODO Auto-generated constructor stub
+		}
+
+		/**
+		 * Gets the selected corpus.
+		 *
+		 * @return the selected corpus
+		 */
+		public List<MainCorpus> getSelectedCorpus() {
+			return selectedCorpus;
+		}
+
+		/**
+		 * Gets the available corpus.
+		 *
+		 * @return the available corpus
+		 */
+		public List<MainCorpus> getAvailableCorpus() {
+			return availableCorpus;
+		}
+
+		/* (non-Javadoc)
+		 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+		 */
+		@Override
+		protected Control createDialogArea(Composite parent) {
+			// parent.setLayout(new FormLayout());
+			Composite mainArea = new Composite(parent, SWT.NONE);
+			mainArea
+					.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+			// 4 columns
+			GridLayout layout = new GridLayout(4, false);
+			mainArea.setLayout(layout);
+
+			availableCorpusView = new org.eclipse.swt.widgets.List(mainArea,
+					SWT.BORDER | SWT.V_SCROLL);
+			GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
+			availableCorpusView.setLayoutData(gridData);
+
+			Composite selectionButtons = new Composite(mainArea, SWT.NONE);
+			selectionButtons.setLayout(new GridLayout(1, false));
+			Button select = new Button(selectionButtons, SWT.ARROW | SWT.RIGHT);
+			Button unselect = new Button(selectionButtons, SWT.ARROW | SWT.LEFT);
+
+			selectedCorpusView = new org.eclipse.swt.widgets.List(mainArea,
+					SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
+			gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
+			selectedCorpusView.setLayoutData(gridData);
+
+			Composite orderButtons = new Composite(mainArea, SWT.NONE);
+			orderButtons.setLayout(new GridLayout(1, false));
+			Button up = new Button(orderButtons, SWT.ARROW | SWT.UP);
+			Button down = new Button(orderButtons, SWT.ARROW | SWT.DOWN);
+
+			select.addSelectionListener(new SelectionAdapter() {
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					int index = availableCorpusView.getSelectionIndex();
+
+					selectedCorpus.add(availableCorpus.get(index));
+					availableCorpus.remove(index);
+
+					reload();
+					availableCorpusView.setSelection(index);
+				}
+			});
+
+			unselect.addSelectionListener(new SelectionAdapter() {
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					if (selectedCorpus.size() > 1) {
+						int index = selectedCorpusView.getSelectionIndex();
+
+						availableCorpus.add(selectedCorpus.get(index));
+						selectedCorpus.remove(index);
+
+						reload();
+						selectedCorpusView.setSelection(index);
+					}
+				}
+			});
+
+			up.addSelectionListener(new SelectionAdapter() {
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					int index = selectedCorpusView.getSelectionIndex();
+					if (index > 0) {
+						MainCorpus selectedC = selectedCorpus.get(index);
+						MainCorpus upperC = selectedCorpus.get(index - 1);
+
+						selectedCorpus.set(index, upperC);
+						selectedCorpus.set(index - 1, selectedC);
+
+						reload();
+						selectedCorpusView.setSelection(index - 1);
+					}
+				}
+			});
+
+			down.addSelectionListener(new SelectionAdapter() {
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					int index = selectedCorpusView.getSelectionIndex();
+					if (index < selectedCorpus.size() - 1) {
+						MainCorpus selectedC = selectedCorpus.get(index);
+						MainCorpus bellowC = selectedCorpus.get(index + 1);
+
+						selectedCorpus.set(index, bellowC);
+						selectedCorpus.set(index + 1, selectedC);
+
+						reload();
+						selectedCorpusView.setSelection(index + 1);
+					}
+				}
+			});
+
+			availableCorpusView.addMouseListener(new MouseAdapter() {
+				@Override
+				public void mouseDoubleClick(MouseEvent e) {
+					int index = selectedCorpusView.getSelectionIndex();
+
+					selectedCorpus.add(availableCorpus.get(index));
+					availableCorpus.remove(index);
+
+					reload();
+					availableCorpusView.setSelection(index);
+				}
+			});
+
+			selectedCorpusView.addMouseListener(new MouseAdapter() {
+				@Override
+				public void mouseDoubleClick(MouseEvent e) {
+					if (selectedCorpus.size() > 1) {
+						int index = selectedCorpusView.getSelectionIndex();
+
+						availableCorpus.add(selectedCorpus.get(index));
+						selectedCorpus.remove(index);
+
+						reload();
+						selectedCorpusView.setSelection(index);
+					}
+				}
+			});
+
+			reload();
+			return mainArea;
+		}
+
+		/**
+		 * Reload.
+		 */
+		public void reload() {
+			System.out
+					.println("CorpusSelectionDialog.reload() => availableCorpus[" //$NON-NLS-1$
+							+ availableCorpus.size()
+							+ "] / selectedCorpus[" //$NON-NLS-1$
+							+ selectedCorpus.size() + "]"); //$NON-NLS-1$
+			availableCorpusView.removeAll();
+			for (MainCorpus corpus : availableCorpus) {
+				if (!corpus.getName().equals("id")) //$NON-NLS-1$
+					availableCorpusView.add(corpus.getName());
+			}
+			selectedCorpusView.removeAll();
+			for (MainCorpus corpus : selectedCorpus) {
+				if (!corpus.getName().equals("id")) //$NON-NLS-1$
+					selectedCorpusView.add(corpus.getName());
+			}
+
+			availableCorpusView.getParent().layout();
+		}
+
+		/* (non-Javadoc)
+		 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+		 */
+		@Override
+		protected void okPressed() {
+			if (selectedCorpus.size() != 0)
+				super.okPressed();
+		}
+	}
+}

Property changes on: tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/CorpusSelection.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/DefineParaSortReferencePattern.java
===================================================================
--- tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/DefineParaSortReferencePattern.java	(revision 0)
+++ tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/DefineParaSortReferencePattern.java	(revision 349)
@@ -0,0 +1,383 @@
+// 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.para.rcp.editors;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
+import org.txm.functions.ReferencePattern;
+import org.txm.para.rcp.editors.ParaBrowserEditor;
+import org.txm.rcp.Messages;
+import org.txm.rcp.editors.concordances.ConcordancesEditor;
+import org.txm.searchengine.cqp.corpus.Property;
+import org.txm.searchengine.cqp.corpus.StructuralUnit;
+import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
+// TODO: Auto-generated Javadoc
+/**
+ * Action to build the reference pattern.
+ *
+ * @ author mdecorde
+ */
+public class DefineParaSortReferencePattern extends Action implements IWorkbenchAction {
+
+	/** The Constant ID. */
+	private static final String ID = "org.txm.rcp.editors.concordances.definereferencepattern"; //$NON-NLS-1$
+	
+	/** The window. */
+	private IWorkbenchWindow window;
+	
+	/** The concordance editor. */
+	private ConcordancesEditor concordanceEditor;
+	
+	/** The para browser editor. */
+	private ParaBrowserEditor paraBrowserEditor;
+
+	/**
+	 * Instantiates a new define reference pattern.
+	 *
+	 * @param window the window
+	 * @param concordanceEditor the concordance editor
+	 */
+	public DefineParaSortReferencePattern(IWorkbenchWindow window,
+			ConcordancesEditor concordanceEditor) {
+		this.window = window;
+		this.concordanceEditor = concordanceEditor;
+		setId(ID);
+		setText(Messages.DefineReferencePattern_3);
+		setToolTipText(Messages.DefineReferencePattern_4);
+	}
+
+	/**
+	 * Instantiates a new define reference pattern.
+	 *
+	 * @param window the window
+	 * @param paraBrowserEditor the para browser editor
+	 */
+	public DefineParaSortReferencePattern(IWorkbenchWindow window,
+			ParaBrowserEditor paraBrowserEditor) {
+		this.window = window;
+		this.paraBrowserEditor = paraBrowserEditor;
+		setId(ID);
+		setText(Messages.DefineReferencePattern_3);
+		setToolTipText(Messages.DefineReferencePattern_4);
+	}
+
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.ui.actions.ActionFactory.IWorkbenchAction#dispose()
+	 */
+	@Override
+	public void dispose() {
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.action.Action#run()
+	 */
+	@Override
+	public void run() {
+		List<StructuralUnit> structuralUnits = null;
+		List<Property> availableReferenceItems = new ArrayList<Property>();
+		try {
+			if (paraBrowserEditor != null) {
+				structuralUnits = paraBrowserEditor.getCorpus()
+						.getOrderedStructuralUnits();
+				availableReferenceItems.addAll(paraBrowserEditor.getCorpus()
+						.getOrderedProperties());
+
+			} else if (concordanceEditor != null) {
+				structuralUnits = concordanceEditor.getCorpus()
+						.getOrderedStructuralUnits();
+				availableReferenceItems.addAll(concordanceEditor.getCorpus()
+						.getOrderedProperties());
+
+			}
+
+		} catch (Exception e) {
+			org.txm.rcp.utils.Logger.printStackTrace(e);
+		}
+
+		for (StructuralUnit unit : structuralUnits) {
+			availableReferenceItems.addAll(unit.getProperties());
+		}
+
+		// System.out.println("selected "+concordanceEditor.getSelectedReferences());
+		// System.out.println("before avail"+availableReferenceItems);
+		if (paraBrowserEditor != null) {
+			availableReferenceItems.remove(paraBrowserEditor
+					.getSelectedReferences());
+		} else {
+			availableReferenceItems.remove(concordanceEditor
+					.getSelectedSortReferences());
+		}
+
+		// System.out.println("after avail"+availableReferenceItems);
+		DefineReferencePatternDialog d = null;
+		if (paraBrowserEditor != null) {
+			d = new DefineReferencePatternDialog(window.getShell(),
+					availableReferenceItems, paraBrowserEditor
+							.getSelectedReferences());
+		} else if (concordanceEditor != null) {
+			d = new DefineReferencePatternDialog(window.getShell(),
+					availableReferenceItems, concordanceEditor
+							.getSelectedSortReferences());
+		}
+
+		if (d.open() == Window.OK) {
+			if (paraBrowserEditor != null) {
+				paraBrowserEditor.setReferencePattern(new ReferencePattern(d
+						.getSelectesdReferenceItems()));
+			} else if (concordanceEditor != null) {
+				concordanceEditor.setRefSortPattern(new ReferencePattern(d
+						.getSelectesdReferenceItems()));
+			}
+			//System.out.println(concordanceEditor.getSortReferencePattern());
+		}
+	}
+
+	/**
+	 * The Class DefineReferencePatternDialog.
+	 */
+	private class DefineReferencePatternDialog extends Dialog {
+
+		/** The available reference items. */
+		private List<Property> availableReferenceItems;
+		
+		/** The selected reference items. */
+		private List<Property> selectedReferenceItems;
+
+		/**
+		 * Instantiates a new define reference pattern dialog.
+		 *
+		 * @param parentShell the parent shell
+		 * @param availableReferenceItems the available reference items
+		 * @param selectedReferences the selected references
+		 */
+		protected DefineReferencePatternDialog(Shell parentShell,
+				List<Property> availableReferenceItems,
+				List<Property> selectedReferences) {
+			super(parentShell);
+			
+			this.availableReferenceItems = availableReferenceItems;
+			this.selectedReferenceItems = selectedReferences;
+			this.availableReferenceItems.removeAll(selectedReferences);
+			this.setShellStyle(this.getShellStyle() | SWT.RESIZE);	
+		}
+
+		/**
+		 * Gets the selectesd reference items.
+		 *
+		 * @return the selectesd reference items
+		 */
+		public List<Property> getSelectesdReferenceItems() {
+			return selectedReferenceItems;
+		}
+
+		/* (non-Javadoc)
+		 * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+		 */
+		@Override
+		protected void configureShell(Shell shell) {
+		      super.configureShell(shell);
+		      shell.setText(Messages.DefineReferencePattern_5);
+		      
+		      shell.setSize(400, 500);
+		      shell.setLocation(shell.getParent().getLocation());
+		   }
+		
+		/* (non-Javadoc)
+		 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+		 */
+		@Override
+		protected Control createDialogArea(Composite parent) {
+
+			Composite mainArea = new Composite(parent, SWT.NONE);
+			mainArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
+					true, true));
+			mainArea.setLayout(new GridLayout(4, false));
+
+			final org.eclipse.swt.widgets.List availbleItems = new org.eclipse.swt.widgets.List(
+					mainArea, SWT.BORDER | SWT.V_SCROLL);
+			for (Property property : availableReferenceItems) {
+				if (property instanceof StructuralUnitProperty) {
+					StructuralUnitProperty sProperty = (StructuralUnitProperty) property;
+					availbleItems.add(sProperty.getStructuralUnit().getName()
+							+ ": " + property.getName()); //$NON-NLS-1$
+				} else {
+					availbleItems.add(property.getName());
+				}
+			}
+						
+			GridData gridData = new GridData(GridData.FILL, GridData.FILL,
+					true, true);
+			//Point size = availbleItems.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+			//gridData.widthHint = size.x;
+			availbleItems.setLayoutData(gridData);
+
+			Composite selectionButtons = new Composite(mainArea, SWT.NONE);
+			selectionButtons.setLayout(new GridLayout(1, false));
+			Button select = new Button(selectionButtons, SWT.ARROW | SWT.RIGHT);
+			Button unselect = new Button(selectionButtons, SWT.ARROW | SWT.LEFT);
+
+			final org.eclipse.swt.widgets.List selectedItems = new org.eclipse.swt.widgets.List(
+					mainArea, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
+			selectedItems.setLayoutData(gridData);
+			for (Property property : selectedReferenceItems) {
+				if (property instanceof StructuralUnitProperty) {
+					StructuralUnitProperty sProperty = (StructuralUnitProperty) property;
+					selectedItems.add(sProperty.getStructuralUnit().getName()
+							+ ": " + property.getName()); //$NON-NLS-1$
+				} else {
+					selectedItems.add(property.getName());
+				}
+			}
+			
+			//DBL CLICK Listeners
+			selectedItems.addMouseListener(new MouseListener() {
+				@Override
+				public void mouseUp(MouseEvent e) { }
+				
+				@Override
+				public void mouseDown(MouseEvent e) { }
+				
+				@Override
+				public void mouseDoubleClick(MouseEvent e) {
+					int ind = selectedItems.getSelectionIndex();
+					availbleItems.add(selectedItems.getItem(ind));
+					selectedItems.remove(ind);
+					availableReferenceItems
+							.add(selectedReferenceItems.get(ind));
+					selectedReferenceItems.remove(ind);
+					selectedItems.setSelection(ind);	
+				}
+			});
+			availbleItems.addMouseListener(new MouseListener() {
+				@Override
+				public void mouseUp(MouseEvent e) { }
+				
+				@Override
+				public void mouseDown(MouseEvent e) { }
+				
+				@Override
+				public void mouseDoubleClick(MouseEvent e) {
+					int ind = availbleItems.getSelectionIndex();
+					selectedItems.add(availbleItems.getItem(ind));
+					availbleItems.remove(ind);
+					selectedReferenceItems
+							.add(availableReferenceItems.get(ind));
+					availableReferenceItems.remove(ind);
+					availbleItems.setSelection(ind);
+				}
+			});
+
+			Composite orderButtons = new Composite(mainArea, SWT.NONE);
+			orderButtons.setLayout(new GridLayout(1, false));
+			Button up = new Button(orderButtons, SWT.ARROW | SWT.UP);
+			Button down = new Button(orderButtons, SWT.ARROW | SWT.DOWN);
+
+			select.addSelectionListener(new SelectionAdapter() {
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					int ind = availbleItems.getSelectionIndex();
+					selectedItems.add(availbleItems.getItem(ind));
+					availbleItems.remove(ind);
+					selectedReferenceItems
+							.add(availableReferenceItems.get(ind));
+					availableReferenceItems.remove(ind);
+					availbleItems.setSelection(ind);
+				}
+			});
+
+			unselect.addSelectionListener(new SelectionAdapter() {
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					int ind = selectedItems.getSelectionIndex();
+					availbleItems.add(selectedItems.getItem(ind));
+					selectedItems.remove(ind);
+					availableReferenceItems
+							.add(selectedReferenceItems.get(ind));
+					selectedReferenceItems.remove(ind);
+					selectedItems.setSelection(ind);					
+				}
+			});
+
+			up.addSelectionListener(new SelectionAdapter() {
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					int ind = selectedItems.getSelectionIndex();
+					if (ind > 0) {
+						String value = selectedItems.getItem(ind);
+						selectedItems.remove(ind);
+						selectedItems.add(value, ind -1);
+						
+						Property prop = selectedReferenceItems.get(ind);
+						selectedReferenceItems.remove(ind);
+						selectedReferenceItems.add(ind-1,prop);
+						
+						selectedItems.setSelection(ind -1);
+					}
+				}
+			});
+
+			down.addSelectionListener(new SelectionAdapter() {
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					int ind = selectedItems.getSelectionIndex();
+					if (ind < selectedItems.getItemCount() - 1) {
+						String value = selectedItems.getItem(ind);
+						selectedItems.remove(ind);
+						selectedItems.add(value, ind + 1);
+						
+						Property prop = selectedReferenceItems.get(ind);
+						selectedReferenceItems.remove(ind);
+						selectedReferenceItems.add(ind+1, prop);
+						
+						selectedItems.setSelection(ind + 1);
+					}
+				}
+			});
+
+			return mainArea;
+		}
+	}
+}

Property changes on: tmp/org.txm.para.rcp/src/org/txm/para/rcp/editors/DefineParaSortReferencePattern.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.para.rcp/build.properties
===================================================================
--- tmp/org.txm.para.rcp/build.properties	(revision 0)
+++ tmp/org.txm.para.rcp/build.properties	(revision 349)
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .

Property changes on: tmp/org.txm.para.rcp/build.properties
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.para.rcp/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- tmp/org.txm.para.rcp/.settings/org.eclipse.jdt.core.prefs	(revision 0)
+++ tmp/org.txm.para.rcp/.settings/org.eclipse.jdt.core.prefs	(revision 349)
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6

Property changes on: tmp/org.txm.para.rcp/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.para.rcp/.classpath
===================================================================
--- tmp/org.txm.para.rcp/.classpath	(revision 0)
+++ tmp/org.txm.para.rcp/.classpath	(revision 349)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Property changes on: tmp/org.txm.para.rcp/.classpath
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.para.rcp/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.para.rcp/META-INF/MANIFEST.MF	(revision 0)
+++ tmp/org.txm.para.rcp/META-INF/MANIFEST.MF	(revision 349)
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Rcp
+Bundle-SymbolicName: org.txm.para.rcp
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.txm.para.rcp.Activator
+Require-Bundle: org.txm.rcp;bundle-version="0.7.8",
+ org.txm.core;bundle-version="0.7.0",
+ org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.txm.para.core
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Export-Package: org.txm.para.rcp,
+ org.txm.para.rcp.editors

Property changes on: tmp/org.txm.para.rcp/META-INF/MANIFEST.MF
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.para.rcp/.project
===================================================================
--- tmp/org.txm.para.rcp/.project	(revision 0)
+++ tmp/org.txm.para.rcp/.project	(revision 349)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.txm.para.rcp</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Property changes on: tmp/org.txm.para.rcp/.project
___________________________________________________________________
Added: svn:mime-type
   + text/plain

