From 05a796346b0c040d82eb3434d64981383e27fd59 Mon Sep 17 00:00:00 2001 From: John Cortell Date: Tue, 13 Oct 2009 22:58:22 +0000 Subject: [PATCH] Return the shell from any available workbench window if none are active. Noticed Debug Platform does this. --- .../org/eclipse/cdt/debug/ui/CDebugUIPlugin.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java index 4120546b747..368e9fdc79e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/CDebugUIPlugin.java @@ -223,13 +223,18 @@ public class CDebugUIPlugin extends AbstractUIPlugin { } /** - * Returns the active workbench shell or null if none - * - * @return the active workbench shell or null if none + * Returns the active workbench shell, or the shell from the first available + * workbench window, or null if neither is available. */ public static Shell getActiveWorkbenchShell() { 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 null;