Revision 1835
tmp/org.txm.chartsengine.jfreechart.rcp/src/org/txm/chartsengine/jfreechart/rcp/JFCSWTChartsComponentsProvider.java (revision 1835) | ||
---|---|---|
49 | 49 |
|
50 | 50 |
|
51 | 51 |
@Override |
52 |
public boolean createChartContainer(ChartsEngine chartsEngine, ChartEditorInput chartEditorInput) {
|
|
52 |
public boolean createChartComponent(ChartsEngine chartsEngine, ChartEditorInput chartEditorInput) {
|
|
53 | 53 |
|
54 | 54 |
if(!chartEditorInput.getResult().isChartDirty()) { |
55 | 55 |
|
... | ... | |
57 | 57 |
|
58 | 58 |
ChartPanel chartPanel = ((JFCChartsEngine) chartsEngine).getJFCTheme().createChartPanel(this, chart); |
59 | 59 |
|
60 |
chartEditorInput.setChartContainer(chartPanel);
|
|
60 |
chartEditorInput.setChartComponent(chartPanel);
|
|
61 | 61 |
|
62 | 62 |
// Store the chart panel in the renderer (eg. can be needed to get the Graphics2D object to use in getItemShape() to compute the label text bounds and draw a background rectangle.) |
63 | 63 |
if(chart.getPlot() instanceof XYPlot && chart.getXYPlot().getRenderer() instanceof IRendererWithItemSelection) { |
tmp/org.txm.chartsengine.graphstream.rcp/src/org/txm/chartsengine/graphstream/rcp/GSSWTChartsComponentsProvider.java (revision 1835) | ||
---|---|---|
20 | 20 |
import org.txm.chartsengine.rcp.swt.ChartComposite; |
21 | 21 |
|
22 | 22 |
/** |
23 |
* Graphstream charts components provider. |
|
24 |
* |
|
23 | 25 |
* @author sjacquot |
24 | 26 |
* |
25 | 27 |
*/ |
... | ... | |
50 | 52 |
super(); |
51 | 53 |
} |
52 | 54 |
|
53 |
/* (non-Javadoc) |
|
54 |
* @see org.txm.chartsengine.rcp.SWTChartsComponentsProvider#createChartContainer(org.txm.chartsengine.core.ChartsEngine, org.txm.chartsengine.rcp.editors.ChartEditorInput) |
|
55 |
*/ |
|
56 | 55 |
@Override |
57 |
protected boolean createChartContainer(ChartsEngine chartsEngine, ChartEditorInput chartEditorInput) {
|
|
56 |
protected boolean createChartComponent(ChartsEngine chartsEngine, ChartEditorInput chartEditorInput) {
|
|
58 | 57 |
if (!chartEditorInput.getResult().isChartDirty()) { |
59 | 58 |
|
60 | 59 |
//System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer"); // Pour les fonctionnalités avancées des CSS |
... | ... | |
86 | 85 |
//graph.display(); |
87 | 86 |
GSChartComponent chartComponent = new GSChartComponent(viewer); |
88 | 87 |
viewer.addView(chartComponent); |
89 |
chartEditorInput.setChartContainer(chartComponent);
|
|
88 |
chartEditorInput.setChartComponent(chartComponent);
|
|
90 | 89 |
|
91 | 90 |
// sets and updates the local preferences node qualifier from the result data |
92 | 91 |
chartEditorInput.syncLocalPreferencesNode(); |
tmp/org.txm.chartsengine.raster.rcp/src/org/txm/chartsengine/raster/rcp/RasterImageChartsComponentProvider.java (revision 1835) | ||
---|---|---|
55 | 55 |
//return (ChartEditor) this.openFile(editorInputName, null, file); |
56 | 56 |
|
57 | 57 |
ChartEditorInput chartEditorInput = new ChartEditorInput(this, result); |
58 |
this.createChartContainer(chartEditorInput);
|
|
58 |
this.createChartComponent(chartEditorInput);
|
|
59 | 59 |
//ChartEditor editor = new ChartEditor(this, chartEditorInput); |
60 | 60 |
|
61 | 61 |
//ChartEditor editor = new ChartEditor(this, editorInputName, result, preferencesNode, chartType, this.getChartsEngine().getChartCreator(result.getClass(), chartType).createChartFile(result, preferencesNode)); |
... | ... | |
68 | 68 |
} |
69 | 69 |
|
70 | 70 |
@Override |
71 |
public boolean createChartContainer(ChartsEngine chartsEngine, ChartEditorInput chartEditorInput) {
|
|
71 |
public boolean createChartComponent(ChartsEngine chartsEngine, ChartEditorInput chartEditorInput) {
|
|
72 | 72 |
|
73 | 73 |
Object chart = chartEditorInput.getChart(); |
74 | 74 |
|
75 | 75 |
if(chart != null) { |
76 |
chartEditorInput.setChartContainer(chart);
|
|
76 |
chartEditorInput.setChartComponent(chart);
|
|
77 | 77 |
|
78 | 78 |
// sets and updates the local preferences node qualifier from the result data |
79 | 79 |
chartEditorInput.syncLocalPreferencesNode(); |
... | ... | |
127 | 127 |
// The best would be to create a plugin as dummyexternalviewer implementing SWT charts components extension? |
128 | 128 |
// Opens an external viewer |
129 | 129 |
if(this.chartsEngine.getOutputFormat() == ChartsEngine.OUTPUT_FORMAT_PS || this.chartsEngine.getOutputFormat() == ChartsEngine.OUTPUT_FORMAT_PDF) { |
130 |
OpenURI.open((File) chartEditor.getEditorInput().getChartContainer());
|
|
130 |
OpenURI.open((File) chartEditor.getResult().getChart());
|
|
131 | 131 |
} |
132 | 132 |
else { |
133 | 133 |
// Load the chart in composite |
tmp/org.txm.chartsengine.raster.rcp/src/org/txm/chartsengine/raster/rcp/swt/RasterComposite.java (revision 1835) | ||
---|---|---|
123 | 123 |
// this.loadSVGDocument(this.file); |
124 | 124 |
// } |
125 | 125 |
// else { |
126 |
this.file = (File) this.chartEditor.getEditorInput().getChartContainer();
|
|
126 |
this.file = (File) this.chartEditor.getEditorInput().getChartComponent();
|
|
127 | 127 |
this.loadRasterFile(this.file); |
128 | 128 |
// } |
129 | 129 |
} |
tmp/org.txm.chartsengine.svgbatik.rcp/src/org/txm/chartsengine/svgbatik/rcp/SVGSWTChartsComponentsProvider.java (revision 1835) | ||
---|---|---|
49 | 49 |
|
50 | 50 |
|
51 | 51 |
@Override |
52 |
public boolean createChartContainer(ChartsEngine chartsEngine, ChartEditorInput chartEditorInput) {
|
|
52 |
public boolean createChartComponent(ChartsEngine chartsEngine, ChartEditorInput chartEditorInput) {
|
|
53 | 53 |
|
54 | 54 |
if (!chartEditorInput.getResult().isChartDirty()) { |
55 | 55 |
|
56 |
chartEditorInput.setChartContainer(new SVGCanvas());
|
|
56 |
chartEditorInput.setChartComponent(new SVGCanvas());
|
|
57 | 57 |
|
58 | 58 |
// sets and updates the local preferences node qualifier from the result data |
59 | 59 |
chartEditorInput.syncLocalPreferencesNode(); |
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditor.java (revision 1835) | ||
---|---|---|
27 | 27 |
import org.txm.chartsengine.rcp.swt.AdvancedChartEditorToolBar; |
28 | 28 |
import org.txm.chartsengine.rcp.swt.ChartComposite; |
29 | 29 |
import org.txm.chartsengine.rcp.swt.ChartEditorToolBar; |
30 |
import org.txm.chartsengine.rcp.swt.SwingChartComposite; |
|
30 | 31 |
import org.txm.core.messages.TXMCoreMessages; |
31 | 32 |
import org.txm.rcp.editors.TXMEditor; |
32 | 33 |
import org.txm.rcp.editors.TXMMultiPageEditor; |
... | ... | |
171 | 172 |
|
172 | 173 |
} |
173 | 174 |
|
174 |
/** |
|
175 |
* Initializes the default context menus. |
|
176 |
*/ |
|
177 |
public void initDefaultContextMenus() { |
|
178 |
SWTChartsComponentsProvider.initDefaultContextMenus(this.chartComposite); |
|
179 |
} |
|
175 |
// /**
|
|
176 |
// * Initializes the default context menus.
|
|
177 |
// */
|
|
178 |
// public void initDefaultContextMenus() {
|
|
179 |
// SWTChartsComponentsProvider.initDefaultContextMenus(this.chartComposite);
|
|
180 |
// }
|
|
180 | 181 |
|
181 | 182 |
|
182 | 183 |
/** |
... | ... | |
256 | 257 |
this.loadChart(); |
257 | 258 |
|
258 | 259 |
|
259 |
// FIXME: this code should be moved in ChartComposit.loadChart()? |
|
260 |
// FIXME: this code should be moved in ChartComposite.loadChart()?
|
|
260 | 261 |
// if editor wasn't exist: |
261 | 262 |
// hiding command parameters, updating tool bar buttons states, registering context menus and event user callbacks |
262 | 263 |
if(needInit |
... | ... | |
274 | 275 |
//editor2.getChartToolBar().synchronize(); |
275 | 276 |
|
276 | 277 |
// initialize the default shared context menus as Export, etc. |
277 |
this.initDefaultContextMenus(); |
|
278 |
//this.initDefaultContextMenus();
|
|
278 | 279 |
|
279 | 280 |
// registers user entries event call back extensions |
280 |
this.registerEventCallBackExtensions(); |
|
281 |
// this.registerEventCallBackExtensions();
|
|
281 | 282 |
|
282 | 283 |
//FIXME: test to contribute to menu only in some context and also for key binding |
283 | 284 |
// create chart editor part context |
... | ... | |
291 | 292 |
//editor2..setContentDescription("details"); |
292 | 293 |
//editor2..setContentDescription(this.getResultData().getDetails()); |
293 | 294 |
|
294 |
this.initializeAWTDelegationListeners(); |
|
295 |
//this.initializeAWTDelegationListeners();
|
|
295 | 296 |
|
296 | 297 |
// } |
297 | 298 |
// }); |
... | ... | |
350 | 351 |
} |
351 | 352 |
} |
352 | 353 |
|
353 |
/** |
|
354 |
* Registers user entries event call back extensions. |
|
355 |
*/ |
|
356 |
public void registerEventCallBackExtensions() { |
|
357 |
String extensionPointId = "org.txm.chartsengine.eventcallback"; //$NON-NLS-1$ |
|
358 |
IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointId); |
|
359 |
|
|
360 |
for(int i = 0; i < contributions.length; i++) { |
|
361 |
if( |
|
362 |
( |
|
363 |
contributions[i].getAttribute("chartsEngineName") == null || //$NON-NLS-1$ // for callback that can be used for all charts engine implementations |
|
364 |
contributions[i].getAttribute("chartsEngineName").equals(this.getChartsEngine().getName()) //$NON-NLS-1$ |
|
365 |
) |
|
366 |
&& |
|
367 |
contributions[i].getAttribute("resultDataClass") != null //$NON-NLS-1$ |
|
368 |
&& contributions[i].getAttribute("resultDataClass").equals(this.getResult().getClass().getName()) //$NON-NLS-1$ |
|
369 |
|
|
370 |
&& ((contributions[i].getAttribute("chartType") == null && this.getChartType().equals(ChartsEnginePreferences.DEFAULT_CHART_TYPE) //$NON-NLS-1$ |
|
371 |
|| |
|
372 |
contributions[i].getAttribute("chartType") != null && !this.getChartType().equals(ChartsEnginePreferences.DEFAULT_CHART_TYPE) && contributions[i].getAttribute("chartType").equals(this.getChartType()) //$NON-NLS-1$ //$NON-NLS-2$ |
|
373 |
) //$NON-NLS-1$ |
|
374 |
) |
|
375 |
|
|
376 |
) { |
|
377 |
try { |
|
378 |
EventCallBack eventCallBack = (EventCallBack)contributions[i].createExecutableExtension("class"); //$NON-NLS-1$ |
|
379 |
|
|
380 |
eventCallBack.setChartEditor(this); |
|
381 |
|
|
382 |
EventCallBackHandler mouseHandler = this.chartComposite.getMouseCallBackHandler(); |
|
383 |
if(mouseHandler != null && mouseHandler.getEventCallBack(eventCallBack.getClass()) == null) { |
|
384 | 354 |
|
385 |
Log.fine("ChartEditor.registerEventCallBackExtensions(): call back of type " + eventCallBack.getClass() //$NON-NLS-1$ |
|
386 |
+ " registered in mouse handler (chart editor = " + this.getClass() //$NON-NLS-1$ |
|
387 |
+ ", result data class = " + this.getResult().getClass() //$NON-NLS-1$ |
|
388 |
+ ", chart type = " + this.getChartType() //$NON-NLS-1$ |
|
389 |
+ ")."); //$NON-NLS-1$ |
|
390 |
|
|
391 |
mouseHandler.registerEventCallBack(eventCallBack); |
|
392 |
} |
|
393 |
EventCallBackHandler keyboardHandler = this.chartComposite.getKeyCallBackHandler(); |
|
394 |
if(keyboardHandler != null && keyboardHandler.getEventCallBack(eventCallBack.getClass()) == null) { |
|
395 |
|
|
396 |
Log.fine("ChartEditor.registerEventCallBackExtensions(): call back of type " + eventCallBack.getClass() //$NON-NLS-1$ |
|
397 |
+ " registered in key handler (chart editor = " + this.getClass() //$NON-NLS-1$ |
|
398 |
+ ", result data class = " + this.getResult().getClass() //$NON-NLS-1$ |
|
399 |
+ ", chart type = " + this.getChartType() //$NON-NLS-1$ |
|
400 |
+ ")."); //$NON-NLS-1$ |
|
401 |
|
|
402 |
keyboardHandler.registerEventCallBack(eventCallBack); |
|
403 |
} |
|
404 |
} |
|
405 |
catch(CoreException e) { |
|
406 |
e.printStackTrace(); |
|
407 |
} |
|
408 |
break; |
|
409 |
} |
|
410 |
} |
|
411 |
|
|
412 |
} |
|
413 | 355 |
|
414 | 356 |
/** |
415 | 357 |
* Activate the editor in the UI. |
... | ... | |
484 | 426 |
} |
485 | 427 |
|
486 | 428 |
|
487 |
/** |
|
488 |
* Initialize Swing/AWT events delegation. |
|
489 |
* @param swingComponent |
|
490 |
*/ |
|
491 |
protected void initializeAWTDelegationListeners() { |
|
492 |
try { |
|
493 |
this.getChartComposite().getChartComponent().setChartEditor(this); |
|
494 |
SWTChartsComponentsProvider.initializeAWTDelegationListeners(this, (JComponent) this.getEditorInput().getChartContainer()); |
|
495 |
} |
|
496 |
catch (Exception e) { |
|
497 |
Log.severe("ChartEditor.initializeAWTDelegationListeners(): can not initialize events delegation."); |
|
498 |
} |
|
499 |
} |
|
429 |
// /** |
|
430 |
// * Initialize Swing/AWT events delegation. |
|
431 |
// * @param swingComponent |
|
432 |
// */ |
|
433 |
// protected void initializeAWTDelegationListeners() { |
|
434 |
// try { |
|
435 |
// this.getChartComposite().getChartComponent().setChartEditor(this); |
|
436 |
// // FIXME: SJ: temporary fix. The composite may not be a SwingChartComposite |
|
437 |
// ((SwingChartComposite) this.chartComposite).initializeAWTDelegationListeners(); |
|
438 |
// } |
|
439 |
// catch (Exception e) { |
|
440 |
// Log.severe("ChartEditor.initializeAWTDelegationListeners(): can not initialize events delegation."); |
|
441 |
// } |
|
442 |
// } |
|
500 | 443 |
|
501 | 444 |
/** |
502 | 445 |
* Convenience method the get the casted linked editor input. |
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditorInput.java (revision 1835) | ||
---|---|---|
24 | 24 |
|
25 | 25 |
|
26 | 26 |
/** |
27 |
* The chart container (for example : can be a file, an AWT/Swing component as ChartPanel for JFC, etc.).
|
|
27 |
* The chart component (for example : can be an AWT/Swing component as ChartPanel for JFC, etc.).
|
|
28 | 28 |
*/ |
29 |
protected Object chartContainer;
|
|
29 |
protected Object chartComponent;
|
|
30 | 30 |
|
31 | 31 |
/** |
32 | 32 |
* Creates a chart editor input linked to the current SWT charts components provider. |
... | ... | |
59 | 59 |
public ChartEditorInput(SWTChartsComponentsProvider swtComponentsProvider, ChartResult result, Object chartContainer) { |
60 | 60 |
super(result); |
61 | 61 |
this.swtChartsComponentsProvider = swtComponentsProvider; |
62 |
this.chartContainer = chartContainer;
|
|
62 |
this.chartComponent = chartContainer;
|
|
63 | 63 |
} |
64 | 64 |
|
65 | 65 |
|
... | ... | |
128 | 128 |
} |
129 | 129 |
|
130 | 130 |
/** |
131 |
* Gets the chart container (for example : can be a file, an AWT/Swing component as ChartPanel for JFC, etc.).
|
|
131 |
* Gets the chart container (for example : can be an AWT/Swing component as ChartPanel for JFC, etc.). |
|
132 | 132 |
* @return the chartContainer |
133 | 133 |
*/ |
134 |
public Object getChartContainer() {
|
|
135 |
return chartContainer;
|
|
134 |
public Object getChartComponent() {
|
|
135 |
return chartComponent;
|
|
136 | 136 |
} |
137 | 137 |
|
138 | 138 |
|
139 | 139 |
/** |
140 |
* Sets the chart container (for example : can be a file, an AWT/Swing component as ChartPanel for JFC, etc.).
|
|
141 |
* @param chartContainer the chartContainer to set
|
|
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 | 142 |
*/ |
143 |
public void setChartContainer(Object chartContainer) {
|
|
144 |
this.chartContainer = chartContainer;
|
|
143 |
public void setChartComponent(Object chartComponent) {
|
|
144 |
this.chartComponent = chartComponent;
|
|
145 | 145 |
} |
146 | 146 |
|
147 | 147 |
/** |
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/SwingChartComposite.java (revision 1835) | ||
---|---|---|
3 | 3 |
*/ |
4 | 4 |
package org.txm.chartsengine.rcp.swt; |
5 | 5 |
|
6 |
import java.awt.AWTEvent; |
|
6 | 7 |
import java.awt.Color; |
7 | 8 |
import java.awt.Component; |
8 | 9 |
import java.awt.Frame; |
... | ... | |
11 | 12 |
import java.awt.datatransfer.DataFlavor; |
12 | 13 |
import java.awt.datatransfer.Transferable; |
13 | 14 |
import java.awt.datatransfer.UnsupportedFlavorException; |
15 |
import java.awt.event.MouseEvent; |
|
16 |
import java.awt.event.MouseListener; |
|
17 |
import java.awt.event.MouseMotionListener; |
|
14 | 18 |
import java.awt.event.WindowEvent; |
15 | 19 |
import java.awt.event.WindowFocusListener; |
16 | 20 |
import java.awt.event.WindowListener; |
... | ... | |
22 | 26 |
import javax.swing.SwingUtilities; |
23 | 27 |
import javax.swing.border.LineBorder; |
24 | 28 |
|
29 |
import org.eclipse.core.runtime.CoreException; |
|
30 |
import org.eclipse.core.runtime.IConfigurationElement; |
|
31 |
import org.eclipse.core.runtime.Platform; |
|
32 |
import org.eclipse.swt.SWT; |
|
25 | 33 |
import org.eclipse.swt.awt.SWT_AWT; |
34 |
import org.eclipse.swt.graphics.Point; |
|
26 | 35 |
import org.eclipse.swt.widgets.Composite; |
36 |
import org.eclipse.swt.widgets.Event; |
|
37 |
import org.eclipse.swt.widgets.Listener; |
|
38 |
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences; |
|
27 | 39 |
import org.txm.chartsengine.core.results.ChartResult; |
28 | 40 |
import org.txm.chartsengine.rcp.IChartComponent; |
41 |
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider; |
|
29 | 42 |
import org.txm.chartsengine.rcp.editors.ChartEditor; |
43 |
import org.txm.chartsengine.rcp.events.EventCallBack; |
|
30 | 44 |
import org.txm.chartsengine.rcp.events.EventCallBackHandler; |
31 | 45 |
import org.txm.core.messages.TXMCoreMessages; |
32 | 46 |
import org.txm.core.preferences.TBXPreferences; |
... | ... | |
90 | 104 |
this.rootPanel = (JComponent) applet.getRootPane().getContentPane(); |
91 | 105 |
this.frame.add(applet); |
92 | 106 |
|
93 |
// this.frame.setAutoRequestFocus(false); |
|
94 |
// this.frame.setFocusTraversalPolicyProvider(true); |
|
95 |
// this.frame.setFocusTraversalPolicy(new FocusTraversalPolicy() { |
|
96 |
// |
|
97 |
// @Override |
|
98 |
// public Component getLastComponent(Container aContainer) { |
|
99 |
// // TODO Auto-generated method stub |
|
100 |
// return null; |
|
101 |
// } |
|
102 |
// |
|
103 |
// @Override |
|
104 |
// public Component getFirstComponent(Container aContainer) { |
|
105 |
// // TODO Auto-generated method stub |
|
106 |
// return null; |
|
107 |
// } |
|
108 |
// |
|
109 |
// @Override |
|
110 |
// public Component getDefaultComponent(Container aContainer) { |
|
111 |
// // TODO Auto-generated method stub |
|
112 |
// return null; |
|
113 |
// } |
|
114 |
// |
|
115 |
// @Override |
|
116 |
// public Component getComponentBefore(Container aContainer, Component aComponent) { |
|
117 |
// // TODO Auto-generated method stub |
|
118 |
// return null; |
|
119 |
// } |
|
120 |
// |
|
121 |
// @Override |
|
122 |
// public Component getComponentAfter(Container aContainer, Component aComponent) { |
|
123 |
// // TODO Auto-generated method stub |
|
124 |
// return null; |
|
125 |
// } |
|
126 |
// }); |
|
127 | 107 |
|
128 |
|
|
129 |
|
|
130 | 108 |
//this.frame.pack(); |
131 | 109 |
|
132 | 110 |
//this.frame.setVisible(true); |
... | ... | |
258 | 236 |
} |
259 | 237 |
}); |
260 | 238 |
|
239 |
|
|
261 | 240 |
|
241 |
// FIXME: For Swing focus debug tests |
|
262 | 242 |
this.frame.addWindowFocusListener(new WindowFocusListener() { |
263 | 243 |
|
264 | 244 |
@Override |
... | ... | |
514 | 494 |
} |
515 | 495 |
|
516 | 496 |
|
497 |
/** |
|
498 |
* Initializes AWT default events to delegate AWT events to SWT. |
|
499 |
*/ |
|
500 |
public void initializeAWTDelegationListeners() { |
|
501 |
|
|
517 | 502 |
|
503 |
|
|
504 |
// // AWT to SWT |
|
505 |
// ((Component) getChartComponent()).addMouseMotionListener(new MouseMotionListener() { |
|
506 |
// |
|
507 |
// @Override |
|
508 |
// public void mouseMoved(final MouseEvent e) { |
|
509 |
// if(!isDisposed()) { |
|
510 |
// getDisplay().asyncExec(new Runnable () { |
|
511 |
// public void run() { |
|
512 |
// notifyListeners(SWT.MouseMove, SwingChartComposite.swingEventToSWT(SwingChartComposite.this, ((JComponent) getChartComponent()), e, SWT.MouseMove)); |
|
513 |
// } |
|
514 |
// }); |
|
515 |
// } |
|
516 |
// } |
|
517 |
// |
|
518 |
// @Override |
|
519 |
// public void mouseDragged(MouseEvent e) { |
|
520 |
// // TODO Auto-generated method stub |
|
521 |
// |
|
522 |
// } |
|
523 |
// }); |
|
524 |
|
|
525 |
((Component) getChartComponent()).addMouseListener(new MouseListener() { |
|
526 |
|
|
527 |
@Override |
|
528 |
public void mouseReleased(final MouseEvent e) { |
|
529 |
if(!isDisposed()) { |
|
530 |
getDisplay().asyncExec(new Runnable () { |
|
531 |
public void run() { |
|
532 |
|
|
533 |
// FIXME: context menu |
|
534 |
if( |
|
535 |
|
|
536 |
e.getButton() == MouseEvent.BUTTON3 |
|
537 |
//e.isPopupTrigger() |
|
538 |
) { |
|
539 |
|
|
540 |
//System.err.println("SWTChartsComponentsProvider.initializeAWTDelegationListeners(...).new MouseListener() {...}.mouseReleased(...).new Runnable() {...}.run(): AWT popup trigger detected"); |
|
541 |
|
|
542 |
|
|
543 |
|
|
544 |
// update the mouse over item selection according to the mouse event |
|
545 |
getChartComponent().updateMouseOverItem(e); |
|
546 |
|
|
547 |
// manually pop up the menu |
|
548 |
if(getMenu() != null) { |
|
549 |
getMenu().setLocation(new Point(e.getXOnScreen(), e.getYOnScreen())); |
|
550 |
getMenu().setVisible(true); |
|
551 |
|
|
552 |
} |
|
553 |
|
|
554 |
// FIXME: the SWT.MenuDetect event delegation doesn't work, it would be better than manually pop up the menu (but other problem is the dynamic menu on chart entity item) |
|
555 |
//chartEditor.getComposite().notifyListeners(SWT.MenuDetect, SWTChartsComponentProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MenuDetect)); |
|
556 |
// FIXME: try to delegate the Menu detect event, DOES NOT SEEM TO WORK |
|
557 |
//chartEditor.getComposite().notifyListeners(SWT.MenuDetect, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MenuDetect)); |
|
558 |
//chartEditor.getComposite().notifyListeners(SWT.Show, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.Show)); |
|
559 |
|
|
560 |
} |
|
561 |
//chartEditor.getComposite().notifyListeners(SWT.MouseUp, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseUp)); |
|
562 |
//chartEditor.activate(); |
|
563 |
} |
|
564 |
}); |
|
565 |
} |
|
566 |
} |
|
567 |
|
|
568 |
@Override |
|
569 |
public void mousePressed(final MouseEvent e) { |
|
570 |
|
|
571 |
|
|
572 |
// FIXME: fix Linux. On Linux, the focus is never lost when clicking outside the Swing component, so the focus can not be given back again and the EditorPart activation patch code based on |
|
573 |
// windowsFocusGained event is called |
|
574 |
// SWT thread |
|
575 |
getDisplay().asyncExec(new Runnable() { |
|
576 |
@Override |
|
577 |
public void run() { |
|
578 |
|
|
579 |
//chartEditor.getComposite().notifyListeners(SWT.MouseDown, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseDown)); |
|
580 |
|
|
581 |
// FIXME: Debug |
|
582 |
// System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new MouseListener() {...}.mousePressed(...).new Runnable() {...}.run()"); |
|
583 |
// Activate the editor part on AWT mouse pressed event |
|
584 |
//chartEditor.activate(); |
|
585 |
//chartEditor.getShell().setFocus(); |
|
586 |
chartEditor.setFocus(); |
|
587 |
//chartEditor.getParent().setFocus(); |
|
588 |
// chartEditor.forceFocus(); |
|
589 |
} |
|
590 |
}); |
|
591 |
|
|
592 |
} |
|
593 |
|
|
594 |
@Override |
|
595 |
public void mouseExited(java.awt.event.MouseEvent e) { |
|
596 |
// TODO Auto-generated method stub |
|
597 |
//Frame frame = (Frame) swingComponent.getFocusCycleRootAncestor(); |
|
598 |
//frame.setAutoRequestFocus(false); |
|
599 |
//frame.setFocusable(false); |
|
600 |
//frame.setFocusableWindowState(false); |
|
601 |
} |
|
602 |
|
|
603 |
@Override |
|
604 |
public void mouseEntered(java.awt.event.MouseEvent e) { |
|
605 |
|
|
606 |
// TODO: DEbug |
|
607 |
//System.err.println("SWTChartsComponentProvider.initializeSwingDelegationListeners(...) AWT mouse entered"); |
|
608 |
|
|
609 |
// Force the focus in the component on mouse enter |
|
610 |
/*if(!swingComponent.isFocusOwner()) { |
|
611 |
|
|
612 |
// SWT thread |
|
613 |
if(!chartEditor.getComposite().isDisposed()) { |
|
614 |
chartEditor.getComposite().getDisplay().asyncExec(new Runnable() { |
|
615 |
public void run() { |
|
518 | 616 |
|
617 |
|
|
618 |
// FIXME: this code works on Windows and Linux but activate() the chart editor when mouse enters |
|
619 |
//chartEditor.activate(); |
|
620 |
|
|
621 |
EventQueue.invokeLater(new Runnable () { |
|
622 |
public void run () { |
|
623 |
|
|
624 |
// TODO: this code forces to give the focus to the embedded AWT Frame under Windows (#1127 related) |
|
625 |
// For unknown reason Frame.requestFocusInWindow() doesn't work and always return false here |
|
626 |
// This code is not sufficient for Linux |
|
627 |
System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...) trying to give focus to root embedded frame"); |
|
628 |
try { |
|
629 |
Frame frame = (Frame) swingComponent.getFocusCycleRootAncestor(); |
|
630 |
//frame.synthesizeWindowActivation(true); |
|
631 |
Class clazz = frame.getClass(); |
|
632 |
Method method = clazz.getMethod("synthesizeWindowActivation", new Class[]{boolean.class}); |
|
633 |
if(method != null) { |
|
634 |
method.invoke(frame, new Object[]{new Boolean(true)}); |
|
635 |
System.out.println("SWTChartsComponentProvider.initializeSwingDelegationListeners(...).new MouseListener() {...}.mouseEntered(...).new Runnable() {...}.run(): " + frame); |
|
636 |
|
|
637 |
} |
|
638 |
|
|
639 |
//frame.requestFocusInWindow(); |
|
640 |
|
|
641 |
} |
|
642 |
catch (Throwable e) { |
|
643 |
Log.printStackTrace(e); |
|
644 |
} |
|
645 |
} |
|
646 |
}); |
|
647 |
|
|
648 |
|
|
649 |
//System.out.println("SWTChartsComponentProvider.initializeSwingDelegationListeners) AWT give focus to frame = " + ((JFCComposite)chartEditor.getComposite()).frame.requestFocusInWindow()); |
|
650 |
|
|
651 |
|
|
652 |
// chartEditor.setFocus(); |
|
653 |
// System.out.println("SWTChartsComponentProvider.initializeSwingDelegationListeners() SWT got focus = " + chartEditor.getComposite().setFocus()); |
|
654 |
|
|
655 |
// EventQueue.invokeLater(new Runnable () { |
|
656 |
// public void run () { |
|
657 |
//swingComponent.requestFocusInWindow(); |
|
658 |
|
|
659 |
// System.out.println("SWTChartsComponentProvider.initializeSwingDelegationListeners() AWT got focus = " + swingComponent.requestFocusInWindow()); |
|
660 |
// } |
|
661 |
// }); |
|
662 |
|
|
663 |
|
|
664 |
|
|
665 |
} |
|
666 |
}); |
|
667 |
} |
|
668 |
}*/ |
|
669 |
} |
|
670 |
|
|
671 |
@Override |
|
672 |
public void mouseClicked(java.awt.event.MouseEvent e) { |
|
673 |
// TODO Auto-generated method stub |
|
674 |
|
|
675 |
} |
|
676 |
}); |
|
677 |
|
|
678 |
// // Swing component focus delegation to the SWT chart composite |
|
679 |
// swingComponent.addFocusListener(new FocusListener() { |
|
680 |
// |
|
681 |
// @Override |
|
682 |
// public void focusLost(final FocusEvent e) { |
|
683 |
// |
|
684 |
// // FIXME: For Swing focus debug tests |
|
685 |
// if(RCPPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER)) { |
|
686 |
// swingComponent.setBorder(javax.swing.BorderFactory.createEmptyBorder()); |
|
687 |
// } |
|
688 |
// |
|
689 |
// Display.getDefault().asyncExec(new Runnable() { |
|
690 |
// |
|
691 |
// @Override |
|
692 |
// public void run() { |
|
693 |
// |
|
694 |
// //chartEditor.getComposite().notifyListeners(SWT.FocusOut, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.FocusOut)); |
|
695 |
// |
|
696 |
// chartEditor.deactivateContext(); |
|
697 |
// } |
|
698 |
// }); |
|
699 |
// } |
|
700 |
// |
|
701 |
// @Override |
|
702 |
// public void focusGained(final FocusEvent e) { |
|
703 |
// |
|
704 |
// // FIXME: For Swing focus debug tests |
|
705 |
// if(RCPPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER)) { |
|
706 |
// swingComponent.setBorder(new LineBorder(Color.red, 1)); |
|
707 |
// } |
|
708 |
// |
|
709 |
// Display.getDefault().asyncExec(new Runnable() { |
|
710 |
// |
|
711 |
// @Override |
|
712 |
// public void run() { |
|
713 |
// |
|
714 |
// //chartEditor.getComposite().notifyListeners(SWT.FocusIn, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.FocusIn)); |
|
715 |
// |
|
716 |
// //PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate(this); |
|
717 |
// |
|
718 |
//// chartEditor.activate(); |
|
719 |
// //chartEditor.getComposite().setFocus(); |
|
720 |
// //chartEditor.forceFocus(); |
|
721 |
// |
|
722 |
// chartEditor.activateContext(); |
|
723 |
// |
|
724 |
// } |
|
725 |
// }); |
|
726 |
// } |
|
727 |
// }); |
|
728 |
// |
|
729 |
|
|
730 |
|
|
731 |
|
|
732 |
|
|
733 |
|
|
734 |
// SWT |
|
735 |
|
|
736 |
// SWT Tooltips tests |
|
737 |
|
|
738 |
|
|
739 |
// toolTip = new DefaultToolTip(this, org.eclipse.jface.window.ToolTip.RECREATE, true); |
|
740 |
// toolTip.setPopupDelay(500); |
|
741 |
|
|
742 |
|
|
743 |
|
|
744 |
// FIXME: test HTML |
|
745 |
// toolTip = new ___CustomHTMLToolTip(this, org.eclipse.jface.window.ToolTip.NO_RECREATE, true); |
|
746 |
// toolTip.setShift(new Point(10, 50)); |
|
747 |
|
|
748 |
|
|
749 |
|
|
750 |
|
|
751 |
// // Define AWT events, needed to properly give the focus to the Swing component and manage the mouse events |
|
752 |
// Listener listener; |
|
753 |
// |
|
754 |
// //FIXME: useless ? |
|
755 |
// // Run event queue dispose event |
|
756 |
//// listener = new Listener () { |
|
757 |
//// public void handleEvent (Event e) { |
|
758 |
//// switch (e.type) { |
|
759 |
//// case SWT.Dispose: |
|
760 |
//// chartPanel.getParent().setVisible(false); |
|
761 |
//// EventQueue.invokeLater(new Runnable () { |
|
762 |
//// public void run() { |
|
763 |
//// ((Frame) chartPanel.getParent().getParent()).dispose(); |
|
764 |
//// } |
|
765 |
//// }); |
|
766 |
//// break; |
|
767 |
//// } |
|
768 |
//// } |
|
769 |
//// }; |
|
770 |
//// this.addListener(SWT.Dispose, listener); |
|
771 |
// |
|
772 |
// |
|
773 |
// // Handle the AWT/Swing events delegation |
|
774 |
// listener = new Listener () { |
|
775 |
// public void handleEvent (Event e) { |
|
776 |
// switch (e.type) { |
|
777 |
// |
|
778 |
// case SWT.FocusOut: |
|
779 |
// // FIXME: DEbug |
|
780 |
//// System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT composite gained focus"); |
|
781 |
// System.out.println("SWTChartsComponentsProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent()"); |
|
782 |
// break; |
|
783 |
// |
|
784 |
// |
|
785 |
// case SWT.FocusIn: |
|
786 |
// // FIXME: DEbug |
|
787 |
//// System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT composite gained focus"); |
|
788 |
// //chartEditor.getComposite().setFocus(); |
|
789 |
// //chartEditor.getComposite().requestFocusInComposite(); |
|
790 |
// break; |
|
791 |
// case SWT.MouseMove: |
|
792 |
// //System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT mouse move: " + e.x + " : " + e.y); |
|
793 |
// |
|
794 |
//// // FIXME: SWT tool tips test |
|
795 |
//// ToolTip tip = new ToolTip(getShell(), SWT.BALLOON | SWT.ID_HIDE); |
|
796 |
//// tip.setMessage("test tool tip SWT"); |
|
797 |
//// tip.setLocation(getDisplay().map(self, null, new Point(e.x, e.y))); |
|
798 |
//// tip.setVisible(true); |
|
799 |
// |
|
800 |
//// // FIXME: JFace tool tips test |
|
801 |
//// //DefaultToolTip tip2 = new DefaultToolTip( self, SWT.NONE, true ); |
|
802 |
//// //toolTip.setShift(new Point(e.x, e.y)); |
|
803 |
//// //toolTip.setText("<html><body><p>rtrt <font style=\"color: red\">yuyuyu</font></p></body></html>"); |
|
804 |
//// toolTip.setText(e.text); |
|
805 |
//// if(e.text != null) { |
|
806 |
//// toolTip.show(new Point(e.x, e.y)); |
|
807 |
//// } |
|
808 |
//// else { |
|
809 |
//// toolTip.hide(); |
|
810 |
//// } |
|
811 |
// |
|
812 |
// // FIXME: JFace tool tips test 2 |
|
813 |
//// toolTip.setText(e.text); |
|
814 |
//// if(e.text != null) { |
|
815 |
//// toolTip.show(new Point(e.x, e.y)); |
|
816 |
//// } |
|
817 |
//// else { |
|
818 |
//// toolTip.hide(); |
|
819 |
//// } |
|
820 |
// |
|
821 |
// |
|
822 |
// |
|
823 |
// break; |
|
824 |
// case SWT.MouseDown: |
|
825 |
// // FIXME: to test in Linux and Mac, it should fix the focus bugs in CA chart between table focus and chart composite/panel focus + Linux singular values bar plot focus bug |
|
826 |
// //System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT mouse down : set focus in composite and request focus in chart panel"); |
|
827 |
// //chartEditor.getComposite().setFocus(); |
|
828 |
// //chartEditor.getComposite().requestFocusInComposite(); |
|
829 |
// break; |
|
830 |
// case SWT.MouseUp: |
|
831 |
// //System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT mouse up"); |
|
832 |
// break; |
|
833 |
// |
|
834 |
// case SWT.MouseEnter: |
|
835 |
// //System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT mouse enter"); |
|
836 |
// break; |
|
837 |
// |
|
838 |
// |
|
839 |
// case SWT.Activate: |
|
840 |
// //System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT activate"); |
|
841 |
// //chartEditor.getComposite().requestFocusInComposite(); |
|
842 |
// break; |
|
843 |
// } |
|
844 |
// } |
|
845 |
// }; |
|
846 |
//chartEditor.getComposite().addListener(SWT.FocusOut, listener); |
|
847 |
// chartEditor.getComposite().addListener(SWT.FocusIn, listener); |
|
848 |
// chartEditor.getComposite().addListener(SWT.MouseDown, listener); // needed to manage the focus delegation between SWT and AWT/Swing |
|
849 |
// |
|
850 |
//// chartEditor.getComposite().addListener(SWT.MouseEnter, listener); // TODO : test AWT delegation |
|
851 |
// // chartEditor.getComposite().addListener(SWT.Activate, listener); // TODO : test AWT delegation |
|
852 |
// |
|
853 |
// |
|
854 |
// |
|
855 |
// // FIXME: SWT tool tips test rather than using Swing |
|
856 |
// //chartEditor.getComposite().addListener(SWT.MouseMove, listener); |
|
857 |
// // chartEditor.getComposite().addListener(SWT.MouseUp, listener); |
|
858 |
|
|
859 |
|
|
860 |
|
|
861 |
} |
|
862 |
|
|
863 |
|
|
864 |
|
|
519 | 865 |
@Override |
520 | 866 |
public void loadChart() { |
521 | 867 |
|
... | ... | |
537 | 883 |
} |
538 | 884 |
} |
539 | 885 |
|
540 |
this.chartEditor.getSWTChartsComponentsProvider().createChartContainer(this.chartEditor.getEditorInput());
|
|
541 |
this.chartComponent = (IChartComponent) this.chartEditor.getEditorInput().getChartContainer();
|
|
886 |
this.chartEditor.getSWTChartsComponentsProvider().createChartComponent(this.chartEditor.getEditorInput());
|
|
887 |
this.chartComponent = (IChartComponent) this.chartEditor.getEditorInput().getChartComponent();
|
|
542 | 888 |
|
543 | 889 |
this.rootPanel.add((Component) this.chartComponent); |
544 | 890 |
|
891 |
this.chartComponent.setChartEditor(this.chartEditor); |
|
892 |
|
|
893 |
// initialize the default shared context menus as Export, etc. |
|
894 |
this.initDefaultContextMenus(); |
|
895 |
// initialize AWT default events to delegate AWT events to SWT. |
|
896 |
this.initializeAWTDelegationListeners(); |
|
897 |
// register user entries event call back extensions |
|
898 |
this.registerEventCallBackExtensions(); |
|
899 |
|
|
900 |
|
|
545 | 901 |
this.frame.setVisible(true); |
546 | 902 |
} |
547 | 903 |
this.loadChart(this.chartEditor.getChart()); |
548 |
// FIXME: SJ: need to fix the focus behavior on the 3 OS |
|
549 |
//this.setFocus(); |
|
550 |
//this.forceFocus(); |
|
551 | 904 |
} |
552 | 905 |
} |
553 | 906 |
|
907 |
|
|
908 |
/** |
|
909 |
* Registers user entries event call back extensions. |
|
910 |
*/ |
|
911 |
public void registerEventCallBackExtensions() { |
|
912 |
|
|
913 |
ChartResult result = this.chartEditor.getResult(); |
|
914 |
|
|
915 |
String extensionPointId = "org.txm.chartsengine.eventcallback"; //$NON-NLS-1$ |
|
916 |
IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointId); |
|
917 |
|
|
918 |
for(int i = 0; i < contributions.length; i++) { |
|
919 |
if( |
|
920 |
( |
|
921 |
contributions[i].getAttribute("chartsEngineName") == null || //$NON-NLS-1$ // for callback that can be used for all charts engine implementations |
|
922 |
contributions[i].getAttribute("chartsEngineName").equals(result.getChartsEngine().getName()) //$NON-NLS-1$ |
|
923 |
) |
|
924 |
&& |
|
925 |
contributions[i].getAttribute("resultDataClass") != null //$NON-NLS-1$ |
|
926 |
&& contributions[i].getAttribute("resultDataClass").equals(result.getClass().getName()) //$NON-NLS-1$ |
|
927 |
|
|
928 |
&& ((contributions[i].getAttribute("chartType") == null && result.getChartType().equals(ChartsEnginePreferences.DEFAULT_CHART_TYPE) //$NON-NLS-1$ |
|
929 |
|| |
|
930 |
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$ |
|
931 |
) //$NON-NLS-1$ |
|
932 |
) |
|
933 |
|
|
934 |
) { |
|
935 |
try { |
|
936 |
EventCallBack eventCallBack = (EventCallBack)contributions[i].createExecutableExtension("class"); //$NON-NLS-1$ |
|
937 |
|
|
938 |
eventCallBack.setChartEditor(this.chartEditor); |
|
939 |
|
|
940 |
EventCallBackHandler mouseHandler = this.getMouseCallBackHandler(); |
|
941 |
if(mouseHandler != null && mouseHandler.getEventCallBack(eventCallBack.getClass()) == null) { |
|
554 | 942 |
|
943 |
Log.fine("ChartEditor.registerEventCallBackExtensions(): call back of type " + eventCallBack.getClass() //$NON-NLS-1$ |
|
944 |
+ " registered in mouse handler (chart editor = " + this.chartEditor.getClass() //$NON-NLS-1$ |
|
945 |
+ ", result data class = " + result.getClass() //$NON-NLS-1$ |
|
946 |
+ ", chart type = " + result.getChartType() //$NON-NLS-1$ |
|
947 |
+ ")."); //$NON-NLS-1$ |
|
948 |
|
|
949 |
mouseHandler.registerEventCallBack(eventCallBack); |
|
950 |
} |
|
951 |
EventCallBackHandler keyboardHandler = this.getKeyCallBackHandler(); |
|
952 |
if(keyboardHandler != null && keyboardHandler.getEventCallBack(eventCallBack.getClass()) == null) { |
|
953 |
|
|
954 |
Log.fine("ChartEditor.registerEventCallBackExtensions(): call back of type " + eventCallBack.getClass() //$NON-NLS-1$ |
|
955 |
+ " registered in key handler (chart editor = " + this.chartEditor.getClass() //$NON-NLS-1$ |
|
956 |
+ ", result data class = " + result.getClass() //$NON-NLS-1$ |
|
957 |
+ ", chart type = " + result.getChartType() //$NON-NLS-1$ |
|
958 |
+ ")."); //$NON-NLS-1$ |
|
959 |
|
|
960 |
keyboardHandler.registerEventCallBack(eventCallBack); |
|
961 |
} |
|
962 |
} |
|
963 |
catch(CoreException e) { |
|
964 |
e.printStackTrace(); |
|
965 |
} |
|
966 |
break; |
|
967 |
} |
|
968 |
} |
|
969 |
|
|
970 |
} |
|
971 |
|
|
555 | 972 |
|
556 |
|
|
557 | 973 |
@Override |
558 | 974 |
public void copyChartViewToClipboard() { |
559 | 975 |
|
... | ... | |
605 | 1021 |
} |
606 | 1022 |
|
607 | 1023 |
|
1024 |
/** |
|
1025 |
* Converts an AWT event to SWT event. Also stores the Swing tool tip source text of the specified Swing component in the SWT event to give it to the SWT composite listener in <code>ChartComposite</code>. |
|
1026 |
* @param swtComposite |
|
1027 |
* @param swingComponent |
|
1028 |
* @param e |
|
1029 |
* @param eventType |
|
1030 |
* @return |
|
1031 |
*/ |
|
1032 |
// TODO : this method is incomplete |
|
1033 |
public static org.eclipse.swt.widgets.Event swingEventToSWT(Composite swtComposite, JComponent swingComponent, AWTEvent e, int eventType) { |
|
1034 |
|
|
1035 |
Event event = new Event(); |
|
1036 |
if(!swtComposite.isDisposed()) { |
|
1037 |
event.display = swtComposite.getDisplay(); |
|
1038 |
} |
|
1039 |
event.widget = swtComposite; |
|
1040 |
event.type = eventType; |
|
1041 |
|
|
1042 |
if(e instanceof MouseEvent) { |
|
1043 |
MouseEvent me = (MouseEvent) e; |
|
1044 |
event.button = me.getButton(); |
|
1045 |
try { |
|
1046 |
// Store the Swing tool tip source text in the SWT event to give it to the SWT composite listener in ChartComposite |
|
1047 |
// NOTE: this method call sometimes throws a java.lang.IndexOutOfBoundsException |
|
1048 |
event.text = swingComponent.getToolTipText(me); |
|
1049 |
} |
|
1050 |
catch(Exception e1) { |
|
1051 |
//e1.printStackTrace(); |
|
1052 |
} |
|
1053 |
event.x = me.getX(); |
|
1054 |
event.y = me.getY(); |
|
1055 |
} |
|
1056 |
return event; |
|
1057 |
} |
|
1058 |
|
|
608 | 1059 |
|
1060 |
|
|
609 | 1061 |
} |
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/ChartComposite.java (revision 1835) | ||
---|---|---|
311 | 311 |
} |
312 | 312 |
|
313 | 313 |
/** |
314 |
* Initializes the default context menus. |
|
315 |
* @param composite |
|
316 |
*/ |
|
317 |
public void initDefaultContextMenus() { |
|
318 |
this.initItemAreaContextMenu(); |
|
319 |
this.initEmptyAreaContextMenu(); |
|
320 |
this.setCurrentContextMenu(EventCallBack.AREA_EMPTY); |
|
321 |
} |
|
322 |
|
|
323 |
|
|
324 |
/** |
|
314 | 325 |
* Gets the chart component dedicated to rendering the chart. |
315 | 326 |
* @return the chartComponent |
316 | 327 |
*/ |
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/SWTChartsComponentsProvider.java (revision 1835) | ||
---|---|---|
59 | 59 |
import org.txm.utils.logger.Log; |
60 | 60 |
|
61 | 61 |
/** |
62 |
* A class providing EditorPart and EditorInput according to the current charts engine. |
|
62 |
* A class providing components such EditorPart and EditorInput according to the current charts engine. |
|
63 |
* |
|
63 | 64 |
* @author sjacquot |
64 | 65 |
* |
65 | 66 |
*/ |
... | ... | |
218 | 219 |
} |
219 | 220 |
|
220 | 221 |
/** |
221 |
* Creates a new chart container for the specified <code>ChartResult</code> save it in the specified <code>ChartEditorInput</code>.
|
|
222 |
* Creates a new chart component for the specified <code>ChartResult</code> save it in the specified <code>ChartEditorInput</code>.
|
|
222 | 223 |
* |
223 | 224 |
* @param chartsEngine |
224 | 225 |
* @param chartEditorInput |
... | ... | |
227 | 228 |
* @param chartType |
228 | 229 |
* @return |
229 | 230 |
*/ |
230 |
protected abstract boolean createChartContainer(ChartsEngine chartsEngine, ChartEditorInput chartEditorInput);
|
|
231 |
protected abstract boolean createChartComponent(ChartsEngine chartsEngine, ChartEditorInput chartEditorInput);
|
|
231 | 232 |
|
232 | 233 |
/** |
233 |
* Creates a new chart container for the specified <code>ChartResult</code> save it in the specified <code>ChartEditorInput</code>.
|
|
234 |
* Creates a new chart component for the specified <code>ChartResult</code> save it in the specified <code>ChartEditorInput</code>.
|
|
234 | 235 |
* |
235 | 236 |
* @param chartEditorInput |
236 | 237 |
* @param result |
... | ... | |
238 | 239 |
* @param chartType |
239 | 240 |
* @return |
240 | 241 |
*/ |
241 |
public boolean createChartContainer(ChartEditorInput chartEditorInput) {
|
|
242 |
Log.finest(this.getClass().getName() + ": creating a chart container...");
|
|
243 |
return this.createChartContainer(this.getChartsEngine(), chartEditorInput);
|
|
242 |
public boolean createChartComponent(ChartEditorInput chartEditorInput) {
|
|
243 |
Log.finest(this.getClass().getName() + ": creating a chart component...");
|
|
244 |
return this.createChartComponent(this.getChartsEngine(), chartEditorInput);
|
|
244 | 245 |
} |
245 | 246 |
|
246 | 247 |
|
... | ... | |
637 | 638 |
} |
638 | 639 |
|
639 | 640 |
|
640 |
/** |
|
641 |
* Initializes the default context menus. |
|
642 |
* @param composite |
|
643 |
*/ |
|
644 |
public static void initDefaultContextMenus(ChartComposite composite) { |
|
645 |
if(composite != null) { |
|
646 |
composite.initItemAreaContextMenu(); |
|
647 |
composite.initEmptyAreaContextMenu(); |
|
648 |
composite.setCurrentContextMenu(EventCallBack.AREA_EMPTY); |
|
649 |
} |
|
650 |
} |
|
641 |
// /**
|
|
642 |
// * Initializes the default context menus.
|
|
643 |
// * @param composite
|
|
644 |
// */
|
|
645 |
// public static void initDefaultContextMenus(ChartComposite composite) {
|
|
646 |
// if(composite != null) {
|
|
647 |
// composite.initItemAreaContextMenu();
|
|
648 |
// composite.initEmptyAreaContextMenu();
|
|
649 |
// composite.setCurrentContextMenu(EventCallBack.AREA_EMPTY);
|
|
650 |
// }
|
|
651 |
// }
|
|
651 | 652 |
|
652 | 653 |
|
653 | 654 |
/** |
... | ... | |
691 | 692 |
return chartEditor; |
692 | 693 |
} |
693 | 694 |
|
694 |
/** |
|
695 |
* Initializes AWT default events to delegate AWT events to SWT. |
|
696 |
* @param chartEditor |
|
697 |
* @param swingComponent |
|
698 |
*/ |
|
699 |
public static void initializeAWTDelegationListeners(final ChartEditor chartEditor, final JComponent swingComponent) { |
|
700 | 695 |
|
701 | 696 |
|
702 |
|
|
703 |
// AWT to SWT |
|
704 |
swingComponent.addMouseMotionListener(new MouseMotionListener() { |
|
705 | 697 |
|
706 |
@Override |
|
707 |
public void mouseMoved(final MouseEvent e) { |
|
708 |
if(!chartEditor.getComposite().isDisposed()) { |
|
709 |
chartEditor.getComposite().getDisplay().asyncExec(new Runnable () { |
|
710 |
public void run() { |
|
711 |
chartEditor.getComposite().notifyListeners(SWT.MouseMove, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseMove)); |
|
712 |
} |
|
713 |
}); |
|
714 |
} |
|
715 |
} |
|
716 |
|
|
717 |
@Override |
|
718 |
public void mouseDragged(MouseEvent e) { |
|
719 |
// TODO Auto-generated method stub |
|
720 |
|
|
721 |
} |
|
722 |
}); |
|
723 |
|
|
724 |
swingComponent.addMouseListener(new MouseListener() { |
|
725 |
|
|
726 |
@Override |
|
727 |
public void mouseReleased(final MouseEvent e) { |
|
728 |
if(!chartEditor.getComposite().isDisposed()) { |
|
729 |
chartEditor.getComposite().getDisplay().asyncExec(new Runnable () { |
|
730 |
public void run() { |
|
731 |
|
|
732 |
// FIXME: context menu |
|
733 |
if( |
|
734 |
|
|
735 |
e.getButton() == MouseEvent.BUTTON3 |
|
736 |
//e.isPopupTrigger() |
|
737 |
) { |
|
738 |
|
|
739 |
//System.err.println("SWTChartsComponentsProvider.initializeAWTDelegationListeners(...).new MouseListener() {...}.mouseReleased(...).new Runnable() {...}.run(): AWT popup trigger detected"); |
|
740 |
|
|
741 |
|
|
742 |
|
|
743 |
// update the mouse over item selection according to the mouse event |
|
744 |
chartEditor.getComposite().getChartComponent().updateMouseOverItem(e); |
|
745 |
|
|
746 |
// manually pop up the menu |
|
747 |
if(chartEditor.getComposite().getMenu() != null) { |
|
748 |
chartEditor.getComposite().getMenu().setLocation(new Point(e.getXOnScreen(), e.getYOnScreen())); |
|
749 |
chartEditor.getComposite().getMenu().setVisible(true); |
|
750 |
|
|
751 |
} |
|
752 |
|
|
753 |
// FIXME: the SWT.MenuDetect event delegation doesn't work, it would be better than manually pop up the menu (but other problem is the dynamic menu on chart entity item) |
|
754 |
//chartEditor.getComposite().notifyListeners(SWT.MenuDetect, SWTChartsComponentProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MenuDetect)); |
|
755 |
// FIXME: try to delegate the Menu detect event, DOES NOT SEEM TO WORK |
|
756 |
//chartEditor.getComposite().notifyListeners(SWT.MenuDetect, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MenuDetect)); |
|
757 |
//chartEditor.getComposite().notifyListeners(SWT.Show, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.Show)); |
|
758 |
|
|
759 |
} |
|
760 |
//chartEditor.getComposite().notifyListeners(SWT.MouseUp, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseUp)); |
|
761 |
//chartEditor.activate(); |
|
762 |
} |
|
763 |
}); |
|
764 |
} |
|
765 |
} |
|
766 |
|
|
767 |
@Override |
|
768 |
public void mousePressed(final MouseEvent e) { |
|
769 |
|
|
770 |
|
|
771 |
// FIXME: fix Linux. On Linux, the focus is never lost when clicking outside the Swing component, so the focus can not be given back again and the EditorPart activation patch code based on |
|
772 |
// windowsFocusGained event is called |
|
773 |
// SWT thread |
|
774 |
chartEditor.getComposite().getDisplay().asyncExec(new Runnable() { |
|
775 |
@Override |
|
776 |
public void run() { |
|
777 |
|
|
778 |
//chartEditor.getComposite().notifyListeners(SWT.MouseDown, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseDown)); |
|
779 |
|
|
780 |
// FIXME: Debug |
|
781 |
// System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new MouseListener() {...}.mousePressed(...).new Runnable() {...}.run()"); |
|
782 |
// Activate the editor part on AWT mouse pressed event |
|
783 |
//chartEditor.activate(); |
|
784 |
//chartEditor.getShell().setFocus(); |
|
785 |
chartEditor.setFocus(); |
|
786 |
//chartEditor.getParent().setFocus(); |
|
787 |
// chartEditor.forceFocus(); |
|
788 |
} |
|
789 |
}); |
|
790 |
|
|
791 |
} |
|
792 |
|
|
793 |
@Override |
|
794 |
public void mouseExited(java.awt.event.MouseEvent e) { |
|
795 |
// TODO Auto-generated method stub |
|
796 |
//Frame frame = (Frame) swingComponent.getFocusCycleRootAncestor(); |
|
797 |
//frame.setAutoRequestFocus(false); |
|
798 |
//frame.setFocusable(false); |
|
799 |
//frame.setFocusableWindowState(false); |
|
800 |
} |
|
801 |
|
|
802 |
@Override |
|
803 |
public void mouseEntered(java.awt.event.MouseEvent e) { |
|
804 |
|
|
805 |
// TODO: DEbug |
|
806 |
//System.err.println("SWTChartsComponentProvider.initializeSwingDelegationListeners(...) AWT mouse entered"); |
|
807 |
|
|
808 |
// Force the focus in the component on mouse enter |
|
809 |
/*if(!swingComponent.isFocusOwner()) { |
|
810 |
|
|
811 |
// SWT thread |
|
812 |
if(!chartEditor.getComposite().isDisposed()) { |
|
813 |
chartEditor.getComposite().getDisplay().asyncExec(new Runnable() { |
|
814 |
public void run() { |
|
815 |
|
|
816 |
|
|
817 |
// FIXME: this code works on Windows and Linux but activate() the chart editor when mouse enters |
|
818 |
//chartEditor.activate(); |
|
819 |
|
|
820 |
EventQueue.invokeLater(new Runnable () { |
|
821 |
public void run () { |
|
822 |
|
|
823 |
// TODO: this code forces to give the focus to the embedded AWT Frame under Windows (#1127 related) |
|
824 |
// For unknown reason Frame.requestFocusInWindow() doesn't work and always return false here |
|
825 |
// This code is not sufficient for Linux |
|
826 |
System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...) trying to give focus to root embedded frame"); |
|
827 |
try { |
|
828 |
Frame frame = (Frame) swingComponent.getFocusCycleRootAncestor(); |
|
829 |
//frame.synthesizeWindowActivation(true); |
|
830 |
Class clazz = frame.getClass(); |
|
831 |
Method method = clazz.getMethod("synthesizeWindowActivation", new Class[]{boolean.class}); |
|
832 |
if(method != null) { |
|
833 |
method.invoke(frame, new Object[]{new Boolean(true)}); |
|
834 |
System.out.println("SWTChartsComponentProvider.initializeSwingDelegationListeners(...).new MouseListener() {...}.mouseEntered(...).new Runnable() {...}.run(): " + frame); |
|
835 |
|
|
836 |
} |
|
837 |
|
|
838 |
//frame.requestFocusInWindow(); |
|
839 |
|
|
840 |
} |
|
841 |
catch (Throwable e) { |
|
842 |
Log.printStackTrace(e); |
|
843 |
} |
|
844 |
} |
|
845 |
}); |
|
846 |
|
|
847 |
|
|
848 |
//System.out.println("SWTChartsComponentProvider.initializeSwingDelegationListeners) AWT give focus to frame = " + ((JFCComposite)chartEditor.getComposite()).frame.requestFocusInWindow()); |
|
849 |
|
|
850 |
|
|
851 |
// chartEditor.setFocus(); |
|
852 |
// System.out.println("SWTChartsComponentProvider.initializeSwingDelegationListeners() SWT got focus = " + chartEditor.getComposite().setFocus()); |
|
853 |
|
|
854 |
// EventQueue.invokeLater(new Runnable () { |
|
855 |
// public void run () { |
|
856 |
//swingComponent.requestFocusInWindow(); |
|
857 |
|
|
858 |
// System.out.println("SWTChartsComponentProvider.initializeSwingDelegationListeners() AWT got focus = " + swingComponent.requestFocusInWindow()); |
|
859 |
// } |
|
860 |
// }); |
|
861 |
|
|
862 |
|
|
863 |
|
|
864 |
} |
|
865 |
}); |
|
866 |
} |
|
867 |
}*/ |
|
868 |
} |
|
869 |
|
|
870 |
@Override |
|
871 |
public void mouseClicked(java.awt.event.MouseEvent e) { |
|
872 |
// TODO Auto-generated method stub |
|
873 |
|
|
874 |
} |
|
875 |
}); |
|
876 |
|
|
877 |
// // Swing component focus delegation to the SWT chart composite |
|
878 |
// swingComponent.addFocusListener(new FocusListener() { |
|
879 |
// |
|
880 |
// @Override |
|
881 |
// public void focusLost(final FocusEvent e) { |
|
882 |
// |
|
883 |
// // FIXME: For Swing focus debug tests |
|
884 |
// if(RCPPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER)) { |
|
885 |
// swingComponent.setBorder(javax.swing.BorderFactory.createEmptyBorder()); |
|
886 |
// } |
|
887 |
// |
|
888 |
// Display.getDefault().asyncExec(new Runnable() { |
|
889 |
// |
|
890 |
// @Override |
|
891 |
// public void run() { |
|
892 |
// |
|
893 |
// //chartEditor.getComposite().notifyListeners(SWT.FocusOut, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.FocusOut)); |
|
894 |
// |
|
895 |
// chartEditor.deactivateContext(); |
|
896 |
// } |
|
897 |
// }); |
|
898 |
// } |
|
899 |
// |
|
900 |
// @Override |
|
901 |
// public void focusGained(final FocusEvent e) { |
|
902 |
// |
|
903 |
// // FIXME: For Swing focus debug tests |
|
904 |
// if(RCPPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER)) { |
|
905 |
// swingComponent.setBorder(new LineBorder(Color.red, 1)); |
|
906 |
// } |
|
907 |
// |
|
908 |
// Display.getDefault().asyncExec(new Runnable() { |
|
909 |
// |
|
910 |
// @Override |
|
911 |
// public void run() { |
|
912 |
// |
|
913 |
// //chartEditor.getComposite().notifyListeners(SWT.FocusIn, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.FocusIn)); |
|
914 |
// |
|
915 |
// //PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate(this); |
|
916 |
// |
|
917 |
//// chartEditor.activate(); |
|
918 |
// //chartEditor.getComposite().setFocus(); |
|
919 |
// //chartEditor.forceFocus(); |
|
920 |
// |
|
921 |
// chartEditor.activateContext(); |
|
922 |
// |
|
923 |
// } |
|
924 |
// }); |
|
925 |
// } |
|
926 |
// }); |
|
927 |
// |
|
928 |
|
|
929 |
|
|
930 |
|
|
931 |
|
|
932 |
|
|
933 |
// SWT |
|
934 |
|
|
935 |
// SWT Tooltips tests |
|
936 |
|
|
937 |
|
|
938 |
// toolTip = new DefaultToolTip(this, org.eclipse.jface.window.ToolTip.RECREATE, true); |
|
939 |
// toolTip.setPopupDelay(500); |
|
940 |
|
|
941 |
|
|
942 |
|
|
943 |
// FIXME: test HTML |
|
944 |
// toolTip = new ___CustomHTMLToolTip(this, org.eclipse.jface.window.ToolTip.NO_RECREATE, true); |
|
945 |
// toolTip.setShift(new Point(10, 50)); |
|
946 |
|
|
947 |
|
|
948 |
|
|
949 |
|
|
950 |
// Define AWT events, needed to properly give the focus to the Swing component and manage the mouse events |
|
951 |
Listener listener; |
|
952 |
|
|
953 |
//FIXME: useless ? |
|
954 |
// Run event queue dispose event |
|
955 |
// listener = new Listener () { |
|
956 |
// public void handleEvent (Event e) { |
|
957 |
// switch (e.type) { |
|
958 |
// case SWT.Dispose: |
|
959 |
// chartPanel.getParent().setVisible(false); |
|
960 |
// EventQueue.invokeLater(new Runnable () { |
|
961 |
// public void run() { |
|
962 |
// ((Frame) chartPanel.getParent().getParent()).dispose(); |
|
963 |
// } |
|
964 |
// }); |
|
965 |
// break; |
|
966 |
// } |
|
967 |
// } |
|
968 |
// }; |
|
969 |
// this.addListener(SWT.Dispose, listener); |
|
970 |
|
|
971 |
|
|
972 |
// Handle the AWT/Swing events delegation |
|
973 |
listener = new Listener () { |
|
974 |
public void handleEvent (Event e) { |
|
975 |
switch (e.type) { |
|
976 |
|
|
977 |
case SWT.FocusOut: |
|
978 |
// FIXME: DEbug |
|
979 |
// System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT composite gained focus"); |
|
980 |
System.out.println("SWTChartsComponentsProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent()"); |
|
981 |
break; |
|
982 |
|
|
983 |
|
|
984 |
case SWT.FocusIn: |
|
985 |
// FIXME: DEbug |
|
986 |
// System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT composite gained focus"); |
|
987 |
//chartEditor.getComposite().setFocus(); |
|
988 |
//chartEditor.getComposite().requestFocusInComposite(); |
|
989 |
break; |
|
990 |
case SWT.MouseMove: |
|
991 |
//System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT mouse move: " + e.x + " : " + e.y); |
|
992 |
|
|
993 |
// // FIXME: SWT tool tips test |
|
994 |
// ToolTip tip = new ToolTip(getShell(), SWT.BALLOON | SWT.ID_HIDE); |
|
995 |
// tip.setMessage("test tool tip SWT"); |
|
996 |
// tip.setLocation(getDisplay().map(self, null, new Point(e.x, e.y))); |
|
997 |
// tip.setVisible(true); |
|
998 |
|
|
999 |
// // FIXME: JFace tool tips test |
|
1000 |
// //DefaultToolTip tip2 = new DefaultToolTip( self, SWT.NONE, true ); |
|
1001 |
// //toolTip.setShift(new Point(e.x, e.y)); |
|
1002 |
// //toolTip.setText("<html><body><p>rtrt <font style=\"color: red\">yuyuyu</font></p></body></html>"); |
|
1003 |
// toolTip.setText(e.text); |
|
1004 |
// if(e.text != null) { |
|
1005 |
// toolTip.show(new Point(e.x, e.y)); |
|
1006 |
// } |
|
1007 |
// else { |
|
1008 |
// toolTip.hide(); |
|
1009 |
// } |
|
1010 |
|
|
1011 |
// FIXME: JFace tool tips test 2 |
|
1012 |
// toolTip.setText(e.text); |
|
1013 |
// if(e.text != null) { |
|
1014 |
// toolTip.show(new Point(e.x, e.y)); |
|
1015 |
// } |
|
1016 |
// else { |
|
1017 |
// toolTip.hide(); |
|
1018 |
// } |
|
1019 |
|
|
1020 |
|
|
1021 |
|
|
1022 |
break; |
|
1023 |
case SWT.MouseDown: |
|
1024 |
// FIXME: to test in Linux and Mac, it should fix the focus bugs in CA chart between table focus and chart composite/panel focus + Linux singular values bar plot focus bug |
|
1025 |
//System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT mouse down : set focus in composite and request focus in chart panel"); |
|
1026 |
//chartEditor.getComposite().setFocus(); |
|
1027 |
//chartEditor.getComposite().requestFocusInComposite(); |
|
1028 |
break; |
|
1029 |
case SWT.MouseUp: |
|
1030 |
//System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT mouse up"); |
|
1031 |
break; |
|
1032 |
|
|
1033 |
case SWT.MouseEnter: |
|
1034 |
//System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT mouse enter"); |
|
1035 |
break; |
|
1036 |
|
|
1037 |
|
|
1038 |
case SWT.Activate: |
|
1039 |
//System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT activate"); |
|
1040 |
//chartEditor.getComposite().requestFocusInComposite(); |
|
1041 |
break; |
|
1042 |
} |
|
1043 |
} |
|
1044 |
}; |
|
1045 |
//chartEditor.getComposite().addListener(SWT.FocusOut, listener); |
|
1046 |
// chartEditor.getComposite().addListener(SWT.FocusIn, listener); |
|
1047 |
// chartEditor.getComposite().addListener(SWT.MouseDown, listener); // needed to manage the focus delegation between SWT and AWT/Swing |
|
1048 |
// |
|
1049 |
//// chartEditor.getComposite().addListener(SWT.MouseEnter, listener); // TODO : test AWT delegation |
|
1050 |
// // chartEditor.getComposite().addListener(SWT.Activate, listener); // TODO : test AWT delegation |
|
1051 |
// |
|
1052 |
// |
|
1053 |
// |
|
1054 |
// // FIXME: SWT tool tips test rather than using Swing |
|
1055 |
// //chartEditor.getComposite().addListener(SWT.MouseMove, listener); |
|
1056 |
// // chartEditor.getComposite().addListener(SWT.MouseUp, listener); |
|
1057 |
|
|
1058 |
|
|
1059 |
|
|
1060 |
} |
|
1061 |
|
|
1062 |
/** |
|
1063 |
* Converts an AWT event to SWT event. Also stores the Swing tool tip source text of the specified Swing component in the SWT event to give it to the SWT composite listener in <code>ChartComposite</code>. |
|
1064 |
* @param swtComposite |
|
1065 |
* @param swingComponent |
|
1066 |
* @param e |
|
1067 |
* @param eventType |
|
1068 |
* @return |
|
1069 |
*/ |
|
1070 |
// TODO : this method is incomplete |
|
1071 |
public static org.eclipse.swt.widgets.Event swingEventToSWT(Composite swtComposite, JComponent swingComponent, AWTEvent e, int eventType) { |
|
1072 |
|
|
1073 |
Event event = new Event(); |
|
1074 |
if(!swtComposite.isDisposed()) { |
|
1075 |
event.display = swtComposite.getDisplay(); |
|
1076 |
} |
|
1077 |
event.widget = swtComposite; |
|
1078 |
event.type = eventType; |
|
1079 |
|
|
1080 |
if(e instanceof MouseEvent) { |
|
1081 |
MouseEvent me = (MouseEvent) e; |
|
1082 |
event.button = me.getButton(); |
|
1083 |
try { |
|
1084 |
// Store the Swing tool tip source text in the SWT event to give it to the SWT composite listener in ChartComposite |
|
1085 |
// NOTE: this method call sometimes throws a java.lang.IndexOutOfBoundsException |
|
1086 |
event.text = swingComponent.getToolTipText(me); |
|
1087 |
} |
|
1088 |
catch(Exception e1) { |
|
1089 |
//e1.printStackTrace(); |
|
1090 |
} |
|
1091 |
event.x = me.getX(); |
|
1092 |
event.y = me.getY(); |
|
1093 |
} |
|
1094 |
return event; |
|
1095 |
} |
|
1096 |
|
|
1097 |
|
|
1098 |
|
|
1099 | 698 |
@Override |
1100 | 699 |
public String toString() { |
1101 | 700 |
String str = this.name + " ("; //$NON-NLS-1$ |
Also available in: Unified diff