List of usage examples for com.vaadin.ui VerticalLayout addComponent
@Override public void addComponent(Component c)
From source file:com.esofthead.mycollab.module.project.view.bug.BugListViewImpl.java
License:Open Source License
private ComponentContainer constructTableActionControls() { final MHorizontalLayout layout = new MHorizontalLayout().withWidth("100%"); final Label lbEmpty = new Label(""); layout.with(lbEmpty).expand(lbEmpty); MHorizontalLayout buttonControls = new MHorizontalLayout(); layout.addComponent(buttonControls); Button customizeViewBtn = new Button("", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override//from ww w . j a va 2 s . c o m public void buttonClick(ClickEvent event) { UI.getCurrent().addWindow(new BugListCustomizeWindow(BugListView.VIEW_DEF_ID, tableItem)); } }); customizeViewBtn.setIcon(FontAwesome.COG); customizeViewBtn.setDescription("Layout Options"); customizeViewBtn.setStyleName(UIConstants.THEME_GRAY_LINK); buttonControls.addComponent(customizeViewBtn); PopupButton exportButtonControl = new PopupButton(); exportButtonControl.addStyleName(UIConstants.THEME_GRAY_LINK); exportButtonControl.setIcon(FontAwesome.EXTERNAL_LINK); exportButtonControl.setDescription(AppContext.getMessage(FileI18nEnum.EXPORT_FILE)); VerticalLayout popupButtonsControl = new VerticalLayout(); exportButtonControl.setContent(popupButtonsControl); Button exportPdfBtn = new Button(AppContext.getMessage(FileI18nEnum.PDF)); StreamWrapperFileDownloader fileDownloader = new StreamWrapperFileDownloader(new StreamResourceFactory() { @Override public StreamResource getStreamResource() { String title = "Bugs of Project " + ((CurrentProjectVariables.getProject() != null && CurrentProjectVariables.getProject().getName() != null) ? CurrentProjectVariables.getProject().getName() : ""); BugSearchCriteria searchCriteria = new BugSearchCriteria(); searchCriteria.setProjectId( new NumberSearchField(SearchField.AND, CurrentProjectVariables.getProject().getId())); return new StreamResource(new SimpleGridExportItemsStreamResource.AllItems<>(title, new RpParameterBuilder(tableItem.getDisplayColumns()), ReportExportType.PDF, ApplicationContextUtil.getSpringBean(BugService.class), searchCriteria, SimpleBug.class), "export.pdf"); } }); fileDownloader.extend(exportPdfBtn); exportPdfBtn.setIcon(FontAwesome.FILE_PDF_O); exportPdfBtn.setStyleName("link"); popupButtonsControl.addComponent(exportPdfBtn); Button exportExcelBtn = new Button(AppContext.getMessage(FileI18nEnum.EXCEL)); StreamWrapperFileDownloader excelDownloader = new StreamWrapperFileDownloader(new StreamResourceFactory() { @Override public StreamResource getStreamResource() { String title = "Bugs of Project " + ((CurrentProjectVariables.getProject() != null && CurrentProjectVariables.getProject().getName() != null) ? CurrentProjectVariables.getProject().getName() : ""); BugSearchCriteria searchCriteria = new BugSearchCriteria(); searchCriteria.setProjectId( new NumberSearchField(SearchField.AND, CurrentProjectVariables.getProject().getId())); return new StreamResource(new SimpleGridExportItemsStreamResource.AllItems<>(title, new RpParameterBuilder(tableItem.getDisplayColumns()), ReportExportType.EXCEL, ApplicationContextUtil.getSpringBean(BugService.class), searchCriteria, SimpleBug.class), "export.xlsx"); } }); excelDownloader.extend(exportExcelBtn); exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O); exportExcelBtn.setStyleName("link"); popupButtonsControl.addComponent(exportExcelBtn); Button exportCsvBtn = new Button(AppContext.getMessage(FileI18nEnum.CSV)); StreamWrapperFileDownloader csvFileDownloader = new StreamWrapperFileDownloader( new StreamResourceFactory() { @Override public StreamResource getStreamResource() { String title = "Bugs of Project " + ((CurrentProjectVariables.getProject() != null && CurrentProjectVariables.getProject().getName() != null) ? CurrentProjectVariables.getProject().getName() : ""); BugSearchCriteria searchCriteria = new BugSearchCriteria(); searchCriteria.setProjectId(new NumberSearchField(SearchField.AND, CurrentProjectVariables.getProject().getId())); return new StreamResource(new SimpleGridExportItemsStreamResource.AllItems<>(title, new RpParameterBuilder(tableItem.getDisplayColumns()), ReportExportType.CSV, ApplicationContextUtil.getSpringBean(BugService.class), searchCriteria, SimpleBug.class), "export.csv"); } }); csvFileDownloader.extend(exportCsvBtn); exportCsvBtn.setIcon(FontAwesome.FILE_TEXT_O); exportCsvBtn.setStyleName("link"); popupButtonsControl.addComponent(exportCsvBtn); buttonControls.addComponent(exportButtonControl); return layout; }
From source file:com.esofthead.mycollab.module.project.view.bug.BugListWidget.java
License:Open Source License
public BugListWidget(final String title, final String backBtnLabel, final BugSearchCriteria bugSearchCriteria, final IBugReportDisplayContainer bugReportDisplayContainer) { super(title, new VerticalLayout()); final VerticalLayout contentLayout = (VerticalLayout) this.bodyContent; contentLayout.setSpacing(true);//from ww w. ja va2s.c o m contentLayout.setWidth("100%"); final Button backToBugReportsBtn = new Button(backBtnLabel, new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { bugReportDisplayContainer.displayBugReports(); } }); // contentLayout.addComponent(backToBugReportsBtn); final VerticalLayout backBtnWrapper = new VerticalLayout(); backBtnWrapper.setMargin(new MarginInfo(false, false, true, false)); backToBugReportsBtn.setStyleName(UIConstants.THEME_GREEN_LINK); backBtnWrapper.addComponent(backToBugReportsBtn); this.addComponentAsFirst(backBtnWrapper); this.tableItem = new BugTableDisplay(BugTableFieldDef.action, Arrays.asList(BugTableFieldDef.summary, BugTableFieldDef.assignUser, BugTableFieldDef.severity, BugTableFieldDef.resolution, BugTableFieldDef.duedate)); this.tableItem.addTableListener(new TableClickListener() { private static final long serialVersionUID = 1L; @Override public void itemClick(final TableClickEvent event) { final SimpleBug bug = (SimpleBug) event.getData(); if ("summary".equals(event.getFieldName())) { EventBusFactory.getInstance().post(new BugEvent.GotoRead(BugListWidget.this, bug.getId())); } } }); this.tableItem.setWidth("100%"); contentLayout.addComponent(this.tableItem); this.setSearchCriteria(bugSearchCriteria); }
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 va2 s .c om 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.BugSelectionWindow.java
License:Open Source License
public BugSelectionWindow(BugRelatedField fieldSelection) { super("Bug Lookup"); this.setWidth("900px"); this.setHeight("500px"); this.fieldSelection = fieldSelection; this.setModal(true); this.setResizable(false); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true);/* w w w.ja v a 2s. co m*/ layout.setMargin(true); BugSimpleSearchPanel contactSimpleSearchPanel = new BugSimpleSearchPanel(); contactSimpleSearchPanel.addSearchHandler(new SearchHandler<BugSearchCriteria>() { @Override public void onSearch(BugSearchCriteria criteria) { tableItem.setSearchCriteria(criteria); } }); layout.addComponent(contactSimpleSearchPanel); createBugList(); layout.addComponent(tableItem); this.setContent(layout); }
From source file:com.esofthead.mycollab.module.project.view.bug.ComponentFormLayoutFactory.java
License:Open Source License
@Override public Layout getLayout() { final VerticalLayout layout = new VerticalLayout(); this.gridFormLayout = new GridFormLayoutHelper(2, 3, "100%", "167px", Alignment.TOP_LEFT); this.gridFormLayout.getLayout().setWidth("100%"); this.gridFormLayout.getLayout().setMargin(false); this.gridFormLayout.getLayout().addStyleName("colored-gridlayout"); layout.addComponent(this.gridFormLayout.getLayout()); return layout; }
From source file:com.esofthead.mycollab.module.project.view.bug.ResolvedInputWindow.java
License:Open Source License
ResolvedInputWindow(final IBugCallbackStatusComp callbackForm, final SimpleBug bug) { super("Resolve bug '" + bug.getSummary() + "'"); this.bug = bug; this.callbackForm = callbackForm; VerticalLayout contentLayout = new VerticalLayout(); this.setWidth("800px"); this.setResizable(false); this.setModal(true); this.editForm = new EditForm(); contentLayout.addComponent(this.editForm); this.editForm.setBean(bug); contentLayout.setMargin(new MarginInfo(false, false, true, false)); this.setContent(contentLayout); this.center(); }
From source file:com.esofthead.mycollab.module.project.view.bug.VersionFormLayoutFactory.java
License:Open Source License
@Override public Layout getLayout() { this.informationLayout = new GridFormLayoutHelper(2, 3, "100%", "167px", Alignment.TOP_LEFT); this.informationLayout.getLayout().setWidth("100%"); this.informationLayout.getLayout().setMargin(false); this.informationLayout.getLayout().addStyleName("colored-gridlayout"); final VerticalLayout layout = new VerticalLayout(); layout.addComponent(this.informationLayout.getLayout()); return layout; }
From source file:com.esofthead.mycollab.module.project.view.bug.WontFixExplainWindow.java
License:Open Source License
WontFixExplainWindow(final IBugCallbackStatusComp callbackForm, final SimpleBug bug) { super("Won't fix bug '" + bug.getSummary() + "'"); this.bug = bug; this.callbackForm = callbackForm; this.setWidth("750px"); this.setResizable(false); this.setModal(true); VerticalLayout contentLayout = new VerticalLayout(); contentLayout.setMargin(new MarginInfo(false, false, true, false)); EditForm editForm = new EditForm(); contentLayout.addComponent(editForm); editForm.setBean(bug);//from w w w . j a v a 2 s. co m this.setContent(contentLayout); this.center(); }
From source file:com.esofthead.mycollab.module.project.view.FollowingTicketViewImpl.java
License:Open Source License
public FollowingTicketViewImpl() { this.setWidth("100%"); final MVerticalLayout headerWrapper = new MVerticalLayout().withSpacing(false).withMargin(false) .withWidth("100%").withStyleName("projectfeed-hdr-wrapper"); final MHorizontalLayout header = new MHorizontalLayout().withMargin(false).withWidth("100%"); final Label layoutHeader = new Label(FontAwesome.EYE.getHtml() + " My Following Tickets", ContentMode.HTML); layoutHeader.addStyleName("h2"); header.with(layoutHeader).withAlign(layoutHeader, Alignment.MIDDLE_LEFT).expand(layoutHeader); headerWrapper.addComponent(header);/* w w w. ja v a 2 s . c o m*/ this.addComponent(headerWrapper); MHorizontalLayout controlBtns = new MHorizontalLayout().withSpacing(false) .withMargin(new MarginInfo(true, false, true, false)).withWidth("100%"); final MVerticalLayout contentWrapper = new MVerticalLayout().withSpacing(false).withMargin(false) .withWidth("100%"); contentWrapper.addStyleName("content-wrapper"); contentWrapper.addComponent(controlBtns); this.addComponent(contentWrapper); final Button backBtn = new Button(AppContext.getMessage(FollowerI18nEnum.BUTTON_BACK_TO_WORKBOARD)); backBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { EventBusFactory.getInstance() .post(new ShellEvent.GotoProjectModule(FollowingTicketViewImpl.this, null)); } }); backBtn.addStyleName(UIConstants.THEME_GREEN_LINK); backBtn.setIcon(FontAwesome.ARROW_LEFT); controlBtns.addComponent(backBtn); controlBtns.setExpandRatio(backBtn, 1.0f); Button exportBtn = new Button("Export", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { exportButtonControl.setPopupVisible(true); } }); exportButtonControl = new SplitButton(exportBtn); exportButtonControl.setWidthUndefined(); exportButtonControl.addStyleName(UIConstants.THEME_GRAY_LINK); exportButtonControl.setIcon(FontAwesome.EXTERNAL_LINK); VerticalLayout popupButtonsControl = new VerticalLayout(); exportButtonControl.setContent(popupButtonsControl); Button exportPdfBtn = new Button("Pdf"); FileDownloader pdfDownloader = new FileDownloader(constructStreamResource(ReportExportType.PDF)); pdfDownloader.extend(exportPdfBtn); exportPdfBtn.setIcon(FontAwesome.FILE_PDF_O); exportPdfBtn.setStyleName("link"); popupButtonsControl.addComponent(exportPdfBtn); Button exportExcelBtn = new Button("Excel"); FileDownloader excelDownloader = new FileDownloader(constructStreamResource(ReportExportType.EXCEL)); excelDownloader.extend(exportExcelBtn); exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O); exportExcelBtn.setStyleName("link"); popupButtonsControl.addComponent(exportExcelBtn); controlBtns.addComponent(exportButtonControl); searchPanel = new FollowingTicketSearchPanel(); contentWrapper.addComponent(searchPanel); this.ticketTable = new FollowingTicketTableDisplay(); this.ticketTable.addStyleName("full-border-table"); this.ticketTable.setMargin(new MarginInfo(true, false, false, false)); contentWrapper.addComponent(this.ticketTable); }
From source file:com.esofthead.mycollab.module.project.view.milestone.MilestoneAddWindow.java
License:Open Source License
public MilestoneAddWindow(final SimpleMilestone milestone) { if (milestone.getId() == null) { setCaption("New milestone"); } else {/*w w w .java 2 s . c om*/ setCaption("Edit milestone"); } this.setWidth("800px"); this.setModal(true); this.setResizable(false); VerticalLayout content = new VerticalLayout(); this.setContent(content); final AdvancedEditBeanForm<SimpleMilestone> editForm = new AdvancedEditBeanForm<>(); content.addComponent(editForm); editForm.setFormLayoutFactory(new DefaultDynaFormLayout(ProjectTypeConstants.MILESTONE, MilestoneDefaultFormLayoutFactory.getForm(), Milestone.Field.id.name())); final MilestoneEditFormFieldFactory milestoneEditFormFieldFactory = new MilestoneEditFormFieldFactory( editForm); editForm.setBeanFormFieldFactory(milestoneEditFormFieldFactory); editForm.setBean(milestone); MHorizontalLayout buttonControls = new MHorizontalLayout() .withMargin(new MarginInfo(true, true, true, false)); buttonControls.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT); Button updateAllBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_UPDATE_OTHER_FIELDS), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { EventBusFactory.getInstance() .post(new MilestoneEvent.GotoAdd(MilestoneAddWindow.this, milestone)); close(); } }); updateAllBtn.addStyleName(UIConstants.BUTTON_LINK); Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { if (editForm.validateForm()) { MilestoneService milestoneService = AppContextUtil.getSpringBean(MilestoneService.class); Integer milestoneId; if (milestone.getId() == null) { milestoneId = milestoneService.saveWithSession(milestone, AppContext.getUsername()); } else { milestoneService.updateWithSession(milestone, AppContext.getUsername()); milestoneId = milestone.getId(); } AttachmentUploadField uploadField = milestoneEditFormFieldFactory.getAttachmentUploadField(); String attachPath = AttachmentUtils.getProjectEntityAttachmentPath(AppContext.getAccountId(), milestone.getProjectid(), ProjectTypeConstants.MILESTONE, "" + milestone.getId()); uploadField.saveContentsToRepo(attachPath); EventBusFactory.getInstance() .post(new MilestoneEvent.NewMilestoneAdded(MilestoneAddWindow.this, milestoneId)); EventBusFactory.getInstance().post(new AssignmentEvent.NewAssignmentAdd(MilestoneAddWindow.this, ProjectTypeConstants.MILESTONE, milestoneId)); close(); } } }); saveBtn.setIcon(FontAwesome.SAVE); saveBtn.setStyleName(UIConstants.BUTTON_ACTION); saveBtn.setClickShortcut(ShortcutAction.KeyCode.ENTER); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { close(); } }); cancelBtn.setStyleName(UIConstants.BUTTON_OPTION); buttonControls.with(updateAllBtn, cancelBtn, saveBtn); content.addComponent(buttonControls); content.setComponentAlignment(buttonControls, Alignment.MIDDLE_RIGHT); }