public void testBlockComment() throws Throwable {

    // Test open page

    openPage();

    setEditor(bot.editorByTitle(TEST_PAGE).toTextEditor());
    setEditorText(getEditor().getText());
    // Test add block comment from Source menu
    SWTBotExt botExt = new SWTBotExt();
    final String commentValue = "<h:commandButton action=\"hello\" value=\"Say Hello!\" />";
    SWTJBTExt.selectTextInSourcePane(botExt, TEST_PAGE, commentValue, 0, commentValue.length(), 0);
    bot.sleep(Timing.time2S());
    bot.menu("Source").menu("Add Block Comment").click(); // $NON-NLS-1$//$NON-NLS-2$
    getEditor().save();
    waitForBlockingJobsAcomplished(VISUAL_UPDATE);
    SWTBotWebBrowser webBrowser = new SWTBotWebBrowser(TEST_PAGE, new SWTBotExt());
    assertVisualEditorContainsManyComments(webBrowser, 1, TEST_PAGE);

    assertTrue(
        "Visual Representation of page doesn't contain comment with value " + commentValue,
        webBrowser.containsCommentWithValue(commentValue));

    // Test remove block comment from Source menu
    SWTJBTExt.selectTextInSourcePane(botExt, TEST_PAGE, commentValue, 0, commentValue.length(), 0);
    getEditor().selectCurrentLine();
    bot.sleep(Timing.time2S());
    bot.menu("Source").menu("Remove Block Comment").click(); // $NON-NLS-1$//$NON-NLS-2$
    getEditor().save();
    waitForBlockingJobsAcomplished(VISUAL_UPDATE);
    assertVisualEditorContainsManyComments(webBrowser, 0, TEST_PAGE);

    // Test add block comment with CTRL+SHIFT+/ hot keys
    SWTJBTExt.selectTextInSourcePane(botExt, TEST_PAGE, commentValue, 0, commentValue.length(), 0);
    pressBlockCommentHotKeys();
    getEditor().save();
    waitForBlockingJobsAcomplished(VISUAL_UPDATE);
    assertVisualEditorContainsManyComments(webBrowser, 1, TEST_PAGE);
    assertTrue(
        "Visual Representation of page doesn't contain comment with value " + commentValue,
        webBrowser.containsCommentWithValue(commentValue));

    // Test remove block comment with CTRL+SHIFT+\ hot keys
    SWTJBTExt.selectTextInSourcePane(botExt, TEST_PAGE, commentValue, 0, commentValue.length(), 0);
    bot.sleep(Timing.time2S());
    getEditor().selectCurrentLine();
    pressUnBlockCommentHotKeys();
    getEditor().save();
    waitForBlockingJobsAcomplished(VISUAL_UPDATE);
    assertVisualEditorContainsManyComments(webBrowser, 0, TEST_PAGE);
  }
  /**
   * Checks Content Assist auto proposal. It's case when there is only one content assist item and
   * that item is automatically inserted into editor and checks if expectedProposalList is equal to
   * current Proposal List
   *
   * @param editorTitle
   * @param textToSelect
   * @param selectionOffset
   * @param selectionLength
   * @param textToSelectIndex
   * @param expectedInsertedText
   */
  public static SWTBotEditor checkContentAssistAutoProposal(
      SWTBotExt bot,
      String editorTitle,
      String textToSelect,
      int selectionOffset,
      int selectionLength,
      int textToSelectIndex,
      String expectedInsertedText) {

    SWTJBTExt.selectTextInSourcePane(
        bot, editorTitle, textToSelect, selectionOffset, selectionLength, textToSelectIndex);

    bot.sleep(Timing.time1S());

    SWTBotEditorExt editor = SWTTestExt.bot.swtBotEditorExtByTitle(editorTitle);
    String editorLineBeforeInsert = editor.getTextOnCurrentLine();
    int xPos = editor.cursorPosition().column;
    String expectedEditorLineAfterInsert =
        editorLineBeforeInsert.substring(0, xPos)
            + expectedInsertedText
            + editorLineBeforeInsert.substring(xPos);
    ContentAssistBot contentAssist = editor.contentAssist();
    contentAssist.invokeContentAssist();
    String editorLineAfterInsert = editor.getTextOnCurrentLine();
    assertTrue(
        "Text on current line should be:\n"
            + expectedEditorLineAfterInsert
            + "\nbut is:\n"
            + editorLineAfterInsert,
        editorLineAfterInsert.equals(expectedEditorLineAfterInsert));

    return editor;
  }
  /**
   * Checks Content Assist content on specified position within editor with editorTitle and checks
   * if expectedProposalList is equal to current Proposal List
   *
   * @param editorTitle
   * @param textToSelect
   * @param selectionOffset
   * @param selectionLength
   * @param textToSelectIndex
   * @param expectedProposalList
   * @param mustEquals
   */
  public static SWTBotEditor checkContentAssistContent(
      SWTBotExt bot,
      String editorTitle,
      String textToSelect,
      int selectionOffset,
      int selectionLength,
      int textToSelectIndex,
      List<String> expectedProposalList,
      boolean mustEquals) {

    SWTJBTExt.selectTextInSourcePane(
        bot, editorTitle, textToSelect, selectionOffset, selectionLength, textToSelectIndex);

    bot.sleep(Timing.time1S());

    SWTBotEditorExt editor = SWTTestExt.bot.swtBotEditorExtByTitle(editorTitle);
    ContentAssistBot contentAssist = editor.contentAssist();
    List<String> currentProposalList = contentAssist.getProposalList();
    assertTrue(
        "Code Assist menu has incorrect menu items.\n"
            + "Expected Proposal Menu Labels vs. Current Proposal Menu Labels :\n"
            + FormatUtils.getListsDiffFormatted(expectedProposalList, currentProposalList),
        mustEquals
            ? expectedProposalList.equals(currentProposalList)
            : currentProposalList.containsAll(expectedProposalList));

    return editor;
  }
 /**
  * Selects textToSelect within Source Pane of editor with title editorTitle
  *
  * @param bot
  * @param editorTitle
  * @param textToSelect
  * @param selectionOffset
  * @param selectionLength
  * @return SWTBotEclipseEditor
  */
 public static SWTBotEclipseEditor selectTextInSourcePane(
     SWTBotExt bot,
     String editorTitle,
     String textToSelect,
     int selectionOffset,
     int selectionLength) {
   return SWTJBTExt.selectTextInSourcePane(
       bot, editorTitle, textToSelect, selectionOffset, selectionLength, 0);
 }
 /**
  * Creates new Server within Server View when Wizard for new Project is called
  *
  * @param bot
  * @param serverGroup
  * @param serverType
  */
 public static void addServerToServerViewOnWizardPage(
     SWTWorkbenchBot bot, String serverGroup, String serverType) {
   // Check if there is defined Application Server if not create one
   if (!SWTJBTExt.isServerDefinedInWebWizardPage(bot)) {
     // Specify Application Server for Deployment
     bot.button(IDELabel.Button.NEW, 1).click();
     bot.shell(IDELabel.Shell.NEW_SERVER).activate();
     bot.tree().select(serverGroup);
     bot.tree().expandNode(serverGroup).select(serverType);
     bot.button(IDELabel.Button.FINISH).click();
   }
 }
  /**
   * Selects specified text in specified opened editor and shows open on options via selecting
   * Navigate -> Open Hyperlink
   *
   * @param bot
   * @param editorTitle
   * @param textToSelect
   * @param selectionOffset
   * @param selectionLength
   * @param textToSelectIndex
   */
  public static void showOpenOnOptions(
      SWTBotExt bot,
      String editorTitle,
      String textToSelect,
      int selectionOffset,
      int selectionLength,
      int textToSelectIndex) {

    SWTJBTExt.selectTextInSourcePane(
        bot, editorTitle, textToSelect, selectionOffset, selectionLength, textToSelectIndex);
    bot.editorByTitle(editorTitle).show();
    bot.editorByTitle(editorTitle).setFocus();
    bot.menu(IDELabel.Menu.NAVIGATE).menu(IDELabel.Menu.OPEN_HYPERLINK).click();

    bot.waitUntil(new ActiveShellContainsWidget(bot, Table.class));
  }
  /**
   * Applies Content Assist auto proposal. It's case when there is only one content assist item and
   * that item is automatically inserted into editor
   *
   * @param editorTitle
   * @param textToSelect
   * @param selectionOffset
   * @param selectionLength
   * @param textToSelectIndex
   */
  public static SWTBotEditor applyContentAssistAutoProposal(
      SWTBotExt bot,
      String editorTitle,
      String textToSelect,
      int selectionOffset,
      int selectionLength,
      int textToSelectIndex) {

    SWTJBTExt.selectTextInSourcePane(
        bot, editorTitle, textToSelect, selectionOffset, selectionLength, textToSelectIndex);

    bot.sleep(Timing.time1S());

    SWTBotEditorExt editor = SWTTestExt.bot.swtBotEditorExtByTitle(editorTitle);
    ContentAssistBot contentAssist = editor.contentAssist();
    contentAssist.invokeContentAssist();

    return editor;
  }
  /**
   * Applies Open On (F3) on textToSelect within editor with editorTitle and checks if
   * expectedOpenedFileName was opened
   *
   * @param editorTitle
   * @param textToSelect
   * @param selectionOffset
   * @param selectionLength
   * @param textToSelectIndex
   * @param expectedOpenedFileName
   */
  public static SWTBotEditor checkOpenOnFileIsOpened(
      SWTBotExt bot,
      String editorTitle,
      String textToSelect,
      int selectionOffset,
      int selectionLength,
      int textToSelectIndex,
      String expectedOpenedFileName) {

    SWTBotEclipseEditor sourceEditor =
        SWTJBTExt.selectTextInSourcePane(
            bot, editorTitle, textToSelect, selectionOffset, selectionLength, textToSelectIndex);

    bot.sleep(Timing.time3S());

    sourceEditor.setFocus();
    // process UI Events
    UIThreadRunnable.syncExec(
        new VoidResult() {
          @Override
          public void run() {}
        });
    bot.sleep(Timing.time3S());
    new SWTUtilExt(bot).waitForNonIgnoredJobs();

    KeyboardHelper.typeKeyCodeUsingAWT(KeyEvent.VK_F3);
    // process UI Events
    UIThreadRunnable.syncExec(
        new VoidResult() {
          @Override
          public void run() {}
        });
    bot.sleep(Timing.time3S());
    new SWTUtilExt(bot).waitForNonIgnoredJobs();

    return checkActiveEditorTitle(bot, expectedOpenedFileName);
  }
 private void pressBlockCommentHotKeys() {
   if (SWTJBTExt.isRunningOnMacOs()) {
     bot.shells()[0].pressShortcut(SWT.COMMAND, '/');
   } else {
     bot.getDisplay()
         .syncExec(
             new Runnable() {
               public void run() {
                 Display display = bot.getDisplay();
                 Event event = new Event();
                 event.type = SWT.KeyDown;
                 event.keyCode = SWT.CTRL;
                 display.post(event);
                 event = new Event();
                 event.type = SWT.KeyDown;
                 event.keyCode = SWT.SHIFT;
                 display.post(event);
                 event = new Event();
                 event.type = SWT.KeyDown;
                 event.character = '/';
                 display.post(event);
                 event = new Event();
                 event.type = SWT.KeyUp;
                 event.character = '/';
                 display.post(event);
                 event = new Event();
                 event.type = SWT.KeyUp;
                 event.keyCode = SWT.SHIFT;
                 display.post(event);
                 event = new Event();
                 event.type = SWT.KeyUp;
                 event.keyCode = SWT.CTRL;
                 display.post(event);
               }
             });
   }
 }
 /**
  * Returns true if runtimeName Server Runtime is defined
  *
  * @param runtimeName
  * @return
  */
 public boolean isServerRuntimeDefined(String runtimeName) {
   return SWTJBTExt.isServerRuntimeDefined(bot, runtimeName);
 }
 /**
  * Stops Application Server in Server View on position specified by index with default UI TimeOut
  * Dynamic version of stopApplicationServer
  *
  * @param index - zero based Position of Server within Server Tree
  */
 public void stopApplicationServer(int index) {
   SWTJBTExt.stopApplicationServer(bot, index, SWTJBTExt.DEFAULT_UI_TIMEOUT);
 }
 /**
  * Stops Application Server in Server View on position specified by index Dynamic version of
  * stopApplicationServer
  *
  * @param index - zero based Position of Server within Server Tree
  * @param uiTimeOut
  */
 public void stopApplicationServer(int index, long uiTimeOut) {
   SWTJBTExt.stopApplicationServer(bot, index);
 }
 /**
  * Stops Application Server in Server View on position specified by index
  *
  * @param bot
  * @param index - zero based Position of Server within Server Tree
  * @param iuTimeOut
  */
 public static void stopApplicationServer(SWTWorkbenchBot bot, int index, long uiTimeOut) {
   SWTJBTExt.chooseServerPopupMenu(bot, index, IDELabel.Menu.STOP, 20 * 1000L, uiTimeOut);
 }
 /**
  * Deletes Application Server in Server View on position specified by index Dynamic version of
  * deleteApplicationServer
  *
  * @param index - zero based Position of Server within Server Tree
  */
 public void deleteApplicationServer(int index) {
   SWTJBTExt.deleteApplicationServer(bot, index);
 }
  /**
   * Returns string representing version of defined Server Runtime on index position in Defined
   * Server Runtime table
   *
   * @param rowIndex
   * @return null when no server runtime is specified, "unknown when not possible to determine
   *     server runtime version" or server runtime version
   */
  public String getDefinedServerRuntimeVersion(int index) {

    return SWTJBTExt.getDefinedServerRuntimeVersion(bot, index);
  }
 /**
  * Starts Application Server in Server View on position specified by index
  *
  * @param bot
  * @param index - zero based Position of Server within Server Tree
  * @param uiTimeOut
  */
 public static void startApplicationServer(SWTWorkbenchBot bot, int index, long uiTimeOut) {
   SWTJBTExt.chooseServerPopupMenu(bot, index, IDELabel.Menu.START, 120 * 1000L, uiTimeOut);
   bot.sleep(10 * 1000L);
 }
 /**
  * Deletes Application Server in Server View on position specified by index
  *
  * @param bot
  * @param index - zero based Position of Server within Server Tree
  */
 public static void deleteApplicationServer(SWTWorkbenchBot bot, int index) {
   SWTJBTExt.chooseServerPopupMenu(bot, index, IDELabel.Menu.DELETE, 10 * 1000L);
   bot.shell(IDELabel.Shell.DELETE_SERVER).activate();
   bot.button(IDELabel.Button.OK).click();
 }
  /**
   * Returns true if any Server Runtime is defined
   *
   * @param bot
   * @return
   */
  public boolean isServerRuntimeDefined() {

    return SWTJBTExt.isServerRuntimeDefined(bot);
  }
 /**
  * Return true when in Web Page of Wizard is defined at least one Server Runtime Instance Dynamic
  * version of isServerDefinedInWebWizardPage
  *
  * @return
  */
 public boolean isServerDefinedInWebWizardPage() {
   return SWTJBTExt.isServerDefinedInWebWizardPage(bot);
 }