Révision 633

tmp/org.txm.wordcloud.rcp/src/org/txm/wordcloud/rcp/editors/WordCloudEditor.java (revision 633)
5 5
import org.eclipse.swt.widgets.Composite;
6 6
import org.eclipse.swt.widgets.Label;
7 7
import org.eclipse.swt.widgets.Spinner;
8
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
8
import org.txm.chartsengine.rcp.editors.ChartEditor;
9 9
import org.txm.core.results.Parameter;
10 10
import org.txm.utils.logger.Log;
11 11
import org.txm.wordcloud.core.functions.WordCloud;
......
19 19
 * @author sjacquot
20 20
 *
21 21
 */
22
public class WordCloudEditor extends ChartEditorPart<WordCloud> {
22
public class WordCloudEditor extends ChartEditor<WordCloud> {
23 23

  
24 24
	
25 25
	@Parameter(key=WordCloudPreferences.F_MIN)
tmp/org.txm.wordcloud.rcp/src/org/txm/wordcloud/rcp/handlers/ComputeWordCloud.java (revision 633)
29 29

  
30 30
import org.eclipse.core.commands.ExecutionEvent;
31 31
import org.eclipse.core.commands.ExecutionException;
32
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
32
import org.txm.chartsengine.rcp.editors.ChartEditor;
33 33
import org.txm.index.core.functions.Index;
34 34
import org.txm.rcp.StatusLine;
35 35
import org.txm.rcp.commands.OpenBrowser;
......
92 92
		
93 93
		StatusLine.setMessage(WordCloudCoreMessages.StatusBar_Opening_result);
94 94

  
95
		ChartEditorPart.openEditor(wordCloud);
95
		ChartEditor.openEditor(wordCloud);
96 96
							
97 97
		return null;
98 98
	}
tmp/org.txm.partition.rcp/src/org/txm/partition/rcp/handlers/ComputePartitionDimensionsBarChart.java (revision 633)
29 29

  
30 30
import org.eclipse.core.commands.ExecutionEvent;
31 31
import org.eclipse.core.commands.ExecutionException;
32
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
32
import org.txm.chartsengine.rcp.editors.ChartEditor;
33 33
import org.txm.partition.core.functions.PartitionDimensions;
34 34
import org.txm.rcp.handlers.BaseAbstractHandler;
35 35
import org.txm.rcp.views.corpora.CorporaView;
......
93 93
		// FIXME: Pie chart tests
94 94
//		partitionDimensions.setChartType("Partition Dimensions Pie Chart"); //$NON-NLS-1$
95 95
		
96
		ChartEditorPart.openEditor(partitionDimensions, partitionDimensions.getClass().getName());
96
		ChartEditor.openEditor(partitionDimensions, partitionDimensions.getClass().getName());
97 97

  
98 98
		return null;
99 99
	}
tmp/org.txm.partition.rcp/src/org/txm/partition/rcp/editors/PartitionDimensionsEditor.java (revision 633)
3 3
import org.eclipse.swt.SWT;
4 4
import org.eclipse.swt.widgets.Composite;
5 5
import org.eclipse.swt.widgets.ToolItem;
6
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
6
import org.txm.chartsengine.rcp.editors.ChartEditor;
7 7
import org.txm.core.results.Parameter;
8 8
import org.txm.partition.core.functions.PartitionDimensions;
9 9
import org.txm.partition.core.preferences.PartitionDimensionsPreferences;
......
16 16
 * @author sjacquot
17 17
 *
18 18
 */
19
public class PartitionDimensionsEditor extends ChartEditorPart<PartitionDimensions> {
19
public class PartitionDimensionsEditor extends ChartEditor<PartitionDimensions> {
20 20

  
21 21

  
22 22
	@Parameter(key=PartitionDimensionsPreferences.CHART_DIMENSIONS_SORT_BY_SIZE)
tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/editors/CooccurrencesEditor.java (revision 633)
78 78
import org.txm.core.preferences.TXMPreferences;
79 79
import org.txm.core.results.TXMParameters;
80 80
import org.txm.rcp.RCPMessages;
81
import org.txm.rcp.editors.TXMEditorPart;
81
import org.txm.rcp.editors.TXMEditor;
82 82
import org.txm.rcp.editors.TXMResultEditorInput;
83 83
import org.txm.rcp.editors.TableKeyListener;
84 84
import org.txm.rcp.preferences.RCPPreferences;
......
97 97
 * 
98 98
 * @author mdecorde
99 99
 */
100
public class CooccurrencesEditor extends TXMEditorPart<Cooccurrence> {
100
public class CooccurrencesEditor extends TXMEditor<Cooccurrence> {
101 101

  
102 102
	/** The Constant ID. */
103 103
	public static final String ID = CooccurrencesEditor.class.getName(); //$NON-NLS-1$
......
275 275
//				updateResultFromEditor();
276 276
//				compute(true);
277 277
//				// FIXME old method
278
//				//TXMEditorPart.compute(CooccurrencesEditor.this.getResultData(), true, CooccurrencesEditor.this);
278
//				//TXMEditor.compute(CooccurrencesEditor.this.getResultData(), true, CooccurrencesEditor.this);
279 279
//			}
280 280
//
281 281
//			@Override
......
757 757
				sort();
758 758

  
759 759
				// Pack the columns
760
				TXMEditorPart.packColumns(viewer);
760
				TXMEditor.packColumns(viewer);
761 761
				
762 762
				// FIXME: need to be done in another way with after the plugin split
763 763
				QueriesView.refresh();
tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/handlers/ComputeCooccurrences.java (revision 633)
39 39
import org.txm.core.preferences.TXMPreferences;
40 40
import org.txm.rcp.RCPMessages;
41 41
import org.txm.rcp.StatusLine;
42
import org.txm.rcp.editors.TXMEditorPart;
42
import org.txm.rcp.editors.TXMEditor;
43 43
import org.txm.rcp.editors.TXMResultEditorInput;
44 44
import org.txm.rcp.handlers.BaseAbstractHandler;
45 45
import org.txm.rcp.utils.Logger;
......
128 128
			StatusLine.setMessage(RCPMessages.ComputeCooccurrences_0);
129 129

  
130 130
			//System.out.println("DEBUG: opening cooc: "+cooc+" corpus="+cooc.getCorpus());
131
			TXMEditorPart.openEditor(cooc, CooccurrencesEditor.ID);
131
			TXMEditor.openEditor(cooc, CooccurrencesEditor.ID);
132 132
			
133 133
			return true;
134 134
		} catch (Exception e) {
tmp/org.txm.links.rcp/src/org/txm/rcp/commands/link/IndexToCooccurrence.java (revision 633)
74 74
		System.out.println("IMPLEMENTATION NOT FINISHED");
75 75
		
76 76
//		try {
77
//			CooccurrencesEditor conceditor = (CooccurrencesEditor) TXMEditorPart.openEditor(new TXMResultEditorInput(corpus, new TXMParameters()), "CooccurrencesEditor"); //$NON-NLS-1$
77
//			CooccurrencesEditor conceditor = (CooccurrencesEditor) TXMEditor.openEditor(new TXMResultEditorInput(corpus, new TXMParameters()), "CooccurrencesEditor"); //$NON-NLS-1$
78 78
//			conceditor.setFocus(query);
79 79
//			conceditor.computeResult(false);
80 80
//		} catch (Exception e) {
......
103 103
		
104 104
//		Corpus corpus = voceditor.getCorpus();
105 105
//		try {
106
//			CooccurrencesEditor conceditor = (CooccurrencesEditor) TXMEditorPart.openEditor(new TXMResultEditorInput(corpus, new TXMParameters()), "CooccurrencesEditor"); //$NON-NLS-1$
106
//			CooccurrencesEditor conceditor = (CooccurrencesEditor) TXMEditor.openEditor(new TXMResultEditorInput(corpus, new TXMParameters()), "CooccurrencesEditor"); //$NON-NLS-1$
107 107
//			conceditor.setFocus(query);
108 108
//			conceditor.computeResult(false);
109 109
//			return conceditor;
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/CAEditor.java (revision 633)
69 69
import org.txm.ca.rcp.messages.CAUIMessages;
70 70
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
71 71
import org.txm.chartsengine.rcp.editors.ChartEditorInput;
72
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
72
import org.txm.chartsengine.rcp.editors.ChartEditor;
73 73
import org.txm.core.results.TXMResult;
74 74
import org.txm.rcp.RCPMessages;
75 75
import org.txm.rcp.editors.SplitedGenericMultiPageEditor;
76
import org.txm.rcp.editors.TXMEditorPart;
76
import org.txm.rcp.editors.TXMEditor;
77 77
import org.txm.rcp.editors.TXMMultiPageEditor;
78 78
import org.txm.rcp.editors.TXMResultEditorInput;
79 79
import org.txm.rcp.editors.Tablable;
......
314 314

  
315 315

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

  
319 319

  
320 320

  
......
329 329
	public void initCAFactorialMapEditor()	{
330 330

  
331 331
		// Editor part
332
		ChartEditorPart caFactorialMapEditorPart = new CAFactorialMapChartEditor(new ChartEditorInput(ca));
332
		ChartEditor caFactorialMapEditorPart = new CAFactorialMapChartEditor(new ChartEditorInput(ca));
333 333
		editors.add(caFactorialMapEditorPart);
334 334

  
335 335
		// Editor input
......
349 349
		}
350 350
		
351 351
		// Editor part
352
		ChartEditorPart caSingularValuesEditorPart = new ChartEditorPart(SWTChartsComponentsProvider.getCurrent().createChartEditorInput(eigenvalues));
352
		ChartEditor caSingularValuesEditorPart = new ChartEditor(SWTChartsComponentsProvider.getCurrent().createChartEditorInput(eigenvalues));
353 353
		caSingularValuesEditorPart.compute(false);
354 354
		editors.add(caSingularValuesEditorPart);
355 355

  
......
667 667
	 * Gets the chart factorial map chart editor.
668 668
	 * @return
669 669
	 */
670
	public ChartEditorPart getChartEditor()	{
671
		return (ChartEditorPart) this.editors.get(0);
670
	public ChartEditor getChartEditor()	{
671
		return (ChartEditor) this.editors.get(0);
672 672
	}
673 673

  
674 674
	@Override
675 675
	public void setFocus()	{
676
		// Give the focus to the CA factorial map ChartEditorPart instead of the parent MultiPageEditorPart
676
		// Give the focus to the CA factorial map ChartEditor instead of the parent MultiPageEditorPart
677 677
		editors.get(0).setFocus();
678 678
		// FIXME: the problem here is that we need to give the focus to the singular values chart editor when clicking in it
679 679
		//	System.err.println("CaEditor.setFocus(): " + this.getActivePage());
......
716 716

  
717 717
	@Override
718 718
	public void close(boolean deleteResult) {
719
		((ChartEditorPart)editors.get(0)).close(deleteResult);
719
		((ChartEditor)editors.get(0)).close(deleteResult);
720 720
	}
721 721

  
722 722

  
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/CAFactorialMapChartEditor.java (revision 633)
11 11
import org.txm.ca.core.preferences.CAPreferences;
12 12
import org.txm.ca.rcp.messages.CAUIMessages;
13 13
import org.txm.chartsengine.rcp.editors.ChartEditorInput;
14
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
14
import org.txm.chartsengine.rcp.editors.ChartEditor;
15 15
import org.txm.core.results.Parameter;
16 16
import org.txm.rcp.IImageKeys;
17 17
import org.txm.utils.logger.Log;
......
21 21
 * @author sjacquot
22 22
 *
23 23
 */
24
public class CAFactorialMapChartEditor extends ChartEditorPart<CA> {
24
public class CAFactorialMapChartEditor extends ChartEditor<CA> {
25 25

  
26 26

  
27 27
	// FIXME: try to automate that
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/handlers/ComputeCA.java (revision 633)
146 146
			}
147 147

  
148 148
			// FIXME: old code
149
			//ChartEditorPart.compute(ca);
149
			//ChartEditor.compute(ca);
150 150
			// FIXME: new code
151 151
			ca.compute();
152 152

  
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificities.java (revision 633)
141 141
//			System.out.println("rows="+table.getRowNames());
142 142
//			System.out.println("cols="+table.getColNames());
143 143
//			System.out.println("prop="+table.getProperty());
144
			init(symbol, specIndex, lexicalTable, Arrays
145
					.asList(lexicalTable.getRowNames().asStringsArray()), Arrays.asList(lexicalTable.getColNames().asStringsArray()), lexicalTable.getProperty().getName(), this.maxScore); 
144
			init(symbol, specIndex, lexicalTable.getProperty().getName()); 
146 145
		}
147 146
		else {
148
			init(si.getSymbol(), specIndex, lexicalTable, Arrays
149
					.asList(lexicalTable.getRowNames().asStringsArray()), Arrays.asList(lexicalTable.getColNames().asStringsArray()),
150
					"TLNONAME: " + lexicalTable.getProperty().getName(), this.maxScore); //$NON-NLS-1$
147
			init(si.getSymbol(), specIndex, "TLNONAME: " + lexicalTable.getProperty().getName()); //$NON-NLS-1$
151 148
		}
152 149
		return true;
153 150
	}
......
168 165
	 * @param maxScore if abs(score) > maxScore -> score = +/- maxScore
169 166
	 * @throws StatException the stat exception
170 167
	 */
171
	protected void init(String symbol, double[][] specIndex, LexicalTable table, List<String> typeFocus, List<String> partFocus, String name, int maxScore) throws StatException {
168
	protected void init(String symbol, double[][] specIndex, String name) throws StatException {
172 169
		
173
		this.lexicalTable = table;
174 170
		this.symbol = symbol;
175 171

  
176
		if (table == null) {
172
		if (this.lexicalTable == null) {
177 173
			throw new IllegalArgumentException(SpecificitiesCoreMessages.SpecificitesResult_2);
178 174
		}
179 175
		this.name = name;
......
187 183
		}
188 184

  
189 185
		this.indices = specIndex;
190
		this.lexicalTable = table;
191
		this.colnames = partFocus;
192
		this.rownames = typeFocus;
186
		this.colnames = Arrays.asList(lexicalTable.getColNames().asStringsArray());
187
		this.rownames = Arrays.asList(lexicalTable.getRowNames().asStringsArray());
193 188

  
194 189
		// filter by max&min
195 190
		int MAX = MAXSPECIF;
......
210 205
			}
211 206
		}
212 207

  
213
		if (typeFocus != null && typeFocus.size() != 0) {
214
			if (typeFocus.size() != specIndex.length) {
208
		if (this.rownames != null && this.rownames.size() != 0) {
209
			if (this.rownames.size() != specIndex.length) {
215 210
				throw new IllegalArgumentException(
216
						SpecificitiesCoreMessages.bind(SpecificitiesCoreMessages.ComputeError_FOUND_AND_WANTED_ROWS_MISMATCH, typeFocus.size(), specIndex.length));
211
						SpecificitiesCoreMessages.bind(SpecificitiesCoreMessages.ComputeError_FOUND_AND_WANTED_ROWS_MISMATCH, this.rownames.size(), specIndex.length));
217 212
			}
218 213

  
219
			rowindex = ArrayIndex.getIndex(table.getRowNames().asStringsArray(), typeFocus.toArray(new String[] {}));
214
			rowindex = ArrayIndex.getIndex(this.lexicalTable.getRowNames().asStringsArray(), this.rownames.toArray(new String[] {}));
220 215
			for (int i : rowindex) {
221 216
				if (i == -1) {
222 217
					throw new IllegalArgumentException(SpecificitiesCoreMessages.SpecificitesResult_6);
223 218
				}
224 219
			}
225 220
		}
226
//		if (partFocus != null && partFocus.size() != 0) {
227
//			if (partFocus.size() != specIndex[0].length) {
221
//		if (this.colnames != null && this.colnames.size() != 0) {
222
//			if (this.colnames.size() != specIndex[0].length) {
228 223
//				throw new IllegalArgumentException(
229
//						SpecificitiesCoreMessages.SpecificitesResult_7 + partFocus.size()
224
//						SpecificitiesCoreMessages.SpecificitesResult_7 + this.colnames.size()
230 225
//						+ ", " + specIndex[0].length + ")."); //$NON-NLS-1$//$NON-NLS-2$ 
231 226
//			}
232 227
//			colindex = ArrayIndex.getIndex(
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/SpecificitiesSelection.java (revision 633)
119 119
		for (int i = 0; i < selectedTypeNames.length; i++) {
120 120
			name += selectedTypeNames[i] + " ";
121 121
		}
122
		if (name.length() > 20) name = name.substring(0, 19) + "...";
122
		if (name.length() > 50) name = name.substring(0, 49) + "...";
123 123
		return name;
124 124
	}
125 125

  
tmp/org.txm.index.rcp/src/org/txm/index/rcp/handlers/ComputeIndex.java (revision 633)
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
import org.txm.rcp.editors.TXMEditor;
38 38
import org.txm.rcp.editors.TXMResultEditorInput;
39 39
import org.txm.rcp.handlers.BaseAbstractHandler;
40 40
import org.txm.rcp.StatusLine;
......
87 87
	}
88 88

  
89 89
	public static void open(Index index) {
90
		TXMEditorPart.openEditor(index, IndexEditor.class.getName());
90
		TXMEditor.openEditor(index, IndexEditor.class.getName());
91 91
	}
92 92
}
tmp/org.txm.index.rcp/src/org/txm/index/rcp/handlers/ComputeLexicon.java (revision 633)
10 10
import org.txm.index.rcp.editors.DictionnaryEditor;
11 11
import org.txm.lexicon.core.functions.Lexicon;
12 12
import org.txm.rcp.TXMWindows;
13
import org.txm.rcp.editors.TXMEditorPart;
13
import org.txm.rcp.editors.TXMEditor;
14 14
import org.txm.rcp.editors.TXMResultEditorInput;
15 15
import org.txm.rcp.handlers.BaseAbstractHandler;
16 16
import org.txm.rcp.views.corpora.CorporaView;
......
67 67
	}
68 68
	
69 69
	public static void open(Index lexicon) {
70
		TXMEditorPart.openEditor(lexicon, DictionnaryEditor.class.getName());
70
		TXMEditor.openEditor(lexicon, DictionnaryEditor.class.getName());
71 71
		
72 72
	}
73 73
}
tmp/org.txm.index.rcp/src/org/txm/index/rcp/editors/IndexEditor.java (revision 633)
72 72
import org.txm.rcp.JobsTimer;
73 73
import org.txm.rcp.RCPMessages;
74 74
import org.txm.rcp.StatusLine;
75
import org.txm.rcp.editors.TXMEditorPart;
75
import org.txm.rcp.editors.TXMEditor;
76 76
import org.txm.rcp.editors.TXMResultEditorInput;
77 77
import org.txm.rcp.editors.TableKeyListener;
78 78
import org.txm.rcp.preferences.RCPPreferences;
......
96 96
 *
97 97
 * @author mdecorde
98 98
 */
99
public class IndexEditor extends TXMEditorPart<Index> {
99
public class IndexEditor extends TXMEditor<Index> {
100 100

  
101 101
	/** The index. */
102 102
	protected Index index;
......
676 676
		initializeFields();
677 677

  
678 678
		// Register the context menu
679
		TXMEditorPart.initContextMenu(this.viewer.getTable(), "IndexEditorContextMenu", this.getSite(), this.viewer); // $NON-NLS-1$
679
		TXMEditor.initContextMenu(this.viewer.getTable(), "IndexEditorContextMenu", this.getSite(), this.viewer); // $NON-NLS-1$
680 680
		
681 681
		viewer.getTable().pack();
682 682
		parent.layout(true);
tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/handlers/ComputeProgression.java (revision 633)
32 32
import org.txm.chartsengine.core.ChartsEngine;
33 33
import org.txm.chartsengine.r.core.RChartsEngine;
34 34
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
35
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
35
import org.txm.chartsengine.rcp.editors.ChartEditor;
36 36
import org.txm.chartsengine.svgbatik.rcp.SVGSWTChartsComponentsProvider;
37 37
import org.txm.progression.core.functions.Progression;
38 38
import org.txm.progression.core.messages.ProgressionCoreMessages;
......
97 97
			tmpSWTComponentsProvider.setChartsEngine(tmpChartsEngine);
98 98
			
99 99
			// Create and open the chart editor
100
			//ChartEditorPart.compute(progression, tmpSWTComponentsProvider);
100
			//ChartEditor.compute(progression, tmpSWTComponentsProvider);
101 101
			
102 102
		}
103 103
		else	{
104 104
			// Create and open the chart editor
105
			//ChartEditorPart.compute(progression);
105
			//ChartEditor.compute(progression);
106 106
		}
107 107

  
108
		ChartEditorPart.openEditor(progression);
108
		ChartEditor.openEditor(progression);
109 109
		
110 110
		return null;
111 111
	}
tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/editors/ProgressionEditor.java (revision 633)
20 20
import org.eclipse.swt.widgets.Text;
21 21
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences;
22 22
import org.txm.chartsengine.r.core.themes.DefaultTheme;
23
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
23
import org.txm.chartsengine.rcp.editors.ChartEditor;
24 24
import org.txm.core.results.Parameter;
25 25
import org.txm.progression.core.functions.Progression;
26 26
import org.txm.progression.core.preferences.ProgressionPreferences;
27 27
import org.txm.progression.rcp.messages.ProgressionUIMessages;
28 28
import org.txm.rcp.IImageKeys;
29 29
import org.txm.rcp.StatusLine;
30
import org.txm.rcp.editors.TXMEditorPart;
30
import org.txm.rcp.editors.TXMEditor;
31 31
import org.txm.rcp.editors.listeners.ComputeKeyListener;
32 32
import org.txm.rcp.editors.listeners.ComputeSelectionListener;
33 33
import org.txm.rcp.swt.widget.AssistedQueryWidget;
......
43 43
 * @author sjacquot
44 44
 *
45 45
 */
46
public class ProgressionEditor extends ChartEditorPart<Progression> {
46
public class ProgressionEditor extends ChartEditor<Progression> {
47 47

  
48 48

  
49 49
	/** The query widgets. */
......
326 326

  
327 327
		protected AssistedQueryWidget focusTextBox;
328 328
		
329
		protected TXMEditorPart editor;
329
		protected TXMEditor editor;
330 330
		
331 331
		/**
332 332
		 * 
tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/chartsengine/events/ProgressionSelectionListener.java (revision 633)
2 2

  
3 3
import org.eclipse.swt.events.SelectionEvent;
4 4
import org.eclipse.swt.events.SelectionListener;
5
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
5
import org.txm.chartsengine.rcp.editors.ChartEditor;
6 6

  
7 7
/**
8 8
 * Progression selection listener.
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/events/EventCallBack.java (revision 633)
6 6
import java.awt.AWTEvent;
7 7

  
8 8
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
9
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
9
import org.txm.chartsengine.rcp.editors.ChartEditor;
10 10

  
11 11
/**
12 12
 * Event call back to manage user entries events in the charts in all chart engine implementations.
......
25 25
	/**
26 26
	 * The linked Chart editor part.
27 27
	 */
28
	protected ChartEditorPart chartEditor;
28
	protected ChartEditor chartEditor;
29 29

  
30 30

  
31 31
	
......
64 64
	/**
65 65
	 * @param chartEditor the chartEditor to set
66 66
	 */
67
	public void setChartEditor(ChartEditorPart chartEditor) {
67
	public void setChartEditor(ChartEditor chartEditor) {
68 68
		this.chartEditor = chartEditor;
69 69
	}
70 70

  
......
73 73
	/**
74 74
	 * @return the chartEditor
75 75
	 */
76
	public ChartEditorPart getChartEditor() {
76
	public ChartEditor getChartEditor() {
77 77
		return chartEditor;
78 78
	}
79 79
	
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditorPart.java (revision 633)
1
package org.txm.chartsengine.rcp.editors;
2

  
3

  
4
import java.io.File;
5
import java.util.ArrayList;
6

  
7
import javax.swing.JComponent;
8

  
9
import org.eclipse.core.runtime.CoreException;
10
import org.eclipse.core.runtime.IConfigurationElement;
11
import org.eclipse.core.runtime.Platform;
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.layout.GridData;
14
import org.eclipse.swt.widgets.Composite;
15
import org.eclipse.swt.widgets.Group;
16
import org.eclipse.ui.IPartListener;
17
import org.eclipse.ui.IWorkbenchPart;
18
import org.eclipse.ui.PlatformUI;
19
import org.eclipse.ui.part.EditorPart;
20
import org.eclipse.ui.part.MultiPageEditorPart;
21
import org.txm.chartsengine.core.ChartsEngine;
22
import org.txm.chartsengine.core.results.ChartResult;
23
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
24
import org.txm.chartsengine.rcp.events.EventCallBack;
25
import org.txm.chartsengine.rcp.events.EventCallBackHandler;
26
import org.txm.chartsengine.rcp.swt.AdvancedChartEditorToolBar;
27
import org.txm.chartsengine.rcp.swt.ChartComposite;
28
import org.txm.chartsengine.rcp.swt.ChartEditorToolBar;
29
import org.txm.rcp.editors.TXMEditorPart;
30
import org.txm.utils.logger.Log;
31

  
32
/**
33
 * Base class of all charts SWT <code>EditorPart</code> subclasses.
34
 * @author sjacquot
35
 *
36
 */
37
public abstract class ChartEditorPart<T extends ChartResult> extends TXMEditorPart<ChartResult>{
38

  
39
	/**
40
	 * The tool bar.
41
	 */
42
	protected ChartEditorToolBar chartToolBar;
43

  
44
	
45
	/**
46
	 * The advanced tool bar.
47
	 */
48
	protected AdvancedChartEditorToolBar advancedChartToolBar;
49
	
50
	/**
51
	 * The advanced rendering parameters composite.
52
	 */
53
	protected Composite advancedToolBarComposite;
54
	
55
	/**
56
	 * The advanced rendering parameters group.
57
	 */
58
	protected Group advancedToolBarGroup;
59

  
60
	/**
61
	 * The chart drawing area composite.
62
	 */
63
	protected ChartComposite chartComposite;
64

  
65
	/**
66
	 * To check whether this editor was already opened when calling SWTChartsComponentsProvider.openEditor().
67
	 */
68
	protected boolean wasAlreadyOpened;
69
	
70
	/**
71
	 * The multi pages editor which contains this editor if exists.
72
	 */
73
	protected MultiPageEditorPart parentMultiPagesEditor = null;
74

  
75

  
76
	/**
77
	 * Linked editors.
78
	 */
79
	//FIXME: should be at TXMEditorPart level
80
	protected ArrayList<EditorPart> linkedEditors = null;
81
	
82
	
83
	
84
	/**
85
	 *
86
	 */
87
	public ChartEditorPart()	{
88
		super();
89
	}
90

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

  
100
	/**
101
	 * 
102
	 * @param swtComponentsProvider
103
	 * @param chartEditorInput
104
	 */
105
	protected ChartEditorPart(SWTChartsComponentsProvider swtComponentsProvider, ChartEditorInput chartEditorInput) {
106
		this.setInput(chartEditorInput);
107
		this.setPartName(chartEditorInput.getName());
108
		
109
		this.wasAlreadyOpened = false;
110
	}
111

  
112
	/**
113
	 * 
114
	 * @param chartEditorInput
115
	 */
116
	public ChartEditorPart(ChartEditorInput<ChartResult> chartEditorInput) {
117
		this(SWTChartsComponentsProvider.getCurrent(), chartEditorInput);
118
	}
119
	
120

  
121
	@Override
122
	public final void __createPartControl(Composite parent) {
123
		
124
		// Toolbar
125
		this.chartToolBar = new ChartEditorToolBar(this, SWT.FLAT | SWT.RIGHT);
126
		//this.chartToolBar = new ChartEditorToolBar(this.topToolBar, SWT.FLAT | SWT.RIGHT, this);
127
		//this.chartToolBar.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_RED));
128

  
129
		// Advanced tool bar
130
		//this.advancedToolBarComposite = new Composite(parent, SWT.NONE);
131
		Group group = this.topToolBar.installGroup("Rendering parameters", "Show/Hide rendering parameters", "platform:/plugin/org.txm.chartsengine.rcp/icons/show_rendering_parameters.png", false);
132
		this.advancedChartToolBar = new AdvancedChartEditorToolBar(group, SWT.FLAT, this);
133
//		this.advancedToolBar.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
134
//		this.advancedToolBarComposite.pack(true);
135

  
136
		// Remove parent composites
137
		//TODO MD: hack ?
138
		this.resultArea.dispose();
139
		
140
		// Chart composite
141
		this.chartComposite = this.getSWTChartsComponentsProvider().createComposite(this, parent);
142
		GridData gd = new GridData(GridData.FILL_BOTH);
143
//		gd.grabExcessVerticalSpace = true;
144
//		gd.grabExcessHorizontalSpace = true;
145
		//gd.horizontalSpan = 2; // 2 for match the command parameters toolbar AND the chart toolbar
146
		this.chartComposite.setLayoutData(gd);
147
		
148
		
149
		// Re-add the bottom toolbar
150
		//TODO MD: hack ?
151
		//this.bottomToolBar = new TXMEditorToolBar(this, SWT.FLAT, "bottom");
152
		
153
		// FIXME: open dialog box message if the composite doesn't contain any chart (typically when the charts engine doesn't contain chart creator for the specified result data type)
154
//		if(composite.getChart() == null)	{
155
//			MessageDialog.openWarning(parent.getShell(), "Warning", "Current charts engine can not create chart for " + this.getResultData().getClass().getSimpleName() + " result type. You can set another charts engine in the preferences.");
156
//		}
157
		
158
		// FIXME: background color tests
159
		//this.composite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
160
		//parent.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
161

  
162
		//this.refresh(false);
163
//
164
//		}
165
		
166
	}
167

  
168

  
169
	/**
170
	 * Initializes the default context menus.
171
	 */
172
	public void initDefaultContextMenus()	{
173
		SWTChartsComponentsProvider.initDefaultContextMenus(this.chartComposite);
174
	}
175
	
176
	/**
177
	 * 
178
	 * @param result
179
	 * @return
180
	 */
181
//	public static ChartEditorPart openEditor(ChartResult result) {
182
//		return openEditor(result, SWTChartsComponentsProvider.getCurrent());
183
//	}
184

  
185
	public static void openEditor(ChartResult result) {
186
		openEditor(result, result.getClass().getName());
187
	}
188

  
189
	
190
	public static void openEditor(ChartResult result, String editorPartId)	{
191
		compute(new ChartEditorInput(result), editorPartId, false, null);
192
	}
193

  
194
	
195
	/**
196
	 * 
197
	 * @param result
198
	 * @param chartsComponentsProvider
199
	 * @return
200
	 */
201
	public static void openEditor(ChartResult result, SWTChartsComponentsProvider chartsComponentsProvider) {
202
		compute(new ChartEditorInput(result), result.getClass().getName(), false, null);
203
		//return chartsComponentsProvider.openEditor(result);
204
	}
205

  
206
	@Override
207
	public void updateEditorFromResult(boolean update) {
208
		// nothing to do
209
	}
210
	
211
	
212
	@Override
213
	protected final void __updateEditorFromResult(boolean update) {
214
		
215
		// loading chart
216
		this.getResult().subTask("Loading chart.");
217
		this.loadChart();
218
		
219
		// if editor wasn't exist:
220
		// hiding command parameters, updating tool bar buttons states, registering context menus and event user callbacks 
221
		if(!update && !getResult().isChartDirty())	{
222
			getSite().getShell().getDisplay().syncExec(new Runnable() {
223
				@Override
224
				public void run() {
225
					// FIXME: decide if we automatically hide or not the parameter area
226
					//editor2.getTopToolbar().setComputingParametersVisible(false);
227
					
228
					// FIXME: tests to disable command if the chart is null and reenable it when the chart is computed 
229
					//editor2.getChartToolBar().synchronize();
230
					
231
					// initialize the default shared context menus as Export, etc.
232
					initDefaultContextMenus();
233
			
234
					// registers user entries event call back extensions
235
					registerEventCallBackExtensions();
236
					
237
					//FIXME: test to contribute to menu only in some context
238
					// create chart editor part context
239
	//				IContextService contextService = (IContextService)getSite().getService(IContextService.class);
240
	//				contextService.activateContext(ChartEditorPart.class.getName());
241
	//				// create chart composite context
242
	//				contextService.activateContext(this.chartComposite.getClass().getName());
243
					
244
					//FIXME: description test
245
					//editor2..setContentDescription("details");
246
					//editor2..setContentDescription(this.getResultData().getDetails());
247
	
248
					initializeAWTDelegationListeners();
249
				}
250
			});
251
		}
252
			
253
		
254
	}
255
	
256
	
257
	/**
258
	 * Registers user entries event call back extensions.
259
	 */
260
	protected void registerEventCallBackExtensions()	{
261
		String extensionPointId = "org.txm.chartsengine.eventcallback"; //$NON-NLS-1$
262
		IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointId);
263
		
264
		for(int i = 0; i < contributions.length; i++) {
265
			if(
266
				(
267
						contributions[i].getAttribute("chartsEngineName") == null || //$NON-NLS-1$ // for callback that can be used for all charts engine implementations 
268
						contributions[i].getAttribute("chartsEngineName").equals(this.getChartsEngine().getName()) //$NON-NLS-1$
269
				)
270
				&&
271
				contributions[i].getAttribute("resultDataClass") != null //$NON-NLS-1$
272
				&& contributions[i].getAttribute("resultDataClass").equals(this.getResult().getClass().getName()) //$NON-NLS-1$
273
				
274
				&& ((contributions[i].getAttribute("chartType") == null && this.getChartType() == null
275
					||
276
					contributions[i].getAttribute("chartType") != null && this.getChartType() != null && contributions[i].getAttribute("chartType").equals(this.getChartType())
277
					)  //$NON-NLS-1$
278
				)
279
				
280
			)	{
281
				try {
282
					EventCallBack eventCallBack = (EventCallBack)contributions[i].createExecutableExtension("class");  //$NON-NLS-1$
283
					
284
					eventCallBack.setChartEditor(this);
285
					
286
					EventCallBackHandler mouseHandler = this.chartComposite.getMouseCallBackHandler();
287
					if(mouseHandler != null && mouseHandler.getEventCallBack(eventCallBack.getClass()) == null)	 {
288

  
289
						Log.info("ChartEditorPart.createPartControl(): call back of type " + eventCallBack.getClass()
290
								+ " registered in mouse handler (chart editor = " + this.getClass()
291
								+ ", result data class = " + this.getResult().getClass()
292
								+ ", chart type = " + this.getChartType()
293
								+ ").");
294
						
295
						mouseHandler.registerEventCallBack(eventCallBack);
296
					}
297
					EventCallBackHandler keyboardHandler = this.chartComposite.getKeyCallBackHandler();
298
					if(keyboardHandler != null && keyboardHandler.getEventCallBack(eventCallBack.getClass()) == null)	 {
299
						
300
						Log.info("ChartEditorPart.createPartControl(): call back of type " + eventCallBack.getClass()
301
								+ " registered in key handler (chart editor = " + this.getClass()
302
								+ ", result data class = " + this.getResult().getClass()
303
								+ ", chart type = " + this.getChartType()
304
								+ ").");
305
						
306
						keyboardHandler.registerEventCallBack(eventCallBack);
307
					}
308
				}
309
				catch(CoreException e) {
310
					e.printStackTrace();
311
				}
312
				break;
313
			}
314
		}
315
		
316
	}
317
	
318
	/**
319
	 * Activate the editor in the UI.
320
	 */
321
	//FIXME: this method doesn't work for Multi pages editor, eg. can not activating CAFactorialMapEditor stored in the CAEditor
322
	public void activate()	{
323
		// Activate the parent multi pages editor instead of this editor if it exists
324
		if(this.parentMultiPagesEditor != null)	{
325
			PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate(this.parentMultiPagesEditor);
326
		}
327
		else	{
328
			// TODO: for focus and activation debug
329
//			System.out.println("ChartEditorPart.activate(): current active editor = " + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart());
330
//			System.out.println("ChartEditorPart.activate(): activating: " + this);
331
//	//		PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop(this);
332
			PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate(this);
333
//			System.out.println("ChartEditorPart.activate(): new active editor = " + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart());
334
		}
335
	}
336

  
337
	/**
338
	 * Forces the Composite to get the focus.
339
	 */
340
	public void forceFocus()	{
341
		// FIXME: debug
342
		//System.err.println("ChartEditorPart.forceFocus()");
343

  
344
		//this.chartComposite.setFocus();
345
		this.chartComposite.notifyListeners(SWT.FocusIn, null); // Needed to force the composite listener to handle the focus event
346
	}
347

  
348

  
349
	@Override
350
	public void setFocus() {
351

  
352
		// FIXME: debug
353
		//System.err.println("ChartEditorPart.setFocus()");
354

  
355
		this.chartComposite.setFocus();
356

  
357
	}
358

  
359
	
360
	
361

  
362
	/**
363
	 * Initialize Swing/AWT events delegation.
364
	 * @param swingComponent
365
	 */
366
	protected void initializeAWTDelegationListeners()	{
367
		this.getChartComposite().getChartComponent().setChartEditor(this);
368
		SWTChartsComponentsProvider.initializeAWTDelegationListeners(this, (JComponent) this.getEditorInput().getChartContainer());
369
	}
370

  
371
	/**
372
	 * Convenience method the get the casted linked editor input.
373
	 * @return the editorInput
374
	 */
375
	public ChartEditorInput<T> getEditorInput() {
376
		return (ChartEditorInput) super.getEditorInput();
377
	}
378

  
379

  
380

  
381
	/**
382
	 * Gets the chart drawing area composite.
383
	 * @return the composite
384
	 */
385
	public ChartComposite getComposite() {
386
		return this.chartComposite;
387
	}
388

  
389

  
390
	/**
391
	 * Resets the chart view (zoom, pan, rotation).
392
	 */
393
	public void resetView() {
394
		this.chartComposite.resetView();
395
	}
396

  
397
	/**
398
	 *  Clears the selected items in chart.
399
	 */
400
	public void clearChartItemsSelection()	{
401
		this.chartComposite.clearChartItemsSelection();
402
	}
403
	
404
	/**
405
	 * Zooms the chart view at x and y coordinates.
406
	 * @param x
407
	 * @param y
408
	 * @param zoomIn
409
	 */
410
	public void zoom(double x, double y, boolean zoomIn)	{
411
		this.chartComposite.zoom(x, y, zoomIn);
412
	}
413

  
414
	/**
415
	 * Pans the chart view.
416
	 * @param chartComponent
417
	 * @param srcX
418
	 * @param srcY
419
	 * @param dstX
420
	 * @param dstY
421
	 * @param panFactor
422
	 */
423
	public void pan(double srcX, double srcY, double dstX, double dstY, double panFactor)	{
424
		this.chartComposite.pan(srcX, srcY, dstX, dstY, panFactor);
425
	}
426
	
427
	
428
	/**
429
	 * Copy the current chart view to clipboard.
430
	 */
431
	public void copyChartViewToClipboard()	{
432
		this.chartComposite.copyChartViewToClipboard();
433
	}
434

  
435
	/**
436
	 * Loads the chart from the chart object stored into the composite.
437
	 * @param resetView
438
	 * @param clearChartItemsSelection
439
	 */
440
	public void loadChart()	{
441
		getSite().getShell().getDisplay().syncExec(new Runnable() {
442
			@Override
443
			public void run() {
444
				chartComposite.loadChart(
445
						getResult().needsToResetView(), 
446
						getResult().needsToClearItemsSelection());
447
			}
448
		});
449
	}
450
	
451
	/**
452
	 * Creates the chart container component from the chart object stored into the composite.
453
	 */
454
	public void createChartContainer()	{
455
		this.getSWTChartsComponentsProvider().createChartContainer(this.getEditorInput());
456
	}
457
	
458
	/**
459
	 * Disposes the editor.
460
	 * Implementations using a Composite to embed AWT/Swing components should manually call this.composite.dispose() in the redefined method.
461
	 */
462
	public void dispose()	{
463
		this.chartComposite.dispose();
464
		super.dispose();
465
	}
466

  
467
	/**
468
	 * Returns the tool bar of this editor.
469
	 * @return the toolBar
470
	 */
471
	public ChartEditorToolBar getToolBar() {
472
		return chartToolBar;
473
	}
474

  
475
	/**
476
	 * Returns the advanced tool bar of this editor.
477
	 * @return
478
	 */
479
	public AdvancedChartEditorToolBar getAdvancedToolBar()	{
480
		return this.advancedChartToolBar;
481
	}
482
	
483

  
484
	/**
485
	 * 
486
	 * @return
487
	 */
488
	public String getChartType()	{
489
		return this.getResult().getChartType();
490
	}
491
	
492
	/**
493
	 * Returns the chart associated with the editor.
494
	 * @return
495
	 */
496
	public Object getChart()	{
497
		return this.getResult().getChart();
498
	}
499
	
500
	/**
501
	 * Returns the chart components provider associated with the editor (through its <code>ChartEditorInput</code>).
502
	 * @return
503
	 */
504
	public SWTChartsComponentsProvider getSWTChartsComponentsProvider()	{
505
		return this.getEditorInput().getSWTChartsComponentsProvider();
506
	}
507

  
508
	/**
509
	 * Gets the charts engine associated with the editor (through its <code>ChartEditorInput</code>).
510
	 * @return
511
	 */
512
	public ChartsEngine getChartsEngine()	{
513
		return this.getEditorInput().getChartsEngine();
514
	}
515

  
516
	/**
517
	 * Exports the current view of the chart editor in the specified file.
518
	 * @param file
519
	 * @param fileFormat
520
	 * @return
521
	 */
522
	public File exportView(File file, String fileFormat)	{
523
		return this.getSWTChartsComponentsProvider().exportView(this, file, fileFormat);
524
	}
525

  
526
	/**
527
	 * Gets the parent multipages editor part if exists.
528
	 * @return the parentMultiPagesEditor
529
	 */
530
	public MultiPageEditorPart getParentMultiPagesEditor() {
531
		return parentMultiPagesEditor;
532
	}
533

  
534
	/**
535
	 * Sets the specified multipages editor part as parent of this one.
536
	 * @param parentMultiPagesEditor the parentMultiPagesEditor to set
537
	 */
538
	public void setParentMultiPagesEditor(MultiPageEditorPart parentMultiPagesEditor) {
539
		this.parentMultiPagesEditor = parentMultiPagesEditor;
540
	}
541

  
542
	/**
543
	 * Links the specified editor to this editor.
544
	 * @param editor
545
	 */
546
	//FIXME: should be at TXMEditorPart level
547
	public void addLinkedEditor(final EditorPart editor)	{
548
		if (this.linkedEditors == null)	{
549
			this.linkedEditors = new ArrayList<EditorPart>();
550
		}
551
		if (!this.linkedEditors.contains(editor))	{
552
			this.linkedEditors.add(editor);
553
			
554
			// FIXME: debug
555
			//System.err.println(this.getClass().getSimpleName() + ": A linked editor of type \"" + editor.getClass().getSimpleName() + "\" has been added to this one. Linked editors count: " + this.linkedEditors.size() + ".");
556
			
557
			// FIXME: temporary solution to break the link with chart editor from another TXM result editor when its closed
558
			// a better solution would be to redefine the onclose event in a root class of all TXM editors
559
			editor.getSite().getPage().addPartListener(new IPartListener() {
560

  
561
	            @Override
562
	            public void partOpened(IWorkbenchPart part) {
563
	                // TODO Auto-generated method stub
564

  
565
	            }
566

  
567
	            @Override
568
	            public void partDeactivated(IWorkbenchPart part) {
569
	                // TODO Auto-generated method stub
570

  
571
	            }
572

  
573
	            @Override
574
	            public void partClosed(IWorkbenchPart part) {
575
	            	if(part.equals(editor))	{
576
	            		// FIXME: Debug
577
		            	//System.out.println("ChartEditorPart.addLinkedEditor(...).new IPartListener() {...}.partClosed()");
578
		                // TODO Auto-generated method stub
579
		            	removeLinkedEditor(editor);
580
		            	editor.getSite().getPage().removePartListener(this);
581
	            	}
582
	            }
583

  
584
	            @Override
585
	            public void partBroughtToTop(IWorkbenchPart part) {
586
	                // TODO Auto-generated method stub
587

  
588
	            }
589

  
590
	            @Override
591
	            public void partActivated(IWorkbenchPart part) {
592
	                // TODO Auto-generated method stub
593

  
594
	            }
595
	        });
596
			
597
			
598
		}
599
	}
600
	
601
	/**
602
	 * Unlinks the specified editor from this editor.
603
	 * @param editor
604
	 */
605
	//FIXME: should be at TXMEditorPart level
606
	public void removeLinkedEditor(EditorPart editor)	{
607
		if(this.linkedEditors != null)	{
608
			if(this.linkedEditors.remove(editor))	{
609
				// FIXME: debug
610
				//System.err.println(this.getClass().getSimpleName() + ": A linked editor of type \"" + editor.getClass().getSimpleName() + "\" has been removed from this one. Linked editors count: " + this.linkedEditors.size() + ".");
611
			}
612
		}
613
		if(this.linkedEditors.isEmpty())	{
614
			this.linkedEditors = null;	
615
		}
616
	}
617
	
618
	/**
619
	 * Gets the linked editors to this one if exist.
620
	 * @return
621
	 */
622
	//FIXME: should be at TXMEditorPart level
623
	public ArrayList<EditorPart> getLinkedEditors()	{
624
		return this.linkedEditors;
625
	}
626
	
627
	/**
628
	 * Gets the first linked editor of the specified class if exists.
629
	 * @param editorClass
630
	 * @return
631
	 */
632
	//FIXME: should be at TXMEditorPart level
633
	public EditorPart getLinkedEditor(Class editorClass)	{
634
		EditorPart editor = null;
635
		if(this.linkedEditors != null) {
636
			for(int i = 0; i < this.linkedEditors.size(); i++) {
637
				if(this.linkedEditors.get(i).getClass().equals(editorClass)) {
638
					editor = this.linkedEditors.get(i);
639
					break;
640
				}
641
			}
642
		}
643
		return editor;
644
	}
645
	
646
	/**
647
	 * Gets the linked editors of the specified class if exist otherwise returns an empty list.
648
	 * @param editorClass
649
	 * @return
650
	 */
651
	//FIXME: should be at TXMEditorPart level
652
	public ArrayList<EditorPart> getLinkedEditors(Class editorClass)	{
653
		ArrayList<EditorPart> editors = new ArrayList<EditorPart>();
654
		if(this.linkedEditors != null) {
655
			for(int i = 0; i < this.linkedEditors.size(); i++) {
656
				if(this.linkedEditors.get(i).getClass().equals(editorClass)) {
657
					editors.add(this.linkedEditors.get(i));
658
				}
659
			}
660
		}
661
		return editors;
662
	}
663
	
664
	// FIXME: useless ?
665
//	/**
666
//	 * Gets the first linked editor linked to the specified editor input.
667
//	 * @param editorClass
668
//	 * @return
669
//	 */
670
//	public EditorPart getLinkedEditor(IEditorInput editorInput)	{
671
//		EditorPart editor = null;
672
//		if(this.linkedEditors != null) {
673
//			for(int i = 0; i < this.linkedEditors.size(); i++) {
674
//				if(this.linkedEditors.get(i).getEditorInput().equals(editorInput)) {
675
//					editor = this.linkedEditors.get(i);
676
//					break;
677
//				}
678
//			}
679
//		}
680
//		return editor;
681
//	}
682

  
683
	/**
684
	 * To check whether this editor was already opened when calling SWTChartsComponentsProvider.openEditor().
685
	 * @return the wasAlreadyOpened
686
	 */
687
	public boolean wasAlreadyOpened() {
688
		return wasAlreadyOpened;
689
	}
690

  
691
	/**
692
	 * To check whether this editor was already opened when calling SWTChartsComponentsProvider.openEditor().
693
	 * @param wasAlreadyOpened the wasAlreadyOpened to set
694
	 */
695
	public void setWasAlreadyOpened(boolean wasAlreadyOpened) {
696
		this.wasAlreadyOpened = wasAlreadyOpened;
697
	}
698

  
699
	/**
700
	 * Checks whatever the chart composite has the focus or not.
701
	 * @return <code>true</code> if the chart composite has the focus otherwise <code>false</code>
702
	 */
703
	public boolean hasFocus()	{
704
		return this.chartComposite.hasFocus();
705
	}
706

  
707
	/**
708
	 * Gets the chart composite.
709
	 * @return the chartComposite
710
	 */
711
	public ChartComposite getChartComposite() {
712
		return chartComposite;
713
	}
714

  
715
	/**
716
	 * Gets the chart toolbar.
717
	 * @return the chartToolBar
718
	 */
719
	public ChartEditorToolBar getChartToolBar() {
720
		return chartToolBar;
721
	}
722

  
723
	@Override
724
	public void updateResultFromEditor() {
725
		// does nothing by default
726
	}
727
	
728
	@Override
729
	public Composite getToolBarContainer(String toolbarLocalId) {
730
		if (ChartEditorToolBar.ID.equals(toolbarLocalId)) {
731
			return this.getTopToolBarContainer();
732
		}
733
		return super.getToolBarContainer(toolbarLocalId);
734
	}
735
}
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditor.java (revision 633)
1
package org.txm.chartsengine.rcp.editors;
2

  
3

  
4
import java.io.File;
5
import java.util.ArrayList;
6

  
7
import javax.swing.JComponent;
8

  
9
import org.eclipse.core.runtime.CoreException;
10
import org.eclipse.core.runtime.IConfigurationElement;
11
import org.eclipse.core.runtime.Platform;
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.layout.GridData;
14
import org.eclipse.swt.widgets.Composite;
15
import org.eclipse.swt.widgets.Group;
16
import org.eclipse.ui.IPartListener;
17
import org.eclipse.ui.IWorkbenchPart;
18
import org.eclipse.ui.PlatformUI;
19
import org.eclipse.ui.part.EditorPart;
20
import org.eclipse.ui.part.MultiPageEditorPart;
21
import org.txm.chartsengine.core.ChartsEngine;
22
import org.txm.chartsengine.core.results.ChartResult;
23
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
24
import org.txm.chartsengine.rcp.events.EventCallBack;
25
import org.txm.chartsengine.rcp.events.EventCallBackHandler;
26
import org.txm.chartsengine.rcp.swt.AdvancedChartEditorToolBar;
27
import org.txm.chartsengine.rcp.swt.ChartComposite;
28
import org.txm.chartsengine.rcp.swt.ChartEditorToolBar;
29
import org.txm.rcp.editors.TXMEditor;
30
import org.txm.utils.logger.Log;
31

  
32
/**
33
 * Base class of all charts SWT <code>EditorPart</code> subclasses.
34
 * @author sjacquot
35
 *
36
 */
37
public abstract class ChartEditor<T extends ChartResult> extends TXMEditor<ChartResult>{
38

  
39
	/**
40
	 * The tool bar.
41
	 */
42
	protected ChartEditorToolBar chartToolBar;
43

  
44
	
45
	/**
46
	 * The advanced tool bar.
47
	 */
48
	protected AdvancedChartEditorToolBar advancedChartToolBar;
49
	
50
	/**
51
	 * The advanced rendering parameters composite.
52
	 */
53
	protected Composite advancedToolBarComposite;
54
	
55
	/**
56
	 * The advanced rendering parameters group.
57
	 */
58
	protected Group advancedToolBarGroup;
59

  
60
	/**
61
	 * The chart drawing area composite.
62
	 */
63
	protected ChartComposite chartComposite;
64

  
65
	/**
66
	 * To check whether this editor was already opened when calling SWTChartsComponentsProvider.openEditor().
67
	 */
68
	protected boolean wasAlreadyOpened;
69
	
70
	/**
71
	 * The multi pages editor which contains this editor if exists.
72
	 */
73
	protected MultiPageEditorPart parentMultiPagesEditor = null;
74

  
75

  
76
	/**
77
	 * Linked editors.
78
	 */
79
	//FIXME: should be at TXMEditor level
80
	protected ArrayList<EditorPart> linkedEditors = null;
81
	
82
	
83
	
84
	/**
85
	 *
86
	 */
87
	public ChartEditor()	{
88
		super();
89
	}
90

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

  
100
	/**
101
	 * 
102
	 * @param swtComponentsProvider
103
	 * @param chartEditorInput
104
	 */
105
	protected ChartEditor(SWTChartsComponentsProvider swtComponentsProvider, ChartEditorInput chartEditorInput) {
106
		this.setInput(chartEditorInput);
107
		this.setPartName(chartEditorInput.getName());
108
		
109
		this.wasAlreadyOpened = false;
110
	}
111

  
112
	/**
113
	 * 
114
	 * @param chartEditorInput
115
	 */
116
	public ChartEditor(ChartEditorInput<ChartResult> chartEditorInput) {
117
		this(SWTChartsComponentsProvider.getCurrent(), chartEditorInput);
118
	}
119
	
120

  
121
	@Override
122
	public final void __createPartControl(Composite parent) {
123
		
124
		// Toolbar
125
		this.chartToolBar = new ChartEditorToolBar(this, SWT.FLAT | SWT.RIGHT);
126
		//this.chartToolBar = new ChartEditorToolBar(this.topToolBar, SWT.FLAT | SWT.RIGHT, this);
127
		//this.chartToolBar.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_RED));
128

  
129
		// Advanced tool bar
130
		//this.advancedToolBarComposite = new Composite(parent, SWT.NONE);
131
		Group group = this.topToolBar.installGroup("Rendering parameters", "Show/Hide rendering parameters", "platform:/plugin/org.txm.chartsengine.rcp/icons/show_rendering_parameters.png", false);
132
		this.advancedChartToolBar = new AdvancedChartEditorToolBar(group, SWT.FLAT, this);
133
//		this.advancedToolBar.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
134
//		this.advancedToolBarComposite.pack(true);
135

  
136
		// Remove parent composites
137
		//TODO MD: hack ?
138
		this.resultArea.dispose();
139
		
140
		// Chart composite
141
		this.chartComposite = this.getSWTChartsComponentsProvider().createComposite(this, parent);
142
		GridData gd = new GridData(GridData.FILL_BOTH);
143
//		gd.grabExcessVerticalSpace = true;
144
//		gd.grabExcessHorizontalSpace = true;
145
		//gd.horizontalSpan = 2; // 2 for match the command parameters toolbar AND the chart toolbar
146
		this.chartComposite.setLayoutData(gd);
147
		
148
		
149
		// Re-add the bottom toolbar
150
		//TODO MD: hack ?
151
		//this.bottomToolBar = new TXMEditorToolBar(this, SWT.FLAT, "bottom");
152
		
153
		// FIXME: open dialog box message if the composite doesn't contain any chart (typically when the charts engine doesn't contain chart creator for the specified result data type)
154
//		if(composite.getChart() == null)	{
155
//			MessageDialog.openWarning(parent.getShell(), "Warning", "Current charts engine can not create chart for " + this.getResultData().getClass().getSimpleName() + " result type. You can set another charts engine in the preferences.");
156
//		}
157
		
158
		// FIXME: background color tests
159
		//this.composite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
160
		//parent.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
161

  
162
		//this.refresh(false);
163
//
164
//		}
165
		
166
	}
167

  
168

  
169
	/**
170
	 * Initializes the default context menus.
171
	 */
172
	public void initDefaultContextMenus()	{
173
		SWTChartsComponentsProvider.initDefaultContextMenus(this.chartComposite);
174
	}
175
	
176
	/**
177
	 * 
178
	 * @param result
179
	 * @return
180
	 */
181
//	public static ChartEditor openEditor(ChartResult result) {
182
//		return openEditor(result, SWTChartsComponentsProvider.getCurrent());
183
//	}
184

  
185
	public static void openEditor(ChartResult result) {
186
		openEditor(result, result.getClass().getName());
187
	}
188

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

Formats disponibles : Unified diff