Java Code Examples for org.eclipse.swtbot.swt.finder.widgets.SWTBotShell#close()

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotShell#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SwtBotMenuActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
public static void openPerspective(SWTWorkbenchBot bot, String perspectiveLabel) {
  SwtBotUtils.print("Opening Perspective: " + perspectiveLabel);

  SWTBotShell shell = null;
  try {
    menu(bot, "Window").menu("Open Perspective").menu("Other...").click();

    shell = bot.shell("Open Perspective");

    bot.waitUntil(ActiveWidgetCondition.widgetMakeActive(shell));
    shell.bot().table().select(perspectiveLabel);

    shell.bot().button("OK").click();
    bot.waitUntil(Conditions.shellCloses(shell));
  } catch (Exception e) {
    if (shell != null && shell.isOpen()) shell.close();
    SwtBotUtils.printError("Couldn't open perspective '" + perspectiveLabel + "'\n"
        + "trying to activate already open perspective instead");
    // maybe somehow the perspective is already opened (by another test before us)
    SWTBotPerspective perspective = bot.perspectiveByLabel(perspectiveLabel);
    perspective.activate();
  }

  SwtBotUtils.print("Opened Perspective: " + perspectiveLabel);
}
 
Example 2
Source File: SwtWorkbenchBot.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Closes the shell with the given title if it exists. This call does not wait for the shell to appear.
 *
 * @param title
 *          the title of the shell to close
 * @return {@code true} if the shell existed and was open, {@code false} otherwise
 */
public boolean closeShell(final String title) {
  SWTBotShell shell = getShell(title);
  if (shell != null && shell.isOpen()) {
    shell.close();
    return true;
  }
  return false;
}
 
Example 3
Source File: FixedDefaultWorkbench.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Close all shells matching given name predicate.
 *
 * @param predicate
 *          condition on name of shells
 * @return the fixed default workbench
 */
FixedDefaultWorkbench closeShellsMatchingName(final Predicate<String> predicate) {
  SWTBotShell[] shells = bot.shells();
  for (SWTBotShell shell : shells) {
    if (!isEclipseShell(shell) && !isLimboShell(shell) && !isQuickAccess(shell) && predicate.test(shell.getText())) {
      shell.close();
    }
  }
  return this;
}
 
Example 4
Source File: SwtWizardBot.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Close the wizard.
 */
public void closeWizard() {
  SWTBotShell activeShell = activeShell();
  boolean wizardIsActive = isWizard(activeShell);
  assertTrue("Wizard is active on close", wizardIsActive);
  activeShell.close();
}
 
Example 5
Source File: SWTBotTestUtil.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static List<String> listExpressionProposal(final SWTBot bot, final int index) {
    bot.toolbarButtonWithId(SWTBOT_ID_EXPRESSIONVIEWER_DROPDOWN, index).click();
    final SWTBotShell proposalShell = bot.shellWithId(SWTBOT_ID_EXPRESSIONVIEWER_PROPOSAL_SHELL);
    final SWTBot proposalBot = proposalShell.bot();
    final SWTBotTable proposalTAble = proposalBot.tableWithId(SWTBOT_ID_EXPRESSIONVIEWER_PROPOSAL_TABLE);

    final List<String> result = new ArrayList<>();
    for (int i = 0; i < proposalTAble.rowCount(); i++) {
        result.add(proposalTAble.getTableItem(i).getText());
    }
    proposalShell.close();
    return result;
}
 
Example 6
Source File: SWTGefBotRule.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void closeAllShells(SWTWorkbenchBot bot, Exception e) {
    final SWTBotShell[] shells = bot.shells();
    for (final SWTBotShell shell : shells) {
        if (shell.isOpen() && !isEclipseShell(shell)) {
            System.out.println(String.format("Trying to close shell '%s' after test failure %s", shell.getText(), e));
            try {
                shell.close();
            } catch (TimeoutException e1) {
                System.out.println(String.format("Failed to close shell %s: %s", shell.getText(), e1));
            }
        }
    }
}