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); }
private Layout createBottomPanel() { final HorizontalLayout controlPanel = new HorizontalLayout(); controlPanel.setMargin(true); controlPanel.setStyleName("more-info"); controlPanel.setHeight("40px"); controlPanel.setWidth("100%"); Button moreInfoBtn = new Button( "More information...", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { editUserForm.displayAdvancedForm(user); } }); moreInfoBtn.addStyleName(UIConstants.THEME_LINK); controlPanel.addComponent(moreInfoBtn); controlPanel.setComponentAlignment(moreInfoBtn, Alignment.MIDDLE_LEFT); return controlPanel; }