コード例 #1
0
  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);
  }
コード例 #2
0
    void displayPageInfo(Page beanItem) {
      MVerticalLayout header = new MVerticalLayout().withMargin(false);
      Label titleLbl = new Label(beanItem.getSubject());
      titleLbl.setStyleName("headerName");
      header.with(titleLbl);
      Div footer = new Div().setStyle("width:100%").setCSSClass("footer2");
      Span lastUpdatedTimeTxt =
          new Span()
              .appendText(
                  AppContext.getMessage(
                      DayI18nEnum.LAST_UPDATED_ON,
                      AppContext.formatPrettyTime(beanItem.getLastUpdatedTime().getTime())))
              .setTitle(AppContext.formatDateTime(beanItem.getLastUpdatedTime().getTime()));
      String uid = UUID.randomUUID().toString();
      ProjectMemberService projectMemberService =
          ApplicationContextUtil.getSpringBean(ProjectMemberService.class);
      SimpleProjectMember member =
          projectMemberService.findMemberByUsername(
              beanItem.getCreatedUser(),
              CurrentProjectVariables.getProjectId(),
              AppContext.getAccountId());
      if (member != null) {
        Img userAvatar =
            new Img("", StorageFactory.getInstance().getAvatarPath(member.getMemberAvatarId(), 16));
        A userLink =
            new A()
                .setId("tag" + uid)
                .setHref(
                    ProjectLinkBuilder.generateProjectMemberFullLink(
                        member.getProjectid(), member.getUsername()))
                .appendText(StringUtils.trim(member.getMemberFullName(), 30, true));
        userLink.setAttribute(
            "onmouseover", TooltipHelper.userHoverJsFunction(uid, member.getUsername()));
        userLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction(uid));
        footer.appendChild(
            lastUpdatedTimeTxt,
            new Text("&nbsp;-&nbsp;Created by: "),
            userAvatar,
            DivLessFormatter.EMPTY_SPACE(),
            userLink,
            DivLessFormatter.EMPTY_SPACE(),
            TooltipHelper.buildDivTooltipEnable(uid));
      } else {
        footer.appendChild(lastUpdatedTimeTxt);
      }

      header.addComponent(new Label(footer.write(), ContentMode.HTML));
      this.addHeader(header);
    }
コード例 #3
0
 @Override
 public void attachField(java.lang.Object propertyId, Field<?> field) {
   if (propertyId.equals("content")) {
     layout.addComponent(field);
   }
 }