public void createBasicLayout() { this.messagePanelBody.removeAllComponents(); this.messagePanelBody.addComponent(this.messageSearchPanel); final Button createMessageBtn = new Button( LocalizationHelper.getMessage(MessageI18nEnum.NEW_MESSAGE_ACTION), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { TopMessagePanel.this.createAddMessageLayout(); } }); createMessageBtn.setEnabled( CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MESSAGES)); createMessageBtn.setStyleName(UIConstants.THEME_BLUE_LINK); createMessageBtn.setIcon(MyCollabResource.newResource("icons/16/addRecord.png")); createMessageBtn.setEnabled( CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MESSAGES)); this.messagePanelBody.addComponent(createMessageBtn); this.messagePanelBody.setComponentAlignment(createMessageBtn, Alignment.MIDDLE_RIGHT); }
@Override protected void onGo(ComponentContainer container, ScreenData<?> data) { if (CurrentProjectVariables.canRead(ProjectRolePermissionCollections.MILESTONES)) { super.onGo(container, data); view.displayStatus(OptionI18nEnum.MilestoneStatus.InProgress); AppContext.addFragment( "project/milestone/list/" + GenericLinkUtils.encodeParam(CurrentProjectVariables.getProjectId()), AppContext.getMessage(MilestoneI18nEnum.VIEW_LIST_TITLE)); } else { NotificationUtil.showMessagePermissionAlert(); } }
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 + ""); } }
@Override protected void onGo(final ComponentContainer container, final ScreenData<?> data) { if (CurrentProjectVariables.canRead(ProjectRolePermissionCollections.TASKS)) { InsideProjectNavigationMenu projectModuleMenu = (InsideProjectNavigationMenu) ((MobileNavigationManager) UI.getCurrent().getContent()).getNavigationMenu(); projectModuleMenu.selectButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_TASK)); if (data.getParams() instanceof Integer) { ProjectTaskService taskService = ApplicationContextUtil.getSpringBean(ProjectTaskService.class); SimpleTask task = taskService.findById((Integer) data.getParams(), AppContext.getAccountId()); if (task != null) { this.view.previewItem(task); super.onGo(container, data); AppContext.addFragment( ProjectLinkGenerator.generateTaskPreviewLink( task.getTaskkey(), task.getProjectShortname()), task.getTaskname()); } else { NotificationUtil.showRecordNotExistNotification(); return; } } } else { NotificationUtil.showMessagePermissionAlert(); } }
public ProjectUserLink(String username, String userAvatarId, String displayName) { if (StringUtils.isBlank(username)) { return; } this.setContentMode(ContentMode.HTML); DivLessFormatter div = new DivLessFormatter(); String uid = UUID.randomUUID().toString(); Img avatarLink = new Img("", StorageFactory.getInstance().getAvatarPath(userAvatarId, 16)); A memberLink = new A() .setId("tag" + uid) .setHref( ProjectLinkBuilder.generateProjectMemberFullLink( CurrentProjectVariables.getProjectId(), username)) .appendText(StringUtils.trim(displayName, 30, true)); memberLink.setAttribute("onmouseover", TooltipHelper.userHoverJsFunction(uid, username)); memberLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction(uid)); div.appendChild( avatarLink, DivLessFormatter.EMPTY_SPACE(), memberLink, DivLessFormatter.EMPTY_SPACE(), TooltipHelper.buildDivTooltipEnable(uid)); this.setValue(div.write()); }
private String buildTaskLink() { String uid = UUID.randomUUID().toString(); String linkName = String.format( "[#%d] - %s", task.getTaskkey(), StringUtils.trim(task.getTaskname(), maxLength, true)); A taskLink = new A() .setId("tag" + uid) .setHref( ProjectLinkBuilder.generateTaskPreviewFullLink( task.getTaskkey(), CurrentProjectVariables.getShortName())) .appendText(linkName) .setStyle("display:inline"); Div resultDiv = new DivLessFormatter().appendChild(taskLink); if (task.isOverdue()) { taskLink.setCSSClass("overdue"); resultDiv.appendChild( new Span() .setCSSClass(UIConstants.LABEL_META_INFO) .appendText(" - Due in " + AppContext.formatDuration(task.getDeadline()))); } else if (task.isCompleted()) { taskLink.setCSSClass("completed"); } taskLink.setAttribute( "onmouseover", TooltipHelper.projectHoverJsFunction(uid, ProjectTypeConstants.TASK, task.getId() + "")); taskLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction(uid)); resultDiv.appendChild(TooltipHelper.buildDivTooltipEnable(uid)); return resultDiv.write(); }
@Override protected void onGo(ComponentContainer container, ScreenData<?> data) { if (data instanceof ProjectScreenData.Edit) { // TODO: Handle edit project } else { if (CurrentProjectVariables.canRead(ProjectRolePermissionCollections.PROJECT)) { super.onGo(container, data); view.displayDashboard(); AppContext.addFragment( ProjectLinkGenerator.generateProjectLink(CurrentProjectVariables.getProject().getId()), AppContext.getMessage(ProjectCommonI18nEnum.VIEW_DASHBOARD)); } else { NotificationUtil.showMessagePermissionAlert(); } } }
@Override protected SearchCriteria fillUpSearchCriteria() { searchCriteria = new VersionSearchCriteria(); searchCriteria.setProjectId( new NumberSearchField(SearchField.AND, CurrentProjectVariables.getProjectId())); searchCriteria.setVersionname(StringSearchField.and(nameField.getValue().trim())); return searchCriteria; }
@Override protected ItemTimeLoggingSearchCriteria getItemSearchCriteria() { ItemTimeLoggingSearchCriteria searchCriteria = new ItemTimeLoggingSearchCriteria(); searchCriteria.setProjectIds(new SetSearchField<>(CurrentProjectVariables.getProjectId())); searchCriteria.setType(StringSearchField.and(ProjectTypeConstants.TASK)); searchCriteria.setTypeId(new NumberSearchField(bean.getId())); return searchCriteria; }
@Override protected Double getTotalNonBillableHours(SimpleTask bean) { ItemTimeLoggingSearchCriteria criteria = new ItemTimeLoggingSearchCriteria(); criteria.setProjectIds(new SetSearchField<>(CurrentProjectVariables.getProjectId())); criteria.setType(StringSearchField.and(ProjectTypeConstants.TASK)); criteria.setTypeId(new NumberSearchField(bean.getId())); criteria.setIsBillable(new BooleanSearchField(false)); return itemTimeLoggingService.getTotalHoursByCriteria(criteria); }
@Override protected void initRelatedComponents() { commentListComp = new CommentDisplay( ProjectTypeConstants.PAGE, CurrentProjectVariables.getProjectId(), ProjectPageRelayEmailNotificationAction.class); commentListComp.setWidth("100%"); commentListComp.setMargin(true); }
private void save(Version item) { VersionService versionService = ApplicationContextUtil.getSpringBean(VersionService.class); item.setSaccountid(AppContext.getAccountId()); item.setProjectid(CurrentProjectVariables.getProjectId()); item.setStatus(StatusI18nEnum.Open.name()); if (item.getId() == null) { versionService.saveWithSession(item, AppContext.getUsername()); } else { versionService.updateWithSession(item, AppContext.getUsername()); } }
@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(); }
@Override protected void saveTimeInvest(double spentHours, boolean isBillable, Date forDate) { ItemTimeLogging item = new ItemTimeLogging(); item.setLoguser(AppContext.getUsername()); item.setLogvalue(spentHours); item.setTypeid(bean.getId()); item.setType(ProjectTypeConstants.TASK); item.setSaccountid(AppContext.getAccountId()); item.setProjectid(CurrentProjectVariables.getProjectId()); item.setLogforday(forDate); item.setIsbillable(isBillable); itemTimeLoggingService.saveWithSession(item, AppContext.getUsername()); }
public ProjectMemberSelectionBox(boolean isNullAllowable) { this.setItemCaptionMode(ItemCaptionMode.EXPLICIT); this.setNullSelectionAllowed(isNullAllowable); ProjectMemberSearchCriteria criteria = new ProjectMemberSearchCriteria(); criteria.setProjectId(new NumberSearchField(CurrentProjectVariables.getProjectId())); criteria.setStatus(new StringSearchField(ProjectMemberStatusConstants.ACTIVE)); ProjectMemberService userService = ApplicationContextUtil.getSpringBean(ProjectMemberService.class); List<SimpleProjectMember> memberList = userService.findPagableListByCriteria(new SearchRequest<>(criteria, 0, Integer.MAX_VALUE)); loadUserList(memberList); }
private int saveMilestone(Milestone milestone) { MilestoneService milestoneService = ApplicationContextUtil.getSpringBean(MilestoneService.class); milestone.setProjectid(CurrentProjectVariables.getProjectId()); milestone.setSaccountid(AppContext.getAccountId()); if (milestone.getId() == null) { milestone.setCreateduser(AppContext.getUsername()); milestoneService.saveWithSession(milestone, AppContext.getUsername()); } else { milestoneService.updateWithSession(milestone, AppContext.getUsername()); } return milestone.getId(); }
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(" - 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); }
public ToogleTaskSummaryField(final SimpleTask task, int maxLength) { this.setWidth("100%"); this.maxLength = maxLength; this.task = task; taskLinkLbl = new Label(buildTaskLink(), ContentMode.HTML); taskLinkLbl.setWidthUndefined(); taskLinkLbl.addStyleName(UIConstants.LABEL_WORD_WRAP); this.addComponent(taskLinkLbl); if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) { this.addStyleName("editable-field"); this.addLayoutClickListener( new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { if (event.getClickedComponent() == taskLinkLbl) { return; } if (isRead) { ToogleTaskSummaryField.this.removeComponent(taskLinkLbl); final TextField editField = new TextField(); editField.setValue(task.getTaskname()); editField.setWidth("100%"); editField.focus(); ToogleTaskSummaryField.this.addComponent(editField); ToogleTaskSummaryField.this.removeStyleName("editable-field"); editField.addValueChangeListener( new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { updateFieldValue(editField); } }); editField.addBlurListener( new FieldEvents.BlurListener() { @Override public void blur(FieldEvents.BlurEvent event) { updateFieldValue(editField); } }); isRead = !isRead; } } }); } }
@Override protected void onGo(ComponentContainer container, ScreenData<?> data) { if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.VERSIONS)) { VersionContainer versionContainer = (VersionContainer) container; versionContainer.addComponent(view.getWidget()); Version version = (Version) data.getParams(); view.editItem(version); ProjectBreadcrumb breadcrumb = ViewManager.getCacheComponent(ProjectBreadcrumb.class); if (version.getId() == null) { breadcrumb.gotoVersionAdd(); } else { breadcrumb.gotoVersionEdit(version); } } else { NotificationUtil.showMessagePermissionAlert(); } }
@Override protected void buildExtraControls() { Button createBtn = new Button( AppContext.getMessage(BugI18nEnum.BUTTON_NEW_VERSION), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { EventBusFactory.getInstance().post(new BugVersionEvent.GotoAdd(this, null)); } }); createBtn.setEnabled( CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.VERSIONS)); createBtn.setStyleName(UIConstants.BUTTON_ACTION); createBtn.setIcon(FontAwesome.PLUS); this.addHeaderRight(createBtn); }
@Override protected void onGo(ComponentContainer container, ScreenData<?> data) { if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES)) { MilestoneContainer milestoneContainer = (MilestoneContainer) container; milestoneContainer.navigateToContainer(ProjectTypeConstants.MILESTONE); milestoneContainer.removeAllComponents(); milestoneContainer.addComponent(view.getWidget()); Milestone milestone = (Milestone) data.getParams(); view.editItem(milestone); ProjectBreadcrumb breadcrumb = ViewManager.getCacheComponent(ProjectBreadcrumb.class); if (milestone.getId() == null) { breadcrumb.gotoMilestoneAdd(); } else { breadcrumb.gotoMilestoneEdit(milestone); } } else { NotificationUtil.showMessagePermissionAlert(); } }
private HorizontalLayout createSearchTopPanel() { final HorizontalLayout layout = new HorizontalLayout(); layout.setWidth("100%"); layout.setSpacing(true); layout.setMargin(true); final Image titleIcon = new Image(null, MyCollabResource.newResource("icons/24/project/component.png")); layout.addComponent(titleIcon); layout.setComponentAlignment(titleIcon, Alignment.MIDDLE_LEFT); final Label componenttitle = new Label("Components"); componenttitle.setStyleName(Reindeer.LABEL_H2); layout.addComponent(componenttitle); layout.setExpandRatio(componenttitle, 1.0f); layout.setComponentAlignment(componenttitle, Alignment.MIDDLE_LEFT); final Button createBtn = new Button( LocalizationHelper.getMessage(BugI18nEnum.NEW_COMPONENT_ACTION), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { EventBus.getInstance().fireEvent(new BugComponentEvent.GotoAdd(this, null)); } }); createBtn.setEnabled( CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.COMPONENTS)); createBtn.setStyleName(UIConstants.THEME_BLUE_LINK); createBtn.setIcon(MyCollabResource.newResource("icons/16/addRecord.png")); UiUtils.addComponent(layout, createBtn, Alignment.MIDDLE_RIGHT); return layout; }
public TaskDashboardViewImpl() { this.withMargin(new MarginInfo(false, true, true, true)); taskSearchPanel = new TaskSearchPanel(); MHorizontalLayout groupWrapLayout = new MHorizontalLayout(); groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); groupWrapLayout.addComponent(new Label("Filter:")); final TaskSavedFilterComboBox savedFilterComboBox = new TaskSavedFilterComboBox(); savedFilterComboBox.addQuerySelectListener( new SavedFilterComboBox.QuerySelectListener() { @Override public void querySelect(SavedFilterComboBox.QuerySelectEvent querySelectEvent) { List<SearchFieldInfo> fieldInfos = querySelectEvent.getSearchFieldInfos(); TaskSearchCriteria criteria = SearchFieldInfo.buildSearchCriteria(TaskSearchCriteria.class, fieldInfos); criteria.setProjectid(new NumberSearchField(CurrentProjectVariables.getProjectId())); EventBusFactory.getInstance() .post(new TaskEvent.SearchRequest(TaskDashboardViewImpl.this, criteria)); } }); groupWrapLayout.addComponent(savedFilterComboBox); groupWrapLayout.addComponent(new Label("Sort:")); final ComboBox sortCombo = new ValueComboBox(false, DESCENDING, ASCENDING); sortCombo.setWidth("100px"); sortCombo.addValueChangeListener( new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { String sortValue = (String) sortCombo.getValue(); if (ASCENDING.equals(sortValue)) { sortDirection = SearchCriteria.ASC; } else { sortDirection = SearchCriteria.DESC; } queryAndDisplayTasks(); } }); sortDirection = SearchCriteria.DESC; groupWrapLayout.addComponent(sortCombo); groupWrapLayout.addComponent(new Label("Group by:")); final ComboBox groupCombo = new ValueComboBox(false, GROUP_DUE_DATE, GROUP_START_DATE, PLAIN_LIST); groupCombo.setWidth("100px"); groupCombo.addValueChangeListener( new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { groupByState = (String) groupCombo.getValue(); queryAndDisplayTasks(); } }); groupByState = GROUP_DUE_DATE; groupWrapLayout.addComponent(groupCombo); taskSearchPanel.addHeaderRight(groupWrapLayout); Button exportBtn = new Button("Export"); final SplitButton exportSplitBtn = new SplitButton(exportBtn); exportBtn.addClickListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { exportSplitBtn.setPopupVisible(true); } }); exportSplitBtn.addStyleName(UIConstants.THEME_GREEN_LINK); OptionPopupContent popupButtonsControl = new OptionPopupContent(); Button exportPdfBtn = new Button("PDF"); exportPdfBtn.setIcon(FontAwesome.FILE_PDF_O); FileDownloader pdfFileDownloder = new FileDownloader(buildStreamSource(ReportExportType.PDF)); pdfFileDownloder.extend(exportPdfBtn); popupButtonsControl.addOption(exportPdfBtn); Button exportExcelBtn = new Button("Excel"); exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O); FileDownloader excelFileDownloader = new FileDownloader(buildStreamSource(ReportExportType.EXCEL)); excelFileDownloader.extend(exportExcelBtn); popupButtonsControl.addOption(exportExcelBtn); exportSplitBtn.setContent(popupButtonsControl); groupWrapLayout.with(exportSplitBtn); Button newTaskBtn = new Button( AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASK), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { SimpleTask newTask = new SimpleTask(); newTask.setProjectid(CurrentProjectVariables.getProjectId()); UI.getCurrent().addWindow(new TaskAddWindow(newTask)); } }); newTaskBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); newTaskBtn.setIcon(FontAwesome.PLUS); newTaskBtn.setDescription(AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASKGROUP)); newTaskBtn.setStyleName(UIConstants.THEME_GREEN_LINK); groupWrapLayout.addComponent(newTaskBtn); Button advanceDisplayBtn = new Button(); advanceDisplayBtn.setWidth("50px"); advanceDisplayBtn.setIcon(FontAwesome.SITEMAP); advanceDisplayBtn.setDescription( AppContext.getMessage(TaskGroupI18nEnum.ADVANCED_VIEW_TOOLTIP)); Button calendarBtn = new Button( null, new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { EventBusFactory.getInstance() .post(new TaskEvent.GotoCalendarView(TaskDashboardViewImpl.this)); } }); calendarBtn.setWidth("50px"); calendarBtn.setDescription("Calendar View"); calendarBtn.setIcon(FontAwesome.CALENDAR); Button chartDisplayBtn = new Button( null, new Button.ClickListener() { private static final long serialVersionUID = -5707546605789537298L; @Override public void buttonClick(ClickEvent event) { displayGanttChartView(); } }); chartDisplayBtn.setWidth("50px"); chartDisplayBtn.setDescription("Display Gantt chart"); chartDisplayBtn.setIcon(FontAwesome.BAR_CHART_O); Button kanbanBtn = new Button( null, new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { displayKanbanView(); } }); kanbanBtn.setWidth("50px"); kanbanBtn.setDescription("Kanban View"); kanbanBtn.setIcon(FontAwesome.TH); ToggleButtonGroup viewButtons = new ToggleButtonGroup(); viewButtons.addButton(advanceDisplayBtn); viewButtons.addButton(calendarBtn); viewButtons.addButton(kanbanBtn); viewButtons.addButton(chartDisplayBtn); viewButtons.setDefaultButton(advanceDisplayBtn); groupWrapLayout.addComponent(viewButtons); mainLayout = new MHorizontalLayout().withFullHeight().withFullWidth(); wrapBody = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, false)); rightColumn = new MVerticalLayout() .withWidth("350px") .withMargin(new MarginInfo(true, false, false, false)); mainLayout.with(wrapBody, rightColumn).expand(wrapBody); }
public HorizontalLayout createButtonControls(int buttonEnableFlags, String permissionItem) { Button optionParentBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_OPTION), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { optionBtn.setPopupVisible(true); } }); optionBtn = new SplitButton(optionParentBtn); optionBtn.setWidthUndefined(); optionBtn.addStyleName(UIConstants.THEME_GRAY_LINK); if (permissionItem != null) { boolean canWrite = CurrentProjectVariables.canWrite(permissionItem); boolean canAccess = CurrentProjectVariables.canAccess(permissionItem); boolean canRead = CurrentProjectVariables.canRead(permissionItem); if ((buttonEnableFlags & ADD_BTN_PRESENTED) == ADD_BTN_PRESENTED) { addBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_ADD), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { optionBtn.setPopupVisible(false); T item = previewForm.getBean(); previewForm.fireAddForm(item); } }); addBtn.setIcon(FontAwesome.PLUS); addBtn.setStyleName(UIConstants.THEME_GREEN_LINK); addBtn.setEnabled(canWrite); editButtons.addComponent(addBtn); } if ((buttonEnableFlags & EDIT_BTN_PRESENTED) == EDIT_BTN_PRESENTED) { editBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_EDIT), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { optionBtn.setPopupVisible(false); T item = previewForm.getBean(); previewForm.fireEditForm(item); } }); editBtn.setIcon(FontAwesome.EDIT); editBtn.setStyleName(UIConstants.THEME_GREEN_LINK); editBtn.setEnabled(canWrite); editButtons.addComponent(editBtn); } if ((buttonEnableFlags & DELETE_BTN_PRESENTED) == DELETE_BTN_PRESENTED) { deleteBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_DELETE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { T item = previewForm.getBean(); previewForm.fireDeleteForm(item); } }); deleteBtn.setIcon(FontAwesome.TRASH_O); deleteBtn.setStyleName(UIConstants.THEME_RED_LINK); deleteBtn.setEnabled(canAccess); editButtons.addComponent(deleteBtn); } if ((buttonEnableFlags & ASSIGN_BTN_PRESENTED) == ASSIGN_BTN_PRESENTED) { assignBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_ASSIGN), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { T item = previewForm.getBean(); previewForm.fireAssignForm(item); } }); assignBtn.setIcon(FontAwesome.SHARE); assignBtn.setStyleName(UIConstants.THEME_GREEN_LINK); editButtons.addComponent(assignBtn, 0); assignBtn.setEnabled(canWrite); } if ((buttonEnableFlags & CLONE_BTN_PRESENTED) == CLONE_BTN_PRESENTED) { cloneBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_CLONE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { optionBtn.setPopupVisible(false); T item = previewForm.getBean(); previewForm.fireCloneForm(item); } }); cloneBtn.setIcon(FontAwesome.ROAD); cloneBtn.setStyleName("link"); cloneBtn.setEnabled(canWrite); popupButtonsControl.addOption(cloneBtn); } if (popupButtonsControl.getComponentCount() > 0) { optionBtn.setContent(popupButtonsControl); editButtons.addComponent(optionBtn); } layout.with(editButtons).withAlign(editButtons, Alignment.MIDDLE_RIGHT); if ((buttonEnableFlags & NAVIGATOR_BTN_PRESENTED) == NAVIGATOR_BTN_PRESENTED) { ButtonGroup navigationBtns = new ButtonGroup(); navigationBtns.setStyleName("navigation-btns"); Button previousItem = new Button( "<", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { T item = previewForm.getBean(); previewForm.fireGotoPrevious(item); } }); previousItem.setStyleName(UIConstants.THEME_GREEN_LINK); previousItem.setDescription( AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_PREVIOUS_ITEM)); previousItem.setEnabled(canRead); navigationBtns.addButton(previousItem); Button nextItemBtn = new Button( ">", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { T item = previewForm.getBean(); previewForm.fireGotoNextItem(item); } }); nextItemBtn.setStyleName(UIConstants.THEME_GREEN_LINK); nextItemBtn.setDescription(AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_NEXT_ITEM)); nextItemBtn.setEnabled(canRead); navigationBtns.addButton(nextItemBtn); layout.addComponent(navigationBtns); layout.setComponentAlignment(navigationBtns, Alignment.MIDDLE_RIGHT); } } return layout; }
@Override protected boolean hasEditPermission() { return CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS); }
private void showTaskGroupInfo() { if (this.isDisplayTaskListInfo) { this.layoutHelper = new GridFormLayoutHelper(2, 3, "100%", "180px", Alignment.MIDDLE_LEFT); this.layoutHelper.getLayout().setWidth("100%"); this.layoutHelper.getLayout().addStyleName("colored-gridlayout"); this.layoutHelper.getLayout().setMargin(false); this.addComponent(this.layoutHelper.getLayout()); final Label descLbl = (Label) this.layoutHelper.addComponent( new Label(), "Description", 0, 0, 2, "100%", Alignment.TOP_RIGHT); descLbl.setContentMode(ContentMode.HTML); descLbl.setValue(StringUtils.preStringFormat(this.taskList.getDescription())); this.layoutHelper.addComponent( new ProjectUserFormLinkField( this.taskList.getOwner(), this.taskList.getOwnerAvatarId(), this.taskList.getOwnerFullName()), LocalizationHelper.getMessage(GenericI18Enum.FORM_ASSIGNEE_FIELD), 0, 1, Alignment.TOP_RIGHT); final DefaultFormViewFieldFactory.FormLinkViewField milestoneLink = new DefaultFormViewFieldFactory.FormLinkViewField( this.taskList.getMilestoneName(), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { EventBus.getInstance() .fireEvent( new MilestoneEvent.GotoRead( this, TaskDisplayComponent.this.taskList.getMilestoneid())); } }, MyCollabResource.newResource("icons/16/project/milestone.png")); this.layoutHelper.addComponent( milestoneLink, LocalizationHelper.getMessage(TaskI18nEnum.FORM_PHASE_FIELD), 1, 1, Alignment.TOP_RIGHT); this.taskListProgress = (ProgressPercentageIndicator) this.layoutHelper.addComponent( new ProgressPercentageIndicator(this.taskList.getPercentageComplete()), "Progress", 0, 2); this.taskListProgress.setWidth("100px"); HorizontalLayout taskNumberProgress = new HorizontalLayout(); taskNumberProgress.setSpacing(true); taskNumberProgress = (HorizontalLayout) this.layoutHelper.addComponent(taskNumberProgress, "Number of open tasks", 1, 2); this.taskNumberLbl = new Label( "(" + this.taskList.getNumOpenTasks() + "/" + this.taskList.getNumAllTasks() + ")"); taskNumberProgress.addComponent(this.taskNumberLbl); } this.taskDisplay = new TaskTableDisplay( new String[] { "id", "taskname", "startdate", "deadline", "percentagecomplete", "assignUserFullName" }, new String[] { "", LocalizationHelper.getMessage(TaskI18nEnum.TABLE_TASK_NAME_HEADER), LocalizationHelper.getMessage(TaskI18nEnum.TABLE_START_DATE_HEADER), LocalizationHelper.getMessage(TaskI18nEnum.TABLE_DUE_DATE_HEADER), LocalizationHelper.getMessage(TaskI18nEnum.TABLE_PER_COMPLETE_HEADER), LocalizationHelper.getMessage(TaskI18nEnum.TABLE_ASSIGNEE_HEADER) }); this.addComponent(this.taskDisplay); this.taskDisplay.addTableListener( new ApplicationEventListener<TableClickEvent>() { private static final long serialVersionUID = 1L; @Override public Class<? extends ApplicationEvent> getEventType() { return TableClickEvent.class; } @Override public void handle(final TableClickEvent event) { final SimpleTask task = (SimpleTask) event.getData(); if ("taskname".equals(event.getFieldName())) { EventBus.getInstance() .fireEvent(new TaskEvent.GotoRead(TaskDisplayComponent.this, task.getId())); } else if ("closeTask".equals(event.getFieldName()) || "reopenTask".equals(event.getFieldName()) || "pendingTask".equals(event.getFieldName()) || "deleteTask".equals(event.getFieldName())) { TaskDisplayComponent.this.removeAllComponents(); final ProjectTaskListService taskListService = ApplicationContextUtil.getSpringBean(ProjectTaskListService.class); TaskDisplayComponent.this.taskList = taskListService.findById( TaskDisplayComponent.this.taskList.getId(), AppContext.getAccountId()); TaskDisplayComponent.this.showTaskGroupInfo(); } } }); this.createTaskBtn = new Button( LocalizationHelper.getMessage(TaskI18nEnum.NEW_TASK_ACTION), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { TaskDisplayComponent.this.removeAllComponents(); final TaskAddPopup taskAddView = new TaskAddPopup(TaskDisplayComponent.this, TaskDisplayComponent.this.taskList); if (TaskDisplayComponent.this.layoutHelper != null) { TaskDisplayComponent.this.addComponent( TaskDisplayComponent.this.layoutHelper.getLayout(), 0); TaskDisplayComponent.this.addComponent(TaskDisplayComponent.this.taskDisplay, 1); TaskDisplayComponent.this.addComponent(taskAddView, 2); } else { TaskDisplayComponent.this.addComponent(TaskDisplayComponent.this.taskDisplay, 0); TaskDisplayComponent.this.addComponent(taskAddView, 1); } TaskDisplayComponent.this.removeComponent(TaskDisplayComponent.this.createTaskBtn); } }); this.createTaskBtn.setEnabled( CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); this.createTaskBtn.setIcon(MyCollabResource.newResource("icons/16/addRecord.png")); this.createTaskBtn.setStyleName(UIConstants.THEME_BLUE_LINK); final VerticalLayout taskGroupFooter = new VerticalLayout(); taskGroupFooter.setMargin(true); taskGroupFooter.addStyleName("task-list-footer"); taskGroupFooter.addComponent(this.createTaskBtn); taskGroupFooter.setComponentAlignment(this.createTaskBtn, Alignment.MIDDLE_RIGHT); this.addComponent(taskGroupFooter); this.taskDisplay.setItems(this.taskList.getSubTasks()); }
@Override public Component generateRow(final SimpleMessage message, final int rowIndex) { final HorizontalLayout messageLayout = new HorizontalLayout(); messageLayout.setStyleName("message"); messageLayout.setSpacing(true); if (message.getIsstick() != null && message.getIsstick()) { messageLayout.addStyleName("important-message"); } messageLayout.setWidth("100%"); VerticalLayout userBlock = new VerticalLayout(); userBlock.setDefaultComponentAlignment(Alignment.TOP_CENTER); userBlock.setWidth("80px"); userBlock.setSpacing(true); userBlock.addComponent( UserAvatarControlFactory.createUserAvatarButtonLink( message.getPostedUserAvatarId(), message.getFullPostedUserName())); Label userName = new Label(message.getFullPostedUserName()); userName.setStyleName("user-name"); userBlock.addComponent(userName); messageLayout.addComponent(userBlock); final CssLayout rowLayout = new CssLayout(); rowLayout.setStyleName("message-container"); rowLayout.setWidth("100%"); final Button title = new Button( message.getTitle(), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { EventBus.getInstance() .fireEvent( new MessageEvent.GotoRead(MessageListViewImpl.this, message.getId())); } }); title.setWidth("550px"); title.setStyleName("link"); title.addStyleName(UIConstants.WORD_WRAP); final HorizontalLayout messageHeader = new HorizontalLayout(); messageHeader.setStyleName("message-header"); messageHeader.setMargin(new MarginInfo(true, true, false, true)); final VerticalLayout leftHeader = new VerticalLayout(); title.addStyleName("message-title"); leftHeader.addComponent(title); final HorizontalLayout rightHeader = new HorizontalLayout(); rightHeader.setSpacing(true); final Label timePostLbl = new Label(DateTimeUtils.getStringDateFromNow(message.getPosteddate())); timePostLbl.setSizeUndefined(); timePostLbl.setStyleName("time-post"); final HorizontalLayout notification = new HorizontalLayout(); notification.setStyleName("notification"); notification.setSizeUndefined(); notification.setSpacing(true); if (message.getCommentsCount() > 0) { final HorizontalLayout commentNotification = new HorizontalLayout(); final Label commentCountLbl = new Label(Integer.toString(message.getCommentsCount())); commentCountLbl.setStyleName("comment-count"); commentCountLbl.setSizeUndefined(); commentNotification.addComponent(commentCountLbl); final Image commentIcon = new Image(null, MyCollabResource.newResource("icons/16/project/message.png")); commentNotification.addComponent(commentIcon); notification.addComponent(commentNotification); } ResourceService attachmentService = ApplicationContextUtil.getSpringBean(ResourceService.class); List<Content> attachments = attachmentService.getContents( AttachmentUtils.getProjectEntityAttachmentPath( AppContext.getAccountId(), message.getProjectid(), AttachmentType.PROJECT_MESSAGE, message.getId())); if (attachments != null && !attachments.isEmpty()) { final HorizontalLayout attachmentNotification = new HorizontalLayout(); final Label attachmentCountLbl = new Label(Integer.toString(attachments.size())); attachmentCountLbl.setStyleName("attachment-count"); attachmentCountLbl.setSizeUndefined(); attachmentNotification.addComponent(attachmentCountLbl); final Image attachmentIcon = new Image(null, MyCollabResource.newResource("icons/16/attachment.png")); attachmentNotification.addComponent(attachmentIcon); notification.addComponent(attachmentNotification); } Button deleteBtn = new Button( "", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { ConfirmDialogExt.show( UI.getCurrent(), LocalizationHelper.getMessage( GenericI18Enum.DELETE_DIALOG_TITLE, SiteConfiguration.getSiteName()), LocalizationHelper.getMessage( GenericI18Enum.CONFIRM_DELETE_RECORD_DIALOG_MESSAGE), LocalizationHelper.getMessage(GenericI18Enum.BUTTON_YES_LABEL), LocalizationHelper.getMessage(GenericI18Enum.BUTTON_NO_LABEL), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(final ConfirmDialog dialog) { if (dialog.isConfirmed()) { final MessageService messageService = ApplicationContextUtil.getSpringBean(MessageService.class); messageService.removeWithSession( message.getId(), AppContext.getUsername(), AppContext.getAccountId()); MessageListViewImpl.this.tableItem.setSearchCriteria(searchCriteria); } } }); } }); deleteBtn.setIcon(MyCollabResource.newResource("icons/12/project/icon_x.png")); deleteBtn.addStyleName("link"); deleteBtn.setEnabled( CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.MESSAGES)); rightHeader.addComponent(timePostLbl); rightHeader.addComponent(deleteBtn); rightHeader.setExpandRatio(timePostLbl, 1.0f); messageHeader.addComponent(leftHeader); messageHeader.setExpandRatio(leftHeader, 1.0f); messageHeader.addComponent(rightHeader); messageHeader.setWidth("100%"); rowLayout.addComponent(messageHeader); final Label messageContent = new Label(StringUtils.formatExtraLink(message.getMessage()), ContentMode.HTML); messageContent.setStyleName("message-body"); rowLayout.addComponent(messageContent); if (notification.getComponentCount() > 0) { VerticalLayout messageFooter = new VerticalLayout(); messageFooter.setWidth("100%"); messageFooter.setStyleName("message-footer"); messageFooter.addComponent(notification); messageFooter.setMargin(true); messageFooter.setComponentAlignment(notification, Alignment.MIDDLE_RIGHT); rowLayout.addComponent(messageFooter); } messageLayout.addComponent(rowLayout); messageLayout.setExpandRatio(rowLayout, 1.0f); return messageLayout; }
public MessageSearchPanel() { this.project = CurrentProjectVariables.getProject(); }
@Override public void displayTaskLists() { TaskListSearchCriteria criteria = new TaskListSearchCriteria(); criteria.setProjectId(new NumberSearchField(CurrentProjectVariables.getProjectId())); taskLists.setSearchCriteria(criteria); }
public ComponentSearchPanel() { this.project = CurrentProjectVariables.getProject(); }