public SMAEstimatedHoursHeader(
      Composite parent, int style, final AbstractWorkflowArtifact sma, final SMAEditor editor) {
    super(parent, style);
    this.awa = sma;
    setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
    setLayout(ALayout.getZeroMarginLayout(2, false));
    editor.getToolkit().adapt(this);

    try {
      if (!sma.isCancelled() && !sma.isCompleted()) {
        Hyperlink link = editor.getToolkit().createHyperlink(this, LABEL, SWT.NONE);
        link.addHyperlinkListener(
            new IHyperlinkListener() {

              @Override
              public void linkEntered(HyperlinkEvent e) {
                // do nothing
              }

              @Override
              public void linkExited(HyperlinkEvent e) {
                // do nothing
              }

              @Override
              public void linkActivated(HyperlinkEvent e) {
                try {
                  if (editor.isDirty()) {
                    editor.doSave(null);
                  }
                  PromptChangeUtil.promptChangeAttribute(
                      sma, AtsAttributeTypes.EstimatedHours, true, false);
                } catch (Exception ex) {
                  OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
                }
              }
            });
      } else {
        Label origLabel = editor.getToolkit().createLabel(this, LABEL);
        origLabel.setLayoutData(new GridData());
      }

      valueLabel = editor.getToolkit().createLabel(this, "0.0");
      valueLabel.setToolTipText(getToolTip());
      valueLabel.setLayoutData(new GridData());
      updateLabel(sma);

    } catch (OseeCoreException ex) {
      Label errorLabel =
          editor.getToolkit().createLabel(this, "Error: " + ex.getLocalizedMessage());
      errorLabel.setForeground(Displays.getSystemColor(SWT.COLOR_RED));
      OseeLog.log(Activator.class, Level.SEVERE, ex);
    }
  }
Exemplo n.º 2
0
  public static boolean promptChangeAssignees(
      final Collection<? extends AbstractWorkflowArtifact> awas, boolean persist)
      throws OseeCoreException {
    for (AbstractWorkflowArtifact awa : awas) {
      if (awa.isCompleted()) {
        AWorkbench.popup(
            "ERROR",
            "Can't assign completed " + awa.getArtifactTypeName() + " (" + awa.getAtsId() + ")");
        return false;
      } else if (awa.isCancelled()) {
        AWorkbench.popup(
            "ERROR",
            "Can't assign cancelled " + awa.getArtifactTypeName() + " (" + awa.getAtsId() + ")");
        return false;
      }
    }
    UserCheckTreeDialog uld =
        new UserCheckTreeDialog(
            "Select Assigness",
            "Select to assign.\nDeSelect to un-assign.",
            AtsClientService.get()
                .getUserServiceClient()
                .getOseeUsers(AtsClientService.get().getUserService().getUsers(Active.Active)));
    if (awas.iterator().next().getParentTeamWorkflow() != null) {
      uld.setTeamMembers(
          AtsClientService.get()
              .getUserServiceClient()
              .getOseeUsers(
                  awas.iterator()
                      .next()
                      .getParentTeamWorkflow()
                      .getTeamDefinition()
                      .getMembersAndLeads()));
    }

    if (awas.size() == 1) {
      uld.setInitialSelections(
          AtsClientService.get()
              .getUserServiceClient()
              .getOseeUsers(awas.iterator().next().getStateMgr().getAssignees()));
    }
    if (uld.open() != 0) {
      return false;
    }
    Collection<IAtsUser> users =
        AtsClientService.get().getUserServiceClient().getAtsUsers(uld.getUsersSelected());
    if (users.isEmpty()) {
      AWorkbench.popup("ERROR", "Must have at least one assignee");
      return false;
    }
    // As a convenience, remove the UnAssigned user if another user is selected
    if (users.size() > 1) {
      users.remove(AtsCoreUsers.SYSTEM_USER);
    }
    for (AbstractWorkflowArtifact awa : awas) {
      awa.getStateMgr().setAssignees(users);
    }
    if (persist) {
      AtsChangeSet.execute("Assignee - Prompt Change", awas);
    }
    return true;
  }