Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » trouble getting Shell value during popup menu action
trouble getting Shell value during popup menu action [message #292460] Thu, 06 October 2005 14:28 Go to next message
Eclipse UserFriend
I have a popup menu action which eventually calls code with an
IProgressMonitor to perform the operation.

I am having trouble getting a Shell value (required by the MessageDialog
call) in my operation.

a) getActiveWorkbenchWindow() returns null:

IWorkbenchWindow window =
PlatformUI.getWorkbench().getActiveWorkbenchWindow();


b) If I use the Display from getDisplay() as follows, I get "invalid thread
access" when I try to call getActiveShell().

Display display = PlatformUI.getWorkbench().getDisplay();
shell = display.getActiveShell();


My code looks something like this:

public class DummyAction extends TeamAction {
public void run(IAction action) {
run(new WorkspaceModifyOperation(null) {
public void execute(IProgressMonitor monitor) throws
InterruptedException, InvocationTargetException {
try {
...
monitor.beginTask(null, 1000);
/* some work... */
/* would like to add message dialog here along with the
work */
...
} catch (TeamException e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
}, Policy.bind("DummyAction.problemMessage"), PROGRESS_DIALOG);
//$NON-NLS-1$
}
}

What approach should be taken to prompt for user input during the operation,
if it is possible?

I suspect, that the prompting may have to be done outside of the
WorkspaceModifyOperation.

Thanks,
Shaun M.
Re: trouble getting Shell value during popup menu action [message #292474 is a reply to message #292460] Thu, 06 October 2005 15:33 Go to previous message
Eclipse UserFriend
Originally posted by: douglas.pollock.magma.ca

Shaun M. wrote:
> a) getActiveWorkbenchWindow() returns null:
> b) If I use the Display from getDisplay() as follows, I get "invalid
> thread access" when I try to call getActiveShell().

You are calling from a non-UI thread. All calls to SWT must be made from
the UI thread. You can use Display.asyncExec and Display.syncExec to
execute code on the UI thread.




d.
Previous Topic:Multiple Products?
Next Topic:Tree Item Disposal
Goto Forum:
  


Current Time: Thu Sep 25 18:24:53 EDT 2025

Powered by FUDForum. Page generated in 0.02905 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top