Révision 2044
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/SwingChartComposite.java (revision 2044) | ||
---|---|---|
13 | 13 |
import java.awt.datatransfer.DataFlavor; |
14 | 14 |
import java.awt.datatransfer.Transferable; |
15 | 15 |
import java.awt.datatransfer.UnsupportedFlavorException; |
16 |
import java.awt.event.FocusEvent; |
|
17 |
import java.awt.event.FocusListener; |
|
16 | 18 |
import java.awt.event.MouseEvent; |
17 | 19 |
import java.awt.event.MouseListener; |
18 | 20 |
import java.awt.event.WindowEvent; |
... | ... | |
20 | 22 |
import java.awt.event.WindowListener; |
21 | 23 |
import java.awt.image.BufferedImage; |
22 | 24 |
import java.io.IOException; |
23 |
import java.lang.reflect.Method; |
|
24 |
import java.util.Stack; |
|
25 | 25 |
|
26 | 26 |
import javax.swing.JComponent; |
27 | 27 |
import javax.swing.JPanel; |
28 | 28 |
import javax.swing.SwingUtilities; |
29 | 29 |
import javax.swing.border.LineBorder; |
30 | 30 |
|
31 |
import org.eclipse.core.runtime.CoreException; |
|
32 |
import org.eclipse.core.runtime.IConfigurationElement; |
|
33 |
import org.eclipse.core.runtime.Platform; |
|
34 | 31 |
import org.eclipse.swt.awt.SWT_AWT; |
35 | 32 |
import org.eclipse.swt.graphics.Point; |
36 | 33 |
import org.eclipse.swt.widgets.Composite; |
37 |
import org.eclipse.swt.widgets.Control; |
|
38 | 34 |
import org.eclipse.swt.widgets.Display; |
39 | 35 |
import org.eclipse.swt.widgets.Event; |
40 |
import org.eclipse.swt.widgets.Shell; |
|
41 |
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences; |
|
42 | 36 |
import org.txm.chartsengine.core.results.ChartResult; |
43 |
import org.txm.chartsengine.rcp.IChartComponent; |
|
44 | 37 |
import org.txm.chartsengine.rcp.editors.ChartEditor; |
45 |
import org.txm.chartsengine.rcp.events.EventCallBack; |
|
46 | 38 |
import org.txm.chartsengine.rcp.events.EventCallBackHandler; |
47 | 39 |
import org.txm.core.messages.TXMCoreMessages; |
48 |
import org.txm.core.preferences.TBXPreferences; |
|
49 |
import org.txm.rcp.preferences.RCPPreferences; |
|
50 | 40 |
import org.txm.utils.OSDetector; |
51 | 41 |
import org.txm.utils.logger.Log; |
52 | 42 |
|
... | ... | |
109 | 99 |
// it breaks all the key events in charts (zoom, pan, selection, etc.) but |
110 | 100 |
// stops the conflict between AWT and SWT events that freezes the SWT Spinner, TextFields, etc. |
111 | 101 |
// (Progression query, Specificities chart banality, etc.) |
112 |
// if(OSDetector.isFamilyUnix()) { |
|
113 |
// this.frame.setFocusableWindowState(false); |
|
114 |
// } |
|
102 |
// see: http://forge.cbp.ens-lyon.fr/redmine/issues/2548 |
|
103 |
if(OSDetector.isFamilyUnix() |
|
104 |
//&& (chartEditor.getClass().getName().equals("org.txm.progression.rcp.editors.ProgressionEditor") //$NON-NLS-1$ |
|
105 |
// || chartEditor.getClass().getName().equals("org.txm.specificities.rcp.editors.SpecificitiesSelectionEditor") //$NON-NLS-1$ |
|
106 |
// || chartEditor.getClass().getName().equals("org.txm.ca.rcp.editors.CAFactorialMapChartEditor") //$NON-NLS-1$ |
|
107 |
// ) |
|
108 |
) { |
|
109 |
// Log.finest("SwingChartComposite.SwingChartComposite(): Temporary Linux bug workaround: AWT focusable window state set to false."); |
|
110 |
//this.frame.setFocusableWindowState(false); |
|
111 |
this.frame.setAutoRequestFocus(false); |
|
112 |
} |
|
115 | 113 |
|
114 |
|
|
116 | 115 |
this.frame.setVisible(true); |
117 | 116 |
|
118 | 117 |
this.rootPanel.setBackground(Color.WHITE); |
... | ... | |
281 | 280 |
}); |
282 | 281 |
|
283 | 282 |
|
284 |
// |
|
285 |
// this.frame.addFocusListener(new FocusListener() {
|
|
286 |
// |
|
287 |
// @Override
|
|
288 |
// public void focusLost(FocusEvent e) {
|
|
289 |
// // TODO Auto-generated method stub
|
|
290 |
// Log.finest("SwingChartComposite.SwingChartComposite(...).new FocusListener() {...}.focusLost()");
|
|
291 |
// }
|
|
292 |
// |
|
293 |
// @Override
|
|
294 |
// public void focusGained(FocusEvent e) {
|
|
295 |
// // TODO Auto-generated method stub
|
|
296 |
// Log.finest("SwingChartComposite.SwingChartComposite(...).new FocusListener() {...}.focusGained()");
|
|
297 |
// }
|
|
298 |
// });
|
|
299 |
// |
|
300 |
// |
|
283 |
|
|
284 |
this.frame.addFocusListener(new FocusListener() { |
|
285 |
|
|
286 |
@Override |
|
287 |
public void focusLost(FocusEvent e) { |
|
288 |
// TODO Auto-generated method stub |
|
289 |
Log.finest("SwingChartComposite.SwingChartComposite(...).new FocusListener() {...}.focusLost()"); |
|
290 |
} |
|
291 |
|
|
292 |
@Override |
|
293 |
public void focusGained(FocusEvent e) { |
|
294 |
// TODO Auto-generated method stub |
|
295 |
Log.finest("SwingChartComposite.SwingChartComposite(...).new FocusListener() {...}.focusGained()"); |
|
296 |
} |
|
297 |
}); |
|
298 |
|
|
299 |
|
|
301 | 300 |
// this.frame.addWindowFocusListener(new WindowFocusListener() { |
302 | 301 |
// |
303 | 302 |
// @Override |
... | ... | |
431 | 430 |
// Debug |
432 | 431 |
Log.finest(TXMCoreMessages.bind("SwingChartComposite.setFocus(): SWT composite focus given state = {0}.", this.isFocusControl())); //$NON-NLS-1$ |
433 | 432 |
|
434 |
this.requestFocusInChartComponent(); |
|
433 |
//this.requestFocusInChartComponent();
|
|
435 | 434 |
|
436 | 435 |
return focusState; |
437 | 436 |
} |
... | ... | |
576 | 575 |
chartEditor.setFocus(); |
577 | 576 |
//chartEditor.getParent().setFocus(); |
578 | 577 |
//chartEditor.getParent().getShell().setActive(); |
578 |
requestFocusInChartComponent(); |
|
579 | 579 |
|
580 |
|
|
581 | 580 |
//chartEditor.getParent().setFocus(); |
582 | 581 |
// chartEditor.forceFocus(); |
583 | 582 |
} |
... | ... | |
587 | 586 |
|
588 | 587 |
@Override |
589 | 588 |
public void mouseExited(java.awt.event.MouseEvent e) { |
589 |
|
|
590 |
// FIXME: SJ: temporary workaround to Linux focus bugs |
|
591 |
// it breaks all the key events in charts (zoom, pan, selection, etc.) but |
|
592 |
// stops the conflict between AWT and SWT events that freezes the SWT Spinner, TextFields, etc. |
|
593 |
// (Progression query, Specificities chart banality, etc.) |
|
594 |
// see: http://forge.cbp.ens-lyon.fr/redmine/issues/2548 |
|
595 |
if(OSDetector.isFamilyUnix()) { |
|
596 |
if (!((Component) getChartComponent()).contains(e.getPoint())) { |
|
597 |
|
|
598 |
// TODO Auto-generated method stub |
|
599 |
// Component f = |
|
600 |
// KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner(); |
|
601 |
// frame.setFocusableWindowState(true); |
|
602 |
// frame.setAutoRequestFocus(false); |
|
603 |
// frame.setFocusable(false); |
|
604 |
// KeyboardFocusManager.getCurrentKeyboardFocusManager().clearFocusOwner(); |
|
605 |
// KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); |
|
606 |
// frame.setFocusableWindowState(false); |
|
607 |
// f.setEnabled(false); |
|
608 |
// f.setEnabled(true); |
|
609 |
// System.out.println("SwingChartComposite.initEventsListeners().new |
|
610 |
// MouseListener() {...}.mouseExited()"); |
|
611 |
// frame.setAutoRequestFocus(false); |
|
612 |
// frame.setFocusable(false); |
|
613 |
// KeyboardFocusManager.getCurrentKeyboardFocusManager().clearFocusOwner(); |
|
614 |
// KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); |
|
615 |
|
|
616 |
frame.setVisible(false); |
|
617 |
Log.finest("SwingChartComposite.initEventsListeners().new MouseListener() {...}.mouseExited()"); |
|
618 |
frame.setVisible(true); |
|
619 |
|
|
620 |
Display.getDefault().asyncExec(new Runnable() { |
|
621 |
|
|
622 |
@Override |
|
623 |
public void run() { |
|
624 |
// TODO Auto-generated method stub |
|
625 |
// shell.setMinimized(true); |
|
626 |
// shell.setMinimized(false); |
|
627 |
// shell.setActive(); |
|
628 |
getChartComponent().getChartEditor().getShell().forceActive(); |
|
629 |
} |
|
630 |
}); |
|
631 |
|
|
632 |
} |
|
633 |
|
|
634 |
|
|
635 |
} |
|
636 |
|
|
637 |
|
|
638 |
|
|
590 | 639 |
// TODO Auto-generated method stub |
591 | 640 |
//Frame frame = (Frame) swingComponent.getFocusCycleRootAncestor(); |
592 | 641 |
//frame.setAutoRequestFocus(false); |
Formats disponibles : Unified diff