3 |
3 |
*/
|
4 |
4 |
package org.txm.chartsengine.rcp.swt;
|
5 |
5 |
|
6 |
|
import java.awt.BorderLayout;
|
7 |
6 |
import java.awt.Color;
|
8 |
7 |
import java.awt.Component;
|
9 |
|
import java.awt.EventQueue;
|
10 |
8 |
import java.awt.Frame;
|
11 |
9 |
import java.awt.Graphics2D;
|
12 |
10 |
import java.awt.Toolkit;
|
... | ... | |
20 |
18 |
import java.awt.event.WindowListener;
|
21 |
19 |
import java.awt.image.BufferedImage;
|
22 |
20 |
import java.io.IOException;
|
23 |
|
import java.lang.reflect.InvocationTargetException;
|
24 |
21 |
import java.lang.reflect.Method;
|
25 |
22 |
import java.util.Stack;
|
26 |
23 |
|
27 |
24 |
import javax.swing.JApplet;
|
28 |
25 |
import javax.swing.JComponent;
|
29 |
|
import javax.swing.JPanel;
|
30 |
26 |
import javax.swing.SwingUtilities;
|
31 |
27 |
import javax.swing.border.LineBorder;
|
32 |
28 |
|
|
29 |
import org.eclipse.swt.SWT;
|
33 |
30 |
import org.eclipse.swt.awt.SWT_AWT;
|
34 |
31 |
import org.eclipse.swt.widgets.Composite;
|
35 |
32 |
import org.eclipse.swt.widgets.Control;
|
36 |
33 |
import org.eclipse.swt.widgets.Display;
|
|
34 |
import org.eclipse.swt.widgets.Event;
|
37 |
35 |
import org.eclipse.swt.widgets.Shell;
|
|
36 |
import org.eclipse.ui.PlatformUI;
|
38 |
37 |
import org.txm.chartsengine.core.results.ChartResult;
|
39 |
38 |
import org.txm.chartsengine.rcp.IChartComponent;
|
40 |
39 |
import org.txm.chartsengine.rcp.editors.ChartEditor;
|
... | ... | |
239 |
238 |
Log.finest("SwingChartComposite.SwingChartComposite(...).new WindowFocusListener() {...}.windowLostFocus()");
|
240 |
239 |
|
241 |
240 |
// Force the keep the focus if the ChartEditor has the focus
|
242 |
|
SwingChartComposite.this.getDisplay().asyncExec(new Runnable() {
|
243 |
|
@Override
|
244 |
|
public void run() {
|
245 |
|
if (Display.getCurrent().getFocusControl() == SwingChartComposite.this) {
|
246 |
|
requestFocusInChartComponent();
|
|
241 |
if(!SwingChartComposite.this.isDisposed()) {
|
|
242 |
SwingChartComposite.this.getDisplay().asyncExec(new Runnable() {
|
|
243 |
@Override
|
|
244 |
public void run() {
|
|
245 |
if (Display.getCurrent().getFocusControl() == SwingChartComposite.this) {
|
|
246 |
Log.finest("SwingChartComposite.SwingChartComposite(...).new WindowFocusListener() {...}.windowLostFocus(): force focus in chart component.");
|
|
247 |
requestFocusInChartComponent();
|
|
248 |
}
|
247 |
249 |
}
|
248 |
|
}
|
249 |
|
});
|
|
250 |
});
|
|
251 |
}
|
250 |
252 |
|
251 |
253 |
|
252 |
254 |
|
... | ... | |
274 |
276 |
SwingChartComposite.this.getDisplay().asyncExec(new Runnable() {
|
275 |
277 |
@Override
|
276 |
278 |
public void run() {
|
277 |
|
if (Display.getCurrent().getFocusControl() == SwingChartComposite.this) {
|
|
279 |
if (
|
|
280 |
Display.getCurrent().getFocusControl() == SwingChartComposite.this
|
|
281 |
// &&
|
|
282 |
// SwingChartComposite.this.chartEditor != PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()
|
|
283 |
) {
|
|
284 |
|
|
285 |
Log.finest("SwingChartComposite.SwingChartComposite(...).new WindowFocusListener() {...}.windowGainedFocus(): activate the EditorPart.");
|
|
286 |
|
278 |
287 |
Stack<Control> stack = new Stack<Control>();
|
279 |
288 |
Control starter = SwingChartComposite.this;
|
280 |
289 |
Shell shell = SwingChartComposite.this.getShell();
|
... | ... | |
288 |
297 |
// instead of calling the originally proposed
|
289 |
298 |
// workaround solution (below),
|
290 |
299 |
//
|
291 |
|
// Event event = new Event();
|
292 |
|
// event.display = Display.getCurrent();
|
293 |
|
// event.type = SWT.Activate;
|
294 |
|
// event.widget = stack.pop();
|
295 |
|
// event.widget.notifyListeners(SWT.Activate, event);
|
|
300 |
// Event event = new Event();
|
|
301 |
// event.display = Display.getCurrent();
|
|
302 |
// event.type = SWT.Activate;
|
|
303 |
// event.widget = stack.pop();
|
|
304 |
// event.widget.notifyListeners(SWT.Activate, event);
|
296 |
305 |
//
|
297 |
306 |
// which should but does NOT set the active
|
298 |
307 |
// widget/control on the shell, we had
|
... | ... | |
302 |
311 |
// control, when selected again, get the proper
|
303 |
312 |
// activation events fired.
|
304 |
313 |
|
|
314 |
//PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate(SwingChartComposite.this.chartEditor);
|
|
315 |
|
305 |
316 |
m = shell.getClass().getDeclaredMethod("setActiveControl", Control.class);// $NON-NLS-1$
|
306 |
317 |
m.setAccessible(true);
|
307 |
318 |
while (!stack.isEmpty()) {
|