Revision 597

tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 597)
94 94
	 */
95 95
	protected HashMap<String, Object> lastParameters = new HashMap<String, Object>();
96 96

  
97
	
98
	
99
	
97

  
98

  
99

  
100 100
	/**
101 101
	 * Creates a new TXMResult, child of the specified parent.
102 102
	 * 
......
127 127
		// + this.preferencesNodeQualifier + ", class = " + getClass());
128 128

  
129 129
		this.dirty = true;
130
		
130

  
131 131
		// loads parameters from local result node, current command preferences or default command preferences
132 132
		try {
133 133
			this.loadGenericParameters();
......
154 154
		return this.children.size() > 0;
155 155
	}
156 156

  
157
	
157

  
158 158
	/**
159 159
	 * Returns all the member fields of the class instance.
160 160
	 * @return
......
169 169
		}
170 170

  
171 171
		return fields;
172
		
172

  
173 173
	}
174
	
174

  
175 175
	/**
176 176
	 * Stores the parameters of the specified type used for last computing.
177 177
	 * @throws Exception
178 178
	 */
179 179
	protected void updateLastParameters(int parameterType) throws Exception {
180
		
180

  
181 181
		List<Field> fields = this.getAllFields();
182
		
182

  
183 183
		for (Field f : fields) {
184 184
			Parameter parameter = f.getAnnotation(Parameter.class);
185 185
			if (parameter == null || parameter.type() != parameterType) {
186 186
				continue;
187 187
			}
188
			
188

  
189 189
			String name;
190 190
			if(!parameter.key().isEmpty())	{
191 191
				name = parameter.key();
......
193 193
			else	{
194 194
				name = f.getName();
195 195
			}
196
			
196

  
197 197
			f.setAccessible(true);
198 198
			this.lastParameters.put(name, f.get(this));
199 199
		}
200 200
	}
201 201

  
202
	
202

  
203 203
	/**
204 204
	 * Stores the last parameters used for computing.
205 205
	 * @throws Exception
......
207 207
	protected void updateLastParameters() throws Exception {
208 208
		this.updateLastParameters(Parameter.COMPUTING);
209 209
	}
210
	
210

  
211 211
	// FIXME: not used?
212 212
	public HashMap<String, Object> getLastParameters() {
213 213
		return lastParameters;
214 214
	}
215 215

  
216 216

  
217
	
217

  
218 218
	/**
219 219
	 * Gets a current parameter specified by its annotation "key" attribute and its annotation "type" attribute.
220 220
	 * @param key
......
224 224
	protected Object getParameter(String key) {
225 225

  
226 226
		List<Field> fields = this.getAllFields();
227
		
227

  
228 228
		for (Field f : fields) {
229 229
			Parameter parameter = f.getAnnotation(Parameter.class);
230 230
			if (parameter == null) {
......
243 243
		return null;
244 244
	}
245 245

  
246
	
246

  
247 247
	/**
248 248
	 * Checks if a parameter value has changed since last computing.
249 249
	 * @param key
......
269 269
		}
270 270
	}
271 271

  
272
	
273
//
274
//		
275
//		
276
//		
277
//		if (key.isEmpty()) {
278
//			return false;
279
//		}
280
//		Object lastValue = this.lastComputingParameters.get(key);
281
//		Object newValue = getParameter(key);
282
//		if (lastValue == null && newValue != null) {
283
//			return true;
284
//		}
285
//		else {
286
//			return !lastValue.equals(newValue);
287
//		}
288
//	}
289 272

  
290
	
273
	//
274
	//		
275
	//		
276
	//		
277
	//		if (key.isEmpty()) {
278
	//			return false;
279
	//		}
280
	//		Object lastValue = this.lastComputingParameters.get(key);
281
	//		Object newValue = getParameter(key);
282
	//		if (lastValue == null && newValue != null) {
283
	//			return true;
284
	//		}
285
	//		else {
286
	//			return !lastValue.equals(newValue);
287
	//		}
288
	//	}
289

  
290

  
291 291
	public String dumpPreferences()	{
292
		
292

  
293 293
		StringBuilder str = new StringBuilder();
294
		
294

  
295 295
		str.append("Command preferences\n");
296 296
		str.append(TXMPreferences.getKeysAndValues(TXMPreferences.scope, this.preferencesNodeQualifier));
297 297
		str.append("\nDefault preferences\n");
298 298
		str.append(TXMPreferences.getKeysAndValues(DefaultScope.INSTANCE, this.preferencesNodeQualifier));
299
		
299

  
300 300
		return str.toString();
301 301
	}
302
	
303
	
302

  
303

  
304 304
	public String dumpParameters()	{
305 305
		return this.dumpParameters(Parameter.COMPUTING);
306 306
	}
307
	
308
	
307

  
308

  
309 309
	public String dumpParameters(int parametersType)	{
310
		
310

  
311 311
		StringBuilder str = new StringBuilder();
312
		
312

  
313 313
		str.append("Parameters (type = " + parametersType + " / " + Parameter.types[parametersType] + ")\n");
314
		
314

  
315 315
		List<Field> fields = new ArrayList<Field>();
316 316
		Class<?> clazz = this.getClass();
317 317
		while (clazz != Object.class) {
......
325 325
				continue;
326 326
			}
327 327
			f.setAccessible(true);
328
			
328

  
329 329
			String name;
330 330
			if(!parameter.key().isEmpty())	{
331 331
				name = parameter.key();
......
348 348
		}
349 349
		return str.toString();
350 350
	}
351
	
352 351

  
352

  
353 353
	/**
354 354
	 * Updates the dirty state by comparing an old parameter with a new one.
355 355
	 * 
......
366 366
		}
367 367
	}
368 368

  
369
	
369

  
370 370
	/**
371 371
	 * Updates the dirty states by comparing TXMResult @Parameter with previously used parameters in the compute() method.
372 372
	 * 
......
389 389
			if (parameter == null || parameter.type() != Parameter.COMPUTING) {
390 390
				continue;
391 391
			}
392
			
392

  
393 393
			String name;
394 394
			if(!"".equals(parameter.key()))	{
395 395
				name = parameter.key();
......
397 397
			else	{
398 398
				name = f.getName();
399 399
			}
400
			
400

  
401 401
			f.setAccessible(true); // not to set accessible to test the field values
402 402
			Object previousValue = this.lastParameters.get(name);
403 403
			Object newValue = f.get(this);
404
			
404

  
405 405
			// FIXME: debug
406 406
			//System.err.println("TXMResult.isDirtyFromHistory(): checking parameter: " + name);
407
			
407

  
408 408
			this.updateDirty(previousValue, newValue);
409 409
			if (this.dirty) {
410 410
				return this.dirty; // no need to go further
......
449 449
		return TXMPreferences.getDefaultScopeKeys(this.preferencesNodeQualifier);
450 450
	}
451 451

  
452
	
452

  
453 453
	/**
454 454
	 * Gets the value of the specified key in parameters, local result node or
455 455
	 * default preferences nodes.
......
586 586
		return true;
587 587
	}
588 588

  
589
	
589

  
590 590
	/**
591 591
	 * 
592 592
	 * @return
......
595 595
	protected boolean loadGenericParameters() throws Exception {
596 596
		return this.loadGenericParameters(Parameter.COMPUTING);
597 597
	}
598
	
598

  
599 599
	/**
600 600
	 * Initialize the @Parameter class members objects using the default and persisted values in the Preference Store
601 601
	 * 
......
606 606
	 * @throws Exception 
607 607
	 */
608 608
	protected boolean loadGenericParameters(int parameterType) throws Exception {
609
		
610
//		// FIXME: debug
611
//		System.err.println("TXMResult.loadGenericParameters(): loading generic parameters into fields for " + this.getClass() + " and parameters type = " + parameterType);
612
		
609

  
610
		//		// FIXME: debug
611
		//		System.err.println("TXMResult.loadGenericParameters(): loading generic parameters into fields for " + this.getClass() + " and parameters type = " + parameterType);
612

  
613 613
		List<Field> fields = this.getAllFields();
614 614

  
615 615
		for (Field f : fields) {
616
		
616

  
617 617
			Parameter parameter = f.getAnnotation(Parameter.class);
618 618
			if (parameter == null || parameter.type() != parameterType) {
619 619
				continue;
620 620
			}
621 621
			String key = parameter.key();
622
			
622

  
623 623
			if (key.isEmpty()) {
624 624
				continue; // no preference key defined for the parameter so it can't be filled with default value or result persistence value from preferences nodes
625 625
			}
626 626
			try {
627 627
				f.setAccessible(true); // set accessible to test the field values
628
				
628

  
629 629
				// only manage simple persisted types
630 630
				if(f.getType().isAssignableFrom(String.class)) {
631 631
					String persistedValue = this.getStringParameterValue(key);
......
654 654
				// FIXME: doesn't work
655 655
				//else if (f.getClass().equals(Boolean.class)) {
656 656
				else if (f.getType().isAssignableFrom(boolean.class)) {
657
					
657

  
658 658
					Boolean persistedValue = this.getBooleanParameterValue(key);
659 659
					if (persistedValue != null) {
660 660
						f.set(this, persistedValue);
......
673 673
	 * @throws Exception
674 674
	 */
675 675
	public abstract boolean loadParameters() throws Exception;
676
	
676

  
677 677
	/**
678 678
	 * Initialize the @Parameter class members objects
679 679
	 * 
......
1041 1041
	// */
1042 1042
	// public abstract String getComputingMessage();
1043 1043

  
1044
	
1044

  
1045 1045
	/**
1046 1046
	 * Convenience method to get a shared name when the result is empty (not yet computed).
1047 1047
	 * @return the String "*"
......
1049 1049
	public String getEmptyName()	{
1050 1050
		return "*"; 
1051 1051
	}
1052
	
1052

  
1053 1053
	/**
1054 1054
	 * Returns a string representation of a unique ID of the result.
1055 1055
	 * 
......
1210 1210
		return this.compute(false, null);
1211 1211
	}
1212 1212

  
1213
	
1213

  
1214 1214
	/**
1215 1215
	 * 
1216 1216
	 * @param update
......
1221 1221
	public boolean compute(boolean update, IProgressMonitor monitor) throws Exception {
1222 1222
		return this.compute(update, monitor, true);
1223 1223
	}
1224
	
1224

  
1225 1225
	/**
1226 1226
	 * Computes the result if 
1227 1227
	 * it can be computed 
......
1273 1273
		// TODO where do we put this parent compute ? :o
1274 1274
		//		if (parent != null && !parent.getHasBeenComputedOnce()) { // parent must be computed at least one time
1275 1275
		// SJ: other way, test the object itself
1276
		// 		if (parent != null && !this.getHasBeenComputedOnce()) { 
1277
		//			this.parent.compute(update, monitor);
1278
		//		}
1276
		if (parent != null && !this.getHasBeenComputedOnce()) { 
1277
			this.parent.compute(update, monitor);
1278
		}
1279 1279

  
1280

  
1281 1280
		if (!this._compute(update)) {
1282 1281

  
1283 1282
			// FIXME: Debug
......
1365 1364
	// FIXME: should be moved in an exporter extension
1366 1365
	public abstract boolean toTxt(File outfile, String encoding, String colseparator, String txtseparator) throws Exception;
1367 1366

  
1368
	
1367

  
1369 1368
	public boolean getHasBeenComputedOnce() {
1370 1369
		return hasBeenComputedOnce;
1371 1370
	}
1372 1371

  
1373
	
1372

  
1374 1373
	/**
1375 1374
	 * increment the process
1376 1375
	 * 
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditorPart.java (revision 597)
35 35
 * @author sjacquot
36 36
 *
37 37
 */
38
public class ChartEditorPart extends TXMEditorPart {
38
public class ChartEditorPart<T extends ChartResult> extends TXMEditorPart<ChartResult>{
39 39

  
40 40
	/**
41 41
	 * The tool bar.
......
89 89
		super();
90 90
	}
91 91

  
92
	/**
93
	 * Returns the result object associated with the editor through its editor input.
94
	 * @return
95
	 */
96
	public T getResultData()	{
97
		return (T) this.getEditorInput().getResult();
98
	}
92 99
	
93 100

  
94 101
	/**
......
107 114
	 * 
108 115
	 * @param chartEditorInput
109 116
	 */
110
	public ChartEditorPart(ChartEditorInput chartEditorInput) {
117
	public ChartEditorPart(ChartEditorInput<ChartResult> chartEditorInput) {
111 118
		this(SWTChartsComponentsProvider.getCurrent(), chartEditorInput);
112 119
	}
113 120
	
......
363 370
	 * Convenience method the get the casted linked editor input.
364 371
	 * @return the editorInput
365 372
	 */
366
	public ChartEditorInput getEditorInput() {
373
	public ChartEditorInput<T> getEditorInput() {
367 374
		return (ChartEditorInput) super.getEditorInput();
368 375
	}
369 376

  
......
488 495
	public Object getChart()	{
489 496
		return this.getResultData().getChart();
490 497
	}
491

  
492
	@Override
493
	public ChartResult getResultData()	{
494
		return (ChartResult) this.getEditorInput().getResult();
495
	}
496

  
497 498
	
498 499
	/**
499 500
	 * Returns the chart components provider associated with the editor (through its <code>ChartEditorInput</code>).
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditorInput.java (revision 597)
15 15
 * @author sjacquot
16 16
 *
17 17
 */
18
public class ChartEditorInput extends TXMResultEditorInput {
18
public class ChartEditorInput<T extends ChartResult> extends TXMResultEditorInput<ChartResult> {
19 19

  
20 20

  
21 21
	@Deprecated
......
42 42
	 * @param result
43 43
	 * @param preferencesNodeQualifier
44 44
	 */
45
	public ChartEditorInput(TXMResult result) {
45
	public ChartEditorInput(ChartResult result) {
46 46
		this(SWTChartsComponentsProvider.getCurrent(), result);
47 47
	}
48 48
	
......
52 52
	 * @param result
53 53
	 * @param preferencesNodeQualifier
54 54
	 */
55
	public ChartEditorInput(SWTChartsComponentsProvider swtComponentsProvider, TXMResult result) {
55
	public ChartEditorInput(SWTChartsComponentsProvider swtComponentsProvider, ChartResult result) {
56 56
		this(swtComponentsProvider, result, null);
57 57
	}
58 58

  
......
65 65
	 * @param chartType
66 66
	 * @param chartContainer
67 67
	 */
68
	public ChartEditorInput(SWTChartsComponentsProvider swtComponentsProvider, TXMResult result, Object chartContainer) {
68
	public ChartEditorInput(SWTChartsComponentsProvider swtComponentsProvider, ChartResult result, Object chartContainer) {
69 69
		super(result);
70 70
		this.swtChartsComponentsProvider = swtComponentsProvider;
71 71
		this.chartContainer = chartContainer;
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/AdvancedChartEditorToolBar.java (revision 597)
17 17
import org.txm.chartsengine.core.ChartCreator;
18 18
import org.txm.chartsengine.core.ChartsEngine;
19 19
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences;
20
import org.txm.chartsengine.core.results.ChartResult;
20 21
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
21 22
import org.txm.chartsengine.rcp.messages.SWTComponentsProviderMessages;
22 23
import org.txm.core.preferences.TXMPreferences;
......
31 32
 */
32 33
public class AdvancedChartEditorToolBar extends ToolBar {
33 34

  
34
	private ChartEditorPart chartEditorPart;
35
	private ChartEditorPart<ChartResult> chartEditorPart;
35 36

  
36
	public ChartEditorPart getEditorPart() {
37
	public ChartEditorPart<ChartResult> getEditorPart() {
37 38
		return chartEditorPart;
38 39
	}
39 40
	
......
45 46
	 * @param parent
46 47
	 * @param style
47 48
	 */
48
	public AdvancedChartEditorToolBar(Composite parent, int style, final ChartEditorPart chartEditorPart) {
49
	public AdvancedChartEditorToolBar(Composite parent, int style, final ChartEditorPart chartEditorPart2) {
49 50
		super(parent, style); //$NON-NLS-1$
50 51
		
51
		this.chartEditorPart = chartEditorPart;
52
		this.chartEditorPart = chartEditorPart2;
52 53
		
53 54
		final ToolItem showTitle = new ToolItem(this, SWT.CHECK);
54 55
		//showTitle.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_TITLE);
......
56 57
		showTitle.setDisabledImage(IImageKeys.getImage(getClass(), "icons/show_title_disabled.png"));
57 58
		showTitle.setToolTipText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_TITLE);
58 59

  
59
		if(!chartEditorPart.getResultData().isEmptyPreference(ChartsEnginePreferences.SHOW_TITLE))	{
60
			showTitle.setSelection(chartEditorPart.getResultData().isTitleVisible());
60
		if(!chartEditorPart2.getResultData().isEmptyPreference(ChartsEnginePreferences.SHOW_TITLE))	{
61
			showTitle.setSelection(chartEditorPart2.getResultData().isTitleVisible());
61 62
		}
62 63
		// disable if not managed by the command
63 64
		else	{
......
71 72
		showLegend.setDisabledImage(IImageKeys.getImage(getClass(), "icons/show_legend_disabled.png"));
72 73
		showLegend.setToolTipText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_LEGEND);
73 74

  
74
		if(!chartEditorPart.getResultData().isEmptyPreference(ChartsEnginePreferences.SHOW_LEGEND))	{
75
			showLegend.setSelection(chartEditorPart.getResultData().isLegendVisible());
75
		if(!chartEditorPart2.getResultData().isEmptyPreference(ChartsEnginePreferences.SHOW_LEGEND))	{
76
			showLegend.setSelection(chartEditorPart2.getResultData().isLegendVisible());
76 77
		}
77 78
		// disable if not managed by the command
78 79
		else	{
......
86 87
		showGrid.setDisabledImage(IImageKeys.getImage(getClass(), "icons/show_grid_disabled.png"));
87 88
		showGrid.setToolTipText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_GRID);
88 89
		
89
		if(!chartEditorPart.getResultData().isEmptyPreference(ChartsEnginePreferences.SHOW_GRID))	{
90
			showGrid.setSelection(chartEditorPart.getResultData().isGridVisible());
90
		if(!chartEditorPart2.getResultData().isEmptyPreference(ChartsEnginePreferences.SHOW_GRID))	{
91
			showGrid.setSelection(chartEditorPart2.getResultData().isGridVisible());
91 92
		}
92 93
		// disable if not managed by the command
93 94
		else	{
......
111 112
		renderingModeCombo.pack();
112 113
		renderingComboItem.setWidth(renderingModeCombo.getBounds().width);
113 114
		
114
		if(!chartEditorPart.getResultData().isEmptyPreference(ChartsEnginePreferences.RENDERING_COLORS_MODE))	{
115
			renderingModeCombo.select(chartEditorPart.getResultData().getRenderingColorsMode());
115
		if(!chartEditorPart2.getResultData().isEmptyPreference(ChartsEnginePreferences.RENDERING_COLORS_MODE))	{
116
			renderingModeCombo.select(chartEditorPart2.getResultData().getRenderingColorsMode());
116 117
		}
117 118
		// disable if not managed
118 119
		else	{
......
121 122
		
122 123
		
123 124
		// Font selection
124
		final Font currentFont = ChartsEngine.createFont(chartEditorPart.getResultData().getFont());
125
		final Font currentFont = ChartsEngine.createFont(chartEditorPart2.getResultData().getFont());
125 126
		
126 127
		final Combo fontCombo = new Combo(this, SWT.READ_ONLY);
127 128
		String fonts[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
......
210 211
				boolean update = true;
211 212
				
212 213
				if(e.getSource() == showTitle)	{
213
					chartEditorPart.getResultData().setTitleVisible(showTitle.getSelection());
214
					chartEditorPart2.getResultData().setTitleVisible(showTitle.getSelection());
214 215
				}
215 216
				else if(e.getSource() == showLegend)	{
216
					chartEditorPart.getResultData().setLegendVisible(showLegend.getSelection());
217
					chartEditorPart2.getResultData().setLegendVisible(showLegend.getSelection());
217 218
				}
218 219
				else if(e.getSource() == showGrid)	{
219
					chartEditorPart.getResultData().setGridVisible(showGrid.getSelection());
220
					chartEditorPart2.getResultData().setGridVisible(showGrid.getSelection());
220 221
				}
221 222
				else if(e.getSource() == renderingModeCombo)	{
222
					chartEditorPart.getResultData().setRenderingColorsMode(renderingModeCombo.getSelectionIndex());
223
					chartEditorPart2.getResultData().setRenderingColorsMode(renderingModeCombo.getSelectionIndex());
223 224
				}
224 225
				else if(e.getSource() == fontCombo || e.getSource() == fontSizeCombo)	{
225
					chartEditorPart.getResultData().setFont("1|" + fontCombo.getItem(fontCombo.getSelectionIndex()) + "|" + fontSizeCombo.getItem(fontSizeCombo.getSelectionIndex()) + "|0");
226
					chartEditorPart2.getResultData().setFont("1|" + fontCombo.getItem(fontCombo.getSelectionIndex()) + "|" + fontSizeCombo.getItem(fontSizeCombo.getSelectionIndex()) + "|0");
226 227
				}
227 228
				else if(e.getSource() == chartTypeCombo)	{
228
					chartEditorPart.getResultData().setChartType(chartTypeCombo.getItem(chartTypeCombo.getSelectionIndex()));
229
					chartEditorPart2.getResultData().setChartType(chartTypeCombo.getItem(chartTypeCombo.getSelectionIndex()));
229 230
					update = false;
230 231
				}
231 232

  
232
				chartEditorPart.getResultData().setChartDirty();
233
				chartEditorPart2.getResultData().setChartDirty();
233 234
				
234 235
				// updates or creates chart
235
				chartEditorPart.compute(update);
236
				chartEditorPart2.compute(update);
236 237
			}
237 238
			
238 239
			@Override
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/ChartComposite.java (revision 597)
8 8
import org.eclipse.swt.widgets.Composite;
9 9
import org.eclipse.swt.widgets.Menu;
10 10
import org.eclipse.swt.widgets.MenuItem;
11
import org.txm.chartsengine.core.results.ChartResult;
11 12
import org.txm.chartsengine.rcp.IChartComponent;
12 13
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
13 14
import org.txm.chartsengine.rcp.events.EventCallBack;
......
43 44
	protected ArrayList<Menu> contextMenus;
44 45
	
45 46
	
46
	protected ChartEditorPart chartEditor;
47
	protected ChartEditorPart<ChartResult> chartEditor;
47 48
	
48 49
	/**
49 50
	 *
50 51
	 * @param parent
51 52
	 * @param style
52 53
	 */
53
	public ChartComposite(ChartEditorPart chartEditor, Composite parent, int style) {
54
	public ChartComposite(ChartEditorPart<ChartResult> chartEditor, Composite parent, int style) {
54 55
		super(parent, style);
55 56

  
56 57
		this.chartEditor = chartEditor;
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/handlers/ComputeAHC.java (revision 597)
127 127
					fMin = d.getFmin();
128 128
					vMax = d.getMaxLines();
129 129
					
130
//					LexicalTable lexicaltable = LexicalTableFactory.getLexicalTable(partition, property, fMin); // use the CAPreferencePage Fmin
131
					
132 130
					LexicalTable lexicaltable = new LexicalTable(partition, property, fMin, vMax); // use the CAPreferencePage Fmin
133
					
134
					
135
					lexicaltable.getData().cut(vMax);
136
					partition.addChild(lexicaltable);
137
					
138 131
					ahc = new AHC(new CA(lexicaltable));
139
					lexicaltable.addChild(ahc);
140 132
				} else {
141 133
					// canceled
142 134
					return null;
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/editors/AHCChartEditor.java (revision 597)
15 15
import org.txm.cah.core.messages.AHCCoreMessages;
16 16
import org.txm.cah.core.preferences.AHCPreferences;
17 17
import org.txm.cah.rcp.messages.AHCUIMessages;
18
import org.txm.chartsengine.core.results.ChartResult;
18 19
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
19 20
import org.txm.core.preferences.TXMPreferences;
20 21
import org.txm.rcp.IImageKeys;
......
31 32
 * @author sjacquot
32 33
 *
33 34
 */
34
public class AHCChartEditor extends ChartEditorPart {
35
public class AHCChartEditor extends ChartEditorPart<AHC> {
35 36

  
36 37
	/**
37 38
	 * Numbers of clusters.
......
232 233
		this.numbersOfClusters.setSelection(TXMPreferences.getInt(AHCPreferences.PREFERENCES_NODE, this.getResultData(), AHCPreferences.N_CLUSTERS));
233 234
	}
234 235

  
235
	@Override
236
	public AHC getResultData() {
237
		return (AHC) super.getResultData();
238
	}
239 236
}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMResultEditorInput.java (revision 597)
11 11
 * @author sjacquot
12 12
 *
13 13
 */
14
public class TXMResultEditorInput implements IEditorInput {
14
public class TXMResultEditorInput<T extends TXMResult> implements IEditorInput {
15 15

  
16 16
	/**
17 17
	 * 
......
21 21
	/**
22 22
	 * TXM result object.
23 23
	 */
24
	protected TXMResult result; 
24
	protected T result; 
25 25
	
26 26
	/**
27 27
	 * Creates an editor input and stores the specified TXM result as source object for further result computing.
28 28
	 * @param sourceResult
29 29
	 * @param preferencesNodeQualifier
30 30
	 */
31
	public TXMResultEditorInput(TXMResult result) {
31
	public TXMResultEditorInput(T result) {
32 32
		this.result = result;
33 33
		this.alwaysRecreateEditor = false;
34 34
	}
......
37 37
	 * Gets the TXM result associated with the editor input.
38 38
	 * @return the linked result
39 39
	 */
40
	public TXMResult getResult() {
40
	public T getResult() {
41 41
		return result;
42 42
	}
43 43

  
......
45 45
	 * Sets the result data associated with the editor input.
46 46
	 * @param resultData the resultData to set
47 47
	 */
48
	public void setResult(TXMResult resultData) {
48
	public void setResult(T resultData) {
49 49
		this.result = resultData;
50 50
	}
51 51
	
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorPart.java (revision 597)
15 15
import org.eclipse.swt.layout.GridLayout;
16 16
import org.eclipse.swt.layout.RowLayout;
17 17
import org.eclipse.swt.widgets.Composite;
18
import org.eclipse.swt.widgets.Display;
19 18
import org.eclipse.swt.widgets.Menu;
20 19
import org.eclipse.swt.widgets.Spinner;
21 20
import org.eclipse.swt.widgets.TableColumn;
22 21
import org.eclipse.ui.IEditorInput;
23
import org.eclipse.ui.IEditorPart;
24 22
import org.eclipse.ui.IEditorSite;
25 23
import org.eclipse.ui.IWorkbenchPage;
26 24
import org.eclipse.ui.IWorkbenchPartSite;
......
29 27
import org.eclipse.ui.PlatformUI;
30 28
import org.eclipse.ui.menus.IMenuService;
31 29
import org.eclipse.ui.part.EditorPart;
32
import org.txm.chartsengine.core.results.ChartResult;
33 30
import org.txm.core.results.TXMResult;
34 31
import org.txm.rcp.JobsTimer;
35 32
import org.txm.rcp.StatusLine;
36 33
import org.txm.rcp.TXMWindows;
37
import org.txm.rcp.commands.RestartTXM;
38 34
import org.txm.rcp.utils.JobHandler;
39 35
import org.txm.rcp.views.corpora.CorporaView;
40 36
import org.txm.utils.logger.Log;
......
48 44
 * @author sjacquot
49 45
 *
50 46
 */
51
public abstract class TXMEditorPart extends EditorPart {
47
public abstract class TXMEditorPart<T extends TXMResult> extends EditorPart {
52 48

  
53 49
	/**
54 50
	 * The editor main tool bar, positioned at the top of the editor.
......
236 232
	}
237 233
	
238 234
	@Override
239
	public TXMResultEditorInput getEditorInput() {
235
	public TXMResultEditorInput<T> getEditorInput() {
240 236
        return (TXMResultEditorInput) super.getEditorInput();
241 237
    }
242 238
	
......
244 240
	 * Returns the result object associated with the editor through its editor input.
245 241
	 * @return
246 242
	 */
247
	public TXMResult getResultData()	{
243
	public T getResultData()	{
248 244
		return this.getEditorInput().getResult();
249 245
	}
250 246

  
......
336 332
	public final void compute(boolean update) {
337 333
		compute(this.getEditorInput(), null, update, this);
338 334
	}
339
	
335
		
340 336
	/**
341 337
	 * Internal method to mutualize compute editor creation
342 338
	 * 
tmp/org.txm.index.rcp/src/org/txm/index/rcp/handlers/ComputeLexicon.java (revision 597)
10 10
import org.txm.index.rcp.editors.DictionnaryEditor;
11 11
import org.txm.lexicon.core.corpusengine.cqp.Lexicon;
12 12
import org.txm.rcp.TXMWindows;
13
import org.txm.rcp.editors.TXMEditorPart;
13 14
import org.txm.rcp.editors.TXMResultEditorInput;
14 15
import org.txm.rcp.handlers.BaseAbstractHandler;
15 16
import org.txm.rcp.views.corpora.CorporaView;
......
41 42
		
42 43
		Object selection = this.getSelection(event);
43 44
		
44
		TXMResultEditorInput editorInput;
45 45
		// New lexicon from corpus
46 46
		Index index = null;
47 47
		if (selection instanceof Corpus)	{
......
54 54
				// TODO Auto-generated catch block
55 55
				e.printStackTrace();
56 56
			}
57
			editorInput = new TXMResultEditorInput(index);
58 57
		} else if(selection instanceof Index) { // Reopens an existing lexicon
59 58
			index = (Index) selection;
60 59
			System.out.println("DEBUG: re-openning "+index);
......
62 61
			return null;
63 62
		}
64 63
		
65
		editorInput = new TXMResultEditorInput(index);
64
		open(index);
66 65
		
67
		try {
68
			IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage();
69
			page.openEditor(editorInput, DictionnaryEditor.class.getName()); //$NON-NLS-1$			
70
		} catch (Exception e) {
71
			org.txm.rcp.utils.Logger.printStackTrace(e);
72
		} 
73
		
74 66
		return null;
75 67
	}
68
	
69
	public static void open(Index lexicon) {
70
		TXMEditorPart.openEditor(lexicon, DictionnaryEditor.class.getName());
71
		
72
	}
76 73
}
tmp/org.txm.index.rcp/src/org/txm/index/rcp/handlers/ComputeIndex.java (revision 597)
34 34
import org.txm.index.rcp.editors.DictionnaryEditor;
35 35
import org.txm.index.rcp.editors.IndexEditor;
36 36
import org.txm.index.rcp.messages.IndexUIMessages;
37
import org.txm.rcp.editors.TXMEditorPart;
37 38
import org.txm.rcp.editors.TXMResultEditorInput;
38 39
import org.txm.rcp.handlers.BaseAbstractHandler;
39 40
import org.txm.rcp.StatusLine;
......
80 81
			return null;
81 82
		}
82 83
		
83
		editorInput = new TXMResultEditorInput(index);
84
		open(index);
84 85
		
85
		try {
86
			IWorkbenchPage page = TXMWindows.getActiveWindow().getActivePage();
87
			StatusLine.setMessage(IndexUIMessages.ComputeIndex_0);
88
			if (index.getLexiconMode()) {
89
				DictionnaryEditor editor = (DictionnaryEditor) page.openEditor(editorInput, DictionnaryEditor.class.getName()); //$NON-NLS-1$
90
			} else {
91
				IndexEditor editor = (IndexEditor) page.openEditor(editorInput, IndexEditor.class.getName()); //$NON-NLS-1$
92
			}
93
		} catch (Exception e) {
94
			org.txm.rcp.utils.Logger.printStackTrace(e);
95
		}
96 86
		return null;
97 87
	}
98 88

  
89
	public static void open(Index index) {
90
		TXMEditorPart.openEditor(index, IndexEditor.class.getName());
91
	}
99 92
}
tmp/org.txm.index.core/src/org/txm/index/core/functions/Index.java (revision 597)
321 321
	
322 322
	@Override
323 323
	public boolean loadParameters() {
324

  
325
//		this.pFmaxFilter = this.getIntParameterValue(IndexPreferences.FMAX_FILTER);
326
//		
327
//		this.pFminFilter = this.getIntParameterValue(IndexPreferences.FMIN_FILTER);
328
//		
329
//		this.pNLinesPerPage = this.getIntParameterValue(IndexPreferences.NLINESPERPAGE);
324 330
		
325
		this.pFmaxFilter = this.getIntParameterValue(IndexPreferences.FMAX_FILTER);
326
		
327
		this.pFminFilter = this.getIntParameterValue(IndexPreferences.FMIN_FILTER);
328
		
329
		this.pNLinesPerPage = this.getIntParameterValue(IndexPreferences.NLINESPERPAGE);
330
		
331 331
		String s = this.getStringParameterValue(IndexPreferences.PROPERTIES);
332 332
		this.pProperties = WordProperty.fromStringToList(getCorpus(), s);
333 333
		
334
		this.pPropertiesSeparator = this.getStringParameterValue(IndexPreferences.PROPERTIES_SEPARATOR);
334
//		this.pPropertiesSeparator = this.getStringParameterValue(IndexPreferences.PROPERTIES_SEPARATOR);
335 335
		
336 336
		this.pQuery = new Query(this.getStringParameterValue(IndexPreferences.QUERY));
337 337
		
338
		this.pTopIndex = this.getIntParameterValue(IndexPreferences.NTOPINDEX);
338
//		this.pTopIndex = this.getIntParameterValue(IndexPreferences.NTOPINDEX);
339
//		
340
//		this.pVmaxFilter = this.getIntParameterValue(IndexPreferences.VMAX_FILTER);
339 341
		
340
		this.pVmaxFilter = this.getIntParameterValue(IndexPreferences.VMAX_FILTER);
341
		
342 342
		return true;
343 343
	}
344 344
	

Also available in: Unified diff