Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix issues for menu handlers not in the right UIThread under Ubuntu

11.10
  • Loading branch information...
commit aee0389e2008446f8b43907da200f32c9d8e57e0 1 parent 3676ac8
@mickaelistria authored
View
13 ...ipse.swtbot.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/test/ui/handler/SampleHandler.java
@@ -14,8 +14,9 @@
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
/**
* Our sample handler extends AbstractHandler, an IHandler base class.
@@ -34,8 +35,12 @@ public SampleHandler() {
* the command has been executed, so extract extract the needed information from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
- IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
- MessageDialog.openInformation(window.getShell(), "Simple Dialog", "Hello, Eclipse world");
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ MessageDialog.openInformation(shell, "Simple Dialog", "Hello, Eclipse world");
+ }
+ });
return null;
}
}
View
15 ...clipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/test/ui/handler/SampleParameterizedHandler.java
@@ -15,8 +15,9 @@
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
/**
* Our sample handler extends AbstractHandler, an IHandler base class.
@@ -34,9 +35,13 @@ public SampleParameterizedHandler() {
/**
* the command has been executed, so extract extract the needed information from the application context.
*/
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
- MessageDialog.openInformation(window.getShell(), "Simple Dialog", "My parameters:" + event.getParameters().toString());
+ public Object execute(final ExecutionEvent event) throws ExecutionException {
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ MessageDialog.openInformation(shell, "Simple Dialog", "My parameters:" + event.getParameters().toString());
+ }
+ });
return null;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.