Index: tmp/org.txm.textsbalance.rcp/plugin.xml
===================================================================
--- tmp/org.txm.textsbalance.rcp/plugin.xml	(revision 0)
+++ tmp/org.txm.textsbalance.rcp/plugin.xml	(revision 126)
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+   <extension
+         point="org.eclipse.ui.editors">
+      <editor
+            class="org.txm.textsbalance.rcp.editors.BalanceEditor"
+            icon="icons/balance.png"
+            id="org.txm.textsbalance.core.functions.TextsBalance"
+            name="Texts Balance">
+      </editor>
+   </extension>
+   <extension
+         point="org.eclipse.ui.commands">
+      <command
+            defaultHandler="org.txm.textsbalance.rcp.handlers.ComputeBalance"
+            id="ComputeBalance"
+            name="Texts balance">
+         <commandParameter
+               id="TextsBalance.createNewEditor"
+               name="%commandParameter.name"
+               optional="true">
+         </commandParameter>
+      </command>
+   </extension>
+   <extension
+         point="org.eclipse.ui.menus">
+      <menuContribution
+            allPopups="false"
+            locationURI="toolbar:org.txm.rcpapplication.toolbartools">
+         <command
+               commandId="ComputeBalance"
+               icon="icons/balance.png"
+               style="push">
+            <visibleWhen
+                  checkEnabled="false">
+               <reference
+                     definitionId="OneCorpusSelected">
+               </reference>
+            </visibleWhen>
+         </command>
+      </menuContribution>
+      <menuContribution
+            allPopups="false"
+            locationURI="popup:org.txm.rcpapplication.views.CorporaView">
+         <command
+               commandId="ComputeBalance"
+               icon="icons/balance.png"
+               style="push">
+            <visibleWhen
+                  checkEnabled="false">
+               <reference
+                     definitionId="OneCorpusSelected">
+               </reference>
+            </visibleWhen>
+         </command>
+      </menuContribution>
+      <menuContribution
+            locationURI="menu:menu.tools">
+         <command
+               commandId="ComputeBalance"
+               icon="icons/balance.png"
+               style="push">
+            <visibleWhen
+                  checkEnabled="false">
+               <reference
+                     definitionId="OneCorpusSelected">
+               </reference>
+            </visibleWhen>
+         </command>
+      </menuContribution>
+   </extension>
+   <extension
+         point="org.eclipse.core.expressions.definitions">
+      <definition
+            id="InstanceOfBalanceEditor">
+         <with
+               variable="activeEditor">
+            <instanceof
+                  value="org.txm.textsbalance.rcp.editors.BalanceEditor">
+            </instanceof>
+         </with>
+      </definition>
+   </extension>
+   <extension
+         point="org.eclipse.ui.preferencePages">
+      <page
+            category="org.txm.rcpapplication.preferences.UserPreferencePage"
+            class="org.txm.textsbalance.rcp.preferences.TextsBalancePreferencePage"
+            id="org.txm.rcp.textsbalance.preferences.TextsBalancePreferencePage"
+            name="Texts balance">
+      </page>
+   </extension>
+   <extension
+         point="org.eclipse.core.runtime.adapters">
+      <factory
+            adaptableType="org.txm.textsbalance.core.functions.TextsBalance"
+            class="org.txm.textsbalance.rcp.adapters.TextsBalanceAdapterFactory">
+         <adapter
+               type="org.eclipse.ui.model.IWorkbenchAdapter">
+         </adapter>
+      </factory>
+   </extension>
+
+</plugin>

Property changes on: tmp/org.txm.textsbalance.rcp/plugin.xml
___________________________________________________________________
Added: svn:mime-type
   + text/plain

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

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

Index: tmp/org.txm.textsbalance.rcp/.classpath
===================================================================
--- tmp/org.txm.textsbalance.rcp/.classpath	(revision 0)
+++ tmp/org.txm.textsbalance.rcp/.classpath	(revision 126)
@@ -0,0 +1,11 @@
+<?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.7"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
+		<accessrules>
+			<accessrule kind="accessible" pattern="**"/>
+		</accessrules>
+	</classpathentry>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

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

Index: tmp/org.txm.textsbalance.rcp/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.textsbalance.rcp/META-INF/MANIFEST.MF	(revision 0)
+++ tmp/org.txm.textsbalance.rcp/META-INF/MANIFEST.MF	(revision 126)
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Texts Balance RCP
+Bundle-SymbolicName: org.txm.textsbalance.rcp;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: TXM
+Require-Bundle: org.txm.rcp;bundle-version="0.7.7",
+ org.eclipse.core.runtime;bundle-version="3.10.0",
+ org.eclipse.ui;bundle-version="3.106.1",
+ org.eclipse.jface.text,
+ org.eclipse.ui.editors,
+ org.txm.core;bundle-version="0.7.0",
+ org.txm.chartsengine.r.core,
+ org.eclipse.core.expressions;bundle-version="3.4.600",
+ org.txm.textsbalance.core;bundle-version="1.0.0",
+ org.txm.chartsengine.jfreechart.core;bundle-version="1.0.0",
+ org.txm.chartsengine.rcp;bundle-version="1.0.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: org.txm.textsbalance.rcp.adapters,
+ org.txm.textsbalance.rcp.editors,
+ org.txm.textsbalance.rcp.handlers,
+ org.txm.textsbalance.rcp.preferences

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

Index: tmp/org.txm.textsbalance.rcp/.project
===================================================================
--- tmp/org.txm.textsbalance.rcp/.project	(revision 0)
+++ tmp/org.txm.textsbalance.rcp/.project	(revision 126)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.txm.textsbalance.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.textsbalance.rcp/.project
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/editors/BalanceEditor.java
===================================================================
--- tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/editors/BalanceEditor.java	(revision 0)
+++ tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/editors/BalanceEditor.java	(revision 126)
@@ -0,0 +1,363 @@
+package org.txm.textsbalance.rcp.editors;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.txm.chartsengine.rcp.editors.ChartEditorPart;
+import org.txm.core.preferences.TXMPreferences;
+import org.txm.rcpapplication.views.CorporaView;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.corpus.StructuralUnit;
+import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
+import org.txm.searchengine.cqp.corpus.query.Match;
+import org.txm.textsbalance.core.functions.TextsBalance;
+import org.txm.textsbalance.core.preferences.TextsBalancePreferences;
+
+/**
+ * Texts balance editor.
+ * 
+ * @author mdecorde
+ * @author sjacquot
+ *
+ */
+public class BalanceEditor extends ChartEditorPart {
+
+	private Combo supCombo;
+
+	private Button groupByTexts;
+
+	private Button groupByWords;
+
+	private Combo suCombo;
+
+	/**
+	 * Structural unit properties to not display.
+	 */
+	protected String[] supsToSkip;
+	
+	
+	/**
+	 * 
+	 */
+	public BalanceEditor() {
+		
+		this.supsToSkip = new String[] {"id", "base", "project"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+	}
+
+	
+	@Override
+	public void createPartControl(Composite parent) {
+		super.createPartControl(parent);
+		
+		if (((TextsBalance)this.getResultData()).getCorpus() == null) {
+			System.out.println("Error: no corpus");
+			return;
+		}
+
+		Group group = new Group(this.getParametersGroup(), SWT.NONE);
+
+		group.setText("Group by:");
+		//group.setLayout(new RowLayout(SWT.VERTICAL));
+		group.setLayout(new RowLayout());
+		
+//		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
+//		gridData.horizontalSpan = 2;
+//		gridData.verticalIndent = 10;
+//		group.setLayoutData(gridData);
+
+		
+		groupByTexts = new Button(group, SWT.RADIO);
+		groupByTexts.setText("text");
+		groupByTexts.setSelection(!TXMPreferences.getBoolean(TextsBalancePreferences.PREFERENCES_NODE, this.getResultData(), TextsBalancePreferences.GROUP_BY_WORDS));	
+		
+		
+		groupByWords = new Button(group, SWT.RADIO);
+		groupByWords.setText("word");
+		groupByWords.setSelection(!groupByTexts.getSelection());
+
+		
+		suCombo = new Combo(this.getParametersGroup(), SWT.READ_ONLY);
+		supCombo = new Combo(this.getParametersGroup(), SWT.READ_ONLY);
+
+		try {
+			loadSU();
+		}
+		catch (CqiClientException e) {
+			e.printStackTrace();
+		}
+
+		
+		
+		suCombo.addSelectionListener(new SelectionListener() {
+			
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				// persistence
+				TXMPreferences.putLocalString(getResultData(), TextsBalancePreferences.STRUCTURAL_UNIT, suCombo.getText());
+				TXMPreferences.putLocalInt(getResultData(), TextsBalancePreferences.STRUCTURAL_UNIT_PROPERTY_INDEX, 0);
+				
+				try {
+					loadSUP(((TextsBalance)getResultData()).getCorpus().getStructuralUnit(suCombo.getText()));
+
+					compute();
+					loadChart();
+				}
+				catch(CqiClientException e1) {
+					// TODO Auto-generated catch block
+					e1.printStackTrace();
+				}
+
+			}
+			
+			@Override
+			public void widgetDefaultSelected(SelectionEvent e) {
+				// TODO Auto-generated method stub
+				
+			}
+		});
+		
+
+		
+		SelectionListener listener = new SelectionListener() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				
+			
+				// persistence
+				TXMPreferences.putLocalInt(getResultData(), TextsBalancePreferences.STRUCTURAL_UNIT_PROPERTY_INDEX, supCombo.getSelectionIndex());
+				TXMPreferences.putLocalBoolean(getResultData(), TextsBalancePreferences.GROUP_BY_WORDS, !groupByTexts.getSelection());
+				
+				compute();
+				loadChart();
+
+			}
+
+			@Override
+			public void widgetDefaultSelected(SelectionEvent e) {
+				
+			}
+		};
+		
+		supCombo.addSelectionListener(listener);
+		groupByTexts.addSelectionListener(listener);
+		groupByWords.addSelectionListener(listener);
+		
+		
+		this.compute();
+		
+	}
+
+	
+	/**
+	 * Computes the balance using local or default parameters.
+	 */
+	public void compute()	{
+		try {
+			
+			String suName = TXMPreferences.getString(TextsBalancePreferences.PREFERENCES_NODE, (TextsBalance) getEditorInput().getResultData(), TextsBalancePreferences.STRUCTURAL_UNIT);
+
+			// gets the structural unit property name
+			String supName = null;
+			int i = 0;
+			for(StructuralUnitProperty p : ((TextsBalance) this.getResultData()).getCorpus().getStructuralUnit(suName).getOrderedProperties()) {
+				if(Arrays.asList(this.supsToSkip).contains(p.getName()))	{ 
+					continue;
+				}
+				if(i == TXMPreferences.getInt(TextsBalancePreferences.PREFERENCES_NODE, this.getResultData(), TextsBalancePreferences.STRUCTURAL_UNIT_PROPERTY_INDEX))	{
+					supName = p.getName();
+					break;
+				}
+				i++;
+			}
+			
+			this.compute(TXMPreferences.getInt(TextsBalancePreferences.PREFERENCES_NODE, TextsBalancePreferences.METHOD),
+					((TextsBalance) this.getResultData()).getCorpus().getStructuralUnit(suName), supName,
+					!TXMPreferences.getBoolean(TextsBalancePreferences.PREFERENCES_NODE, this.getResultData(), TextsBalancePreferences.GROUP_BY_WORDS)
+					);
+			
+			
+		}
+		catch(CqiClientException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	
+	
+	/**
+	 * 
+	 * @param method 1: use CQL to solve matches, 2 uses corpus struct indexes, 2 is faster !
+	 * @throws CqiClientException
+	 */
+	public void compute(final int method, final StructuralUnit su, final String propertyName, final boolean groupByTexts) {
+
+		
+		
+		Job job = new Job("Compute Texts Balance") {
+
+		    @Override
+		    protected IStatus run(IProgressMonitor monitor) {
+
+		    	// creating
+				monitor.beginTask("Computing", IProgressMonitor.UNKNOWN);
+				
+				TextsBalance textsBalance = (TextsBalance)getResultData();
+				try {
+					textsBalance.compute(method, su, propertyName, groupByTexts);
+				}
+				catch(CqiClientException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+				createChart();
+				
+				// cancel
+				if(monitor.isCanceled())	{
+					close();
+					return Status.CANCEL_STATUS;
+				}
+				
+				
+				// loading
+				monitor.setTaskName("Loading");
+				loadChart();
+
+				
+				setPartName(textsBalance.getCorpus().getName() + " - " + textsBalance.getName());
+				
+				
+				// FIXME: persistence test, saving local preferences/parameters to file
+				//TextsBalancePreferences.flush((TextsBalance) getEditorInput().getResultData());
+
+				// refreshes the view to update the node label
+				getSite().getShell().getDisplay().syncExec(new Runnable() {
+					@Override
+					public void run() {
+						CorporaView.refresh();
+					}
+				});
+
+				
+				// done
+				monitor.done(); 
+				return Status.OK_STATUS;
+	    }
+
+		};
+		//job.setUser(true); // show progress bar, without that the progress is located to bottom right
+		job.schedule();
+	}
+
+	
+	
+	/**
+	 * Fills the SU combo box from the corpus.
+	 * @throws CqiClientException
+	 */
+	private void loadSU() throws CqiClientException {
+
+		String selectedSuName = TextsBalancePreferences.getString(TextsBalancePreferences.PREFERENCES_NODE, (TextsBalance) this.getResultData(), TextsBalancePreferences.STRUCTURAL_UNIT);
+		int selectedIndex = 0;
+		int i = 0;
+		
+		for (StructuralUnit p : ((TextsBalance) this.getResultData()).getCorpus().getOrderedStructuralUnits()) {
+			if (p.getName().equals("txmcorpus"))	{ //$NON-NLS-1$
+				continue;
+			}
+			suCombo.add(p.getName());
+			if (selectedSuName.equals(p.getName()))	{
+				selectedIndex = i;
+			}
+			i++;
+		}
+		suCombo.select(selectedIndex);
+		loadSUP(((TextsBalance)this.getResultData()).getCorpus().getStructuralUnit(suCombo.getText()));
+	}
+
+	/**
+	 * Fills the SUP combo box from the specified structural unit.
+	 * @param su
+	 * @throws CqiClientException
+	 */
+	private void loadSUP(StructuralUnit su) throws CqiClientException {
+		supCombo.removeAll();
+		for (StructuralUnitProperty p : su.getOrderedProperties()) {
+			if (Arrays.asList(this.supsToSkip).contains(p.getName()))	{ 
+				continue;
+			}
+			supCombo.add(p.getName());
+		}
+		if (supCombo.getItemCount() > 0) {
+			supCombo.select(TextsBalancePreferences.getInt(TextsBalancePreferences.PREFERENCES_NODE, this.getResultData(), TextsBalancePreferences.STRUCTURAL_UNIT_PROPERTY_INDEX));
+		}
+	}
+	
+	/**
+	 * 
+	 * @param corpus
+	 * @param structs
+	 * @return
+	 */
+	public ArrayList<Integer> intersect(List<Match> corpus, List<Match> structs) {
+		int ai=0, bi=0;
+		ArrayList<Integer> result = new ArrayList<Integer>();
+
+		while (ai < corpus.size() && bi < structs.size() ) {
+			if (structs.get(bi).contains(corpus.get(ai))) { 
+				result.add(bi);
+				ai++; 
+			} else if (corpus.get(ai).contains(structs.get(bi))) { 
+				result.add(bi);
+				bi++; 
+			} else { 
+				if (structs.get(bi).getStart() < corpus.get(ai).getStart()) {
+					bi++;
+				} else {
+					ai++;	
+				}
+			} 
+		}
+
+		return result;
+	}
+
+	@Override
+	public void doSave(IProgressMonitor monitor) {
+		// Do the Save operation
+	}
+
+	@Override
+	public void doSaveAs() {
+		// Do the Save As operation
+	}
+
+
+	@Override
+	public boolean isDirty() {
+		return false;
+	}
+
+	@Override
+	public boolean isSaveAsAllowed() {
+		return false;
+	}
+
+
+}

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

Index: tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/editors/BalanceEditorInput.java
===================================================================
--- tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/editors/BalanceEditorInput.java	(revision 0)
+++ tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/editors/BalanceEditorInput.java	(revision 126)
@@ -0,0 +1,124 @@
+// 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.textsbalance.rcp.editors;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IPersistableElement;
+import org.txm.chartsengine.rcp.editors.ChartEditorInput;
+import org.txm.searchengine.cqp.corpus.Corpus;
+import org.txm.textsbalance.core.functions.TextsBalance;
+import org.txm.textsbalance.core.preferences.TextsBalancePreferences;
+/**
+ * Editor input for TextBalance.
+ *
+ * @author mdecorde
+ * @author sjacquot
+ */
+public class BalanceEditorInput extends ChartEditorInput {
+	
+	/** The corpus. */
+	private Corpus corpus;
+	
+	/**
+	 * Instantiates a new index editor input.
+	 *
+	 * @param corpus the corpus
+	 */
+	public BalanceEditorInput(TextsBalance textBalance) {
+		super(textBalance, TextsBalancePreferences.PREFERENCES_NODE);
+		this.corpus = textBalance.getCorpus();
+	}
+
+	/**
+	 * Exists.
+	 *
+	 * @return true, if successful
+	 * @see org.eclipse.ui.IEditorInput#exists()
+	 */
+	@Override
+	public boolean exists() {
+		return false;
+	}
+
+	/**
+	 * Gets the image descriptor.
+	 *
+	 * @return the image descriptor
+	 * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
+	 */
+	@Override
+	public ImageDescriptor getImageDescriptor() {
+		return null;
+	}
+
+	/**
+	 * Gets the persistable.
+	 *
+	 * @return the persistable
+	 * @see org.eclipse.ui.IEditorInput#getPersistable()
+	 */
+	@Override
+	public IPersistableElement getPersistable() {
+		return null;
+	}
+
+	/**
+	 * Gets the tool tip text.
+	 *
+	 * @return the tool tip text
+	 * @see org.eclipse.ui.IEditorInput#getToolTipText()
+	 */
+	@Override
+	public String getToolTipText() {
+		return getName();
+	}
+	
+	/**
+	 * Gets the adapter.
+	 *
+	 * @param arg0 the arg0
+	 * @return the adapter
+	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+	 */
+	@Override
+	@SuppressWarnings("unchecked") //$NON-NLS-1$
+	public Object getAdapter(Class arg0) {
+		return null;
+	}
+
+	/**
+	 * Gets the corpus.
+	 *
+	 * @return the corpus
+	 */
+	public Corpus getCorpus() {
+		return corpus;
+	}
+
+
+}

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

Index: tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/handlers/ComputeBalance.java
===================================================================
--- tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/handlers/ComputeBalance.java	(revision 0)
+++ tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/handlers/ComputeBalance.java	(revision 126)
@@ -0,0 +1,130 @@
+// 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.textsbalance.rcp.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
+import org.txm.rcpapplication.Application;
+import org.txm.rcpapplication.views.CorporaView;
+import org.txm.searchengine.cqp.corpus.Corpus;
+import org.txm.textsbalance.core.functions.TextsBalance;
+import org.txm.textsbalance.rcp.editors.BalanceEditorInput;
+
+/**
+ * Computes and opens a texts balance editor.
+ * 
+ * @author mdecorde
+ * @author sjacquot
+ * 
+ */
+public class ComputeBalance extends AbstractHandler {
+
+
+	
+	// FIXME: should be put in an Activator? or better in an extension point loaded by the corpora view?
+	// adds a double click listener to the Corpus View
+	static	{
+		CorporaView.addDoubleClickListener(TextsBalance.class, "ComputeBalance"); //$NON-NLS-1$
+	}
+	
+	
+
+	@Override
+	public Object execute(ExecutionEvent event) throws ExecutionException {
+
+		
+		ISelection sel = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
+		if(!(sel instanceof IStructuredSelection)) {
+			return null;
+		}
+		IStructuredSelection selection = (IStructuredSelection) sel;
+
+		Object selectedObject = selection.getFirstElement();
+
+		TextsBalance balance = null;
+		boolean newResult = false;
+		
+		// creates new result
+		if(selectedObject instanceof Corpus) {
+			balance = new TextsBalance((Corpus) selectedObject);
+			newResult = true;
+		}
+		// opens existing result
+		else if(selectedObject instanceof TextsBalance) {
+			balance = (TextsBalance) selectedObject;
+		}
+		
+		if(balance != null)	{
+			BalanceEditorInput editorInput = new BalanceEditorInput(balance);
+			SWTChartsComponentsProvider.getCurrent().openEditor(editorInput);
+
+			if(newResult)	{
+				CorporaView.storeResult(balance.getCorpus(), balance);
+			}
+		}
+		else	{
+			System.err.println("Cannot open Balance editor with " + selectedObject);
+		}
+		
+
+
+		// FIXME: test d'utilisation de la même commande pour la création d'un nouvel éditeur et pour la mise à jour d'un graphique, avec une commande paramétrée (voir plugin.xml)
+//		if(event.getParameter("TextsBalance.createNewEditor") == null)	{
+//			ISelection sel = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
+//			if (!(sel instanceof IStructuredSelection)) return null;
+//			selection = (IStructuredSelection) sel;
+//	
+//			Object s = selection.getFirstElement();
+//			if (s instanceof Corpus) {
+//				Corpus corpus = (Corpus) s;
+//				if (!openEditor(corpus)) {
+//					System.out.println("Cannot open Balance editor with "+s);
+//				}
+//			}
+//		}
+//		else	{
+//			//System.out.println("ComputeBalance.execute() " + ((Event)event.getTrigger()).widget);
+//			((BalanceEditor)((ChartEditorToolBar)((ToolItem)((Event)event.getTrigger()).widget).getParent()).getEditorPart()).compute();
+//			((BalanceEditor)((ChartEditorToolBar)((ToolItem)((Event)event.getTrigger()).widget).getParent()).getEditorPart()).reloadChart();
+//			
+//		}
+		
+		
+		
+		return null;
+	}
+
+
+
+
+}

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

Index: tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/preferences/TextsBalancePreferencePage.java
===================================================================
--- tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/preferences/TextsBalancePreferencePage.java	(revision 0)
+++ tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/preferences/TextsBalancePreferencePage.java	(revision 126)
@@ -0,0 +1,95 @@
+package org.txm.textsbalance.rcp.preferences;
+
+// 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:$ 
+//
+
+
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.ComboFieldEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbench;
+import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
+import org.txm.rcp.preferences.TXMPreferencePage;
+import org.txm.rcp.preferences.TXMPreferenceStore;
+import org.txm.textsbalance.core.preferences.TextsBalancePreferences;
+import org.txm.textsbalance.rcp.adapters.TextsBalanceAdapterFactory;
+
+/**
+ * Texts balance preference page.
+ * @author sjacquot
+ *
+ */
+public class TextsBalancePreferencePage extends TXMPreferencePage {
+
+
+
+	@Override
+	public void createFieldEditors() {
+
+		
+		// Charts rendering
+		Composite chartsTab = SWTChartsComponentsProvider.createChartsRenderingPreferencesTabFolderComposite(this.getFieldEditorParent());
+		
+		
+		// FIXME: input text
+//		IntegerFieldEditor method = new IntegerFieldEditor(TextsBalancePreferencesInitializer.METHOD, "Method", this.getFieldEditorParent());
+//		method.setValidRange(1, 2);
+//		method.setTextLimit(1);
+//		method.getTextControl(getFieldEditorParent()).setToolTipText("Method (1: uses CQL to solve matches, 2 uses corpus struct indexes, 2 is faster!)");
+//		this.addField(method);
+		
+		String[][] methods = new String[2][2];
+		for(int i = 0; i < 2; i++) {
+			methods[i][0] = String.valueOf(i + 1);
+			methods[i][1] = String.valueOf(i + 1);
+		}
+
+		this.addField(new ComboFieldEditor(TextsBalancePreferences.METHOD, "Method", methods, chartsTab));
+		this.addField(new BooleanFieldEditor(TextsBalancePreferences.GROUP_BY_WORDS, "Group by words", chartsTab));
+		
+		// other shared preferences
+		SWTChartsComponentsProvider.createChartsRenderingPreferencesFields(this, chartsTab);
+		
+	}
+	
+	
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+	 */
+	@Override
+	public void init(IWorkbench workbench) {
+		this.setPreferenceStore(new TXMPreferenceStore(TextsBalancePreferences.PREFERENCES_NODE));
+		this.setDescription("Texts balance charts.");
+		this.setImageDescriptor(TextsBalanceAdapterFactory.ICON);
+	}
+
+}

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

Index: tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/adapters/TextsBalanceAdapterFactory.java
===================================================================
--- tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/adapters/TextsBalanceAdapterFactory.java	(revision 0)
+++ tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/adapters/TextsBalanceAdapterFactory.java	(revision 126)
@@ -0,0 +1,66 @@
+// Copyright © 2010-2013 ENS de Lyon.
+package org.txm.textsbalance.rcp.adapters;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.FrameworkUtil;
+import org.txm.rcp.adapters.BaseAdapterFactory;
+import org.txm.textsbalance.core.functions.TextsBalance;
+
+
+/**
+ * A factory for creating Adapter objects.
+ *  
+ * @author mdecorde
+ * @author sjacquot
+ */
+public class TextsBalanceAdapterFactory extends BaseAdapterFactory {
+
+	
+	public static final ImageDescriptor ICON =
+			AbstractUIPlugin.imageDescriptorFromPlugin(FrameworkUtil.getBundle(TextsBalanceAdapterFactory.class).getSymbolicName(),
+					"platform:/plugin/"+ FrameworkUtil.getBundle(TextsBalanceAdapterFactory.class).getSymbolicName() + "/icons/balance.png"); //$NON-NLS-1$
+	
+	
+	/**
+	 * Gets the adapter.
+	 *
+	 * @param adaptableObject the adaptable object
+	 * @param adapterType the adapter type
+	 * @return the adapter
+	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
+	 */
+	@Override
+	public Object getAdapter(Object adaptableObject, Class adapterType) {
+		
+		if(adapterType == IWorkbenchAdapter.class)	{
+			if(adaptableObject instanceof TextsBalance)	{
+				return new IWorkbenchAdapter() {
+					@Override
+					public Object[] getChildren(Object resultData) {
+						return new Object[0];
+					}
+	
+					@Override
+					public ImageDescriptor getImageDescriptor(Object object) {
+						return ICON;
+					}
+	
+					@Override
+					public String getLabel(Object resultData) {
+						return ((TextsBalance) resultData).getName();
+					}
+	
+					@Override
+					public Object getParent(Object resultData) {
+						return ((TextsBalance) resultData).getCorpus();
+					}
+				};
+			}
+		}
+		return null;
+	}
+
+
+}

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

Index: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/adapters/TextsBalanceAdapterFactory$1.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/adapters/TextsBalanceAdapterFactory$1.class
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/adapters/TextsBalanceAdapterFactory.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/adapters/TextsBalanceAdapterFactory.class
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/editors/BalanceEditor.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/editors/BalanceEditor.class
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/editors/BalanceEditorInput.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/editors/BalanceEditorInput.class
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/editors/BalanceEditor$1.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/editors/BalanceEditor$1.class
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/editors/BalanceEditor$2.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/editors/BalanceEditor$2.class
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/editors/BalanceEditor$3.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/editors/BalanceEditor$3.class
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/editors/BalanceEditor$3$1.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/editors/BalanceEditor$3$1.class
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/handlers/ComputeBalance.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/handlers/ComputeBalance.class
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/preferences/TextsBalancePreferencePage.class
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tmp/org.txm.textsbalance.rcp/bin/org/txm/textsbalance/rcp/preferences/TextsBalancePreferencePage.class
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Index: tmp/org.txm.textsbalance.rcp/build.properties
===================================================================
--- tmp/org.txm.textsbalance.rcp/build.properties	(revision 0)
+++ tmp/org.txm.textsbalance.rcp/build.properties	(revision 126)
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+               META-INF/,\
+               .,\
+               icons/,\
+               OSGI-INF/l10n/bundle.properties

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

Index: tmp/org.txm.textsbalance.rcp/icons/balance.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: tmp/org.txm.textsbalance.rcp/icons/balance.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

