DESCRIPTION

Register ShellListener to detect if workbench is active

By registering a ShellListener we can avoid that the detection if the
workbench is active may freeze the UI thread.

Bug: 455468
Change-Id: I31e02f6f676c3354c6310a51283c7022d9cfe3e2
Signed-off-by: Douglas Trujillo xxx@xxx.xxx

COMMENTS

author: Douglas Trujillo
date: 2014-12-19 00:29:18.000000000

Uploaded patch set 1.

-------------------------------------
author: Brenden Conley
date: 2014-12-19 00:30:48.000000000

Patch Set 1:

Build Started https://hudson.eclipse.org/egit/job/egit-stable.gerrit/485/

-------------------------------------
author: Brenden Conley
date: 2014-12-19 00:31:25.000000000

Patch Set 1: Verified-1

Build Failed 

https://hudson.eclipse.org/egit/job/egit-stable.gerrit/485/ : FAILURE

-------------------------------------
author: Courtney Wall
date: 2014-12-19 05:48:59.000000000

Patch Set 1:

(2 comments)

Line:250, org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java -> is this needed? plugin.isActive should be false anyways then, right?

Line:531, org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java -> can this ever return null in this case? if so, I'd log this case to get notified if this assumption is wrong.

-------------------------------------
author: Douglas Trujillo
date: 2014-12-19 08:13:43.000000000

Patch Set 1:

(2 comments)

Line:250, org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java -> not sure if that's true during startup, isActive could be called before the listener got registered asynchronously.

Line:531, org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java -> Done

-------------------------------------
author: Jayvion Booth
date: 2014-12-19 08:30:30.000000000

Patch Set 1:

(3 comments)

The entire patch is actually not OK because it assumes that there is only one shell possible (and listens to this only shell) - but there can be multiple of them (multiple Eclipse windows), created and disposed etc.

To reliably answer the "isShellActive" question one has to be on SWT thread as the previous code did (surprise!) or one has to add listeners to *each* currently opened shell and another listener (or even filter) to the Display itself to get notified if shells are created or disposed.

Not sure if this is worth the effort, but the current patch isn't sufficient.

Line:250, org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java -> Or isActive is not set back to false yet...

Line:525, org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java -> we don't know if the display is active here, so we can't set isActive to true. The line is not needed.

Line:531, org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java -> the shell can be not active because the other (non-eclipse) window is active at the moment. This is absolutely legal.

-------------------------------------
