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
|