Révision 1808

tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditor.java (revision 1808)
466 466
		// Debug
467 467
		Log.finest("ChartEditor.setFocus(): giving focus to chart composite..."); //$NON-NLS-1$
468 468

  
469
		this.parent.setFocus();
470
//		this.getEditorSite().getPage().activate(this);
471

  
472
		
469
		//this.parent.setFocus();
473 470
		this.chartComposite.setFocus();
474
		//this.chartComposite.requestFocusInChartComponent();
475

  
476 471
		
477 472
	}
478 473

  
479 474
	
475

  
476
	public void onPartActivated()	{
477
		System.out.println("+++++ ChartEditor.onPartActivated(): " + this.getResult());
478
		this.activateContext();
479
	}
480

  
481
	public void onPartDeactivated()	{
482
		System.out.println("----- ChartEditor.onPartDeactivated(): " + this.getResult());
483
		this.deactivateContext();
484
	}
485

  
480 486
	
481
	
482
	
483
	
484 487
	/**
485 488
	 * Initialize Swing/AWT events delegation.
486 489
	 * @param swingComponent
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/SwingChartComposite.java (revision 1808)
15 15
import java.awt.datatransfer.UnsupportedFlavorException;
16 16
import java.awt.image.BufferedImage;
17 17
import java.io.IOException;
18
import java.lang.reflect.Method;
19
import java.util.Stack;
18 20

  
19 21
import javax.swing.JComponent;
20 22
import javax.swing.JPanel;
23
import javax.swing.border.LineBorder;
21 24

  
22 25
import org.eclipse.swt.awt.SWT_AWT;
23 26
import org.eclipse.swt.widgets.Composite;
27
import org.eclipse.swt.widgets.Control;
28
import org.eclipse.swt.widgets.Display;
29
import org.eclipse.swt.widgets.Shell;
24 30
import org.txm.chartsengine.core.results.ChartResult;
25 31
import org.txm.chartsengine.rcp.IChartComponent;
26 32
import org.txm.chartsengine.rcp.editors.ChartEditor;
27 33
import org.txm.chartsengine.rcp.events.EventCallBackHandler;
28 34
import org.txm.core.messages.TXMCoreMessages;
35
import org.txm.core.preferences.TBXPreferences;
36
import org.txm.rcp.preferences.RCPPreferences;
29 37
import org.txm.utils.logger.Log;
30 38

  
31 39
/**
......
68 76
		super(chartEditor, parent, style);
69 77
		
70 78
		this.frame = SWT_AWT.new_Frame(this);
79
		
80
	
81
		
82
		
83
		
84
		
85
		
86
		
87
		
88
		
89
		
90
		
91
		
92
		
93
		
94
		
95
		
71 96
		// Need to add an AWT/Swing Panel to fix mouse events and mouse cursors changes on AWT/Swing chart component panel
72 97
		this.rootPanel = new JPanel(new BorderLayout());
73 98
		
......
80 105

  
81 106
		this.rootPanel.setBackground(Color.WHITE);
82 107
		
108
		
109
		
110
		
111
		// SJ: Workaround to fix a bug with some Java version and some OS where the focus of an embedded Swing component does not delegate to SWT, eg. the Part is not activated.
112
		// see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=377104
113
		// see: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8203855
114
		this.frame.addWindowListener(new java.awt.event.WindowAdapter() {
115
			@Override
116
			public void windowActivated(java.awt.event.WindowEvent e) {
117
				SwingChartComposite.this.getDisplay().asyncExec(new Runnable() {
118
					@Override
119
					public void run() {
120
						if (Display.getCurrent().getFocusControl() == SwingChartComposite.this) {
121
							Stack<Control> stack = new Stack<Control>();
122
							Control starter = SwingChartComposite.this;
123
							Shell shell = SwingChartComposite.this.getShell();
124
							while (starter != null && !(starter instanceof Shell)) {
125
								stack.push(starter.getParent());
126
								starter = starter.getParent();
127
							}
128

  
129
							Method m = null;
130
							try {
131
								// instead of calling the originally proposed
132
								// workaround solution (below),
133
								//
134
								// Event event = new Event();
135
								// event.display = Display.getCurrent();
136
								// event.type = SWT.Activate;
137
								// event.widget = stack.pop();
138
								// event.widget.notifyListeners(SWT.Activate,
139
								// event);
140
								//
141
								// which should but does NOT set the active
142
								// widget/control on the shell, we had
143
								// to call the setActiveControl method directly.
144
								// Updating the active control on the shell is
145
								// important so that the last active
146
								// control, when selected again, get the proper
147
								// activation events fired.
148

  
149
								m = shell.getClass().getDeclaredMethod("setActiveControl", Control.class);// $NON-NLS-1$
150
								m.setAccessible(true);
151
								while (!stack.isEmpty()) {
152
									m.invoke(shell, stack.pop());
153
								}
154
								
155
								// force the Swing component focus
156
								//setFocus();
157
								
158
							}
159
							catch (Exception e) {
160
								Log.severe("** Embedded part was not able to set active control on Shell. This will result in other workbench parts not getting activated."); //$NON-NLS-1$
161
								Log.printStackTrace(e);
162
							}
163
							finally {
164
								if (m != null) {
165
									m.setAccessible(false);
166
								}
167
							}
168
						}
169
					}
170
				});
171
			}
172
		});
173
		
174
		
83 175
	}
84 176

  
85 177
	@Override
......
176 268
	
177 269
	@Override
178 270
	public void requestFocusInChartComponent()	{
271
		
272
		
273
		if(chartComponent != null) {
274
		
179 275
		EventQueue.invokeLater(new Runnable () {
180 276
			public void run () {
181
				if(chartComponent != null && !((Component) chartComponent).isFocusOwner())	{
277
				if(!((Component) chartComponent).isFocusOwner())	{
182 278
					
183
					//boolean focusState = ((Component) chartComponent).requestFocusInWindow();
184
					((JComponent) chartComponent).grabFocus();
279
					boolean focusState = ((Component) chartComponent).requestFocusInWindow();
280
					//((Component) chartComponent).requestFocus();
281
//					((JComponent) chartComponent).grabFocus();
185 282
					
186 283
					// Debug
187 284
					Log.finest(TXMCoreMessages.bind("SwingChartComposite.requestFocusInChartComponent(): AWT component focus given state = {0}.", ((Component) chartComponent).isFocusOwner())); //$NON-NLS-1$
188 285
					
286
					// FIXME: For Swing focus debug tests
287
					if(RCPPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER))	{
288
						if(((Component) chartComponent).isFocusOwner())	{
289
							((JComponent) chartComponent).setBorder(new LineBorder(Color.red, 1));
290
						}
291
						else	{
292
							((JComponent) chartComponent).setBorder(javax.swing.BorderFactory.createEmptyBorder());
293
						}
294
					}
295
					
296
					
189 297
				}
190 298
			}
191 299
		});
300
		
301
		}
192 302
	}
193 303

  
194 304
	
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/SWTChartsComponentsProvider.java (revision 1808)
23 23
import org.eclipse.core.runtime.Platform;
24 24
import org.eclipse.jface.preference.BooleanFieldEditor;
25 25
import org.eclipse.jface.preference.ComboFieldEditor;
26
import org.eclipse.jface.util.IPropertyChangeListener;
27
import org.eclipse.jface.util.PropertyChangeEvent;
26 28
import org.eclipse.swt.SWT;
27 29
import org.eclipse.swt.graphics.Point;
28 30
import org.eclipse.swt.layout.GridData;
......
37 39
import org.eclipse.swt.widgets.ToolBar;
38 40
import org.eclipse.swt.widgets.ToolItem;
39 41
import org.eclipse.swt.widgets.Widget;
42
import org.eclipse.ui.IPartListener;
43
import org.eclipse.ui.IPartService;
40 44
import org.eclipse.ui.IWorkbenchPage;
45
import org.eclipse.ui.IWorkbenchPart;
41 46
import org.eclipse.ui.IWorkbenchWindow;
42 47
import org.eclipse.ui.PartInitException;
43 48
import org.eclipse.ui.PlatformUI;
......
80 85
	}
81 86
	
82 87
	
88
	static	{
89
		
90
		// FIXME: SJ: test to fix the Swing focus problem on the 3 OS
91
		IPartService service = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService();
92
		service.addPartListener(new IPartListener() {
93
			
94
			@Override
95
			public void partOpened(IWorkbenchPart part) {
96
				// TODO Auto-generated method stub
97
				
98
			}
99
			
100
			@Override
101
			public void partDeactivated(IWorkbenchPart part) {
102
				if(part instanceof ChartEditor)	{
103
					((ChartEditor) part).onPartDeactivated();
104
				}
105
			}
106
			
107
			@Override
108
			public void partClosed(IWorkbenchPart part) {
109
				// TODO Auto-generated method stub
110
				
111
			}
112
			
113
			@Override
114
			public void partBroughtToTop(IWorkbenchPart part) {
115
				// TODO Auto-generated method stub
116
				
117
			}
118
			
119
			@Override
120
			public void partActivated(IWorkbenchPart part) {
121
				if(part instanceof ChartEditor)	{
122
					((ChartEditor) part).onPartActivated();
123
				}
124
			}
125
		});
126
		
127
	}
83 128
	
84 129
	
85
	
86 130
	/**
87 131
	 * The charts engine.
88 132
	 */
......
152 196
//			// TODO Auto-generated catch block
153 197
//			e.printStackTrace();
154 198
//		}
199
		
155 200
	}
156 201

  
157 202
	/**
......
661 706
	 */
662 707
	public static void initializeAWTDelegationListeners(final ChartEditor chartEditor, final JComponent swingComponent)	{
663 708

  
664
		// AWT to  SWT
665
		swingComponent.addMouseMotionListener(new MouseMotionListener() {
666

  
667
			@Override
668
			public void mouseMoved(final MouseEvent e) {
669
				if(!chartEditor.getComposite().isDisposed())	{
670
					chartEditor.getComposite().getDisplay().asyncExec(new Runnable () {
671
						public void run() {
672
							chartEditor.getComposite().notifyListeners(SWT.MouseMove, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseMove));
673
						}
674
					});
675
				}
676
			}
677

  
678
			@Override
679
			public void mouseDragged(MouseEvent e) {
680
				// TODO Auto-generated method stub
681

  
682
			}
683
		});
684

  
685
		swingComponent.addMouseListener(new MouseListener() {
686

  
687
			@Override
688
			public void mouseReleased(final MouseEvent e) {
689
				chartEditor.getComposite().getDisplay().asyncExec(new Runnable () {
690
					public void run() {
691
						
692
						// FIXME: context menu
693
						if(e.isPopupTrigger())	{
694

  
695
							//System.err.println("SWTChartsComponentsProvider.initializeAWTDelegationListeners(...).new MouseListener() {...}.mouseReleased(...).new Runnable() {...}.run(): AWT popup trigger detected");
696
							
697

  
698
							
699
							// update the mouse over item selection according to the mouse event
700
							chartEditor.getComposite().getChartComponent().updateMouseOverItem(e);
701
							
702
							// manually pop up the menu
703
							if(chartEditor.getComposite().getMenu() != null)	{
704
								chartEditor.getComposite().getMenu().setLocation(new Point(e.getXOnScreen(), e.getYOnScreen()));
705
								chartEditor.getComposite().getMenu().setVisible(true);
706
							}
707

  
708
							// 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)
709
							//chartEditor.getComposite().notifyListeners(SWT.MenuDetect, SWTChartsComponentProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MenuDetect));
710
							// FIXME: try to delegate the Menu detect event, DOES NOT SEEM TO WORK
711
							//chartEditor.getComposite().notifyListeners(SWT.MenuDetect, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MenuDetect));
712
							//chartEditor.getComposite().notifyListeners(SWT.Show, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.Show));
713
							
714
						}
715
						//chartEditor.getComposite().notifyListeners(SWT.MouseUp, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseUp));
716
						//chartEditor.activate();
717
					}
718
				});
719
			}
720

  
721
			@Override
722
			public void mousePressed(final MouseEvent e) {
723

  
724
				// SWT thread
725
				chartEditor.getComposite().getDisplay().asyncExec(new Runnable() {
726
					@Override
727
					public void run() {
728

  
729
						//chartEditor.getComposite().notifyListeners(SWT.MouseDown, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseDown));
730
						
731
						// FIXME: Debug
732
//						System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new MouseListener() {...}.mousePressed(...).new Runnable() {...}.run()");
733
						// Activate the editor part on AWT mouse pressed event
734
						//chartEditor.activate();
735
						//chartEditor.getShell().setFocus();
736
						chartEditor.setFocus();
737
						//chartEditor.getParent().setFocus();
738
//						chartEditor.forceFocus();
739
					}
740
				});
741

  
742
			}
743

  
744
			@Override
745
			public void mouseExited(java.awt.event.MouseEvent e) {
746
				// TODO Auto-generated method stub
747

  
748
			}
749

  
750
			@Override
751
			public void mouseEntered(java.awt.event.MouseEvent e) {
752

  
753
				// TODO: DEbug
754
				//System.err.println("SWTChartsComponentProvider.initializeSwingDelegationListeners(...) AWT mouse entered");
755

  
756
				// Force the focus in the component on mouse enter
757
				/*if(!swingComponent.isFocusOwner())	{
758

  
759
					// SWT thread
760
					if(!chartEditor.getComposite().isDisposed())	{
761
						chartEditor.getComposite().getDisplay().asyncExec(new Runnable() {
762
							public void run() {
763 709
	
764
	
765
								// FIXME: this code works on Windows and Linux but activate() the chart editor when mouse enters
766
								//chartEditor.activate();
767
	
768
								EventQueue.invokeLater(new Runnable () {
769
									public void run () {
770
								
771
										// TODO: this code forces to give the focus to the embedded AWT Frame under Windows (#1127 related)
772
										// For unknown reason Frame.requestFocusInWindow() doesn't work and always return false here
773
										// This code is not sufficient for Linux
774
										System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...) trying to give focus to root embedded frame");
775
										try {
776
											Frame frame = (Frame) swingComponent.getFocusCycleRootAncestor();
777
											//frame.synthesizeWindowActivation(true);
778
											Class clazz = frame.getClass();
779
											Method method = clazz.getMethod("synthesizeWindowActivation", new Class[]{boolean.class});
780
											if(method != null)	{
781
												method.invoke(frame, new Object[]{new Boolean(true)});
782
												System.out.println("SWTChartsComponentProvider.initializeSwingDelegationListeners(...).new MouseListener() {...}.mouseEntered(...).new Runnable() {...}.run(): " + frame);
783
			
784
											}
785
			
786
											//frame.requestFocusInWindow();
787
			
788
			                            }
789
										catch (Throwable e) {
790
											Log.printStackTrace(e);
791
										}
792
									}
793
								});
794
								
795
								
796
								//System.out.println("SWTChartsComponentProvider.initializeSwingDelegationListeners) AWT give focus to frame = " + ((JFCComposite)chartEditor.getComposite()).frame.requestFocusInWindow());
797
	
798
	
799
	//							chartEditor.setFocus();
800
	//							System.out.println("SWTChartsComponentProvider.initializeSwingDelegationListeners() SWT got focus = " + chartEditor.getComposite().setFocus());
801
	
802
	//							EventQueue.invokeLater(new Runnable () {
803
	//								public void run () {
804
										//swingComponent.requestFocusInWindow();
805
	
806
	//									System.out.println("SWTChartsComponentProvider.initializeSwingDelegationListeners() AWT got focus = " + swingComponent.requestFocusInWindow());
807
	//								}
808
	//							});
809
	
810
	
811
	
812
							}
813
						});
814
					}
815
				}*/
816
			}
710
//		
711
//		// AWT to  SWT
712
//		swingComponent.addMouseMotionListener(new MouseMotionListener() {
713
//
714
//			@Override
715
//			public void mouseMoved(final MouseEvent e) {
716
//				if(!chartEditor.getComposite().isDisposed())	{
717
//					chartEditor.getComposite().getDisplay().asyncExec(new Runnable () {
718
//						public void run() {
719
//							chartEditor.getComposite().notifyListeners(SWT.MouseMove, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseMove));
720
//						}
721
//					});
722
//				}
723
//			}
724
//
725
//			@Override
726
//			public void mouseDragged(MouseEvent e) {
727
//				// TODO Auto-generated method stub
728
//
729
//			}
730
//		});
731
//
732
//		swingComponent.addMouseListener(new MouseListener() {
733
//
734
//			@Override
735
//			public void mouseReleased(final MouseEvent e) {
736
//				chartEditor.getComposite().getDisplay().asyncExec(new Runnable () {
737
//					public void run() {
738
//						
739
//						// FIXME: context menu
740
//						if(e.isPopupTrigger())	{
741
//
742
//							//System.err.println("SWTChartsComponentsProvider.initializeAWTDelegationListeners(...).new MouseListener() {...}.mouseReleased(...).new Runnable() {...}.run(): AWT popup trigger detected");
743
//							
744
//
745
//							
746
//							// update the mouse over item selection according to the mouse event
747
//							chartEditor.getComposite().getChartComponent().updateMouseOverItem(e);
748
//							
749
//							// manually pop up the menu
750
//							if(chartEditor.getComposite().getMenu() != null)	{
751
//								chartEditor.getComposite().getMenu().setLocation(new Point(e.getXOnScreen(), e.getYOnScreen()));
752
//								chartEditor.getComposite().getMenu().setVisible(true);
753
//							}
754
//
755
//							// 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)
756
//							//chartEditor.getComposite().notifyListeners(SWT.MenuDetect, SWTChartsComponentProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MenuDetect));
757
//							// FIXME: try to delegate the Menu detect event, DOES NOT SEEM TO WORK
758
//							//chartEditor.getComposite().notifyListeners(SWT.MenuDetect, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MenuDetect));
759
//							//chartEditor.getComposite().notifyListeners(SWT.Show, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.Show));
760
//							
761
//						}
762
//						//chartEditor.getComposite().notifyListeners(SWT.MouseUp, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseUp));
763
//						//chartEditor.activate();
764
//					}
765
//				});
766
//			}
767
//
768
//			@Override
769
//			public void mousePressed(final MouseEvent e) {
770
//
771
//				// SWT thread
772
//				chartEditor.getComposite().getDisplay().asyncExec(new Runnable() {
773
//					@Override
774
//					public void run() {
775
//
776
//						//chartEditor.getComposite().notifyListeners(SWT.MouseDown, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseDown));
777
//						
778
//						// FIXME: Debug
779
////						System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new MouseListener() {...}.mousePressed(...).new Runnable() {...}.run()");
780
//						// Activate the editor part on AWT mouse pressed event
781
//						//chartEditor.activate();
782
//						//chartEditor.getShell().setFocus();
783
//						chartEditor.setFocus();
784
//						//chartEditor.getParent().setFocus();
785
////						chartEditor.forceFocus();
786
//					}
787
//				});
788
//
789
//			}
790
//
791
//			@Override
792
//			public void mouseExited(java.awt.event.MouseEvent e) {
793
//				// TODO Auto-generated method stub
794
//
795
//			}
796
//
797
//			@Override
798
//			public void mouseEntered(java.awt.event.MouseEvent e) {
799
//
800
//				// TODO: DEbug
801
//				//System.err.println("SWTChartsComponentProvider.initializeSwingDelegationListeners(...) AWT mouse entered");
802
//
803
//				// Force the focus in the component on mouse enter
804
//				/*if(!swingComponent.isFocusOwner())	{
805
//
806
//					// SWT thread
807
//					if(!chartEditor.getComposite().isDisposed())	{
808
//						chartEditor.getComposite().getDisplay().asyncExec(new Runnable() {
809
//							public void run() {
810
//	
811
//	
812
//								// FIXME: this code works on Windows and Linux but activate() the chart editor when mouse enters
813
//								//chartEditor.activate();
814
//	
815
//								EventQueue.invokeLater(new Runnable () {
816
//									public void run () {
817
//								
818
//										// TODO: this code forces to give the focus to the embedded AWT Frame under Windows (#1127 related)
819
//										// For unknown reason Frame.requestFocusInWindow() doesn't work and always return false here
820
//										// This code is not sufficient for Linux
821
//										System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...) trying to give focus to root embedded frame");
822
//										try {
823
//											Frame frame = (Frame) swingComponent.getFocusCycleRootAncestor();
824
//											//frame.synthesizeWindowActivation(true);
825
//											Class clazz = frame.getClass();
826
//											Method method = clazz.getMethod("synthesizeWindowActivation", new Class[]{boolean.class});
827
//											if(method != null)	{
828
//												method.invoke(frame, new Object[]{new Boolean(true)});
829
//												System.out.println("SWTChartsComponentProvider.initializeSwingDelegationListeners(...).new MouseListener() {...}.mouseEntered(...).new Runnable() {...}.run(): " + frame);
830
//			
831
//											}
832
//			
833
//											//frame.requestFocusInWindow();
834
//			
835
//			                            }
836
//										catch (Throwable e) {
837
//											Log.printStackTrace(e);
838
//										}
839
//									}
840
//								});
841
//								
842
//								
843
//								//System.out.println("SWTChartsComponentProvider.initializeSwingDelegationListeners) AWT give focus to frame = " + ((JFCComposite)chartEditor.getComposite()).frame.requestFocusInWindow());
844
//	
845
//	
846
//	//							chartEditor.setFocus();
847
//	//							System.out.println("SWTChartsComponentProvider.initializeSwingDelegationListeners() SWT got focus = " + chartEditor.getComposite().setFocus());
848
//	
849
//	//							EventQueue.invokeLater(new Runnable () {
850
//	//								public void run () {
851
//										//swingComponent.requestFocusInWindow();
852
//	
853
//	//									System.out.println("SWTChartsComponentProvider.initializeSwingDelegationListeners() AWT got focus = " + swingComponent.requestFocusInWindow());
854
//	//								}
855
//	//							});
856
//	
857
//	
858
//	
859
//							}
860
//						});
861
//					}
862
//				}*/
863
//			}
864
//
865
//			@Override
866
//			public void mouseClicked(java.awt.event.MouseEvent e) {
867
//				// TODO Auto-generated method stub
868
//
869
//			}
870
//		});
871
//
872
//		// Swing component focus delegation to the SWT chart composite
873
//		swingComponent.addFocusListener(new FocusListener() {
874
//			
875
//			@Override
876
//			public void focusLost(final FocusEvent e) {
877
//				
878
//				// FIXME: For Swing focus debug tests
879
//				if(RCPPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER))	{
880
//					swingComponent.setBorder(javax.swing.BorderFactory.createEmptyBorder());
881
//				}
882
//				
883
//				Display.getDefault().asyncExec(new Runnable() {
884
//					
885
//					@Override
886
//					public void run() {
887
//						
888
//						//chartEditor.getComposite().notifyListeners(SWT.FocusOut, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.FocusOut));
889
//						
890
//						chartEditor.deactivateContext();						
891
//					}
892
//				});
893
//			}
894
//			
895
//			@Override
896
//			public void focusGained(final FocusEvent e) {
897
//				
898
//				// FIXME: For Swing focus debug tests
899
//				if(RCPPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER))	{
900
//					swingComponent.setBorder(new LineBorder(Color.red, 1));
901
//				}
902
//				
903
//				Display.getDefault().asyncExec(new Runnable() {
904
//					
905
//					@Override
906
//					public void run() {
907
//						
908
//						//chartEditor.getComposite().notifyListeners(SWT.FocusIn, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.FocusIn));
909
//
910
//						//PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate(this);
911
//						
912
////						chartEditor.activate();
913
//						//chartEditor.getComposite().setFocus();
914
//						//chartEditor.forceFocus();
915
//
916
//						chartEditor.activateContext();
917
//						
918
//					}
919
//				});
920
//			}
921
//		});
922
//		
817 923

  
818
			@Override
819
			public void mouseClicked(java.awt.event.MouseEvent e) {
820
				// TODO Auto-generated method stub
821

  
822
			}
823
		});
824

  
825
		// Swing component focus delegation to the SWT chart composite
826
		swingComponent.addFocusListener(new FocusListener() {
827
			
828
			@Override
829
			public void focusLost(final FocusEvent e) {
830
				
831
				// FIXME: For Swing focus debug tests
832
				if(RCPPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER))	{
833
					swingComponent.setBorder(javax.swing.BorderFactory.createEmptyBorder());
834
				}
835
				
836
				Display.getDefault().asyncExec(new Runnable() {
837
					
838
					@Override
839
					public void run() {
840
						
841
						//chartEditor.getComposite().notifyListeners(SWT.FocusOut, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.FocusOut));
842
						
843
						chartEditor.deactivateContext();						
844
					}
845
				});
846
			}
847
			
848
			@Override
849
			public void focusGained(final FocusEvent e) {
850
				
851
				// FIXME: For Swing focus debug tests
852
				if(RCPPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER))	{
853
					swingComponent.setBorder(new LineBorder(Color.red, 1));
854
				}
855
				
856
				Display.getDefault().asyncExec(new Runnable() {
857
					
858
					@Override
859
					public void run() {
860
						
861
						//chartEditor.getComposite().notifyListeners(SWT.FocusIn, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.FocusIn));
862

  
863
						//PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate(this);
864
						
865
//						chartEditor.activate();
866
						//chartEditor.getComposite().setFocus();
867
						//chartEditor.forceFocus();
868

  
869
						chartEditor.activateContext();
870
						
871
					}
872
				});
873
			}
874
		});
875 924
		
876 925

  
877
		
878 926

  
879 927

  
880

  
881 928
		// SWT
882 929

  
883 930
		// SWT Tooltips tests

Formats disponibles : Unified diff