public void refreshGroupTasks(Date date, TaskView taskView) {
    Date fromDate = determineFirstDateForTaskViewBasedOnSpecifiedDate(date, taskView);
    int daysTotal = taskView.getNrOfDaysToShow();

    List<String> statuses = new ArrayList<String>(4);
    statuses.add("Ready");

    if (taskView.equals(TaskView.GRID)) {
      taskServices
          .call(
              new RemoteCallback<List<TaskSummary>>() {
                @Override
                public void callback(List<TaskSummary> tasks) {
                  allTaskSummaries = tasks;
                  filterTasks(view.getSearchBox().getText());
                  view.getSelectionModel().clear();
                }
              })
          .getTasksAssignedAsPotentialOwnerByExpirationDateOptional(
              identity.getName(), statuses, null, "en-UK");
    } else {
      taskServices
          .call(
              new RemoteCallback<Map<Day, List<TaskSummary>>>() {
                @Override
                public void callback(Map<Day, List<TaskSummary>> tasks) {
                  currentDayTasks = tasks;
                  filterTasks(view.getSearchBox().getText());
                }
              })
          .getTasksAssignedAsPotentialOwnerFromDateToDateByDays(
              identity.getName(), statuses, fromDate, daysTotal, "en-UK");
    }
  }
Пример #2
0
  /**
   * Show a project
   *
   * @param function the action being taken
   * @param p the project
   * @param parentId the parent project id
   * @throws Exception
   */
  private void showProject(Action function, Project p, Integer parentId) throws Exception {

    // set the link panel to show this project's links
    linkPanel.setOwner(p);

    // show all possible parent projects
    parentProjectComboBox.removeAllItems();
    parentProjectComboBox.addItem("");
    Collection<Project> projects = TaskModel.getReference().getProjects();
    if (projects != null) {
      for (Project project : projects) {
        // add open projects that are not the current one
        if ((p == null || p.getKey() != project.getKey())
            && project.getStatus().equals(Resource.getResourceString("OPEN")))
          parentProjectComboBox.addItem(getProjectString(project));
      }
    }

    // if we are showing an existing project - fill in the gui fields for it
    if (p != null) {
      // task number
      projectIdText.setText(Integer.toString(p.getKey()));
      projectIdText.setEditable(false);

      // window title - "Item N"
      windowTitle = Resource.getResourceString("Item_") + " " + p.getKey();

      // due date
      GregorianCalendar gc = new GregorianCalendar();
      Date dd = p.getDueDate();
      if (dd != null) {
        gc.setTime(dd);
        dueDateChooser.setCalendar(gc);
      }

      GregorianCalendar gc2 = new GregorianCalendar();
      dd = p.getStartDate();
      if (dd != null) gc2.setTime(dd);
      startDateChooser.setCalendar(gc2);

      int daysleft = DateUtil.daysLeft(p.getDueDate());
      daysLeftText.setText(Integer.toString(daysleft));

      String cat = p.getCategory();
      if (cat != null && !cat.equals("")) {
        categoryBox.setSelectedItem(cat);
      } else {
        categoryBox.setSelectedIndex(0);
      }

      description.setText(p.getDescription());

      statusComboBox.setEditable(false);

      Collection<Task> ptasks = TaskModel.getReference().getTasks(p.getKey());
      totalTaskCount.setText(Integer.toString(ptasks.size()));

      int openTasks = 0;
      for (Task pt : ptasks) {
        if (!TaskModel.isClosed(pt)) {
          openTasks++;
        }
      }
      openTaskCount.setText(Integer.toString(openTasks));

      // set parent project
      Integer pid = p.getParent();
      if (pid != null) {
        Project par = TaskModel.getReference().getProject(pid.intValue());
        if (TaskModel.isClosed(par)) {
          // if parent closed - would not have been added before
          parentProjectComboBox.addItem(getProjectString(par));
        }
        parentProjectComboBox.setSelectedItem(getProjectString(par));
      }

      // add the task list
      if (taskPanel == null) {
        taskPanel = new TaskListPanel(TaskView.getProjectString(p));
        taskPanel.addClosedTaskFilter();
        taskBorder.add(
            taskPanel, GridBagConstraintsFactory.create(0, 0, GridBagConstraints.BOTH, 1.0, 1.0));
      }

    } else {
      // set fields for a new project

      projectIdText.setText("NEW");
      projectIdText.setEditable(false);

      // title
      windowTitle = Resource.getResourceString("NEW_Item");
      statusComboBox.addItem(Resource.getResourceString("OPEN"));
      statusComboBox.setEnabled(false);
      categoryBox.setSelectedIndex(0);
      description.setText(""); // desc
      totalTaskCount.setText("");
      openTaskCount.setText("");

      // parent id may have been passed in
      if (parentId != null) {
        Project par = TaskModel.getReference().getProject(parentId.intValue());
        if (TaskModel.isClosed(par)) {
          parentProjectComboBox.addItem(getProjectString(par));
        }
        parentProjectComboBox.setSelectedItem(getProjectString(par));

        String cat = par.getCategory();
        if (cat != null && !cat.equals("")) {
          categoryBox.setSelectedItem(cat);
        } else {
          categoryBox.setSelectedIndex(0);
        }

        GregorianCalendar gc = new GregorianCalendar();
        Date dd = par.getDueDate();
        if (dd != null) {
          gc.setTime(dd);
          dueDateChooser.setCalendar(gc);
        }

        Date sd = par.getStartDate();
        if (sd != null) {
          gc.setTime(sd);
          startDateChooser.setCalendar(gc);
        }
      }
    }

    // can't change status on a new project
    if (p == null) {
      statusComboBox.setEnabled(false);
    }

    // cloning takes the fields filled in for an existing task and resets
    // only those
    // that don't apply to the clone
    if (function == Action.CLONE) {
      // need new task number
      projectIdText.setText("CLONE");
      projectIdText.setEditable(false);

      statusComboBox.removeAllItems();
      statusComboBox.addItem(Resource.getResourceString("OPEN"));
      statusComboBox.setEnabled(false);

    }
    // change existing task
    else if (function == Action.CHANGE) {

      String state = null;
      if (p != null) state = p.getStatus();

      // set next state pulldown - projects only move between open and
      // closed
      statusComboBox.removeAllItems();
      statusComboBox.addItem(Resource.getResourceString("OPEN"));
      statusComboBox.addItem(Resource.getResourceString("CLOSED"));
      statusComboBox.setSelectedItem(state);
      statusComboBox.setEnabled(true);
    }
  }