List of usage examples for com.vaadin.ui CssLayout setHeightUndefined
@Override public void setHeightUndefined()
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 w w .j ava 2 s .c om 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 w ww.j a va 2 s.c o m*/ 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%"); }