Révision 1429

tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/handlers/ComputeCA.java (revision 1429)
107 107
						return null;
108 108
					}
109 109

  
110
					// FIXME: old version using dialog box for parameters
111
					// ask property and Fmins and Vmax
112
					//				String title = TXMUIMessages.bind(CAUIMessages.ComputeCorrespondanceAnalysisDialog_0, partition.getName());
113
					//				CAParametersDialog d = new CAParametersDialog(window.getShell(), partition.getParent(), title);
114
					//
115
					//				if (d.open() == MessageDialog.OK) {
116
					//					WordProperty property = d.getProperty();
117
					//					int fMin = d.getFmin();
118
					//					int vMax = d.getMaxLines();
119
					//
120
					//					Log.info(NLS.bind(CAUIMessages.computingCorrespondenceAnalysisOnP0WithPropertyP1, partition, property));
121
					//
122
					//					LexicalTable lexicalTable = new LexicalTable(partition);
123
					//					lexicalTable.setParameters(property, fMin, vMax, null);
124
					//					ca = new CA(lexicalTable);
125
					//				} else { // aborted
126
					//					return null;
127
					//				}
128

  
129 110
					// FIXME: SJ: temporary version before we fix the problems listed below
130 111
					lexicalTable = new LexicalTable(partition);
131 112
					lexicalTable.setParameters((WordProperty) partition.getCorpus().getDefaultProperty(), 20, 200, null);
......
133 114

  
134 115
					// FIXME: SJ: new version, creating a, empty LT and an empty CA
135 116
					// does not work at this time because of some problems in CAEditor (refreshing and components creation + eigenvalues computing)
136
					//				ca = new CA(new LexicalTable(partition));
117
//					lexicalTable = new LexicalTable(partition);
118
//					ca = new CA(lexicalTable);
137 119
				}
138 120
				else if (selection instanceof PartitionIndex) {
139 121
					PartitionIndex index = (PartitionIndex) selection;
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/CAEditor.java (revision 1429)
27 27
//
28 28
package org.txm.ca.rcp.editors;
29 29

  
30
import java.awt.Component;
31
import java.awt.event.ComponentEvent;
32
import java.awt.event.ComponentListener;
33
import java.text.DecimalFormat;
34 30
import java.util.ArrayList;
35 31
import java.util.Arrays;
36 32
import java.util.List;
37 33

  
38 34
import org.eclipse.jface.viewers.ISelectionChangedListener;
39 35
import org.eclipse.jface.viewers.IStructuredContentProvider;
40
import org.eclipse.jface.viewers.ITableLabelProvider;
41 36
import org.eclipse.jface.viewers.LabelProvider;
42 37
import org.eclipse.jface.viewers.SelectionChangedEvent;
43 38
import org.eclipse.jface.viewers.TableViewer;
......
46 41
import org.eclipse.swt.SWT;
47 42
import org.eclipse.swt.events.SelectionEvent;
48 43
import org.eclipse.swt.events.SelectionListener;
49
import org.eclipse.swt.graphics.Image;
50 44
import org.eclipse.swt.graphics.Rectangle;
51 45
import org.eclipse.swt.layout.FillLayout;
52 46
import org.eclipse.swt.layout.FormAttachment;
......
64 58
import org.eclipse.ui.PartInitException;
65 59
import org.eclipse.ui.part.EditorPart;
66 60
import org.txm.ca.core.chartsengine.base.CAChartCreator;
67
import org.txm.ca.core.chartsengine.base.Utils;
68 61
import org.txm.ca.core.functions.CA;
69 62
import org.txm.ca.core.functions.Eigenvalues;
70 63
import org.txm.ca.rcp.messages.CAUIMessages;
71 64
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
72
import org.txm.chartsengine.rcp.editors.ChartEditorInput;
73 65
import org.txm.chartsengine.rcp.editors.ChartEditor;
66
import org.txm.chartsengine.rcp.editors.ChartEditorInput;
74 67
import org.txm.core.results.TXMResult;
68
import org.txm.rcp.editors.ITablableEditorInput;
75 69
import org.txm.rcp.editors.SplitedGenericMultiPageEditor;
76
import org.txm.rcp.editors.TXMEditor;
77 70
import org.txm.rcp.editors.TXMMultiPageEditor;
78 71
import org.txm.rcp.editors.TXMResultEditorInput;
79
import org.txm.rcp.editors.ITablableEditorInput;
80 72
import org.txm.rcp.editors.input.AbstractTablableEditorInput;
81 73
import org.txm.rcp.messages.TXMUIMessages;
82
import org.txm.statsengine.core.StatException;
83
import org.txm.utils.logger.Log;
84 74

  
85 75
// TODO: Auto-generated Javadoc
86 76
/**
......
91 81
 */
92 82
public class CAEditor extends TXMMultiPageEditor implements SplitedGenericMultiPageEditor {
93 83

  
94
	/** The self. */
95
	CAEditor self;
96 84

  
97 85
	/** The ca. */
98 86
	private CA ca;
......
103 91
	protected EditorPart mainEditor;
104 92

  
105 93

  
106
	private static String SEPARATOR = "SEPARATOR"; //$NON-NLS-1$
94
	public static String SEPARATOR = "SEPARATOR"; //$NON-NLS-1$
107 95

  
108
	private static String COL_TYPE = "Double"; //$NON-NLS-1$
96
	public static String COL_TYPE = "Double"; //$NON-NLS-1$
109 97

  
110 98
	/** The names. */
111 99
	private List<String> names = Arrays.asList(new String[] {
......
121 109
	 */
122 110
	@Override
123 111
	protected void createPages() {
124
		self = this;
125 112
		Composite container = this.getContainer();
126 113
		final Composite parentContainer = container.getParent();
127 114

  
......
130 117
		parentContainer.setLayout(new FormLayout());// change layout
131 118
		final Sash sash = new Sash(parentContainer, SWT.VERTICAL);
132 119

  
133
		Composite caChartComposite = new Composite(parentContainer, SWT.NONE);
120
		Composite mainEditorComposite = new Composite(parentContainer, SWT.NONE);
134 121

  
135 122
		FormData containerData = new FormData();
136 123
		containerData.left = new FormAttachment(sash, 0);
......
158 145
			}
159 146
		});
160 147

  
161
		FormData AFCgraphData = new FormData();
162
		AFCgraphData.left = new FormAttachment(0, 0);
163
		AFCgraphData.right = new FormAttachment(sash, 0);
164
		AFCgraphData.top = new FormAttachment(0, 0);
165
		AFCgraphData.bottom = new FormAttachment(100, 0);
166
		caChartComposite.setLayoutData(AFCgraphData);// set new layout data
167
		caChartComposite.setLayout(new FillLayout());
148
		FormData CAFactorialMapChartFormData = new FormData();
149
		CAFactorialMapChartFormData.left = new FormAttachment(0, 0);
150
		CAFactorialMapChartFormData.right = new FormAttachment(sash, 0);
151
		CAFactorialMapChartFormData.top = new FormAttachment(0, 0);
152
		CAFactorialMapChartFormData.bottom = new FormAttachment(100, 0);
153
		mainEditorComposite.setLayoutData(CAFactorialMapChartFormData);// set new layout data
154
		mainEditorComposite.setLayout(new FillLayout());
168 155
		// /////////////////////
169 156

  
170 157

  
171 158
		editors = new ArrayList<EditorPart>();
172 159
		inputs = new ArrayList<IEditorInput>();
173 160

  
174
		TXMResultEditorInput cainput = (TXMResultEditorInput) getEditorInput();
175
		this.ca = (CA) cainput.getResult();
161
		TXMResultEditorInput caInput = (TXMResultEditorInput) getEditorInput();
162
		this.ca = (CA) caInput.getResult();
176 163

  
177
		setPartName(this.ca.getName());
164
		//this.setPartName(this.ca.getName());
178 165

  
179 166
		// Initialize the editor parts and editor inputs
180 167
		this.initCAFactorialMapEditor();
181
		this.initCASingularValuesTableEditor();
182
		this.initRowsTableEditor();
183
		this.initColumnsTableEditor();
168
	//	this.initCASingularValuesTableEditor();
169
//		this.initRowsTableEditor();
170
//		this.initColumnsTableEditor();
184 171
		this.initCASingularValuesBarChartEditor();
185 172

  
186 173

  
......
194 181
			final CAFactorialMapChartEditor caFactorialMapEditorPart = (CAFactorialMapChartEditor) editors.get(0); 
195 182
			this.mainEditor = caFactorialMapEditorPart;
196 183

  
197
			IEditorSite site = createSite(caFactorialMapEditorPart);
184
			IEditorSite site = this.createSite(caFactorialMapEditorPart);
198 185
			// call init first so that if an exception is thrown, we have created no new widgets
199
			caFactorialMapEditorPart.init(site, editors.get(0).getEditorInput());
186
			caFactorialMapEditorPart.init(site, caFactorialMapEditorPart.getEditorInput());
200 187

  
201 188
			// Set the parent multi pages editor of the CA factorial map editor to activate it from the child editor
202 189
			caFactorialMapEditorPart.setParentMultiPagesEditor(this);
203 190

  
204
			caFactorialMapEditorPart.createPartControl(caChartComposite);
191
			caFactorialMapEditorPart.createPartControl(mainEditorComposite);
205 192
			caFactorialMapEditorPart.refresh(false);
206 193

  
207 194
			caFactorialMapEditorPart.addPropertyListener(new IPropertyListener() {
208 195
				@Override
209 196
				public void propertyChanged(Object source, int propertyId) {
210
					self.handlePropertyChange(propertyId);
197
					handlePropertyChange(propertyId);
211 198
				}
212 199
			});
213 200

  
214
			// Axis unit square ratio constraint
215
			caFactorialMapEditorPart.getComposite().getChartComponent().setSquareOffEnabled(true);
216
			caFactorialMapEditorPart.getComposite().getChartComponent().squareOff();
217
			Component chartComponent = (Component) caFactorialMapEditorPart.getComposite().getChartComponent();
218
			// Axis unit square ratio constraint on resize
219
			chartComponent.addComponentListener(new ComponentListener() {
201
//			// Axis unit square ratio constraint
202
//			caFactorialMapEditorPart.getComposite().getChartComponent().setSquareOffEnabled(true);
203
//			caFactorialMapEditorPart.getComposite().getChartComponent().squareOff();
204
//			Component chartComponent = (Component) caFactorialMapEditorPart.getComposite().getChartComponent();
205
//			// Axis unit square ratio constraint on resize
206
//			chartComponent.addComponentListener(new ComponentListener() {
207
//
208
//				@Override
209
//				public void componentShown(ComponentEvent arg0) {
210
//					// TODO Auto-generated method stub
211
//				}
212
//
213
//				@Override
214
//				public void componentResized(ComponentEvent e) {
215
//					caFactorialMapEditorPart.getComposite().getChartComponent().squareOff();
216
//				}
217
//
218
//				@Override
219
//				public void componentMoved(ComponentEvent arg0) {
220
//					// TODO Auto-generated method stub
221
//				}
222
//
223
//				@Override
224
//				public void componentHidden(ComponentEvent arg0) {
225
//					// TODO Auto-generated method stub
226
//				}
227
//			});
220 228

  
221
				@Override
222
				public void componentShown(ComponentEvent arg0) {
223
					// TODO Auto-generated method stub
224
				}
225 229

  
226
				@Override
227
				public void componentResized(ComponentEvent e) {
228
					caFactorialMapEditorPart.getComposite().getChartComponent().squareOff();
229
				}
230

  
231
				@Override
232
				public void componentMoved(ComponentEvent arg0) {
233
					// TODO Auto-generated method stub
234
				}
235

  
236
				@Override
237
				public void componentHidden(ComponentEvent arg0) {
238
					// TODO Auto-generated method stub
239
				}
240
			});
241

  
242

  
243 230
		}
244 231
		catch (Exception e1) {
245 232
			org.txm.rcp.utils.Logger.printStackTrace(e1);
......
263 250

  
264 251

  
265 252
		// Selection changed listener to highlight CA chart points from table lines selection
266
		ISelectionChangedListener selectionChangedListener = new ISelectionChangedListener() {
253
//		ISelectionChangedListener selectionChangedListener = new ISelectionChangedListener() {
254
//
255
//			@Override
256
//			public void selectionChanged(SelectionChangedEvent e) {
257
//				// Highlight points from table lines
258
//				Table table = (Table) ((TableViewer) e.getSource()).getTable();
259
//				String[] selectedLabels = new String[table.getSelectionCount()];
260
//				TableItem[] selection = table.getSelection();
261
//
262
//				for (int i = 0; i < selection.length; i++)	{
263
//					selectedLabels[i] = selection[i].getText();
264
//				}
265
//
266
//				CAFactorialMapChartEditor chartEditor = (CAFactorialMapChartEditor) editors.get(0);
267
//				((CAChartCreator) chartEditor.getResult().getChartCreator()).updateChartCAFactorialMapHighlightPoints(chartEditor.getChart(), (e.getSource() == getRowsInfosEditor().getViewer()), selectedLabels);
268
//			}
269
//		};
270
//
271
//		// Add selection listener to rows table to link editor with factorial map chart
272
//		this.getRowsInfosEditor().getViewer().addSelectionChangedListener(selectionChangedListener);
273
//		// Add selection listener to cols table to link editor with factorial map chart
274
//		this.getColsInfosEditor().getViewer().addSelectionChangedListener(selectionChangedListener);
275
//
276
//		// Selection listeners to change chart items selection order from table sorting
277
//		SelectionListener selectionListener = new SelectionListener() {
278
//
279
//			@Override
280
//			public void widgetSelected(SelectionEvent e) {
281
//				// Change chart items selection order
282
//				CAFactorialMapChartEditor chartEditor = (CAFactorialMapChartEditor) editors.get(0); 
283
//				((CAChartCreator) chartEditor.getResult().getChartCreator()).updateChartCAFactorialMapSetLabelItemsSelectionOrder(chartEditor.getChart(), getRowsInfosEditor().getOrdererLabels(), getColsInfosEditor().getOrdererLabels());
284
//			}
285
//
286
//			@Override
287
//			public void widgetDefaultSelected(SelectionEvent e) {
288
//				// TODO Auto-generated method stub
289
//
290
//			}
291
//		};
292
//		// Add listener to column to link chart items selection order with table sorting order
293
//		for(int i = 0; i < this.getRowsInfosEditor().getViewer().getTable().getColumnCount(); i++) {
294
//			this.getRowsInfosEditor().getViewer().getTable().getColumn(i).addSelectionListener(selectionListener);
295
//		}
296
//		// Add listener to column to link chart items selection order with table sorting order
297
//		for(int i = 0; i < this.getColsInfosEditor().getViewer().getTable().getColumnCount(); i++) {
298
//			this.getColsInfosEditor().getViewer().getTable().getColumn(i).addSelectionListener(selectionListener);
299
//		}
300
//
301
//
302
//
303
//		// Sets the parent multi pages editor of the singular values barplot to activate it from the child editor
304
//		((ChartEditor)editors.get(4)).setParentMultiPagesEditor(this);
305
//
306
//
307
//		this.setActivePage(LAST_EDITOR_USED);
267 308

  
268
			@Override
269
			public void selectionChanged(SelectionChangedEvent e) {
270
				// Highlight points from table lines
271
				Table table = (Table) ((TableViewer) e.getSource()).getTable();
272
				String[] selectedLabels = new String[table.getSelectionCount()];
273
				TableItem[] selection = table.getSelection();
274

  
275
				for (int i = 0; i < selection.length; i++)	{
276
					selectedLabels[i] = selection[i].getText();
277
				}
278

  
279
				CAFactorialMapChartEditor chartEditor = (CAFactorialMapChartEditor) editors.get(0);
280
				((CAChartCreator) chartEditor.getResult().getChartCreator()).updateChartCAFactorialMapHighlightPoints(chartEditor.getChart(), (e.getSource() == getRowsInfosEditor().getViewer()), selectedLabels);
281
			}
282
		};
283

  
284
		// Add selection listener to rows table to link editor with factorial map chart
285
		this.getRowsInfosEditor().getViewer().addSelectionChangedListener(selectionChangedListener);
286
		// Add selection listener to cols table to link editor with factorial map chart
287
		this.getColsInfosEditor().getViewer().addSelectionChangedListener(selectionChangedListener);
288

  
289
		// Selection listeners to change chart items selection order from table sorting
290
		SelectionListener selectionListener = new SelectionListener() {
291

  
292
			@Override
293
			public void widgetSelected(SelectionEvent e) {
294
				// Change chart items selection order
295
				CAFactorialMapChartEditor chartEditor = (CAFactorialMapChartEditor) editors.get(0); 
296
				((CAChartCreator) chartEditor.getResult().getChartCreator()).updateChartCAFactorialMapSetLabelItemsSelectionOrder(chartEditor.getChart(), getRowsInfosEditor().getOrdererLabels(), getColsInfosEditor().getOrdererLabels());
297
			}
298

  
299
			@Override
300
			public void widgetDefaultSelected(SelectionEvent e) {
301
				// TODO Auto-generated method stub
302

  
303
			}
304
		};
305
		// Add listener to column to link chart items selection order with table sorting order
306
		for(int i = 0; i < this.getRowsInfosEditor().getViewer().getTable().getColumnCount(); i++) {
307
			this.getRowsInfosEditor().getViewer().getTable().getColumn(i).addSelectionListener(selectionListener);
308
		}
309
		// Add listener to column to link chart items selection order with table sorting order
310
		for(int i = 0; i < this.getColsInfosEditor().getViewer().getTable().getColumnCount(); i++) {
311
			this.getColsInfosEditor().getViewer().getTable().getColumn(i).addSelectionListener(selectionListener);
312
		}
313

  
314

  
315

  
316
		// Sets the parent multi pages editor of the singular values barplot to activate it from the child editor
317
		((ChartEditor)editors.get(4)).setParentMultiPagesEditor(this);
318

  
319

  
320

  
321
		this.setActivePage(LAST_EDITOR_USED);
322

  
323 309
		this.setPartName(this.getEditorInput().getName());
324 310
	}
325 311

  
......
336 322
		// Editor input
337 323
		inputs.add(caFactorialMapEditorPart.getEditorInput());
338 324

  
325
//		try {
326
//			this.addPage(caFactorialMapEditorPart, caFactorialMapEditorPart.getEditorInput());
327
//		}
328
//		catch (PartInitException e) {
329
//			// TODO Auto-generated catch block
330
//			e.printStackTrace();
331
//		}
332
		
339 333
	}
340 334

  
341 335
	/**
......
350 344
		}
351 345
		
352 346
		// Editor part
353
		EigenvaluesChartEditor eigenvaluesEditor = new EigenvaluesChartEditor(SWTChartsComponentsProvider.getCurrent().createChartEditorInput(eigenvalues));
354
		eigenvaluesEditor.compute(false);
347
		//EigenvaluesChartEditor eigenvaluesEditor = new EigenvaluesChartEditor(SWTChartsComponentsProvider.getCurrent().createChartEditorInput(eigenvalues));
348
		EigenvaluesChartEditor eigenvaluesEditor = new EigenvaluesChartEditor(new ChartEditorInput<Eigenvalues>(eigenvalues));
349
		
350
		//eigenvaluesEditor.compute(false);
355 351
		editors.add(eigenvaluesEditor);
356 352

  
357 353
		// Editor input
......
363 359
	 */
364 360
	public void initCASingularValuesTableEditor()	{
365 361
		// Editor part
366
		editors.add(new SingularValuesEditor());
367

  
368
		// Editor input
369
		ITablableEditorInput table = new AbstractTablableEditorInput() {
370
			@Override
371
			public String[] getColumnTitles() {
372
				return new String[] {
373
						CAUIMessages.CorrespondanceAnalysisEditorInput_4,
374
						CAUIMessages.eigenvalue,
375
						"%", CAUIMessages.CorrespondanceAnalysisEditorInput_11, "", ""}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
376
			}
377

  
378
			@Override
379
			public String[] getColumnTypes() {
380
				return new String[] {
381
						TXMUIMessages.integer,
382
						COL_TYPE,
383
						COL_TYPE,
384
						COL_TYPE,
385
						COL_TYPE,
386
						SEPARATOR};
387
			}
388

  
389
			@Override
390
			public IStructuredContentProvider getContentProvider() {
391
				return new IStructuredContentProvider() {
392
					@Override
393
					public Object[] getElements(Object inputElement) {
394
						CA ca = (CA) inputElement;
395
						List<List<Object>> tabledata = ca.getSingularValuesInfos();
396
						return tabledata.toArray();
397
					}
398

  
399
					@Override
400
					public void dispose() {
401
						// TODO Auto-generated method stub
402
					}
403

  
404
					@Override
405
					public void inputChanged(Viewer viewer, Object oldInput,
406
							Object newInput) {
407
						// TODO Auto-generated method stub
408
					}
409
				};
410
			}
411

  
412
			@Override
413
			public Object getInput() {
414
				return ca;
415
			}
416

  
417
			@Override
418
			public LabelProvider getLabelProvider() {
419
				return new CASingularValueLabelProvider();
420
			}
421
		};
422

  
423
		inputs.add(table);
362
		SingularValuesEditor editor = new SingularValuesEditor(ca); 
363
		editors.add(editor);
364
		inputs.add(editor.getEditorInput());
424 365
	}
425 366

  
426 367
	/**
......
485 426
					}
486 427

  
487 428
					@Override
488
					public void inputChanged(Viewer viewer, Object oldInput,
489
							Object newInput) {
429
					public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
490 430
						// TODO Auto-generated method stub
491 431
					}
492 432
				};
......
587 527
		inputs.add(table);
588 528
	}
589 529

  
590
	/**
591
	 * The Class CASingularValueLabelProvider.
592
	 */
593
	private class CASingularValueLabelProvider extends LabelProvider implements	ITableLabelProvider {
594 530

  
595
		/**
596
		 * Percent values number format.
597
		 */
598
		protected DecimalFormat percentValuesNumberFormat = new DecimalFormat(new String("0.00")); //$NON-NLS-1$
599 531

  
600

  
601
		/* (non-Javadoc)
602
		 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
603
		 */
604
		@Override
605
		public Image getColumnImage(Object element, int columnIndex) {
606
			// TODO Auto-generated method stub
607
			return null;
608
		}
609

  
610
		/* (non-Javadoc)
611
		 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
612
		 */
613
		@Override
614
		@SuppressWarnings("unchecked") //$NON-NLS-1$
615
		public String getColumnText(Object element, int columnIndex) {
616
			DecimalFormat f;
617
			Object o = ((List<Object>) element).get(columnIndex);
618
			switch (columnIndex) {
619
			case 0: // factor
620
				return o.toString();
621
			case 1: // eigenvalue
622
				if ((Double) o < 1) {
623
					if ((Double) o < 0.0001)
624
						f = new DecimalFormat("0.0000E00"); //$NON-NLS-1$
625
					else
626
						f = new DecimalFormat("0.0000"); //$NON-NLS-1$
627
				} else {
628
					f = new DecimalFormat("##########0.0000"); //$NON-NLS-1$
629
				}
630
				// FIXME: printf syntax tests
631
				//return String.format("%.4f", o);
632
				return f.format(o);
633
			case 2: // percent
634
			case 3: // cumul
635
				return percentValuesNumberFormat.format(o);
636
			default:
637
				return ""; //$NON-NLS-1$
638
			}
639
		}
640
	}
641

  
642 532
	/**
643 533
	 * Gets the CA.
644 534
	 *
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/SingularValuesEditor.java (revision 1429)
27 27
//
28 28
package org.txm.ca.rcp.editors;
29 29

  
30
import java.text.DecimalFormat;
30 31
import java.util.ArrayList;
31 32
import java.util.List;
32 33

  
33
import org.eclipse.core.runtime.IProgressMonitor;
34 34
import org.eclipse.jface.action.MenuManager;
35
import org.eclipse.jface.viewers.ArrayContentProvider;
36
import org.eclipse.jface.viewers.IStructuredContentProvider;
37
import org.eclipse.jface.viewers.ITableLabelProvider;
38
import org.eclipse.jface.viewers.LabelProvider;
35 39
import org.eclipse.jface.viewers.TableViewer;
36 40
import org.eclipse.jface.viewers.TableViewerColumn;
41
import org.eclipse.jface.viewers.Viewer;
37 42
import org.eclipse.swt.SWT;
38 43
import org.eclipse.swt.events.SelectionAdapter;
39 44
import org.eclipse.swt.events.SelectionEvent;
45
import org.eclipse.swt.graphics.Image;
40 46
import org.eclipse.swt.layout.FillLayout;
41
import org.eclipse.swt.widgets.Composite;
42 47
import org.eclipse.swt.widgets.Event;
43 48
import org.eclipse.swt.widgets.Listener;
44 49
import org.eclipse.swt.widgets.Menu;
45 50
import org.eclipse.swt.widgets.Table;
46 51
import org.eclipse.swt.widgets.TableItem;
47
import org.eclipse.ui.IEditorInput;
48
import org.eclipse.ui.IEditorSite;
49
import org.eclipse.ui.PartInitException;
50
import org.eclipse.ui.part.EditorPart;
52
import org.txm.ca.core.functions.CA;
53
import org.txm.ca.rcp.messages.CAUIMessages;
54
import org.txm.core.results.TXMResult;
51 55
import org.txm.rcp.StatusLine;
52 56
import org.txm.rcp.editors.ITablableEditorInput;
57
import org.txm.rcp.editors.TXMEditor;
53 58
import org.txm.rcp.editors.TableKeyListener;
54 59
import org.txm.rcp.editors.TableSorter;
60
import org.txm.rcp.editors.input.AbstractTablableEditorInput;
55 61
import org.txm.rcp.messages.TXMUIMessages;
56 62
// TODO: Auto-generated Javadoc
57 63
/**
......
59 65
 *
60 66
 * @author mdecorde
61 67
 */
62
public class SingularValuesEditor extends EditorPart {
68
public class SingularValuesEditor extends TXMEditor<CA> {
63 69

  
70

  
71

  
64 72
	/** The ID. */
65 73
	static public String ID = "org.txm.rcp.editors.TableEditor"; //$NON-NLS-1$
66 74

  
67 75
	/** The viewer. */
68 76
	private TableViewer viewer;
69 77

  
70
	/** The i editor input. */
71
	private IEditorInput iEditorInput;
72

  
73 78
	/** The table input. */
74
	private ITablableEditorInput tableInput;
79
	//private ITablableEditorInput tableInput;
75 80

  
76 81
	/** The columns. */
77 82
	List<TableViewerColumn> columns = new ArrayList<TableViewerColumn>();
......
79 84
	/** The table sorter. */
80 85
	private TableSorter tableSorter;
81 86

  
82
	/* (non-Javadoc)
83
	 * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
84
	 */
85
	@Override
86
	public void doSave(IProgressMonitor monitor) {
87
		// TODO Auto-generated method stub
88
	}
89 87

  
90
	/* (non-Javadoc)
91
	 * @see org.eclipse.ui.part.EditorPart#doSaveAs()
88

  
89
	/**
90
	 * 
91
	 * @param result
92 92
	 */
93
	@Override
94
	public void doSaveAs() {
95
		// TODO Auto-generated method stub
96
	}
93
	public SingularValuesEditor(TXMResult result) {
94
		super(result);
95
		
96
//		// Editor input
97
//		ITablableEditorInput table = new AbstractTablableEditorInput() {
98
//			@Override
99
//			public String[] getColumnTitles() {
100
//				return new String[] {
101
//						CAUIMessages.CorrespondanceAnalysisEditorInput_4,
102
//						CAUIMessages.eigenvalue,
103
//						"%", CAUIMessages.CorrespondanceAnalysisEditorInput_11, "", ""}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
104
//			}
105
//
106
//			@Override
107
//			public String[] getColumnTypes() {
108
//				return new String[] {
109
//						TXMUIMessages.integer,
110
//						CAEditor.COL_TYPE,
111
//						CAEditor.COL_TYPE,
112
//						CAEditor.COL_TYPE,
113
//						CAEditor.COL_TYPE,
114
//						CAEditor.SEPARATOR};
115
//			}
116
//
117
//			@Override
118
//			public IStructuredContentProvider getContentProvider() {
119
//				return new IStructuredContentProvider() {
120
//					@Override
121
//					public Object[] getElements(Object inputElement) {
122
//						CA ca = (CA) inputElement;
123
//						List<List<Object>> tabledata = ca.getSingularValuesInfos();
124
//						return tabledata.toArray();
125
//					}
126
//
127
//					@Override
128
//					public void dispose() {
129
//						// TODO Auto-generated method stub
130
//					}
131
//
132
//					@Override
133
//					public void inputChanged(Viewer viewer, Object oldInput,
134
//							Object newInput) {
135
//						// TODO Auto-generated method stub
136
//					}
137
//				};
138
//			}
139
//
140
//			@Override
141
//			public Object getInput() {
142
//				return SingularValuesEditor.this.getResult();
143
//			}
144
//
145
//			@Override
146
//			public LabelProvider getLabelProvider() {
147
//				return new CASingularValueLabelProvider();
148
//			}
149
//		};
150
//
97 151

  
98
	/* (non-Javadoc)
99
	 * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
100
	 */
101
	@Override
102
	public void init(IEditorSite site, IEditorInput input)
103
			throws PartInitException {
104
		setSite(site);
105
		setInput(input);
106
		this.iEditorInput = input;
107 152
	}
108 153

  
109
	/* (non-Javadoc)
110
	 * @see org.eclipse.ui.part.EditorPart#isDirty()
154
	
155
	/**
156
	 * The Class CASingularValueLabelProvider.
111 157
	 */
112
	@Override
113
	public boolean isDirty() {
114
		// TODO Auto-generated method stub
115
		return false;
116
	}
158
	private class CASingularValueLabelProvider extends LabelProvider implements	ITableLabelProvider {
117 159

  
118
	/* (non-Javadoc)
119
	 * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
120
	 */
121
	@Override
122
	public boolean isSaveAsAllowed() {
123
		// TODO Auto-generated method stub
124
		return false;
160
		/**
161
		 * Percent values number format.
162
		 */
163
		protected DecimalFormat percentValuesNumberFormat = new DecimalFormat(new String("0.00")); //$NON-NLS-1$
164

  
165

  
166
		/* (non-Javadoc)
167
		 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
168
		 */
169
		@Override
170
		public Image getColumnImage(Object element, int columnIndex) {
171
			// TODO Auto-generated method stub
172
			return null;
173
		}
174

  
175
		/* (non-Javadoc)
176
		 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
177
		 */
178
		@Override
179
		@SuppressWarnings("unchecked") //$NON-NLS-1$
180
		public String getColumnText(Object element, int columnIndex) {
181
			DecimalFormat f;
182
			Object o = ((List<Object>) element).get(columnIndex);
183
			switch (columnIndex) {
184
			case 0: // factor
185
				return o.toString();
186
			case 1: // eigenvalue
187
				if ((Double) o < 1) {
188
					if ((Double) o < 0.0001)
189
						f = new DecimalFormat("0.0000E00"); //$NON-NLS-1$
190
					else
191
						f = new DecimalFormat("0.0000"); //$NON-NLS-1$
192
				} else {
193
					f = new DecimalFormat("##########0.0000"); //$NON-NLS-1$
194
				}
195
				// FIXME: printf syntax tests
196
				//return String.format("%.4f", o);
197
				return f.format(o);
198
			case 2: // percent
199
			case 3: // cumul
200
				return percentValuesNumberFormat.format(o);
201
			default:
202
				return ""; //$NON-NLS-1$
203
			}
204
		}
125 205
	}
206
	
126 207

  
127
	/* (non-Javadoc)
128
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
129
	 */
130 208
	@Override
131
	public void createPartControl(Composite parent) {
132
		parent.setLayout(new FillLayout());
209
	public void _createPartControl() throws Exception {
210
		
211
		this.parent.setLayout(new FillLayout());
133 212

  
134
		if (!(iEditorInput instanceof ITablableEditorInput)) {
135
			throw new IllegalArgumentException(TXMUIMessages.wrongInput);
136
		}
137
		tableInput = (ITablableEditorInput) iEditorInput;
213
		//tableInput = (ITablableEditorInput) this.getEditorInput();
138 214

  
139
		viewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL
140
				| SWT.MULTI | SWT.FULL_SELECTION);
215
		viewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
141 216
		viewer.getTable().addKeyListener(new TableKeyListener(viewer));
142 217

  
143 218
		Table table = viewer.getTable();
144 219
		table.setHeaderVisible(true);
145 220
		table.setLinesVisible(true);
146 221

  
147
		String[] titles = tableInput.getColumnTitles();
222
		String[] titles = new String[] {
223
				CAUIMessages.CorrespondanceAnalysisEditorInput_4,
224
				CAUIMessages.eigenvalue,
225
				"%", CAUIMessages.CorrespondanceAnalysisEditorInput_11, "", ""}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$;
148 226

  
227
		
149 228
		for (int i = 0; i < titles.length; i++) {
150 229
			final int index = i;
151 230
			final TableViewerColumn column;
......
166 245

  
167 246
			column.getColumn().addSelectionListener(new SelectionAdapter() {
168 247
				@Override
169
				public void widgetSelected(SelectionEvent e)
170
				{
248
				public void widgetSelected(SelectionEvent e) {
171 249
					StatusLine.setMessage(TXMUIMessages.sortingColumn);
172 250
					tableSorter.setColumn(index);
173 251
					int dir = viewer.getTable().getSortDirection();
......
213 291
		    });
214 292

  
215 293

  
294
		
295
		
216 296

  
217
		viewer.setContentProvider(tableInput.getContentProvider());
218
		viewer.setLabelProvider(tableInput.getLabelProvider());
219
		viewer.setInput(tableInput.getInput());
297
		//viewer.setContentProvider(tableInput.getContentProvider());
298
		
299
		
300
		viewer.setContentProvider(ArrayContentProvider.getInstance());
301
//		viewer.setContentProvider(new IStructuredContentProvider() {
302
//			@Override
303
//			public Object[] getElements(Object inputElement) {
304
//				return ((CA) inputElement).getSingularValuesInfos().toArray();
305
//			}
306
//
307
//			@Override
308
//			public void dispose() {
309
//				// TODO Auto-generated method stub
310
//			}
311
//
312
//			@Override
313
//			public void inputChanged(Viewer viewer, Object oldInput,
314
//					Object newInput) {
315
//				// TODO Auto-generated method stub
316
//			}
317
//		}
318
//);
319
		
320
		
321
		viewer.setLabelProvider(new CASingularValueLabelProvider());
322
		
323
		
324
		
220 325

  
221 326
		tableSorter = new TableSorter();
222
		tableSorter.setColumnTypes(tableInput.getColumnTypes());
327
		
328
		//tableSorter.setColumnTypes(tableInput.getColumnTypes());
329
		
330
		
331
		tableSorter.setColumnTypes(new String[] {
332
				TXMUIMessages.integer,
333
				CAEditor.COL_TYPE,
334
				CAEditor.COL_TYPE,
335
				CAEditor.COL_TYPE,
336
				CAEditor.COL_TYPE,
337
				CAEditor.SEPARATOR});
338
		
339
		
223 340
		viewer.setSorter(tableSorter);
224 341

  
225 342
		viewer.refresh();
......
234 351
		}
235 352
		viewer.getTable().setSortDirection(dir);
236 353
		viewer.getTable().setSortColumn(columns.get(0).getColumn());
354

  
355
		
237 356
		viewer.refresh();
238 357

  
239 358
		// Pack the columns except the bar plot column
......
242 361
				viewer.getTable().getColumn(i).pack();
243 362
			}
244 363
		}
364
		
245 365
	}
246 366

  
367

  
368
	@Override
369
	public void setFocus() {
370
		viewer.getControl().setFocus();
371
	}
372

  
373

  
374
	@Override
375
	public void updateResultFromEditor() {
376
		// TODO Auto-generated method stub
377
		
378
	}
379

  
380
	@Override
381
	public void updateEditorFromResult(boolean update) throws Exception {
382

  
383
		try {
384
			this.viewer.setInput(((CA)this.getResult()).getSingularValuesInfos().toArray());
385
		}
386
		catch (Exception e) {
387
			// TODO Auto-generated catch block
388
			e.printStackTrace();
389
			this.viewer.setInput(null);
390
		}
391
	}
392
	
393
	
247 394
	/**
248 395
	 * Creates the context menu.
249 396
	 *
......
261 408
		getSite().setSelectionProvider(tableViewer);
262 409
	}
263 410

  
264
	/* (non-Javadoc)
265
	 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
266
	 */
267
	@Override
268
	public void setFocus() {
269
		viewer.getControl().setFocus();
270
	}
271 411
}
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/CAFactorialMapChartEditor.java (revision 1429)
1 1
package org.txm.ca.rcp.editors;
2 2

  
3
import java.awt.Component;
4
import java.awt.event.ComponentEvent;
5
import java.awt.event.ComponentListener;
6

  
3 7
import org.eclipse.swt.SWT;
4 8
import org.eclipse.swt.custom.CLabel;
5 9
import org.eclipse.swt.events.SelectionEvent;
......
239 243
		};
240 244
		plansCombo.addSelectionListener(listener);
241 245

  
242
		// advanced parameters
246
		// parent parameters
243 247
		// thresholds
244
		if (!getResult().isParentVisible()) {
248
		if (!this.getResult().isParentVisible()) {
245 249
			ThresholdsGroup thresholdsGroup = new ThresholdsGroup(this.getExtendedParametersGroup(), SWT.NONE, this, true, false);
246 250
			this.fMinSpinner = thresholdsGroup.getFMinSpinner();
247 251
			this.vMaxSpinner = thresholdsGroup.getVMaxSpinner();
248 252
			this.vMaxSpinner.setMinimum(1);
249 253
		}
254
		
250 255
	}
251 256

  
252 257
	@Override
253 258
	public void updateEditorFromChart(boolean update) {
254
		// nothing to do
259
//		if(!update)	{
260
//		// Axis unit square ratio constraint
261
//		this.getComposite().getChartComponent().setSquareOffEnabled(true);
262
//		this.getComposite().getChartComponent().squareOff();
263
//		Component chartComponent = (Component) this.getComposite().getChartComponent();
264
//		// Axis unit square ratio constraint on resize
265
//		chartComponent.addComponentListener(new ComponentListener() {
266
//
267
//			@Override
268
//			public void componentShown(ComponentEvent arg0) {
269
//				// TODO Auto-generated method stub
270
//			}
271
//
272
//			@Override
273
//			public void componentResized(ComponentEvent e) {
274
//				getComposite().getChartComponent().squareOff();
275
//			}
276
//
277
//			@Override
278
//			public void componentMoved(ComponentEvent arg0) {
279
//				// TODO Auto-generated method stub
280
//			}
281
//
282
//			@Override
283
//			public void componentHidden(ComponentEvent arg0) {
284
//				// TODO Auto-generated method stub
285
//			}
286
//		});
287
//		}
288

  
255 289
	}
256 290

  
257 291
}
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 1429)
10 10
import java.util.Date;
11 11
import java.util.HashMap;
12 12
import java.util.List;
13
import java.util.TreeSet;
14 13
import java.util.concurrent.Semaphore;
15 14
import java.util.regex.Pattern;
16 15

  
......
39 38
 * 
40 39
 * A TXMResult always have a parent (except the root: @see Workspace).
41 40
 * 
42
 * To compute a result simply call the {@link #compute()} method. It contains
43
 * all the life cycle steps of the result.
41
 * To compute a result simply call the {@link #compute()} method. It contains all the life cycle steps of the result.
44 42
 * 
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.
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.
48 44
 * 
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)
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)
53 48
 * 
54 49
 * Groovy call sample :
55
 * 
56 50
 * <pre>
57 51
 * {@code
58 52
 * MyTXMResult result = new MyTXMResult(parent);
......
65 59
 * </pre>
66 60
 * 
67 61
 * @author mdecorde
68
 * 
69 62
 * @author sjacquot
70 63
 */
71 64
public abstract class TXMResult implements Cloneable, IProgressMonitor, Comparable<TXMResult> {
......
76 69
	public static final String UNDERSCORE = "_";
77 70

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

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

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

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

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

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

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

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

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

  
146 137
	/**
147
	 * To keep track of the parameters used for the last computing and to determine
148
	 * if the result is dirty.
138
	 * To keep track of the parameters used for the last computing and to determine if the result is dirty. 
149 139
	 */
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.
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.
156 142
	// But this stack is also the start for an UNDO command on TXMResult.
157 143
	protected ArrayList<HashMap<String, Object>> parametersHistory = new ArrayList<HashMap<String, Object>>();
158 144

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

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

  
181 168
	/**
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.
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.
185 171
	 */
186
	@Parameter(key = TXMPreferences.LAZY_NAME, type = Parameter.INTERNAL)
172
	@Parameter(key=TXMPreferences.LAZY_NAME, type=Parameter.INTERNAL)
187 173
	private String lazyName;
188 174

  
175

  
176

  
177

  
178

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

  
198 187
	/**
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
	 * 
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. 
203 190
	 * @param uuid
204 191
	 */
205 192
	public TXMResult(String parametersNodePath) {
......
207 194
	}
208 195

  
209 196
	/**
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.
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.
213 199
	 * 
214 200
	 * @param uuid
215 201
	 * @param parent
......
222 208
			parent.addChild(this);
223 209
		}
224 210

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

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

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

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

  
233

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

  
239

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

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

  
257 245
		if (!("ROOT".equals(this.parametersNodePath)) && // search for parent only if UUID != "ROOT"
258
				parent == null && this.parametersNodePath != null && !parentNodePath.isEmpty()) {
246
				parent == null && 
247
				this.parametersNodePath != null && 
248
				!parentNodePath.isEmpty()) {
259 249
			Log.finest("Searching parent with UUID: " + parentNodePath + "..."); //$NON-NLS-1$ //$NON-NLS-2$
260 250
			TXMResult retrievedParent = TXMResult.getResult(parentNodePath);
261 251
			if (retrievedParent != null) {
262 252
				Log.finest("Parent retrieved from UUID: " + retrievedParent + "."); //$NON-NLS-1$ //$NON-NLS-2$
263 253
				retrievedParent.addChild(this);
264
			} else {
254
			}
255
			else {
265 256
				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$
266 257
				// FIXME: commented for now
267
				// TBXPreferences.delete(this);
258
				//TBXPreferences.delete(this);
268 259
				return;
269 260
			}
270 261
		}
271 262

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

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

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

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

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

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

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

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

  
336
	
352 337
	/**
353 338
	 * Creates an UUID dedicated to persistence of this result.
354
	 * 
355 339
	 * @return
356 340
	 */
357 341
	public static String createUUID() {
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();
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();
362 344
		return UUID_PREFIX + ID_TIME_FORMAT.format(new Date(System.currentTimeMillis())) + "_" + nextInt();
363 345
	}
364

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

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

  
363

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

  
373

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

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

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

  
414

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

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

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

  
......
458 436

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

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

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

  
462

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

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

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

  
......
509 486
			}
510 487

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

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

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

Formats disponibles : Unified diff