/**
   * Closes Report Usage Windows and enable Atlassian Connector Usage Reporting Window. Did not find
   * other way how to disable Atlassian Connector Usage Reporting Window displaying
   *
   * @param reportJbtUsage
   * @param reportSubclipseUsage
   */
  public static void manageBlockingWidows(boolean reportJbtUsage, boolean reportSubclipseUsage) {
    // Manage JBT/JBDS and Subclipse Usage Reporting
    SWTWorkbenchBot bot = new SWTWorkbenchBot();
    SWTBotShell shJbtUsage = null;
    SWTBotShell shSubclipseUsage = null;
    bot.sleep(Timing.time5S());
    new SWTUtilExt(bot).waitForNonIgnoredJobs();
    SWTBotShell[] shells = bot.shells();
    int index = 0;
    while ((shJbtUsage == null || shSubclipseUsage == null) && index < shells.length) {
      if (shells[index].getText().equals(IDELabel.Shell.JBOSS_DEVELOPER_STUDIO_USAGE)
          || shells[index].getText().equals(IDELabel.Shell.JBOSS_TOOLS_USAGE)) {
        shJbtUsage = shells[index];
      } else if (shells[index].getText().equals(IDELabel.Shell.SUBCLIPSE_USAGE)) {
        shSubclipseUsage = shells[index];
      }
      index++;
    }
    if (shJbtUsage != null && shJbtUsage.isActive()) {
      closeJBossToolsUsageWindow(shJbtUsage, reportJbtUsage);
      if (shSubclipseUsage != null) {
        closeSubclipseUsageWindow(shSubclipseUsage, reportSubclipseUsage);
      }
    } else if (shSubclipseUsage != null && shSubclipseUsage.isActive()) {
      closeSubclipseUsageWindow(shSubclipseUsage, reportSubclipseUsage);
      if (shJbtUsage != null) {
        closeJBossToolsUsageWindow(shJbtUsage, reportJbtUsage);
      }
    }
    // Manage Atlassian Connector Usage Reporting
    try {
      SWTBot prefBot =
          new SWTOpenExt(new SWTBotExt())
              .preferenceOpen(ActionItem.Preference.AtlassianConnectorUsageData.LABEL);
      SWTBotCheckBox chbEnableMonitoring = prefBot.checkBox();
      if (!chbEnableMonitoring.isChecked()) {
        chbEnableMonitoring.click();
      }
      prefBot.button(IDELabel.Button.OK).click();
    } catch (WidgetNotFoundException wnfe) {
      // do nothing there is no Atlassian Connector installed
    }

    // Get rid of welcome screen. Simple close did not work when run in maven
    log.debug("Trying to close Welcome Screen");
    for (IViewReference viewReference : WorkbenchPartLookup.getInstance().findAllViewReferences()) {
      if (viewReference.getPartName().equals("Welcome")) {
        final IViewReference iViewReference = viewReference;
        Display.syncExec(
            new Runnable() {
              @Override
              public void run() {
                iViewReference.getPage().hideView(iViewReference);
              }
            });
        log.debug("Welcome Screen closed");
        break;
      }
      // ok, Welcome screen not present
      log.info("Welcome window not present");
    }
  }