List of usage examples for com.vaadin.ui Button Button
public Button(Resource icon)
From source file:com.esofthead.mycollab.module.crm.view.opportunity.OpportunitySimpleSearchPanel.java
License:Open Source License
private void createBasicSearchLayout() { layoutSearchPane = new GridLayout(3, 3); layoutSearchPane.setSpacing(true);/* ww w . j av a 2 s. co m*/ final ValueComboBox group = new ValueComboBox(false, "Name", "Account Name", "Sales Stage", AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE)); group.select("Name"); group.setImmediate(true); group.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { removeComponents(); String searchType = (String) group.getValue(); if (searchType.equals("Name")) { addTextFieldSearch(); } else if (searchType.equals("Account Name")) { addTextFieldSearch(); } else if (searchType.equals("Sales Stage")) { addTextFieldSearch(); } else if (searchType.equals(AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE))) { addUserListSelectField(); } } }); layoutSearchPane.addComponent(group, 1, 0); layoutSearchPane.setComponentAlignment(group, Alignment.MIDDLE_CENTER); addTextFieldSearch(); Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH)); searchBtn.setStyleName(UIConstants.THEME_GREEN_LINK); searchBtn.setIcon(FontAwesome.SEARCH); searchBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { searchCriteria = new OpportunitySearchCriteria(); searchCriteria.setSaccountid(new NumberSearchField(SearchField.AND, AppContext.getAccountId())); String searchType = (String) group.getValue(); if (StringUtils.isNotBlank(searchType)) { if (textValueField != null) { String strSearch = textValueField.getValue(); if (StringUtils.isNotBlank(strSearch)) { if (searchType.equals("Name")) { searchCriteria .setOpportunityName(new StringSearchField(SearchField.AND, strSearch)); } } } if (userBox != null) { String user = (String) userBox.getValue(); if (StringUtils.isNotBlank(user)) { searchCriteria.setAssignUsers( new SetSearchField<String>(SearchField.AND, new String[] { user })); } } } OpportunitySimpleSearchPanel.this.notifySearchHandler(searchCriteria); } }); layoutSearchPane.addComponent(searchBtn, 2, 0); layoutSearchPane.setComponentAlignment(searchBtn, Alignment.MIDDLE_CENTER); this.setCompositionRoot(layoutSearchPane); }
From source file:com.esofthead.mycollab.module.file.view.components.FileDownloadWindow.java
License:Open Source License
private void constructBody() { final MVerticalLayout layout = new MVerticalLayout(); final Embedded iconEmbed = new Embedded(); iconEmbed.setSource(MyCollabResource.newResource("icons/page_white.png")); layout.with(iconEmbed).withAlign(iconEmbed, Alignment.MIDDLE_CENTER); final GridFormLayoutHelper info = new GridFormLayoutHelper(1, 4, "100%", "80px", Alignment.TOP_LEFT); info.getLayout().setWidth("100%"); info.getLayout().setMargin(new MarginInfo(false, true, false, true)); info.getLayout().setSpacing(false);// ww w . j a va 2s . c o m if (this.content.getDescription() != null) { final Label desvalue = new Label(); if (!this.content.getDescription().equals("")) { desvalue.setData(this.content.getDescription()); } else { desvalue.setValue(" "); desvalue.setContentMode(ContentMode.HTML); } info.addComponent(desvalue, "Description", 0, 0); } final Label author = new Label(this.content.getCreatedBy()); info.addComponent(author, "Created by", 0, 1); final Label size = new Label(ResourceUtils.getVolumeDisplay(this.content.getSize())); info.addComponent(size, "Size", 0, 2); final Label dateCreate = new Label(AppContext.formatDate(this.content.getCreated().getTime())); info.addComponent(dateCreate, "Date created", 0, 3); layout.addComponent(info.getLayout()); final MHorizontalLayout buttonControls = new MHorizontalLayout(); buttonControls.setSpacing(true); buttonControls.setMargin(new MarginInfo(true, false, true, false)); final Button downloadBtn = new Button("Download"); List<Resource> resources = new ArrayList<Resource>(); resources.add(content); StreamResource downloadResource = StreamDownloadResourceUtil.getStreamResourceSupportExtDrive(resources); FileDownloader fileDownloader = new FileDownloader(downloadResource); fileDownloader.extend(downloadBtn); downloadBtn.addStyleName(UIConstants.THEME_GREEN_LINK); buttonControls.with(downloadBtn).withAlign(downloadBtn, Alignment.MIDDLE_CENTER); final Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { FileDownloadWindow.this.close(); } }); cancelBtn.addStyleName(UIConstants.THEME_GRAY_LINK); buttonControls.with(cancelBtn).withAlign(cancelBtn, Alignment.MIDDLE_CENTER); layout.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_CENTER); this.setContent(layout); }
From source file:com.esofthead.mycollab.module.project.ui.components.ProjectCommentInput.java
License:Open Source License
ProjectCommentInput(final ReloadableComponent component, final CommentType typeVal, final Integer extraTypeIdVal, final boolean cancelButtonEnable, final boolean isSendingEmailRelay, final Class<? extends SendingRelayEmailNotificationAction> emailHandler) { super();//from w ww . j a v a2s .co m this.withWidth("100%").withStyleName("message"); final SimpleUser currentUser = AppContext.getSession(); MVerticalLayout userBlock = new MVerticalLayout().withMargin(false).withWidth("80px"); userBlock.setDefaultComponentAlignment(Alignment.TOP_CENTER); ClickListener gotoUser = new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { EventBusFactory.getInstance() .post(new ProjectMemberEvent.GotoRead(this, currentUser.getUsername())); } }; Button userAvatarBtn = UserAvatarControlFactory.createUserAvatarButtonLink(currentUser.getAvatarid(), currentUser.getDisplayName()); userAvatarBtn.addClickListener(gotoUser); userBlock.addComponent(userAvatarBtn); Button userName = new Button(currentUser.getDisplayName()); userName.setStyleName("user-name"); userName.addStyleName("link"); userName.addStyleName(UIConstants.WORD_WRAP); userName.addClickListener(gotoUser); userBlock.addComponent(userName); this.addComponent(userBlock); MVerticalLayout textAreaWrap = new MVerticalLayout().withWidth("100%").withStyleName("message-container"); this.addComponent(textAreaWrap); this.setExpandRatio(textAreaWrap, 1.0f); type = typeVal; extraTypeId = extraTypeIdVal; commentArea = new RichTextArea(); commentArea.setWidth("100%"); commentArea.setHeight("200px"); final AttachmentPanel attachments = new AttachmentPanel(); final MHorizontalLayout controlsLayout = new MHorizontalLayout().withSpacing(true).withMargin(false) .withWidth("100%"); final MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments); uploadExt.addComponent(attachments); controlsLayout.with(uploadExt).withAlign(uploadExt, Alignment.TOP_LEFT).expand(uploadExt); final Label emptySpace = new Label(); controlsLayout.addComponent(emptySpace); controlsLayout.setExpandRatio(emptySpace, 1.0f); if (cancelButtonEnable) { 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) { component.cancel(); } }); cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK); controlsLayout.addComponent(cancelBtn); controlsLayout.setComponentAlignment(cancelBtn, Alignment.TOP_RIGHT); } final Button newCommentBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_POST), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { final Comment comment = new Comment(); comment.setComment(Jsoup.clean(commentArea.getValue(), Whitelist.relaxed())); comment.setCreatedtime(new GregorianCalendar().getTime()); comment.setCreateduser(AppContext.getUsername()); comment.setSaccountid(AppContext.getAccountId()); comment.setType(type.toString()); comment.setTypeid("" + typeId); comment.setExtratypeid(extraTypeId); final CommentService commentService = ApplicationContextUtil .getSpringBean(CommentService.class); int commentId = commentService.saveWithSession(comment, AppContext.getUsername(), isSendingEmailRelay, emailHandler); String attachmentPath = AttachmentUtils.getProjectEntityCommentAttachmentPath(typeVal, AppContext.getAccountId(), CurrentProjectVariables.getProjectId(), typeId, commentId); if (!"".equals(attachmentPath)) { attachments.saveContentsToRepo(attachmentPath); } // save success, clear comment area and load list // comments again commentArea.setValue(""); attachments.removeAllAttachmentsDisplay(); component.reload(); } }); newCommentBtn.setStyleName(UIConstants.THEME_GREEN_LINK); newCommentBtn.setIcon(FontAwesome.SEND); controlsLayout.with(newCommentBtn).withAlign(newCommentBtn, Alignment.TOP_RIGHT); textAreaWrap.addComponent(commentArea); textAreaWrap.addComponent(controlsLayout); }
From source file:com.esofthead.mycollab.module.project.ui.components.TagViewComponent.java
License:Open Source License
private HorizontalLayout createSaveTagComp() { final MHorizontalLayout layout = new MHorizontalLayout(); final SuggestField field = new SuggestField(); field.setInputPrompt("Enter tag name"); field.setMinimumQueryCharacters(2);//from w ww . ja va 2 s . c o m field.setSuggestionConverter(new TagSuggestionConverter()); field.setSuggestionHandler(new SuggestField.SuggestionHandler() { @Override public List<Object> searchItems(String query) { tagQuery = query; return handleSearchQuery(query); } }); Button addBtn = new Button("Add"); addBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { String tagName = (field.getValue() == null) ? tagQuery : field.getValue().toString().trim(); if (!tagName.equals("")) { Tag tag = new Tag(); tag.setName(tagName); tag.setType(type); tag.setTypeid(typeId + ""); tag.setSaccountid(AppContext.getAccountId()); tag.setExtratypeid(CurrentProjectVariables.getProjectId()); int result = tagService.saveWithSession(tag, AppContext.getUsername()); if (result > 0) { TagViewComponent.this.removeComponent(layout); TagViewComponent.this.addComponent(new TagBlock(tag)); TagViewComponent.this.addComponent(createAddTagBtn()); } else { TagViewComponent.this.removeComponent(layout); TagViewComponent.this.addComponent(createAddTagBtn()); } } else { NotificationUtil.showWarningNotification("The tag value must have more than 2 characters"); } tagQuery = ""; } }); layout.with(field, addBtn); return layout; }
From source file:com.esofthead.mycollab.module.project.view.bug.BugSimpleSearchPanel.java
License:Open Source License
private void createBasicSearchLayout() { layoutSearchPane = new GridLayout(5, 3); layoutSearchPane.setSpacing(true);// w w w .j a v a 2 s .c o m addTextFieldSearch(); final CheckBox chkIsOpenBug = new CheckBox("Only Open Bugs"); layoutSearchPane.addComponent(chkIsOpenBug, 2, 0); layoutSearchPane.setComponentAlignment(chkIsOpenBug, Alignment.MIDDLE_CENTER); Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH)); searchBtn.setStyleName(UIConstants.THEME_GREEN_LINK); searchBtn.setIcon(FontAwesome.SEARCH); searchBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { searchCriteria = new BugSearchCriteria(); searchCriteria.setProjectId( new NumberSearchField(SearchField.AND, CurrentProjectVariables.getProject().getId())); searchCriteria.setSummary(new StringSearchField(textValueField.getValue().trim())); if (chkIsOpenBug.getValue()) { searchCriteria.setStatuses(new SetSearchField<>(SearchField.AND, new String[] { BugStatus.InProgress.name(), BugStatus.Open.name(), BugStatus.ReOpened.name() })); } BugSimpleSearchPanel.this.notifySearchHandler(searchCriteria); } }); layoutSearchPane.addComponent(searchBtn, 3, 0); layoutSearchPane.setComponentAlignment(searchBtn, Alignment.MIDDLE_CENTER); Button clearBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLEAR)); clearBtn.setStyleName(UIConstants.THEME_GRAY_LINK); clearBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { textValueField.setValue(""); } }); layoutSearchPane.addComponent(clearBtn, 4, 0); layoutSearchPane.setComponentAlignment(clearBtn, Alignment.MIDDLE_CENTER); this.setCompositionRoot(layoutSearchPane); }
From source file:com.esofthead.mycollab.module.project.view.bug.components.BugSelectionField.java
License:Open Source License
@Override protected Component initContent() { MHorizontalLayout layout = new MHorizontalLayout(); Button browseBtn = new Button(FontAwesome.ELLIPSIS_H); browseBtn.addStyleName(UIConstants.BUTTON_OPTION); browseBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING); browseBtn.addClickListener(new Button.ClickListener() { @Override//from w w w . j a v a 2 s .c o m public void buttonClick(Button.ClickEvent event) { UI.getCurrent().addWindow(new BugSelectionWindow(BugSelectionField.this)); } }); layout.with(suggestField, new Label("or browse"), browseBtn); return layout; }
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);/*from w w w. ja v a 2s . 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.ProjectAddBaseTemplateWindow.java
License:Open Source License
public ProjectAddBaseTemplateWindow() { super(AppContext.getMessage(ProjectI18nEnum.OPT_CREATE_PROJECT_FROM_TEMPLATE)); this.setModal(true); this.setClosable(true); this.setResizable(false); this.setWidth("550px"); MVerticalLayout content = new MVerticalLayout(); GridFormLayoutHelper gridFormLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(1, 3); final TemplateProjectComboBox templateProjectComboBox = new TemplateProjectComboBox(); Button helpBtn = new Button(""); helpBtn.setIcon(FontAwesome.QUESTION_CIRCLE); helpBtn.addStyleName(UIConstants.BUTTON_ACTION); helpBtn.setDescription(AppContext.getMessage(ProjectI18nEnum.OPT_MARK_TEMPLATE_HELP)); gridFormLayoutHelper/*w w w.j a va2 s . c om*/ .addComponent( new MHorizontalLayout().withFullWidth().with(templateProjectComboBox, helpBtn) .expand(templateProjectComboBox), AppContext.getMessage(ProjectI18nEnum.FORM_TEMPLATE), 0, 0); final TextField prjNameField = new TextField(); gridFormLayoutHelper.addComponent(prjNameField, AppContext.getMessage(GenericI18Enum.FORM_NAME), 0, 1); final TextField prjKeyField = new TextField(); gridFormLayoutHelper.addComponent(prjKeyField, AppContext.getMessage(ProjectI18nEnum.FORM_SHORT_NAME), 0, 2); MHorizontalLayout buttonControls = new MHorizontalLayout(); content.with(gridFormLayoutHelper.getLayout(), buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT); Button okBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_OK), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { SimpleProject templatePrj = (SimpleProject) templateProjectComboBox.getValue(); if (templatePrj == null) { NotificationUtil.showErrorNotification( AppContext.getMessage(ProjectI18nEnum.ERROR_MUST_CHOOSE_TEMPLATE_PROJECT)); return; } String newPrjName = prjNameField.getValue(); if (newPrjName.length() == 0) { NotificationUtil.showErrorNotification("Project name must be not null"); return; } String newPrjKey = prjKeyField.getValue(); if (newPrjKey.length() > 3 || newPrjKey.length() == 0) { NotificationUtil .showErrorNotification("Project key must be not null and less than 3 characters"); return; } ProjectTemplateService projectTemplateService = AppContextUtil .getSpringBean(ProjectTemplateService.class); if (projectTemplateService != null) { Integer newProjectId = projectTemplateService.cloneProject(templatePrj.getId(), newPrjName, newPrjKey, AppContext.getAccountId(), AppContext.getUsername()); EventBusFactory.getInstance().post(new ProjectEvent.GotoMyProject(this, new PageActionChain(new ProjectScreenData.Goto(newProjectId)))); close(); } } }); okBtn.setIcon(FontAwesome.SAVE); okBtn.addStyleName(UIConstants.BUTTON_ACTION); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { close(); } }); cancelBtn.addStyleName(UIConstants.BUTTON_OPTION); buttonControls.with(cancelBtn, okBtn); this.setContent(content); }
From source file:com.esofthead.mycollab.module.project.view.ProjectBreadcrumb.java
License:Open Source License
public void gotoMessageList() { this.select(0); this.addLink(new Button(AppContext.getMessage(BreadcrumbI18nEnum.MESSAGES))); AppContext.addFragment(ProjectLinkGenerator.generateMessagesLink(project.getId()), AppContext.getMessage(MessageI18nEnum.VIEW_LIST_TITLE)); }
From source file:com.esofthead.mycollab.module.project.view.ProjectBreadcrumb.java
License:Open Source License
public void gotoRiskList() { this.select(0); this.addLink(new Button(AppContext.getMessage(BreadcrumbI18nEnum.RISKS))); AppContext.addFragment(ProjectLinkGenerator.generateRisksLink(project.getId()), AppContext.getMessage(RiskI18nEnum.VIEW_LIST_TITLE)); }