Révision 222

tmp/org.txm.specificities.core/src/org/txm/specificities/core/chartsengine/jfreechart/JFCSpecificitiesBarChartCreator.java (revision 222)
13 13
import org.jfree.ui.TextAnchor;
14 14
import org.txm.chartsengine.core.ChartsEngine;
15 15
import org.txm.chartsengine.jfreechart.core.JFCChartCreator;
16
import org.txm.chartsengine.jfreechart.core.renderers.interfaces.IItemSelectionRenderer;
16
import org.txm.chartsengine.jfreechart.core.renderers.interfaces.IRendererWithItemSelection;
17 17
import org.txm.chartsengine.jfreechart.core.themes.base.ExtendedNumberAxis;
18
import org.txm.core.messages.TXMCoreMessages;
18
import org.txm.chartsengine.jfreechart.core.themes.base.SymbolAxisBetweenTicks;
19 19
import org.txm.core.preferences.TXMPreferences;
20 20
import org.txm.specificities.core.functions.SpecificitesResult;
21 21
import org.txm.specificities.core.messages.SpecificitiesCoreMessages;
......
45 45
		JFreeChart chart = null;
46 46

  
47 47

  
48
		// FIXME: XY bar chart version
49 48
		// Create the data set
50
		final XYSeriesCollection dataset = new XYSeriesCollection();
49
		XYSeriesCollection dataset = new XYSeriesCollection();
51 50

  
51
        if(drawBars)	{
52
			// Create the bar chart
53
	        chart = this.getChartsEngine().createXYBarChart(dataset, specificitiesResult.getName(), SpecificitiesCoreMessages.ChartsEngine_SPECIFICITIES_X_AXIS_LABEL, SpecificitiesCoreMessages.ChartsEngine_SPECIFICITIES_Y_AXIS_LABEL, true, false);
54
        }
55
        else	{
56
			// Create the line chart
57
	        chart = this.getChartsEngine().createXYLineChart(dataset, specificitiesResult.getName(), SpecificitiesCoreMessages.ChartsEngine_SPECIFICITIES_X_AXIS_LABEL, SpecificitiesCoreMessages.ChartsEngine_SPECIFICITIES_Y_AXIS_LABEL,
58
	        		true, false, true, true, true, false, false);
59
        }
52 60

  
61
        ((IRendererWithItemSelection) chart.getXYPlot().getRenderer()).setChartType(ChartsEngine.CHART_TYPE_SPECIFICITIES);
62

  
63

  
64

  
65
        // Add positive banality marker
66
        Marker marker = new ValueMarker(banality);
67
        marker.setPaint(Color.RED);
68
        marker.setLabel(SpecificitiesCoreMessages.bind(SpecificitiesCoreMessages.ChartsEngine_SPECIFICITIES_BANALITY_MARKER_LABEL, banality));
69
        marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
70
        marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
71
        chart.getXYPlot().addRangeMarker(marker);
72

  
73

  
74
        // Add negative banality marker
75
        marker = new ValueMarker(-banality);
76
        marker.setPaint(Color.RED);
77
        marker.setLabel(SpecificitiesCoreMessages.bind(SpecificitiesCoreMessages.ChartsEngine_SPECIFICITIES_BANALITY_MARKER_LABEL, -banality));
78
        marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
79
        marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
80
        chart.getXYPlot().addRangeMarker(marker);
81

  
82
		return chart;
83
		
84
	}
85

  
86
	@Override
87
	public void updateChart(Object chart, Object resultData, String preferencesNode) {
88
		
89
		SpecificitesResult specificitiesResult = (SpecificitesResult) resultData;
90
		JFreeChart jfcChart = (JFreeChart) chart;
91
		
92
		// Create the data set
93
		XYSeriesCollection dataset = (XYSeriesCollection) jfcChart.getXYPlot().getDataset();
94
		dataset.removeAllSeries();
53 95
		String[] xAxisSymbols;
54 96

  
55 97
		// Transpose the data set
56
		if(transpose)	{
98
		if(TXMPreferences.getBoolean(preferencesNode, resultData, SpecificitiesPreferences.CHART_TRANSPOSE))	{
57 99
	        xAxisSymbols = new String[specificitiesResult.getSelectedTypeNames().length];
58 100

  
59 101
			for(int i = 0; i < specificitiesResult.getSelectedPartNames().length; i++) {
60 102
				XYSeries series = new XYSeries(specificitiesResult.getSelectedPartNames()[i]);
61 103
				dataset.addSeries(series);
62 104

  
63

  
64 105
				for(int j = 0; j < specificitiesResult.getSelectedTypeNames().length; j++) {
65 106
					series.add(j, specificitiesResult.getSelectedSpecificitiesIndex()[j][i]);
66 107
					// Add X axis symbol
......
84 125
				}
85 126
			}
86 127
		}
87

  
88
        if(drawBars)	{
89
			// Create the bar chart
90
	        chart = this.getChartsEngine().createXYBarChart(dataset, specificitiesResult.getName(), SpecificitiesCoreMessages.ChartsEngine_SPECIFICITIES_X_AXIS_LABEL, SpecificitiesCoreMessages.ChartsEngine_SPECIFICITIES_Y_AXIS_LABEL, true, false, false, xAxisSymbols);
91
        }
92
        else	{
93
			// Create the line chart
94
	        chart = this.getChartsEngine().createXYLineChart(dataset, specificitiesResult.getName(), SpecificitiesCoreMessages.ChartsEngine_SPECIFICITIES_X_AXIS_LABEL, SpecificitiesCoreMessages.ChartsEngine_SPECIFICITIES_Y_AXIS_LABEL,
95
	        		true, false, true, true, true, false, false, xAxisSymbols);
96
        }
97

  
98
        ((IItemSelectionRenderer) chart.getXYPlot().getRenderer()).setChartType(ChartsEngine.CHART_TYPE_SPECIFICITIES);
99

  
100

  
128
		
101 129
        // Custom range axis for ticks drawing options
102
        double minimumValue = DatasetUtilities.findMinimumRangeValue(chart.getXYPlot().getDataset()).doubleValue();
103
        double maximumValue = DatasetUtilities.findMaximumRangeValue(chart.getXYPlot().getDataset()).doubleValue();
130
        double minimumValue = DatasetUtilities.findMinimumRangeValue(jfcChart.getXYPlot().getDataset()).doubleValue();
131
        double maximumValue = DatasetUtilities.findMaximumRangeValue(jfcChart.getXYPlot().getDataset()).doubleValue();
104 132
        // Adjust ticks values according to data set contains only positives values or only negatives values
105 133
        if(minimumValue > 0)	{
106 134
        	minimumValue = 0;
107 135
        }
108 136
        if(maximumValue < 0)	{
109
        	maximumValue = banality;
137
        	maximumValue = TXMPreferences.getFloat(preferencesNode, resultData, SpecificitiesPreferences.CHART_BANALITY);
110 138
        }
111

  
112 139
        // Custom range axis to cut the values to minimum and maximum values
113
        chart.getXYPlot().setRangeAxis(new ExtendedNumberAxis((NumberAxis) chart.getXYPlot().getRangeAxis(), true, true, minimumValue, maximumValue));
140
        jfcChart.getXYPlot().setRangeAxis(new ExtendedNumberAxis((NumberAxis) jfcChart.getXYPlot().getRangeAxis(), true, true, minimumValue, maximumValue));
141
		
142
        jfcChart.getXYPlot().setDomainAxis(new SymbolAxisBetweenTicks(SpecificitiesCoreMessages.ChartsEngine_SPECIFICITIES_X_AXIS_LABEL, xAxisSymbols));
114 143

  
115

  
116
        // Add positive banality marker
117
        Marker marker = new ValueMarker(banality);
118
        marker.setPaint(Color.red);
119
        marker.setLabel(SpecificitiesCoreMessages.bind(SpecificitiesCoreMessages.ChartsEngine_SPECIFICITIES_BANALITY_MARKER_LABEL, banality));
120
        marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
121
        marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
122
        chart.getXYPlot().addRangeMarker(marker);
123

  
124

  
125
        // Add negative banality marker
126
        marker = new ValueMarker(-banality);
127
        marker.setPaint(Color.red);
128
        marker.setLabel(SpecificitiesCoreMessages.bind(SpecificitiesCoreMessages.ChartsEngine_SPECIFICITIES_BANALITY_MARKER_LABEL, -banality));
129
        marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
130
        marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
131
        chart.getXYPlot().addRangeMarker(marker);
132

  
133

  
134

  
135
		// FIXME: Category bar chart version
136
//		// Create the data set
137
//		final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
138
//
139
//		// Transpose the data set
140
//		if(transpose)	{
141
//			for(int i = 0; i < specificitiesResult.getSelectedTypeNames().length; i++) {
142
//				for(int j = 0; j < specificitiesResult.getSelectedPartNames().length; j++) {
143
//					dataset.addValue(specificitiesResult.getSelectedSpecificitiesIndex()[i][j],
144
//							specificitiesResult.getSelectedPartNames()[j],
145
//							specificitiesResult.getSelectedTypeNames()[i]);
146
//				}
147
//			}
148
//		}
149
//		else {
150
//			for(int i = 0; i < specificitiesResult.getSelectedPartNames().length; i++) {
151
//				for(int j = 0; j < specificitiesResult.getSelectedTypeNames().length; j++) {
152
//					dataset.addValue(specificitiesResult.getSelectedSpecificitiesIndex()[j][i],
153
//							specificitiesResult.getSelectedTypeNames()[j],
154
//							specificitiesResult.getSelectedPartNames()[i]);
155
//				}
156
//			}
157
//		}
158
//
159
//        if(drawBars)	{
160
//			// Create the bar chart
161
//	        chart = this.createCategoryBarChart(dataset, specificitiesResult.getName(), ChartsEngineMessages.ChartsEngine_SPECIFICITIES_X_AXIS_LABEL, ChartsEngineMessages.ChartsEngine_SPECIFICITIES_Y_AXIS_LABEL, true, false);
162
//        }
163
//        else	{
164
//			// Create the line chart
165
//	        chart = this.createCategoryLineChart(dataset, specificitiesResult.getName(), ChartsEngineMessages.ChartsEngine_SPECIFICITIES_X_AXIS_LABEL, ChartsEngineMessages.ChartsEngine_SPECIFICITIES_Y_AXIS_LABEL, true, false);
166
//        }
167
//        ((IItemSelectionRenderer) chart.getCategoryPlot().getRenderer()).setChartType(ChartsEngine.CHART_TYPE_SPECIFICITIES);
168
//
169
//
170
//        // Custom range axis for ticks drawing options
171
//        double minimumValue = DatasetUtilities.findMinimumRangeValue(chart.getCategoryPlot().getDataset()).doubleValue();
172
//        double maximumValue = DatasetUtilities.findMaximumRangeValue(chart.getCategoryPlot().getDataset()).doubleValue();
173
//        // Adjust ticks values according to data set contains only positives values or only negatives values
174
//        if(minimumValue > 0)	{
175
//        	minimumValue = 0;
176
//        }
177
//        if(maximumValue < 0)	{
178
//        	maximumValue = banality;
179
//        }
180
//
181
//        // Custom range axis to cut the values to minimum and maximum values
182
//        chart.getCategoryPlot().setRangeAxis(new ExtendedNumberAxis((NumberAxis) chart.getCategoryPlot().getRangeAxis(), true, true, minimumValue, maximumValue));
183
//
184
//
185
//        // Add positive banality marker
186
//        Marker marker = new ValueMarker(banality);
187
//        marker.setPaint(Color.red);
188
//        marker.setLabel(JFreeChartsEngineMessages.bind(ChartsEngineMessages.ChartsEngine_SPECIFICITIES_BANALITY_MARKER_LABEL, banality));
189
//        marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
190
//        marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
191
//        chart.getCategoryPlot().addRangeMarker(marker);
192
//
193
//
194
//        // Add negative banality marker
195
//        marker = new ValueMarker(-banality);
196
//        marker.setPaint(Color.red);
197
//        marker.setLabel(JFreeChartsEngineMessages.bind(ChartsEngineMessages.ChartsEngine_SPECIFICITIES_BANALITY_MARKER_LABEL, -banality));
198
//        marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
199
//        marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
200
//        chart.getCategoryPlot().addRangeMarker(marker);
201

  
202

  
203
//        int itemsColorsRenderingMode = Theme.ITEMS_RENDERING_COLORS_MODE;
204
//		// Grayscale
205
//        if(grayscale)	{
206
//        	itemsColorsRenderingMode = Theme.ITEMS_RENDERING_GRAYSCALE_MODE;
207
//        }
208
//
209
//        // Re-apply theme to the chart to match the colors rendering mode
210
//        // FIXME : the rendering mode should be pass to all methods, even base methods as createXYLineChart(), createBarChart(), etc.
211
//		this.theme.applyThemeToChart(chart, itemsColorsRenderingMode);
212

  
213
		return chart;
144
        
145
		super.updateChart(chart, resultData, preferencesNode);
214 146
		
147
		
215 148
	}
149
	
216 150

  
217

  
218 151
	@Override
219 152
	public Class getResultDataClass() {
220 153
		return SpecificitesResult.class;
tmp/org.txm.index.rcp/META-INF/MANIFEST.MF (revision 222)
10 10
 org.eclipse.core.runtime;bundle-version="3.10.0",
11 11
 org.txm.rcp,
12 12
 org.txm.r;bundle-version="1.0.0"
13
Export-Package: org.txm.index.rcp.adapters,
14
 org.txm.index.rcp.editors,
15
 org.txm.index.rcp.handlers
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/SWTChartsComponentsProvider.java (revision 222)
551 551
		page.addField(new BooleanFieldEditor(ChartsEnginePreferences.SHOW_GRID, SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_GRID, composite));
552 552

  
553 553
		// Rendering colors mode selection
554
		String colorsModes[][] = new String[3][2];
554
		String colorsModes[][] = new String[4][2];
555 555
		colorsModes[0][0] = SWTComponentsProviderMessages.ChartsEnginePreferencePage_RenderingModeColors;
556 556
		colorsModes[0][1] = "0"; //$NON-NLS-1$
557 557
		colorsModes[1][0] = SWTComponentsProviderMessages.ChartsEnginePreferencePage_RenderingModeGrayscale;
558 558
		colorsModes[1][1] = "1"; //$NON-NLS-1$
559 559
		colorsModes[2][0] = SWTComponentsProviderMessages.ChartsEnginePreferencePage_RenderingModeBlackAndWhite;
560 560
		colorsModes[2][1] = "2"; //$NON-NLS-1$
561
		colorsModes[3][0] = SWTComponentsProviderMessages.ChartsEnginePreferencePage_RenderingModeMonochrome;
562
		colorsModes[3][1] = "3"; //$NON-NLS-1$
563

  
561 564
		
562 565
		ComboFieldEditor renderingModeComboField = new ComboFieldEditor(ChartsEnginePreferences.RENDERING_COLORS_MODE, SWTComponentsProviderMessages.ChartsEnginePreferencePage_RenderingColorsMode, colorsModes, composite);
563 566
		page.addField(renderingModeComboField);
......
750 753
	
751 754
	
752 755
	/**
753
	 * Copy a chart as image in the clipboard from the specified chart component.
754
	 * @param chartComponent
755
	 */
756
	public abstract void copyChartToClipboard(Object chartComponent);
757
	
758
	
759
	/**
760 756
	 * 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.
761 757
	 * @param editorPart
762 758
	 * @param editorId
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/events/BaseSelectionListener.java (revision 222)
1
package org.txm.chartsengine.rcp.events;
2

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

  
8
/**
9
 * SWT base selection listener shared by all charts implementing call backs for resetting view, export view, etc.
10
 * @author sjacquot
11
 *
12
 */
13
public class BaseSelectionListener implements SelectionListener {
14

  
15

  
16
	/**
17
	 * Command constants.
18
	 */
19
	public final static int RESET_VIEW = 0, EXPORT_VIEW = 1, SEND_TO_INDEX = 2, SEND_TO_EDITION = 3, SEND_TO_CONCORDANCE = 4, SEND_TO_COOCCURRENCE = 5;
20

  
21

  
22
	/**
23
	 * Chart editor.
24
	 */
25
	protected ChartEditorPart chartEditor;
26

  
27
	/**
28
	 * Command ID.
29
	 */
30
	protected int commandId;
31

  
32

  
33
	/**
34
	 *
35
	 * @param chartEditor
36
	 */
37
	public BaseSelectionListener(ChartEditorPart chartEditor, int commandId) {
38
		this.chartEditor = chartEditor;
39
		this.commandId = commandId;
40
	}
41

  
42

  
43

  
44
	@Override
45
	public void widgetSelected(SelectionEvent e) {
46
		// Reset view
47
		if(this.commandId == BaseSelectionListener.RESET_VIEW)	{
48
			this.chartEditor.resetView();
49
			this.chartEditor.forceFocus();
50
		}
51
		// Export view
52
		else if(this.commandId == BaseSelectionListener.EXPORT_VIEW)	{
53

  
54
			ExportChartEditorView exportChartEditorView = new ExportChartEditorView();
55
			try {
56
				// FIXME : can null argument make trouble ?
57
				// FIXME: yes the problem here is that you can't get the application context from the ExecutionEvent in the command
58
				exportChartEditorView.execute(null);
59

  
60
//				// Manually execute the command
61
////				Command command = ((ICommandService)this.chartEditor.getSite().getService(ICommandService.class)).getCommand(ExportChartEditorView.ID);
62
////				Event trigger = new Event();
63
////				trigger.widget = (Widget) e.getSource();
64
////				exportChartEditorView.execute(((IHandlerService)this.chartEditor.getSite().getService(IHandlerService.class)).createExecutionEvent(command, trigger));
65
//
66
//				// FIXME: test 2
67
//				// Manually execute the command
68
//				Command command = ((ICommandService)this.chartEditor.getSite().getService(ICommandService.class)).getCommand(ExportChartEditorView.ID);
69
//				Event trigger = new Event();
70
//				trigger.widget = (Widget) e.getSource();
71
//				trigger.data = this.chartEditor;
72
//
73
////System.out.println("BaseSelectionListener.widgetSelected() " + e.getSource());
74
//
75
//				((IHandlerService)this.chartEditor.getSite().getService(IHandlerService.class)).executeCommand(ExportChartEditorView.ID, trigger);
76
//
77
////				ExecutionEvent executionEvent = ((IHandlerService)this.chartEditor.getSite().getService(IHandlerService.class)).createExecutionEvent(command, trigger);
78
////				command.executeWithChecks(executionEvent);
79
//
80
//
81
//				//executionEvent.
82
//
83
//				// From a view you get the site which allow to get the service
84
////				EHandlerService handlerService = ((IHandlerService)this.chartEditor.getSite().getService(IHandlerService.class)).createExecutionEvent(command, event);
85
////				try {
86
////					handlerService.executeCommand(exportChartEditorView, null);
87
////				  } catch (Exception ex) {
88
////				    throw new RuntimeException("add.command not found");
89
////				    // Give message
90
////				    }
91

  
92
			}
93
			catch(Exception e1) {
94
				// TODO Auto-generated catch block
95
				e1.printStackTrace();
96
			}
97
		}
98
	}
99

  
100
	@Override
101
	public void widgetDefaultSelected(SelectionEvent e) {
102
		// TODO Auto-generated method stub
103

  
104
	}
105

  
106
}
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/messages/SWTComponentsProviderMessages.java (revision 222)
23 23
	public static String ChartsEnginePreferencePage_RenderingModeBlackAndWhite;
24 24
	public static String ChartsEnginePreferencePage_RenderingModeColors;
25 25
	public static String ChartsEnginePreferencePage_RenderingModeGrayscale;
26
	public static String ChartsEnginePreferencePage_RenderingModeMonochrome;
27
	public static String ChartsEnginePreferencePage_RenderingMonochromeColor;
26 28

  
27 29
	public static String ChartsEngineSharedPreferencePage_CHARTS_RENDERING_DEFAULT_PREFERENCES;
28 30
	
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditorInput.java (revision 222)
17 17
 */
18 18
public class ChartEditorInput implements IEditorInput {
19 19

  
20

  
20 21
	/**
22
	 * 
23
	 */
24
	protected boolean alwaysRecreateEditor;
25
	
26
	/**
21 27
	 * The name.
22 28
	 */
23 29
	protected String name;
......
95 101
		this.preferencesNodeQualifier = preferencesNodeQualifier;
96 102
		this.chartType = chartType;
97 103
		this.chartContainer = chartContainer;
104
		this.alwaysRecreateEditor = false;
98 105
	}
99 106

  
100 107
	
......
216 223
		return this.swtChartsComponentsProvider.getChartsEngine();
217 224
	}
218 225
	
219
	
220
	@Override
221
	public boolean equals(Object obj)	{
222
		if(obj instanceof ChartEditorInput)	{
223
			// FIXME: validate these tests for all chart editors
224
//			if(this == obj)	{
225
//				return true;
226
//			};
227
			// Always recreate an editor for specificites result
228
//			if(((ChartEditorInput) obj).getResultData() instanceof SpecificitesResult)	{
229
//				return false;
230
//			}
231
			// Always recreate an editor for partition dimension result
232
			if(((ChartEditorInput) obj).getResultData() instanceof Partition)	{
233
				return false;
234
			}
235
			return this.resultData == ((ChartEditorInput) obj).getResultData();
236
		}
237
		return false;
238
	}
239 226

  
240

  
241

  
242 227
	/**
243 228
	 * @return the chartContainer
244 229
	 */
......
293 278
		TXMPreferences.putLocalString(this.resultData, ChartsEnginePreferences.RESULT_DATA_TYPE, this.resultData.getClass().getName());
294 279
	}
295 280
	
281

  
282

  
283
	/**
284
	 * If <code>true</code>, a new chart editor part will always be recreated even for the same TXM result object. 
285
	 * @param alwaysRecreateEditor the alwaysRecreateEditor to set
286
	 */
287
	public void setAlwaysRecreateEditor(boolean alwaysRecreateEditor) {
288
		this.alwaysRecreateEditor = alwaysRecreateEditor;
289
	}
290

  
296 291
	
292
	
293
	@Override
294
	public boolean equals(Object obj)	{
295
		if(obj instanceof ChartEditorInput)	{
296
			if(this.alwaysRecreateEditor)	{
297
				return false;
298
			}
299
			return this.resultData == ((ChartEditorInput) obj).getResultData();
300
		}
301
		return false;
302
	}
303

  
304
	
297 305
}
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditorPart.java (revision 222)
11 11
import org.eclipse.swt.SWT;
12 12
import org.eclipse.swt.events.SelectionEvent;
13 13
import org.eclipse.swt.events.SelectionListener;
14
import org.eclipse.swt.layout.FormAttachment;
15
import org.eclipse.swt.layout.FormData;
16
import org.eclipse.swt.layout.FormLayout;
14
import org.eclipse.swt.layout.GridData;
15
import org.eclipse.swt.layout.GridLayout;
17 16
import org.eclipse.swt.layout.RowLayout;
18 17
import org.eclipse.swt.widgets.Composite;
19 18
import org.eclipse.swt.widgets.Group;
......
26 25
import org.eclipse.ui.PlatformUI;
27 26
import org.eclipse.ui.part.EditorPart;
28 27
import org.eclipse.ui.part.MultiPageEditorPart;
29
import org.eclipse.ui.plugin.AbstractUIPlugin;
30 28
import org.txm.chartsengine.core.ChartsEngine;
31 29
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
32 30
import org.txm.chartsengine.rcp.events.EventCallBack;
33 31
import org.txm.chartsengine.rcp.events.EventCallBackHandler;
32
import org.txm.chartsengine.rcp.swt.AdvancedChartEditorToolBar;
34 33
import org.txm.chartsengine.rcp.swt.ChartComposite;
35 34
import org.txm.chartsengine.rcp.swt.ChartEditorToolBar;
36 35
import org.txm.functions.TXMResult;
37 36
import org.txm.rcp.editors.TXMEditorPart;
38
import org.txm.rcpapplication.Application;
37
import org.txm.rcpapplication.IImageKeys;
39 38
import org.txm.utils.logger.Log;
40 39

  
41 40
/**
......
47 46

  
48 47

  
49 48
	/**
50
	 * The <code>EditorPart</code> ID constant. 
51
	 */
52
	//protected static final String ID =  ChartEditorPart.class.getCanonicalName();
53
	 
54
	/**
55 49
	 * The tool bar.
56 50
	 */
57 51
	protected ChartEditorToolBar toolBar;
58 52

  
59
	protected Composite parametersComposite;
60 53
	
61
	protected Group parametersGroup;
54
	/**
55
	 * The advanced tool bar.
56
	 */
57
	protected AdvancedChartEditorToolBar advancedToolBar;
62 58
	
59
	protected Composite advancedToolBarComposite;
60
	protected Group advancedToolBarGroup;
61
	
62
	
63
	protected Composite commandParametersComposite;
64
	protected Group commandParametersGroup;
65
	
63 66

  
64 67
	/**
65 68
	 * The chart drawing area composite.
......
118 121

  
119 122
	
120 123

  
121
//	/**
122
//	 * Gets the <code>EditorPart</code> ID.
123
//	 * @return the ID
124
//	 */
125
//	public abstract String getID();
126

  
127

  
128

  
129 124
	@Override
130 125
	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
131 126
		this.setSite(site);
132 127
		this.setInput(input);
133 128
		// FIXME: see how to use the Adapters and AdapterFactory to define image and title of Editor in the contributing plug-ins
134 129
		// another way is to use editors extension in plug-ins and redefine icon and name, using this solution the problem is that the name (which is also editor title) can not be dynamic according to the result data
135
		// so it seems better to use Adapters if that's possible
130
		// so it seems better to use Adapters if it's possible
136 131
		this.setPartName(input.getName());
137 132
	}
138 133

  
139 134

  
140
	@Override
141
	public void createPartControl(Composite parent) {
142

  
143
		super.createPartControl(parent);
135
	
136
	public Group initGroup(final Composite composite, String groupTitle, String buttonToolTip, String iconFilePath)	{
144 137
		
145
		// Test, original code
146
		FormLayout mainLayout = new FormLayout();
138
		final Group group = new Group(composite, SWT.NONE);
139
		group.setText(groupTitle);
147 140
		
148
//		mainLayout.marginHeight = 5;
149
//		mainLayout.marginWidth = 5;
141
//		GridData gd1 = new GridData();
142
//		group.setLayoutData(gd1);
143
//		gd1.exclude = true;
144
//		group.setVisible(false);
150 145
		
151
		mainLayout.marginTop = 3;
152
		mainLayout.marginLeft = 0;
153
		mainLayout.spacing = 3;
154
		parent.setLayout(mainLayout);
146
		RowLayout layout = new RowLayout();
147
//		layout.marginLeft = 10;
148
//		layout.marginTop = 10;
149
//		layout.spacing = 8;
150
		layout.wrap = true;
151
		layout.center = true;
152
		group.setLayout(layout);
155 153

  
156 154
		
157
//		parent.setLayout(new RowLayout(SWT.VERTICAL));
158
//		parent.setLayoutData(new RowData(50, 40));
159

  
160

  
161
		// Toolbar
162
		// FIXME: tests
163
		//this.toolBar = new ChartEditorToolBar(parent, SWT.FLAT | SWT.SHADOW_OUT, this);
164
		this.toolBar = new ChartEditorToolBar(parent, SWT.FLAT, this);
155
		GridData gd2 = new GridData(GridData.FILL_BOTH);;
156
		gd2.grabExcessVerticalSpace = false;
157
		gd2.grabExcessHorizontalSpace = true;
158
		gd2.exclude = true;
159
		composite.setLayoutData(gd2);
160
		composite.setVisible(false);
165 161
		
166 162
		
167
		// FIXME: dimensions/margin tests
168
//		this.toolBar.computeSize(1500, 800, true);
169
//		this.toolBar.setBounds(200, 400, 1500, 300);
170
//		this.toolBar.pack();
171
//		this.toolBar.setSize(1500, 800);
172

  
173

  
174
		// FIXME: command parameters composite
175
		this.parametersComposite = new Composite(parent, SWT.NONE);
163
//		FormData formData = new FormData();
164
//		formData.top = new FormAttachment(this.toolBar);
165
//		//formData.bottom = new FormAttachment(100);
166
//		formData.left = new FormAttachment(0);
167
//		formData.right = new FormAttachment(100);
168
//		formData.height = 0;
169
//		composite.setLayoutData(formData);
176 170
		
177

  
178
		// FIXME: group tests
179
		this.parametersGroup = new Group(this.parametersComposite, SWT.NONE);
180
		this.parametersGroup.setText("Command parameters");
181
		RowLayout layout1 = new RowLayout();
182
		layout1.marginLeft = 10;
183
		layout1.marginTop = 10;
184
		layout1.spacing = 8;
185
		layout1.wrap = true;
186
		layout1.center = true;
187
		this.parametersGroup.setLayout(layout1);
188

  
171
		//composite.setBackground(new Color (Display.getCurrent(), 255, 0, 0));
189 172
		
173
//		RowLayout layout2 = new RowLayout();
174
//		layout2.marginLeft = 10;
175
//		layout2.marginTop = 10;
176
//		layout2.spacing = 8;
177
//		layout2.wrap = true;
178
//		layout2.center = true;
179
//		composite.setLayout(layout2);
180
//		
181
//		
182
//		composite.setVisible(false);
183
//		composite.getParent().layout(true);
190 184
		
191
		FormData formData = new FormData();
192
		formData.top = new FormAttachment(this.toolBar);
193
		//formData.bottom = new FormAttachment(100);
194
		formData.left = new FormAttachment(0);
195
		formData.right = new FormAttachment(100);
196
		formData.height = 0;
197
		this.parametersComposite.setLayoutData(formData);
198 185
		
199
		//this.parametersComposite.setBackground(new Color (Display.getCurrent(), 255, 0, 0));
200
		
201
		RowLayout layout = new RowLayout();
202
		layout.marginLeft = 10;
203
		layout.marginTop = 10;
204
		layout.spacing = 8;
205
		layout.wrap = true;
206
		layout.center = true;
207
		this.parametersComposite.setLayout(layout);
208
		//this.parametersGroup.setLayout(layout);
209
		
210
		
211
		this.parametersComposite.setVisible(false);
212
		this.parametersComposite.getParent().layout(true);
213
		
214
		
215
		// FIXME: tests show/hide parameters
186
		// FIXME: tests show/hide computing parameters
216 187
		final ToolItem showParameters = new ToolItem(this.toolBar, SWT.CHECK);
217
		showParameters.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, "platform:/plugin/org.txm.rcp/icons/add.png").createImage());
218
		showParameters.setToolTipText("Show/Hide command parameters");
188
		showParameters.setImage(IImageKeys.getImage(this, iconFilePath));
189
		showParameters.setToolTipText(buttonToolTip);
219 190
		showParameters.setSelection(false);
220 191
		
221 192
		showParameters.addSelectionListener(new SelectionListener() {
......
223 194
			@Override
224 195
			public void widgetSelected(SelectionEvent e) {
225 196
				
226
				parametersComposite.pack();
227
				int height = 0; 
228
				if(showParameters.getSelection())	{
229
					height = parametersComposite.getSize().y;
230
				}
231
				((FormData)parametersComposite.getLayoutData()).height = height;
232
				parametersComposite.getParent().layout(true);
233
				parametersComposite.setVisible(showParameters.getSelection());
197
				((GridData)composite.getLayoutData()).exclude = !showParameters.getSelection();
198
				composite.setVisible(showParameters.getSelection());
199
				composite.getParent().layout(true);
200
				
234 201
			}
235 202
			
236 203
			@Override
......
240 207
			}
241 208
		});
242 209
		
210
		return group;
211
		//return null;
243 212

  
213
	}
214
	
215
	@Override
216
	public void createPartControl(Composite parent) {
217

  
218
		super.createPartControl(parent);
244 219
		
220
		// Test, original code
221
//		FormLayout mainLayout = new FormLayout();
222
////		mainLayout.marginHeight = 5;
223
////		mainLayout.marginWidth = 5;
224
//		mainLayout.marginTop = 3;
225
//		mainLayout.marginLeft = 0;
226
//		mainLayout.spacing = 3;
227
//		parent.setLayout(mainLayout);
228

  
229

  
230
		// tests for set visible
231
		GridLayout gl = new GridLayout();
232
		gl.marginTop = 5;
233
		gl.marginHeight = 0;
234
		gl.marginWidth = 0;
235
		parent.setLayout(gl);
236

  
237

  
238
		// Toolbar
239
		// FIXME: tests
240
		//this.toolBar = new ChartEditorToolBar(parent, SWT.FLAT | SWT.SHADOW_OUT, this);
241
		this.toolBar = new ChartEditorToolBar(parent, SWT.FLAT, this);
242
		//this.toolBar.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
245 243
		
244
//		// FIXME: Tab folder tests
245
//		final TabFolder tabFolder = new TabFolder(parent, SWT.TOP);
246
//		GridData gd1 = new GridData();
247
//		tabFolder.setLayoutData(gd1);
248
//		gd1.exclude = true;
249
//		tabFolder.setVisible(false);
250
//		
251
//		// Command parameters
252
//		TabItem tabItem2 = new TabItem(tabFolder, SWT.NULL);
253
//		tabItem2.setText("Command parameters");
254
//		this.commandParametersComposite = new Composite(tabFolder, SWT.NONE);
255
//		RowLayout layout2 = new RowLayout();
256
//		layout2.marginLeft = 10;
257
//		layout2.marginTop = 10;
258
//		layout2.spacing = 8;
259
//		layout2.wrap = true;
260
//		layout2.center = true;
261
//		this.commandParametersComposite.setLayout(layout2);
262
//		tabItem2.setControl(this.commandParametersComposite);
263
//
264
//		// Charts rendering advanced tool bar
265
//		TabItem tabItem = new TabItem(tabFolder, SWT.NULL);
266
//		tabItem.setText("Charts rendering");
267
//		this.advancedToolBar = new AdvancedChartEditorToolBar(tabFolder, SWT.FLAT, this);
268
//		tabItem.setControl(this.advancedToolBar);
269
////		this.advancedToolBar.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
270
//		
271
//		
272
//		// FIXME: tests show/hide computing parameters
273
//		final ToolItem showParameters = new ToolItem(this.toolBar, SWT.CHECK);
274
//		showParameters.setImage(IImageKeys.getImage(this, "platform:/plugin/org.txm.rcp/icons/add.png"));
275
//		showParameters.setToolTipText("Show/hide advanced parameters");
276
//		showParameters.setSelection(false);
277
//		
278
//		showParameters.addSelectionListener(new SelectionListener() {
279
//			
280
//			@Override
281
//			public void widgetSelected(SelectionEvent e) {
282
//				
283
//				
284
//				((GridData)tabFolder.getLayoutData()).exclude = !showParameters.getSelection();
285
//				tabFolder.setVisible(showParameters.getSelection());
286
//				tabFolder.getParent().layout(true);
287
//			}
288
//			
289
//			@Override
290
//			public void widgetDefaultSelected(SelectionEvent e) {
291
//				// TODO Auto-generated method stub
292
//				
293
//			}
294
//		});
295
//		
296
//		// adapt the height of the tab folder to current tab height
297
//		tabFolder.addSelectionListener(new SelectionAdapter() {
298
//			@Override
299
//			public void widgetSelected(SelectionEvent event) {
300
//				tabFolder.getSelection()[0].getControl().pack(true);
301
//				System.out.println("ChartEditorPart.createPartControl(...).new SelectionAdapter() {...}.widgetSelected(): current tab bounds " + tabFolder.getSelection()[0].getControl().getBounds());
302
//				//tabFolder.setBounds(tabFolder.getBounds().x, tabFolder.getBounds().y, tabFolder.getBounds().width, tabFolder.getSelection()[0].getControl().getBounds().height * 2);
303
//				//tabFolder.layout(true);
304
//				//tabFolder.pack();
305
//			}
306
//		});
307

  
308
		new ToolItem(this.toolBar, SWT.SEPARATOR);
309
		
310
		
311
		// Tests with groups instead of tabs 
312
		// FIXME: command parameters composite
313
		this.commandParametersComposite = new Composite(parent, SWT.NONE);
314
		this.commandParametersGroup = this.initGroup(this.commandParametersComposite, "Computing parameters", "Show/Hide command parameters", "icons/show_computing_parameters.png");
315
		this.commandParametersGroup.pack();
316
		
317
		
318
		
319
		// Advanced tool bar
320
		this.advancedToolBarComposite = new Composite(parent, SWT.NONE);
321
		Group group = this.initGroup(this.advancedToolBarComposite, "Rendering parameters", "Show/Hide rendering parameters", "icons/show_rendering_parameters.png");
322
		this.advancedToolBar = new AdvancedChartEditorToolBar(group, SWT.FLAT, this);
323
//		this.advancedToolBar.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
324
		this.advancedToolBarComposite.pack(true);
325
		group.pack(true);
326
		this.advancedToolBar.pack(true);
327
		
328

  
329
		
330
		
246 331
		// FIXME: background color tests
247 332
		//this.toolBar.setBackground(parent.getBackground());
248 333
		//this.toolBar.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
249 334

  
250 335
		// Chart composite
251
		ChartComposite composite = this.getSWTChartsComponentsProvider().createComposite(this, parent);
252

  
253
//		FormData formData2 = new FormData();
254
//		formData2.top = new FormAttachment(toolBarsComposite, 10);
255
//		composite.setLayoutData(formData2);
336
		ChartComposite chartComposite = this.getSWTChartsComponentsProvider().createComposite(this, parent);
337
		GridData gd = new GridData(GridData.FILL_BOTH);
338
		gd.grabExcessVerticalSpace = true;
339
		gd.grabExcessHorizontalSpace = true;
340
		chartComposite.setLayoutData(gd);
256 341
		
257
		
258 342
		// 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)
259 343
//		if(composite.getChart() == null)	{
260 344
//			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.");
......
267 351
		
268 352
		
269 353
		// initialize the default shared context menus as Export, etc.
270
		SWTChartsComponentsProvider.initDefaultContextMenus(composite);
354
		SWTChartsComponentsProvider.initDefaultContextMenus(chartComposite);
271 355

  
272 356
		
273 357
		// registers user entries event call back extensions
358
		this.registerEventCallBackExtensions();
359
	}
360

  
361

  
362
	/**
363
	 * Registers user entries event call back extensions.
364
	 */
365
	protected void registerEventCallBackExtensions()	{
274 366
		String extensionPointId = "org.txm.chartsengine.eventcallback"; //$NON-NLS-1$
275 367
		IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointId);
276 368
		
......
296 388
					
297 389
					eventCallBack.setChartEditor(this);
298 390
					
299
					EventCallBackHandler mouseHandler = composite.getMouseCallBackHandler();
391
					EventCallBackHandler mouseHandler = this.chartComposite.getMouseCallBackHandler();
300 392
					if(mouseHandler != null && mouseHandler.getEventCallBack(eventCallBack.getClass()) == null)	 {
301 393

  
302 394
						Log.info("ChartEditorPart.createPartControl(): call back of type " + eventCallBack.getClass()
......
307 399
						
308 400
						mouseHandler.registerEventCallBack(eventCallBack);
309 401
					}
310
					EventCallBackHandler keyboardHandler = composite.getKeyCallBackHandler();
402
					EventCallBackHandler keyboardHandler = this.chartComposite.getKeyCallBackHandler();
311 403
					if(keyboardHandler != null && keyboardHandler.getEventCallBack(eventCallBack.getClass()) == null)	 {
312 404
						
313 405
						Log.info("ChartEditorPart.createPartControl(): call back of type " + eventCallBack.getClass()
......
327 419
		}
328 420
		
329 421
	}
330

  
331 422
	
332 423
	/**
333 424
	 * Activate the editor in the UI.
......
424 515
	}
425 516

  
426 517
	/**
518
	 *  Clears the selected items in chart.
519
	 */
520
	public void clearChartItemsSelection()	{
521
		this.chartComposite.clearChartItemsSelection();
522
	}
523
	
524
	/**
427 525
	 * Zooms the chart view at x and y coordinates.
428 526
	 * @param x
429 527
	 * @param y
......
451 549
	 * Copy the current chart view to clipboard.
452 550
	 */
453 551
	public void copyChartViewToClipboard()	{
454
		this.getEditorInput().getSWTChartsComponentsProvider().copyChartToClipboard(this.getComposite().getChartComponent());
552
		this.chartComposite.copyChartViewToClipboard();
455 553
	}
456 554

  
457 555
	/**
556
	 * Loads the chart from the chart object stored into the composite (without reseting the view and clearing the selected items).
557
	 */
558
	public void loadChart()	{
559
		this.loadChart(false, false);
560
	}
561

  
562
	/**
458 563
	 * Loads the chart from the chart object stored into the composite.
564
	 * @param resetView
565
	 * @param clearChartItemsSelection
459 566
	 */
460
	public void loadChart()	{
567
	public void loadChart(final boolean resetView, final boolean clearChartItemsSelection)	{
461 568
		getSite().getShell().getDisplay().syncExec(new Runnable() {
462 569
			@Override
463 570
			public void run() {
464
				chartComposite.loadChart();
571
				chartComposite.loadChart(resetView, clearChartItemsSelection);
465 572
			}
466 573
		});
467 574
	}
468

  
469 575
	
576
	
577
	
470 578
	/**
471 579
	 * Updates the specified chart stored in the editor and according to the stored TXM result.
472 580
	 * @return
......
530 638
	}
531 639

  
532 640
	/**
641
	 * Returns the advanced tool bar of this editor.
642
	 * @return
643
	 */
644
	public AdvancedChartEditorToolBar getAdvancedToolBar()	{
645
		return this.advancedToolBar;
646
	}
647
	
648
	/**
533 649
	 * Returns the result object associated with the editor.
534 650
	 * @return
535 651
	 */
......
752 868

  
753 869

  
754 870
	/**
755
	 * @return the parametersComposite
756
	 */
757
	public Composite getParametersComposite() {
758
		return parametersComposite;
759
	}
760

  
761

  
762

  
763
	/**
764 871
	 * @return the wasAlreadyOpened
765 872
	 */
766 873
	public boolean wasAlreadyOpened() {
......
779 886

  
780 887

  
781 888
	/**
782
	 * @return the parametersGroup
783
	 */
784
	public Group getParametersGroup() {
785
		return parametersGroup;
786
	}
787
	
788
	/**
789 889
	 * Checks whatever the chart composite has the focus or not.
790 890
	 * @return <code>true</code> if the chart composite has the focus otherwise <code>false</code>
791 891
	 */
792 892
	public boolean hasFocus()	{
793
		return this.chartComposite.isFocusControl();
893
		return this.chartComposite.hasFocus();
794 894
	}
895

  
896

  
897

  
898
	/**
899
	 * @return the commandParametersGroup
900
	 */
901
	public Group getCommandParametersGroup() {
902
		return commandParametersGroup;
903
	}
904

  
905

  
906

  
907
	/**
908
	 * @return the commandParametersComposite
909
	 */
910
	public Composite getCommandParametersComposite() {
911
		return commandParametersComposite;
912
	}
795 913
}
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/IChartComponent.java (revision 222)
49 49
	public void setChartEditor(ChartEditorPart editor);
50 50
	
51 51
	/**
52
	 * Update the mouse over item selection according to the specified mouse event.
52
	 * Updates the mouse over item selection according to the specified mouse event.
53 53
	 * @param event
54 54
	 */
55 55
	public void updateMouseOverItem(MouseEvent event);
56
	
57
	/**
58
	 * Checks if the component has the focus.
59
	 * @return
60
	 */
61
	public boolean hasFocus();
56 62
}
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/ChartEditorToolBar.java (revision 222)
1 1
package org.txm.chartsengine.rcp.swt;
2 2

  
3
import org.eclipse.core.runtime.IProgressMonitor;
4
import org.eclipse.core.runtime.IStatus;
5
import org.eclipse.core.runtime.Status;
6
import org.eclipse.core.runtime.jobs.Job;
7 3
import org.eclipse.jface.action.ToolBarManager;
8
import org.eclipse.swt.SWT;
9
import org.eclipse.swt.events.SelectionEvent;
10
import org.eclipse.swt.events.SelectionListener;
4
import org.eclipse.swt.layout.FormLayout;
11 5
import org.eclipse.swt.widgets.Composite;
12 6
import org.eclipse.swt.widgets.ToolBar;
13
import org.eclipse.swt.widgets.ToolItem;
14 7
import org.eclipse.ui.menus.IMenuService;
15
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences;
16 8
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
17
import org.txm.chartsengine.rcp.messages.SWTComponentsProviderMessages;
18
import org.txm.core.preferences.TXMPreferences;
19
import org.txm.rcpapplication.IImageKeys;
20
import org.txm.rcpapplication.views.CorporaView;
21 9

  
22 10
/**
23 11
 * The default chart editor tool bar shared by every <code>ChartEditorPart</code>.
......
55 43
//		    data.horizontalSpan = 3;
56 44
//		    this.setLayoutData(data);
57 45
		
46
		//System.out.println("ChartEditorToolBar.ChartEditorToolBar()");
47
		//this.setLayout(new FormLayout());
48
		
49
//		RowLayout rl = new RowLayout();
50
//		rl.marginTop = 10;
51
//		rl.marginWidth = 5;
52
//		this.setLayout(rl);
53
		
58 54
		// permit to contribute via plugin.xml menu extension
59 55
		ToolBarManager manager = new ToolBarManager(this);
60 56
		IMenuService menuService = (IMenuService) this.editorPart.getSite().getService(IMenuService.class);
61 57
		menuService.populateContributionManager(manager, "toolbar:" + ChartEditorToolBar.ID); //$NON-NLS-1$
62 58

  
63 59
		
64
		new ToolItem(this, SWT.SEPARATOR);
65
		
66
		final ToolItem showTitle = new ToolItem(this, SWT.CHECK);
67
		//showTitle.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_TITLE);
68
		showTitle.setImage(IImageKeys.getImage(this, "icons/show_title.png"));
69
		showTitle.setDisabledImage(IImageKeys.getImage(this, "icons/show_title_disabled.png"));
70
		showTitle.setToolTipText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_TITLE);
71

  
72
		if(!TXMPreferences.isEmpty(chartEditorPart.getPreferencesNodeQualifier(), ChartsEnginePreferences.SHOW_TITLE))	{
73
			showTitle.setSelection(TXMPreferences.getBoolean(chartEditorPart.getPreferencesNodeQualifier(), chartEditorPart.getResultData(), ChartsEnginePreferences.SHOW_TITLE));
74
		}
75
		// disable if not managed
76
		else	{
77
			showTitle.setEnabled(false);
78
		}
79
		
80

  
81
		final ToolItem showLegend = new ToolItem(this, SWT.CHECK);
82
		//showLegend.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_LEGEND);
83
		showLegend.setImage(IImageKeys.getImage(this, "icons/show_legend.png"));
84
		showLegend.setDisabledImage(IImageKeys.getImage(this, "icons/show_legend_disabled.png"));
85
		showLegend.setToolTipText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_LEGEND);
86

  
87
		if(!TXMPreferences.isEmpty(chartEditorPart.getPreferencesNodeQualifier(), ChartsEnginePreferences.SHOW_LEGEND))	{
88
			showLegend.setSelection(TXMPreferences.getBoolean(chartEditorPart.getPreferencesNodeQualifier(), chartEditorPart.getResultData(), ChartsEnginePreferences.SHOW_LEGEND));
89
		}
90
		// disable if not managed
91
		else	{
92
			showLegend.setEnabled(false);
93
		}
94

  
95
		
96
		final ToolItem showGrid = new ToolItem(this, SWT.CHECK);
97
		//showGrid.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_GRID);
98
		showGrid.setImage(IImageKeys.getImage(this, "icons/show_grid.png"));
99
		showGrid.setDisabledImage(IImageKeys.getImage(this, "icons/show_grid_disabled.png"));
100
		showGrid.setToolTipText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_GRID);
101
		
102
		if(!TXMPreferences.isEmpty(chartEditorPart.getPreferencesNodeQualifier(), ChartsEnginePreferences.SHOW_GRID))	{
103
			showGrid.setSelection(TXMPreferences.getBoolean(chartEditorPart.getPreferencesNodeQualifier(), chartEditorPart.getResultData(), ChartsEnginePreferences.SHOW_GRID));
104
		}
105
		// disable if not managed
106
		else	{
107
			showGrid.setEnabled(false);
108
		}
109

  
110
		
111
		
112
		SelectionListener listener = new SelectionListener() {
113
			
114
			@Override
115
			public void widgetSelected(final SelectionEvent e) {
116
				
117
				// Accessing the source must be done outside the Job
118
				if(e.getSource() == showTitle)	{
119
					TXMPreferences.putLocalBoolean(chartEditorPart.getResultData(), ChartsEnginePreferences.SHOW_TITLE,showTitle.getSelection());
120
				}
121
				if(e.getSource() == showLegend)	{
122
					TXMPreferences.putLocalBoolean(chartEditorPart.getResultData(), ChartsEnginePreferences.SHOW_LEGEND, showLegend.getSelection());
123
				}
124
				if(e.getSource() == showGrid)	{
125
					TXMPreferences.putLocalBoolean(chartEditorPart.getResultData(), ChartsEnginePreferences.SHOW_GRID, showGrid.getSelection());
126
				}
127
				
128
				
129
				// updates existing chart 
130
				Job job = new Job("Update chart") {
131

  
132
				    @Override
133
				    protected IStatus run(final IProgressMonitor monitor) {
134

  
135
								
136
								
137
							  	// updating and reloading
138
								monitor.beginTask("Updating", IProgressMonitor.UNKNOWN);
139
								chartEditorPart.updateChart();
140

  
141
								
142
								
143
								// cancel
144
								if(monitor.isCanceled())	{
145
									return Status.CANCEL_STATUS;
146
								}
147
								
148
								// refreshes
149
					    		chartEditorPart.getSite().getShell().getDisplay().asyncExec(new Runnable() {
150
									@Override
151
									public void run() {
152
										CorporaView.refresh();
153
									}
154
								});
155
								
156
								
157
								// loading
158
								monitor.setTaskName("Loading");
159
								chartEditorPart.loadChart();
160
								
161
								
162
								
163
								// FIXME: persistence test, saving local preferences/parameters to file
164
								//TXMPreferences.flush(chartEditorPart.getResultData());
165
								
166
								
167
								// done
168
								monitor.done(); 
169

  
170
							
171
//							}
172
//						});
173
				  
174
			    		
175
				        return Status.OK_STATUS;
176
				    }
177

  
178
				};
179
				//job.setUser(true); // show progress bar, without that the progress is located to bottom right
180
				job.schedule();
181
				
182
				
183
				
184
				
185
			}
186
			
187
			@Override
188
			public void widgetDefaultSelected(SelectionEvent e) {
189
				// TODO Auto-generated method stub
190
				
191
			}
192
		};
193
		
194
		showTitle.addSelectionListener(listener);
195
		showLegend.addSelectionListener(listener);
196
		showGrid.addSelectionListener(listener);
197
	
60
//		new ToolItem(this, SWT.SEPARATOR);
61
//		
62
//		final ToolItem showTitle = new ToolItem(this, SWT.CHECK);
63
//		//showTitle.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_TITLE);
64
//		showTitle.setImage(IImageKeys.getImage(this, "icons/show_title.png"));
65
//		showTitle.setDisabledImage(IImageKeys.getImage(this, "icons/show_title_disabled.png"));
66
//		showTitle.setToolTipText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_TITLE);
67
//
68
//		if(!TXMPreferences.isEmpty(chartEditorPart.getPreferencesNodeQualifier(), ChartsEnginePreferences.SHOW_TITLE))	{
69
//			showTitle.setSelection(TXMPreferences.getBoolean(chartEditorPart.getPreferencesNodeQualifier(), chartEditorPart.getResultData(), ChartsEnginePreferences.SHOW_TITLE));
70
//		}
71
//		// disable if not managed
72
//		else	{
73
//			showTitle.setEnabled(false);
74
//		}
75
//		
76
//
77
//		final ToolItem showLegend = new ToolItem(this, SWT.CHECK);
78
//		//showLegend.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_LEGEND);
79
//		showLegend.setImage(IImageKeys.getImage(this, "icons/show_legend.png"));
80
//		showLegend.setDisabledImage(IImageKeys.getImage(this, "icons/show_legend_disabled.png"));
81
//		showLegend.setToolTipText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_LEGEND);
82
//
83
//		if(!TXMPreferences.isEmpty(chartEditorPart.getPreferencesNodeQualifier(), ChartsEnginePreferences.SHOW_LEGEND))	{
84
//			showLegend.setSelection(TXMPreferences.getBoolean(chartEditorPart.getPreferencesNodeQualifier(), chartEditorPart.getResultData(), ChartsEnginePreferences.SHOW_LEGEND));
85
//		}
86
//		// disable if not managed
87
//		else	{
88
//			showLegend.setEnabled(false);
89
//		}
90
//
91
//		
92
//		final ToolItem showGrid = new ToolItem(this, SWT.CHECK);
93
//		//showGrid.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_GRID);
94
//		showGrid.setImage(IImageKeys.getImage(this, "icons/show_grid.png"));
95
//		showGrid.setDisabledImage(IImageKeys.getImage(this, "icons/show_grid_disabled.png"));
96
//		showGrid.setToolTipText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_GRID);
97
//		
98
//		if(!TXMPreferences.isEmpty(chartEditorPart.getPreferencesNodeQualifier(), ChartsEnginePreferences.SHOW_GRID))	{
99
//			showGrid.setSelection(TXMPreferences.getBoolean(chartEditorPart.getPreferencesNodeQualifier(), chartEditorPart.getResultData(), ChartsEnginePreferences.SHOW_GRID));
100
//		}
101
//		// disable if not managed
102
//		else	{
103
//			showGrid.setEnabled(false);
104
//		}
105
//
106
//		
107
//		
108
//		SelectionListener listener = new SelectionListener() {
109
//			
110
//			@Override
111
//			public void widgetSelected(final SelectionEvent e) {
112
//				
113
//				// Accessing the source must be done outside the Job
114
//				if(e.getSource() == showTitle)	{
115
//					TXMPreferences.putLocalBoolean(chartEditorPart.getResultData(), ChartsEnginePreferences.SHOW_TITLE,showTitle.getSelection());
116
//				}
117
//				if(e.getSource() == showLegend)	{
118
//					TXMPreferences.putLocalBoolean(chartEditorPart.getResultData(), ChartsEnginePreferences.SHOW_LEGEND, showLegend.getSelection());
119
//				}
120
//				if(e.getSource() == showGrid)	{
121
//					TXMPreferences.putLocalBoolean(chartEditorPart.getResultData(), ChartsEnginePreferences.SHOW_GRID, showGrid.getSelection());
122
//				}
123
//				
124
//				
125
//				// updates existing chart 
126
//				Job job = new Job("Update chart") {
127
//
128
//				    @Override
129
//				    protected IStatus run(final IProgressMonitor monitor) {
130
//
131
//								
132
//								
133
//							  	// updating and reloading
134
//								monitor.beginTask("Updating", IProgressMonitor.UNKNOWN);
135
//								chartEditorPart.updateChart();
136
//
137
//								
138
//								
139
//								// cancel
140
//								if(monitor.isCanceled())	{
141
//									return Status.CANCEL_STATUS;
142
//								}
143
//								
144
//								// refreshes
145
//					    		chartEditorPart.getSite().getShell().getDisplay().asyncExec(new Runnable() {
146
//									@Override
147
//									public void run() {
148
//										CorporaView.refresh();
149
//									}
150
//								});
151
//								
152
//								
153
//								// loading
154
//								monitor.setTaskName("Loading");
155
//								chartEditorPart.loadChart();
156
//								
157
//								
158
//								
159
//								// FIXME: persistence test, saving local preferences/parameters to file
160
//								//TXMPreferences.flush(chartEditorPart.getResultData());
161
//								
162
//								
163
//								// done
164
//								monitor.done(); 
165
//
166
//							
167
////							}
168
////						});
169
//				  
170
//			    		
171
//				        return Status.OK_STATUS;
172
//				    }
173
//
174
//				};
175
//				//job.setUser(true); // show progress bar, without that the progress is located to bottom right
176
//				job.schedule();
177
//				
178
//				
179
//				
180
//				
181
//			}
182
//			
183
//			@Override
184
//			public void widgetDefaultSelected(SelectionEvent e) {
185
//				// TODO Auto-generated method stub
186
//				
187
//			}
188
//		};
189
//		showTitle.addSelectionListener(listener);
190
//		showLegend.addSelectionListener(listener);
191
//		showGrid.addSelectionListener(listener);
198 192
	}
199 193

  
200 194

  
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/AdvancedChartEditorToolBar.java (revision 222)
1
package org.txm.chartsengine.rcp.swt;
2

  
3
import org.eclipse.core.runtime.IProgressMonitor;
4
import org.eclipse.core.runtime.IStatus;
5
import org.eclipse.core.runtime.Status;
6
import org.eclipse.core.runtime.jobs.Job;
7
import org.eclipse.jface.action.ToolBarManager;
8
import org.eclipse.jface.preference.ComboFieldEditor;
9
import org.eclipse.swt.SWT;
10
import org.eclipse.swt.custom.CLabel;
11
import org.eclipse.swt.events.SelectionEvent;
12
import org.eclipse.swt.events.SelectionListener;
13
import org.eclipse.swt.widgets.Combo;
14
import org.eclipse.swt.widgets.Composite;
15
import org.eclipse.swt.widgets.ToolBar;
16
import org.eclipse.swt.widgets.ToolItem;
17
import org.eclipse.ui.menus.IMenuService;
18
import org.txm.ca.rcp.messages.CAUIMessages;
19
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences;
20
import org.txm.chartsengine.rcp.editors.ChartEditorPart;
21
import org.txm.chartsengine.rcp.messages.SWTComponentsProviderMessages;
22
import org.txm.core.preferences.TXMPreferences;
23
import org.txm.rcpapplication.IImageKeys;
24
import org.txm.rcpapplication.views.CorporaView;
25

  
26
/**
27
 * The default chart editor tool bar shared by every <code>ChartEditorPart</code>.
28
 * @author sjacquot
29
 *
30
 */
31
public class AdvancedChartEditorToolBar extends ToolBar {
32

  
33
	
34
	protected static final String ID =  "AdvancedChartEditorToolBar"; //$NON-NLS-1$
35
	
36

  
37
	/**
38
	 * The linked <code>ChartEditorPart</code>.
39
	 */
40
	protected ChartEditorPart editorPart;
41

  
42

  
43

  
44

  
45
	/**
46
	 *
47
	 * @param parent
48
	 * @param style
49
	 */
50
	public AdvancedChartEditorToolBar(Composite parent, int style, final ChartEditorPart chartEditorPart) {
51
		super(parent, style);
52

  
53
		this.editorPart = chartEditorPart;
54

  
55
		// FIXME: tests
56
		//this.setLayout(new FormLayout());
57
		//this.setLayout(new GridLayout());
58
//		 GridData data = new GridData();
59
//		    data.horizontalSpan = 3;
60
//		    this.setLayoutData(data);
61
		
62
		// permit to contribute via plugin.xml menu extension
63
		ToolBarManager manager = new ToolBarManager(this);
64
		IMenuService menuService = (IMenuService) this.editorPart.getSite().getService(IMenuService.class);
65
		menuService.populateContributionManager(manager, "toolbar:" + AdvancedChartEditorToolBar.ID); //$NON-NLS-1$
66

  
67
		
68
//		new ToolItem(this, SWT.SEPARATOR);
69
		
70
		final ToolItem showTitle = new ToolItem(this, SWT.CHECK);
71
		//showTitle.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_TITLE);
72
		showTitle.setImage(IImageKeys.getImage(this, "icons/show_title.png"));
73
		showTitle.setDisabledImage(IImageKeys.getImage(this, "icons/show_title_disabled.png"));
74
		showTitle.setToolTipText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_TITLE);
75

  
76
		if(!TXMPreferences.isEmpty(chartEditorPart.getPreferencesNodeQualifier(), ChartsEnginePreferences.SHOW_TITLE))	{
77
			showTitle.setSelection(TXMPreferences.getBoolean(chartEditorPart.getPreferencesNodeQualifier(), chartEditorPart.getResultData(), ChartsEnginePreferences.SHOW_TITLE));
78
		}
79
		// disable if not managed
80
		else	{
81
			showTitle.setEnabled(false);
82
		}
83
		
84

  
85
		final ToolItem showLegend = new ToolItem(this, SWT.CHECK);
86
		//showLegend.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_LEGEND);
87
		showLegend.setImage(IImageKeys.getImage(this, "icons/show_legend.png"));
88
		showLegend.setDisabledImage(IImageKeys.getImage(this, "icons/show_legend_disabled.png"));
89
		showLegend.setToolTipText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_LEGEND);
90

  
91
		if(!TXMPreferences.isEmpty(chartEditorPart.getPreferencesNodeQualifier(), ChartsEnginePreferences.SHOW_LEGEND))	{
92
			showLegend.setSelection(TXMPreferences.getBoolean(chartEditorPart.getPreferencesNodeQualifier(), chartEditorPart.getResultData(), ChartsEnginePreferences.SHOW_LEGEND));
93
		}
94
		// disable if not managed
95
		else	{
96
			showLegend.setEnabled(false);
97
		}
98

  
99
		
100
		final ToolItem showGrid = new ToolItem(this, SWT.CHECK);
101
		//showGrid.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_GRID);
102
		showGrid.setImage(IImageKeys.getImage(this, "icons/show_grid.png"));
103
		showGrid.setDisabledImage(IImageKeys.getImage(this, "icons/show_grid_disabled.png"));
104
		showGrid.setToolTipText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_GRID);
105
		
106
		if(!TXMPreferences.isEmpty(chartEditorPart.getPreferencesNodeQualifier(), ChartsEnginePreferences.SHOW_GRID))	{
107
			showGrid.setSelection(TXMPreferences.getBoolean(chartEditorPart.getPreferencesNodeQualifier(), chartEditorPart.getResultData(), ChartsEnginePreferences.SHOW_GRID));
108
		}
109
		// disable if not managed
110
		else	{
111
			showGrid.setEnabled(false);
112
		}
113

  
114
		
115
		
116
		// Rendering colors mode selection
117
	
118
		ToolItem itemSeparator = new ToolItem(this, SWT.SEPARATOR);
119
//		CLabel factorsLabel = new CLabel(this, SWT.CENTER);
120
//		factorsLabel.setText(SWTComponentsProviderMessages.ChartsEnginePreferencePage_RenderingColorsMode);
121
//		itemSeparator.setWidth(factorsLabel.getBounds().width);
122
//	    itemSeparator.setControl(factorsLabel);
123
		
124
		final Combo renderingModeCombo = new Combo(this, SWT.READ_ONLY);
125
		String colorsModes[] = new String[]{SWTComponentsProviderMessages.ChartsEnginePreferencePage_RenderingModeColors,
126
			SWTComponentsProviderMessages.ChartsEnginePreferencePage_RenderingModeGrayscale,
127
			SWTComponentsProviderMessages.ChartsEnginePreferencePage_RenderingModeBlackAndWhite,
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff