Révision 1702
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/SWTChartsComponentsProvider.java (revision 1702) | ||
|---|---|---|
| 1 | 1 |
package org.txm.chartsengine.rcp; |
| 2 | 2 |
|
| 3 | 3 |
|
| 4 |
import java.awt.AWTEvent; |
|
| 4 | 5 |
import java.awt.Color; |
| 5 | 6 |
import java.awt.event.FocusEvent; |
| 6 | 7 |
import java.awt.event.FocusListener; |
| ... | ... | |
| 40 | 41 |
import org.eclipse.ui.IWorkbenchWindow; |
| 41 | 42 |
import org.eclipse.ui.PartInitException; |
| 42 | 43 |
import org.eclipse.ui.PlatformUI; |
| 43 |
import org.eclipse.ui.part.MultiPageEditorPart; |
|
| 44 | 44 |
import org.txm.chartsengine.core.ChartsEngine; |
| 45 | 45 |
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences; |
| 46 | 46 |
import org.txm.chartsengine.core.results.ChartResult; |
| ... | ... | |
| 712 | 712 |
//chartEditor.getComposite().notifyListeners(SWT.Show, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.Show)); |
| 713 | 713 |
|
| 714 | 714 |
} |
| 715 |
chartEditor.getComposite().notifyListeners(SWT.MouseUp, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseUp)); |
|
| 715 |
//chartEditor.getComposite().notifyListeners(SWT.MouseUp, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseUp));
|
|
| 716 | 716 |
//chartEditor.activate(); |
| 717 | 717 |
} |
| 718 | 718 |
}); |
| ... | ... | |
| 726 | 726 |
@Override |
| 727 | 727 |
public void run() {
|
| 728 | 728 |
|
| 729 |
chartEditor.getComposite().notifyListeners(SWT.MouseDown, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseDown)); |
|
| 729 |
//chartEditor.getComposite().notifyListeners(SWT.MouseDown, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.MouseDown));
|
|
| 730 | 730 |
|
| 731 | 731 |
// FIXME: Debug |
| 732 | 732 |
// System.out.println("SWTChartsComponentProvider.initializeAWTDelegationListeners(...).new MouseListener() {...}.mousePressed(...).new Runnable() {...}.run()");
|
| 733 | 733 |
// Activate the editor part on AWT mouse pressed event |
| 734 |
// chartEditor.activate(); |
|
| 734 |
//chartEditor.activate(); |
|
| 735 |
//chartEditor.getShell().setFocus(); |
|
| 736 |
chartEditor.setFocus(); |
|
| 737 |
//chartEditor.getParent().setFocus(); |
|
| 735 | 738 |
// chartEditor.forceFocus(); |
| 736 | 739 |
} |
| 737 | 740 |
}); |
| ... | ... | |
| 819 | 822 |
} |
| 820 | 823 |
}); |
| 821 | 824 |
|
| 825 |
// Swing component focus delegation to the SWT chart composite |
|
| 822 | 826 |
swingComponent.addFocusListener(new FocusListener() {
|
| 823 | 827 |
|
| 824 | 828 |
@Override |
| 825 |
public void focusLost(FocusEvent e) {
|
|
| 829 |
public void focusLost(final FocusEvent e) {
|
|
| 826 | 830 |
|
| 827 | 831 |
// FIXME: For Swing focus debug tests |
| 828 | 832 |
if(RCPPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER)) {
|
| ... | ... | |
| 833 | 837 |
|
| 834 | 838 |
@Override |
| 835 | 839 |
public void run() {
|
| 840 |
|
|
| 841 |
//chartEditor.getComposite().notifyListeners(SWT.FocusOut, SWTChartsComponentsProvider.swingEventToSWT(chartEditor.getComposite(), swingComponent, e, SWT.FocusOut)); |
|
| 842 |
|
|
| 836 | 843 |
chartEditor.deactivateContext(); |
| 837 | 844 |
} |
| 838 | 845 |
}); |
| 839 | 846 |
} |
| 840 | 847 |
|
| 841 | 848 |
@Override |
| 842 |
public void focusGained(FocusEvent e) {
|
|
| 849 |
public void focusGained(final FocusEvent e) {
|
|
| 843 | 850 |
|
| 844 | 851 |
// FIXME: For Swing focus debug tests |
| 845 | 852 |
if(RCPPreferences.getInstance().getBoolean(TBXPreferences.EXPERT_USER)) {
|
| ... | ... | |
| 850 | 857 |
|
| 851 | 858 |
@Override |
| 852 | 859 |
public void run() {
|
| 853 |
chartEditor.activateContext(); |
|
| 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 |
|
|
| 854 | 871 |
} |
| 855 | 872 |
}); |
| 856 | 873 |
} |
| ... | ... | |
| 990 | 1007 |
* @return |
| 991 | 1008 |
*/ |
| 992 | 1009 |
// TODO : this method is incomplete |
| 993 |
public static org.eclipse.swt.widgets.Event swingEventToSWT(Composite swtComposite, JComponent swingComponent, MouseEvent e, int eventType) {
|
|
| 1010 |
public static org.eclipse.swt.widgets.Event swingEventToSWT(Composite swtComposite, JComponent swingComponent, AWTEvent e, int eventType) {
|
|
| 994 | 1011 |
|
| 995 | 1012 |
Event event = new Event(); |
| 996 |
event.button = e.getButton(); |
|
| 997 | 1013 |
if(!swtComposite.isDisposed()) {
|
| 998 | 1014 |
event.display = swtComposite.getDisplay(); |
| 999 | 1015 |
} |
| 1000 | 1016 |
event.widget = swtComposite; |
| 1001 | 1017 |
event.type = eventType; |
| 1002 | 1018 |
|
| 1003 |
try {
|
|
| 1004 |
// Store the Swing tool tip source text in the SWT event to give it to the SWT composite listener in ChartComposite |
|
| 1005 |
// NOTE: this method call sometimes throws a java.lang.IndexOutOfBoundsException |
|
| 1006 |
event.text = swingComponent.getToolTipText(e); |
|
| 1019 |
if(e instanceof MouseEvent) {
|
|
| 1020 |
MouseEvent me = (MouseEvent) e; |
|
| 1021 |
event.button = me.getButton(); |
|
| 1022 |
try {
|
|
| 1023 |
// Store the Swing tool tip source text in the SWT event to give it to the SWT composite listener in ChartComposite |
|
| 1024 |
// NOTE: this method call sometimes throws a java.lang.IndexOutOfBoundsException |
|
| 1025 |
event.text = swingComponent.getToolTipText(me); |
|
| 1026 |
} |
|
| 1027 |
catch(Exception e1) {
|
|
| 1028 |
//e1.printStackTrace(); |
|
| 1029 |
} |
|
| 1030 |
event.x = me.getX(); |
|
| 1031 |
event.y = me.getY(); |
|
| 1007 | 1032 |
} |
| 1008 |
catch(Exception e1) {
|
|
| 1009 |
//e1.printStackTrace(); |
|
| 1010 |
} |
|
| 1011 |
event.x = e.getX(); |
|
| 1012 |
event.y = e.getY(); |
|
| 1013 | 1033 |
return event; |
| 1014 | 1034 |
} |
| 1015 | 1035 |
|
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditor.java (revision 1702) | ||
|---|---|---|
| 328 | 328 |
|
| 329 | 329 |
|
| 330 | 330 |
// if(this.parentMultiPagesEditor == null) {
|
| 331 |
// this.forceFocus(); |
|
| 331 |
// //this.forceFocus(); |
|
| 332 |
// this.activate(); |
|
| 332 | 333 |
// } |
| 333 | 334 |
} |
| 334 | 335 |
|
| ... | ... | |
| 439 | 440 |
*/ |
| 440 | 441 |
//FIXME: this method doesn't work for Multi pages editor, eg. can not activating CAFactorialMapEditor stored in the CAEditor |
| 441 | 442 |
public void activate() {
|
| 443 |
|
|
| 442 | 444 |
// Activate the parent multi pages editor instead of this editor if it exists |
| 443 | 445 |
if(this.parentMultiPagesEditor != null) {
|
| 444 | 446 |
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate(this.parentMultiPagesEditor); |
| 445 | 447 |
} |
| 446 |
else {
|
|
| 448 |
else {
|
|
| 447 | 449 |
// TODO: for focus and activation debug |
| 448 |
// System.out.println("ChartEditor.activate(): current active editor = " + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart());
|
|
| 449 | 450 |
// System.out.println("ChartEditor.activate(): activating: " + this);
|
| 450 |
// PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop(this); |
|
| 451 |
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate(this); |
|
| 451 |
//PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop(this); |
|
| 452 |
|
|
| 453 |
//this.parent.setFocus(); |
|
| 452 | 454 |
|
| 455 |
// if(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart() != this) {
|
|
| 456 |
//this.chartComposite.setFocus(); |
|
| 457 |
// } |
|
| 458 |
|
|
| 459 |
//PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate(this); |
|
| 460 |
|
|
| 461 |
|
|
| 462 |
//getEditorSite().getPage().activate(this); |
|
| 463 |
// if(!this.chartComposite.hasFocus()) {
|
|
| 464 |
// this.chartComposite.setFocus(); |
|
| 465 |
// } |
|
| 466 |
|
|
| 453 | 467 |
// System.out.println("ChartEditor.activate(): new active editor = " + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart());
|
| 454 | 468 |
} |
| 469 |
// else {
|
|
| 470 |
// PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop(this); |
|
| 471 |
// } |
|
| 455 | 472 |
} |
| 456 | 473 |
|
| 457 | 474 |
/** |
| 458 | 475 |
* Forces the Composite to get the focus. |
| 459 | 476 |
*/ |
| 460 |
public void forceFocus() {
|
|
| 477 |
public void forceFocus() {
|
|
| 461 | 478 |
// FIXME: debug |
| 462 | 479 |
//System.err.println("ChartEditor.forceFocus()");
|
| 463 | 480 |
|
| 464 | 481 |
//this.chartComposite.setFocus(); |
| 465 |
this.chartComposite.notifyListeners(SWT.FocusIn, null); // Needed to force the composite listener to handle the focus event |
|
| 482 |
//this.chartComposite.notifyListeners(SWT.FocusIn, null); // Needed to force the composite listener to handle the focus event
|
|
| 466 | 483 |
} |
| 467 | 484 |
|
| 468 | 485 |
|
| 469 | 486 |
@Override |
| 470 | 487 |
public void setFocus() {
|
| 471 | 488 |
|
| 489 |
super.setFocus(); |
|
| 472 | 490 |
// Debug |
| 473 | 491 |
Log.finest("ChartEditor.setFocus(): giving focus to chart composite..."); //$NON-NLS-1$
|
| 474 | 492 |
|
| 493 |
this.parent.setFocus(); |
|
| 494 |
// this.getEditorSite().getPage().activate(this); |
|
| 495 |
|
|
| 496 |
|
|
| 475 | 497 |
this.chartComposite.setFocus(); |
| 498 |
//this.chartComposite.requestFocusInChartComponent(); |
|
| 476 | 499 |
|
| 500 |
|
|
| 477 | 501 |
} |
| 478 | 502 |
|
| 479 | 503 |
|
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/SwingChartComposite.java (revision 1702) | ||
|---|---|---|
| 180 | 180 |
public void requestFocusInChartComponent() {
|
| 181 | 181 |
EventQueue.invokeLater(new Runnable () {
|
| 182 | 182 |
public void run () {
|
| 183 |
if(chartComponent != null) {
|
|
| 183 |
if(chartComponent != null && !((Component) chartComponent).isFocusOwner()) {
|
|
| 184 | 184 |
|
| 185 |
boolean focusState = ((Component) chartComponent).requestFocusInWindow(); |
|
| 185 |
//boolean focusState = ((Component) chartComponent).requestFocusInWindow();
|
|
| 186 | 186 |
((JComponent) chartComponent).grabFocus(); |
| 187 | 187 |
|
| 188 | 188 |
// Debug |
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/handlers/ResetChartView.java (revision 1702) | ||
|---|---|---|
| 18 | 18 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
| 19 | 19 |
ChartEditor chartEditor = SWTChartsComponentsProvider.getActiveChartEditor(event); |
| 20 | 20 |
|
| 21 |
//ChartEditor chartEditor = null; |
|
| 22 |
|
|
| 23 | 21 |
try {
|
| 24 |
//chartEditor = (ChartEditor)SWTEditorsUtils.getActiveEditor(event); |
|
| 25 |
|
|
| 26 | 22 |
chartEditor.resetView(); |
| 27 | 23 |
chartEditor.forceFocus(); |
| 28 | 24 |
} |
Formats disponibles : Unified diff