Révision 1991
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/ChartComposite.java (revision 1991) | ||
---|---|---|
5 | 5 |
import java.util.ArrayList; |
6 | 6 |
import java.util.EventListener; |
7 | 7 |
|
8 |
import org.eclipse.core.runtime.CoreException; |
|
9 |
import org.eclipse.core.runtime.IConfigurationElement; |
|
10 |
import org.eclipse.core.runtime.Platform; |
|
8 | 11 |
import org.eclipse.swt.widgets.Composite; |
9 | 12 |
import org.eclipse.swt.widgets.Menu; |
10 | 13 |
import org.txm.chartsengine.core.ChartsEngine; |
14 |
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences; |
|
11 | 15 |
import org.txm.chartsengine.core.results.ChartResult; |
12 | 16 |
import org.txm.chartsengine.rcp.IChartComponent; |
13 | 17 |
import org.txm.chartsengine.rcp.editors.ChartEditor; |
... | ... | |
128 | 132 |
* @param chartEditorInput |
129 | 133 |
* @return |
130 | 134 |
*/ |
131 |
public boolean createChartComponent() {
|
|
135 |
public void createChartComponent() {
|
|
132 | 136 |
|
133 |
if (!this.chartEditor.getResult().isChartDirty()) { |
|
137 |
// if (!this.chartEditor.getResult().isChartDirty()) {
|
|
134 | 138 |
|
135 | 139 |
Log.finest(this.getClass().getSimpleName() + ": creating a chart component..."); |
136 | 140 |
|
137 | 141 |
this.chartComponent = this._createChartComponent(); |
138 | 142 |
this.chartComponent.setChartEditor(this.chartEditor); |
139 | 143 |
|
140 |
return true; |
|
141 |
} |
|
142 |
else { |
|
143 |
return false; |
|
144 |
} |
|
144 |
// initialize the default shared context menus as Export, etc. |
|
145 |
this.initDefaultContextMenus(); |
|
146 |
// initialize Listeners. |
|
147 |
this.initEventsListeners(); |
|
148 |
// register user entries event call back extensions |
|
149 |
this.registerEventCallBackExtensions(); |
|
150 |
|
|
151 |
|
|
152 |
// return true; |
|
153 |
// } |
|
154 |
// else { |
|
155 |
// return false; |
|
156 |
// } |
|
145 | 157 |
} |
146 | 158 |
|
159 |
/** |
|
160 |
* Initializes event listeners. |
|
161 |
*/ |
|
162 |
public abstract void initEventsListeners(); |
|
147 | 163 |
|
148 | 164 |
|
149 |
|
|
150 | 165 |
/** |
151 | 166 |
* Creates the pop up menu dedicated to empty area location click event that is populated from plugin.xml. |
152 | 167 |
*/ |
... | ... | |
395 | 410 |
|
396 | 411 |
|
397 | 412 |
/** |
413 |
* Registers user entries event call back extensions. |
|
414 |
*/ |
|
415 |
public void registerEventCallBackExtensions() { |
|
416 |
|
|
417 |
ChartResult result = this.chartEditor.getResult(); |
|
418 |
|
|
419 |
String extensionPointId = "org.txm.chartsengine.eventcallback"; //$NON-NLS-1$ |
|
420 |
IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointId); |
|
421 |
|
|
422 |
for(int i = 0; i < contributions.length; i++) { |
|
423 |
if( |
|
424 |
( |
|
425 |
contributions[i].getAttribute("chartsEngineName") == null || //$NON-NLS-1$ // for callback that can be used for all charts engine implementations |
|
426 |
contributions[i].getAttribute("chartsEngineName").equals(result.getChartsEngine().getName()) //$NON-NLS-1$ |
|
427 |
) |
|
428 |
&& |
|
429 |
contributions[i].getAttribute("resultDataClass") != null //$NON-NLS-1$ |
|
430 |
&& contributions[i].getAttribute("resultDataClass").equals(result.getClass().getName()) //$NON-NLS-1$ |
|
431 |
|
|
432 |
&& ((contributions[i].getAttribute("chartType") == null && result.getChartType().equals(ChartsEnginePreferences.DEFAULT_CHART_TYPE) //$NON-NLS-1$ |
|
433 |
|| |
|
434 |
contributions[i].getAttribute("chartType") != null && !result.getChartType().equals(ChartsEnginePreferences.DEFAULT_CHART_TYPE) && contributions[i].getAttribute("chartType").equals(result.getChartType()) //$NON-NLS-1$ //$NON-NLS-2$ |
|
435 |
) //$NON-NLS-1$ |
|
436 |
) |
|
437 |
|
|
438 |
) { |
|
439 |
try { |
|
440 |
EventCallBack eventCallBack = (EventCallBack)contributions[i].createExecutableExtension("class"); //$NON-NLS-1$ |
|
441 |
|
|
442 |
eventCallBack.setChartEditor(this.chartEditor); |
|
443 |
|
|
444 |
EventCallBackHandler mouseHandler = this.getMouseCallBackHandler(); |
|
445 |
if(mouseHandler != null && mouseHandler.getEventCallBack(eventCallBack.getClass()) == null) { |
|
446 |
|
|
447 |
Log.fine("ChartEditor.registerEventCallBackExtensions(): call back of type " + eventCallBack.getClass() //$NON-NLS-1$ |
|
448 |
+ " registered in mouse handler (chart editor = " + this.chartEditor.getClass() //$NON-NLS-1$ |
|
449 |
+ ", result data class = " + result.getClass() //$NON-NLS-1$ |
|
450 |
+ ", chart type = " + result.getChartType() //$NON-NLS-1$ |
|
451 |
+ ")."); //$NON-NLS-1$ |
|
452 |
|
|
453 |
mouseHandler.registerEventCallBack(eventCallBack); |
|
454 |
} |
|
455 |
EventCallBackHandler keyboardHandler = this.getKeyCallBackHandler(); |
|
456 |
if(keyboardHandler != null && keyboardHandler.getEventCallBack(eventCallBack.getClass()) == null) { |
|
457 |
|
|
458 |
Log.fine("ChartEditor.registerEventCallBackExtensions(): call back of type " + eventCallBack.getClass() //$NON-NLS-1$ |
|
459 |
+ " registered in key handler (chart editor = " + this.chartEditor.getClass() //$NON-NLS-1$ |
|
460 |
+ ", result data class = " + result.getClass() //$NON-NLS-1$ |
|
461 |
+ ", chart type = " + result.getChartType() //$NON-NLS-1$ |
|
462 |
+ ")."); //$NON-NLS-1$ |
|
463 |
|
|
464 |
keyboardHandler.registerEventCallBack(eventCallBack); |
|
465 |
} |
|
466 |
} |
|
467 |
catch(CoreException e) { |
|
468 |
e.printStackTrace(); |
|
469 |
} |
|
470 |
break; |
|
471 |
} |
|
472 |
} |
|
473 |
|
|
474 |
} |
|
475 |
|
|
476 |
/** |
|
398 | 477 |
* Gets the chart component dedicated to rendering the chart. |
399 | 478 |
* @return the chartComponent |
400 | 479 |
*/ |
Formats disponibles : Unified diff