示例#1
0
  private void displayTasks() {
    if (this.criteria == null) {
      final TaskSearchCriteria criteria = new TaskSearchCriteria();
      criteria.setProjectid(new NumberSearchField(CurrentProjectVariables.getProjectId()));
      criteria.setTaskListId(new NumberSearchField(this.taskList.getId()));
      criteria.setStatuses(
          new SetSearchField<String>(SearchField.AND, new String[] {"Open", "Pending"}));
      this.criteria = criteria;
    }

    this.taskDisplay.setSearchCriteria(this.criteria);

    // Update tasklist progress and number of open task/all task
    if (this.taskNumberLbl != null) {
      this.taskNumberLbl.setValue(
          "("
              + (this.taskList.getNumOpenTasks() + 1)
              + "/"
              + (this.taskList.getNumAllTasks() + 1)
              + ")");
    }

    final int newAllTasks = this.taskList.getNumAllTasks() + 1;
    final double newProgressTask =
        (this.taskList.getPercentageComplete() * this.taskList.getNumAllTasks()) / newAllTasks;
    if (this.taskListProgress != null) {
      this.taskListProgress.setValue(newProgressTask + "");
    }
  }
  private void queryAndDisplayTasks() {
    wrapBody.removeAllComponents();

    if (GROUP_DUE_DATE.equals(groupByState)) {
      baseCriteria.setOrderFields(
          Arrays.asList(new SearchCriteria.OrderField("deadline", sortDirection)));
      taskGroupOrderComponent = new DueDateOrderComponent();
    } else if (GROUP_START_DATE.equals(groupByState)) {
      baseCriteria.setOrderFields(
          Arrays.asList(new SearchCriteria.OrderField("startdate", sortDirection)));
      taskGroupOrderComponent = new StartDateOrderComponent();
    } else if (PLAIN_LIST.equals(groupByState)) {
      baseCriteria.setOrderFields(
          Arrays.asList(new SearchCriteria.OrderField("lastupdatedtime", sortDirection)));
      taskGroupOrderComponent = new SimpleListOrderComponent();
    } else {
      throw new MyCollabException("Do not support group view by " + groupByState);
    }
    wrapBody.addComponent(taskGroupOrderComponent);
    final ProjectTaskService projectTaskService =
        ApplicationContextUtil.getSpringBean(ProjectTaskService.class);
    int totalTasks = projectTaskService.getTotalCount(baseCriteria);
    taskSearchPanel.setTotalCountNumber(totalTasks);
    currentPage = 0;
    int pages = totalTasks / 20;
    if (currentPage < pages) {
      Button moreBtn =
          new Button(
              "More",
              new Button.ClickListener() {
                @Override
                public void buttonClick(ClickEvent clickEvent) {
                  int totalTasks = projectTaskService.getTotalCount(baseCriteria);
                  int pages = totalTasks / 20;
                  currentPage++;
                  List<SimpleTask> otherTasks =
                      projectTaskService.findPagableListByCriteria(
                          new SearchRequest<>(baseCriteria, currentPage + 1, 20));
                  taskGroupOrderComponent.insertTasks(otherTasks);
                  if (currentPage == pages) {
                    wrapBody.removeComponent(wrapBody.getComponent(1));
                  }
                }
              });
      moreBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
      wrapBody.addComponent(moreBtn);
    }
    List<SimpleTask> tasks =
        projectTaskService.findPagableListByCriteria(
            new SearchRequest<>(baseCriteria, currentPage + 1, 20));
    taskGroupOrderComponent.insertTasks(tasks);
  }
  @Override
  protected void displayView() {
    constructUI();
    baseCriteria = new TaskSearchCriteria();
    baseCriteria.setProjectid(new NumberSearchField(CurrentProjectVariables.getProjectId()));
    OptionValService optionValService =
        ApplicationContextUtil.getSpringBean(OptionValService.class);
    List<OptionVal> options =
        optionValService.findOptionValsExcludeClosed(
            ProjectTypeConstants.TASK,
            CurrentProjectVariables.getProjectId(),
            AppContext.getAccountId());

    SetSearchField<String> statuses = new SetSearchField<>();
    for (OptionVal option : options) {
      statuses.addValue(option.getTypeval());
    }
    baseCriteria.setStatuses(statuses);
    statisticSearchCriteria = BeanUtility.deepClone(baseCriteria);
    queryAndDisplayTasks();
    displayTaskStatistic();
  }