Révision 1425

tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/results/ChartResult.java (revision 1425)
153 153
		this.chartDirty = true;
154 154
	}
155 155

  
156

  
157 156
	@Override
158 157
	public boolean compute(IProgressMonitor monitor) {
158
		return compute(monitor, true);
159
	}
159 160

  
161
	@Override
162
	public boolean compute(IProgressMonitor monitor, boolean deepComputing) {
163

  
160 164
		try {
161 165
			Log.finest("*** ChartResult.compute(): " + this.getClass().getSimpleName() + ": starting computing process...");
162 166

  
163 167
			// compute the result if needed
164
			if(super.compute(monitor, true))	{
168
			if(super.compute(monitor, deepComputing))	{
165 169
				// compute the chart
166 170
				return renderChart();
167 171
			}
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java (revision 1425)
265 265
			_compute_with_lists();
266 266
		}
267 267
		
268
		
268
		totalsize = -1; // refresh total size at next call of getTotalSize
269 269
		return true;
270 270
	}
271 271

  
......
369 369

  
370 370
	@Override
371 371
	public String getDetails() {
372
		return getName();
372
		return NLS.bind(getName()+" ({0})", getPartsCount());
373 373
	}
374 374

  
375 375
	/**
......
380 380
	public int getPartsCount() {
381 381
		// FIXME: later should just return the direct children count
382 382
		try {
383
			if (!hasBeenComputedOnce()) {
384
				compute();
385
			}
386
			
383
//			if (!hasBeenComputedOnce()) {
384
//				compute();
385
//			}
386
//			
387 387
			return getParts().size();
388 388
		} catch(Exception e) { }
389 389
		return 0;
......
474 474
	 * @throws CqiClientException
475 475
	 */
476 476
	public int getTotalSize() throws CqiClientException {
477
		if (!hasBeenComputedOnce()) {
478
			try {
479
				compute();
480
			} catch (Exception e) {
481
				// TODO Auto-generated catch block
482
				e.printStackTrace();
483
			}
484
		}
477
		
485 478
		if (totalsize == -1) {
486 479
			totalsize = 0;
487 480
			for (Part p : getParts()) {
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/handlers/ComputeSpecifictiesSelectionChart.java (revision 1425)
11 11
import org.eclipse.ui.handlers.HandlerUtil;
12 12
import org.txm.chartsengine.rcp.editors.ChartEditor;
13 13
import org.txm.rcp.handlers.BaseAbstractHandler;
14
import org.txm.rcp.views.corpora.CorporaView;
14 15
import org.txm.specificities.core.functions.Specificities;
15 16
import org.txm.specificities.core.functions.SpecificitiesSelection;
16 17
import org.txm.specificities.rcp.editors.SpecificitiesEditor;
......
31 32
	@Override
32 33
	public Object execute(ExecutionEvent event) throws ExecutionException {
33 34
		
34
		
35 35
		Object selection = this.getCorporaViewSelectedObject(event);
36 36
		SpecificitiesSelection specificitiesSelection = null;
37 37
		
38 38
		// Reopening from existing result
39
		if(selection instanceof SpecificitiesSelection)	{
39
		if(selection instanceof SpecificitiesSelection && CorporaView.isFocused())	{
40 40
			specificitiesSelection = (SpecificitiesSelection) selection;
41 41
		}
42 42
		// Creates from SpecificitiesEditor selected table lines
tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/corpora/CorporaView.java (revision 1425)
59 59
import org.eclipse.swt.widgets.Menu;
60 60
import org.eclipse.swt.widgets.TreeItem;
61 61
import org.eclipse.ui.IWorkbenchPage;
62
import org.eclipse.ui.IWorkbenchPart;
62 63
import org.eclipse.ui.IWorkbenchWindow;
63 64
import org.eclipse.ui.PartInitException;
64 65
import org.eclipse.ui.PlatformUI;
......
119 120
	public static HashMap<String, String> doubleClickInstalledCommands = new HashMap<String, String>();
120 121

  
121 122

  
122
//	public static HashMap<Class, Class> getManagedDoubleClickClasses() {
123
//		return managedDoubleClickClasses;
124
//	}
123
	//	public static HashMap<Class, Class> getManagedDoubleClickClasses() {
124
	//		return managedDoubleClickClasses;
125
	//	}
125 126

  
126 127

  
127 128
	/**
......
166 167

  
167 168
			treeViewer.setContentProvider(new TXMResultContentProvider(this));
168 169
			//treeViewer.setLabelProvider(new TextometrieLabelProvider());
169
			
170

  
170 171
			//treeViewer.setLabelProvider(new DecoratingLabelProvider(new TXMResultLabelProvider(),PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
171 172
			treeViewer.setLabelProvider(new DecoratingLabelProvider(new WorkbenchLabelProvider(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
172
			
173

  
173 174
			Workspace w = Toolbox.workspace;
174 175
			if (w == null) return;
175 176
			treeViewer.setInput(w);
......
191 192
		treeViewer.setColumnProperties(new String[]{"name"}); // mandatory to enable edit mode -> used to identify columns
192 193

  
193 194

  
194
//		ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(treeViewer) {
195
//			protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
196
//				System.out.println("activated");
197
//				return event.keyCode == SWT.F2;
198
//			}
199
//		};
200
//		int f = ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | 
201
//			    ColumnViewerEditor.TABBING_VERTICAL |
202
//			    ColumnViewerEditor.KEYBOARD_ACTIVATION;
203
//		
204
//		TreeViewerEditor.create(treeViewer, actSupport, f);
205
//
206
//		treeViewer.setCellEditors(new CellEditor[]{new TextCellEditor(treeViewer.getTree())});
207
//		treeViewer.setCellModifier(new ICellModifier() {
208
//
209
//			@Override
210
//			public void modify(Object element, String property, Object value) {
211
//				System.out.println("modify: "+element+" "+property+" "+value);
212
//				if (element instanceof TreeItem)
213
//				{
214
//					//update element and tree model
215
//					TreeItem treeItem = (TreeItem)element;
216
//					TXMResult data = (TXMResult)treeItem.getData();
217
//					data.setUserName(value.toString());
218
//					treeItem.setText(value.toString());
219
//				}
220
//			}
221
//
222
//			@Override
223
//			public Object getValue(Object element, String property) {
224
//				if (element instanceof TXMResult) {
225
//					return ((TXMResult)element).getUserName();
226
//				}
227
//				return element.toString();
228
//			}
229
//
230
//			@Override
231
//			public boolean canModify(Object element, String property) {
232
//				return element instanceof TXMResult;
233
//			}
234
//		});
195
		//		ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(treeViewer) {
196
		//			protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
197
		//				System.out.println("activated");
198
		//				return event.keyCode == SWT.F2;
199
		//			}
200
		//		};
201
		//		int f = ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | 
202
		//			    ColumnViewerEditor.TABBING_VERTICAL |
203
		//			    ColumnViewerEditor.KEYBOARD_ACTIVATION;
204
		//		
205
		//		TreeViewerEditor.create(treeViewer, actSupport, f);
206
		//
207
		//		treeViewer.setCellEditors(new CellEditor[]{new TextCellEditor(treeViewer.getTree())});
208
		//		treeViewer.setCellModifier(new ICellModifier() {
209
		//
210
		//			@Override
211
		//			public void modify(Object element, String property, Object value) {
212
		//				System.out.println("modify: "+element+" "+property+" "+value);
213
		//				if (element instanceof TreeItem)
214
		//				{
215
		//					//update element and tree model
216
		//					TreeItem treeItem = (TreeItem)element;
217
		//					TXMResult data = (TXMResult)treeItem.getData();
218
		//					data.setUserName(value.toString());
219
		//					treeItem.setText(value.toString());
220
		//				}
221
		//			}
222
		//
223
		//			@Override
224
		//			public Object getValue(Object element, String property) {
225
		//				if (element instanceof TXMResult) {
226
		//					return ((TXMResult)element).getUserName();
227
		//				}
228
		//				return element.toString();
229
		//			}
230
		//
231
		//			@Override
232
		//			public boolean canModify(Object element, String property) {
233
		//				return element instanceof TXMResult;
234
		//			}
235
		//		});
235 236

  
236 237
		//		treeViewer.addFilter(new ViewerFilter() {
237 238
		//			@Override
......
244 245
		treeViewer.setContentProvider(new TXMResultContentProvider(this));
245 246
		//treeViewer.setLabelProvider(new TextometrieLabelProvider());
246 247
		//treeViewer.setLabelProvider(new DecoratingLabelProvider(new TXMResultLabelProvider(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
247
		
248

  
248 249
		treeViewer.setLabelProvider(new DecoratingLabelProvider(new WorkbenchLabelProvider(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
249
		
250

  
250 251
		// for now the sorter is used to sort the Corpus, Subcorpus and partition objects
251 252
		treeViewer.setSorter(new ViewerSorter() {
252 253
			public int category(Object element) {
......
357 358
				if (arg0.keyCode == SWT.DEL) {
358 359
					final ISelection sel = treeViewer.getSelection();
359 360
					if (sel instanceof IStructuredSelection) {
360
						
361

  
361 362
						if (!DeleteObject.askContinueToDelete((IStructuredSelection)sel)) return;
362
						
363

  
363 364
						JobHandler job = new JobHandler("Deleting", true) {
364 365

  
365 366
							@Override
......
395 396
		});
396 397

  
397 398
		// FIXME: show icon for results that are user persistable
398
		
399
		 	final int IMAGE_MARGIN = 2;
400
		    final Image icon = IImageKeys.getImage("icons/decorators/bullet_green.png");
401
//		    final Image icon = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.gef","platform:/plugin/org.eclipse.gef/org/eclipse/gef/internal/icons/pinned.gif").createImage();
402
//		    final Image icon = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.team.svn.help","platform:/plugin/org.eclipse.team.svn.help/images/lock.gif").createImage();
403
		    
404
		 	
405
		 	
406
//		 	treeViewer.getTree().addListener(SWT.MeasureItem, new Listener() {
407
//		 	   public void handleEvent(Event event) {
408
//		 	      TreeItem item = (TreeItem)event.item;
409
//		 	      Image trailingImage = (Image)item.getImage();
410
//		 	      if (trailingImage != null) {
411
//		 	         event.width += trailingImage.getBounds().width + IMAGE_MARGIN;
412
//		 	      }
413
//		 	   }
414
//		 	});
415
//		 	treeViewer.getTree().addListener(SWT.PaintItem, new Listener() {
416
//		 	   public void handleEvent(Event event) {
417
//		 		   if(event.item.getData() instanceof TXMResult && ((TXMResult)event.item.getData()).isUserPersistable())	{
418
//			 	      TreeItem item = (TreeItem)event.item;
419
//			 	      Image trailingImage = (Image)item.getImage();
420
//			 	      if (trailingImage != null) {
421
//			 	         //int x = event.x + event.width + IMAGE_MARGIN;
422
//			 	        int x = event.x + event.width;
423
//			 	        //int x = event.x - 20;
424
//			 	       //int x = event.x - 5;
425
//			 	         int itemHeight = treeViewer.getTree().getItemHeight();
426
//			 	         int imageHeight = trailingImage.getBounds().height;
427
//			 	         int y = event.y + (itemHeight - imageHeight) / 2;
428
//			 	        //int y = event.y + 5;
429
//			 	        
430
//			 	       event.gc.drawImage(icon, x, y); 
431
//			 	        //event.gc.drawImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_SAVE_EDIT_DISABLED), x, y);
432
//			 	      }
433
//		 		   }
434
//		 	   }
435
//		 	});
436
		
437
		
399

  
400
		final int IMAGE_MARGIN = 2;
401
		final Image icon = IImageKeys.getImage("icons/decorators/bullet_green.png");
402
		//		    final Image icon = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.gef","platform:/plugin/org.eclipse.gef/org/eclipse/gef/internal/icons/pinned.gif").createImage();
403
		//		    final Image icon = AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.team.svn.help","platform:/plugin/org.eclipse.team.svn.help/images/lock.gif").createImage();
404

  
405

  
406

  
407
		//		 	treeViewer.getTree().addListener(SWT.MeasureItem, new Listener() {
408
		//		 	   public void handleEvent(Event event) {
409
		//		 	      TreeItem item = (TreeItem)event.item;
410
		//		 	      Image trailingImage = (Image)item.getImage();
411
		//		 	      if (trailingImage != null) {
412
		//		 	         event.width += trailingImage.getBounds().width + IMAGE_MARGIN;
413
		//		 	      }
414
		//		 	   }
415
		//		 	});
416
		//		 	treeViewer.getTree().addListener(SWT.PaintItem, new Listener() {
417
		//		 	   public void handleEvent(Event event) {
418
		//		 		   if(event.item.getData() instanceof TXMResult && ((TXMResult)event.item.getData()).isUserPersistable())	{
419
		//			 	      TreeItem item = (TreeItem)event.item;
420
		//			 	      Image trailingImage = (Image)item.getImage();
421
		//			 	      if (trailingImage != null) {
422
		//			 	         //int x = event.x + event.width + IMAGE_MARGIN;
423
		//			 	        int x = event.x + event.width;
424
		//			 	        //int x = event.x - 20;
425
		//			 	       //int x = event.x - 5;
426
		//			 	         int itemHeight = treeViewer.getTree().getItemHeight();
427
		//			 	         int imageHeight = trailingImage.getBounds().height;
428
		//			 	         int y = event.y + (itemHeight - imageHeight) / 2;
429
		//			 	        //int y = event.y + 5;
430
		//			 	        
431
		//			 	       event.gc.drawImage(icon, x, y); 
432
		//			 	        //event.gc.drawImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_SAVE_EDIT_DISABLED), x, y);
433
		//			 	      }
434
		//		 		   }
435
		//		 	   }
436
		//		 	});
437

  
438

  
438 439
		MenuManager menuManager = new MenuManager();
439 440
		Menu menu = menuManager.createContextMenu(treeViewer.getTree());
440 441

  
......
599 600
			corporaView.treeViewer.reveal(obj);
600 601
		}
601 602
	}
603

  
604
	public static boolean isFocused() {
605
		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
606
		if (window == null) return false;
607
		IWorkbenchPage page = window.getActivePage();
608
		if (page == null) return false;
609

  
610
		IWorkbenchPart part = page.getActivePart();
611
		return part.getSite().getId().equals(CorporaView.ID);
612
	}
602 613
}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 1425)
64 64
import org.txm.core.messages.TXMCoreMessages;
65 65
import org.txm.core.results.Parameter;
66 66
import org.txm.core.results.TXMResult;
67
import org.txm.core.results.TXMResultListener;
67 68
import org.txm.rcp.JobsTimer;
68 69
import org.txm.rcp.StatusLine;
69 70
import org.txm.rcp.TXMWindows;
......
97 98
 * @author sjacquot
98 99
 *
99 100
 */
100
public abstract class TXMEditor<T extends TXMResult> extends EditorPart {
101
public abstract class TXMEditor<T extends TXMResult> extends EditorPart implements TXMResultListener, Comparable<TXMEditor> {
101 102

  
102 103
	/**
103 104
	 * ID to use in plugin.xml to contribute to the top toolbar.
......
188 189
	 */
189 190
	protected boolean dirty;
190 191

  
192
	public int compareTo(TXMEditor other) {
193
		return 1;
194
	}
191 195
	
192
	
193
	
194

  
195 196
	@Override
196 197
	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
197 198
		this.setSite(site);
198 199
		this.setInput(input);
199 200
		this.result = getEditorInput().getResult(); // store result for debug purpose
201
//		this.result.addResultListener(this);
200 202
		// FIXME: see how to use the Adapters and AdapterFactory to define image and title of Editor in the contributing plug-ins
201 203
		// another way is to use editors extension in plug-ins and redefine icon and name, using this solution the problem is that the name (which is also editor title) can not be dynamic according to the result data
202 204
		// so it seems better to use Adapters if it's possible or keep this solution below
......
237 239
		IPartListener2 pl = new IPartListener2() {
238 240
			// ... Other methods
239 241
			public void partClosed(IWorkbenchPartReference partRef) {
242
				
243
//				if (getResult() != null) {
244
//					getResult().removeResultListener(TXMEditor.this);
245
//				}
246
				
240 247
				if (partRef.getId().equals(TXMEditor.this.getClass().getName())) { // called after this.doSave() 
241 248
					//System.out.println("EVENT partClosed");
242 249
					for (TXMEditorExtension<T> b : extensions) {
......
284 291
	public GLComposite getFirstLineComposite() {
285 292
		return firstLineComposite;
286 293
	}
294
	
295
	public boolean isDisposed() {
296
		return resultArea == null || resultArea.isDisposed();
297
	}
287 298

  
288 299
	public Shell getShell() {
289 300
		if (parent !=null && !parent.isDisposed()) {
......
510 521
	}
511 522

  
512 523
	@Override
513
	public void doSave(IProgressMonitor monitor) {
524
	public void doSave(final IProgressMonitor monitor) {
514 525
		// FIXME: SJ: to discuss. A this moment the save is automatically done or not in TXMResult.compute() according to a preference of the TBX
515 526
		//		if (TBXPreferences.getInstance().getBoolean(TBXPreferences.AUTO_SAVE_RESULTS)) { // ?
516 527
		//			getResult().saveParameters();
517 528
		//		}
518 529

  
519 530
		/// FIXME: SJ: dirty state tests
520
		//this.compute(true);
521
		this.setDirty(false);
522

  
531
		if (parent != null && !parent.isDisposed()) {
532
			parent.getDisplay().asyncExec(new Runnable() {
533
				
534
				@Override
535
				public void run() {
536
					compute(true);
537
					TXMEditor.this.setDirty(false);
538
				}
539
			});
540
		}
523 541
		
524 542
		notifyExtensions("notifyDoSave"); //$NON-NLS-1$
525 543
		firePropertyChange(IEditorPart.PROP_DIRTY);
......
756 774
//								setDirty(false);
757 775
								
758 776
								refresh(update);
777
								
778
//								// refresh all opened editors
779
//								// FIXME: update all open editors of the children result
780
//								// FIXME: prob here is that updateEditorFromResult() doesn't enough because the compute() method does some other stuff
781
//								// so the cascade computing may be done here rather than in TXMResult.compute() or we need to move some stuff from TXMEditor.compute() to
782
//								// TXMEditor.updateEditorFromResult(), eg. the chart loading
783
//								// WARNING: At This moment, with this code, TXMResult.compute() of the children is called twice
784
//								for (IEditorReference reference : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences()) {
785
//									IEditorPart editor = reference.getEditor(false);
786
//									if(editor != null && editor instanceof TXMEditor)	{
787
//										TXMEditor txmEditor = ((TXMEditor)editor);
788
//										//if (txmEditor.getResult().getParent() == this.getResult())	{
789
//											Log.finest("TXMEditor.refresh(): updating editor for result: " + txmEditor.getResult().getSimpleName());
790
//											//txmEditor.compute(false);
791
//											//txmEditor.updateEditorFromResult(false);
792
//											txmEditor.refresh(false);
793
//										//}
794
//									}
795
//								}
796
								
797
								// focus in the main widget 
798
								setFocus();
759 799
							} catch (Exception e) {
760 800
								Log.finest("TXMEditor.compute(): " + TXMEditor.this.getClass().getSimpleName() + ": Error while refreshing the editor: " + e); //$NON-NLS-1$
761 801
								Log.printStackTrace(e);
......
829 869
		return editor;
830 870
	}
831 871

  
832

  
833 872
	/**
834 873
	 * Synchronizes the editor with the result and refreshes the corpus view.
835 874
	 * Also fires a dirty property change.
......
876 915
		// FIXME: debug test to not draw while updating the widgets
877 916
		this.getContainer().setRedraw(true);
878 917
		
879
		// focus in the main widget 
880
		this.setFocus();
881

  
882 918
		/// FIXME: SJ: dirty state tests
883 919
		this.setDirty(false);
884 920

  
885 921
		
886
		// FIXME: update all open editors of the children result
887
		// FIXME: prob here is that updateEditorFromResult() doesn't enough because the compute() method does some other stuff
888
		// so the cascade computing may be done here rather than in TXMResult.compute() or we need to move some stuff from TXMEditor.compute() to
889
		// TXMEditor.updateEditorFromResult(), eg. the chart loading
890
		// WARNING: At This moment, with this code, TXMResult.compute() of the children is called twice
891
		//						for (IEditorReference reference : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences()) {
892
		//							IEditorPart editor = reference.getEditor(false);
893
		//							if(editor != null && editor instanceof TXMEditor)	{
894
		//								TXMEditor txmEditor = ((TXMEditor)editor);
895
		//								if(txmEditor.getResult().getParent() == this.getResult())	{
896
		//									Log.finest("TXMEditor.refresh(): updating editor for result: " + txmEditor.getResult().getSimpleName());
897
		//									txmEditor.compute(false);
898
		//									//txmEditor.updateEditorFromResult(false);
899
		//									//txmEditor.refresh(false);
900
		//								}
901
		//							}
902
		//						}
922
		
903 923

  
904 924
		notifyExtensions("notifyEndOfRefresh"); //$NON-NLS-1$
905 925
	}
......
912 932
	public abstract void updateResultFromEditor();
913 933

  
914 934
	/**
935
	 * UI safe
936
	 * 
915 937
	 * Synchronizes the editor with the result. 
916 938
	 * Dedicated to dynamically change the editor components from the stored result.
917 939
	 * <p>
918 940
	 * Use this method if you need to save parameter with Type not managed by the autoUpdateEditorFieldsFromResult method
919 941
	 * @throws Exception 
920 942
	 */
943
	public final void updateFromResult(final boolean update) throws Exception {
944
		if (this.parent != null && !this.parent.isDisposed()) {
945
			this.parent.getDisplay().syncExec(new Runnable() {
946
				
947
				@Override
948
				public void run() {
949
					try {
950
						refresh(update);
951
					} catch (Exception e) {
952
						// TODO Auto-generated catch block
953
						e.printStackTrace();
954
					}
955
				}
956
			});
957
		}
958
	}
959
	
960
	/**
961
	 * Synchronizes the editor with the result. 
962
	 * Dedicated to dynamically change the editor components from the stored result.
963
	 * <p>
964
	 * Use this method if you need to save parameter with Type not managed by the autoUpdateEditorFieldsFromResult method
965
	 * @throws Exception 
966
	 */
921 967
	public abstract void updateEditorFromResult(boolean update) throws Exception;
922 968

  
923 969

  
tmp/org.txm.rcp/plugin.xml (revision 1425)
139 139
            restorable="true">
140 140
      </view>
141 141
      <view
142
            category="org.txm.rcp"
143
            class="org.txm.rcp.views.QueriesView"
144
            icon="icons/objects/query.png"
145
            id="org.txm.rcp.views.QueriesView"
146
            name="%view.name.4"
147
            restorable="true">
148
      </view>
149
      <view
150 142
            category="org.txm.rcp.debug"
151 143
            class="org.txm.rcp.views.SummaryView"
152 144
            id="org.txm.rcp.views.InternalCorpusView"
tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java (revision 1425)
1577 1577
				for(String key : preferences.keys()) {
1578 1578
					dstPreferences.put(key, preferences.get(key, ""));
1579 1579
				}
1580
				dstPreferences.flush();
1580 1581
			}
1581 1582
			catch(BackingStoreException e) {
1582 1583
				// TODO Auto-generated catch block
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 1425)
10 10
import java.util.Date;
11 11
import java.util.HashMap;
12 12
import java.util.List;
13
import java.util.TreeSet;
13 14
import java.util.concurrent.Semaphore;
14 15
import java.util.regex.Pattern;
15 16

  
......
38 39
 * 
39 40
 * A TXMResult always have a parent (except the root: @see Workspace).
40 41
 * 
41
 * To compute a result simply call the {@link #compute()} method. It contains all the life cycle steps of the result.
42
 * To compute a result simply call the {@link #compute()} method. It contains
43
 * all the life cycle steps of the result.
42 44
 * 
43
 * To set parameters, you can alternatively call the {@link #setParameters()} methods or the setXXX methods. The setParameters methods are usually useful to transfer several parameters at once.
45
 * To set parameters, you can alternatively call the {@link #setParameters()}
46
 * methods or the setXXX methods. The setParameters methods are usually useful
47
 * to transfer several parameters at once.
44 48
 * 
45
 * The class contains convenient methods to maintain the same logic between results :
46
 * - canCompute() : test if all necessary parameters are set
47
 * - isDirty(): return true if the result needs to be recomputed (if a parameter changed)
49
 * The class contains convenient methods to maintain the same logic between
50
 * results : - canCompute() : test if all necessary parameters are set -
51
 * isDirty(): return true if the result needs to be recomputed (if a parameter
52
 * changed)
48 53
 * 
49 54
 * Groovy call sample :
55
 * 
50 56
 * <pre>
51 57
 * {@code
52 58
 * MyTXMResult result = new MyTXMResult(parent);
......
59 65
 * </pre>
60 66
 * 
61 67
 * @author mdecorde
68
 * 
62 69
 * @author sjacquot
63 70
 */
64 71
public abstract class TXMResult implements Cloneable, IProgressMonitor, Comparable<TXMResult> {
......
69 76
	public static final String UNDERSCORE = "_";
70 77

  
71 78
	private static int next = 0;
72
	
79
	//TreeSet<TXMResultListener> listeners = new TreeSet<>();
73 80

  
74
	
75
//	/**
76
//	 * Unique ID of the result.
77
//	 */
78
//	protected String uniqueID;
81
	// /**
82
	// * Unique ID of the result.
83
	// */
84
	// protected String uniqueID;
79 85

  
80 86
	/**
81 87
	 * Editor can use this to test if the result has been computed once.
......
88 94
	protected int weight;
89 95

  
90 96
	/**
91
	 * the command this command to true when the result needs to be recomputed.
92
	 * like after updating parameters
97
	 * the command this command to true when the result needs to be recomputed. like
98
	 * after updating parameters
93 99
	 */
94 100
	protected boolean dirty = true;
95
	
101

  
96 102
	/**
97 103
	 * if frozen, the result is not updated when computed
98 104
	 */
99 105
	protected boolean frozen = false;
100
	
106

  
101 107
	/**
102
	 * if a method changed the internal data without **recomputing** the result, the result must be marked "altered"
108
	 * if a method changed the internal data without **recomputing** the result, the
109
	 * result must be marked "altered"
103 110
	 */
104 111
	protected boolean altered = false;
105 112

  
......
117 124
	 * Command preferences node path.
118 125
	 */
119 126
	protected String commandPreferencesNodePath;
120
	//protected IEclipsePreferences preferencesNode; // TODO: directly use a preferences node rather than a node path?
127
	// protected IEclipsePreferences preferencesNode; // TODO: directly use a
128
	// preferences node rather than a node path?
121 129

  
122 130
	/**
123
	 * Parameters node path. Concatenation of the Project scope path + the result uuid
131
	 * Parameters node path. Concatenation of the Project scope path + the result
132
	 * uuid
124 133
	 */
125 134
	protected String parametersNodePath;
126 135

  
......
135 144
	private Semaphore progressSemaphore = new Semaphore(1);
136 145

  
137 146
	/**
138
	 * To keep track of the parameters used for the last computing and to determine if the result is dirty. 
147
	 * To keep track of the parameters used for the last computing and to determine
148
	 * if the result is dirty.
139 149
	 */
140
	// FIXME: SJ: actually only used by the chart results. Purpose here is that the chart creators need to know if a computing parameter has changed to recreate or not some entity.
141
	// The problem is since the result is already computing, the parameters are already updated and the method hasParameterChanged() will always return false. Using this stack fix the problem.
150
	// FIXME: SJ: actually only used by the chart results. Purpose here is that the
151
	// chart creators need to know if a computing parameter has changed to recreate
152
	// or not some entity.
153
	// The problem is since the result is already computing, the parameters are
154
	// already updated and the method hasParameterChanged() will always return
155
	// false. Using this stack fix the problem.
142 156
	// But this stack is also the start for an UNDO command on TXMResult.
143 157
	protected ArrayList<HashMap<String, Object>> parametersHistory = new ArrayList<HashMap<String, Object>>();
144 158

  
145
	
146 159
	/**
147 160
	 * Internal persistable state.
148 161
	 */
......
156 169
	/**
157 170
	 * The visibility state.
158 171
	 */
159
	@Parameter(key=TXMPreferences.VISIBLE, type=Parameter.INTERNAL)
172
	@Parameter(key = TXMPreferences.VISIBLE, type = Parameter.INTERNAL)
160 173
	private Boolean visible;
161 174

  
162 175
	/**
163 176
	 * The user name (to rename a result).
164 177
	 */
165
	@Parameter(key=TXMPreferences.USER_NAME, type=Parameter.INTERNAL)
178
	@Parameter(key = TXMPreferences.USER_NAME, type = Parameter.INTERNAL)
166 179
	protected String userName;
167 180

  
168 181
	/**
169
	 *  To store the simple name for unserialization and lazy loading.
170
	 *  This string can be used, for example, to display some infos in UI even if the result has not yet been recomputed.
182
	 * To store the simple name for unserialization and lazy loading. This string
183
	 * can be used, for example, to display some infos in UI even if the result has
184
	 * not yet been recomputed.
171 185
	 */
172
	@Parameter(key=TXMPreferences.LAZY_NAME, type=Parameter.INTERNAL)
186
	@Parameter(key = TXMPreferences.LAZY_NAME, type = Parameter.INTERNAL)
173 187
	private String lazyName;
174 188

  
175

  
176

  
177

  
178

  
179 189
	/**
180 190
	 * Creates a new TXMResult, child of the specified parent.
191
	 * 
181 192
	 * @param parent
182 193
	 */
183 194
	public TXMResult(TXMResult parent) {
......
185 196
	}
186 197

  
187 198
	/**
188
	 * Creates a new TXMResult with no parent.
189
	 * If a local node exist with the parent_uuid, the parent will be retrieved and this result will be added to it. 
199
	 * Creates a new TXMResult with no parent. If a local node exist with the
200
	 * parent_uuid, the parent will be retrieved and this result will be added to
201
	 * it.
202
	 * 
190 203
	 * @param uuid
191 204
	 */
192 205
	public TXMResult(String parametersNodePath) {
......
194 207
	}
195 208

  
196 209
	/**
197
	 * Creates a new TXMResult, child of the specified parent.
198
	 * If the parameters node path is null, a new path is generated from the project root path ending by a new generated UUID.
210
	 * Creates a new TXMResult, child of the specified parent. If the parameters
211
	 * node path is null, a new path is generated from the project root path ending
212
	 * by a new generated UUID.
199 213
	 * 
200 214
	 * @param uuid
201 215
	 * @param parent
......
208 222
			parent.addChild(this);
209 223
		}
210 224

  
211
		if (parametersNodePath == null)	{
212
			if (this.getProject() != null)	{
225
		if (parametersNodePath == null) {
226
			if (this.getProject() != null) {
213 227
				parametersNodePath = this.getProject().getParametersNodeRootPath();
214 228
			} else {
215 229
				parametersNodePath = "";
216 230
			}
217
			this.parametersNodePath = parametersNodePath + createUUID() + "_" + this.getClass().getSimpleName(); //$NON-NLS-1$;
218
		}
219
		else	{
231
			this.parametersNodePath = parametersNodePath + createUUID() + "_" + this.getClass().getSimpleName(); //$NON-NLS-1$ ;
232
		} else {
220 233
			this.parametersNodePath = parametersNodePath;
221 234
		}
222 235

  
......
225 238
		this.weight = 0;
226 239

  
227 240
		this.children = new ArrayList<TXMResult>(1);
228
		//this.children = Collections.synchronizedList(new ArrayList<TXMResult>()); // FIXME: SJ: can fix the conccurent excpetion if needed
241
		// this.children = Collections.synchronizedList(new ArrayList<TXMResult>()); //
242
		// FIXME: SJ: can fix the conccurent excpetion if needed
229 243

  
230
		this.commandPreferencesNodePath = FrameworkUtil.getBundle(getClass()).getSymbolicName(); //$NON-NLS-1$
244
		this.commandPreferencesNodePath = FrameworkUtil.getBundle(getClass()).getSymbolicName(); // $NON-NLS-1$
231 245
		Log.finest("TXMResult.TXMResult(): command preferences node path: " + this.commandPreferencesNodePath + "."); //$NON-NLS-1$ //$NON-NLS-2$
232 246

  
233

  
234 247
		this.visible = true;
235 248
		this.dirty = true;
236 249
		this.internalPersistable = false;
237 250
		this.userPersistable = TBXPreferences.getInstance().getBoolean(TBXPreferences.AUTO_PERSISTENCE_ENABLED);
238 251

  
239

  
240 252
		// retrieving parent from UUID
241 253
		String parentNodePath = this.getStringParameterValue(TXMPreferences.PARENT_PARAMETERS_NODE_PATH);
242 254

  
243
		//System.out.println("TXMResult.TXMResult(): parent UUID = " + parentUUID);
255
		// System.out.println("TXMResult.TXMResult(): parent UUID = " + parentUUID);
244 256

  
245 257
		if (!("ROOT".equals(this.parametersNodePath)) && // search for parent only if UUID != "ROOT"
246
				parent == null && 
247
				this.parametersNodePath != null && 
248
				!parentNodePath.isEmpty()) {
258
				parent == null && this.parametersNodePath != null && !parentNodePath.isEmpty()) {
249 259
			Log.finest("Searching parent with UUID: " + parentNodePath + "..."); //$NON-NLS-1$ //$NON-NLS-2$
250 260
			TXMResult retrievedParent = TXMResult.getResult(parentNodePath);
251 261
			if (retrievedParent != null) {
252 262
				Log.finest("Parent retrieved from UUID: " + retrievedParent + "."); //$NON-NLS-1$ //$NON-NLS-2$
253 263
				retrievedParent.addChild(this);
254
			}
255
			else {
264
			} else {
256 265
				Log.severe("Warning: no parent was found in project for path=" + parametersNodePath + " and puuid=" + parentNodePath + " preferences=" + this.dumpParameters()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
257 266
				// FIXME: commented for now
258
				//TBXPreferences.delete(this);
267
				// TBXPreferences.delete(this);
259 268
				return;
260 269
			}
261 270
		}
262 271

  
263
		// loads parameters from local result node, current command preferences or default command preferences
272
		// loads parameters from local result node, current command preferences or
273
		// default command preferences
264 274
		try {
265 275
			this.autoLoadParametersFromAnnotations(); // auto fill from Parameter annotations
266
			this.loadParameters();  // subclasses manual settings
276
			this.loadParameters(); // subclasses manual settings
267 277
		} catch (Exception e) {
268 278
			Log.severe("Fail to load " + parametersNodePath + "result: " + e); //$NON-NLS-1$ //$NON-NLS-2$
269 279
			Log.printStackTrace(e);
270 280
		}
271 281

  
272 282
		// Log
273
		if (this.parent == null)	{
283
		if (this.parent == null) {
274 284
			Log.finest("Warning: the TXMResult of " + this.getClass() + " is attached to no parent. (uuid = " + this.parametersNodePath + ")");//$NON-NLS-1$ //$NON-NLS-2$
275 285
		}
276 286

  
277 287
		try {
278 288
			this.parametersHistory.add(new HashMap<String, Object>());
279
			//this.updateLastParameters();
280
		}
281
		catch (Exception e) {
289
			// this.updateLastParameters();
290
		} catch (Exception e) {
282 291
			// TODO Auto-generated catch block
283 292
			e.printStackTrace();
284 293
		}
......
286 295

  
287 296
	/**
288 297
	 * Sets the user name.
298
	 * 
289 299
	 * @param name
290 300
	 */
291 301
	public void setUserName(String name) {
......
298 308
	public boolean isAltered() {
299 309
		return altered;
300 310
	}
301
	
311

  
302 312
	/**
303 313
	 * Mark the result as altered -> modifications are lost after a re-compute
314
	 * 
315
	 * children are marked dirty since data has been modified
304 316
	 */
305 317
	public void setAltered() {
306 318
		this.altered = true;
319
		for (TXMResult r : getChildren()) {
320
			r.setDirty();
321
		}
307 322
	}
308
	
323

  
309 324
	/**
310 325
	 * Freezes the result -> cannot be recomputed.
311 326
	 */
312 327
	public void freeze() {
313 328
		this.frozen = true;
314 329
	}
315
	
330

  
316 331
	/**
317 332
	 * Unfreezes the result -> can be recomputed.
318 333
	 */
......
326 341
	public void setFrozen(boolean frozen) {
327 342
		this.frozen = frozen;
328 343
	}
329
	
344

  
330 345
	/**
331 346
	 * @return true if the resutl is frozen
332 347
	 */
333 348
	public boolean isFrozen() {
334 349
		return this.frozen;
335 350
	}
336
	
351

  
337 352
	/**
338 353
	 * Creates an UUID dedicated to persistence of this result.
354
	 * 
339 355
	 * @return
340 356
	 */
341 357
	public static String createUUID() {
342
		// FIXME: see if it's useful to put the class name or not, should be better to save it in the .prefs
343
		//this.uniqueID = this.getClass().getName() + '@' + ID_TIME_FORMAT.format(new Date(System.currentTimeMillis())) + "_" + UUID.randomUUID();
358
		// FIXME: see if it's useful to put the class name or not, should be better to
359
		// save it in the .prefs
360
		// this.uniqueID = this.getClass().getName() + '@' + ID_TIME_FORMAT.format(new
361
		// Date(System.currentTimeMillis())) + "_" + UUID.randomUUID();
344 362
		return UUID_PREFIX + ID_TIME_FORMAT.format(new Date(System.currentTimeMillis())) + "_" + nextInt();
345 363
	}
346
	
364

  
347 365
	/**
348 366
	 * 
349 367
	 * @return the next integer in the current session of TXM
......
354 372

  
355 373
	/**
356 374
	 * Checks if the result at least one child.
375
	 * 
357 376
	 * @return
358 377
	 */
359 378
	public boolean hasChildren() {
360 379
		return this.children.size() > 0;
361 380
	}
362 381

  
363

  
364 382
	/**
365 383
	 * Gets the preferences node path of the result command.
366 384
	 * 
......
370 388
		return this.commandPreferencesNodePath;
371 389
	}
372 390

  
373

  
374 391
	public String[] getCommandPreferencesKeys() throws BackingStoreException {
375 392
		return TXMPreferences.getCommandScopeKeys(this.commandPreferencesNodePath);
376 393
	}
......
380 397
	}
381 398

  
382 399
	/**
383
	 * Gets a current parameter specified by its annotation "key" attribute and its annotation "type" attribute.
400
	 * Gets a current parameter specified by its annotation "key" attribute and its
401
	 * annotation "type" attribute.
402
	 * 
384 403
	 * @param key
385 404
	 * @param parameterType
386 405
	 * @return
......
390 409
	}
391 410

  
392 411
	/**
393
	 * Gets a current parameter specified by its annotation "key" attribute and its annotation "type" attribute.
412
	 * Gets a current parameter specified by its annotation "key" attribute and its
413
	 * annotation "type" attribute.
414
	 * 
394 415
	 * @param key
395
	 * @param propagateToParent if true ask the parents
416
	 * @param propagateToParent
417
	 *            if true ask the parents
396 418
	 * @param parameterType
397 419
	 * @return
398 420
	 */
399 421
	public Object getParameter(String key, boolean propagateToParent) {
400 422
		try {
401
			Field field = this.getField(key); 
402
			if (field != null)	{
423
			Field field = this.getField(key);
424
			if (field != null) {
403 425
				field.setAccessible(true);
404
				return field.get(this);	
426
				return field.get(this);
405 427
			} else if (propagateToParent && this.parent != null) {
406 428
				return this.parent.getParameter(key, propagateToParent);
407 429
			}
......
411 433
		return null;
412 434
	}
413 435

  
414

  
415 436
	/**
416 437
	 * Gets a member field according to its key.
438
	 * 
417 439
	 * @param key
418 440
	 * @return the field if exists otherwise null
419 441
	 */
420
	public Field getField(String key)	{
442
	public Field getField(String key) {
421 443

  
422
		Field field = null; 
444
		Field field = null;
423 445

  
424 446
		List<Field> fields = this.getAllFields();
425 447

  
......
436 458

  
437 459
	/**
438 460
	 * Returns all the member fields of the class instance.
461
	 * 
439 462
	 * @return the list of declared fields
440 463
	 */
441
	public List<Field> getAllFields()	{
464
	public List<Field> getAllFields() {
442 465

  
443 466
		List<Field> fields = new ArrayList<Field>();
444 467
		Class<?> clazz = this.getClass();
......
453 476

  
454 477
	/**
455 478
	 * Stores the parameters of the specified type used for last computing.
479
	 * 
456 480
	 * @throws Exception
457 481
	 */
458 482
	protected void updateLastParameters(int parameterType) throws Exception {
459 483
		this.updateLastParameters(parameterType, false);
460 484
	}
461 485

  
462

  
463 486
	/**
464 487
	 * Stores the parameters of the specified type used for last computing.
488
	 * 
465 489
	 * @param parameterType
466 490
	 * @param appendToLastParameters
467 491
	 * @throws Exception
......
470 494

  
471 495
		HashMap<String, Object> lastParameters;
472 496

  
473
		if(appendToLastParameters)	{
497
		if (appendToLastParameters) {
474 498
			lastParameters = this.getLastParametersFromHistory();
475
		}
476
		else	{
499
		} else {
477 500
			lastParameters = new HashMap<>();
478 501
		}
479 502

  
......
486 509
			}
487 510

  
488 511
			String name;
489
			if(!parameter.key().isEmpty())	{
512
			if (!parameter.key().isEmpty()) {
490 513
				name = parameter.key();
491
			}
492
			else	{
514
			} else {
493 515
				name = f.getName();
494 516
			}
495 517

  
......
497 519
			lastParameters.put(name, f.get(this));
498 520
		}
499 521

  
500
		if(!appendToLastParameters)	{
522
		if (!appendToLastParameters) {
501 523
			this.parametersHistory.add(lastParameters);
502 524
		}
503 525

  
504 526
		// truncate the stack to the max count
505 527
		// FIXME: store this in a TBX preference
506
		if(this.parametersHistory.size() > 5)	{
528
		if (this.parametersHistory.size() > 5) {
507 529
			this.parametersHistory.remove(0);
508 530
			this.parametersHistory.remove(0);
509 531
			this.parametersHistory.remove(0);
......
513 535

  
514 536
	/**
515 537
	 * Stores the last parameters used for computing.
538
	 * 
516 539
	 * @throws Exception
517 540
	 */
518 541
	protected void updateLastParameters() throws Exception {
519 542
		this.updateLastParameters(Parameter.COMPUTING);
520 543
	}
521 544

  
522

  
523 545
	/**
524 546
	 * 
525 547
	 * @param parameterType
......
535 557
			}
536 558

  
537 559
			String name;
538
			if(!parameter.key().isEmpty())	{
560
			if (!parameter.key().isEmpty()) {
539 561
				name = parameter.key();
540
			}
541
			else	{
562
			} else {
542 563
				name = f.getName();
543 564
			}
544 565

  
......
546 567
			this.getLastParametersFromHistory().remove(name);
547 568
		}
548 569

  
549
		if(this.getLastParametersFromHistory().isEmpty())	{
570
		if (this.getLastParametersFromHistory().isEmpty()) {
550 571
			this.parametersHistory.remove(this.parametersHistory.size() - 1);
551 572
		}
552 573
	}
553 574

  
554

  
555 575
	/**
556
	 * Clears the parameters used for last computing.
557
	 * Dedicated to force a full recomputing.
576
	 * Clears the parameters used for last computing. Dedicated to force a full
577
	 * recomputing.
578
	 * 
558 579
	 * @throws Exception
559 580
	 */
560 581
	protected void clearLastComputingParameters() {
561 582
		this.clearLastParameters(Parameter.COMPUTING);
562 583
	}
563 584

  
564

  
565 585
	/**
566
	 * Checks if a parameter value has changed since the n-2 computing.
567
	 * This method permits to know, for example, if a parent that has already been computed was dirty before its computing,
568
	 * then a child can adjust or not its computing, regarding to the parent state.
586
	 * Checks if a parameter value has changed since the n-2 computing. This method
587
	 * permits to know, for example, if a parent that has already been computed was
588
	 * dirty before its computing, then a child can adjust or not its computing,
589
	 * regarding to the parent state.
590
	 * 
569 591
	 * @param key
570 592
	 * @param older
571 593
	 * @return
572 594
	 */
573 595
	public boolean hasParameterChanged(String key, boolean older) {
574
		if(older)	{
575
			return this.hasParameterChanged(key, this.parametersHistory.get(this.parametersHistory.size() - 2));	
576
		}
577
		else	{
596
		if (older) {
597
			return this.hasParameterChanged(key, this.parametersHistory.get(this.parametersHistory.size() - 2));
598
		} else {
578 599
			return this.hasParameterChanged(key);
579 600
		}
580 601
	}
581 602

  
582 603
	/**
583 604
	 * Checks if a parameter value has changed since last computing.
605
	 * 
584 606
	 * @param key
585 607
	 * @param parameterType
586 608
	 * @return
......
590 612
	}
591 613

  
592 614
	/**
593
	 * Checks if a parameter value has changed since last computing according to the specified external map.
615
	 * Checks if a parameter value has changed since last computing according to the
616
	 * specified external map.
617
	 * 
594 618
	 * @param key
595 619
	 * @param lastParameters
596 620
	 * @return
......
599 623
		if (key.isEmpty()) {
600 624
			return false;
601 625
		}
602
		//		if (this.isDirty()) {
603
		//			return true;
604
		//		}
626
		// if (this.isDirty()) {
627
		// return true;
628
		// }
605 629

  
606 630
		Object lastValue = lastParameters.get(key);
607 631
		Object newValue = this.getParameter(key);
608 632
		if (lastValue == null) {
609
			if(newValue != null)	{
633
			if (newValue != null) {
610 634
				return true;
611
			}
612
			else	{
635
			} else {
613 636
				return false;
614 637
			}
615
		}
616
		else {
638
		} else {
617 639
			return !lastValue.equals(newValue);
618 640
		}
619 641
	}
620 642

  
621

  
622

  
623 643
	/**
624
	 * Dumps the command and default preferences of the result preferences node qualifier.
644
	 * Dumps the command and default preferences of the result preferences node
645
	 * qualifier.
646
	 * 
625 647
	 * @return
626 648
	 */
627
	public String dumpPreferences()	{
649
	public String dumpPreferences() {
628 650

  
629 651
		StringBuilder str = new StringBuilder();
630 652

  
631
		if(TXMPreferences.resultScopeNodeExists(this))	{
653
		if (TXMPreferences.resultScopeNodeExists(this)) {
632 654
			str.append("\nResult local node preferences\n"); //$NON-NLS-1$
633 655
			str.append(TXMPreferences.getKeysAndValues(this.getParametersNodePath()));
634 656
		}
......
642 664
		return str.toString();
643 665
	}
644 666

  
645

  
646 667
	/**
647 668
	 * Dumps the result computing parameters (Parameter annotation).
669
	 * 
648 670
	 * @return
649 671
	 */
650
	public String dumpParameters()	{
672
	public String dumpParameters() {
651 673
		return this.dumpParameters(Parameter.COMPUTING);
652 674
	}
653 675

  
654

  
655 676
	/**
656 677
	 * Dumps the result computing parameters (Parameter annotation).
678
	 * 
657 679
	 * @param parametersType
658 680
	 * @return
659 681
	 */
660
	public String dumpParameters(int parametersType)	{
682
	public String dumpParameters(int parametersType) {
661 683

  
662 684
		StringBuilder str = new StringBuilder();
663 685

  
......
673 695
			f.setAccessible(true);
674 696

  
675 697
			String name;
676
			if(!parameter.key().isEmpty())	{
698
			if (!parameter.key().isEmpty()) {
677 699
				name = parameter.key();
678
			}
679
			else	{
700
			} else {
680 701
				name = f.getName();
681 702
			}
682 703

  
683 704
			try {
684 705
				Object v = f.get(this);
685 706
				if (v != null) {
686
					str.append(name + " ("+ v.getClass().getSimpleName() + ") = " + v + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
707
					str.append(name + " (" + v.getClass().getSimpleName() + ") = " + v + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
687 708
				} else {
688 709
					str.append(name + " = NULL \n"); //$NON-NLS-1$ //$NON-NLS-2$
689 710
				}
690
			}
691
			catch (IllegalArgumentException e) {
711
			} catch (IllegalArgumentException e) {
692 712
				// TODO Auto-generated catch block
693 713
				e.printStackTrace();
694
			}
695
			catch (IllegalAccessException e) {
714
			} catch (IllegalAccessException e) {
696 715
				// TODO Auto-generated catch block
697 716
				e.printStackTrace();
698 717
			}
......
700 719
		return str.toString();
701 720
	}
702 721

  
703

  
704

  
705 722
	/**
706 723
	 * Updates the dirty state by comparing an old parameter with a new one.
707 724
	 * 
708
	 * @param lastValue may be null
709
	 * @param newValue may be null
725
	 * @param lastValue
726
	 *            may be null
727
	 * @param newValue
728
	 *            may be null
710 729
	 */
711 730
	protected void updateDirty(Object lastValue, Object newValue) {
712
		if(lastValue == null && newValue == null)	{
731
		if (lastValue == null && newValue == null) {
713 732
			return;
714 733
		}
715 734
		if (lastValue == null || !lastValue.equals(newValue)) {
716
			Log.info("TXMResult.updateDirty(): " + this.getClass().getSimpleName() + ": setting dirty to true: last = "+ lastValue + " / new = " + newValue);
735
			Log.info("TXMResult.updateDirty(): " + this.getClass().getSimpleName() + ": setting dirty to true: last = " + lastValue + " / new = " + newValue);
717 736
			this.setDirty();
718 737
		}
719 738
	}
720 739

  
721 740
	/**
722
	 * Updates the dirty states by comparing TXMResult @Parameter with previously used parameters in the compute() method.
741
	 * Updates the dirty states by comparing TXMResult @Parameter with previously
742
	 * used parameters in the compute() method.
723 743
	 * 
724
	 * To work correctly :
725
	 *  - the equals method of the TXMResult parameters must be correctly implemented.
726
	 *  - the @Parameter member must be another variable (the previous is stored in the lastParameters protected variable) (e.g editing a List @Parameter is not enough for this test)
744
	 * To work correctly : - the equals method of the TXMResult parameters must be
745
	 * correctly implemented. - the @Parameter member must be another variable (the
746
	 * previous is stored in the lastParameters protected variable) (e.g editing a
747
	 * List @Parameter is not enough for this test)
727 748
	 * 
728
	 * The method is final and don't need to be re-implemented. To ignore this method, don't use the @Parameter annotations
749
	 * The method is final and don't need to be re-implemented. To ignore this
750
	 * method, don't use the @Parameter annotations
729 751
	 * 
730 752
	 * Implement isDirty if you need more test
731 753
	 * 
732 754
	 * @return
733
	 * @throws IllegalAccessException 
734
	 * @throws IllegalArgumentException 
755
	 * @throws IllegalAccessException
756
	 * @throws IllegalArgumentException
735 757
	 */
736 758
	public final boolean isDirtyFromHistory() throws Exception {
737 759

  
738 760
		List<Field> fields = this.getAllFields();
739
		
761

  
740 762
		for (Field f : fields) {
741 763
			Parameter parameter = f.getAnnotation(Parameter.class);
742
			if (parameter == null
743
					|| parameter.type() != Parameter.COMPUTING
744
					// FIXME: non electric mode tests
745
					//|| parameter.electric() == false 
746
					) {
764
			if (parameter == null || parameter.type() != Parameter.COMPUTING
765
			// FIXME: non electric mode tests
766
			// || parameter.electric() == false
767
			) {
747 768
				continue;
748 769
			}
749 770
			String name;
750
			if (!parameter.key().isEmpty())	{
771
			if (!parameter.key().isEmpty()) {
751 772
				name = parameter.key();
752
			}
753
			else {
773
			} else {
754 774
				name = f.getName();
755 775
			}
756 776

  
......
759 779
			Object previousValue = this.getLastParametersFromHistory().get(name);
760 780
			Object newValue = f.get(this);
761 781

  
762
			//			// FIXME: debug
763
			//			Log.finest("TXMResult.isDirtyFromHistory(): checking parameter: " + name);
782
			// // FIXME: debug
783
			// Log.finest("TXMResult.isDirtyFromHistory(): checking parameter: " + name);
764 784

  
765 785
			this.updateDirty(previousValue, newValue);
766 786
			if (this.dirty) {
......
771 791
		return this.dirty;
772 792
	}
773 793

  
774

  
775
	public HashMap<String, Object> getLastParametersFromHistory()	{
794
	public HashMap<String, Object> getLastParametersFromHistory() {
776 795
		return this.parametersHistory.get(this.parametersHistory.size() - 1);
777 796
	}
778 797

  
......
786 805
	}
787 806

  
788 807
	/**
789
	 * Marks the result as dirty so editors or others will know the TXMResult needs to be recomputed.
790
	 * This method is also recursively called on all the children branch to mark them as dirty.
808
	 * Marks the result as dirty so editors or others will know the TXMResult needs
809
	 * to be recomputed. This method is also recursively called on all the children
810
	 * branch to mark them as dirty.
791 811
	 */
792 812
	public void setDirty() {
793 813
		this.setDirty(true);
794 814
	}
795 815

  
796 816
	/**
797
	 *  Sets the result dirty state so editors or others will know the TXMResult needs to be recomputed or not.
798
	 *  This method is also recursively called on all the children branch sets the new dirty state.
817
	 * Sets the result dirty state so editors or others will know the TXMResult
818
	 * needs to be recomputed or not. This method is also recursively called on all
819
	 * the children branch sets the new dirty state.
820
	 * 
799 821
	 * @param dirty
800 822
	 */
801 823
	public void setDirty(boolean dirty) {
......
804 826
			this.children.get(i).setDirty(dirty);
805 827
		}
806 828
	}
807
	
808 829

  
809 830
	/**
810 831
	 * Gets the value of the specified key in parameters, local result node or
......
872 893
		return TXMPreferences.getString(key, this, this.commandPreferencesNodePath);
873 894
	}
874 895

  
875

  
876 896
	/**
877 897
	 * Checks if the specified parameter exists.
898
	 * 
878 899
	 * @param key
879 900
	 * @return
880 901
	 */
881
	public boolean parameterExists(String key)	{
902
	public boolean parameterExists(String key) {
882 903
		return TXMPreferences.keyExists(this.parametersNodePath, key);
883 904
	}
884 905

  
885 906
	/**
886
	 * Checks if a preference is empty (equals to "") in the command preference node.
887
	 * An empty preference can be used to disable a functionality for a kind of result
888
	 * (eg. A partition dimension bar chart does not have a legend so it can be used to not offer the hide/show legend button in UI).
907
	 * Checks if a preference is empty (equals to "") in the command preference
908
	 * node. An empty preference can be used to disable a functionality for a kind
909
	 * of result (eg. A partition dimension bar chart does not have a legend so it
910
	 * can be used to not offer the hide/show legend button in UI).
911
	 * 
889 912
	 * @param key
890 913
	 * @return
891 914
	 */
892
	public boolean isEmptyPreference(String key)	{
915
	public boolean isEmptyPreference(String key) {
893 916
		return TXMPreferences.isEmpty(this.commandPreferencesNodePath, key);
894 917
	}
895 918

  
896

  
897

  
898 919
	/**
899
	 * Stores the specified parameters pairs of key/value in a local node dedicated to the specified result. The node qualifier is generated by the <code>TXMResult.getUUID</code> method.
920
	 * Stores the specified parameters pairs of key/value in a local node dedicated
921
	 * to the specified result. The node qualifier is generated by the
922
	 * <code>TXMResult.getUUID</code> method.
900 923
	 * 
901 924
	 * @param key
902 925
	 * @return
......
905 928
		this.saveParameter(key, StringUtils.join(values, UNDERSCORE));
906 929
	}
907 930

  
908

  
909 931
	/**
910
	 * Stores the specified parameters pairs of key/value in a local node dedicated to the specified result. The node qualifier is generated by the <code>TXMResult.getUUID</code> method.
932
	 * Stores the specified parameters pairs of key/value in a local node dedicated
933
	 * to the specified result. The node qualifier is generated by the
934
	 * <code>TXMResult.getUUID</code> method.
935
	 * 
911 936
	 * @param result
912 937
	 * @param key
913 938
	 * @param value
914 939
	 */
915
	public void saveParameter(String key, Object value)	{
940
	public void saveParameter(String key, Object value) {
916 941
		// FIXME: debug
917
		//Log.info("TXMResult.saveParameter(): saving parameter " + key + " = " + value + " for " + this.getClass() + " (" + value.getClass() + ") to node.");
942
		// Log.info("TXMResult.saveParameter(): saving parameter " + key + " = " + value
943
		// + " for " + this.getClass() + " (" + value.getClass() + ") to node.");
918 944

  
919 945
		TXMPreferences.putLocal(this, key, value);
920 946
	}
921 947

  
922

  
923 948
	/**
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff