Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Why does HandlerUtil.getActiveWorkbenchWindow sometimes return null?
Why does HandlerUtil.getActiveWorkbenchWindow sometimes return null? [message #325914] Mon, 03 March 2008 03:01 Go to next message
Eclipse UserFriend
How is it possible that HandlerUtil.getActiveWorkbenchWindow
occasionally returns null? (Or equivalently that
getActiveWorkbenchWindowChecked throws an Exception?)

We've observed that this happens sometimes, but it's unpredictable. Best
shot at reproducing it is repetitive wild clicking such that command
handlers calling these methods are invoked.

Thanks all,
Jasper.
Re: Why does HandlerUtil.getActiveWorkbenchWindow sometimes return null? [message #325930 is a reply to message #325914] Mon, 03 March 2008 09:28 Go to previous messageGo to next message
Eclipse UserFriend
HandlerUtil#getActiveWorkbenchWindow(*) will return null most
consistently when a dialog is up (the active Shell is a dialog).

What usecases are you seeing where that happens? Just opening or just
closing a dialog and then executing a command? Shell based popups (like
the F2 javadoc window)?

Later,
PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
Re: Why does HandlerUtil.getActiveWorkbenchWindow sometimes return null? [message #325950 is a reply to message #325930] Mon, 03 March 2008 22:54 Go to previous messageGo to next message
Eclipse UserFriend
Paul,

We've seen this happen when executing handlers for commands associated
with toolbar items. The code is typically something like:

public Object execute(ExecutionEvent event) throws ExecutionException {
try {
// Spawn a dialog
IWorkbenchWindow window =
HandlerUtil.getActiveWorkbenchWindowChecked(event);
SomeDialog dialog = new SomeDialog(window.getShell());
dialog.open();
// ...
}
catch (Throwable t) {
// ...
}
}

Is it possible that a user invokes the handler once, closes the spawned
dialog, and then invokes the handler a second time fast enough that the
framework didn't yet get around to re-assigning the active workbench
window to ISources.ACTIVE_WORKBENCH_WINDOW_NAME ?

Thanks,
Jasper.


Paul Webster wrote:
> HandlerUtil#getActiveWorkbenchWindow(*) will return null most
> consistently when a dialog is up (the active Shell is a dialog).
>
> What usecases are you seeing where that happens? Just opening or just
> closing a dialog and then executing a command? Shell based popups (like
> the F2 javadoc window)?
>
> Later,
> PW
>
>
Re: Why does HandlerUtil.getActiveWorkbenchWindow sometimes return null? [message #325982 is a reply to message #325914] Tue, 04 March 2008 21:35 Go to previous messageGo to next message
Eclipse UserFriend
In 3.3 I used this


PlatformUI.getWorkbench().getActiveWorkbenchWindow()
Re: Why does HandlerUtil.getActiveWorkbenchWindow sometimes return null? [message #326082 is a reply to message #325950] Thu, 06 March 2008 19:33 Go to previous message
Eclipse UserFriend
Jasper wrote:
>
> Is it possible that a user invokes the handler once, closes the spawned
> dialog, and then invokes the handler a second time fast enough that the
> framework didn't yet get around to re-assigning the active workbench
> window to ISources.ACTIVE_WORKBENCH_WINDOW_NAME ?

That's entirely possible. Some of the work is driven by OS events and
some by asyncExec(*) calls ... but OS events are usually processed
before asyncExec(*) runnables.

It would be good to narrow it down to a specific use case (dialog closes
and then another dialog or window takes focus before the command can
work a second time).

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
Previous Topic:Help needed writing a custom expression for visibleWhen of a command menuContribution
Next Topic:Customizing cheat sheets
Goto Forum:
  


Current Time: Wed Mar 12 11:59:36 EDT 2025

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

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

Back to the top