Revision 1815

tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/CAFactorialMapChartEditor.java (revision 1815)
242 242
				getResult().setChartDirty();
243 243
				getResult().setNeedsToResetView(resetView);
244 244
				compute(true);
245
				forceFocus();
245
				//forceFocus();
246 246
			}
247 247

  
248 248
			@Override
tmp/org.txm.chartsengine.raster.rcp/src/org/txm/chartsengine/raster/rcp/swt/RasterComposite.java (revision 1815)
104 104
	
105 105

  
106 106
	
107
	@Override
108
	public void requestFocusInChartComponent()	{
109
		// FIXME: to check
110
//		EventQueue.invokeLater(new Runnable () {
111
//			public void run () {
112
//				getPanel().requestFocusInWindow();
113
//			}
114
//		});
115
	}
107
//	@Override
108
//	public void requestFocusInChartComponent()	{
109
//		// FIXME: to check
110
////		EventQueue.invokeLater(new Runnable () {
111
////			public void run () {
112
////				getPanel().requestFocusInWindow();
113
////			}
114
////		});
115
//	}
116 116

  
117 117
	
118 118
	@Override
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/SWTChartsComponentsProvider.java (revision 1815)
965 965

  
966 966

  
967 967
		// Handle the AWT/Swing events delegation
968
		listener = new Listener () {
969
			public void handleEvent (Event e) {
970
				switch (e.type) {
971
					case SWT.FocusIn:
972
						// FIXME: DEbug
973
//						System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT composite gained focus");
974
						//chartEditor.getComposite().setFocus();
975
						//chartEditor.getComposite().requestFocusInComposite();
976
						break;
977
					case SWT.MouseMove:
978
						//System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT mouse move: " + e.x + " : " + e.y);
968
//		listener = new Listener () {
969
//			public void handleEvent (Event e) {
970
//				switch (e.type) {
971
//					case SWT.FocusIn:
972
//						// FIXME: DEbug
973
////						System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT composite gained focus");
974
//						//chartEditor.getComposite().setFocus();
975
//						//chartEditor.getComposite().requestFocusInComposite();
976
//						break;
977
//					case SWT.MouseMove:
978
//						//System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT mouse move: " + e.x + " : " + e.y);
979
//
980
////						// FIXME: SWT tool tips test
981
////						ToolTip tip = new ToolTip(getShell(), SWT.BALLOON | SWT.ID_HIDE);
982
////						tip.setMessage("test tool tip SWT");
983
////						tip.setLocation(getDisplay().map(self, null, new Point(e.x, e.y)));
984
////						tip.setVisible(true);
985
//
986
////						// FIXME: JFace tool tips test
987
////						//DefaultToolTip tip2 = new DefaultToolTip( self, SWT.NONE, true );
988
////						//toolTip.setShift(new Point(e.x, e.y));
989
////						//toolTip.setText("<html><body><p>rtrt <font style=\"color: red\">yuyuyu</font></p></body></html>");
990
////						toolTip.setText(e.text);
991
////						if(e.text != null)	{
992
////							toolTip.show(new Point(e.x, e.y));
993
////						}
994
////						else	{
995
////							toolTip.hide();
996
////						}
997
//
998
//						// FIXME: JFace tool tips test 2
999
////						toolTip.setText(e.text);
1000
////						if(e.text != null)	{
1001
////							toolTip.show(new Point(e.x, e.y));
1002
////						}
1003
////						else	{
1004
////							toolTip.hide();
1005
////						}
1006
//
1007
//
1008
//
1009
//						break;
1010
//					case SWT.MouseDown:
1011
//						// 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
1012
//						//System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT mouse down : set focus in composite and request focus in chart panel");
1013
//						//chartEditor.getComposite().setFocus();
1014
//						//chartEditor.getComposite().requestFocusInComposite();
1015
//						break;
1016
//					case SWT.MouseUp:
1017
//						//System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT mouse up");
1018
//						break;
1019
//
1020
//					case SWT.MouseEnter:
1021
//						//System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT mouse enter");
1022
//						break;
1023
//
1024
//
1025
//					case SWT.Activate:
1026
//						//System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT activate");
1027
//						//chartEditor.getComposite().requestFocusInComposite();
1028
//						break;
1029
//				}
1030
//		   }
1031
//		};
1032
//		chartEditor.getComposite().addListener(SWT.FocusIn, listener);
1033
//		chartEditor.getComposite().addListener(SWT.MouseDown, listener); // needed to manage the focus delegation between SWT and AWT/Swing
1034
//
1035
////		chartEditor.getComposite().addListener(SWT.MouseEnter, listener); // TODO : test AWT delegation
1036
//	//	chartEditor.getComposite().addListener(SWT.Activate, listener); // TODO : test AWT delegation
1037
//
1038
//
1039
//
1040
//		// FIXME: SWT tool tips test rather than using Swing
1041
//		//chartEditor.getComposite().addListener(SWT.MouseMove, listener);
1042
//	//	chartEditor.getComposite().addListener(SWT.MouseUp, listener);
979 1043

  
980
//						// FIXME: SWT tool tips test
981
//						ToolTip tip = new ToolTip(getShell(), SWT.BALLOON | SWT.ID_HIDE);
982
//						tip.setMessage("test tool tip SWT");
983
//						tip.setLocation(getDisplay().map(self, null, new Point(e.x, e.y)));
984
//						tip.setVisible(true);
985 1044

  
986
//						// FIXME: JFace tool tips test
987
//						//DefaultToolTip tip2 = new DefaultToolTip( self, SWT.NONE, true );
988
//						//toolTip.setShift(new Point(e.x, e.y));
989
//						//toolTip.setText("<html><body><p>rtrt <font style=\"color: red\">yuyuyu</font></p></body></html>");
990
//						toolTip.setText(e.text);
991
//						if(e.text != null)	{
992
//							toolTip.show(new Point(e.x, e.y));
993
//						}
994
//						else	{
995
//							toolTip.hide();
996
//						}
997 1045

  
998
						// FIXME: JFace tool tips test 2
999
//						toolTip.setText(e.text);
1000
//						if(e.text != null)	{
1001
//							toolTip.show(new Point(e.x, e.y));
1002
//						}
1003
//						else	{
1004
//							toolTip.hide();
1005
//						}
1006

  
1007

  
1008

  
1009
						break;
1010
					case SWT.MouseDown:
1011
						// 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
1012
						//System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT mouse down : set focus in composite and request focus in chart panel");
1013
						//chartEditor.getComposite().setFocus();
1014
						//chartEditor.getComposite().requestFocusInComposite();
1015
						break;
1016
					case SWT.MouseUp:
1017
						//System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT mouse up");
1018
						break;
1019

  
1020
					case SWT.MouseEnter:
1021
						//System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT mouse enter");
1022
						break;
1023

  
1024

  
1025
					case SWT.Activate:
1026
						//System.err.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new Listener() {...}.handleEvent(): SWT activate");
1027
						//chartEditor.getComposite().requestFocusInComposite();
1028
						break;
1029
				}
1030
		   }
1031
		};
1032
		chartEditor.getComposite().addListener(SWT.FocusIn, listener);
1033
		chartEditor.getComposite().addListener(SWT.MouseDown, listener); // needed to manage the focus delegation between SWT and AWT/Swing
1034

  
1035
//		chartEditor.getComposite().addListener(SWT.MouseEnter, listener); // TODO : test AWT delegation
1036
	//	chartEditor.getComposite().addListener(SWT.Activate, listener); // TODO : test AWT delegation
1037

  
1038

  
1039

  
1040
		// FIXME: SWT tool tips test rather than using Swing
1041
		//chartEditor.getComposite().addListener(SWT.MouseMove, listener);
1042
	//	chartEditor.getComposite().addListener(SWT.MouseUp, listener);
1043

  
1044

  
1045

  
1046 1046
	}
1047 1047

  
1048 1048
	/**
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditor.java (revision 1815)
447 447
//		}
448 448
	}
449 449

  
450
	/**
451
	 * Forces the Composite to get the focus.
452
	 */
453
	public void forceFocus() {
454
		// FIXME: debug
455
		//System.err.println("ChartEditor.forceFocus()");
450
//	/**
451
//	 * Forces the Composite to get the focus.
452
//	 */
453
//	public void forceFocus() {
454
//		// FIXME: debug
455
//		//System.err.println("ChartEditor.forceFocus()");
456
//
457
//		//this.chartComposite.setFocus();
458
//		//this.chartComposite.notifyListeners(SWT.FocusIn, null); // Needed to force the composite listener to handle the focus event
459
//	}
456 460

  
457
		//this.chartComposite.setFocus();
458
		//this.chartComposite.notifyListeners(SWT.FocusIn, null); // Needed to force the composite listener to handle the focus event
459
	}
460 461

  
461

  
462 462
	@Override
463 463
	public void setFocus() {
464 464

  
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/SwingChartComposite.java (revision 1815)
246 246
				
247 247
				// FIXME: For Swing focus debug tests
248 248
				if(RCPPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER))	{
249
					((JComponent) chartComponent).setBorder(javax.swing.BorderFactory.createEmptyBorder());
249
					((JComponent) rootPanel).setBorder(javax.swing.BorderFactory.createEmptyBorder());
250 250
				}
251 251

  
252 252
				
......
257 257
				
258 258
				// FIXME: For Swing focus debug tests
259 259
				if(RCPPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER))	{
260
					((JComponent) chartComponent).setBorder(new LineBorder(Color.red, 1));
260
					((JComponent) rootPanel).setBorder(new LineBorder(Color.red, 1));
261 261
				}
262 262

  
263 263
				
......
342 342
		
343 343
	}
344 344
	
345
	@Override
346
	public boolean setFocus() {
347

  
348
		if (this.isDisposed()) {
349
			return false;
350
		}
351
		
352
		// Debug
353
		Log.finest("SwingChartComposite.setFocus(): trying to give focus to SWT composite and AWT component..."); //$NON-NLS-1$
354
		
355
		boolean focusState = super.setFocus();
356
		
357
		// Debug
358
		Log.finest(TXMCoreMessages.bind("SwingChartComposite.setFocus(): SWT composite focus given state = {0}.", this.isFocusControl())); //$NON-NLS-1$
359
		
360
		//this.requestFocusInChartComponent();
361
		
362
		return focusState;
363
	}
345
//	@Override
346
//	public boolean setFocus() {
347
//
348
//		if (this.isDisposed()) {
349
//			return false;
350
//		}
351
//		
352
//		// Debug
353
//		Log.finest("SwingChartComposite.setFocus(): trying to give focus to SWT composite and AWT component..."); //$NON-NLS-1$
354
//		
355
//		boolean focusState = super.setFocus();
356
//		
357
//		// Debug
358
//		Log.finest(TXMCoreMessages.bind("SwingChartComposite.setFocus(): SWT composite focus given state = {0}.", this.isFocusControl())); //$NON-NLS-1$
359
//		
360
//		//this.requestFocusInChartComponent();
361
//		
362
//		return focusState;
363
//	}
364 364
	
365
	@Override
366
	public void requestFocusInChartComponent()	{
367
		
368
		
369
		if(chartComponent != null) {
370
		
371
		EventQueue.invokeLater(new Runnable () {
372
			public void run () {
373
				if(!((Component) chartComponent).isFocusOwner())	{
374
					
375
					//boolean focusState = ((Component) chartComponent).requestFocusInWindow();
376
					//((Component) chartComponent).requestFocus();
377
					((JComponent) chartComponent).grabFocus();
378
					
379
					// Debug
380
					Log.finest(TXMCoreMessages.bind("SwingChartComposite.requestFocusInChartComponent(): AWT component focus given state = {0}.", ((Component) chartComponent).isFocusOwner())); //$NON-NLS-1$
381
					
382
//					// FIXME: For Swing focus debug tests
383
//					if(RCPPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER))	{
384
//						if(((Component) chartComponent).isFocusOwner())	{
385
//							((JComponent) chartComponent).setBorder(new LineBorder(Color.red, 1));
386
//						}
387
//						else	{
388
//							((JComponent) chartComponent).setBorder(javax.swing.BorderFactory.createEmptyBorder());
389
//						}
390
//					}
391
					
392
					
393
				}
394
			}
395
		});
396
		
397
		}
398
	}
365
//	@Override
366
//	public void requestFocusInChartComponent()	{
367
//		
368
//		
369
////		if(chartComponent != null) {
370
////		
371
////		EventQueue.invokeLater(new Runnable () {
372
////			public void run () {
373
////				if(!((Component) chartComponent).isFocusOwner())	{
374
////					
375
////					//boolean focusState = ((Component) chartComponent).requestFocusInWindow();
376
////					//((Component) chartComponent).requestFocus();
377
////					((JComponent) chartComponent).grabFocus();
378
////					
379
////					// Debug
380
////					Log.finest(TXMCoreMessages.bind("SwingChartComposite.requestFocusInChartComponent(): AWT component focus given state = {0}.", ((Component) chartComponent).isFocusOwner())); //$NON-NLS-1$
381
////					
382
//////					// FIXME: For Swing focus debug tests
383
//////					if(RCPPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER))	{
384
//////						if(((Component) chartComponent).isFocusOwner())	{
385
//////							((JComponent) chartComponent).setBorder(new LineBorder(Color.red, 1));
386
//////						}
387
//////						else	{
388
//////							((JComponent) chartComponent).setBorder(javax.swing.BorderFactory.createEmptyBorder());
389
//////						}
390
//////					}
391
////					
392
////					
393
////				}
394
////			}
395
////		});
396
////		
397
////		}
398
//	}
399 399

  
400 400
	
401 401
	
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/ChartComposite.java (revision 1815)
188 188
	/**
189 189
	 * Requests that component to get the focus thread-safely.
190 190
	 */
191
	public abstract void requestFocusInChartComponent();
191
	//public abstract void requestFocusInChartComponent();
192 192

  
193 193
	/**
194 194
	 * Clears the selected items in chart.
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/handlers/ResetChartView.java (revision 1815)
20 20
		
21 21
		try {
22 22
			chartEditor.resetView();
23
			chartEditor.forceFocus();
23
//			chartEditor.forceFocus();
24 24
		}
25 25
		catch (Exception e) {
26 26
			// nothing to do

Also available in: Unified diff