Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [riena-dev] Re: getActiveWorkbenchWindow() and SwtApplication problem

Hi,

ok so I would consider that as a bug that it does not work with multiple windows. So we should open a bugzilla report for that.

christian

Am 11.04.2009 um 00:00 schrieb Elias Volanakis:

After looking into this more carefully, I found out that getActiveWorkbenchWindow() does only return null when called from a non-ui thread -- i.e. the focus does not matter. So it is not as much of a problem as I thought it was.

The second observation is still applicable: prePerformLogin / postPerform methods in SwtApplication will only work with one window.

Elias.


On Fri, Apr 10, 2009 at 1:40 PM, Elias Volanakis <elias@xxxxxxxxxxxxxxxxx> wrote:
Hi all,

I wanted to point out that I consider PlatformUI.getWorkbench().getActiveWorkbenchWindow() to be harmful. 

This method will return null when no window is active (for example the user is in another application like Firefox). This has caused NPEs in apps I have written in the past, because something would call getActiveWorkbenchWindow() while the app did not have the focus. In general you should use this.getShell() or parent.getShell() in widgets or getSite().getShell() in views and editors.

I suggest to get rid of the RcpUtilities class that provides this. I have refactored DialogView to not use it.

The other usage of RcpUtilities is in SwtApplication. This suffers exactly from the problem described above. If I understand correctly a Thread tries to hide the active window after some time of inactivity. If the application is not in the foreground there is no active window and so the inactive window will still be accessible.  Also that code assumes there is only one window and will not work correctly with several windows. It should be refactored to use PlatformUI.getWorkbench().getWorkbenchWindows() and iterate over each window.

Hope this helps,
Elias.

--
Elias Volanakis | Technical Lead | EclipseSource Portland
elias@xxxxxxxxxxxxxxxxx | +1 503 929 5537 | http://eclipsesource.com





--
Elias Volanakis | Technical Lead | EclipseSource Portland
elias@xxxxxxxxxxxxxxxxx | +1 503 929 5537 | http://eclipsesource.com


<ATT00001.c>


Back to the top