@Override
  public void run(TableLoadOption... tableLoadOptions) {
    try {
      Set<Artifact> groupOptions = getEmailGroupsAndUserGroups(UserManager.getUser());
      UserGroupsCheckTreeDialog dialog = new UserGroupsCheckTreeDialog(groupOptions);
      dialog.setTitle("Select Groups to Email");
      if (dialog.open() == 0) {

        Set<String> emails = new HashSet<String>();
        for (Artifact artifact : dialog.getSelection()) {
          if (artifact.isOfType(CoreArtifactTypes.UniversalGroup)) {
            for (Artifact userArt :
                artifact.getRelatedArtifacts(CoreRelationTypes.Universal_Grouping__Members)) {
              if (userArt instanceof User) {
                if (!EmailUtil.isEmailValid((User) userArt)) {
                  OseeLog.logf(
                      Activator.class,
                      Level.SEVERE,
                      "Invalid email [%s] for user [%s]; skipping",
                      ((User) userArt).getEmail(),
                      userArt);
                } else if (((User) userArt).isActive()) {
                  emails.add(((User) userArt).getEmail());
                }
              }
            }
          } else if (artifact.isOfType(CoreArtifactTypes.UserGroup)) {
            for (User user :
                artifact.getRelatedArtifacts(CoreRelationTypes.Users_User, User.class)) {
              if (!EmailUtil.isEmailValid(user)) {
                OseeLog.logf(
                    Activator.class,
                    Level.SEVERE,
                    "Invalid email [%s] for user [%s]; skipping",
                    user.getEmail(),
                    user);
              } else if (user.isActive()) {
                emails.add(user.getEmail());
              }
            }
          }
        }
        if (emails.isEmpty()) {
          AWorkbench.popup("Error", "No emails configured.");
          return;
        }
        String emailStr =
            org.eclipse.osee.framework.jdk.core.util.Collections.toString(";", emails);
        if (emailStr.length() > 2048) {
          AWorkbench.popup(
              "Email list too big for auto-open. Emails opened in editor for copy/paste.");
          ResultsEditor.open("Email Addresses", "Email Addresses", emailStr);
        } else {
          Program.launch("mailto:" + emailStr);
        }
        AWorkbench.popup("Complete", "Configured emails openened in local email client.");
      }
    } catch (OseeCoreException ex) {
      OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
    }
  }
예제 #2
0
  @Override
  public void run() {
    if (selectedCoverageEditorItem.getSelectedCoverageEditorItems().isEmpty()) {
      AWorkbench.popup("Select Coverage Item");
      return;
    }
    if (selectedCoverageEditorItem.getSelectedCoverageEditorItems().size() > 0) {
      ICoverage item =
          selectedCoverageEditorItem.getSelectedCoverageEditorItems().iterator().next();
      String highlightLine = null;

      try {
        if (item instanceof CoverageItem) {
          if (Strings.isValid(item.getName())) {
            highlightLine = item.getName();
          }
          item = item.getParent();
        }
        // If order number then parent has full file contents
        // attempt to find line in file that matches
        if (Strings.isValid(item.getOrderNumber())) {
          if (item.getParent() != null) {
            String itemLineText = item.getName();
            String parentFileContents = item.getParent().getFileContents();
            if (!Strings.isValid(parentFileContents)) {
              AWorkbench.popup("No File Contents Available");
              return;
            }
            String html = parentFileContents;
            // mark text for method
            if (Strings.isValid(itemLineText)) {
              html = html.replaceAll(itemLineText, "HEREBEGIN" + itemLineText + "HEREEND");
            }
            // mark text for executable line
            if (Strings.isValid(highlightLine)) {
              html = html.replaceAll(highlightLine, "HEREBEGIN" + highlightLine + "HEREEND");
            }
            html = AHTML.textToHtml(html);
            html = html.replaceAll(" ", "&nbsp;");
            html = html.replaceAll("HEREBEGIN", "<FONT style=\"BACKGROUND-COLOR: yellow\">");
            html = html.replaceAll("HEREEND", "</FONT>");
            ResultsEditor.open(
                "source",
                CoverageUtil.getFullPathWithName(item.getParent(), true)
                    + "["
                    + item.getName()
                    + "]",
                html);
          } else {
            AWorkbench.popup("No File Contents Available");
            return;
          }
        }
        // If no order number, just open full text
        else {
          String text = item.getFileContents();
          if (!Strings.isValid(text)) {
            AWorkbench.popup("No File Contents Available");
            return;
          }
          String html = AHTML.textToHtml(text);
          html = html.replaceAll(" ", "&nbsp;");
          ResultsEditor.open("source", CoverageUtil.getFullPathWithName(item, true), html);
        }

      } catch (OseeCoreException ex) {
        OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
      }
    }
  }