1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Return the shell from any available workbench window if none are active. Noticed Debug Platform does this.

This commit is contained in:
John Cortell 2009-10-13 22:58:22 +00:00
parent f20f970bc8
commit 05a796346b

View file

@ -223,13 +223,18 @@ public class CDebugUIPlugin extends AbstractUIPlugin {
} }
/** /**
* Returns the active workbench shell or <code>null</code> if none * Returns the active workbench shell, or the shell from the first available
* * workbench window, or <code>null</code> if neither is available.
* @return the active workbench shell or <code>null</code> if none
*/ */
public static Shell getActiveWorkbenchShell() { public static Shell getActiveWorkbenchShell() {
IWorkbenchWindow window = getActiveWorkbenchWindow(); IWorkbenchWindow window = getActiveWorkbenchWindow();
if ( window != null ) { if (window == null) {
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
if (windows.length > 0) {
return windows[0].getShell();
}
}
else {
return window.getShell(); return window.getShell();
} }
return null; return null;