Révision 1841
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/handlers/ResetChartView.java (revision 1841) | ||
|---|---|---|
| 8 | 8 |
|
| 9 | 9 |
/** |
| 10 | 10 |
* Resets the chart view of the active chart editor part. |
| 11 |
* |
|
| 11 | 12 |
* @author sjacquot |
| 12 | 13 |
* |
| 13 | 14 |
*/ |
| ... | ... | |
| 20 | 21 |
|
| 21 | 22 |
try {
|
| 22 | 23 |
chartEditor.resetView(); |
| 23 |
// chartEditor.forceFocus(); |
|
| 24 | 24 |
} |
| 25 | 25 |
catch (Exception e) {
|
| 26 | 26 |
// nothing to do |
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/handlers/ExportChart.java (revision 1841) | ||
|---|---|---|
| 45 | 45 |
import org.txm.chartsengine.core.results.ChartResult; |
| 46 | 46 |
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider; |
| 47 | 47 |
import org.txm.core.preferences.TBXPreferences; |
| 48 |
import org.txm.core.preferences.TXMPreferences; |
|
| 49 |
import org.txm.core.results.TXMResult; |
|
| 50 | 48 |
import org.txm.rcp.JobsTimer; |
| 51 | 49 |
import org.txm.rcp.StatusLine; |
| 52 | 50 |
import org.txm.rcp.commands.OpenGraph; |
| ... | ... | |
| 64 | 62 |
* @author sjacquot |
| 65 | 63 |
* |
| 66 | 64 |
*/ |
| 65 |
// FIXME: SJ: this class should not used the SWTChartsComponentsProvider but directly the current charts engine |
|
| 67 | 66 |
public class ExportChart extends BaseAbstractHandler {
|
| 68 | 67 |
|
| 69 | 68 |
private static final String ID = "ExportChart"; //$NON-NLS-1$ |
| ... | ... | |
| 91 | 90 |
extensions[i] = "*." + SWTChartsComponentsProvider.getCurrent().getChartsEngineSupportedExportFileFormats().get(i); //$NON-NLS-1$ |
| 92 | 91 |
|
| 93 | 92 |
// Store the default chart export file format index |
| 94 |
if(ChartsEnginePreferences.getInstance().getString(ChartsEnginePreferences.DEFAULT_EXPORT_FORMAT).equals(SWTChartsComponentsProvider.getCurrent().getEditorSupportedExportFileFormats().get(i))) {
|
|
| 93 |
if(ChartsEnginePreferences.getInstance().getString(ChartsEnginePreferences.DEFAULT_EXPORT_FORMAT).equals(SWTChartsComponentsProvider.getCurrent().getChartsEngineSupportedExportFileFormats().get(i))) {
|
|
| 95 | 94 |
defaultChartFormatIndex = i; |
| 96 | 95 |
} |
| 97 | 96 |
} |
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/handlers/ExportChartEditorView.java (revision 1841) | ||
|---|---|---|
| 46 | 46 |
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences; |
| 47 | 47 |
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider; |
| 48 | 48 |
import org.txm.chartsengine.rcp.editors.ChartEditor; |
| 49 |
import org.txm.core.messages.TXMCoreMessages; |
|
| 49 | 50 |
import org.txm.core.preferences.TBXPreferences; |
| 50 |
import org.txm.core.preferences.TXMPreferences; |
|
| 51 | 51 |
import org.txm.rcp.JobsTimer; |
| 52 | 52 |
import org.txm.rcp.StatusLine; |
| 53 | 53 |
import org.txm.rcp.commands.OpenGraph; |
| ... | ... | |
| 57 | 57 |
import org.txm.utils.logger.Log; |
| 58 | 58 |
|
| 59 | 59 |
/** |
| 60 |
* Exports chart editor view using chart editor export.
|
|
| 61 |
* Exports the chart view as it drawn in the editor (cropped, panned, etc.). |
|
| 60 |
* Exports chart editor view using chart composite export.
|
|
| 61 |
* Exports the chart view as it is drawn in the editor (cropped, panned, etc.).
|
|
| 62 | 62 |
* |
| 63 | 63 |
* @author mdecorde |
| 64 | 64 |
* @author sjacquot |
| ... | ... | |
| 68 | 68 |
|
| 69 | 69 |
public static final String ID = "org.txm.chartsengine.rcp.handlers.ExportChartEditorView"; //$NON-NLS-1$ |
| 70 | 70 |
|
| 71 |
|
|
| 71 | 72 |
@Override |
| 72 | 73 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
| 73 | 74 |
|
| ... | ... | |
| 77 | 78 |
final FileDialog dialog = new FileDialog(shell, SWT.SAVE); |
| 78 | 79 |
|
| 79 | 80 |
// Create the file extensions from the current chart editor supported file formats |
| 80 |
String extensions[] = new String[chartEditor.getSWTChartsComponentsProvider().getEditorSupportedExportFileFormats().size()];
|
|
| 81 |
String extensions[] = new String[chartEditor.getEditorSupportedExportFileFormats().size()]; |
|
| 81 | 82 |
int defaultChartFormatIndex = 0; |
| 82 |
for(int i = 0; i < chartEditor.getSWTChartsComponentsProvider().getEditorSupportedExportFileFormats().size(); i++) {
|
|
| 83 |
extensions[i] = "*." + chartEditor.getSWTChartsComponentsProvider().getEditorSupportedExportFileFormats().get(i); //$NON-NLS-1$
|
|
| 83 |
for(int i = 0; i < chartEditor.getEditorSupportedExportFileFormats().size(); i++) {
|
|
| 84 |
extensions[i] = "*." + chartEditor.getEditorSupportedExportFileFormats().get(i); //$NON-NLS-1$ |
|
| 84 | 85 |
|
| 85 | 86 |
// Store the default chart export file format index |
| 86 |
if(ChartsEnginePreferences.getInstance().getString(ChartsEnginePreferences.DEFAULT_EXPORT_FORMAT).equals(chartEditor.getSWTChartsComponentsProvider().getEditorSupportedExportFileFormats().get(i))) {
|
|
| 87 |
if(ChartsEnginePreferences.getInstance().getString(ChartsEnginePreferences.DEFAULT_EXPORT_FORMAT).equals(chartEditor.getEditorSupportedExportFileFormats().get(i))) {
|
|
| 87 | 88 |
defaultChartFormatIndex = i; |
| 88 | 89 |
} |
| 89 | 90 |
} |
| 90 | 91 |
|
| 91 | 92 |
dialog.setFilterExtensions(extensions); |
| 92 |
// Select default chart export file format |
|
| 93 |
|
|
| 94 |
// Select default chart export file format according to the user preferences |
|
| 93 | 95 |
dialog.setFilterIndex(defaultChartFormatIndex); |
| 94 | 96 |
|
| 95 | 97 |
dialog.setFileName(chartEditor.getResult().getValidFileName()); |
| ... | ... | |
| 108 | 110 |
filepath += suffix; |
| 109 | 111 |
} |
| 110 | 112 |
final File file = new File(filepath); |
| 111 |
StatusLine.setMessage("Exporting view: " + file);
|
|
| 112 |
|
|
| 113 |
|
|
| 113 | 114 |
LastOpened.set(ID, file.getParent(), file.getName()); |
| 114 | 115 |
|
| 115 | 116 |
try {
|
| 116 | 117 |
file.createNewFile(); |
| 117 | 118 |
} |
| 118 | 119 |
catch(IOException e1) {
|
| 119 |
System.err.println(NLS.bind(TXMUIMessages.exportColonCantCreateFileP0ColonP1, file, e1));
|
|
| 120 |
Log.severe(TXMCoreMessages.bind(TXMUIMessages.exportColonCantCreateFileP0ColonP1, file, e1));
|
|
| 120 | 121 |
} |
| 121 | 122 |
if(!file.canWrite()) {
|
| 122 |
System.err.println(NLS.bind(TXMUIMessages.impossibleToReadP0, file));
|
|
| 123 |
Log.severe(TXMCoreMessages.bind(TXMUIMessages.impossibleToReadP0, file));
|
|
| 123 | 124 |
} |
| 124 | 125 |
if(!file.isFile()) {
|
| 125 |
System.err.println("Error: " + file + " is not a file"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 126 |
Log.severe(TXMCoreMessages.bind("Error: {0} is not a file.", file));
|
|
| 126 | 127 |
} |
| 127 | 128 |
|
| 128 |
JobHandler jobhandler = new JobHandler(TXMUIMessages.exportingResults) {
|
|
| 129 |
JobHandler jobhandler = new JobHandler(TXMCoreMessages.bind("Exporting current chart view to file {0}...", file.getAbsolutePath())) {
|
|
| 129 | 130 |
@Override |
| 130 | 131 |
protected IStatus run(IProgressMonitor monitor) {
|
| 131 | 132 |
try {
|
| 132 | 133 |
this.runInit(monitor); |
| 133 | 134 |
monitor.beginTask(TXMUIMessages.exporting, 100); |
| 134 | 135 |
|
| 135 |
String outputFormat = chartEditor.getSWTChartsComponentsProvider().getEditorSupportedExportFileFormats().get(dialog.getFilterIndex());
|
|
| 136 |
String outputFormat = (String) chartEditor.getEditorSupportedExportFileFormats().get(dialog.getFilterIndex());
|
|
| 136 | 137 |
chartEditor.exportView(file, outputFormat); |
| 137 | 138 |
|
| 138 | 139 |
if(file.exists()) {
|
| 139 | 140 |
|
| 140 |
System.out.println(NLS.bind(TXMUIMessages.p1ExportSavedInFileColonP0, file.getAbsolutePath(), outputFormat.toUpperCase()));
|
|
| 141 |
Log.info(NLS.bind(TXMUIMessages.p1ExportSavedInFileColonP0, file.getAbsolutePath(), outputFormat.toUpperCase()));
|
|
| 141 | 142 |
|
| 142 | 143 |
// Open internal editor in the UI thread |
| 143 | 144 |
if(TBXPreferences.getInstance().getBoolean(TBXPreferences.EXPORT_SHOW)) {
|
| ... | ... | |
| 150 | 151 |
} |
| 151 | 152 |
} |
| 152 | 153 |
else {
|
| 153 |
System.out.println(NLS.bind(TXMUIMessages.failedToExportInFileP0WithFormatP1, file.getAbsolutePath(), outputFormat));
|
|
| 154 |
Log.severe(NLS.bind(TXMUIMessages.failedToExportInFileP0WithFormatP1, file.getAbsolutePath(), outputFormat));
|
|
| 154 | 155 |
} |
| 155 | 156 |
} |
| 156 | 157 |
catch(ThreadDeath td) {
|
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/SWTChartsComponentsProvider.java (revision 1841) | ||
|---|---|---|
| 1 | 1 |
package org.txm.chartsengine.rcp; |
| 2 | 2 |
|
| 3 | 3 |
|
| 4 |
import java.awt.AWTEvent; |
|
| 5 |
import java.awt.Frame; |
|
| 6 |
import java.awt.event.MouseEvent; |
|
| 7 |
import java.awt.event.MouseListener; |
|
| 8 |
import java.awt.event.MouseMotionListener; |
|
| 9 | 4 |
import java.io.File; |
| 10 | 5 |
import java.util.ArrayList; |
| 11 | 6 |
import java.util.Arrays; |
| 12 | 7 |
import java.util.List; |
| 13 | 8 |
import java.util.Properties; |
| 14 | 9 |
|
| 15 |
import javax.swing.JComponent; |
|
| 16 |
|
|
| 17 | 10 |
import org.eclipse.core.commands.ExecutionEvent; |
| 18 | 11 |
import org.eclipse.core.runtime.CoreException; |
| 19 | 12 |
import org.eclipse.core.runtime.IConfigurationElement; |
| ... | ... | |
| 21 | 14 |
import org.eclipse.jface.preference.BooleanFieldEditor; |
| 22 | 15 |
import org.eclipse.jface.preference.ComboFieldEditor; |
| 23 | 16 |
import org.eclipse.swt.SWT; |
| 24 |
import org.eclipse.swt.graphics.Point; |
|
| 25 | 17 |
import org.eclipse.swt.layout.GridData; |
| 26 | 18 |
import org.eclipse.swt.widgets.Composite; |
| 27 | 19 |
import org.eclipse.swt.widgets.Event; |
| 28 | 20 |
import org.eclipse.swt.widgets.Group; |
| 29 | 21 |
import org.eclipse.swt.widgets.Label; |
| 30 |
import org.eclipse.swt.widgets.Listener; |
|
| 31 | 22 |
import org.eclipse.swt.widgets.TabFolder; |
| 32 | 23 |
import org.eclipse.swt.widgets.TabItem; |
| 33 | 24 |
import org.eclipse.swt.widgets.ToolBar; |
| 34 | 25 |
import org.eclipse.swt.widgets.ToolItem; |
| 35 | 26 |
import org.eclipse.swt.widgets.Widget; |
| 36 |
import org.eclipse.ui.IPartListener; |
|
| 37 |
import org.eclipse.ui.IPartService; |
|
| 38 |
import org.eclipse.ui.IWorkbenchPage; |
|
| 39 |
import org.eclipse.ui.IWorkbenchPart; |
|
| 40 |
import org.eclipse.ui.IWorkbenchWindow; |
|
| 41 |
import org.eclipse.ui.PartInitException; |
|
| 42 | 27 |
import org.eclipse.ui.PlatformUI; |
| 43 | 28 |
import org.txm.chartsengine.core.ChartsEngine; |
| 44 | 29 |
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences; |
| 45 |
import org.txm.chartsengine.core.results.ChartResult; |
|
| 46 | 30 |
import org.txm.chartsengine.rcp.editors.ChartEditor; |
| 47 |
import org.txm.chartsengine.rcp.editors.ChartEditorInput; |
|
| 48 |
import org.txm.chartsengine.rcp.events.EventCallBack; |
|
| 49 | 31 |
import org.txm.chartsengine.rcp.messages.ChartsUIMessages; |
| 50 | 32 |
import org.txm.chartsengine.rcp.preferences.___KeyboardBindingProperties; |
| 51 | 33 |
import org.txm.chartsengine.rcp.preferences.___MouseBindingProperties; |
| 52 | 34 |
import org.txm.chartsengine.rcp.swt.AdvancedChartEditorToolBar; |
| 53 | 35 |
import org.txm.chartsengine.rcp.swt.ChartComposite; |
| 54 | 36 |
import org.txm.chartsengine.rcp.swt.ChartEditorToolBar; |
| 37 |
import org.txm.core.messages.TXMCoreMessages; |
|
| 55 | 38 |
import org.txm.core.preferences.TXMPreferences; |
| 56 | 39 |
import org.txm.rcp.editors.TXMMultiPageEditor; |
| 57 | 40 |
import org.txm.rcp.preferences.TXMPreferencePage; |
| ... | ... | |
| 68 | 51 |
|
| 69 | 52 |
|
| 70 | 53 |
|
| 71 |
|
|
| 72 |
|
|
| 73 | 54 |
// FIXME: should be done in an activator? |
| 74 | 55 |
static {
|
| 75 | 56 |
// Initializes the SWT Charts Components provider according to the current charts engine and its output format |
| ... | ... | |
| 77 | 58 |
SWTChartsComponentsProvider.setCurrrentComponentsProvider(ChartsEngine.getCurrent()); |
| 78 | 59 |
} |
| 79 | 60 |
|
| 80 |
|
|
| 81 |
static {
|
|
| 82 |
|
|
| 83 |
// FIXME: SJ: test to fix the Swing focus problems on the 3 OS |
|
| 84 |
IPartService service = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService(); |
|
| 85 |
service.addPartListener(new IPartListener() {
|
|
| 86 |
|
|
| 87 |
@Override |
|
| 88 |
public void partOpened(IWorkbenchPart part) {
|
|
| 89 |
// TODO Auto-generated method stub |
|
| 90 |
|
|
| 91 |
} |
|
| 92 |
|
|
| 93 |
@Override |
|
| 94 |
public void partDeactivated(IWorkbenchPart part) {
|
|
| 95 |
if(part instanceof ChartEditor) {
|
|
| 96 |
((ChartEditor) part).onPartDeactivated(); |
|
| 97 |
} |
|
| 98 |
} |
|
| 99 |
|
|
| 100 |
@Override |
|
| 101 |
public void partClosed(IWorkbenchPart part) {
|
|
| 102 |
// TODO Auto-generated method stub |
|
| 103 |
|
|
| 104 |
} |
|
| 105 |
|
|
| 106 |
@Override |
|
| 107 |
public void partBroughtToTop(IWorkbenchPart part) {
|
|
| 108 |
// TODO Auto-generated method stub |
|
| 109 |
|
|
| 110 |
} |
|
| 111 |
|
|
| 112 |
@Override |
|
| 113 |
public void partActivated(IWorkbenchPart part) {
|
|
| 114 |
if(part instanceof ChartEditor) {
|
|
| 115 |
((ChartEditor) part).onPartActivated(); |
|
| 116 |
} |
|
| 117 |
} |
|
| 118 |
}); |
|
| 119 |
|
|
| 120 |
} |
|
| 121 |
|
|
| 122 |
|
|
| 61 |
|
|
| 123 | 62 |
/** |
| 124 | 63 |
* The charts engine. |
| 125 | 64 |
*/ |
| ... | ... | |
| 167 | 106 |
this.mouseBindingProperties = mouseBindingProperties; |
| 168 | 107 |
this.keyboardBindingProperties = keyboardBindingProperties; |
| 169 | 108 |
|
| 170 |
// FIXME : see if we need to define the L&F as system for AWT/Swing components |
|
| 109 |
// FIXME : SJ: see if we need to define the L&F as system for AWT/Swing components
|
|
| 171 | 110 |
// If yes, we need to find a way to manage the GTK L&F/Linux bug, see ticket #761 |
| 172 | 111 |
// System Look and feel |
| 173 | 112 |
// try {
|
| ... | ... | |
| 199 | 138 |
public SWTChartsComponentsProvider(ChartsEngine chartsEngine) {
|
| 200 | 139 |
this(chartsEngine, new ___MouseBindingProperties(), new ___KeyboardBindingProperties()); |
| 201 | 140 |
} |
| 202 |
|
|
| 203 | 141 |
|
| 204 | 142 |
/** |
| 205 | 143 |
* |
| ... | ... | |
| 208 | 146 |
this(null); |
| 209 | 147 |
} |
| 210 | 148 |
|
| 149 |
|
|
| 211 | 150 |
|
| 212 | 151 |
/** |
| 213 |
* Creates a <code>ChartEditorInput</code> for the specified chart result. |
|
| 214 |
* @param result |
|
| 215 |
* @return a <code>ChartEditorInput</code> |
|
| 152 |
* Creates and stores SWT charts components providers from installed extension contributions and defines the current one according to the specified charts engine output format and provider supported input format. |
|
| 216 | 153 |
*/ |
| 217 |
public ChartEditorInput createChartEditorInput(ChartResult result) {
|
|
| 218 |
return new ChartEditorInput(this, result); |
|
| 219 |
} |
|
| 220 |
|
|
| 221 |
/** |
|
| 222 |
* Creates a new chart component for the specified <code>ChartResult</code> save it in the specified <code>ChartEditorInput</code>. |
|
| 223 |
* |
|
| 224 |
* @param chartsEngine |
|
| 225 |
* @param chartEditorInput |
|
| 226 |
* @param result |
|
| 227 |
* @param preferencesNode |
|
| 228 |
* @param chartType |
|
| 229 |
* @return |
|
| 230 |
*/ |
|
| 231 |
protected abstract boolean createChartComponent(ChartsEngine chartsEngine, ChartEditorInput chartEditorInput); |
|
| 232 |
|
|
| 233 |
/** |
|
| 234 |
* Creates a new chart component for the specified <code>ChartResult</code> save it in the specified <code>ChartEditorInput</code>. |
|
| 235 |
* |
|
| 236 |
* @param chartEditorInput |
|
| 237 |
* @param result |
|
| 238 |
* @param preferencesNode |
|
| 239 |
* @param chartType |
|
| 240 |
* @return |
|
| 241 |
*/ |
|
| 242 |
public boolean createChartComponent(ChartEditorInput chartEditorInput) {
|
|
| 243 |
Log.finest(this.getClass().getSimpleName() + ": creating a chart component..."); |
|
| 244 |
return this.createChartComponent(this.getChartsEngine(), chartEditorInput); |
|
| 245 |
} |
|
| 246 |
|
|
| 247 |
|
|
| 248 |
/** |
|
| 249 |
* Creates and stores SWT charts components providers from installed extension contributions and define the current one according to the specified charts engine output format and provider supported input format. |
|
| 250 |
*/ |
|
| 251 | 154 |
public static void createSWTChartsComponentsProviders() {
|
| 252 | 155 |
|
| 253 | 156 |
|
| ... | ... | |
| 278 | 181 |
swtChartsComponentsProvider.setChartsEngine(chartsEngine); |
| 279 | 182 |
|
| 280 | 183 |
SWTChartsComponentsProvider.chartsComponentsProviders.add(swtChartsComponentsProvider); |
| 281 |
Log.fine("Starting SWT charts components provider: " + swtChartsComponentsProvider + ".");
|
|
| 282 | 184 |
|
| 185 |
Log.fine(TXMCoreMessages.bind("Starting SWT charts components provider: {0}...", swtChartsComponentsProvider));
|
|
| 283 | 186 |
|
| 187 |
|
|
| 284 | 188 |
} |
| 285 | 189 |
catch(CoreException e) {
|
| 286 | 190 |
// TODO Auto-generated catch block |
| ... | ... | |
| 317 | 221 |
|
| 318 | 222 |
|
| 319 | 223 |
/** |
| 320 |
* Gets an SWT charts component provider according to the specified charts engine output format and provider supported input format. |
|
| 224 |
* Gets an SWT charts components provider according to the specified charts engine output format and provider supported input format. |
|
| 225 |
* |
|
| 321 | 226 |
* @param chartsEngine |
| 322 |
* @return |
|
| 227 |
* @return the first components provider that manages the format of the specified charts engine
|
|
| 323 | 228 |
*/ |
| 324 | 229 |
public static SWTChartsComponentsProvider getComponentsProvider(ChartsEngine chartsEngine) {
|
| 325 | 230 |
|
| ... | ... | |
| 339 | 244 |
|
| 340 | 245 |
/** |
| 341 | 246 |
* Gets an installed charts components provider according to its class type. |
| 247 |
* |
|
| 342 | 248 |
* @param type |
| 343 |
* @return the installed charts components provider according to its class type if it exists otherwise null;
|
|
| 249 |
* @return the installed charts components provider according to its class type if it exists otherwise null |
|
| 344 | 250 |
*/ |
| 345 | 251 |
public static SWTChartsComponentsProvider getComponentsProvider(Class type) {
|
| 346 | 252 |
SWTChartsComponentsProvider provider = null; |
| ... | ... | |
| 381 | 287 |
|
| 382 | 288 |
|
| 383 | 289 |
/** |
| 384 |
* Returns the export formats supported by the implementation of the <code>EditorPart</code> for the view. |
|
| 385 |
* @return |
|
| 386 |
*/ |
|
| 387 |
public abstract ArrayList<String> getEditorSupportedExportFileFormats(); |
|
| 388 |
|
|
| 389 |
/** |
|
| 390 | 290 |
* Returns the input formats supported by the implementation of the <code>EditorPart</code> for viewing. |
| 391 | 291 |
* @return |
| 392 | 292 |
*/ |
| ... | ... | |
| 510 | 410 |
|
| 511 | 411 |
} |
| 512 | 412 |
|
| 513 |
|
|
| 514 |
|
|
| 515 | 413 |
/** |
| 516 |
* Export the current view of chart editor in the specified file. |
|
| 517 |
* @param chartEditor |
|
| 518 |
* @param file |
|
| 519 |
* @param fileFormat |
|
| 520 |
* @return |
|
| 521 |
*/ |
|
| 522 |
public abstract File exportView(ChartEditor chartEditor, File file, String fileFormat); |
|
| 523 |
|
|
| 524 |
|
|
| 525 |
/** |
|
| 526 |
* Opens the specified <code>ChartEditor</code> in the active page and registers the event listeners and context menus according to the type of the chart editor part. |
|
| 527 |
* The ID of the editor and the chart type are the editor input result data class name. |
|
| 528 |
* @param chartEditorInput |
|
| 529 |
* @return |
|
| 530 |
*/ |
|
| 531 |
public ChartEditor openEditor(ChartEditorInput chartEditorInput) {
|
|
| 532 |
return this.openEditor(chartEditorInput, chartEditorInput.getResult().getClass().getName()); |
|
| 533 |
} |
|
| 534 |
|
|
| 535 |
|
|
| 536 |
/** |
|
| 537 |
* Opens the <code>ChartEditor</code> specified by its id and ChartEditorInput in the active page and registers the event listeners and context menus according to the <code>EventCallBack</code> installed extensions. |
|
| 538 |
* @param chartEditorInput |
|
| 539 |
* @param editorPartId |
|
| 540 |
* @param chartType |
|
| 541 |
* @return |
|
| 542 |
*/ |
|
| 543 |
// FIXME: this method have some trouble when calling through a progress dialog |
|
| 544 |
// FIXME: this method is not in use anymore since the editor opening is now down in TXMEditor so the code for ChartEngine downgrading is not |
|
| 545 |
// active anymore. Try to use again this code |
|
| 546 |
public ChartEditor openEditor(ChartEditorInput chartEditorInput, String editorPartId) {
|
|
| 547 |
|
|
| 548 |
ChartEditor openedChartEditorPart = null; |
|
| 549 |
|
|
| 550 |
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); |
|
| 551 |
IWorkbenchPage page = window.getActivePage(); |
|
| 552 |
|
|
| 553 |
boolean isAlreadyOpened = page.findEditors(chartEditorInput, editorPartId, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID).length > 0; |
|
| 554 |
|
|
| 555 |
Log.finest("SWTChartsComponentsProvider.openEditor(): opening editor with id " + editorPartId);
|
|
| 556 |
|
|
| 557 |
// if the editor is already open or the charts engine can create the specified chart type |
|
| 558 |
if(isAlreadyOpened || this.chartsEngine.canCreateChart(chartEditorInput.getResult())) {
|
|
| 559 |
|
|
| 560 |
//Log.finest(this.name + " - Opening editor for result data type " + chartEditorInput.getResultData().getClass() + " and editor id " + editorPartId); |
|
| 561 |
|
|
| 562 |
try {
|
|
| 563 |
|
|
| 564 |
openedChartEditorPart = (ChartEditor) page.openEditor(chartEditorInput, editorPartId, true, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID); |
|
| 565 |
openedChartEditorPart.setWasAlreadyOpened(isAlreadyOpened); |
|
| 566 |
|
|
| 567 |
|
|
| 568 |
// directly returns if the editor was already opened |
|
| 569 |
if(isAlreadyOpened) {
|
|
| 570 |
return openedChartEditorPart; |
|
| 571 |
} |
|
| 572 |
} |
|
| 573 |
catch(PartInitException e) {
|
|
| 574 |
e.printStackTrace(); |
|
| 575 |
} |
|
| 576 |
|
|
| 577 |
} |
|
| 578 |
// get the first installed charts engine that can create chart and use the SWT provider matching it |
|
| 579 |
else {
|
|
| 580 |
Log.warning("Rendering failed with current charts engine, trying to rendering chart with other installed SWT components provider and other charts engine:");
|
|
| 581 |
|
|
| 582 |
boolean canCreate = false; |
|
| 583 |
for(int i = 0; i < ChartsEngine.getChartsEngines().size() && !canCreate; i++) {
|
|
| 584 |
if(ChartsEngine.getChartsEngines().get(i) != this.chartsEngine) {
|
|
| 585 |
ChartsEngine chartsEngine = ChartsEngine.getChartsEngines().get(i); |
|
| 586 |
canCreate = chartsEngine.canCreateChart(chartEditorInput.getResult()); |
|
| 587 |
// get a provider that can manage the charts engine |
|
| 588 |
if(canCreate) {
|
|
| 589 |
SWTChartsComponentsProvider provider = SWTChartsComponentsProvider.getComponentsProvider(chartsEngine); |
|
| 590 |
if(provider != null) {
|
|
| 591 |
provider.setChartsEngine(chartsEngine); |
|
| 592 |
chartEditorInput.setSWTChartsComponentsProvider(provider); |
|
| 593 |
Log.fine(provider.toString()); |
|
| 594 |
return provider.openEditor(chartEditorInput, editorPartId); |
|
| 595 |
} |
|
| 596 |
} |
|
| 597 |
} |
|
| 598 |
} |
|
| 599 |
} |
|
| 600 |
|
|
| 601 |
return openedChartEditorPart; |
|
| 602 |
} |
|
| 603 |
|
|
| 604 |
/** |
|
| 605 |
* |
|
| 606 |
* @param titleImage |
|
| 607 |
* @param editorInputName |
|
| 608 |
* @param result |
|
| 609 |
* @param chartType |
|
| 610 |
* @param params |
|
| 611 |
* @return |
|
| 612 |
*/ |
|
| 613 |
public ChartEditor openEditor(ChartResult result) {
|
|
| 614 |
return this.openEditor(this.createChartEditorInput(result), result.getClass().getName()); |
|
| 615 |
} |
|
| 616 |
|
|
| 617 |
|
|
| 618 |
// /** |
|
| 619 |
// * Initializes the default context menus. |
|
| 620 |
// * @param composite |
|
| 621 |
// */ |
|
| 622 |
// public static void initDefaultContextMenus(ChartComposite composite) {
|
|
| 623 |
// if(composite != null) {
|
|
| 624 |
// composite.initItemAreaContextMenu(); |
|
| 625 |
// composite.initEmptyAreaContextMenu(); |
|
| 626 |
// composite.setCurrentContextMenu(EventCallBack.AREA_EMPTY); |
|
| 627 |
// } |
|
| 628 |
// } |
|
| 629 |
|
|
| 630 |
|
|
| 631 |
/** |
|
| 632 | 414 |
* Gets the current active chart editor managing the multi pages editor. |
| 633 | 415 |
* @param event |
| 634 | 416 |
* @return |
| ... | ... | |
| 656 | 438 |
&& ((ChartEditor)((TXMMultiPageEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart()).getMainEditorPart()).hasFocus()) {
|
| 657 | 439 |
chartEditor = (ChartEditor)((TXMMultiPageEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart()).getMainEditorPart(); |
| 658 | 440 |
} |
| 659 |
// FIXME: became useless? |
|
| 441 |
// FIXME: SJ: became useless?
|
|
| 660 | 442 |
// else if(((MultiPageEditorPart) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()).getSelectedPage() instanceof ChartEditor |
| 661 | 443 |
// && ((ChartEditor)((MultiPageEditorPart) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()).getSelectedPage()).hasFocus() ) {
|
| 662 | 444 |
// chartEditor = (ChartEditor)((MultiPageEditorPart) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()).getSelectedPage(); |
| ... | ... | |
| 674 | 456 |
|
| 675 | 457 |
@Override |
| 676 | 458 |
public String toString() {
|
| 677 |
String str = this.name + " ("; //$NON-NLS-1$
|
|
| 678 |
str += "supported input formats: " + this.supportedInputFormats.toString().replaceAll("\\[|\\]", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 679 |
str += ", Charts Engine: " + this.chartsEngine + ")"; //$NON-NLS-1$ //$NON-NLS-2$ |
|
| 680 |
return str; |
|
| 459 |
return String.format("%s (supported input formats: %s, Charts Engine: %s)", this.name, this.supportedInputFormats.toString().replaceAll("\\[|\\]", ""), this.chartsEngine); //$NON-NLS-1$
|
|
| 681 | 460 |
} |
| 682 | 461 |
|
| 683 | 462 |
|
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/events/EventCallBackHandler.java (revision 1841) | ||
|---|---|---|
| 6 | 6 |
import java.util.ArrayList; |
| 7 | 7 |
|
| 8 | 8 |
import org.txm.chartsengine.rcp.IChartComponent; |
| 9 |
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider; |
|
| 10 | 9 |
import org.txm.utils.logger.Log; |
| 11 | 10 |
|
| 12 | 11 |
/** |
| 13 | 12 |
* Abstract chart event handler. |
| 14 | 13 |
* This is the superclass of custom listeners dedicated to various chart types. |
| 14 |
* |
|
| 15 | 15 |
* @author sjacquot |
| 16 | 16 |
* |
| 17 | 17 |
*/ |
| ... | ... | |
| 19 | 19 |
|
| 20 | 20 |
|
| 21 | 21 |
/** |
| 22 |
* The linked SWT Charts Component Provider. |
|
| 23 |
*/ |
|
| 24 |
protected SWTChartsComponentsProvider swtChartsComponentProvider; |
|
| 25 |
|
|
| 26 |
/** |
|
| 27 | 22 |
* The chart UI component. |
| 28 | 23 |
*/ |
| 29 | 24 |
protected IChartComponent chartComponent; |
| ... | ... | |
| 38 | 33 |
* |
| 39 | 34 |
* @param swtChartsComponentProvider |
| 40 | 35 |
*/ |
| 41 |
public EventCallBackHandler(SWTChartsComponentsProvider swtChartsComponentProvider, IChartComponent chartComponent) {
|
|
| 42 |
this.swtChartsComponentProvider = swtChartsComponentProvider; |
|
| 36 |
public EventCallBackHandler(IChartComponent chartComponent) {
|
|
| 43 | 37 |
this.chartComponent = chartComponent; |
| 44 | 38 |
this.eventCallBacks = new ArrayList<EventCallBack>(); |
| 45 | 39 |
} |
| ... | ... | |
| 53 | 47 |
// Do not add to event call backs of same type |
| 54 | 48 |
for(int i = 0; i < this.eventCallBacks.size(); i++) {
|
| 55 | 49 |
if(this.eventCallBacks.get(i).getClass().equals(eventCallBack.getClass())) {
|
| 56 |
Log.fine("Event call back handler warning: the event call back of type \"" + eventCallBack.getClass() + "\" has not been registered because one of same type is already registered."); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 50 |
Log.fine(String.format("Event call back handler warning: the event call back of type \"%s\" has not been registered because one of same type is already registered.", eventCallBack.getClass())); //$NON-NLS-1$
|
|
| 57 | 51 |
return; |
| 58 | 52 |
} |
| 59 | 53 |
} |
| 60 | 54 |
this.eventCallBacks.add(eventCallBack); |
| 61 |
eventCallBack.setSwtChartsComponentProvider(this.swtChartsComponentProvider); |
|
| 62 | 55 |
} |
| 63 | 56 |
|
| 64 | 57 |
|
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/events/EventCallBack.java (revision 1841) | ||
|---|---|---|
| 27 | 27 |
*/ |
| 28 | 28 |
protected ChartEditor chartEditor; |
| 29 | 29 |
|
| 30 |
|
|
| 31 |
|
|
| 32 | 30 |
/** |
| 33 |
* The linked SWT Charts Component Provider. |
|
| 34 |
*/ |
|
| 35 |
protected SWTChartsComponentsProvider swtChartsComponentProvider; |
|
| 36 |
|
|
| 37 |
|
|
| 38 |
/** |
|
| 39 | 31 |
* |
| 40 | 32 |
*/ |
| 41 | 33 |
public EventCallBack() {
|
| ... | ... | |
| 50 | 42 |
* @param customData |
| 51 | 43 |
*/ |
| 52 | 44 |
public abstract void processEvent(AWTEvent event, int eventArea, Object customData); |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
/** |
|
| 57 |
* @param swtChartsComponentProvider the swtChartsComponentProvider to set |
|
| 58 |
*/ |
|
| 59 |
public void setSwtChartsComponentProvider(SWTChartsComponentsProvider swtChartsComponentProvider) {
|
|
| 60 |
this.swtChartsComponentProvider = swtChartsComponentProvider; |
|
| 61 |
} |
|
| 62 | 45 |
|
| 63 |
|
|
| 64 | 46 |
/** |
| 65 | 47 |
* @param chartEditor the chartEditor to set |
| 66 | 48 |
*/ |
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/events/ChartKeyListener.java (revision 1841) | ||
|---|---|---|
| 4 | 4 |
import java.awt.event.KeyListener; |
| 5 | 5 |
|
| 6 | 6 |
import org.txm.chartsengine.rcp.IChartComponent; |
| 7 |
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider; |
|
| 8 | 7 |
|
| 9 | 8 |
/** |
| 10 | 9 |
* Chart key listener. |
| 11 | 10 |
* This is the superclass of custom key listeners dedicated to various chart types. |
| 11 |
* |
|
| 12 | 12 |
* @author sjacquot |
| 13 | 13 |
* |
| 14 | 14 |
*/ |
| ... | ... | |
| 20 | 20 |
* Creates a chart key listener and registers the default zoom and pan call backs handler. |
| 21 | 21 |
* @param chartComponent |
| 22 | 22 |
*/ |
| 23 |
public ChartKeyListener(SWTChartsComponentsProvider swtChartsComponentProvider, IChartComponent chartComponent, double keyPressedPanFactor) {
|
|
| 24 |
super(swtChartsComponentProvider, chartComponent);
|
|
| 23 |
public ChartKeyListener(IChartComponent chartComponent, double keyPressedPanFactor) {
|
|
| 24 |
super(chartComponent); |
|
| 25 | 25 |
|
| 26 | 26 |
// register default zoom and pan call back |
| 27 | 27 |
this.registerEventCallBack(new ZoomAndPanCallBack(keyPressedPanFactor)); |
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/events/AbstractChartMouseListener.java (revision 1841) | ||
|---|---|---|
| 10 | 10 |
/** |
| 11 | 11 |
* Abstract chart mouse listener. |
| 12 | 12 |
* This is the superclass of custom mouse listeners dedicated to various chart types. |
| 13 |
* |
|
| 13 | 14 |
* @author sjacquot |
| 14 | 15 |
* |
| 15 | 16 |
*/ |
| ... | ... | |
| 41 | 42 |
* |
| 42 | 43 |
* @param chartPanel |
| 43 | 44 |
*/ |
| 44 |
public AbstractChartMouseListener(SWTChartsComponentsProvider swtChartsComponentProvider, IChartComponent chartPanel) {
|
|
| 45 |
super(swtChartsComponentProvider, chartPanel);
|
|
| 45 |
public AbstractChartMouseListener(IChartComponent chartPanel) {
|
|
| 46 |
super(chartPanel); |
|
| 46 | 47 |
|
| 47 | 48 |
// FIXME: Add default mouse handler for zoom and pan here rather than in subclasses ? |
| 48 | 49 |
|
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditor.java (revision 1841) | ||
|---|---|---|
| 2 | 2 |
|
| 3 | 3 |
|
| 4 | 4 |
import java.io.File; |
| 5 |
import java.util.ArrayList; |
|
| 5 | 6 |
|
| 6 |
import javax.swing.JComponent; |
|
| 7 |
|
|
| 8 |
import org.eclipse.core.runtime.CoreException; |
|
| 9 |
import org.eclipse.core.runtime.IConfigurationElement; |
|
| 10 |
import org.eclipse.core.runtime.Platform; |
|
| 11 | 7 |
import org.eclipse.swt.SWT; |
| 12 | 8 |
import org.eclipse.swt.layout.GridData; |
| 13 | 9 |
import org.eclipse.swt.widgets.Composite; |
| 14 | 10 |
import org.eclipse.swt.widgets.Group; |
| 15 | 11 |
import org.eclipse.swt.widgets.ToolItem; |
| 12 |
import org.eclipse.ui.IPartListener; |
|
| 13 |
import org.eclipse.ui.IPartService; |
|
| 14 |
import org.eclipse.ui.IWorkbenchPart; |
|
| 16 | 15 |
import org.eclipse.ui.PlatformUI; |
| 17 | 16 |
import org.eclipse.ui.contexts.IContextActivation; |
| 18 | 17 |
import org.eclipse.ui.contexts.IContextService; |
| 19 | 18 |
import org.eclipse.ui.part.MultiPageEditorPart; |
| 20 | 19 |
import org.txm.chartsengine.core.ChartsEngine; |
| 21 |
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences; |
|
| 22 | 20 |
import org.txm.chartsengine.core.results.ChartResult; |
| 23 | 21 |
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider; |
| 24 |
import org.txm.chartsengine.rcp.events.EventCallBack; |
|
| 25 |
import org.txm.chartsengine.rcp.events.EventCallBackHandler; |
|
| 26 | 22 |
import org.txm.chartsengine.rcp.messages.ChartsUIMessages; |
| 27 | 23 |
import org.txm.chartsengine.rcp.swt.AdvancedChartEditorToolBar; |
| 28 | 24 |
import org.txm.chartsengine.rcp.swt.ChartComposite; |
| 29 | 25 |
import org.txm.chartsengine.rcp.swt.ChartEditorToolBar; |
| 30 |
import org.txm.chartsengine.rcp.swt.SwingChartComposite; |
|
| 31 | 26 |
import org.txm.core.messages.TXMCoreMessages; |
| 32 | 27 |
import org.txm.rcp.editors.TXMEditor; |
| 33 | 28 |
import org.txm.rcp.editors.TXMMultiPageEditor; |
| ... | ... | |
| 43 | 38 |
|
| 44 | 39 |
public final static String CONTEXT_ID_CHART_EDITOR = ChartEditor.class.getName(); |
| 45 | 40 |
|
| 41 |
|
|
| 42 |
// ChartEditor context activation/deactivation |
|
| 43 |
static {
|
|
| 44 |
|
|
| 45 |
IPartService service = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService(); |
|
| 46 |
service.addPartListener(new IPartListener() {
|
|
| 47 |
|
|
| 48 |
@Override |
|
| 49 |
public void partOpened(IWorkbenchPart part) {
|
|
| 50 |
// TODO Auto-generated method stub |
|
| 51 |
|
|
| 52 |
} |
|
| 53 |
|
|
| 54 |
@Override |
|
| 55 |
public void partDeactivated(IWorkbenchPart part) {
|
|
| 56 |
if(part instanceof ChartEditor) {
|
|
| 57 |
((ChartEditor) part).onPartDeactivated(); |
|
| 58 |
} |
|
| 59 |
} |
|
| 60 |
|
|
| 61 |
@Override |
|
| 62 |
public void partClosed(IWorkbenchPart part) {
|
|
| 63 |
// TODO Auto-generated method stub |
|
| 64 |
|
|
| 65 |
} |
|
| 66 |
|
|
| 67 |
@Override |
|
| 68 |
public void partBroughtToTop(IWorkbenchPart part) {
|
|
| 69 |
// TODO Auto-generated method stub |
|
| 70 |
|
|
| 71 |
} |
|
| 72 |
|
|
| 73 |
@Override |
|
| 74 |
public void partActivated(IWorkbenchPart part) {
|
|
| 75 |
if(part instanceof ChartEditor) {
|
|
| 76 |
((ChartEditor) part).onPartActivated(); |
|
| 77 |
} |
|
| 78 |
} |
|
| 79 |
}); |
|
| 80 |
|
|
| 81 |
} |
|
| 82 |
|
|
| 83 |
|
|
| 46 | 84 |
/** |
| 85 |
* SWT chart components provider used to create the chart composite. |
|
| 86 |
* Store it allows the switch of component provider in the RCP in keeping the chart editors in a coherent state, by testing that the SWT Components providers charts engine match the result charts engine. |
|
| 87 |
*/ |
|
| 88 |
protected SWTChartsComponentsProvider swtChartsComponentsProvider; |
|
| 89 |
|
|
| 90 |
/** |
|
| 47 | 91 |
* The tool bar. |
| 48 | 92 |
*/ |
| 49 | 93 |
protected ChartEditorToolBar chartToolBar; |
| ... | ... | |
| 90 | 134 |
|
| 91 | 135 |
/** |
| 92 | 136 |
* Token used to deactivate the context after it has been activated. |
| 137 |
* The context is used by the RCP to bind keys or contextual menu to an editor. |
|
| 93 | 138 |
*/ |
| 94 | 139 |
protected IContextActivation contextActivationToken; |
| 95 | 140 |
|
| ... | ... | |
| 103 | 148 |
|
| 104 | 149 |
|
| 105 | 150 |
/** |
| 106 |
* |
|
| 151 |
* Creates a new editor.
|
|
| 107 | 152 |
* @param swtComponentsProvider |
| 108 | 153 |
* @param chartEditorInput |
| 109 | 154 |
*/ |
| ... | ... | |
| 140 | 185 |
false); |
| 141 | 186 |
this.advancedChartToolBar = new AdvancedChartEditorToolBar(this, group, this.getParametersGroupsComposite(), SWT.FLAT); |
| 142 | 187 |
|
| 188 |
this.swtChartsComponentsProvider = SWTChartsComponentsProvider.getComponentsProvider(this.getResult().getChartsEngine()); |
|
| 189 |
|
|
| 143 | 190 |
// Chart composite |
| 144 |
this.chartComposite = SWTChartsComponentsProvider.getComponentsProvider(this.getResult().getChartsEngine()).createComposite(this, this.getResultArea());
|
|
| 191 |
this.chartComposite = this.swtChartsComponentsProvider.createComposite(this, this.getResultArea());
|
|
| 145 | 192 |
|
| 146 | 193 |
GridData gd = new GridData(GridData.FILL_BOTH); |
| 147 | 194 |
this.chartComposite.setLayoutData(gd); |
| 148 | 195 |
|
| 149 |
// 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) |
|
| 150 |
// if(composite.getChart() == null) {
|
|
| 151 |
// 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."); |
|
| 152 |
// } |
|
| 153 |
|
|
| 154 |
// FIXME: background color tests |
|
| 155 |
//this.composite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE)); |
|
| 156 |
//parent.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE)); |
|
| 157 |
|
|
| 158 |
|
|
| 159 | 196 |
// subclasses manual creation |
| 160 | 197 |
this.__createPartControl(); |
| 161 | 198 |
|
| ... | ... | |
| 172 | 209 |
|
| 173 | 210 |
} |
| 174 | 211 |
|
| 175 |
// /** |
|
| 176 |
// * Initializes the default context menus. |
|
| 177 |
// */ |
|
| 178 |
// public void initDefaultContextMenus() {
|
|
| 179 |
// SWTChartsComponentsProvider.initDefaultContextMenus(this.chartComposite); |
|
| 180 |
// } |
|
| 181 |
|
|
| 182 |
|
|
| 183 | 212 |
/** |
| 184 | 213 |
* Opens an editor where id is the specified result class name, computes the result then refreshes the editor components. |
| 185 | 214 |
* @param result |
| ... | ... | |
| 188 | 217 |
return openEditor(result, false); |
| 189 | 218 |
} |
| 190 | 219 |
|
| 220 |
/** |
|
| 221 |
* |
|
| 222 |
* @param result |
|
| 223 |
* @param alwaysRecreateEditor |
|
| 224 |
* @return |
|
| 225 |
*/ |
|
| 191 | 226 |
public static ChartEditor openEditor(ChartResult result, boolean alwaysRecreateEditor) {
|
| 192 | 227 |
return openEditor(result, result.getClass().getName(), alwaysRecreateEditor); |
| 193 | 228 |
} |
| 194 | 229 |
|
| 230 |
/** |
|
| 231 |
* |
|
| 232 |
* @param result |
|
| 233 |
* @param editorPartId |
|
| 234 |
* @return |
|
| 235 |
*/ |
|
| 195 | 236 |
public static ChartEditor openEditor(ChartResult result, String editorPartId) {
|
| 196 | 237 |
return openEditor(result, editorPartId, false); |
| 197 | 238 |
} |
| 198 | 239 |
|
| 199 |
|
|
| 200 | 240 |
/** |
| 201 | 241 |
* Opens an editor specified by its id, computes the specified result then refreshes the editor components. |
| 202 | 242 |
* @param result |
| ... | ... | |
| 212 | 252 |
} |
| 213 | 253 |
|
| 214 | 254 |
|
| 215 |
|
|
| 216 | 255 |
@Override |
| 217 | 256 |
public void updateResultFromEditor() {
|
| 218 | 257 |
// does nothing by default |
| ... | ... | |
| 229 | 268 |
public final void updateEditorFromResult(boolean update) {
|
| 230 | 269 |
|
| 231 | 270 |
// check that the charts engine used for the result matches the SWT components provider otherwise find a suitable components provider |
| 232 |
if(this.getResult().getChartsEngine() != this.getSWTChartsComponentsProvider().getChartsEngine()) {
|
|
| 271 |
// and recreate new ChartCoomposite and ChartComponent |
|
| 272 |
if(this.getResult().getChartsEngine() != this.swtChartsComponentsProvider.getChartsEngine()) {
|
|
| 233 | 273 |
|
| 234 |
Log.finest("ChartEditor.__updateEditorFromResult(): result charts engine = " + this.getResult().getChartsEngine().getName() + " / Editor charts engine = " + this.getSWTChartsComponentsProvider().getChartsEngine().getName() + "."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
| 274 |
Log.finest("ChartEditor.__updateEditorFromResult(): result charts engine = " + this.getResult().getChartsEngine().getName() + " / Editor charts engine = " + this.swtChartsComponentsProvider.getChartsEngine().getName() + "."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
| 235 | 275 |
|
| 236 |
this.getEditorInput().setSWTChartsComponentsProvider(SWTChartsComponentsProvider.getComponentsProvider(this.getResult().getChartsEngine())); |
|
| 237 |
this.getSWTChartsComponentsProvider().setChartsEngine(this.getResult().getChartsEngine()); |
|
| 276 |
//this.getEditorInput().setSWTChartsComponentsProvider(SWTChartsComponentsProvider.getComponentsProvider(this.getResult().getChartsEngine())); |
|
| 277 |
this.swtChartsComponentsProvider = SWTChartsComponentsProvider.getComponentsProvider(this.getResult().getChartsEngine()); |
|
| 278 |
this.swtChartsComponentsProvider.setChartsEngine(this.getResult().getChartsEngine()); |
|
| 238 | 279 |
|
| 239 | 280 |
Log.finest("ChartEditor.__updateEditorFromResult(): charts engine used to create the chart does not match the editor one. The SWT components provider has been changed to match it: " + this.getSWTChartsComponentsProvider() + "."); //$NON-NLS-1$ //$NON-NLS-2$
|
| 240 | 281 |
|
| ... | ... | |
| 258 | 299 |
|
| 259 | 300 |
|
| 260 | 301 |
// FIXME: this code should be moved in ChartComposite.loadChart()? |
| 261 |
// if editor wasn't exist: |
|
| 262 |
// hiding command parameters, updating tool bar buttons states, registering context menus and event user callbacks |
|
| 263 |
if(needInit |
|
| 264 |
|
|
| 265 |
//!update |
|
| 266 |
// && !this.getResult().isChartDirty() |
|
| 267 |
) {
|
|
| 268 |
// getSite().getShell().getDisplay().syncExec(new Runnable() {
|
|
| 269 |
// @Override |
|
| 270 |
// public void run() {
|
|
| 271 |
// FIXME: decide if we automatically hide or not the parameter area |
|
| 272 |
//editor2.getTopToolbar().setComputingParametersVisible(false); |
|
| 273 |
|
|
| 274 |
// FIXME: tests to disable command if the chart is null and reenable it when the chart is computed |
|
| 275 |
//editor2.getChartToolBar().synchronize(); |
|
| 276 |
|
|
| 277 |
// initialize the default shared context menus as Export, etc. |
|
| 278 |
//this.initDefaultContextMenus(); |
|
| 279 |
|
|
| 280 |
// registers user entries event call back extensions |
|
| 281 |
// this.registerEventCallBackExtensions(); |
|
| 282 |
|
|
| 283 |
//FIXME: test to contribute to menu only in some context and also for key binding |
|
| 284 |
// create chart editor part context |
|
| 285 |
// this.activateContext(); |
|
| 286 |
// IContextService contextService = (IContextService)getSite().getService(IContextService.class); |
|
| 287 |
// this.contextActivationToken = contextService.activateContext(CONTEXT_ID_CHART_EDITOR); |
|
| 288 |
// // create chart composite context |
|
| 289 |
// contextService.activateContext(this.chartComposite.getClass().getName()); |
|
| 290 |
|
|
| 291 |
//FIXME: description test |
|
| 292 |
//editor2..setContentDescription("details");
|
|
| 293 |
//editor2..setContentDescription(this.getResultData().getDetails()); |
|
| 294 |
|
|
| 295 |
//this.initializeAWTDelegationListeners(); |
|
| 296 |
|
|
| 297 |
// } |
|
| 298 |
// }); |
|
| 299 |
|
|
| 302 |
if(needInit) {
|
|
| 300 | 303 |
this.onInit(); |
| 301 | 304 |
} |
| 302 | 305 |
|
| 303 | 306 |
// sublcass updating |
| 304 | 307 |
this.updateEditorFromChart(update); |
| 305 | 308 |
|
| 306 |
|
|
| 307 |
// if(this.parentMultiPagesEditor == null) {
|
|
| 308 |
// //this.forceFocus(); |
|
| 309 |
// this.activate(); |
|
| 310 |
// } |
|
| 311 | 309 |
} |
| 312 | 310 |
|
| 313 | 311 |
|
| ... | ... | |
| 352 | 350 |
} |
| 353 | 351 |
|
| 354 | 352 |
|
| 355 |
|
|
| 356 |
/** |
|
| 357 |
* Activate the editor in the UI. |
|
| 358 |
*/ |
|
| 359 |
//FIXME: this method doesn't work for Multi pages editor, eg. can not activating CAFactorialMapEditor stored in the CAEditor |
|
| 360 |
public void activate() {
|
|
| 361 |
|
|
| 362 |
// Activate the parent multi pages editor instead of this editor if it exists |
|
| 363 |
if(this.parentMultiPagesEditor != null) {
|
|
| 364 |
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate(this.parentMultiPagesEditor); |
|
| 365 |
} |
|
| 366 |
else {
|
|
| 367 |
// TODO: for focus and activation debug |
|
| 368 |
// System.out.println("ChartEditor.activate(): activating: " + this);
|
|
| 369 |
//PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop(this); |
|
| 370 |
|
|
| 371 |
//this.parent.setFocus(); |
|
| 372 |
|
|
| 373 |
// if(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart() != this) {
|
|
| 374 |
//this.chartComposite.setFocus(); |
|
| 375 |
// } |
|
| 376 |
|
|
| 377 |
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate(this); |
|
| 378 |
|
|
| 379 |
|
|
| 380 |
//getEditorSite().getPage().activate(this); |
|
| 381 |
// if(!this.chartComposite.hasFocus()) {
|
|
| 382 |
// this.chartComposite.setFocus(); |
|
| 383 |
// } |
|
| 384 |
|
|
| 385 |
// System.out.println("ChartEditor.activate(): new active editor = " + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart());
|
|
| 386 |
} |
|
| 387 |
// else {
|
|
| 388 |
// PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop(this); |
|
| 389 |
// } |
|
| 390 |
} |
|
| 391 |
|
|
| 392 |
// /** |
|
| 393 |
// * Forces the Composite to get the focus. |
|
| 394 |
// */ |
|
| 395 |
// public void forceFocus() {
|
|
| 396 |
// // FIXME: debug |
|
| 397 |
// //System.err.println("ChartEditor.forceFocus()");
|
|
| 398 |
// |
|
| 399 |
// //this.chartComposite.setFocus(); |
|
| 400 |
// //this.chartComposite.notifyListeners(SWT.FocusIn, null); // Needed to force the composite listener to handle the focus event |
|
| 401 |
// } |
|
| 402 |
|
|
| 403 |
|
|
| 404 | 353 |
@Override |
| 405 | 354 |
public void setFocus() {
|
| 355 |
|
|
| 356 |
// Debug |
|
| 357 |
Log.finest("ChartEditor.setFocus(): giving focus to chart composite..."); //$NON-NLS-1$
|
|
| 406 | 358 |
|
| 407 |
//this.getEditorSite().getShell().setActive(); |
|
| 408 | 359 |
this.parent.setFocus(); |
| 409 | 360 |
super.setFocus(); |
| 410 |
// Debug |
|
| 411 |
Log.finest("ChartEditor.setFocus(): giving focus to chart composite..."); //$NON-NLS-1$
|
|
| 412 | 361 |
|
| 413 | 362 |
this.chartComposite.setFocus(); |
| 414 | 363 |
|
| ... | ... | |
| 427 | 376 |
} |
| 428 | 377 |
|
| 429 | 378 |
|
| 430 |
// /** |
|
| 431 |
// * Initialize Swing/AWT events delegation. |
|
| 432 |
// * @param swingComponent |
|
| 433 |
// */ |
|
| 434 |
// protected void initializeAWTDelegationListeners() {
|
|
| 435 |
// try {
|
|
| 436 |
// this.getChartComposite().getChartComponent().setChartEditor(this); |
|
| 437 |
// // FIXME: SJ: temporary fix. The composite may not be a SwingChartComposite |
|
| 438 |
// ((SwingChartComposite) this.chartComposite).initializeAWTDelegationListeners(); |
|
| 439 |
// } |
|
| 440 |
// catch (Exception e) {
|
|
| 441 |
// Log.severe("ChartEditor.initializeAWTDelegationListeners(): can not initialize events delegation.");
|
|
| 442 |
// } |
|
| 443 |
// } |
|
| 444 |
|
|
| 445 | 379 |
/** |
| 446 | 380 |
* Convenience method the get the casted linked editor input. |
| 447 | 381 |
* @return the editorInput |
| ... | ... | |
| 451 | 385 |
} |
| 452 | 386 |
|
| 453 | 387 |
|
| 454 |
|
|
| 455 | 388 |
/** |
| 456 | 389 |
* Gets the chart drawing area composite. |
| 457 | 390 |
* @return the composite |
| ... | ... | |
| 575 | 508 |
} |
| 576 | 509 |
|
| 577 | 510 |
/** |
| 578 |
* Returns the chart components provider associated with the editor (through its <code>ChartEditorInput</code>).
|
|
| 511 |
* Returns the chart components provider associated with the editor. |
|
| 579 | 512 |
* @return |
| 580 | 513 |
*/ |
| 581 | 514 |
public SWTChartsComponentsProvider getSWTChartsComponentsProvider() {
|
| 582 |
return this.getEditorInput().getSWTChartsComponentsProvider();
|
|
| 515 |
return this.swtChartsComponentsProvider;
|
|
| 583 | 516 |
} |
| 584 | 517 |
|
| 585 | 518 |
/** |
| 586 |
* Gets the charts engine associated with the editor (through its <code>ChartEditorInput</code>).
|
|
| 519 |
* Gets the charts engine used by the result.
|
|
| 587 | 520 |
* @return |
| 588 | 521 |
*/ |
| 589 | 522 |
public ChartsEngine getChartsEngine() {
|
| ... | ... | |
| 592 | 525 |
|
| 593 | 526 |
/** |
| 594 | 527 |
* Exports the current view of the chart editor in the specified file. |
| 528 |
* |
|
| 595 | 529 |
* @param file |
| 596 | 530 |
* @param fileFormat |
| 597 | 531 |
* @return |
| 598 | 532 |
*/ |
| 599 | 533 |
public File exportView(File file, String fileFormat) {
|
| 600 |
return this.getSWTChartsComponentsProvider().exportView(this, file, fileFormat);
|
|
| 534 |
return this.chartComposite.exportView(file, fileFormat);
|
|
| 601 | 535 |
} |
| 602 | 536 |
|
| 537 |
|
|
| 603 | 538 |
/** |
| 539 |
* Returns the export formats supported by the implementation of the <code>ChartComposite</code> for exporting the current the view. |
|
| 540 |
* |
|
| 541 |
* @return |
|
| 542 |
*/ |
|
| 543 |
public ArrayList<String> getEditorSupportedExportFileFormats() {
|
|
| 544 |
return this.chartComposite.getEditorSupportedExportFileFormats(); |
|
| 545 |
} |
|
| 546 |
|
|
| 547 |
/** |
|
| 604 | 548 |
* Gets the parent multipages editor part if exists. |
| 605 | 549 |
* @return the parentMultiPagesEditor |
| 606 | 550 |
*/ |
| ... | ... | |
| 617 | 561 |
} |
| 618 | 562 |
|
| 619 | 563 |
/** |
| 620 |
* To check whether this editor was already opened when calling SWTChartsComponentsProvider.openEditor().
|
|
| 564 |
* To check whether this editor was already opened when calling openEditor(). |
|
| 621 | 565 |
* @return the wasAlreadyOpened |
| 622 | 566 |
*/ |
| 623 | 567 |
public boolean wasAlreadyOpened() {
|
| ... | ... | |
| 625 | 569 |
} |
| 626 | 570 |
|
| 627 | 571 |
/** |
| 628 |
* To check whether this editor was already opened when calling SWTChartsComponentsProvider.openEditor().
|
|
| 572 |
* To check whether this editor was already opened when calling openEditor(). |
|
| 629 | 573 |
* @param wasAlreadyOpened the wasAlreadyOpened to set |
| 630 | 574 |
*/ |
| 631 | 575 |
public void setWasAlreadyOpened(boolean wasAlreadyOpened) {
|
| ... | ... | |
| 656 | 600 |
return chartToolBar; |
| 657 | 601 |
} |
| 658 | 602 |
|
| 659 |
// @Override |
|
| 660 |
// public boolean isDirty() {
|
|
| 661 |
// boolean d1 = super.isDirty(); |
|
| 662 |
// boolean d2 = this.getResult().isChartDirty(); |
|
| 663 |
// return super.isDirty() && this.getResult().isChartDirty(); |
|
| 664 |
// } |
|
| 665 |
|
|
| 666 |
|
|
| 667 | 603 |
@Override |
| 668 | 604 |
public T getResult() {
|
| 669 | 605 |
return (T) this.getEditorInput().getResult(); |
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditorInput.java (revision 1841) | ||
|---|---|---|
| 1 | 1 |
package org.txm.chartsengine.rcp.editors; |
| 2 | 2 |
|
| 3 |
import org.eclipse.jface.resource.ImageDescriptor; |
|
| 4 |
import org.eclipse.ui.IPersistableElement; |
|
| 5 |
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences; |
|
| 6 | 3 |
import org.txm.chartsengine.core.results.ChartResult; |
| 7 |
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider; |
|
| 8 |
import org.txm.core.preferences.TXMPreferences; |
|
| 9 | 4 |
import org.txm.rcp.editors.TXMResultEditorInput; |
| 10 | 5 |
|
| 11 | 6 |
/** |
| 12 | 7 |
* Base class of all charts SWT <code>IEditorInput</code> implementations. |
| 8 |
* |
|
| 13 | 9 |
* @author sjacquot |
| 14 | 10 |
* |
| 15 | 11 |
*/ |
| 12 |
// FIXME: SJ: this class may be useless, we may use TXMEditorInput instead |
|
| 16 | 13 |
public class ChartEditorInput<T extends ChartResult> extends TXMResultEditorInput<ChartResult> {
|
| 17 | 14 |
|
| 18 | 15 |
|
| 19 | 16 |
/** |
| 20 |
* SWT chart components provider used to create the chart editor. |
|
| 21 |
* Store it allows the switch of component provider in the RCP in keeping the chart editors in a coherent state. |
|
| 22 |
*/ |
|
| 23 |
protected SWTChartsComponentsProvider swtChartsComponentsProvider = null; |
|
| 24 |
|
|
| 25 |
|
|
| 26 |
/** |
|
| 27 |
* The chart component (for example : can be an AWT/Swing component as ChartPanel for JFC, etc.). |
|
| 28 |
*/ |
|
| 29 |
protected Object chartComponent; |
|
| 30 |
|
|
| 31 |
/** |
|
| 32 | 17 |
* Creates a chart editor input linked to the current SWT charts components provider. |
| 33 | 18 |
* @param result |
| 34 | 19 |
* @param preferencesNodeQualifier |
| 35 | 20 |
*/ |
| 36 | 21 |
public ChartEditorInput(ChartResult result) {
|
| 37 |
this(SWTChartsComponentsProvider.getCurrent(), result); |
|
| 38 |
} |
|
| 39 |
|
|
| 40 |
/** |
|
| 41 |
* Creates a chart editor input linked to the specified SWT charts components provider. |
|
| 42 |
* @param swtComponentsProvider |
|
| 43 |
* @param result |
|
| 44 |
* @param preferencesNodeQualifier |
|
| 45 |
*/ |
|
| 46 |
public ChartEditorInput(SWTChartsComponentsProvider swtComponentsProvider, ChartResult result) {
|
|
| 47 |
this(swtComponentsProvider, result, null); |
|
| 48 |
} |
|
| 49 |
|
|
| 50 |
/** |
|
| 51 |
* Creates a chart editor input linked to the specified SWT charts components provider. |
|
| 52 |
* @param swtComponentsProvider |
|
| 53 |
* @param name |
|
| 54 |
* @param result |
|
| 55 |
* @param preferencesNodeQualifier |
|
| 56 |
* @param chartType |
|
| 57 |
* @param chartContainer |
|
| 58 |
*/ |
|
| 59 |
public ChartEditorInput(SWTChartsComponentsProvider swtComponentsProvider, ChartResult result, Object chartContainer) {
|
|
| 60 | 22 |
super(result); |
| 61 |
this.swtChartsComponentsProvider = swtComponentsProvider; |
|
| 62 |
this.chartComponent = chartContainer; |
|
| 63 | 23 |
} |
| 64 |
|
|
| 65 |
|
|
| 66 |
@Override |
|
| 67 |
public boolean exists() {
|
|
| 68 |
// TODO Auto-generated method stub |
|
| 69 |
return false; |
|
| 70 |
} |
|
| 71 | 24 |
|
| 72 |
@Override |
|
| 73 |
public ImageDescriptor getImageDescriptor() {
|
|
| 74 |
// TODO Auto-generated method stub |
|
| 75 |
return null; |
|
| 76 |
} |
|
| 77 |
|
|
| 78 |
@Override |
|
| 79 |
public IPersistableElement getPersistable() {
|
|
| 80 |
// TODO Auto-generated method stub |
|
| 81 |
return null; |
|
| 82 |
} |
|
| 83 |
|
|
| 84 |
@Override |
|
| 85 |
public Object getAdapter(Class type) {
|
|
| 86 |
// FIXME |
|
| 87 |
// System.err.println("************** ChartEditorInput.getAdapter() type = " + type + " / adaptable object = " + this);
|
|
| 88 |
// // if the object implements or extends the desired interface, use it |
|
| 89 |
// |
|
| 90 |
// if (type.isInstance(IResource.class)) |
|
| 91 |
//// |
|
| 92 |
// return this; |
|
| 93 |
//// |
|
| 94 |
//// |
|
| 95 |
//// |
|
| 96 |
//// // if the object is able to adapt itself, let it do it |
|
| 97 |
//// |
|
| 98 |
//// if (this instanceof IAdaptable) {
|
|
| 99 |
//// |
|
| 100 |
//// IAdaptable adaptable = (IAdaptable) this; |
|
| 101 |
//// |
|
| 102 |
//// Object adapter = adaptable.getAdapter(type); |
|
| 103 |
//// |
|
| 104 |
//// if (adapter != null) |
|
| 105 |
//// |
|
| 106 |
//// return adapter; |
|
| 107 |
//// |
|
| 108 |
//// } |
|
| 109 |
// |
|
| 110 |
// |
|
| 111 |
// |
|
| 112 |
// // delegate to the global adapter manager |
|
| 113 |
// |
|
| 114 |
// return Platform.getAdapterManager().getAdapter(this, type); |
|
| 115 |
|
|
| 116 |
|
|
| 117 |
return null; |
|
| 118 |
} |
|
| 119 |
|
|
| 120 |
|
|
| 121 |
|
|
| 122 | 25 |
/** |
| 123 |
* Gets the <code>SWTChartsComponentsProvider</code> linked to this editor input. |
|
| 124 |
* @return the swtComponentProvider |
|
| 125 |
*/ |
|
| 126 |
public SWTChartsComponentsProvider getSWTChartsComponentsProvider() {
|
|
| 127 |
return this.swtChartsComponentsProvider; |
|
| 128 |
} |
|
| 129 |
|
|
| 130 |
/** |
|
| 131 |
* Gets the chart container (for example : can be an AWT/Swing component as ChartPanel for JFC, etc.). |
|
| 132 |
* @return the chartContainer |
|
| 133 |
*/ |
|
| 134 |
public Object getChartComponent() {
|
|
| 135 |
return chartComponent; |
|
| 136 |
} |
|
| 137 |
|
|
| 138 |
|
|
| 139 |
/** |
|
| 140 |
* Sets the chart component (for example: can be an AWT/Swing component as ChartPanel for JFC, etc.). |
|
| 141 |
* @param chartComponent the chartContainer to set |
|
| 142 |
*/ |
|
| 143 |
public void setChartComponent(Object chartComponent) {
|
|
| 144 |
this.chartComponent = chartComponent; |
|
| 145 |
} |
|
| 146 |
|
|
| 147 |
/** |
|
| 148 |
* Set the <code>SWTChartsComponentsProvider</code> to link to this editor input and to use for reading the chart object. |
|
| 149 |
* @param swtChartsComponentsProvider the swtChartsComponentsProvider to set |
|
| 150 |
*/ |
|
| 151 |
public void setSWTChartsComponentsProvider(SWTChartsComponentsProvider swtChartsComponentsProvider) {
|
|
| 152 |
this.swtChartsComponentsProvider = swtChartsComponentsProvider; |
|
| 153 |
} |
|
| 154 |
|
|
| 155 |
|
|
| 156 |
/** |
|
| 157 | 26 |
* Gets a string representing the type of the chart as defined in the chart creator extension. |
| 158 | 27 |
* @return the chartType or <code>null</code> if there only one chart type needed for the linked <code>TXMResult</code>. |
| 159 | 28 |
*/ |
| ... | ... | |
| 166 | 35 |
return (ChartResult) this.result; |
| 167 | 36 |
} |
| 168 | 37 |
|
| 169 |
/** |
|
| 170 |
* Sets and updates the local preferences node qualifier from the result data. |
|
| 171 |
* Synchronizes the local preferences node with the result data type, chart type, etc. |
|
| 172 |
*/ |
|
| 173 |
// FIXME; should be move to TXMResultEditorInput class |
|
| 174 |
public void syncLocalPreferencesNode() {
|
|
| 175 |
//FIXME: to call when implemented in parent class |
|
| 176 |
//super.syncLocalPreferencesNode(); |
|
| 177 |
// FIXME: persistence test |
|
| 178 |
if(this.getResult().getChartType() != null) {
|
|
| 179 |
TXMPreferences.putLocal(this.result, ChartsEnginePreferences.CHART_TYPE, this.getResult().getChartType()); |
|
| 180 |
} |
|
| 181 |
} |
|
| 182 |
|
|
| 183 | 38 |
|
| 184 | 39 |
@Override |
| 185 | 40 |
public boolean equals(Object obj) {
|
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/IChartComponent.java (revision 1841) | ||
|---|---|---|
| 6 | 6 |
|
| 7 | 7 |
/** |
| 8 | 8 |
* Chart component interface. |
| 9 |
* A component dedicated to render chart, from a file, from an AWT object, etc. and to be embedded in a SWT ChartComposite. |
|
| 9 |
* A component dedicated to render chart, from a file, from an AWT object, etc. and to be embedded in an SWT ChartComposite. |
|
| 10 |
* |
|
| 10 | 11 |
* @author sjacquot |
| 11 | 12 |
* |
| 12 | 13 |
*/ |
| ... | ... | |
| 67 | 68 |
*/ |
| 68 | 69 |
public void squareOff(); |
| 69 | 70 |
|
| 70 |
// /** |
|
| 71 |
// * Sets the square off unit axis constraints state. |
|
| 72 |
// * @param enabled |
|
| 73 |
// */ |
|
| 74 |
// public void setSquareOffEnabled(boolean enabled); |
|
| 75 | 71 |
|
| 76 | 72 |
} |
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/ChartComposite.java (revision 1841) | ||
|---|---|---|
| 1 | 1 |
package org.txm.chartsengine.rcp.swt; |
| 2 | 2 |
|
| 3 | 3 |
import java.awt.Component; |
| 4 |
import java.io.File; |
|
| 4 | 5 |
import java.util.ArrayList; |
| 5 | 6 |
import java.util.EventListener; |
| 6 | 7 |
|
| 7 | 8 |
import org.eclipse.swt.widgets.Composite; |
| 8 | 9 |
import org.eclipse.swt.widgets.Menu; |
| 10 |
import org.txm.chartsengine.core.ChartsEngine; |
|
| 9 | 11 |
import org.txm.chartsengine.core.results.ChartResult; |
| 10 | 12 |
import org.txm.chartsengine.rcp.IChartComponent; |
| 11 | 13 |
import org.txm.chartsengine.rcp.editors.ChartEditor; |
| 14 |
import org.txm.chartsengine.rcp.editors.ChartEditorInput; |
|
| 12 | 15 |
import org.txm.chartsengine.rcp.events.EventCallBack; |
| 13 | 16 |
import org.txm.chartsengine.rcp.events.EventCallBackHandler; |
| 14 | 17 |
import org.txm.rcp.editors.TXMEditor; |
| ... | ... | |
| 63 | 66 |
} |
| 64 | 67 |
|
| 65 | 68 |
|
| 69 |
|
|
| 66 | 70 |
/** |
| 71 |
* Loads the chart from specified data. |
|
| 72 |
* @param data |
|
| 73 |
*/ |
|
| 74 |
public abstract void loadChart(Object data); |
|
| 75 |
|
|
| 76 |
|
|
| 77 |
/** |
|
| 78 |
* Loads or reloads the chart from the chart object stored in the linked editor input. |
|
| 79 |
* This method is especially used for file based implementations of charts engine for reloading a file that has been externally modified. |
|
| 80 |
*/ |
|
| 81 |
public abstract void loadChart(); |
|
| 82 |
|
|
| 83 |
|
|
| 84 |
/** |
|
| 85 |
* Loads or reloads the chart from the chart object stored in the linked editor input. |
|
| 86 |
* @param resetView |
|
| 87 |
* @param clearChartItemsSelection |
|
| 88 |
* @param squareOff |
|
| 89 |
*/ |
|
| 90 |
public void loadChart(boolean resetView, boolean clearChartItemsSelection, boolean squareOff) {
|
|
| 91 |
this.loadChart(); |
|
| 92 |
|
|
| 93 |
if(squareOff) {
|
|
| 94 |
this.squareOff(); |
|
| 95 |
} |
|
| 96 |
|
|
| 97 |
if(clearChartItemsSelection) {
|
|
| 98 |
this.clearChartItemsSelection(); |
|
| 99 |
} |
|
| 100 |
|
|
| 101 |
if(resetView) {
|
|
| 102 |
this.resetView(); |
|
| 103 |
} |
|
| 104 |
} |
|
| 105 |
|
|
| 106 |
/** |
|
| 107 |
* Loads or reloads the chart from the chart object stored in the linked editor input. |
|
| 108 |
* @param resetView |
|
| 109 |
* @param clearChartItemsSelection |
|
| 110 |
*/ |
|
| 111 |
public void loadChart(boolean resetView, boolean clearChartItemsSelection) {
|
|
| 112 |
this.loadChart(resetView, clearChartItemsSelection, false); |
|
| 113 |
} |
|
| 114 |
|
|
| 115 |
/** |
|
| 116 |
* Creates a new chart component. |
|
| 117 |
* |
|
| 118 |
* @param chartsEngine |
|
| 119 |
* @param chartEditorInput |
|
| 120 |
* @return |
|
| 121 |
*/ |
|
| 122 |
protected abstract IChartComponent _createChartComponent(); |
|
| 123 |
|
|
| 124 |
|
|
| 125 |
/** |
|
| 126 |
* Creates a new chart component by calling the implementation method and store it. |
|
| 127 |
* |
|
| 128 |
* @param chartEditorInput |
|
| 129 |
* @return |
|
| 130 |
*/ |
|
| 131 |
public boolean createChartComponent() {
|
|
| 132 |
|
|
| 133 |
if (!this.chartEditor.getResult().isChartDirty()) {
|
|
| 134 |
|
|
| 135 |
Log.finest(this.getClass().getSimpleName() + ": creating a chart component..."); |
|
| 136 |
|
|
| 137 |
this.chartComponent = this._createChartComponent(); |
|
| 138 |
this.chartComponent.setChartEditor(this.chartEditor); |
|
| 139 |
|
|
| 140 |
return true; |
|
| 141 |
} |
|
| 142 |
else {
|
|
| 143 |
return false; |
|
| 144 |
} |
|
| 145 |
} |
|
| 146 |
|
|
| 147 |
|
|
| 148 |
|
|
| 149 |
|
|
| 150 |
/** |
|
| 67 | 151 |
* Creates the pop up menu dedicated to empty area location click event that is populated from plugin.xml. |
| 68 | 152 |
*/ |
| 69 | 153 |
public void initEmptyAreaContextMenu() {
|
| ... | ... | |
| 112 | 196 |
this.setMenu(this.contextMenus.get(index)); |
| 113 | 197 |
} |
| 114 | 198 |
|
| 199 |
|
|
| 115 | 200 |
/** |
| 116 | 201 |
* Gets the menu specified by its index. |
| 117 | 202 |
* @param index |
| ... | ... | |
| 121 | 206 |
return this.contextMenus.get(index); |
| 122 | 207 |
} |
| 123 | 208 |
|
| 124 |
/** |
|
| 125 |
* Loads the chart from specified data. |
|
| 126 |
* @param data |
|
| 127 |
*/ |
|
| 128 |
public abstract void loadChart(Object data); |
|
| 129 | 209 |
|
| 130 |
|
|
| 131 | 210 |
/** |
| 132 |
* Loads or reloads the chart from the chart object stored in the linked editor input. |
|
| 133 |
* This method is especially used for file based implementations of charts engine for reloading a file that has been externally modified. |
|
| 134 |
*/ |
|
| 135 |
public abstract void loadChart(); |
|
| 136 |
|
|
| 137 |
|
|
| 138 |
/** |
|
| 139 |
* Loads or reloads the chart from the chart object stored in the linked editor input. |
|
| 140 |
* @param resetView |
|
| 141 |
* @param clearChartItemsSelection |
|
| 142 |
* @param squareOff |
|
| 143 |
*/ |
|
| 144 |
public void loadChart(boolean resetView, boolean clearChartItemsSelection, boolean squareOff) {
|
|
| 145 |
this.loadChart(); |
|
| 146 |
|
|
| 147 |
if(squareOff) {
|
|
| 148 |
this.squareOff(); |
|
| 149 |
} |
|
| 150 |
|
|
| 151 |
if(clearChartItemsSelection) {
|
|
| 152 |
this.clearChartItemsSelection(); |
|
| 153 |
} |
|
Formats disponibles : Unified diff