List of usage examples for com.vaadin.ui Label Label
public Label(String text)
From source file:com.esofthead.mycollab.module.project.view.settings.ProjectRoleReadViewImpl.java
License:Open Source License
protected ComponentContainer createBottomPanel() { VerticalLayout permissionsPanel = new VerticalLayout(); final Label organizationHeader = new Label(AppContext.getMessage(ProjectRoleI18nEnum.SECTION_PERMISSIONS)); organizationHeader.setStyleName("h2"); permissionsPanel.addComponent(organizationHeader); projectFormHelper = new GridFormLayoutHelper(2, ProjectRolePermissionCollections.PROJECT_PERMISSIONS.length, "100%", "167px", Alignment.TOP_LEFT); projectFormHelper.getLayout().setWidth("100%"); projectFormHelper.getLayout().setMargin(false); projectFormHelper.getLayout().addStyleName("colored-gridlayout"); permissionsPanel.addComponent(projectFormHelper.getLayout()); return permissionsPanel; }
From source file:com.esofthead.mycollab.module.project.view.settings.ProjectRoleReadViewImpl.java
License:Open Source License
protected void onPreviewItem() { projectFormHelper.getLayout().removeAllComponents(); final PermissionMap permissionMap = beanItem.getPermissionMap(); for (int i = 0; i < ProjectRolePermissionCollections.PROJECT_PERMISSIONS.length; i++) { final String permissionPath = ProjectRolePermissionCollections.PROJECT_PERMISSIONS[i]; projectFormHelper.addComponent(/*from www . j a v a 2 s.co m*/ new Label(AppContext.getPermissionCaptionValue(permissionMap, RolePermissionI18nEnum.valueOf(permissionPath).name())), AppContext.getMessage(RolePermissionI18nEnum.valueOf(permissionPath)), 0, i); } }
From source file:com.esofthead.mycollab.module.project.view.task.TaskAddPopup.java
License:Open Source License
public TaskAddPopup(final TaskDisplayComponent taskDisplayComp, final TaskList taskList) { final VerticalLayout taskLayout = new VerticalLayout(); taskLayout.addStyleName("taskadd-popup"); final VerticalLayout popupHeader = new VerticalLayout(); popupHeader.setWidth("100%"); popupHeader.setMargin(true);/*from www . ja v a2 s . c o m*/ popupHeader.addStyleName("popup-header"); final Label titleLbl = new Label(AppContext.getMessage(TaskI18nEnum.DIALOG_NEW_TASK_TITLE)); titleLbl.addStyleName("bold"); popupHeader.addComponent(titleLbl); taskLayout.addComponent(popupHeader); this.task = new SimpleTask(); TabSheet taskContainer = new TabSheet(); final TaskInputForm taskInputForm = new TaskInputForm(); taskInputForm.setWidth("100%"); taskContainer.addTab(taskInputForm, AppContext.getMessage(GenericI18Enum.WINDOW_INFORMATION_TITLE)); this.taskNoteComponent = new TaskNoteLayout(); taskContainer.addTab(this.taskNoteComponent, AppContext.getMessage(TaskI18nEnum.FORM_NOTES_ATTACHMENT)); taskLayout.addComponent(taskContainer); final MHorizontalLayout controlsLayout = new MHorizontalLayout().withMargin(true); controlsLayout.addStyleName("popup-footer"); final Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { taskDisplayComp.closeTaskAdd(); } }); cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK); final Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (taskInputForm.validateForm()) { final ProjectTaskService taskService = ApplicationContextUtil .getSpringBean(ProjectTaskService.class); task.setTasklistid(taskList.getId()); task.setProjectid(CurrentProjectVariables.getProjectId()); task.setSaccountid(AppContext.getAccountId()); task.setNotes(taskNoteComponent.getNote()); taskService.saveWithSession(task, AppContext.getUsername()); taskNoteComponent.saveContentsToRepo(task.getId()); taskDisplayComp.saveTaskSuccess(task); taskDisplayComp.closeTaskAdd(); } } }); saveBtn.setIcon(FontAwesome.SAVE); saveBtn.setStyleName(UIConstants.THEME_GREEN_LINK); controlsLayout.with(saveBtn, cancelBtn).alignAll(Alignment.MIDDLE_CENTER); taskLayout.addComponent(controlsLayout); taskLayout.setComponentAlignment(controlsLayout, Alignment.MIDDLE_RIGHT); this.setCompositionRoot(taskLayout); }
From source file:com.esofthead.mycollab.module.project.view.task.TaskDashboardViewImpl.java
License:Open Source License
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("Sort")); final ComboBox sortCombo = new ValueComboBox(false, AppContext.getMessage(GenericI18Enum.OPT_SORT_DESCENDING), AppContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING)); sortCombo.addValueChangeListener(new Property.ValueChangeListener() { @Override/* www . j a va 2 s .co m*/ public void valueChange(Property.ValueChangeEvent valueChangeEvent) { String sortValue = (String) sortCombo.getValue(); if (AppContext.getMessage(GenericI18Enum.OPT_SORT_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, GROUP_CREATED_DATE, PLAIN_LIST, GROUP_USER); 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 printBtn = new Button("", new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { UI.getCurrent().addWindow(new TaskCustomizeReportOutputWindow(new LazyValueInjector() { @Override protected Object doEval() { return baseCriteria; } })); } }); printBtn.setIcon(FontAwesome.PRINT); printBtn.addStyleName(UIConstants.BUTTON_OPTION); printBtn.setDescription(AppContext.getMessage(GenericI18Enum.ACTION_EXPORT)); groupWrapLayout.addComponent(printBtn); Button newTaskBtn = new Button(AppContext.getMessage(TaskI18nEnum.NEW), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) { SimpleTask newTask = new SimpleTask(); newTask.setProjectid(CurrentProjectVariables.getProjectId()); newTask.setSaccountid(AppContext.getAccountId()); newTask.setLogby(AppContext.getUsername()); UI.getCurrent().addWindow(new TaskAddWindow(newTask)); } } }); newTaskBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); newTaskBtn.setIcon(FontAwesome.PLUS); newTaskBtn.setStyleName(UIConstants.BUTTON_ACTION); groupWrapLayout.addComponent(newTaskBtn); Button advanceDisplayBtn = new Button("List"); advanceDisplayBtn.setWidth("100px"); advanceDisplayBtn.setIcon(FontAwesome.SITEMAP); advanceDisplayBtn.setDescription("Advance View"); Button kanbanBtn = new Button("Kanban", new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { displayKanbanView(); } }); kanbanBtn.setWidth("100px"); kanbanBtn.setDescription("Kanban View"); kanbanBtn.setIcon(FontAwesome.TH); ToggleButtonGroup viewButtons = new ToggleButtonGroup(); viewButtons.addButton(advanceDisplayBtn); viewButtons.addButton(kanbanBtn); viewButtons.withDefaultButton(advanceDisplayBtn); groupWrapLayout.addComponent(viewButtons); MHorizontalLayout mainLayout = new MHorizontalLayout().withFullHeight().withFullWidth(); wrapBody = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, false)); rightColumn = new MVerticalLayout().withWidth("370px") .withMargin(new MarginInfo(true, false, false, false)); mainLayout.with(wrapBody, rightColumn).expand(wrapBody); this.with(taskSearchPanel, mainLayout); }
From source file:com.esofthead.mycollab.module.project.view.task.TaskGroupNoItemView.java
License:Open Source License
public TaskGroupNoItemView() { this.setMargin(new MarginInfo(true, false, false, false)); VerticalLayout layout = new VerticalLayout(); layout.addStyleName("taskgroup-noitem"); layout.setSpacing(true);/*from www .ja v a 2s . c om*/ layout.setDefaultComponentAlignment(Alignment.TOP_CENTER); layout.setMargin(true); Image image = new Image(null, MyCollabResource.newResource("icons/48/project/tasklist.png")); layout.addComponent(image); Label title = new Label(AppContext.getMessage(TaskGroupI18nEnum.NO_ITEM_VIEW_TITLE)); title.addStyleName("h2"); title.setWidthUndefined(); layout.addComponent(title); Label body = new Label(AppContext.getMessage(TaskGroupI18nEnum.NO_ITEM_VIEW_HINT)); body.setWidthUndefined(); layout.addComponent(body); Button createTaskGroupBtn = new Button(AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASKGROUP), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final TaskGroupAddWindow taskListWindow = new TaskGroupAddWindow(null); UI.getCurrent().addWindow(taskListWindow); } }); createTaskGroupBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); HorizontalLayout links = new HorizontalLayout(); links.addComponent(createTaskGroupBtn); createTaskGroupBtn.addStyleName(UIConstants.THEME_GREEN_LINK); links.setSpacing(true); layout.addComponent(links); this.addComponent(layout); this.setComponentAlignment(layout, Alignment.TOP_CENTER); }
From source file:com.esofthead.mycollab.module.project.view.task.TaskGroupReorderViewImpl.java
License:Open Source License
private void constructHeader() { CssLayout headerWrapper = new CssLayout(); headerWrapper.setWidth("100%"); headerWrapper.addStyleName("taskgroup-header"); HorizontalLayout header = new HorizontalLayout(); header.setSpacing(true);//from w ww . j a v a 2 s.co m header.setWidth("100%"); Label headerLbl = new Label("All Tasks"); headerLbl.setStyleName("h2"); header.addComponent(headerLbl); header.setComponentAlignment(headerLbl, Alignment.MIDDLE_LEFT); header.setExpandRatio(headerLbl, 1.0f); Button backToListBtn = new Button("Back to dashboard", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { EventBusFactory.getInstance().post(new TaskListEvent.GotoTaskListScreen(this, null)); } }); backToListBtn.setStyleName(UIConstants.THEME_GREEN_LINK); header.addComponent(backToListBtn); header.setComponentAlignment(backToListBtn, Alignment.MIDDLE_RIGHT); saveOrderBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { EventBusFactory.getInstance().post(new TaskListEvent.SaveReoderTaskList(event, changeSet)); } }); saveOrderBtn.setStyleName(UIConstants.THEME_GREEN_LINK); header.addComponent(saveOrderBtn); header.setComponentAlignment(saveOrderBtn, Alignment.MIDDLE_RIGHT); headerWrapper.addComponent(header); this.addComponent(headerWrapper); final DDVerticalLayout ddLayout = new DDVerticalLayout(); ddLayout.addStyleName("taskgroup-reorder"); ddLayout.setComponentVerticalDropRatio(0.3f); ddLayout.setDragMode(LayoutDragMode.CLONE); ddLayout.setDropHandler(new DropHandler() { private static final long serialVersionUID = 1L; @Override public AcceptCriterion getAcceptCriterion() { return new Not(VerticalLocationIs.MIDDLE); } @Override public void drop(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); DDVerticalLayout.VerticalLayoutTargetDetails details = (DDVerticalLayout.VerticalLayoutTargetDetails) event .getTargetDetails(); TaskListComponent comp = (TaskListComponent) transferable.getComponent(); int currentIndex = ddLayout.getComponentIndex(comp); int newIndex = details.getOverIndex(); ddLayout.removeComponent(comp); if (currentIndex > newIndex && details.getDropLocation() == VerticalDropLocation.BOTTOM) { newIndex++; } SimpleTaskList dropTaskList = comp.getTaskList(); dropTaskList.setGroupindex(newIndex); changeSet.add(dropTaskList); ddLayout.addComponent(comp, newIndex); // change affected task list items for (int i = 0; i < ddLayout.getComponentCount(); i++) { TaskListComponent affectedComp = (TaskListComponent) ddLayout.getComponent(i); SimpleTaskList affectedTaskList = affectedComp.getTaskList(); affectedTaskList.setGroupindex(i); changeSet.add(affectedTaskList); } } }); taskLists = new BeanList<ProjectTaskListService, TaskListSearchCriteria, SimpleTaskList>(null, ApplicationContextUtil.getSpringBean(ProjectTaskListService.class), TaskListRowDisplayHandler.class, ddLayout); this.addComponent(taskLists); }
From source file:com.esofthead.mycollab.module.project.view.task.TaskSearchTableDisplay.java
License:Open Source License
public TaskSearchTableDisplay(TableViewField requiredColumn, List<TableViewField> displayColumns) { super(ApplicationContextUtil.getSpringBean(ProjectTaskService.class), SimpleTask.class, requiredColumn, displayColumns);/*from w ww. jav a2 s. co m*/ this.addGeneratedColumn("taskname", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleTask task = TaskSearchTableDisplay.this.getBeanByIndex(itemId); CssLayout taskName = new CssLayout(); String taskname = "[%s-%s] %s"; taskname = String.format(taskname, CurrentProjectVariables.getProject().getShortname(), task.getTaskkey(), task.getTaskname()); LabelLink b = new LabelLink(taskname, ProjectLinkBuilder .generateTaskPreviewFullLink(task.getTaskkey(), task.getProjectShortname())); b.setDescription(ProjectTooltipGenerator.generateToolTipTask(AppContext.getUserLocale(), task, AppContext.getSiteUrl(), AppContext.getTimezone())); if (StringUtils.isNotBlank(task.getPriority())) { b.setIconLink(ProjectResources.getIconResourceLink12ByTaskPriority(task.getPriority())); } if (task.getPercentagecomplete() != null && 100d == task.getPercentagecomplete()) { b.addStyleName(UIConstants.LINK_COMPLETED); } else { if ("Pending".equals(task.getStatus())) { b.addStyleName(UIConstants.LINK_PENDING); } else if ((task.getEnddate() != null && (task.getEnddate().before(new GregorianCalendar().getTime()))) || (task.getActualenddate() != null && (task.getActualenddate().before(new GregorianCalendar().getTime()))) || (task.getDeadline() != null && (task.getDeadline().before(new GregorianCalendar().getTime())))) { b.addStyleName(UIConstants.LINK_OVERDUE); } } taskName.addComponent(b); taskName.setWidth("100%"); taskName.setHeightUndefined(); return taskName; } }); this.addGeneratedColumn("percentagecomplete", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleTask task = TaskSearchTableDisplay.this.getBeanByIndex(itemId); Double percomp = (task.getPercentagecomplete() == null) ? new Double(0) : task.getPercentagecomplete(); ProgressPercentageIndicator progress = new ProgressPercentageIndicator(percomp); progress.setWidth("100px"); return progress; } }); this.addGeneratedColumn("startdate", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleTask task = TaskSearchTableDisplay.this.getBeanByIndex(itemId); return new Label(AppContext.formatDate(task.getStartdate())); } }); this.addGeneratedColumn("deadline", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleTask task = TaskSearchTableDisplay.this.getBeanByIndex(itemId); return new Label(AppContext.formatDate(task.getDeadline())); } }); this.addGeneratedColumn("id", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleTask task = TaskSearchTableDisplay.this.getBeanByIndex(itemId); PopupButton taskSettingPopupBtn = new PopupButton(); VerticalLayout filterBtnLayout = new VerticalLayout(); filterBtnLayout.setMargin(true); filterBtnLayout.setSpacing(true); filterBtnLayout.setWidth("100px"); Button editButton = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { EventBusFactory.getInstance() .post(new TaskEvent.GotoEdit(TaskSearchTableDisplay.this, task)); } }); editButton.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); editButton.setStyleName("link"); filterBtnLayout.addComponent(editButton); if ((task.getPercentagecomplete() != null && task.getPercentagecomplete() != 100) || task.getPercentagecomplete() == null) { Button closeBtn = new Button("Close", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { task.setStatus("Closed"); task.setPercentagecomplete(100d); ProjectTaskService projectTaskService = ApplicationContextUtil .getSpringBean(ProjectTaskService.class); projectTaskService.updateWithSession(task, AppContext.getUsername()); fireTableEvent(new TableClickEvent(TaskSearchTableDisplay.this, task, "closeTask")); } }); closeBtn.setStyleName("link"); closeBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); filterBtnLayout.addComponent(closeBtn); } else { Button reOpenBtn = new Button("ReOpen", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { task.setStatus("Open"); task.setPercentagecomplete(0d); ProjectTaskService projectTaskService = ApplicationContextUtil .getSpringBean(ProjectTaskService.class); projectTaskService.updateWithSession(task, AppContext.getUsername()); fireTableEvent(new TableClickEvent(TaskSearchTableDisplay.this, task, "reopenTask")); } }); reOpenBtn.setStyleName("link"); reOpenBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); filterBtnLayout.addComponent(reOpenBtn); } if (!"Pending".equals(task.getStatus())) { if (!"Closed".equals(task.getStatus())) { Button pendingBtn = new Button("Pending", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { task.setStatus("Pending"); task.setPercentagecomplete(0d); ProjectTaskService projectTaskService = ApplicationContextUtil .getSpringBean(ProjectTaskService.class); projectTaskService.updateWithSession(task, AppContext.getUsername()); fireTableEvent( new TableClickEvent(TaskSearchTableDisplay.this, task, "pendingTask")); } }); pendingBtn.setStyleName("link"); pendingBtn.setEnabled( CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); filterBtnLayout.addComponent(pendingBtn); } } else { Button reOpenBtn = new Button("ReOpen", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { task.setStatus("Open"); task.setPercentagecomplete(0d); ProjectTaskService projectTaskService = ApplicationContextUtil .getSpringBean(ProjectTaskService.class); projectTaskService.updateWithSession(task, AppContext.getUsername()); fireTableEvent(new TableClickEvent(TaskSearchTableDisplay.this, task, "reopenTask")); } }); reOpenBtn.setStyleName("link"); reOpenBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); filterBtnLayout.addComponent(reOpenBtn); } Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { ConfirmDialogExt.show(UI.getCurrent(), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, SiteConfiguration.getSiteName()), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), AppContext.getMessage(GenericI18Enum.BUTTON_YES), AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { ProjectTaskService projectTaskService = ApplicationContextUtil .getSpringBean(ProjectTaskService.class); projectTaskService.removeWithSession(task.getId(), AppContext.getUsername(), AppContext.getAccountId()); fireTableEvent(new TableClickEvent(TaskSearchTableDisplay.this, task, "deleteTask")); } } }); } }); deleteBtn.setStyleName("link"); deleteBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS)); filterBtnLayout.addComponent(deleteBtn); taskSettingPopupBtn.setIcon(MyCollabResource.newResource("icons/16/item_settings.png")); taskSettingPopupBtn.setStyleName("link"); taskSettingPopupBtn.setContent(filterBtnLayout); return taskSettingPopupBtn; } }); this.addGeneratedColumn("assignUserFullName", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleTask task = TaskSearchTableDisplay.this.getBeanByIndex(itemId); return new ProjectUserLink(task.getAssignuser(), task.getAssignUserAvatarId(), task.getAssignUserFullName()); } }); this.setWidth("100%"); }
From source file:com.esofthead.mycollab.module.project.view.task.TaskTableDisplay.java
License:Open Source License
public TaskTableDisplay(TableViewField requiredColumn, List<TableViewField> displayColumns, int displayNums) { super(ApplicationContextUtil.getSpringBean(ProjectTaskService.class), SimpleTask.class, requiredColumn, displayColumns);/*from ww w . j a va 2 s . com*/ this.displayNumItems = displayNums; this.addGeneratedColumn("taskname", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleTask task = TaskTableDisplay.this.getBeanByIndex(itemId); CssLayout taskName = new CssLayout(); String taskname = "[%s-%s] %s"; taskname = String.format(taskname, CurrentProjectVariables.getProject().getShortname(), task.getTaskkey(), task.getTaskname()); LabelLink b = new LabelLink(taskname, ProjectLinkBuilder .generateTaskPreviewFullLink(task.getTaskkey(), task.getProjectShortname())); b.setDescription(ProjectTooltipGenerator.generateToolTipTask(AppContext.getUserLocale(), task, AppContext.getSiteUrl(), AppContext.getTimezone())); if (StringUtils.isNotBlank(task.getPriority())) { b.setIconLink(ProjectResources.getIconResourceLink12ByTaskPriority(task.getPriority())); } if (task.isCompleted()) { b.addStyleName(UIConstants.LINK_COMPLETED); } else if (task.isPending()) { b.addStyleName(UIConstants.LINK_PENDING); } else if (task.isOverdue()) { b.addStyleName(UIConstants.LINK_OVERDUE); } taskName.addComponent(b); taskName.setWidth("100%"); taskName.setHeightUndefined(); return taskName; } }); this.addGeneratedColumn("percentagecomplete", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleTask task = TaskTableDisplay.this.getBeanByIndex(itemId); Double percomp = (task.getPercentagecomplete() == null) ? new Double(0) : task.getPercentagecomplete(); ProgressPercentageIndicator progress = new ProgressPercentageIndicator(percomp); progress.setWidth("100px"); return progress; } }); this.addGeneratedColumn("startdate", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleTask task = TaskTableDisplay.this.getBeanByIndex(itemId); return new Label(AppContext.formatDate(task.getStartdate())); } }); this.addGeneratedColumn("deadline", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleTask task = TaskTableDisplay.this.getBeanByIndex(itemId); return new Label(AppContext.formatDate(task.getDeadline())); } }); this.addGeneratedColumn("id", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleTask task = TaskTableDisplay.this.getBeanByIndex(itemId); PopupButton taskSettingPopupBtn = new PopupButton(); taskSettingPopupBtn.setIcon(MyCollabResource.newResource("icons/16/item_settings.png")); taskSettingPopupBtn.setStyleName("link"); taskSettingPopupBtn.addStyleName("noDefaultIcon"); MVerticalLayout filterBtnLayout = new MVerticalLayout().withSpacing(true).withMargin(true) .withWidth("100px"); Button editButton = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { EventBusFactory.getInstance() .post(new TaskEvent.GotoEdit(TaskTableDisplay.this, task)); } }); editButton.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); editButton.setStyleName("link"); filterBtnLayout.addComponent(editButton); if ((task.getPercentagecomplete() != null && task.getPercentagecomplete() != 100) || task.getPercentagecomplete() == null) { Button closeBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLOSE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { task.setStatus(StatusI18nEnum.Closed.name()); task.setPercentagecomplete(100d); ProjectTaskService projectTaskService = ApplicationContextUtil .getSpringBean(ProjectTaskService.class); projectTaskService.updateSelectiveWithSession(task, AppContext.getUsername()); fireTableEvent(new TableClickEvent(TaskTableDisplay.this, task, "closeTask")); } }); closeBtn.setStyleName("link"); closeBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); filterBtnLayout.addComponent(closeBtn); } else { Button reOpenBtn = new Button("ReOpen", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { task.setStatus(StatusI18nEnum.Open.name()); task.setPercentagecomplete(0d); ProjectTaskService projectTaskService = ApplicationContextUtil .getSpringBean(ProjectTaskService.class); projectTaskService.updateSelectiveWithSession(task, AppContext.getUsername()); fireTableEvent(new TableClickEvent(TaskTableDisplay.this, task, "reopenTask")); } }); reOpenBtn.setStyleName("link"); reOpenBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); filterBtnLayout.addComponent(reOpenBtn); } if (!"Pending".equals(task.getStatus())) { if (!"Closed".equals(task.getStatus())) { Button pendingBtn = new Button("Pending", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { task.setStatus("Pending"); task.setPercentagecomplete(0d); ProjectTaskService projectTaskService = ApplicationContextUtil .getSpringBean(ProjectTaskService.class); projectTaskService.updateSelectiveWithSession(task, AppContext.getUsername()); fireTableEvent(new TableClickEvent(TaskTableDisplay.this, task, "pendingTask")); } }); pendingBtn.setStyleName("link"); pendingBtn.setEnabled( CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); filterBtnLayout.addComponent(pendingBtn); } } else { Button reOpenBtn = new Button("ReOpen", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { task.setStatus("Open"); task.setPercentagecomplete(0d); ProjectTaskService projectTaskService = ApplicationContextUtil .getSpringBean(ProjectTaskService.class); projectTaskService.updateSelectiveWithSession(task, AppContext.getUsername()); fireTableEvent(new TableClickEvent(TaskTableDisplay.this, task, "reopenTask")); } }); reOpenBtn.setStyleName("link"); reOpenBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); filterBtnLayout.addComponent(reOpenBtn); } Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { ConfirmDialogExt.show(UI.getCurrent(), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, SiteConfiguration.getSiteName()), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), AppContext.getMessage(GenericI18Enum.BUTTON_YES), AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { ProjectTaskService projectTaskService = ApplicationContextUtil .getSpringBean(ProjectTaskService.class); projectTaskService.removeWithSession(task.getId(), AppContext.getUsername(), AppContext.getAccountId()); fireTableEvent(new TableClickEvent(TaskTableDisplay.this, task, "deleteTask")); } } }); } }); deleteBtn.setStyleName("link"); deleteBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS)); filterBtnLayout.addComponent(deleteBtn); taskSettingPopupBtn.setContent(filterBtnLayout); return taskSettingPopupBtn; } }); this.addGeneratedColumn("assignUserFullName", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleTask task = TaskTableDisplay.this.getBeanByIndex(itemId); return new ProjectUserLink(task.getAssignuser(), task.getAssignUserAvatarId(), task.getAssignUserFullName()); } }); this.setWidth("100%"); }
From source file:com.esofthead.mycollab.module.project.view.user.MyProjectListComponent.java
License:Open Source License
public MyProjectListComponent() { withSpacing(false).withMargin(false); this.addStyleName("myprojectlist"); MHorizontalLayout header = new MHorizontalLayout().withSpacing(false) .withMargin(new MarginInfo(false, true, false, true)).withHeight("34px"); header.addStyleName("panel-header"); titleLbl = new Label(AppContext.getMessage(ProjectCommonI18nEnum.WIDGET_ACTIVE_PROJECTS_TITLE, 0)); final PopupButton projectsPopup = new PopupButton(""); projectsPopup.addStyleName("popuplistindicator"); final MVerticalLayout filterBtnLayout = new MVerticalLayout().withWidth("200px"); ProjectService projectService = ApplicationContextUtil.getSpringBean(ProjectService.class); int allProjectCount = projectService.getTotalCount(getAllProjectsSearchCriteria()); Button allProjectsBtn = new Button( AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ALL_PROJECTS, allProjectCount), new ClickListener() { private static final long serialVersionUID = 1L; @Override/* w w w . j av a 2 s. c om*/ public void buttonClick(ClickEvent event) { displayAllProjects(); projectsPopup.setPopupVisible(false); } }); allProjectsBtn.setStyleName("link"); filterBtnLayout.addComponent(allProjectsBtn); int activeProjectsCount = projectService.getTotalCount(getActiveProjectsSearchCriteria()); Button activeProjectsBtn = new Button( AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ACTIVE_PROJECTS, activeProjectsCount), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { displayActiveProjects(); projectsPopup.setPopupVisible(false); } }); activeProjectsBtn.setStyleName("link"); filterBtnLayout.addComponent(activeProjectsBtn); int archiveProjectsCount = projectService.getTotalCount(getArchivedProjectsSearchCriteria()); Button archiveProjectsBtn = new Button( AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ARCHIVE_PROJECTS, archiveProjectsCount), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { displayArchiveProjects(); projectsPopup.setPopupVisible(false); } }); archiveProjectsBtn.setStyleName("link"); filterBtnLayout.addComponent(archiveProjectsBtn); projectsPopup.setContent(filterBtnLayout); header.with(titleLbl, projectsPopup).withAlign(titleLbl, Alignment.MIDDLE_LEFT) .withAlign(projectsPopup, Alignment.MIDDLE_RIGHT).expand(titleLbl); this.projectList = new ProjectPagedList(); this.with(header, projectList); }
From source file:com.esofthead.mycollab.module.project.view.user.ProjectActivityStreamPagedList.java
License:Open Source License
protected void feedBlocksPut(Date currentDate, Date nextDate, CssLayout currentBlock) { MHorizontalLayout blockWrapper = new MHorizontalLayout().withWidth("100%").withStyleName("feed-block-wrap"); blockWrapper.setDefaultComponentAlignment(Alignment.TOP_LEFT); Calendar cal1 = Calendar.getInstance(); cal1.setTime(currentDate);/*from w w w .j av a 2s . co m*/ Calendar cal2 = Calendar.getInstance(); cal2.setTime(nextDate); if (cal1.get(Calendar.YEAR) != cal2.get(Calendar.YEAR)) { int currentYear = cal2.get(Calendar.YEAR); Label yearLbl = new Label(String.valueOf(currentYear)); yearLbl.setStyleName("year-lbl"); yearLbl.setWidthUndefined(); yearLbl.setHeight("49px"); this.listContainer.addComponent(yearLbl); } else { blockWrapper.setMargin(new MarginInfo(true, false, false, false)); } Label dateLbl = new Label(DateFormatUtils.format(nextDate, AppContext.getUserDayMonthFormat())); dateLbl.setSizeUndefined(); dateLbl.setStyleName("date-lbl"); blockWrapper.addComponent(dateLbl); blockWrapper.addComponent(currentBlock); blockWrapper.setExpandRatio(currentBlock, 1.0f); this.listContainer.addComponent(blockWrapper); }