Révision 651

tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditor.java (revision 651)
114 114
	public final void __createPartControl(Composite parent) {
115 115
		
116 116
		// Toolbar
117
		this.chartToolBar = new ChartEditorToolBar(this, SWT.FLAT | SWT.RIGHT);
118
		//this.chartToolBar = new ChartEditorToolBar(this.topToolBar, SWT.FLAT | SWT.RIGHT, this);
117
		this.chartToolBar = new ChartEditorToolBar(this, this.getTopToolBarContainer(), SWT.FLAT | SWT.RIGHT);
119 118
		//this.chartToolBar.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_RED));
120 119

  
121 120
		// Advanced tool bar
122 121
		//this.advancedToolBarComposite = new Composite(parent, SWT.NONE);
123 122
		Group group = this.topToolBar.installGroup("Rendering parameters", "Show/Hide rendering parameters", "platform:/plugin/org.txm.chartsengine.rcp/icons/show_rendering_parameters.png", false);
124
		this.advancedChartToolBar = new AdvancedChartEditorToolBar(group, SWT.FLAT, this);
125
//		this.advancedToolBar.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
123
		this.advancedChartToolBar = new AdvancedChartEditorToolBar(this, group, SWT.FLAT);
124
		//this.advancedChartToolBar.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
126 125
//		this.advancedToolBarComposite.pack(true);
127 126

  
128 127
		// Remove parent composites
......
155 154
		//this.refresh(false);
156 155
//
157 156
//		}
158
		
159 157
	}
160 158

  
161 159

  
......
234 232
		// if editor wasn't exist:
235 233
		// hiding command parameters, updating tool bar buttons states, registering context menus and event user callbacks 
236 234
		if(!update && !getResult().isChartDirty())	{
237
			getSite().getShell().getDisplay().syncExec(new Runnable() {
238
				@Override
239
				public void run() {
235
//			getSite().getShell().getDisplay().syncExec(new Runnable() {
236
//				@Override
237
//				public void run() {
240 238
					// FIXME: decide if we automatically hide or not the parameter area
241 239
					//editor2.getTopToolbar().setComputingParametersVisible(false);
242 240
					
......
261 259
					//editor2..setContentDescription(this.getResultData().getDetails());
262 260
	
263 261
					initializeAWTDelegationListeners();
264
				}
265
			});
262
					
263
//				}
264
//			});
266 265
		}
267
			
268
		
269 266
	}
270 267
	
271 268
	
......
747 744
	}
748 745
	
749 746

  
750
	
751
	@Override
752
	public Composite getToolBarContainer(String toolbarLocalId) {
753
		if (ChartEditorToolBar.ID.equals(toolbarLocalId)) {
754
			return this.getTopToolBarContainer();
755
		}
756
		return super.getToolBarContainer(toolbarLocalId);
757
	}
758 747
}
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/AdvancedChartEditorToolBar.java (revision 651)
3 3
import java.awt.Font;
4 4
import java.awt.GraphicsEnvironment;
5 5
import java.util.ArrayList;
6
import java.util.HashMap;
7
import java.util.Iterator;
8
import java.util.Map;
9 6

  
10 7
import org.apache.commons.lang.StringUtils;
11 8
import org.eclipse.swt.SWT;
......
13 10
import org.eclipse.swt.events.SelectionListener;
14 11
import org.eclipse.swt.widgets.Combo;
15 12
import org.eclipse.swt.widgets.Composite;
16
import org.eclipse.swt.widgets.ToolBar;
17 13
import org.eclipse.swt.widgets.ToolItem;
18 14
import org.txm.chartsengine.core.ChartCreator;
19 15
import org.txm.chartsengine.core.ChartsEngine;
20 16
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences;
21
import org.txm.chartsengine.core.results.ChartResult;
22
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider;
23 17
import org.txm.chartsengine.rcp.editors.ChartEditor;
24 18
import org.txm.chartsengine.rcp.messages.SWTComponentsProviderMessages;
25 19
import org.txm.rcp.IImageKeys;
......
31 25
 * @author sjacquot
32 26
 *
33 27
 */
34
public class AdvancedChartEditorToolBar extends ToolBar {
28
public class AdvancedChartEditorToolBar extends ChartEditorToolBar {
35 29

  
36
	private ChartEditor<ChartResult> chartEditorPart;
37

  
38
	public ChartEditor<ChartResult> getEditorPart() {
39
		return chartEditorPart;
40
	}
30
	public final static String ID = "AdvancedChartEditorToolBar" ;
41 31
	
42
	@Override
43
	protected void checkSubclass() { } // if this method is not defined then the ToolBar cannot be subclassed
44
	
45 32
	/**
46 33
	 *
47 34
	 * @param parent
48 35
	 * @param style
49 36
	 */
50
	public AdvancedChartEditorToolBar(Composite parent, int style, final ChartEditor chartEditorPart) {
51
		super(parent, style); //$NON-NLS-1$
37
	public AdvancedChartEditorToolBar(ChartEditor chartEditor, Composite parent, int style) {
38
		super(chartEditor, parent, style, AdvancedChartEditorToolBar.ID);
52 39
		
53
		this.chartEditorPart = chartEditorPart;
54 40
		
55 41
		final ToolItem showTitle = new ToolItem(this, SWT.CHECK);
56 42
		//showTitle.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_TITLE);
......
58 44
		showTitle.setDisabledImage(IImageKeys.getImage(getClass(), "icons/show_title_disabled.png"));
59 45
		showTitle.setToolTipText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_TITLE);
60 46

  
61
		if(!chartEditorPart.getResult().isEmptyPreference(ChartsEnginePreferences.SHOW_TITLE))	{
62
			showTitle.setSelection(chartEditorPart.getResult().isTitleVisible());
47
		if(!chartEditor.getResult().isEmptyPreference(ChartsEnginePreferences.SHOW_TITLE))	{
48
			showTitle.setSelection(chartEditor.getResult().isTitleVisible());
63 49
		}
64 50
		// disable if not managed by the command
65 51
		else	{
......
73 59
		showLegend.setDisabledImage(IImageKeys.getImage(getClass(), "icons/show_legend_disabled.png"));
74 60
		showLegend.setToolTipText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_LEGEND);
75 61

  
76
		if(!chartEditorPart.getResult().isEmptyPreference(ChartsEnginePreferences.SHOW_LEGEND))	{
77
			showLegend.setSelection(chartEditorPart.getResult().isLegendVisible());
62
		if(!chartEditor.getResult().isEmptyPreference(ChartsEnginePreferences.SHOW_LEGEND))	{
63
			showLegend.setSelection(chartEditor.getResult().isLegendVisible());
78 64
		}
79 65
		// disable if not managed by the command
80 66
		else	{
......
88 74
		showGrid.setDisabledImage(IImageKeys.getImage(getClass(), "icons/show_grid_disabled.png"));
89 75
		showGrid.setToolTipText(SWTComponentsProviderMessages.SWTChartsComponentProvider_SHOW_HIDE_GRID);
90 76
		
91
		if(!chartEditorPart.getResult().isEmptyPreference(ChartsEnginePreferences.SHOW_GRID))	{
92
			showGrid.setSelection(chartEditorPart.getResult().isGridVisible());
77
		if(!chartEditor.getResult().isEmptyPreference(ChartsEnginePreferences.SHOW_GRID))	{
78
			showGrid.setSelection(chartEditor.getResult().isGridVisible());
93 79
		}
94 80
		// disable if not managed by the command
95 81
		else	{
......
113 99
		renderingModeCombo.pack();
114 100
		renderingComboItem.setWidth(renderingModeCombo.getBounds().width);
115 101
		
116
		if(!chartEditorPart.getResult().isEmptyPreference(ChartsEnginePreferences.RENDERING_COLORS_MODE))	{
117
			renderingModeCombo.select(chartEditorPart.getResult().getRenderingColorsMode());
102
		if(!chartEditor.getResult().isEmptyPreference(ChartsEnginePreferences.RENDERING_COLORS_MODE))	{
103
			renderingModeCombo.select(chartEditor.getResult().getRenderingColorsMode());
118 104
		}
119 105
		// disable if not managed
120 106
		else	{
......
123 109
		
124 110
		
125 111
		// Font selection
126
		final Font currentFont = ChartsEngine.createFont(chartEditorPart.getResult().getFont());
112
		final Font currentFont = ChartsEngine.createFont(chartEditor.getResult().getFont());
127 113
		
128 114
		final Combo fontCombo = new Combo(this, SWT.READ_ONLY);
129 115
		String fonts[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
......
171 157
		ArrayList<ChartCreator> allChartCreators = new ArrayList<ChartCreator>();
172 158
		
173 159
		for (int i = 0; i < ChartsEngine.getChartsEngines().size(); i++) {
174
			ArrayList<ChartCreator> chartCreators = ChartsEngine.getChartsEngines().get(i).getChartCreators(this.chartEditorPart.getResult());
160
			ArrayList<ChartCreator> chartCreators = ChartsEngine.getChartsEngines().get(i).getChartCreators(this.getEditorPart().getResult());
175 161
			for (int j = 0; j < chartCreators.size(); j++) {
176 162
				chartsEngineNames.add(ChartsEngine.getChartsEngines().get(i).getName());
177 163
				allChartCreators.add(chartCreators.get(j));
......
219 205
				boolean update = true;
220 206
				
221 207
				if(e.getSource() == showTitle)	{
222
					chartEditorPart.getResult().setTitleVisible(showTitle.getSelection());
208
					getEditorPart().getResult().setTitleVisible(showTitle.getSelection());
223 209
				}
224 210
				else if(e.getSource() == showLegend)	{
225
					chartEditorPart.getResult().setLegendVisible(showLegend.getSelection());
211
					getEditorPart().getResult().setLegendVisible(showLegend.getSelection());
226 212
				}
227 213
				else if(e.getSource() == showGrid)	{
228
					chartEditorPart.getResult().setGridVisible(showGrid.getSelection());
214
					getEditorPart().getResult().setGridVisible(showGrid.getSelection());
229 215
				}
230 216
				else if(e.getSource() == renderingModeCombo)	{
231
					chartEditorPart.getResult().setRenderingColorsMode(renderingModeCombo.getSelectionIndex());
217
					getEditorPart().getResult().setRenderingColorsMode(renderingModeCombo.getSelectionIndex());
232 218
				}
233 219
				else if(e.getSource() == fontCombo || e.getSource() == fontSizeCombo)	{
234
					chartEditorPart.getResult().setFont("1|" + fontCombo.getItem(fontCombo.getSelectionIndex()) + "|" + fontSizeCombo.getItem(fontSizeCombo.getSelectionIndex()) + "|0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
220
					getEditorPart().getResult().setFont("1|" + fontCombo.getItem(fontCombo.getSelectionIndex()) + "|" + fontSizeCombo.getItem(fontSizeCombo.getSelectionIndex()) + "|0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
235 221
				}
236 222
				else if(e.getSource() == chartTypeCombo)	{
237 223
					
238 224
					String[] data = StringUtils.split(chartTypeCombo.getItem(chartTypeCombo.getSelectionIndex()), '/');
239 225
					data[0] = StringUtils.trim(data[0]);
240 226
					data[1] = StringUtils.trim(data[1]);
241
					chartEditorPart.getResult().setChartType(data[1]);
242
					chartEditorPart.getResult().setChartsEngine(ChartsEngine.getChartsEngineByName(data[0]));
227
					getEditorPart().getResult().setChartType(data[1]);
228
					getEditorPart().getResult().setChartsEngine(ChartsEngine.getChartsEngineByName(data[0]));
243 229
					update = false;
244 230
				}
245 231

  
246
				chartEditorPart.getResult().setChartDirty();
232
				getEditorPart().getResult().setChartDirty();
247 233
				
248 234
				// updates or creates chart
249
				chartEditorPart.compute(update);
235
				getEditorPart().compute(update);
236
				getEditorPart().setFocus();
250 237
			}
251 238
			
252 239
			@Override
......
265 252
	}
266 253

  
267 254

  
255
	
256
	@Override
257
	protected void checkSubclass() { } // if this method is not defined then the ToolBar cannot be subclassed
258
	
259

  
268 260
}
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/ChartEditorToolBar.java (revision 651)
1 1
package org.txm.chartsengine.rcp.swt;
2 2

  
3
import org.eclipse.core.commands.Command;
4 3
import org.eclipse.swt.widgets.Composite;
5
import org.eclipse.ui.PlatformUI;
6
import org.eclipse.ui.commands.ICommandService;
7
import org.eclipse.ui.handlers.IHandlerService;
8 4
import org.txm.chartsengine.rcp.editors.ChartEditor;
9
import org.txm.chartsengine.rcp.handlers.ExportChartEditorView;
10 5
import org.txm.rcp.editors.TXMEditorToolBar;
11 6

  
12 7
/**
......
28 23
	 * @param parent
29 24
	 * @param style
30 25
	 * @param toolBarId
31
	 * @param chartEditorPart
26
	 * @param chartEditor
32 27
	 */
33
	protected ChartEditorToolBar(ChartEditor chartEditorPart, int style, String toolBarId) {
34
		super(chartEditorPart, style, toolBarId);
28
	public ChartEditorToolBar(ChartEditor chartEditor, Composite parent, int style) {
29
		this(chartEditor, parent, style, ChartEditorToolBar.ID);
35 30
	}
36 31
	
37 32

  
......
41 36
	 * @param style
42 37
	 * @param chartEditorPart
43 38
	 */
44
	public ChartEditorToolBar(ChartEditor chartEditorPart, int style) {
45
		this(chartEditorPart, style, ChartEditorToolBar.ID); //$NON-NLS-1$
39
	public ChartEditorToolBar(ChartEditor chartEditor, Composite parent, int style, String toolbarId) {
40
		super(chartEditor, parent, style, toolbarId);
46 41

  
47 42
		
48 43
		//FIXME: tests
tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/ChartsEngine.java (revision 651)
40 40
	/**
41 41
	 * Chart type constants.
42 42
	 */
43
	@Deprecated
44
	// FIXME: became useless since the ChartResult is stored in the renderer
43 45
	public final static int CHART_TYPE_PARTITION_DIMENSIONS = 0, CHART_TYPE_SPECIFICITIES = 1, CHART_TYPE_PROGRESSION = 2, CHART_TYPE_CA_FACTORIAL_MAP = 3, CHART_TYPE_CA_SINGULAR_VALUES = 4,
44 46
			CHART_TYPE_CAH_2D = 5, CHART_TYPE_CAH_3D = 6;
45 47

  
tmp/org.txm.chartsengine.jfreechart.rcp/plugin.xml (revision 651)
24 24
            allPopups="false"
25 25
            locationURI="toolbar:AdvancedChartEditorToolBar">
26 26
         <command
27
               commandId="OpenJFCChartPropertiesEditor"
27
               commandId="org.txm.chartsengine.jfreechart.rcp.handlers.OpenJFCChartPropertiesEditor"
28 28
               icon="icons/silk_chart_edit.png"
29 29
               style="push">
30 30
         </command>
......
34 34
         point="org.eclipse.ui.commands">
35 35
      <command
36 36
            defaultHandler="org.txm.chartsengine.jfreechart.rcp.handlers.OpenJFCChartPropertiesEditor"
37
            id="OpenJFCChartPropertiesEditor"
37
            id="org.txm.chartsengine.jfreechart.rcp.handlers.OpenJFCChartPropertiesEditor"
38 38
            name="Open Chart Properties">
39 39
      </command>
40 40
   </extension>
tmp/org.txm.chartsengine.jfreechart.core/src/org/txm/chartsengine/jfreechart/core/renderers/interfaces/IRendererWithItemSelection.java (revision 651)
32 32
	 * Returns the chart type as defined by {@link ChartsEngine} constants.
33 33
	 * @return
34 34
	 */
35
	@Deprecated
36
	// FIXME: became useless since the ChartResult is stored in the renderer
35 37
	public int getChartType();
36 38
	
37 39
	/**
38 40
	 * Sets the chart type  
39 41
	 * @param chartType
40 42
	 */
43
	@Deprecated
44
	// FIXME: became useless since the ChartResult is stored in the renderer
41 45
	public void setChartType(int chartType);
42 46
	
43 47
	/**
tmp/org.txm.chartsengine.jfreechart.core/src/org/txm/chartsengine/jfreechart/core/JFCChartCreator.java (revision 651)
16 16

  
17 17
/**
18 18
 * JFreeChart base chart creator.
19
 * 
20
 * All JFC charts creators should extend this class.
21
 * The updateChart(ChartResult result) method implementation of the subclasses must call super.update(result) to benefit to the shared system. 
22
 * Before updating, the subclasses should call chart.setNotify(true) to avoid conflict between the updating and the rendering threads.
23
 * 
19 24
 * @author sjacquot
20 25
 *
21 26
 */
......
30 35
	
31 36

  
32 37
	/**
33
	 * 
34
	 * @param chart
38
	 * Updates the chart according to the shared parameters, also applies the current theme to the chart and the user renderer settings.
35 39
	 * @param result
36
	 * @param preferencesNode
37 40
	 * @param applyTheme
38 41
	 */
39 42
	public void updateChart(ChartResult result, boolean applyTheme) {
......
91 94
				}
92 95
			}
93 96
			
94
			
95
			
96
			
97
			
98 97
			chart.setNotify(true);
99 98
		}
100 99
		// File
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorToolBar.java (revision 651)
40 40
	 * 
41 41
	 * @param parent
42 42
	 * @param style
43
	 * @param toolbarLocalId
43
	 * @param toolbarId
44 44
	 * @param editor
45 45
	 */
46
	public TXMEditorToolBar(TXMEditor editor, int style, String toolbarLocalId) {
47
		//TODO change the test with ;
48
		super(editor.getToolBarContainer(toolbarLocalId), style);
46
	public TXMEditorToolBar(TXMEditor editor, Composite parent, int style, String toolbarId) {
47
		super(parent, style);
49 48

  
50 49
		this.editorPart = editor;
51 50

  
52 51
		// permit to contribute via plugin.xml menu extension
53 52
		ToolBarManager manager = new ToolBarManager(this);
54 53
		IMenuService menuService = (IMenuService) this.editorPart.getSite().getService(IMenuService.class);
55
		menuService.populateContributionManager(manager, "toolbar:" + toolbarLocalId); //$NON-NLS-1$
54
		menuService.populateContributionManager(manager, "toolbar:" + toolbarId); //$NON-NLS-1$
56 55
	}
57 56

  
58 57
	@Override
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 651)
144 144
			rl.marginTop = rl.marginHeight = rl.marginWidth = rl.marginBottom = 0;
145 145
			this.topToolBarContainer.setLayout(rl);
146 146

  
147
			this.topToolBar = new TXMEditorToolBar(this, SWT.FLAT | SWT.RIGHT, TOP_TOOLBAR_ID);
147
			this.topToolBar = new TXMEditorToolBar(this, this.topToolBarContainer, SWT.FLAT | SWT.RIGHT, TOP_TOOLBAR_ID);
148 148

  
149

  
150 149
			this.parametersGroupsComposite = new Composite(parent, SWT.NONE);
151 150
			GridLayout gl = new GridLayout(1, true);
152 151
			gl.marginBottom = gl.marginHeight = gl.marginWidth = gl.marginTop = 0;
......
167 166
			// display main area
168 167
			this.resultArea = new Composite(parent, SWT.NONE);
169 168
			this.resultArea.setLayoutData(new GridData(GridData.FILL_BOTH));
170

  
171
			// create the top tool bar
169
			
170
			
171
			// create the bottom tool bar
172 172
			this.bottomToolBarContainer = new Composite(parent, SWT.NONE);
173 173
			this.bottomToolBarContainer.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
174 174
			rl = new RowLayout(SWT.HORIZONTAL);
175 175
			rl.marginTop = rl.marginHeight = rl.marginWidth = rl.marginBottom = 0;
176 176
			this.bottomToolBarContainer.setLayout(rl);
177 177

  
178
			// bottom tool bar
179
			this.bottomToolBar = new TXMEditorToolBar(this, SWT.FLAT, "bottom");
180 178
			
179
			
180
			this.bottomToolBar = new TXMEditorToolBar(this, this.bottomToolBarContainer, SWT.FLAT, "bottom");
181
			
181 182
			this.__createPartControl(parent); // essentially for the ChartEditor
182 183
			this._createPartControl(parent); // child editor create its parameters and display widgets
183 184
			
184 185
			
185
			
186 186
			if (!this.getResult().isDirty()) {
187 187
				this.topToolBar.setComputingParametersVisible(false);
188 188
			}
189 189
			
190
			// remove empty toolbars
191
			// SJ: Hack?
192
			if (this.bottomToolBar.getChildren().length > 0) {
190
			// remove empty toolbar
191
			//TODO SJ: Hack?
192
			if (this.bottomToolBar.getItems().length == 0) {
193 193
				this.bottomToolBar.dispose();
194 194
			}
195 195
		}
......
798 798
			return this.getEditorInput().deleteResult();
799 799
		} catch(Exception e) {
800 800
			System.out.println("Error: could not delete result: " + e.getLocalizedMessage());
801
			Log.printStackTrace(e);
801 802
			return false;
802 803
		}
803 804
	}
......
884 885
		viewer.getControl().setRedraw(true);
885 886
	}
886 887

  
887

  
888

  
889
	public Composite getToolBarContainer(String toolbarLocalId) {
890
		if (TOP_TOOLBAR_ID.equals(toolbarLocalId)) {
891
			return this.getTopToolBarContainer();
892
		} else if ("bottom".equals(toolbarLocalId)) {
893
			return this.getBottomToolBarContainer();
894
		}
895
		return this.getTopToolBarContainer(); // default toolbar container
896
	}
897

  
898 888
	/**
899 889
	 * @return the lastComputingParameters
900 890
	 */
tmp/org.txm.chartsengine.r.core/src/org/txm/chartsengine/r/core/RChartCreator.java (revision 651)
6 6

  
7 7
import org.txm.chartsengine.core.ChartCreator;
8 8
import org.txm.chartsengine.core.results.ChartResult;
9
import org.txm.core.results.TXMResult;
10 9
import org.txm.utils.logger.Log;
11 10

  
12 11

  

Formats disponibles : Unified diff