Revision 626

tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/CAFactorialMapChartEditor.java (revision 626)
175 175
						((ToolItem) e.getSource()).setSelection(true);
176 176
						return;
177 177
					}
178
					getResultData().setShowIndividuals(((ToolItem) e.getSource()).getSelection());
178
					getResult().setShowIndividuals(((ToolItem) e.getSource()).getSelection());
179 179
				}
180 180
				//Show/hide rows
181 181
				else if(e.getSource() == showVariables)	{
......
186 186
						return;
187 187
					}
188 188

  
189
					getResultData().setShowVariables(((ToolItem) e.getSource()).getSelection());
189
					getResult().setShowVariables(((ToolItem) e.getSource()).getSelection());
190 190
				}
191 191
				//Show/hide rows
192 192
				else if(e.getSource() == showPointShapes)	{
193
					getResultData().setShowPointShapes(((ToolItem) e.getSource()).getSelection());
193
					getResult().setShowPointShapes(((ToolItem) e.getSource()).getSelection());
194 194
				}
195 195
				// Change factors
196 196
				else if(e.getSource() == plansCombo)	{
......
212 212
					dimension2 = Integer.parseInt(split[1]);
213 213

  
214 214
					// FIXME: persistence
215
					getResultData().setFirstDimension(dimension1);
216
					getResultData().setSecondDimension(dimension2);
215
					getResult().setFirstDimension(dimension1);
216
					getResult().setSecondDimension(dimension2);
217 217

  
218 218
					resetView = true;
219 219
				}
220
				getResultData().setChartDirty();
221
				getResultData().setNeedsToResetView(resetView);
220
				getResult().setChartDirty();
221
				getResult().setNeedsToResetView(resetView);
222 222
				compute(true);
223 223
				// synchronize the part names
224
				((CAEditor)getParentMultiPagesEditor()).setName(getResultData().getName());
224
				((CAEditor)getParentMultiPagesEditor()).setName(getResult().getName());
225 225
				forceFocus();
226 226
			}
227 227
			
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/handlers/ComputeCA.java (revision 626)
38 38
import org.txm.ca.core.functions.CA;
39 39
import org.txm.ca.rcp.editors.CAEditor;
40 40
import org.txm.ca.rcp.messages.CAUIMessages;
41
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
42
import org.txm.core.results.TXMResult;
43 41
import org.txm.lexicaltable.core.functions.LexicalTable;
44
import org.txm.lexicaltable.core.functions.___LexicalTableFactory;
45 42
import org.txm.lexicaltable.rcp.editors.LexicalTableDialog;
46 43
import org.txm.rcp.RCPMessages;
47 44
import org.txm.rcp.StatusLine;
......
112 109

  
113 110
					Log.info(NLS.bind(CAUIMessages.ComputeCorrespondanceAnalysis_0, partition, property));
114 111

  
115
					//LexicalTable lexicalTable = LexicalTableFactory.getLexicalTable(partition, property, fMin);
116 112
					LexicalTable lexicalTable = new LexicalTable(partition, property, fMin, vMax);
117 113
					ca = new CA(lexicalTable);
118 114
				}
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/messages/CAUIMessages.java (revision 626)
5 5

  
6 6
public class CAUIMessages extends Utf8NLS {
7 7
	
8
	
9
	private static final String BUNDLE_NAME = "org.txm.ca.rcp.messages.messages"; //$NON-NLS-1$
10
	
8 11
	static {
9 12
		Utf8NLS.initializeMessages(CAUIMessages.class);
10 13
	}
tmp/org.txm.chartsengine.svgbatik.rcp/src/org/txm/chartsengine/svgbatik/rcp/swt/SVGComposite.java (revision 626)
126 126
	
127 127
	@Override
128 128
	public void loadChart()	{
129
		if(!this.chartEditor.getResultData().isChartDirty())	{
129
		if(!this.chartEditor.getResult().isChartDirty())	{
130 130
			// creates components if they not exist
131 131
			if(this.chartComponent == null)	{
132 132
				
......
141 141
			Object chart = this.chartEditor.getEditorInput().getChart();
142 142
			// recreates the chart if not of right type
143 143
			if(!(chart instanceof File))	{
144
				this.file = this.chartEditor.getSWTChartsComponentsProvider().getChartsEngine().getChartCreator(this.chartEditor.getResultData()).createChartFile(this.chartEditor.getResultData());
144
				this.file = this.chartEditor.getSWTChartsComponentsProvider().getChartsEngine().getChartCreator(this.chartEditor.getResult()).createChartFile(this.chartEditor.getResult());
145 145
			}
146 146
			else	{
147 147
				this.file = (File) chart;	
tmp/org.txm.textsbalance.feature/feature.xml (revision 626)
65 65
   </license>
66 66

  
67 67
   <requires>
68
      <import plugin="org.txm.searchengine.cqp.core" version="1.1.0" match="greaterOrEqual"/>
69
      <import plugin="org.txm.searchengine.core" version="1.0.0" match="greaterOrEqual"/>
68 70
      <import plugin="org.txm.rcp" version="0.7.7" match="greaterOrEqual"/>
69 71
      <import plugin="org.eclipse.core.runtime" version="3.10.0" match="greaterOrEqual"/>
70 72
      <import plugin="org.eclipse.ui" version="3.106.1" match="greaterOrEqual"/>
71 73
      <import plugin="org.eclipse.jface.text"/>
72 74
      <import plugin="org.eclipse.ui.editors"/>
73
      <import plugin="org.eclipse.core.expressions" version="3.4.600" match="greaterOrEqual"/>
74 75
      <import plugin="org.txm.core" version="0.7.0" match="greaterOrEqual"/>
75 76
      <import plugin="org.txm.chartsengine.r.core"/>
77
      <import plugin="org.eclipse.core.expressions" version="3.4.600" match="greaterOrEqual"/>
76 78
      <import plugin="org.txm.textsbalance.core" version="1.0.0" match="greaterOrEqual"/>
77 79
      <import plugin="org.txm.chartsengine.jfreechart.core" version="1.0.0" match="greaterOrEqual"/>
78 80
      <import plugin="org.txm.chartsengine.rcp" version="1.0.0" match="greaterOrEqual"/>
tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java (revision 626)
919 919
		
920 920
		IEclipsePreferences preferences = scope.getNode(nodeQualifier);
921 921
		
922
		str.append("Path = " +  preferences .absolutePath() + "\n");
922
		str.append("Path = " +  preferences.absolutePath() + "\n");
923 923
		
924 924
		try {
925 925
			String[] keys = preferences.keys();
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 626)
145 145
	 * Creates and stores an UUID dedicated to persistence of this result.
146 146
	 */
147 147
	protected void createUUID() {
148
		this.uniqueID = this.getClass().getName() + '@' + ID_TIME_FORMAT.format(new Date(System.currentTimeMillis())) + "_" + UUID.randomUUID();
148
		// FIXME: see if it's useful to put the class name or not
149
		//this.uniqueID = this.getClass().getName() + '@' + ID_TIME_FORMAT.format(new Date(System.currentTimeMillis())) + "_" + UUID.randomUUID();
150
		this.uniqueID = ID_TIME_FORMAT.format(new Date(System.currentTimeMillis())) + "_" + UUID.randomUUID();
149 151
	}
150 152

  
151 153
	/**
......
239 241
		
240 242
	}
241 243

  
242
	// FIXME: not used?
244

  
243 245
	public HashMap<String, Object> getLastParameters() {
244 246
		return lastParameters;
245 247
	}
......
281 283
	 * @return
282 284
	 */
283 285
	public boolean hasParameterChanged(String key) {
286
		return this.hasParameterChanged(key, this.lastParameters);
287
	}
288

  
289
	/**
290
	 * Checks if a parameter value has changed since last computing according to the specified external map.
291
	 * @param key
292
	 * @param lastParameters
293
	 * @return
294
	 */
295
	public boolean hasParameterChanged(String key, HashMap<String, Object> lastParameters) {
284 296
		if (key.isEmpty()) {
285 297
			return false;
286 298
		}
287
		Object lastValue = this.lastParameters.get(key);
299
		Object lastValue = lastParameters.get(key);
288 300
		Object newValue = this.getParameter(key);
289 301
		if (lastValue == null) {
290 302
			if(newValue != null)	{
......
298 310
			return !lastValue.equals(newValue);
299 311
		}
300 312
	}
313
	
314
	
301 315

  
302

  
303 316
	/**
304 317
	 * Dumps the command and default preferences of the result preferences node qualifier.
305 318
	 * @return
......
308 321

  
309 322
		StringBuilder str = new StringBuilder();
310 323

  
311
		str.append("Default command preferences\n"); //$NON-NLS-1$
312
		str.append(TXMPreferences.getKeysAndValues(DefaultScope.INSTANCE, this.preferencesNodeQualifier));
324
		if(TXMPreferences.resultScopeNodeExists(this))	{
325
			str.append("\nResult local node preferences\n"); //$NON-NLS-1$
326
			str.append(TXMPreferences.getKeysAndValues(TXMPreferences.scope, this.getUUID()));
327
		}
313 328

  
314 329
		str.append("\nCommand preferences\n"); //$NON-NLS-1$
315 330
		str.append(TXMPreferences.getKeysAndValues(TXMPreferences.scope, this.preferencesNodeQualifier));
331
		
332
		str.append("\nDefault command preferences\n"); //$NON-NLS-1$
333
		str.append(TXMPreferences.getKeysAndValues(DefaultScope.INSTANCE, this.preferencesNodeQualifier));
316 334

  
335

  
336
		
317 337
		return str.toString();
318 338
	}
319 339
	
......
370 390
		return str.toString();
371 391
	}
372 392
	
373
	
374
	/**
375
	 * Dumps the result computing parameters (Parameter annotation).
376
	 * @return
377
	 */
378
	public String htmlDumpParameters()	{
379
		return this.htmlDumpParameters(null, true);
380
	}
381 393

  
382
	/**
383
	 * Dumps the result parameters (Parameter annotation) of the specified type.
384
	 * @param parametersType
385
	 * @return
386
	 */
387
	public String htmlDumpParameters(Integer parametersType, boolean html)	{
388 394

  
389
		StringBuilder str = new StringBuilder();
390
		if (html) str.append("<h4>");
391
		str.append("Current parameters");
392
		if (parametersType != null) {
393
			str.append(" (type = " + parametersType + " / " + Parameter.types[parametersType] + ")\n"); //$NON-NLS-1$
394
		}
395
		if (html) str.append("</h4>");
396
		
397
		List<Field> fields = new ArrayList<Field>();
398
		Class<?> clazz = this.getClass();
399
		while (clazz != Object.class) {
400
			fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
401
			clazz = clazz.getSuperclass();
402
		}
403

  
404
		if (html) str.append("<ul>");
405
		for (Field f : fields) {
406
			Parameter parameter = f.getAnnotation(Parameter.class);
407
			if (parameter == null) {
408
				continue;
409
			}
410
			if (parametersType != null && parameter.type() != parametersType) {
411
				continue;
412
			}
413
			f.setAccessible(true);
414

  
415
			String key = parameter.key();
416
			if (key == null) continue;
417
			
418
			String name;
419
			if(!key.isEmpty())	{
420
				name = parameter.key();
421
			}
422
			else	{
423
				name = f.getName();
424
			}
425
			int type = parameter.type();
426
			try {
427
				if (html) str.append("<li>");
428
				str.append(name + "("+Parameter.types[type]+") = " + f.get(this) + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
429
				if (html) str.append("</li>");
430
			}
431
			catch (Exception e) {
432
				// TODO Auto-generated catch block
433
				e.printStackTrace();
434
			}
435
		}
436
		if (html) str.append("</ul>");
437
		return str.toString();
438
	}
439

  
440 395
	/**
441
	 * Dumps the command and default preferences of the result preferences node qualifier.
442
	 * @return
443
	 */
444
	public String htmlDumpPreferences()	{
445

  
446
		StringBuilder str = new StringBuilder();
447

  
448
		str.append("<h4>"+this.getClass().getSimpleName()+" command preferences</h4>\n"); //$NON-NLS-1$
449
		str.append("<ul>\n"); //$NON-NLS-1$
450
		HashMap<String, Object> map = TXMPreferences.getKeysAndValuesAsMap(TXMPreferences.scope, this.preferencesNodeQualifier);
451
		for (String k : map.keySet()) {
452
			str.append("<li>"+k+" = "+map.get(k)+"</li>\n");
453
		}
454
		str.append("</ul>\n"); //$NON-NLS-1$
455
		
456
		str.append("\n<h4>"+this.getClass().getSimpleName()+" command default preferences</h4>\n"); //$NON-NLS-1$
457
		str.append("<ul>\n"); //$NON-NLS-1$
458
		map = TXMPreferences.getKeysAndValuesAsMap(DefaultScope.INSTANCE, this.preferencesNodeQualifier);
459
		for (String k : map.keySet()) {
460
			str.append("<li>"+k+" = "+map.get(k)+"</li>\n");
461
		}
462
		str.append("</ul>\n"); //$NON-NLS-1$
463
		
464
		return str.toString();
465
	}
466
	
467
	public String htmlDumpLastParameters() {
468
		StringBuilder builder = new StringBuilder();
469
		builder.append("<h4>Last compute parameters</h4>");
470
		
471
		if (lastParameters.keySet().size() == 0) {
472
			builder.append("<p>not computed yet.</p>");
473
		} else {
474
			builder.append("<ul>\n");
475
			for (String k : lastParameters.keySet()) {
476
				builder.append("<li>"+k+" = "+lastParameters.get(k)+"</li>\n");
477
			}
478
			builder.append("<ul>\n");
479
		}
480
		
481
		
482
		
483
		return builder.toString();
484
	}
485

  
486

  
487

  
488

  
489
	/**
490 396
	 * Updates the dirty state by comparing an old parameter with a new one.
491 397
	 * 
492 398
	 * @param lastValue may be null
......
671 577
	 * @param value
672 578
	 */
673 579
	public void saveParameter(String key, Object value)	{
674
		TXMPreferences.putLocal(this, key, value);;
580
		// FIXME: debug
581
		System.err.println("TXMResult.saveParameter(): saving parameter " + key + " = " + value + " for " + this.getClass() + " (" + value.getClass() + ") to node.");
582

  
583
		TXMPreferences.putLocal(this, key, value);
675 584
	}
676 585

  
677 586

  
......
695 604
				continue; // no preference key defined
696 605
			}
697 606

  
698
			// FIXME: these tests doesn't seem sufficient, need to add real primitive types? and maybe use isAssignable() rather than equals()? need to test and validate that
699
			// only manage simple types
700
			if (f.getClass().equals(Integer.class) || 
701
					f.getClass().equals(String.class) ||
702
					f.getClass().equals(Double.class) ||
703
					f.getClass().equals(Float.class) ||
704
					f.getClass().equals(Boolean.class)) {
607
			if (f.getType().isAssignableFrom(int.class) || f.getType().isAssignableFrom(Integer.class) ||
608
					f.getType().isAssignableFrom(double.class) || f.getType().isAssignableFrom(Double.class) ||
609
					f.getType().isAssignableFrom(float.class) || f.getType().isAssignableFrom(Float.class) ||
610
					f.getType().isAssignableFrom(boolean.class) || f.getType().isAssignableFrom(Boolean.class) ||
611
					f.getType().isAssignableFrom(String.class)) {
705 612
				f.setAccessible(true); // set accessible to test the field values
706 613
				try {
707 614
					Object newValue = f.get(this);
......
850 757
			targetField.setAccessible(true);
851 758
			
852 759
			// FIXME: debug
853
			System.err.println("TXMResult.setParameter(); setting parameter " + key + " = " + value + " for " + this.getClass());
760
			System.err.println("TXMResult.setParameter(): setting parameter " + key + " = " + value + " for " + this.getClass() + " (" + value.getClass() + ")");
854 761
			
855 762
			targetField.set(this, value);
856 763
		}
tmp/org.txm.wordcloud.feature/feature.xml (revision 626)
73 73
      <import plugin="org.txm.rcp" version="0.7.5" match="greaterOrEqual"/>
74 74
      <import plugin="org.eclipse.core.expressions" version="3.4.500" match="greaterOrEqual"/>
75 75
      <import plugin="org.txm.wordcloud.rcp"/>
76
      <import plugin="org.txm.wordcloud.tbx"/>
76
      <import plugin="org.txm.wordcloud.core"/>
77 77
   </requires>
78 78

  
79 79
   <plugin
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/SWTChartsComponentsProvider.java (revision 626)
1 1
package org.txm.chartsengine.rcp;
2 2

  
3

  
3 4
import java.awt.event.MouseEvent;
4 5
import java.awt.event.MouseListener;
5 6
import java.awt.event.MouseMotionListener;
......
54 55
import org.txm.utils.logger.Log;
55 56

  
56 57
/**
57
 * A class providing EditorPart and EditorInput according to the current charts
58
 * engine.
59
 * 
58
 * A class providing EditorPart and EditorInput according to the current charts engine.
60 59
 * @author sjacquot
61 60
 * 
62 61
 */
63 62
public abstract class SWTChartsComponentsProvider {
64 63

  
64
	
65
	
66
	
67
	
65 68
	// FIXME: should be done in an activator?
66
	static {
67
		// Initializes the SWT Charts Components provider according to the
68
		// current charts engine and its output format
69
	static	{	
70
		// Initializes the SWT Charts Components provider according to the current charts engine and its output format
69 71
		SWTChartsComponentsProvider.createSWTChartsComponentsProviders();
70 72
		SWTChartsComponentsProvider.setCurrrentComponentsProvider(ChartsEngine.getCurrent());
71 73
	}
72

  
74
	
75
	
76
	
77
	
78
	
73 79
	/**
74 80
	 * The charts engine.
75 81
	 */
76 82
	protected ChartsEngine chartsEngine;
77 83

  
84

  
78 85
	/**
79 86
	 * The name of the provider.
80 87
	 */
81 88
	protected String name;
82

  
89
	
83 90
	/**
84 91
	 * The supported editor input formats.
85 92
	 */
86 93
	protected List<String> supportedInputFormats;
87

  
94
	
95
	
88 96
	/**
89
	 * Mouse control properties which will be shared by all implementations and
90
	 * chart editors.
97
	 * Mouse control properties which will be shared by all implementations and chart editors.
91 98
	 */
92 99
	protected Properties mouseBindingProperties;
93 100

  
101

  
94 102
	/**
95
	 * Keyboard control properties which will be shared by all implementations
96
	 * and chart editors.
103
	 * Keyboard control properties which will be shared by all implementations and chart editors.
97 104
	 */
98 105
	protected Properties keyboardBindingProperties;
99 106

  
107
	
100 108
	/**
101 109
	 * Installed SWT charts components providers.
102 110
	 */
103 111
	protected static ArrayList<SWTChartsComponentsProvider> chartsComponentsProviders;
104

  
112
	
105 113
	/**
106 114
	 * Current SWT charts components provider index in the providers list.
107 115
	 */
108 116
	protected static int currentChartsComponentsProviderIndex;
109

  
117
	
118
	
119
	
110 120
	public SWTChartsComponentsProvider(ChartsEngine chartsEngine, Properties mouseBindingProperties, Properties keyboardBindingProperties) {
111 121
		this.chartsEngine = chartsEngine;
112 122

  
113 123
		this.mouseBindingProperties = mouseBindingProperties;
114 124
		this.keyboardBindingProperties = keyboardBindingProperties;
115 125

  
116
		// FIXME : see if we need to define the L&F as system for AWT/Swing
117
		// components
118
		// If yes, we need to find a way to manage the GTK L&F/Linux bug, see
119
		// ticket #761
120
		// System Look and feel
121
		// try {
122
		// UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
123
		// }
124
		// catch(ClassNotFoundException e) {
125
		// // TODO Auto-generated catch block
126
		// e.printStackTrace();
127
		// }
128
		// catch(InstantiationException e) {
129
		// // TODO Auto-generated catch block
130
		// e.printStackTrace();
131
		// }
132
		// catch(IllegalAccessException e) {
133
		// // TODO Auto-generated catch block
134
		// e.printStackTrace();
135
		// }
136
		// catch(UnsupportedLookAndFeelException e) {
137
		// // TODO Auto-generated catch block
138
		// e.printStackTrace();
139
		// }
126
		// FIXME : see if we need to define the L&F as system for AWT/Swing components
127
		// If yes, we need to find a way to manage the GTK L&F/Linux bug, see ticket #761
128
        // System Look and feel
129
//        try {
130
//			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
131
//		}
132
//		catch(ClassNotFoundException e) {
133
//			// TODO Auto-generated catch block
134
//			e.printStackTrace();
135
//		}
136
//		catch(InstantiationException e) {
137
//			// TODO Auto-generated catch block
138
//			e.printStackTrace();
139
//		}
140
//		catch(IllegalAccessException e) {
141
//			// TODO Auto-generated catch block
142
//			e.printStackTrace();
143
//		}
144
//		catch(UnsupportedLookAndFeelException e) {
145
//			// TODO Auto-generated catch block
146
//			e.printStackTrace();
147
//		}
140 148
	}
141 149

  
142 150
	/**
......
147 155
		this(chartsEngine, new ___MouseBindingProperties(), new ___KeyboardBindingProperties());
148 156
	}
149 157

  
158
	
150 159
	/**
151 160
	 * 
152 161
	 */
......
154 163
		this(null);
155 164
	}
156 165

  
166
	
157 167
	/**
158 168
	 * Creates a <code>ChartEditorInput</code> for the specified chart result.
159
	 * 
160 169
	 * @param result
161 170
	 * @return a <code>ChartEditorInput</code>
162 171
	 */
163 172
	public ChartEditorInput createChartEditorInput(ChartResult result) {
164 173
		return new ChartEditorInput(this, result);
165 174
	}
166

  
175
	
167 176
	/**
168
	 * Creates a new chart container for the specified <code>ChartResult</code>
169
	 * save it in the specified <code>ChartEditorInput</code>.
177
	 * Creates a new chart container for the specified <code>ChartResult</code> save it in the specified <code>ChartEditorInput</code>.
170 178
	 * 
171 179
	 * @param chartsEngine
172 180
	 * @param chartEditorInput
......
176 184
	 * @return
177 185
	 */
178 186
	protected abstract boolean createChartContainer(ChartsEngine chartsEngine, ChartEditorInput chartEditorInput);
179

  
187
	
180 188
	/**
181
	 * Creates a new chart container for the specified <code>ChartResult</code>
182
	 * save it in the specified <code>ChartEditorInput</code>.
189
	 * Creates a new chart container for the specified <code>ChartResult</code> save it in the specified <code>ChartEditorInput</code>.
183 190
	 * 
184 191
	 * @param chartEditorInput
185 192
	 * @param result
......
187 194
	 * @param chartType
188 195
	 * @return
189 196
	 */
190
	public boolean createChartContainer(ChartEditorInput chartEditorInput) {
197
	public boolean createChartContainer(ChartEditorInput chartEditorInput)	{
191 198
		return this.createChartContainer(this.getChartsEngine(), chartEditorInput);
192 199
	}
193

  
200
	
201
	
194 202
	/**
195
	 * Creates and stores SWT charts components providers from installed
196
	 * extension contributions and define the current one according to the
197
	 * specified charts engine output format and provider supported input
198
	 * format.
203
	 * Creates and stores SWT charts components providers from installed extension contributions and define the current one according to the specified charts engine output format and provider supported input format.
199 204
	 */
200
	public static void createSWTChartsComponentsProviders() {
201

  
205
	public static void createSWTChartsComponentsProviders()	{
206
		
207
		
202 208
		SWTChartsComponentsProvider.chartsComponentsProviders = new ArrayList<SWTChartsComponentsProvider>();
203

  
209
		
204 210
		String extensionPointId = "org.txm.rcp.swtchartscomponentsprovider"; //$NON-NLS-1$
205 211
		IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointId);
206

  
207
		for (int i = 0; i < contributions.length; i++) {
208

  
209
			// FIXME: to manage more than one input format, Store them in the
210
			// class rather than in the extension schema?
212
		
213
		for(int i = 0; i < contributions.length; i++) {
214
			
215
			// FIXME: to manage more than one input format, Store them in the class rather than in the extension schema?
211 216
			String formatsStr = contributions[i].getAttribute("inputFormat").replace(" ", "").trim();
212 217
			String[] formats = formatsStr.split(",");
213

  
218
			
214 219
			try {
215
				SWTChartsComponentsProvider swtChartsComponentsProvider = (SWTChartsComponentsProvider) contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
220
				SWTChartsComponentsProvider swtChartsComponentsProvider = (SWTChartsComponentsProvider)contributions[i].createExecutableExtension("class");  //$NON-NLS-1$
216 221
				swtChartsComponentsProvider.setName(contributions[i].getAttribute("name")); //$NON-NLS-1$
217 222
				swtChartsComponentsProvider.setEditorSupportedInputFormat(Arrays.asList(formats));
218

  
223
				
219 224
				// Add the first charts engine that supports the input format
220 225
				ChartsEngine chartsEngine = null;
221
				for (int j = 0; j < formats.length; j++) {
226
				for(int j = 0; j < formats.length; j++) {
222 227
					chartsEngine = ChartsEngine.getChartsEngine(formats[j]);
223
					if (chartsEngine != null) {
228
					if(chartsEngine != null)	{
224 229
						break;
225 230
					}
226 231
				}
227
				swtChartsComponentsProvider.setChartsEngine(chartsEngine);
228

  
232
				swtChartsComponentsProvider.setChartsEngine(chartsEngine);					
233
				
229 234
				SWTChartsComponentsProvider.chartsComponentsProviders.add(swtChartsComponentsProvider);
230 235
				Log.warning("Starting SWT charts components provider: " + swtChartsComponentsProvider);
231

  
232
			} catch (CoreException e) {
236
				
237
				
238
			}
239
			catch(CoreException e) {
233 240
				// TODO Auto-generated catch block
234 241
				e.printStackTrace();
235 242
			}
236 243
		}
237 244
	}
238

  
245
	
246
	
239 247
	/**
240 248
	 * Gets the current charts component provider.
241
	 * 
242 249
	 * @return the current charts engine
243 250
	 */
244
	public static SWTChartsComponentsProvider getCurrent() {
251
	public static SWTChartsComponentsProvider getCurrent()	{
245 252
		return SWTChartsComponentsProvider.chartsComponentsProviders.get(SWTChartsComponentsProvider.currentChartsComponentsProviderIndex);
246 253
	}
247

  
254
	
248 255
	/**
249
	 * Sets the current charts component provider according to the specified
250
	 * charts engine output format and provider supported input format.
251
	 * 
252
	 * @param name
253
	 *            the name of the charts engine to set as current
256
	 * Sets the current charts component provider according to the specified charts engine output format and provider supported input format. 
257
	 * @param name the name of the charts engine to set as current
254 258
	 */
255
	public static void setCurrrentComponentsProvider(ChartsEngine chartsEngine) {
256
		for (int i = 0; i < SWTChartsComponentsProvider.chartsComponentsProviders.size(); i++) {
257
			if (SWTChartsComponentsProvider.chartsComponentsProviders.get(i).getEditorSupportedInputFormats().contains(chartsEngine.getOutputFormat())) {
259
	public static void setCurrrentComponentsProvider(ChartsEngine chartsEngine)	{
260
		for(int i = 0; i < SWTChartsComponentsProvider.chartsComponentsProviders.size(); i++) {
261
			if(SWTChartsComponentsProvider.chartsComponentsProviders.get(i).getEditorSupportedInputFormats().contains(chartsEngine.getOutputFormat()))	{
258 262
				// Set new charts engine
259 263
				SWTChartsComponentsProvider.chartsComponentsProviders.get(i).setChartsEngine(chartsEngine);
260

  
264
				
261 265
				SWTChartsComponentsProvider.currentChartsComponentsProviderIndex = i;
262 266
				Log.warning("Set current SWT charts components provider to: " + SWTChartsComponentsProvider.getCurrent());
263 267
				break;
264 268
			}
265 269
		}
266 270
	}
267

  
271
	
272
	
268 273
	/**
269
	 * Gets an SWT charts component provider according to the specified charts
270
	 * engine output format and provider supported input format.
271
	 * 
274
	 * Gets an SWT charts component provider according to the specified charts engine output format and provider supported input format. 
272 275
	 * @param chartsEngine
273 276
	 * @return
274 277
	 */
275
	public static SWTChartsComponentsProvider getComponentsProvider(ChartsEngine chartsEngine) {
276

  
278
	public static SWTChartsComponentsProvider getComponentsProvider(ChartsEngine chartsEngine)	{
279
		
277 280
		SWTChartsComponentsProvider chartsComponentsProvider = null;
281
		
282
		for(int i = 0; i < SWTChartsComponentsProvider.chartsComponentsProviders.size(); i++) {
283
			if(SWTChartsComponentsProvider.chartsComponentsProviders.get(i).getEditorSupportedInputFormats().contains(chartsEngine.getOutputFormat()))	{
278 284

  
279
		for (int i = 0; i < SWTChartsComponentsProvider.chartsComponentsProviders.size(); i++) {
280
			if (SWTChartsComponentsProvider.chartsComponentsProviders.get(i).getEditorSupportedInputFormats().contains(chartsEngine.getOutputFormat())) {
281

  
282 285
				chartsComponentsProvider = SWTChartsComponentsProvider.chartsComponentsProviders.get(i);
283 286
				break;
284 287
			}
285 288
		}
286

  
289
		
287 290
		return chartsComponentsProvider;
288 291
	}
289

  
292
	
293
	
290 294
	/**
291 295
	 * Gets an installed charts components provider according to its class type.
292
	 * 
293 296
	 * @param type
294
	 * @return the installed charts components provider according to its class
295
	 *         type if it exists otherwise null;
297
	 * @return the installed charts components provider according to its class type if it exists otherwise null;
296 298
	 */
297
	public static SWTChartsComponentsProvider getComponentsProvider(Class type) {
299
	public static SWTChartsComponentsProvider getComponentsProvider(Class type)	{
298 300
		SWTChartsComponentsProvider provider = null;
299
		for (int i = 0; i < SWTChartsComponentsProvider.chartsComponentsProviders.size(); i++) {
300
			if (SWTChartsComponentsProvider.chartsComponentsProviders.get(i).getClass().equals(type)) {
301
		for(int i = 0; i < SWTChartsComponentsProvider.chartsComponentsProviders.size(); i++) {
302
			if(SWTChartsComponentsProvider.chartsComponentsProviders.get(i).getClass().equals(type))	{
301 303
				provider = SWTChartsComponentsProvider.chartsComponentsProviders.get(i);
302 304
				break;
303 305
			}
304 306
		}
305 307
		return provider;
306 308
	}
309
	
307 310

  
308
	// /**
309
	// * Creates and return a SWT EditorPart for the specified CA result.
310
	// * @param ca
311
	// * @return a SWT EditorPart
312
	// */
313
	// public abstract ChartEditorPart createCAFactorialMapChartEditorPart(CA
314
	// ca);
315
	//
316
	//
317
	// /**
318
	// * Creates and return a SWT EditorPart for the singular values of the
319
	// specified CA result.
320
	// * @param ca
321
	// * @return a SWT EditorPart
322
	// */
323
	// public abstract ChartEditorPart
324
	// createCASingularValuesBarChartEditorPart(CA ca);
325
	//
311
//	/**
312
//	 * Creates and return a SWT EditorPart for the specified CA result.
313
//	 * @param ca
314
//	 * @return a SWT EditorPart
315
//	 */
316
//	public abstract ChartEditorPart createCAFactorialMapChartEditorPart(CA ca);
317
//
318
//
319
//	/**
320
//	 * Creates and return a SWT EditorPart for the singular values of the specified CA result.
321
//	 * @param ca
322
//	 * @return a SWT EditorPart
323
//	 */
324
//	public abstract ChartEditorPart createCASingularValuesBarChartEditorPart(CA ca);
325
//
326 326

  
327 327
	/**
328 328
	 * Creates and return a SWT EditorPart for the specified CAH result.
329
	 * 
330 329
	 * @param cah
331 330
	 * @return a SWT EditorPart
332 331
	 */
333
	// public abstract ChartEditorPart createCAHChartEditorPart(Image
334
	// titleImage, CAH cah);
332
//	public abstract ChartEditorPart createCAHChartEditorPart(Image titleImage, CAH cah);
335 333

  
334

  
336 335
	/**
337
	 * Creates and return a SWT EditorPart for the specified dimensions of
338
	 * partition result.
339
	 * 
336
	 * Creates and return a SWT EditorPart for the specified dimensions of partition result.
340 337
	 * @param titleImage
341 338
	 * @param partition
342 339
	 * @param sortPartsBySize
343 340
	 * @return a SWT EditorPart
344 341
	 */
345
	// public abstract ChartEditorPart
346
	// createDimensionsPartitionChartEditorPart(Image titleImage, Partition
347
	// partition, boolean sortPartsBySize);
342
//	public abstract ChartEditorPart createDimensionsPartitionChartEditorPart(Image titleImage, Partition partition, boolean sortPartsBySize);
348 343

  
344

  
349 345
	/**
350
	 * Creates and return a SWT EditorPart for the specified specificities
351
	 * result.
352
	 * 
353
	 * @param titleImage
354
	 *            the editor title image
355
	 * @param specificitiesResult
356
	 *            the specificities result
357
	 * @param typeNames
358
	 *            the type names
359
	 * @param partNames
360
	 *            the part names
361
	 * @param specIndex
362
	 *            the specificities indices
363
	 * @param transpose
364
	 *            the transpose
365
	 * @param drawBars
366
	 *            the draw bar chart state
367
	 * @param drawLines
368
	 *            the draw line chart state
346
	 * Creates and return a SWT EditorPart for the specified specificities result.
347
	 * @param titleImage the editor title image
348
	 * @param specificitiesResult the specificities result
349
	 * @param typeNames the type names
350
	 * @param partNames the part names
351
	 * @param specIndex the specificities indices
352
	 * @param transpose the transpose
353
	 * @param drawBars the draw bar chart state
354
	 * @param drawLines the draw line chart state
369 355
	 * @param banalite
370 356
	 * @param monochrome
371 357
	 * @return
372 358
	 */
373
	// public abstract ChartEditorPart createSpecificitiesChartEditorPart(Image
374
	// titleImage, SpecificitesResult specificitiesResult, boolean transpose,
375
	// boolean drawBars, boolean drawLines, float banalite, boolean monochrome);
359
//	public abstract ChartEditorPart createSpecificitiesChartEditorPart(Image titleImage, SpecificitesResult specificitiesResult, boolean transpose, boolean drawBars, boolean drawLines, float banalite, boolean monochrome);
376 360

  
361

  
377 362
	/**
378 363
	 * Creates and return a SWT EditorPart for the specified progression result.
379
	 * 
380 364
	 * @param titleImage
381 365
	 * @param progression
382 366
	 * @param monochrome
......
385 369
	 * @param file
386 370
	 * @return
387 371
	 */
388
	// public abstract ChartEditorPart createProgressionChartEditorPart(Image
389
	// titleImage, Progression progression, boolean monochrome, boolean
390
	// monostyle, boolean doCumulative);
372
	//public abstract ChartEditorPart createProgressionChartEditorPart(Image titleImage, Progression progression, boolean monochrome, boolean monostyle, boolean doCumulative);
391 373

  
374

  
392 375
	/**
393 376
	 * Set the current charts engine.
394
	 * 
395
	 * @param chartsEngine
396
	 *            the chartsEngine to set
377
	 * @param chartsEngine the chartsEngine to set
397 378
	 */
398 379
	public void setChartsEngine(ChartsEngine chartsEngine) {
399 380
		this.chartsEngine = chartsEngine;
400 381
	}
401 382

  
383

  
402 384
	/**
403 385
	 * Gets the charts engine.
404
	 * 
405 386
	 * @return the chartsEngine
406 387
	 */
407 388
	public ChartsEngine getChartsEngine() {
408 389
		return chartsEngine;
409 390
	}
410 391

  
411
	/**
412
	 * Creates the chart drawing area composite.
413
	 * 
414
	 * @param parent
415
	 * @param style
416
	 * @return the composite
417
	 */
418
	public abstract ChartComposite createComposite(ChartEditorPart chartEditor, Composite parent);
419 392

  
393
	 /**
394
	  * Creates the chart drawing area composite.
395
	  * @param parent
396
	  * @param style
397
	  * @return the composite
398
	  */
399
	 public abstract ChartComposite createComposite(ChartEditorPart chartEditor, Composite parent);
400

  
401

  
420 402
	/**
421
	 * Returns the export formats supported by the implementation of the
422
	 * <code>EditorPart</code> for the view.
423
	 * 
403
	 * Returns the export formats supported by the implementation of the <code>EditorPart</code> for the view.
424 404
	 * @return
425 405
	 */
426 406
	public abstract ArrayList<String> getEditorSupportedExportFileFormats();
427

  
407
	
428 408
	/**
429
	 * Returns the input formats supported by the implementation of the
430
	 * <code>EditorPart</code> for viewing.
431
	 * 
409
	 * Returns the input formats supported by the implementation of the <code>EditorPart</code> for viewing.
432 410
	 * @return
433 411
	 */
434
	public List<String> getEditorSupportedInputFormats() {
412
	public List<String> getEditorSupportedInputFormats()	{
435 413
		return this.supportedInputFormats;
436 414
	}
415
	
437 416

  
438 417
	/**
439
	 * Sets the input formats supported by the implementation of the
440
	 * <code>EditorPart</code> for viewing.
441
	 * 
418
	 * Sets the input formats supported by the implementation of the <code>EditorPart</code> for viewing.
442 419
	 * @param supportedInputFormats
443 420
	 */
444
	public void setEditorSupportedInputFormat(List<String> supportedInputFormats) {
421
	public void setEditorSupportedInputFormat(List<String> supportedInputFormats)	{
445 422
		this.supportedInputFormats = supportedInputFormats;
446 423
	}
447

  
424
	
448 425
	/**
449
	 * Returns the export formats supported by the implementation of the
450
	 * <code>ChartsEngine</code> for the total chart.
451
	 * 
426
	 * Returns the export formats supported by the implementation of the <code>ChartsEngine</code> for the total chart.
452 427
	 * @return
453 428
	 */
454 429
	public abstract ArrayList<String> getChartsEngineSupportedExportFileFormats();
455 430

  
431

  
456 432
	/**
457
	 * Creates a SWT group for the charts engine default preferences area in
458
	 * preference pages.
459
	 * 
433
	 * Creates a SWT group for the charts engine default preferences area in preference pages.
460 434
	 * @return
461 435
	 */
462
	public static Group createChartsRenderingPreferencesGroup(Composite parent) {
436
	public static Group createChartsRenderingPreferencesGroup(Composite parent)	{
463 437

  
464 438
		Group chartsGroup = new Group(parent, SWT.NONE);
465 439

  
......
472 446

  
473 447
		return chartsGroup;
474 448
	}
475

  
449
	
450
	
476 451
	/**
477 452
	 * 
478 453
	 * @param parent
479 454
	 * @return
480 455
	 */
481
	public static Composite createChartsRenderingPreferencesTabFolderComposite(Composite parent) {
456
	public static Composite createChartsRenderingPreferencesTabFolderComposite(Composite parent)	{
482 457
		return createChartsRenderingPreferencesTabFolderComposite(parent, SWTComponentsProviderMessages.ChartsEngineSharedPreferencePage_CHARTS_RENDERING_DEFAULT_PREFERENCES);
483 458
	}
484

  
459
	
485 460
	/**
486 461
	 * Creates a tab folder with a tab item for rendering preferences.
487
	 * 
488 462
	 * @param parent
489 463
	 * @return
490 464
	 */
491
	public static Composite createChartsRenderingPreferencesTabFolderComposite(Composite parent, String tabTitle) {
465
	public static Composite createChartsRenderingPreferencesTabFolderComposite(Composite parent, String tabTitle)	{
492 466

  
467
		
493 468
		TabFolder tabFolder = new TabFolder(parent, SWT.TOP);
494 469
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
495 470
		gridData.horizontalSpan = 2;
......
499 474
		tabItem.setText(tabTitle);
500 475
		Composite composite = new Composite(tabFolder, SWT.NULL);
501 476
		tabItem.setControl(composite);
477
		
502 478

  
503 479
		return composite;
504 480
	}
505

  
481
	
506 482
	/**
507 483
	 * 
508 484
	 * @param page
509 485
	 * @param composite
510 486
	 */
511
	public static void createChartsRenderingPreferencesFields(TXMPreferencePage page, Composite composite) {
512

  
487
	public static void createChartsRenderingPreferencesFields(TXMPreferencePage page, Composite composite)	{
488
		
513 489
		Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
514 490
		GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
515 491
		gridData.horizontalSpan = 2;
516 492
		separator.setLayoutData(gridData);
517 493

  
518
		String commandNodeQualifier = ((TXMPreferenceStore) page.getPreferenceStore()).getNodeQualifier();
494
		String commandNodeQualifier = ((TXMPreferenceStore)page.getPreferenceStore()).getNodeQualifier(); 
519 495

  
520 496
		// Show title
521
		if (!TXMPreferences.isEmpty(commandNodeQualifier, ChartsEnginePreferences.SHOW_TITLE)) {
497
		if(!TXMPreferences.isEmpty(commandNodeQualifier, ChartsEnginePreferences.SHOW_TITLE))	{
522 498
			page.addField(new BooleanFieldEditor(ChartsEnginePreferences.SHOW_TITLE, SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_TITLE, composite));
523 499
		}
524 500
		// Show legend
525
		if (!TXMPreferences.isEmpty(commandNodeQualifier, ChartsEnginePreferences.SHOW_LEGEND)) {
501
		if(!TXMPreferences.isEmpty(commandNodeQualifier, ChartsEnginePreferences.SHOW_LEGEND))	{
526 502
			page.addField(new BooleanFieldEditor(ChartsEnginePreferences.SHOW_LEGEND, SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_LEGEND, composite));
527 503
		}
528 504
		// Show grid
529
		if (!TXMPreferences.isEmpty(commandNodeQualifier, ChartsEnginePreferences.SHOW_GRID)) {
505
		if(!TXMPreferences.isEmpty(commandNodeQualifier, ChartsEnginePreferences.SHOW_GRID))	{
530 506
			page.addField(new BooleanFieldEditor(ChartsEnginePreferences.SHOW_GRID, SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_GRID, composite));
531 507
		}
532 508

  
533 509
		// Rendering colors mode selection
534
		if (!TXMPreferences.isEmpty(commandNodeQualifier, ChartsEnginePreferences.RENDERING_COLORS_MODE)) {
510
		if(!TXMPreferences.isEmpty(commandNodeQualifier, ChartsEnginePreferences.RENDERING_COLORS_MODE))	{
535 511
			String colorsModes[][] = new String[4][2];
536 512
			colorsModes[0][0] = SWTComponentsProviderMessages.ChartsEnginePreferencePage_RenderingModeColors;
537 513
			colorsModes[0][1] = "0"; //$NON-NLS-1$
......
546 522
		}
547 523

  
548 524
		// Same lines stroke
549
		if (!TXMPreferences.isEmpty(commandNodeQualifier, ChartsEnginePreferences.MULTIPLE_LINE_STROKES)) {
525
		if(!TXMPreferences.isEmpty(commandNodeQualifier, ChartsEnginePreferences.MULTIPLE_LINE_STROKES))	{
550 526
			page.addField(new BooleanFieldEditor(ChartsEnginePreferences.MULTIPLE_LINE_STROKES, "Multiple lines stroke", composite));
551 527
		}
552 528

  
529
		
553 530
	}
531
	
554 532

  
533
	
555 534
	/**
556 535
	 * Export the current view of chart editor in the specified file.
557
	 * 
558 536
	 * @param chartEditor
559 537
	 * @param file
560 538
	 * @param fileFormat
......
562 540
	 */
563 541
	public abstract File exportView(ChartEditorPart chartEditor, File file, String fileFormat);
564 542

  
543
	
565 544
	/**
566
	 * Opens the specified <code>ChartEditorPart</code> in the active page and
567
	 * registers the event listeners and context menus according to the type of
568
	 * the chart editor part. The ID of the editor and the chart type are the
569
	 * editor input result data class name.
570
	 * 
545
	 * Opens the specified <code>ChartEditorPart</code> in the active page and registers the event listeners and context menus according to the type of the chart editor part.
546
	 * The ID of the editor and the chart type are the editor input result data class name.
571 547
	 * @param chartEditorInput
572 548
	 * @return
573 549
	 */
574
	public ChartEditorPart openEditor(ChartEditorInput chartEditorInput) {
550
	public ChartEditorPart openEditor(ChartEditorInput chartEditorInput)	{
575 551
		return this.openEditor(chartEditorInput, chartEditorInput.getResult().getClass().getName());
576 552
	}
577 553

  
554
	
578 555
	/**
579
	 * Opens the <code>ChartEditorPart</code> specified by its id and
580
	 * ChartEditorInput in the active page and registers the event listeners and
581
	 * context menus according to the <code>EventCallBack</code> installed
582
	 * extensions.
583
	 * 
556
	 * Opens the <code>ChartEditorPart</code> specified by its id and ChartEditorInput in the active page and registers the event listeners and context menus according to the <code>EventCallBack</code> installed extensions. 
584 557
	 * @param chartEditorInput
585 558
	 * @param editorPartId
586 559
	 * @param chartType
587 560
	 * @return
588 561
	 */
589
	// FIXME: this method have some trouble when calling through a progress
590
	// dialog
591
	// FIXME: this method is not in use anymore since the editor opening is now
592
	// down in TXMEditorPart so the code for ChartEngine downgrading is not
562
	// FIXME: this method have some trouble when calling through a progress dialog
563
	// FIXME: this method is not in use anymore since the editor opening is now down in TXMEditorPart so the code for ChartEngine downgrading is not 
593 564
	// active anymore. Try to use again this code
594
	public ChartEditorPart openEditor(ChartEditorInput chartEditorInput, String editorPartId) {
565
	public ChartEditorPart openEditor(ChartEditorInput chartEditorInput, String editorPartId)	{
595 566

  
596 567
		ChartEditorPart openedChartEditorPart = null;
597 568

  
598 569
		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
599 570
		IWorkbenchPage page = window.getActivePage();
600 571

  
601
		// IWorkbenchWindow window =
602
		// PlatformUI.getWorkbench().getWorkbenchWindows()[0];
603
		// IWorkbenchPage page = window.getActivePage();
604

  
572
//		IWorkbenchWindow window = PlatformUI.getWorkbench().getWorkbenchWindows()[0];
573
//		IWorkbenchPage page = window.getActivePage();
574
		
605 575
		boolean isAlreadyOpened = page.findEditors(chartEditorInput, editorPartId, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID).length > 0;
606

  
576
		
607 577
		Log.info("SWTChartsComponentsProvider.openEditor(): opening editor with id " + editorPartId);
578
		
579
		// if the editor is already open or the charts engine can create the specified chart type
580
		if(isAlreadyOpened || this.chartsEngine.canCreateChart(chartEditorInput.getResult()))	{
581
			
582
			//Log.info(this.name + " - Opening editor for result data type " + chartEditorInput.getResultData().getClass() + " and editor id " + editorPartId);
608 583

  
609
		// if the editor is already open or the charts engine can create the
610
		// specified chart type
611
		if (isAlreadyOpened || this.chartsEngine.canCreateChart(chartEditorInput.getResult())) {
612

  
613
			// Log.info(this.name + " - Opening editor for result data type " +
614
			// chartEditorInput.getResultData().getClass() + " and editor id " +
615
			// editorPartId);
616

  
584
			
617 585
			try {
618

  
586
				
619 587
				openedChartEditorPart = (ChartEditorPart) page.openEditor(chartEditorInput, editorPartId, true, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID);
620 588
				openedChartEditorPart.setWasAlreadyOpened(isAlreadyOpened);
621

  
589
				
590
				
622 591
				// directly returns if the editor was already opened
623
				if (isAlreadyOpened) {
592
				if(isAlreadyOpened)	{
624 593
					return openedChartEditorPart;
625 594
				}
626

  
595
				
627 596
				// compute the chart
628
				// openedChartEditorPart.computeChart(false);
597
				//openedChartEditorPart.computeChart(false);
629 598

  
599
				
630 600
				// FIXME: directly close the editor if it contains no chart
631
				// if(openedChartEditorPart.getChart() == null) {
632
				// page.closeEditor(openedChartEditorPart, false);
633
				// return openedChartEditorPart;
634
				// }
635

  
601
//				if(openedChartEditorPart.getChart() == null)	{
602
//					page.closeEditor(openedChartEditorPart, false);
603
//					return openedChartEditorPart;
604
//				}
605
				
636 606
				// FIXME: tests with reuseEditor()
637
				// openedChartEditorPart = (ChartEditorPart)
638
				// page.reuseEditor(editorPart, editorPart.getEditorInput());
639

  
640
				// openedChartEditorPart.refreshCorporaView();
641

  
607
				//openedChartEditorPart  = (ChartEditorPart) page.reuseEditor(editorPart, editorPart.getEditorInput());
608
				
609
				
610
				//openedChartEditorPart.refreshCorporaView();
611
				
642 612
				openedChartEditorPart.forceFocus();
643

  
644
			} catch (PartInitException e) {
613
				
614
			}
615
			catch(PartInitException e) {
645 616
				e.printStackTrace();
646 617
			}
647

  
618
			
648 619
		}
649
		// get the first installed charts engine that can create chart and use
650
		// the SWT provider matching it
651
		else {
620
		// get the first installed charts engine that can create chart and use the SWT provider matching it
621
		else	{
652 622
			Log.warning("Rendering failed with current charts engine, trying to rendering chart with other installed SWT components provider and other charts engine:");
653

  
623
	
654 624
			boolean canCreate = false;
655
			for (int i = 0; i < ChartsEngine.getChartsEngines().size() && !canCreate; i++) {
656
				if (ChartsEngine.getChartsEngines().get(i) != this.chartsEngine) {
625
			for(int i = 0; i < ChartsEngine.getChartsEngines().size() && !canCreate; i++) {
626
				if(ChartsEngine.getChartsEngines().get(i) != this.chartsEngine)	{
657 627
					ChartsEngine chartsEngine = ChartsEngine.getChartsEngines().get(i);
658 628
					canCreate = chartsEngine.canCreateChart(chartEditorInput.getResult());
659 629
					// get a provider that can manage the charts engine
660
					if (canCreate) {
630
					if(canCreate)	{
661 631
						SWTChartsComponentsProvider provider = SWTChartsComponentsProvider.getComponentsProvider(chartsEngine);
662
						if (provider != null) {
632
						if(provider != null)	{
663 633
							provider.setChartsEngine(chartsEngine);
664 634
							chartEditorInput.setSWTChartsComponentsProvider(provider);
665 635
							Log.warning(provider.toString());
......
669 639
				}
670 640
			}
671 641
		}
672

  
642
		
673 643
		return openedChartEditorPart;
674 644
	}
675

  
645
	
676 646
	/**
677 647
	 * 
678 648
	 * @param titleImage
......
682 652
	 * @param params
683 653
	 * @return
684 654
	 */
685
	public ChartEditorPart openEditor(ChartResult result) {
655
	public ChartEditorPart openEditor(ChartResult result)	{
686 656
		return this.openEditor(this.createChartEditorInput(result), result.getClass().getName());
687 657
	}
688

  
658
	
659
	
689 660
	/**
690 661
	 * Initializes the default context menus.
691
	 * 
692 662
	 * @param composite
693 663
	 */
694
	public static void initDefaultContextMenus(ChartComposite composite) {
695
		if (composite != null) {
664
	public static void initDefaultContextMenus(ChartComposite composite)	{
665
		if(composite != null)	{
696 666
			composite.initItemAreaContextMenu();
697 667
			composite.initEmptyAreaContextMenu();
698 668
			composite.setCurrentContextMenu(EventCallBack.AREA_EMPTY);
699 669
		}
700 670
	}
701 671

  
672
	
702 673
	/**
703 674
	 * Gets the current active chart editor managing the multi pages editor.
704
	 * 
705 675
	 * @param event
706 676
	 * @return
707 677
	 */
708
	public static ChartEditorPart getActiveChartEditor(ExecutionEvent event) {
678
	public static ChartEditorPart getActiveChartEditor(ExecutionEvent event)	{
709 679
		ChartEditorPart chartEditor = null;
710 680

  
711
		Event eevent = (Event) event.getTrigger();
681
		Event eevent = (Event)event.getTrigger();
712 682
		Widget widget = eevent.widget;
713 683
		// Toolbars
714
		if (event != null && widget instanceof ToolItem) {
684
		if(event != null && widget instanceof ToolItem)	{
715 685
			ToolItem to = (ToolItem) widget;
716 686
			ToolBar parent = to.getParent();
717
			if (to.getParent() instanceof ChartEditorToolBar) {
718
				chartEditor = ((ChartEditorToolBar) ((ToolItem) ((Event) event.getTrigger()).widget).getParent()).getEditorPart();
687
			if(to.getParent() instanceof ChartEditorToolBar)	{
688
				chartEditor = ((ChartEditorToolBar)((ToolItem)((Event)event.getTrigger()).widget).getParent()).getEditorPart();	
719 689
			}
720
			if (to.getParent() instanceof AdvancedChartEditorToolBar) {
721
				chartEditor = ((AdvancedChartEditorToolBar) ((ToolItem) ((Event) event.getTrigger()).widget).getParent()).getEditorPart();
690
			if(to.getParent() instanceof AdvancedChartEditorToolBar)	{
691
				chartEditor = ((AdvancedChartEditorToolBar)((ToolItem)((Event)event.getTrigger()).widget).getParent()).getEditorPart();
722 692
			}
723 693
		}
724 694
		// Context menu, multi pages editor
725
		else if (PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart() instanceof SplitedGenericMultiPageEditor) {
695
		else if(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart() instanceof SplitedGenericMultiPageEditor)	{
726 696
			// Main editor
727
			if (((SplitedGenericMultiPageEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart()).getMainEditorPart() instanceof ChartEditorPart && ((ChartEditorPart) ((SplitedGenericMultiPageEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart()).getMainEditorPart()).hasFocus()) {
728
				chartEditor = (ChartEditorPart) ((SplitedGenericMultiPageEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart()).getMainEditorPart();
729
			} else if (((MultiPageEditorPart) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()).getSelectedPage() instanceof ChartEditorPart && ((ChartEditorPart) ((MultiPageEditorPart) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()).getSelectedPage()).hasFocus()) {
730
				chartEditor = (ChartEditorPart) ((MultiPageEditorPart) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()).getSelectedPage();
697
			if(((SplitedGenericMultiPageEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart()).getMainEditorPart() instanceof ChartEditorPart
698
					&& ((ChartEditorPart)((SplitedGenericMultiPageEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart()).getMainEditorPart()).hasFocus())	{
699
				chartEditor = (ChartEditorPart)((SplitedGenericMultiPageEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart()).getMainEditorPart();
731 700
			}
701
			else if(((MultiPageEditorPart) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()).getSelectedPage() instanceof ChartEditorPart
702
					&& ((ChartEditorPart)((MultiPageEditorPart) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()).getSelectedPage()).hasFocus() )	{
703
				chartEditor = (ChartEditorPart)((MultiPageEditorPart) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()).getSelectedPage();
704
			}
732 705
		}
733 706
		// Context menu, Normal editor
734
		else if (PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart() instanceof ChartEditorPart) {
735
			chartEditor = (ChartEditorPart) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
707
		else if(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart() instanceof ChartEditorPart)	{
708
			chartEditor = (ChartEditorPart) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();	
736 709
		}
737 710
		return chartEditor;
738 711
	}
739

  
712
	
740 713
	/**
741 714
	 * Initializes AWT default events to delegate AWT events to SWT.
742
	 * 
743 715
	 * @param chartEditor
744 716
	 * @param swingComponent
745 717
	 */
746
	public static void initializeAWTDelegationListeners(final ChartEditorPart chartEditor, final JComponent swingComponent) {
718
	public static void initializeAWTDelegationListeners(final ChartEditorPart chartEditor, final JComponent swingComponent)	{
747 719

  
748
		// AWT to SWT
720
		// AWT to  SWT
749 721
		swingComponent.addMouseMotionListener(new MouseMotionListener() {
750 722

  
751 723
			@Override
752 724
			public void mouseMoved(final MouseEvent e) {
753
				chartEditor.getComposite().getDisplay().asyncExec(new Runnable() {
725
				chartEditor.getComposite().getDisplay().asyncExec(new Runnable () {
754 726
					public void run() {
755
						if (!chartEditor.getComposite().isDisposed()) {
727
						if(!chartEditor.getComposite().isDisposed())	{
756 728
							chartEditor.getComposite().notifyListeners(SWT.MouseMove, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseMove));
757 729
						}
758 730
					}
......
770 742

  
771 743
			@Override
772 744
			public void mouseReleased(final MouseEvent e) {
773
				chartEditor.getComposite().getDisplay().asyncExec(new Runnable() {
745
				chartEditor.getComposite().getDisplay().asyncExec(new Runnable () {
774 746
					public void run() {
775

  
747
						
776 748
						// FIXME: context menu
777
						if (e.isPopupTrigger()) {
749
						if(e.isPopupTrigger())	{
778 750

  
779
							// System.err.println("SWTChartsComponentsProvider.initializeAWTDelegationListeners(...).new MouseListener() {...}.mouseReleased(...).new Runnable() {...}.run(): AWT popup trigger detected");
751
							//System.err.println("SWTChartsComponentsProvider.initializeAWTDelegationListeners(...).new MouseListener() {...}.mouseReleased(...).new Runnable() {...}.run(): AWT popup trigger detected");
752
							
780 753

  
781
							// update the mouse over item selection according to
782
							// the mouse event
754
							
755
							// update the mouse over item selection according to the mouse event
783 756
							chartEditor.getComposite().getChartComponent().updateMouseOverItem(e);
784

  
757
							
785 758
							// FIXME: temporary disabled for 0.7.8
786 759
							// manually pop up the menu
787
							if (chartEditor.getComposite().getMenu() != null) {
760
							if(chartEditor.getComposite().getMenu() != null)	{
788 761
								chartEditor.getComposite().getMenu().setLocation(new Point(e.getXOnScreen(), e.getYOnScreen()));
789 762
								chartEditor.getComposite().getMenu().setVisible(true);
790 763
							}
791 764

  
792
							// FIXME: the SWT.MenuDetect event delegation
793
							// doesn't work, it would be better than manually
794
							// pop up the menu (but other problem is the dynamic
795
							// menu on chart entity item)
796
							// chartEditor.getComposite().notifyListeners(SWT.MenuDetect,
797
							// SWTChartsComponentProvider.swingEventToSWT(chartEditor.getComposite(),
798
							// swingComponent, e, SWT.MenuDetect));
799
							// FIXME: try to delegate the Menu detect event,
800
							// DOES NOT SEEM TO WORK
801
							// chartEditor.getComposite().notifyListeners(SWT.MenuDetect,
802
							// SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(),
803
							// swingComponent, e, SWT.MenuDetect));
804
							// chartEditor.getComposite().notifyListeners(SWT.Show,
805
							// SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(),
806
							// swingComponent, e, SWT.Show));
807

  
765
							// FIXME: the SWT.MenuDetect event delegation doesn't work, it would be better than manually pop up the menu (but other problem is the dynamic menu on chart entity item)
766
							//chartEditor.getComposite().notifyListeners(SWT.MenuDetect, SWTChartsComponentProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MenuDetect));
767
							// FIXME: try to delegate the Menu detect event, DOES NOT SEEM TO WORK
768
							//chartEditor.getComposite().notifyListeners(SWT.MenuDetect, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MenuDetect));
769
							//chartEditor.getComposite().notifyListeners(SWT.Show, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.Show));
770
							
808 771
						}
809 772
						chartEditor.getComposite().notifyListeners(SWT.MouseUp, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseUp));
810
						// chartEditor.activate();
773
						//chartEditor.activate();
811 774
					}
812 775
				});
813 776
			}
......
821 784
					public void run() {
822 785

  
823 786
						chartEditor.getComposite().notifyListeners(SWT.MouseDown, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseDown));
824

  
787
						
825 788
						// FIXME: Debug
826
						// System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new MouseListener() {...}.mousePressed(...).new Runnable() {...}.run()");
789
//						System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new MouseListener() {...}.mousePressed(...).new Runnable() {...}.run()");
827 790
						// Activate the editor part on AWT mouse pressed event
828 791
						chartEditor.activate();
829
						// chartEditor.forceFocus();
792
//						chartEditor.forceFocus();
830 793
					}
831 794
				});
832 795

  
......
842 805
			public void mouseEntered(java.awt.event.MouseEvent e) {
843 806

  
844 807
				// TODO: DEbug
845
				// System.err.println("SWTChartsComponentProvider.initializeSwingDelegationListeners(...) AWT mouse entered");
808
				//System.err.println("SWTChartsComponentProvider.initializeSwingDelegationListeners(...) AWT mouse entered");
846 809

  
847 810
				// Force the focus in the component on mouse enter
848
				/*
849
				 * if(!swingComponent.isFocusOwner()) {
850
				 * 
851
				 * // SWT thread if(!chartEditor.getComposite().isDisposed()) {
852
				 * chartEditor.getComposite().getDisplay().asyncExec(new
853
				 * Runnable() { public void run() {
854
				 * 
855
				 * 
856
				 * // FIXME: this code works on Windows and Linux but activate()
857
				 * the chart editor when mouse enters //chartEditor.activate();
858
				 * 
859
				 * EventQueue.invokeLater(new Runnable () { public void run () {
860
				 * 
861
				 * // TODO: this code forces to give the focus to the embedded
862
				 * AWT Frame under Windows (#1127 related) // For unknown reason
863
				 * Frame.requestFocusInWindow() doesn't work and always return
864
				 * false here // This code is not sufficient for Linux
865
				 * System.out.println(
866
				 * "SWTChartsComponentProvider.initializeAWTDelegationListeners(...) trying to give focus to root embedded frame"
867
				 * ); try { Frame frame = (Frame)
868
				 * swingComponent.getFocusCycleRootAncestor();
869
				 * //frame.synthesizeWindowActivation(true); Class clazz =
870
				 * frame.getClass(); Method method =
871
				 * clazz.getMethod("synthesizeWindowActivation", new
872
				 * Class[]{boolean.class}); if(method != null) {
873
				 * method.invoke(frame, new Object[]{new Boolean(true)});
874
				 * System.out.println(
875
				 * "SWTChartsComponentProvider.initializeSwingDelegationListeners(...).new MouseListener() {...}.mouseEntered(...).new Runnable() {...}.run(): "
876
				 * + frame);
877
				 * 
878
				 * }
879
				 * 
880
				 * //frame.requestFocusInWindow();
881
				 * 
882
				 * } catch (Throwable e) { Log.printStackTrace(e); } } });
883
				 * 
884
				 * 
885
				 * //System.out.println(
886
				 * "SWTChartsComponentProvider.initializeSwingDelegationListeners) AWT give focus to frame = "
887
				 * + ((JFCComposite)chartEditor.getComposite()).frame.
888
				 * requestFocusInWindow());
889
				 * 
890
				 * 
891
				 * // chartEditor.setFocus(); // System.out.println(
892
				 * "SWTChartsComponentProvider.initializeSwingDelegationListeners() SWT got focus = "
893
				 * + chartEditor.getComposite().setFocus());
894
				 * 
895
				 * // EventQueue.invokeLater(new Runnable () { // public void
896
				 * run () { //swingComponent.requestFocusInWindow();
897
				 * 
898
				 * // System.out.println(
899
				 * "SWTChartsComponentProvider.initializeSwingDelegationListeners() AWT got focus = "
900
				 * + swingComponent.requestFocusInWindow()); // } // });
901
				 * 
902
				 * 
903
				 * 
904
				 * } }); } }
905
				 */
811
				/*if(!swingComponent.isFocusOwner())	{
812

  
813
					// SWT thread
814
					if(!chartEditor.getComposite().isDisposed())	{
815
						chartEditor.getComposite().getDisplay().asyncExec(new Runnable() {
816
							public void run() {
817
	
818
	
819
								// FIXME: this code works on Windows and Linux but activate() the chart editor when mouse enters
820
								//chartEditor.activate();
821
	
822
								EventQueue.invokeLater(new Runnable () {
823
									public void run () {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff