List of usage examples for com.vaadin.ui HorizontalLayout addComponent
@Override public void addComponent(Component c)
From source file:com.esofthead.mycollab.module.file.view.components.ResourcesDisplayComponent.java
License:Open Source License
public ResourcesDisplayComponent(final String rootPath, final Folder rootFolder) { this.setSpacing(true); this.baseFolder = rootFolder; this.rootPath = rootPath; externalResourceService = ApplicationContextUtil.getSpringBean(ExternalResourceService.class); externalDriveService = ApplicationContextUtil.getSpringBean(ExternalDriveService.class); resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class); VerticalLayout mainBodyLayout = new VerticalLayout(); mainBodyLayout.setSpacing(true);//from w ww. j a va 2 s . c o m mainBodyLayout.addStyleName("box-no-border-left"); // file breadcrum --------------------- HorizontalLayout breadcrumbContainer = new HorizontalLayout(); breadcrumbContainer.setMargin(false); fileBreadCrumb = new FileBreadcrumb(rootPath); breadcrumbContainer.addComponent(fileBreadCrumb); mainBodyLayout.addComponent(breadcrumbContainer); // Construct controllGroupBtn controllGroupBtn = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true)); final Button selectAllBtn = new Button(); selectAllBtn.addStyleName(UIConstants.THEME_BROWN_LINK); selectAllBtn.setIcon(FontAwesome.SQUARE_O); selectAllBtn.setData(false); selectAllBtn.setImmediate(true); selectAllBtn.setDescription("Select all"); selectAllBtn.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { if (!(Boolean) selectAllBtn.getData()) { selectAllBtn.setIcon(FontAwesome.CHECK_SQUARE_O); selectAllBtn.setData(true); resourcesContainer.setAllValues(true); } else { selectAllBtn.setData(false); selectAllBtn.setIcon(FontAwesome.SQUARE_O); resourcesContainer.setAllValues(false); } } }); controllGroupBtn.with(selectAllBtn).withAlign(selectAllBtn, Alignment.MIDDLE_LEFT); Button goUpBtn = new Button("Up"); goUpBtn.setIcon(FontAwesome.ARROW_UP); goUpBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { Folder parentFolder; if (baseFolder instanceof ExternalFolder) { if (baseFolder.getPath().equals("/")) { parentFolder = baseFolder; } else { parentFolder = externalResourceService.getParentResourceFolder( ((ExternalFolder) baseFolder).getExternalDrive(), baseFolder.getPath()); } } else if (!baseFolder.getPath().equals(rootPath)) { parentFolder = resourceService.getParentFolder(baseFolder.getPath()); } else { parentFolder = baseFolder; } resourcesContainer.constructBody(parentFolder); baseFolder = parentFolder; fileBreadCrumb.gotoFolder(baseFolder); } }); goUpBtn.setDescription("Back to parent folder"); goUpBtn.setStyleName(UIConstants.THEME_BROWN_LINK); goUpBtn.setDescription("Go up"); controllGroupBtn.with(goUpBtn).withAlign(goUpBtn, Alignment.MIDDLE_LEFT); ButtonGroup navButton = new ButtonGroup(); navButton.addStyleName(UIConstants.THEME_BROWN_LINK); Button createBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CREATE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { AddNewFolderWindow addnewFolderWindow = new AddNewFolderWindow(); UI.getCurrent().addWindow(addnewFolderWindow); } }); createBtn.setIcon(FontAwesome.PLUS); createBtn.addStyleName(UIConstants.THEME_BROWN_LINK); createBtn.setDescription("Create new folder"); createBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS)); navButton.addButton(createBtn); Button uploadBtn = new Button("Upload", new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { MultiUploadContentWindow multiUploadWindow = new MultiUploadContentWindow(); UI.getCurrent().addWindow(multiUploadWindow); } }); uploadBtn.setIcon(FontAwesome.UPLOAD); uploadBtn.addStyleName(UIConstants.THEME_BROWN_LINK); uploadBtn.setDescription("Upload"); uploadBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS)); navButton.addButton(uploadBtn); Button downloadBtn = new Button("Download"); LazyStreamSource streamSource = new LazyStreamSource() { private static final long serialVersionUID = 1L; @Override protected StreamSource buildStreamSource() { Collection<Resource> selectedResources = getSelectedResources(); return StreamDownloadResourceUtil.getStreamSourceSupportExtDrive(selectedResources); } @Override public String getFilename() { Collection<Resource> selectedResources = getSelectedResources(); return StreamDownloadResourceUtil.getDownloadFileName(selectedResources); } }; OnDemandFileDownloader downloaderExt = new OnDemandFileDownloader(streamSource); downloaderExt.extend(downloadBtn); downloadBtn.setIcon(FontAwesome.DOWNLOAD); downloadBtn.addStyleName(UIConstants.THEME_BROWN_LINK); downloadBtn.setDescription("Download"); downloadBtn.setEnabled(AppContext.canRead(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS)); navButton.addButton(downloadBtn); Button moveToBtn = new Button("Move", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { Collection<Resource> selectedResources = getSelectedResources(); if (CollectionUtils.isNotEmpty(selectedResources)) { MoveResourceWindow moveResourceWindow = new MoveResourceWindow(selectedResources); UI.getCurrent().addWindow(moveResourceWindow); } else { NotificationUtil.showWarningNotification("Please select at least one item to move"); } } }); moveToBtn.setIcon(FontAwesome.ARROWS); moveToBtn.addStyleName(UIConstants.THEME_BROWN_LINK); moveToBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS)); moveToBtn.setDescription("Move to"); navButton.addButton(moveToBtn); Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { Collection<Resource> selectedResources = getSelectedResources(); if (CollectionUtils.isEmpty(selectedResources)) { NotificationUtil.showWarningNotification("Please select at least one item to delete"); } else { deleteResourceAction(); } } }); deleteBtn.setIcon(FontAwesome.TRASH_O); deleteBtn.addStyleName(UIConstants.THEME_RED_LINK); deleteBtn.setDescription("Delete resource"); deleteBtn.setEnabled(AppContext.canAccess(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS)); navButton.addButton(deleteBtn); controllGroupBtn.addComponent(navButton); mainBodyLayout.addComponent(controllGroupBtn); resourcesContainer = new ResourcesContainer(baseFolder); mainBodyLayout.addComponent(resourcesContainer); this.addComponent(mainBodyLayout); }
From source file:com.esofthead.mycollab.module.project.ui.components.DynaFormLayout.java
License:Open Source License
@Override public void attachField(Object propertyId, Field<?> field) { AbstractDynaField dynaField = fieldMappings.get(propertyId); if (dynaField != null) { DynaSection section = dynaField.getOwnSection(); GridFormLayoutHelper gridLayout = sectionMappings.get(section); HorizontalLayout componentWrapper = gridLayout.getComponentWrapper(dynaField.getDisplayName()); if (componentWrapper != null) { componentWrapper.addComponent(field); }/*w w w. j a va 2 s. co m*/ } }
From source file:com.esofthead.mycollab.module.project.ui.components.GenericTaskTableDisplay.java
License:Open Source License
public GenericTaskTableDisplay(List<TableViewField> displayColumns) { super(ApplicationContextUtil.getSpringBean(ProjectGenericTaskService.class), ProjectGenericTask.class, displayColumns);/* w w w . j a va 2s . c om*/ addGeneratedColumn("name", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(final Table source, final Object itemId, final Object columnId) { HorizontalLayout layout = new HorizontalLayout(); final ProjectGenericTask task = GenericTaskTableDisplay.this.getBeanByIndex(itemId); if (task.getType() != null) { FontIconLabel icon = new FontIconLabel(ProjectAssetsManager.getAsset(task.getType())); layout.addComponent(icon); layout.setComponentAlignment(icon, Alignment.MIDDLE_CENTER); } final ButtonLink b = new ButtonLink(task.getName(), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { fireTableEvent(new TableClickEvent(GenericTaskTableDisplay.this, task, "name")); } }); b.setWidth("100%"); layout.addComponent(b); layout.setExpandRatio(b, 1.0f); layout.setWidth("100%"); return layout; } }); addGeneratedColumn("assignUser", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public Object generateCell(Table source, Object itemId, Object columnId) { final ProjectGenericTask task = GenericTaskTableDisplay.this.getBeanByIndex(itemId); return new UserLink(task.getAssignUser(), task.getAssignUserAvatarId(), task.getAssignUserFullName()); } }); addGeneratedColumn("dueDate", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(final Table source, final Object itemId, final Object columnId) { final ProjectGenericTask task = GenericTaskTableDisplay.this.getBeanByIndex(itemId); return new Label(AppContext.formatDate(task.getDueDate())); } }); }
From source file:com.esofthead.mycollab.module.project.ui.components.TimeLogComp.java
License:Open Source License
public void displayTime(final V bean) { this.removeAllComponents(); this.withSpacing(true).withMargin(new MarginInfo(false, false, false, true)); HorizontalLayout header = new MHorizontalLayout().withSpacing(true).withMargin(false); Label dateInfoHeader = new Label( FontAwesome.CLOCK_O.getHtml() + " " + AppContext.getMessage(TimeTrackingI18nEnum.SUB_INFO_TIME), ContentMode.HTML);/*from ww w. j a v a 2 s . c om*/ dateInfoHeader.setStyleName("info-hdr"); header.addComponent(dateInfoHeader); if (hasEditPermission()) { Button editBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { showEditTimeWindow(bean); } }); editBtn.setStyleName("link"); editBtn.addStyleName("info-hdr"); header.addComponent(editBtn); } this.addComponent(header); MVerticalLayout layout = new MVerticalLayout().withWidth("100%").withSpacing(true) .withMargin(new MarginInfo(false, false, false, true)); double billableHours = getTotalBillableHours(bean); double nonBillableHours = getTotalNonBillableHours(bean); double remainHours = getRemainedHours(bean); layout.addComponent(new Label( String.format(AppContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS), billableHours))); layout.addComponent(new Label(String .format(AppContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS), nonBillableHours))); layout.addComponent(new Label( String.format(AppContext.getMessage(TimeTrackingI18nEnum.OPT_REMAIN_HOURS), remainHours))); this.addComponent(layout); }
From source file:com.esofthead.mycollab.module.project.view.bug.BugRelatedField.java
License:Open Source License
public void displayRelatedBugs(final SimpleBug bug) { this.bug = bug; VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setWidth("100%"); mainLayout.setMargin(true);//from w w w. j a v a 2 s .c o m mainLayout.setSpacing(true); HorizontalLayout layoutAdd = new HorizontalLayout(); layoutAdd.setSpacing(true); Label lbBug = new Label("Bug:"); lbBug.setWidth("70px"); layoutAdd.addComponent(lbBug); layoutAdd.setComponentAlignment(lbBug, Alignment.MIDDLE_LEFT); itemField = new TextField(); itemField.setWidth("300px"); itemField.setNullRepresentation(""); itemField.setReadOnly(true); itemField.setEnabled(true); layoutAdd.addComponent(itemField); layoutAdd.setComponentAlignment(itemField, Alignment.MIDDLE_LEFT); browseBtn = new Button("", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { callItemSelectionWindow(); } }); browseBtn.setIcon(MyCollabResource.newResource(WebResourceIds._16_browseItem)); browseBtn.setStyleName("link"); layoutAdd.addComponent(browseBtn); layoutAdd.setComponentAlignment(browseBtn, Alignment.MIDDLE_LEFT); clearBtn = new Button("", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { setItemFieldValue(""); } }); clearBtn.setIcon(MyCollabResource.newResource("icons/16/clearItem.png")); clearBtn.setStyleName("link"); layoutAdd.addComponent(clearBtn); layoutAdd.setComponentAlignment(clearBtn, Alignment.MIDDLE_LEFT); Label lbIs = new Label("is"); layoutAdd.addComponent(lbIs); layoutAdd.setComponentAlignment(lbIs, Alignment.MIDDLE_LEFT); comboRelation = new BugRelationComboBox(); comboRelation.setWidth("200px"); layoutAdd.addComponent(comboRelation); layoutAdd.setComponentAlignment(comboRelation, Alignment.MIDDLE_LEFT); btnRelate = new Button("Relate"); btnRelate.setStyleName(UIConstants.THEME_GREEN_LINK); btnRelate.setIcon(MyCollabResource.newResource(WebResourceIds._16_addRecord)); ProjectMemberService memberService = ApplicationContextUtil.getSpringBean(ProjectMemberService.class); SimpleProjectMember member = memberService.findMemberByUsername(AppContext.getUsername(), CurrentProjectVariables.getProjectId(), AppContext.getAccountId()); if (member != null) { btnRelate.setEnabled((member.getIsadmin() || (AppContext.getUsername().equals(bug.getAssignuser())) || (AppContext.getUsername().equals(bug.getLogby()))) && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)); } btnRelate.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { if (!itemField.getValue().toString().trim().equals("") && relatedBean != null && !relatedBean.getSummary().equals(bug.getSummary())) { SimpleRelatedBug relatedBug = new SimpleRelatedBug(); relatedBug.setBugid(bug.getId()); relatedBug.setRelatedid(relatedBean.getId()); relatedBug.setRelatetype((String) comboRelation.getValue()); relatedBug.setComment(txtComment.getValue().toString()); relatedBugService.saveWithSession(relatedBug, AppContext.getUsername()); SimpleRelatedBug oppositeRelation = new SimpleRelatedBug(); oppositeRelation.setBugid(relatedBean.getId()); oppositeRelation.setRelatedid(bug.getId()); oppositeRelation.setComment(txtComment.getValue().toString()); if (comboRelation.getValue().toString().equals(BugRelationConstants.PARENT)) { oppositeRelation.setRelatetype(BugRelationConstants.CHILD); } else if (comboRelation.getValue().toString().equals(BugRelationConstants.CHILD)) { oppositeRelation.setRelatetype(BugRelationConstants.PARENT); } else if (comboRelation.getValue().toString().equals(BugRelationConstants.RELATED)) { oppositeRelation.setRelatetype(BugRelationConstants.RELATED); } else if (comboRelation.getValue().toString().equals(BugRelationConstants.BEFORE)) { oppositeRelation.setRelatetype(BugRelationConstants.AFTER); } else if (comboRelation.getValue().toString().equals(BugRelationConstants.AFTER)) { oppositeRelation.setRelatetype(BugRelationConstants.BEFORE); } else if (comboRelation.getValue().toString().equals(BugRelationConstants.DUPLICATED)) { oppositeRelation.setRelatetype(BugRelationConstants.DUPLICATED); BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class); bug.setStatus(BugStatus.Resolved.name()); bug.setResolution(BugResolution.Duplicate.name()); bugService.updateWithSession(bug, AppContext.getUsername()); } relatedBugService.saveWithSession(oppositeRelation, AppContext.getUsername()); setCriteria(); setItemFieldValue(""); txtComment.setValue(""); relatedBean = null; } } }); layoutAdd.addComponent(btnRelate); layoutAdd.setComponentAlignment(btnRelate, Alignment.MIDDLE_LEFT); Label lbInstruction = new Label("<strong>Relate to an existing ticket</strong>", ContentMode.HTML); mainLayout.addComponent(lbInstruction); mainLayout.addComponent(layoutAdd); HorizontalLayout layoutComment = new HorizontalLayout(); layoutComment.setSpacing(true); Label lbComment = new Label("Comment:"); lbComment.setWidth("70px"); layoutComment.addComponent(lbComment); layoutComment.setComponentAlignment(lbComment, Alignment.TOP_LEFT); txtComment = new RichTextArea(); txtComment.setHeight("130px"); txtComment.setWidth("565px"); layoutComment.addComponent(txtComment); layoutComment.setComponentAlignment(txtComment, Alignment.MIDDLE_LEFT); mainLayout.addComponent(layoutComment); tableItem = new DefaultPagedBeanTable<RelatedBugService, BugRelatedSearchCriteria, SimpleRelatedBug>( ApplicationContextUtil.getSpringBean(RelatedBugService.class), SimpleRelatedBug.class, Arrays.asList( new TableViewField(BugI18nEnum.RELATED_BUG_NAME, "bugName", UIConstants.TABLE_EX_LABEL_WIDTH), new TableViewField(BugI18nEnum.RELATED_BUG_TYPE, "relatetype", UIConstants.TABLE_S_LABEL_WIDTH), new TableViewField(BugI18nEnum.RELATED_BUG_COMMENT, "comment", UIConstants.TABLE_EX_LABEL_WIDTH), new TableViewField(null, "id", UIConstants.TABLE_CONTROL_WIDTH))); tableItem.addGeneratedColumn("bugName", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleRelatedBug relatedItem = tableItem.getBeanByIndex(itemId); String bugname = "[%s-%s] %s"; bugname = String.format(bugname, CurrentProjectVariables.getProject().getShortname(), relatedItem.getRelatedid(), relatedItem.getBugName()); BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class); final SimpleBug bug = bugService.findById(relatedItem.getRelatedid(), AppContext.getAccountId()); LabelLink b = new LabelLink(bugname, ProjectLinkBuilder.generateBugPreviewFullLink(bug.getBugkey(), bug.getProjectShortName())); if (StringUtils.isNotBlank(bug.getPriority())) { String iconPriority = ProjectResources.getIconResourceLink12ByBugPriority(bug.getPriority()); b.setIconLink(iconPriority); } if (BugStatus.Verified.name().equals(bug.getStatus())) { b.addStyleName(UIConstants.LINK_COMPLETED); } else if (bug.getDuedate() != null && (bug.getDuedate().before(new GregorianCalendar().getTime()))) { b.addStyleName(UIConstants.LINK_OVERDUE); } b.setWidth("100%"); return b; } }); tableItem.addGeneratedColumn("id", new ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public Object generateCell(Table source, Object itemId, Object columnId) { final SimpleRelatedBug relatedItem = tableItem.getBeanByIndex(itemId); Button deleteBtn = new Button(null, new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { BugRelatedSearchCriteria relateBugIdCriteria = new BugRelatedSearchCriteria(); relateBugIdCriteria.setBugId(new NumberSearchField(relatedItem.getBugid())); relateBugIdCriteria.setRelatedId(new NumberSearchField(relatedItem.getRelatedid())); relatedBugService.removeByCriteria(relateBugIdCriteria, AppContext.getAccountId()); BugRelatedSearchCriteria relateIdCriteria = new BugRelatedSearchCriteria(); relateIdCriteria.setBugId(new NumberSearchField(relatedItem.getRelatedid())); relateIdCriteria.setRelatedId(new NumberSearchField(relatedItem.getBugid())); relatedBugService.removeByCriteria(relateIdCriteria, AppContext.getAccountId()); BugRelatedField.this.setCriteria(); } }); deleteBtn.setStyleName("link"); deleteBtn.setIcon(MyCollabResource.newResource("icons/16/delete.png")); relatedItem.setExtraData(deleteBtn); ProjectMemberService memberService = ApplicationContextUtil .getSpringBean(ProjectMemberService.class); SimpleProjectMember member = memberService.findMemberByUsername(AppContext.getUsername(), CurrentProjectVariables.getProjectId(), AppContext.getAccountId()); if (member != null) { deleteBtn.setEnabled( member.getIsadmin() || (AppContext.getUsername().equals(bug.getAssignuser())) || (AppContext.getUsername().equals(bug.getLogby()))); } return deleteBtn; } }); mainLayout.addComponent(tableItem); setCriteria(); this.setCompositionRoot(mainLayout); }
From source file:com.esofthead.mycollab.module.project.view.bug.BugTableDisplay.java
License:Open Source License
public BugTableDisplay(String viewId, TableViewField requiredColumn, List<TableViewField> displayColumns) { super(ApplicationContextUtil.getSpringBean(BugService.class), SimpleBug.class, viewId, requiredColumn, displayColumns);//from w w w . j a v a2 s.com this.addGeneratedColumn("id", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public Object generateCell(final Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); final Button bugSettingBtn = new Button(null, FontAwesome.COG); bugSettingBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY); final ContextMenu contextMenu = new ContextMenu(); contextMenu.setAsContextMenuOf(bugSettingBtn); contextMenu.addItemClickListener(new ContextMenuItemClickListener() { @Override public void contextMenuItemClicked(ContextMenuItemClickEvent event) { if (((ContextMenuItem) event.getSource()).getData() == null) { return; } String category = ((MenuItemData) ((ContextMenuItem) event.getSource()).getData()) .getAction(); String value = ((MenuItemData) ((ContextMenuItem) event.getSource()).getData()).getKey(); if ("status".equals(category)) { if (AppContext.getMessage(BugStatus.Verified).equals(value)) { UI.getCurrent().addWindow(new ApproveInputWindow(BugTableDisplay.this, bug)); } else if (AppContext.getMessage(BugStatus.InProgress).equals(value)) { bug.setStatus(BugStatus.InProgress.name()); BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class); bugService.updateWithSession(bug, AppContext.getUsername()); } else if (AppContext.getMessage(BugStatus.Open).equals(value)) { UI.getCurrent().addWindow(new ReOpenWindow(BugTableDisplay.this, bug)); } else if (AppContext.getMessage(BugStatus.Resolved).equals(value)) { UI.getCurrent().addWindow(new ResolvedInputWindow(BugTableDisplay.this, bug)); } } else if ("severity".equals(category)) { bug.setSeverity(value); BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class); bugService.updateWithSession(bug, AppContext.getUsername()); refresh(); } else if ("priority".equals(category)) { bug.setPriority(value); BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class); bugService.updateWithSession(bug, AppContext.getUsername()); refresh(); } else if ("action".equals(category)) { if ("edit".equals(value)) { EventBusFactory.getInstance() .post(new BugEvent.GotoEdit(BugTableDisplay.this, bug)); } else if ("delete".equals(value)) { 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()) { BugService bugService = ApplicationContextUtil .getSpringBean(BugService.class); bugService.removeWithSession(bug.getId(), AppContext.getUsername(), AppContext.getAccountId()); refresh(); } } }); } } } }); bugSettingBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)); bugSettingBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { displayContextMenuItem(contextMenu, bug, event.getClientX(), event.getClientY()); } }); return bugSettingBtn; } }); 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 SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); return new ProjectUserLink(bug.getAssignuser(), bug.getAssignUserAvatarId(), bug.getAssignuserFullName()); } }); this.addGeneratedColumn("loguserFullName", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); return new ProjectUserLink(bug.getLogby(), bug.getLoguserAvatarId(), bug.getLoguserFullName()); } }); this.addGeneratedColumn("summary", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); String bugname = "[%s-%s] %s"; bugname = String.format(bugname, CurrentProjectVariables.getProject().getShortname(), bug.getBugkey(), bug.getSummary()); LabelLink b = new LabelLink(bugname, ProjectLinkBuilder.generateBugPreviewFullLink(bug.getBugkey(), bug.getProjectShortName())); if (StringUtils.isNotBlank(bug.getPriority())) { b.setIconLink(ProjectResources.getIconResourceLink12ByBugPriority(bug.getPriority())); } b.setDescription(ProjectTooltipGenerator.generateToolTipBug(AppContext.getUserLocale(), bug, AppContext.getSiteUrl(), AppContext.getTimezone())); if (bug.isCompleted()) { b.addStyleName(UIConstants.LINK_COMPLETED); } else if (bug.isOverdue()) { b.addStyleName(UIConstants.LINK_OVERDUE); } return b; } }); this.addGeneratedColumn("severity", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); Resource iconPriority = new ExternalResource( ProjectResources.getIconResourceLink12ByBugSeverity(bug.getPriority())); Embedded iconEmbedded = new Embedded(null, iconPriority); Label lbPriority = new Label(AppContext.getMessage(BugSeverity.class, bug.getSeverity())); HorizontalLayout containerField = new HorizontalLayout(); containerField.setSpacing(true); containerField.addComponent(iconEmbedded); containerField.addComponent(lbPriority); containerField.setExpandRatio(lbPriority, 1.0f); return containerField; } }); this.addGeneratedColumn("duedate", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); return new Label(AppContext.formatDate(bug.getDuedate())); } }); this.addGeneratedColumn("createdtime", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); return new Label(AppContext.formatDateTime(bug.getCreatedtime())); } }); this.addGeneratedColumn("resolution", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public Object generateCell(Table source, Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); return new Label(AppContext.getMessage(BugResolution.class, bug.getResolution())); } }); this.setWidth("100%"); }
From source file:com.esofthead.mycollab.module.project.view.bug.ComponentListViewImpl.java
License:Open Source License
private ComponentContainer constructTableActionControls() { final CssLayout layoutWrapper = new CssLayout(); layoutWrapper.setWidth("100%"); final HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true);/*w w w . j a v a 2s. c o m*/ layoutWrapper.addStyleName(UIConstants.TABLE_ACTION_CONTROLS); layoutWrapper.addComponent(layout); this.selectOptionButton = new SelectionOptionButton(this.tableItem); layout.addComponent(this.selectOptionButton); this.tableActionControls = new DefaultMassItemActionHandlersContainer(); if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.COMPONENTS)) { tableActionControls.addActionItem(MassItemActionHandler.DELETE_ACTION, FontAwesome.TRASH_O, "delete", AppContext.getMessage(GenericI18Enum.BUTTON_DELETE)); } tableActionControls.addActionItem(MassItemActionHandler.MAIL_ACTION, FontAwesome.ENVELOPE_O, "mail", AppContext.getMessage(GenericI18Enum.BUTTON_MAIL)); tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_PDF_ACTION, FontAwesome.FILE_PDF_O, "export", "export.pdf", AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_PDF)); tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_EXCEL_ACTION, FontAwesome.FILE_EXCEL_O, "export", "export.xlsx", AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_EXCEL)); tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_CSV_ACTION, FontAwesome.FILE_TEXT_O, "export", "export.csv", AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_CSV)); layout.addComponent(this.tableActionControls); layout.addComponent(this.selectedItemsNumberLabel); layout.setComponentAlignment(this.selectedItemsNumberLabel, Alignment.MIDDLE_CENTER); return layoutWrapper; }
From source file:com.esofthead.mycollab.module.project.view.bug.components.BugRowDisplayHandler.java
License:Open Source License
@Override public Component generateRow(SimpleBug bug, int rowIndex) { MVerticalLayout rowContent = new MVerticalLayout().withSpacing(false).withWidth("100%"); final LabelLink defectLink = new LabelLink( "[" + CurrentProjectVariables.getProject().getShortname() + "-" + bug.getBugkey() + "]: " + bug.getSummary(),/*from w ww . j a va 2s . c om*/ ProjectLinkBuilder.generateBugPreviewFullLink(bug.getBugkey(), bug.getProjectShortName())); defectLink.setWidth("100%"); defectLink.setIconLink(ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG)); defectLink.setDescription(ProjectTooltipGenerator.generateToolTipBug(AppContext.getUserLocale(), bug, AppContext.getSiteUrl(), AppContext.getTimezone())); if (bug.isCompleted()) { defectLink.addStyleName(UIConstants.LINK_COMPLETED); } else if (bug.isOverdue()) { defectLink.addStyleName(UIConstants.LINK_OVERDUE); } rowContent.addComponent(defectLink); final LabelHTMLDisplayWidget descInfo = new LabelHTMLDisplayWidget(bug.getDescription()); descInfo.setWidth("100%"); rowContent.addComponent(descInfo); final Label dateInfo = new Label(AppContext.getMessage(DayI18nEnum.LAST_UPDATED_ON, AppContext.formatPrettyTime(bug.getLastupdatedtime()))); dateInfo.setStyleName(UIConstants.WIDGET_ROW_METADATA); rowContent.addComponent(dateInfo); final HorizontalLayout hLayoutAssigneeInfo = new HorizontalLayout(); hLayoutAssigneeInfo.setSpacing(true); final Label assignee = new Label(AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE) + ": "); assignee.setStyleName(UIConstants.WIDGET_ROW_METADATA); hLayoutAssigneeInfo.addComponent(assignee); hLayoutAssigneeInfo.setComponentAlignment(assignee, Alignment.MIDDLE_CENTER); final ProjectUserLink userLink = new ProjectUserLink(bug.getAssignuser(), bug.getAssignUserAvatarId(), bug.getAssignuserFullName(), false, true); hLayoutAssigneeInfo.addComponent(userLink); hLayoutAssigneeInfo.setComponentAlignment(userLink, Alignment.MIDDLE_CENTER); rowContent.addComponent(hLayoutAssigneeInfo); rowContent.setStyleName(UIConstants.WIDGET_ROW); if ((rowIndex + 1) % 2 != 0) { rowContent.addStyleName("odd"); } return rowContent; }
From source file:com.esofthead.mycollab.module.project.view.bug.components.UnresolvedBugsByAssigneeWidget.java
License:Open Source License
public void setSearchCriteria(final BugSearchCriteria searchCriteria) { this.bugSearchCriteria = searchCriteria; this.bodyContent.removeAllComponents(); final BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class); final int totalCount = bugService.getTotalCount(searchCriteria); final List<GroupItem> groupItems = bugService.getAssignedDefectsSummary(searchCriteria); if (!groupItems.isEmpty()) { for (final GroupItem item : groupItems) { final HorizontalLayout assigneeLayout = new HorizontalLayout(); assigneeLayout.setSpacing(true); assigneeLayout.setWidth("100%"); String assignUser = item.getGroupid(); String assignUserFullName = item.getGroupid() == null ? AppContext.getMessage(BugI18nEnum.OPT_UNDEFINED_USER) : item.getGroupname(); if (assignUserFullName == null || "".equals(assignUserFullName.trim())) { assignUserFullName = StringUtils.extractNameFromEmail(assignUser); }// w ww .j a v a 2 s .co m final BugAssigneeButton userLbl = new BugAssigneeButton(assignUser, item.getExtraValue(), assignUserFullName); assigneeLayout.addComponent(userLbl); final ProgressBarIndicator indicator = new ProgressBarIndicator(totalCount, totalCount - item.getValue(), false); indicator.setWidth("100%"); assigneeLayout.addComponent(indicator); assigneeLayout.setExpandRatio(indicator, 1.0f); this.bodyContent.addComponent(assigneeLayout); } } }
From source file:com.esofthead.mycollab.module.project.view.bug.components.UnresolvedBugsByAssigneeWidget2.java
License:Open Source License
public void setSearchCriteria(final BugSearchCriteria searchCriteria) { this.bugSearchCriteria = searchCriteria; this.bodyContent.removeAllComponents(); final BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class); final int totalCount = bugService.getTotalCount(searchCriteria); final List<GroupItem> groupItems = bugService.getAssignedDefectsSummary(searchCriteria); if (!groupItems.isEmpty()) { for (final GroupItem item : groupItems) { final HorizontalLayout assigneeLayout = new HorizontalLayout(); assigneeLayout.setSpacing(true); assigneeLayout.setWidth("100%"); String assignUser = item.getGroupid(); String assignUserFullName = item.getGroupid() == null ? AppContext.getMessage(BugI18nEnum.OPT_UNDEFINED_USER) : item.getGroupname(); if (assignUserFullName == null || "".equals(assignUserFullName.trim())) { assignUserFullName = StringUtils.extractNameFromEmail(assignUser); }/* w w w. j a v a 2 s . c o m*/ final BugAssigneeLink userLbl = new BugAssigneeLink(assignUser, item.getExtraValue(), assignUserFullName); assigneeLayout.addComponent(userLbl); final ProgressBarIndicator indicator = new ProgressBarIndicator(totalCount, totalCount - item.getValue(), false); indicator.setWidth("100%"); assigneeLayout.addComponent(indicator); assigneeLayout.setExpandRatio(indicator, 1.0f); this.bodyContent.addComponent(assigneeLayout); } } }