+ return mainShell;
+ }
+
+ /**
+ * Close all non-main shells that are visible.
+ *
+ * @param bot
+ * the workbench bot
+ */
+ public static void closeSecondaryShells(SWTWorkbenchBot bot) {
+ SWTBotShell[] shells = bot.shells();
+ SWTBotShell mainShell = getMainShell(shells);
+ if (mainShell == null) {
+ return;
+ }
+
+ // Close all non-main shell but make sure we don't close an invisible
+ // shell such the special "limbo shell" that Eclipse needs to work
+ Arrays.stream(shells)
+ .filter(shell -> shell != mainShell)
+ .filter(SWTBotShell::isVisible)
+ .peek(shell -> log.debug(MessageFormat.format("Closing ligering shell with title {0}", shell.getText())))
+ .forEach(SWTBotShell::close);