Index: TXM/trunk/bundles/org.txm.chartsengine.r.core/src/org/txm/stat/engine/r/RWorkspaceRenderer.java
===================================================================
--- TXM/trunk/bundles/org.txm.chartsengine.r.core/src/org/txm/stat/engine/r/RWorkspaceRenderer.java	(revision 3945)
+++ TXM/trunk/bundles/org.txm.chartsengine.r.core/src/org/txm/stat/engine/r/RWorkspaceRenderer.java	(revision 3946)
@@ -36,17 +36,14 @@
 
 import org.apache.commons.lang.StringEscapeUtils;
 import org.rosuda.REngine.REXP;
-import org.rosuda.REngine.REXPMismatchException;
 import org.txm.chartsengine.core.ChartsEngine;
 import org.txm.core.messages.TXMCoreMessages;
-import org.txm.statsengine.core.StatException;
 import org.txm.statsengine.r.core.RWorkspace;
 import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
 import org.txm.statsengine.r.core.messages.RCoreMessages;
 import org.txm.utils.OSDetector;
 import org.txm.utils.logger.Log;
 
-// TODO: Auto-generated Javadoc
 /**
  * Wrap R plot methods
  * 
Index: TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/views/corpora/CorpusViewContentProvider.java
===================================================================
--- TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/views/corpora/CorpusViewContentProvider.java	(revision 3945)
+++ TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/views/corpora/CorpusViewContentProvider.java	(revision 3946)
@@ -48,6 +48,7 @@
 import org.txm.objects.CorpusBuild;
 import org.txm.objects.Project;
 import org.txm.objects.Workspace;
+import org.txm.rcp.CorporaSourceProvider;
 import org.txm.rcp.adapters.RCPProjectAdapterFactory;
 import org.txm.searchengine.cqp.corpus.MainCorpus;
 import org.txm.utils.logger.Log;
@@ -218,7 +219,9 @@
 	 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
 	 */
 	@Override
-	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+		CorporaSourceProvider.updateSelection(viewer.getSelection());
+	}
 	
 	/*
 	 * (non-Javadoc)
Index: TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/views/corpora/CorporaView.java
===================================================================
--- TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/views/corpora/CorporaView.java	(revision 3945)
+++ TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/views/corpora/CorporaView.java	(revision 3946)
@@ -118,75 +118,72 @@
  * <p>
  */
 public class CorporaView extends ViewPart {
-
+	
 	/** The ID. */
 	static public String ID = CorporaView.class.getName();
-
+	
 	/** The tree viewer. */
 	public TreeViewer treeViewer;
-
-	/** The self. */
-	private static CorporaView self;
-
+	
 	/**
 	 * stores the class that are managed by a Doubleclick handler
 	 */
 	// private static HashMap<Class, Class> managedDoubleClickClasses = new HashMap<Class, Class>();
-
-
+	
+	
 	public static HashMap<String, String> doubleClickInstalledCommands = new HashMap<>();
-
-
+	
+	
 	// public static HashMap<Class, Class> getManagedDoubleClickClasses() {
 	// return managedDoubleClickClasses;
 	// }
-
-
+	
+	
 	/**
 	 * Gets the single instance of CorporaView.
 	 *
 	 * @return single instance of CorporaView
 	 */
 	public static CorporaView getInstance() {
-		if (self == null) {
-			if (!PlatformUI.isWorkbenchRunning()) return null;
-
-			IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-			if (window == null) return null;
-			IWorkbenchPage page = window.getActivePage();
-			if (page == null) return null;
-			CorporaView corporaView = (CorporaView) page.findView(CorporaView.ID);
-			self = corporaView;
-		}
-		return self;
+		
+		if (!PlatformUI.isWorkbenchRunning()) return null;
+		
+		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+		if (window == null) return null;
+		IWorkbenchPage page = window.getActivePage();
+		if (page == null) return null;
+		
+		return (CorporaView) page.findView(CorporaView.ID);
 	}
-
+	
 	public TreeViewer getTreeViewer() {
 		return treeViewer;
 	}
-
-
+	
+	
 	/**
 	 * Reload.
 	 */
 	public static void reload() {
 		// System.out.println("Reload corpora view");
 		CorporaView corporaView = getInstance();
-		if (corporaView != null)
+		if (corporaView != null) {
 			corporaView._reload();
+		}
 	}
-
+	
 	/**
 	 * _reload.
 	 */
 	public void _reload() {
+		
 		if (Toolbox.isInitialized()) {
-
+			
 			treeViewer.setContentProvider(new CorpusViewContentProvider(this));
 			ColumnViewerToolTipSupport.enableFor(treeViewer);
-
+			
 			treeViewer.setLabelProvider(new CorpusViewLabelProvider(new WorkbenchLabelProvider(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
-
+			
 			Workspace w = Toolbox.workspace;
 			if (w == null) {
 				return;
@@ -195,7 +192,7 @@
 			treeViewer.refresh();
 		}
 	}
-
+	
 	/**
 	 * This is a callback that will allow us to create the viewer and initialize
 	 * it.
@@ -204,68 +201,18 @@
 	 */
 	@Override
 	public void createPartControl(Composite parent) {
+		
 		treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
 		PlatformUI.getWorkbench().getHelpSystem().setHelp(treeViewer.getControl(), TXMUIMessages.corpus);
 		getSite().setSelectionProvider(treeViewer);
 		treeViewer.setColumnProperties(new String[] { "name" }); // mandatory to enable edit mode -> used to identify columns //$NON-NLS-1$
-
-
-		// ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(treeViewer) {
-		// protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
-		// System.out.println("activated");
-		// return event.keyCode == SWT.F2;
-		// }
-		// };
-		// int f = ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR |
-		// ColumnViewerEditor.TABBING_VERTICAL |
-		// ColumnViewerEditor.KEYBOARD_ACTIVATION;
-		//
-		// TreeViewerEditor.create(treeViewer, actSupport, f);
-		//
-		// treeViewer.setCellEditors(new CellEditor[]{new TextCellEditor(treeViewer.getTree())});
-		// treeViewer.setCellModifier(new ICellModifier() {
-		//
-		// @Override
-		// public void modify(Object element, String property, Object value) {
-		// System.out.println("modify: "+element+" "+property+" "+value);
-		// if (element instanceof TreeItem)
-		// {
-		// //update element and tree model
-		// TreeItem treeItem = (TreeItem)element;
-		// TXMResult data = (TXMResult)treeItem.getData();
-		// data.setUserName(value.toString());
-		// treeItem.setText(value.toString());
-		// }
-		// }
-		//
-		// @Override
-		// public Object getValue(Object element, String property) {
-		// if (element instanceof TXMResult) {
-		// return ((TXMResult)element).getUserName();
-		// }
-		// return element.toString();
-		// }
-		//
-		// @Override
-		// public boolean canModify(Object element, String property) {
-		// return element instanceof TXMResult;
-		// }
-		// });
-
-		// treeViewer.addFilter(new ViewerFilter() {
-		// @Override
-		// public boolean select(Viewer viewer, Object parentElement, Object element) {
-		// if (element instanceof Text) return false;
-		// if (element instanceof SavedQuery) return false;
-		// return true;
-		// }
-		// });
+		
 		treeViewer.setContentProvider(new CorpusViewContentProvider(this));
 		treeViewer.setLabelProvider(new DecoratingLabelProvider(new WorkbenchLabelProvider(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
-
+		
 		// for now the sorter is used to sort the Corpus, Subcorpus and partition objects
 		treeViewer.setSorter(new ViewerSorter() {
-
+			
 			@Override
 			public int category(Object element) {
 				if (element instanceof Subcorpus) return 2; // must do it before the Corpus test
@@ -273,17 +220,17 @@
 				else if (element instanceof Partition) return 1;
 				else return 3;
 			}
-
+			
 			@Override
 			public int compare(Viewer viewer, Object e1, Object e2) {
-
+				
 				int cat1 = category(e1);
 				int cat2 = category(e2);
-
+				
 				if (cat1 != cat2) {
 					return cat1 - cat2;
 				}
-
+				
 				if (e1 instanceof TXMResult && e2 instanceof TXMResult) {
 					return ((TXMResult) e1).compareTo((TXMResult) e2);
 				}
@@ -292,56 +239,30 @@
 				}
 			}
 		});
-
-		if (Toolbox.isInitialized()) {
-			Workspace w = null;
-			while (w == null) {
-				try {
-					Thread.sleep(100);
-				}
-				catch (InterruptedException e1) {
-					// TODO Auto-generated catch block
-					org.txm.utils.logger.Log.printStackTrace(e1);
-				}
-				w = Toolbox.workspace;
-				if (w == null) continue;
-				else break;// return;
-			}
-			Project p = w.getProject("default"); //$NON-NLS-1$
-			if (p == null) return;
-			treeViewer.setInput(p);
-		}
+				
+		treeViewer.setInput(Toolbox.workspace);
+		
 		// FIXME: SJ: to remove?
 		// PlatformUI.getWorkbench().getHelpSystem().setHelp(treeViewer.getTree(), "org.txm.rcp.corporaView" //$NON-NLS-1$);
-
+		
 		treeViewer.getTree().addSelectionListener(new SelectionListener() {
-
+			
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				TreeItem[] sel = treeViewer.getTree().getSelection();
 				if (sel.length == 0)
 					return;
-
+				
 				CorporaSourceProvider.updateSelection(treeViewer.getSelection());
-
+				
 				CorporaView.this.setFocus(); // force focus on the corpora view -> ensure the active selection is the corpora view selection
-
+				
 				ISelection tsel = treeViewer.getSelection();
 				if (!(tsel instanceof TreeSelection)) return;
-
+				
 				TreeSelection selection = (TreeSelection) treeViewer.getSelection();
 				Object selectedItem = selection.getFirstElement();
-
-				// FIXME : MD tests
-				// if (selectedItem instanceof TXMResult) {
-				// TXMResult r = ((TXMResult)selectedItem);
-				// if (r.compute()) {
-				// String mess = r.getSimpleDetails();
-				// if (mess == null) mess = selectedItem.toString();
-				// StatusLine.setMessage(mess);
-				// }
-				// }
-
+								
 				// FIXME: SJ tests, define here what to display
 				if (selectedItem instanceof TXMResult) {
 					TXMResult result = ((TXMResult) selectedItem);
@@ -351,7 +272,7 @@
 					// }
 					// StatusLine.setMessage(mess);
 					// StatusLine.setMessage(((TXMResult)selectedItem).getComputingDoneMessage());
-
+					
 					if (result instanceof MainCorpus) { // just for this result type, pre-compute to show the corpus size
 						try {
 							result.compute(false);
@@ -361,7 +282,7 @@
 							e1.printStackTrace();
 						}
 					}
-
+					
 					// Status bar
 					//					if (!result.hasBeenComputedOnce() && !(result instanceof Partition)) { // FIXME: SJ: tmp fix for showing Partition parts
 					//						StatusLine.setMessage("");
@@ -370,10 +291,10 @@
 					//						// TODO uncomment when status line will be restored
 					//						// StatusLine.setMessage(((TXMResult) selectedItem).getDetails());
 					//					}
-
+					
 					// FIXME : MD re-enable status line on corpora view selection
 					if (selectedItem instanceof TXMResult) {
-
+						
 						TXMResult r = ((TXMResult)selectedItem);
 						String mess = null;
 						try {mess = r.getSimpleDetails();}
@@ -381,20 +302,18 @@
 							Log.warning(NLS.bind(TXMUIMessages.errorWhileGettingResultInformationsP0, e2));
 							Log.printStackTrace(e2);
 						}
-
+						
 						if (mess == null) mess = r.getName();
 						StatusLine.setMessage(mess);
 					}
 				}
 			}
-
+			
 			@Override
-			public void widgetDefaultSelected(SelectionEvent e) {
-				// TODO Auto-generated method stub
-			}
+			public void widgetDefaultSelected(SelectionEvent e) { }
 		});
-
-
+		
+		
 		// double click listener installation from commands
 		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
 		ICommandService cmdService = window.getService(ICommandService.class);
@@ -411,16 +330,16 @@
 				e1.printStackTrace();
 			}
 		}
-
+		
 		treeViewer.addDoubleClickListener(new IDoubleClickListener() {
-
+			
 			@Override
 			public void doubleClick(DoubleClickEvent event) {
 				TreeSelection selection = (TreeSelection) treeViewer.getSelection();
 				Object selectedItem = selection.getFirstElement();
 				if (selectedItem != null) {
 					String commandId = doubleClickInstalledCommands.get(selectedItem.getClass().getName());
-
+					
 					if (commandId == null) {
 						for (String clazz : doubleClickInstalledCommands.keySet()) {
 							if (selectedItem.getClass().getSuperclass().getName().equals(clazz)) {
@@ -429,7 +348,7 @@
 							}
 						}
 					}
-
+					
 					if (commandId != null) {
 						BaseAbstractHandler.executeCommand(commandId);
 					}
@@ -447,47 +366,44 @@
 				}
 			}
 		});
-
+		
 		treeViewer.getTree().addKeyListener(new KeyAdapter() {
-
+			
 			@Override
 			public void keyPressed(KeyEvent e) {
-
+				
 				boolean expert = TBXPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER);
-
+				
 				if (expert && (char) e.keyCode == 'c' & ((e.stateMask & SWT.CTRL) != 0)) {
 					Object o = treeViewer.getStructuredSelection().getFirstElement();
 					if (o != null && o instanceof TXMResult) {
 						CopyTXMResultTree.copy((IStructuredSelection) treeViewer.getSelection());
 					}
-
 				}
 				else if (expert && (char) e.keyCode == 'x' & ((e.stateMask & SWT.CTRL) != 0)) {
 					Object o = treeViewer.getStructuredSelection().getFirstElement();
 					if (o != null && o instanceof TXMResult) {
 						CutTXMResultTree.cut((IStructuredSelection) treeViewer.getSelection());
 					}
-
 				}
 				else if (expert && (char) e.keyCode == 'v' & ((e.stateMask & SWT.CTRL) != 0)) {
 					Object o = treeViewer.getStructuredSelection().getFirstElement();
 					if (o != null && o instanceof TXMResult) {
 						PasteTXMResultTree.paste((TXMResult) o);
 					}
-
 				} else if (e.keyCode == SWT.DEL) {
 					final ISelection sel = treeViewer.getSelection();
 					if (sel instanceof IStructuredSelection) {
-
+						
 						if (!DeleteObject.askContinueToDelete((IStructuredSelection) sel)) return;
-
+						
 						JobHandler job = new JobHandler(TXMUIMessages.deleting, true) {
-
+							
 							@Override
 							protected IStatus run(IProgressMonitor monitor) {
 								DeleteObject.delete(sel);
 								this.syncExec(new Runnable() {
-
+									
 									@Override
 									public void run() {
 										refresh();
@@ -516,17 +432,17 @@
 				// }
 			}
 		});
-
+		
 		final int IMAGE_MARGIN = 2;
 		final Image icon = IImageKeys.getImage("icons/decorators/bullet_green.png"); //$NON-NLS-1$
 		final Image icon_lock = IImageKeys.getImage("icons/decorators/lock.png"); //$NON-NLS-1$
-
+		
 		// FIXME: test to show icon for results that are user persistable
 		// final Image icon = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.gef","platform:/plugin/org.eclipse.gef/org/eclipse/gef/internal/icons/pinned.gif").createImage();
 		// final Image icon = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.team.svn.help","platform:/plugin/org.eclipse.team.svn.help/images/lock.gif").createImage();
-
-
-
+		
+		
+		
 		// treeViewer.getTree().addListener(SWT.MeasureItem, new Listener() {
 		// public void handleEvent(Event event) {
 		// TreeItem item = (TreeItem)event.item;
@@ -537,7 +453,7 @@
 		// }
 		// });
 		treeViewer.getTree().addListener(SWT.PaintItem, new Listener() {
-
+			
 			@Override
 			public void handleEvent(Event event) {
 				if (event.item.getData() instanceof TXMResult && ((TXMResult) event.item.getData()).isLocked()) {
@@ -548,27 +464,29 @@
 						int itemHeight = treeViewer.getTree().getItemHeight();
 						int imageHeight = trailingImage.getBounds().height;
 						int y = 2 + event.y + (itemHeight - imageHeight) / 2;
-
+						
 						event.gc.drawImage(icon_lock, x, y);
 					}
 				}
 			}
 		});
-
+		
 		MenuManager menuManager = new MenuManager();
 		Menu menu = menuManager.createContextMenu(treeViewer.getTree());
-
+		
 		// Set the MenuManager
 		treeViewer.getTree().setMenu(menu);
 		getSite().registerContextMenu(menuManager, treeViewer);
 		// Make the selection available
 		getSite().setSelectionProvider(treeViewer);
-
+		
 		IContextService contextService = getSite().getService(IContextService.class);
 		contextService.activateContext(ID);
+		
+		treeViewer.refresh();
 	}
-
-
+	
+	
 	/**
 	 * Passing the focus request to the viewer's control.
 	 */
@@ -576,7 +494,7 @@
 	public void setFocus() {
 		treeViewer.getControl().setFocus();
 	}
-
+	
 	/**
 	 * Gets the first selected object in the tree.
 	 * 
@@ -596,7 +514,7 @@
 		}
 		return null;
 	}
-
+	
 	/**
 	 * Gets the selected objects in the tree.
 	 * 
@@ -616,16 +534,16 @@
 		}
 		return null;
 	}
-
+	
 	/**
 	 * Selects some items.
 	 * 
 	 * @param arrayList
 	 */
 	public static void select(List<?> arrayList) {
-
+		
 		if (!PlatformUI.isWorkbenchRunning()) return;
-
+		
 		CorporaView corporaView = openView();
 		if (corporaView != null) {
 			StructuredSelection selection = new StructuredSelection(arrayList);
@@ -633,7 +551,7 @@
 			corporaView.getTreeViewer().reveal(arrayList); // to be sure
 		}
 	}
-
+	
 	/**
 	 * Opens the Corpora view if not already opened.
 	 * 
@@ -643,7 +561,7 @@
 		// open Unit View if not opened
 		try {
 			if (!PlatformUI.isWorkbenchRunning()) return null;
-
+			
 			IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
 			CorporaView view = (CorporaView) page.findView(CorporaView.ID);
 			if (view == null) {
@@ -661,8 +579,8 @@
 		}
 		return null;
 	}
-
-
+	
+	
 	/**
 	 * Refresh the tree view.
 	 */
@@ -674,7 +592,7 @@
 			// corporaView.treeViewer.expandAll(); // FIXME
 		}
 	}
-
+	
 	/**
 	 * Refreshes the view and the tree.
 	 *
@@ -683,9 +601,9 @@
 	public static void refresh(CorporaView corporaView) {
 		corporaView.treeViewer.refresh();
 	}
-
-
-
+	
+	
+	
 	/**
 	 * Refreshes the specified result node in the tree view.
 	 * 
@@ -693,14 +611,14 @@
 	 */
 	public static void refreshObject(final TXMResult result) {
 		Display.getDefault().syncExec(new Runnable() {
-
+			
 			@Override
 			public void run() {
-
+				
 				CorporaView corporaView = getInstance();
-
+				
 				corporaView.treeViewer.refresh();
-
+				
 				try {
 					CorporaView.expand(result.getParent());
 				}
@@ -709,7 +627,7 @@
 			}
 		});
 	}
-
+	
 	/**
 	 * Refreshes the specified result node in the tree view, also synchronizes the TXMResult and the TXMEditor (as the editor part name from the result name, for example).
 	 * 
@@ -718,7 +636,7 @@
 	public static void refreshObject(TXMEditor editor) {
 		refreshObject(editor.getResult());
 	}
-
+	
 	/**
 	 * Expands the specified tree node.
 	 * 
@@ -730,7 +648,7 @@
 			corporaView.treeViewer.expandToLevel(obj, 1);
 		}
 	}
-
+	
 	/**
 	 * 
 	 * @param obj
@@ -741,7 +659,7 @@
 			corporaView.treeViewer.reveal(obj);
 		}
 	}
-
+	
 	/**
 	 * Checks if the Corpora view is active.
 	 * 
Index: TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/commands/function/RefreshCorporaView.java
===================================================================
--- TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/commands/function/RefreshCorporaView.java	(revision 0)
+++ TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/commands/function/RefreshCorporaView.java	(revision 3946)
@@ -0,0 +1,17 @@
+package org.txm.rcp.commands.function;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.txm.rcp.views.corpora.CorporaView;
+
+public class RefreshCorporaView extends AbstractHandler  {
+
+	@Override
+	public Object execute(ExecutionEvent event) throws ExecutionException {
+		
+		CorporaView.reload();
+		
+		return null;
+	}
+}

Property changes on: TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/commands/function/RefreshCorporaView.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: TXM/trunk/bundles/org.txm.rcp/plugin.xml
===================================================================
--- TXM/trunk/bundles/org.txm.rcp/plugin.xml	(revision 3945)
+++ TXM/trunk/bundles/org.txm.rcp/plugin.xml	(revision 3946)
@@ -2643,6 +2643,15 @@
                style="push">
          </command>
       </menuContribution>
+      <menuContribution
+            allPopups="false"
+            locationURI="toolbar:org.txm.rcp.views.corpora.CorporaView">
+         <command
+               commandId="org.txm.rcp.commands.function.RefreshCorporaView"
+               icon="icons/refresh.png"
+               style="push">
+         </command>
+      </menuContribution>
    </extension>
    <extension
          id="general"
@@ -2852,6 +2861,11 @@
             id="org.txm.rcp.commands.QuitHandler"
             name="%command.name.114">
       </command>
+      <command
+            defaultHandler="org.txm.rcp.commands.function.RefreshCorporaView"
+            id="org.txm.rcp.commands.function.RefreshCorporaView"
+            name="Refresh corpora view">
+      </command>
    </extension>
    <extension
          id="commands"
