List of usage examples for com.vaadin.ui Button Button
public Button(Resource icon)
From source file:cib.ladnyik.MyVaadinApplication.java
License:Apache License
@Override public void init() { Workbook wb = new XSSFWorkbook(); window = new Window("My Vaadin Application"); setMainWindow(window);//from w w w.j a va2 s . c om Button button = new Button("Click Me Two Times Three Times XXX"); button.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { window.addComponent(new Label("Thank you for clicking")); System.out.println("Thank you for clicking"); } }); window.addComponent(button); }
From source file:cirad.cgh.vcf2fasta.view.Vcf2fastaForm.java
License:Open Source License
private Button getButton(String caption) { Button button = new Button(caption); button.setImmediate(true);// w ww.jav a2s .c o m button.setHtmlContentAllowed(true); return button; }
From source file:com.anothernode.ballkontrolle.BallkontrolleUI.java
License:Open Source License
@Override protected void init(VaadinRequest request) { final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true);//from w w w. ja v a 2s . c o m setContent(layout); Label team1Player1 = new Label(""); Label team1Player2 = new Label(""); Label team2Player1 = new Label(""); Label team2Player2 = new Label(""); final Button button = new Button("Draw Teams"); button.addClickListener(event -> { final Drawing drawing = new Drawing(Data.summonPlayers()); team1Player1.setValue(drawing.getTeam1().getPlayer1().toString()); team1Player2.setValue(drawing.getTeam1().getPlayer2().toString()); team2Player1.setValue(drawing.getTeam2().getPlayer1().toString()); team2Player2.setValue(drawing.getTeam2().getPlayer2().toString()); }); layout.addComponent(button); layout.addComponent(new Label("Team 1:")); layout.addComponent(team1Player1); layout.addComponent(team1Player2); layout.addComponent(new Label("Team 2:")); layout.addComponent(team2Player1); layout.addComponent(team2Player2); }
From source file:com.anphat.customer.controller.CustomerContactController.java
private void addButtonAddContactOnTblTermInfo(CustomPageTableFilter tbl) { tbl.addGeneratedColumn("btnAddContact", new CustomTable.ColumnGenerator() { @Override/*from w w w . j a v a2s . co m*/ public Object generateCell(CustomTable source, Object itemId, Object columnId) { TermInformationDTO term = (TermInformationDTO) itemId; CustomerContactDTO contactDTO = term.convert2CustomerContact(); StaffDTO staff = (StaffDTO) VaadinSession.getCurrent().getAttribute("staff"); contactDTO.setStaffCode(staff.getCode()); Button btnAdd = new Button(FontAwesome.PHONE); btnAdd.addStyleName(Runo.BUTTON_LINK); addBtnAddContactClickListener(btnAdd, contactDTO); return btnAdd; } }); }
From source file:com.anphat.customer.controller.CustomerContactController.java
private void addButtonOnTblTermInfo(CustomPageTableFilter tbl) { tbl.addGeneratedColumn("btnReport", new CustomTable.ColumnGenerator() { @Override/*w w w.j av a2 s .co m*/ public Object generateCell(CustomTable source, Object itemId, Object columnId) { TermInformationDTO term = (TermInformationDTO) itemId; Button btnAdd = new Button(FontAwesome.REGISTERED); btnAdd.addStyleName(Runo.BUTTON_LINK); addBtnReportClickListener(btnAdd, term); return btnAdd; } }); }
From source file:com.anphat.customer.controller.ListCustomerControllerForOnePage.java
private void initTable(int pageLength) { tblCustomer = panel.getMainTable();//ww w . j a v a2s . c om tblContainer = new BeanItemContainer<>(CustomerDTO.class); tblCustomer.setMultiSelect(false); tblCustomer.addGeneratedColumn("mineNameCode", new CustomTable.ColumnGenerator() { @Override public Object generateCell(CustomTable source, Object itemId, Object columnId) { CustomerDTO cust = (CustomerDTO) itemId; if (!DataUtil.isStringNullOrEmpty(cust.getMineName())) { return mapMineName.get(cust.getMineName()); } else { return ""; } } }); tblCustomer.addGeneratedColumn("taxCodeLink", new CustomTable.ColumnGenerator() { @Override public Object generateCell(CustomTable source, Object itemId, Object columnId) { final CustomerDTO cust = (CustomerDTO) itemId; Button btn = new Button(cust.getTaxCode()); btn.setStyleName("v-button-link"); // btn.setStyleName("v-button-link-left"); btn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { CustomerManagementDetailDialog detailDialog = new CustomerManagementDetailDialog(); CustomerManagementDetailController controller = new CustomerManagementDetailController( detailDialog, tblCustomer); controller.fillData(cust); UI.getCurrent().addWindow(detailDialog); } }); return btn; } }); tblCustomer.addGeneratedColumn("taxAuthorityName", new CustomTable.ColumnGenerator() { @Override public Object generateCell(CustomTable source, Object itemId, Object columnId) { CustomerDTO cust = (CustomerDTO) itemId; if (!DataUtil.isStringNullOrEmpty(cust.getTaxAuthority())) { String a = mapTaxAuthority.get(cust.getTaxAuthority()); if (a == null) { return cust.getTaxAuthority(); } else { return mapTaxAuthority.get(cust.getTaxAuthority()); } } else { return ""; } } }); CommonFunctionTableFilter.initTable(panel, HEADER, tblContainer, CAPTION, pageLength, LANG); tblCustomer.setColumnExpandRatio("taxCode", 1); tblCustomer.setColumnExpandRatio("name", 2); tblCustomer.setColumnExpandRatio("notes", 2); tblCustomer.setColumnExpandRatio("createDate", 1); tblCustomer.setColumnExpandRatio("status", 0.75f); tblCustomer.setColumnExpandRatio("mineNameCode", 1.5f); tblCustomer.setColumnExpandRatio("taxAuthorityName", 1); CommonUtils.convertFieldAppParamTable(tblCustomer, "status", Constants.APP_PARAMS.CUSTOMER_SERVICE_STATUS, mapCustomerStatus); tblCustomer.setMultiSelect(false); tblCustomer.setColumnWidth(Constants.STT, 65); }
From source file:com.anphat.customer.ui.CustomerCareHistoryDialog.java
private void buildGridCareHistory() { gridCareHistoryLayout = new GridLayout(2, 4); CommonUtils.setBasicAttributeLayout(gridCareHistoryLayout, BundleUtils.getString("label.history.care.caption"), false); locale = (Locale) VaadinSession.getCurrent().getAttribute("locale"); if (locale == null) { locale = new Locale("vi"); }//w ww . j a v a 2s. c o m dfDateTracking = new DateField(BundleUtils.getString("customerCareHistoryForm.dateTracking")); dfDateTracking.setWidth("100%"); dfDateTracking.setImmediate(true); dfDateTracking.setLocale(locale); gridCareHistoryLayout.addComponent(dfDateTracking, 0, 3); taNotes = new TextArea(BundleUtils.getString("customerCareHistoryForm.notes")); taNotes.setRequired(true); taNotes.setWidth("100%"); gridCareHistoryLayout.addComponent(taNotes, 0, 2, 1, 2); cbxService = CommonUtils.buildComboBox(BundleUtils.getString("term.information.service")); cbxService.setNullSelectionAllowed(true); gridCareHistoryLayout.addComponent(cbxService, 0, 0); cbxCustomerServiceStatus = CommonUtils.buildComboBox(BundleUtils.getString("customerStatusForm.status")); cbxCustomerServiceStatus.setNullSelectionAllowed(true); gridCareHistoryLayout.addComponent(cbxCustomerServiceStatus, 1, 3); f9Contact = new MappingCombobox(BundleUtils.getString("customer.contact.name"), BundleUtils.getString("customerCareHistoryForm.telNumber")); gridCareHistoryLayout.addComponent(f9Contact.getLayout(), 1, 0); btnAddContact = new Button(BundleUtils.getString("label.customer.contact.addNew")); btnAddContact.addStyleName("v-button-link"); btnAddContact.setDisableOnClick(true); ShortcutUtils.setShortkeyF2(btnAddContact); gridCareHistoryLayout.addComponent(btnAddContact, 1, 1); mainLayout.addComponent(gridCareHistoryLayout); GridManyButton gridManyButton = CommonUtils.getCommonButtonDialog(this); btnSave = gridManyButton.getBtnCommon().get(0); mainLayout.addComponent(gridManyButton); DataUtil.addFocusWindow(this, taNotes); }
From source file:com.anphat.customer.ui.ImportCustomerUploadForm.java
private void buildGridTermInfo() { gridTermInfo = new GridLayout(4, 3); CommonUtils.setBasicAttributeLayout(gridTermInfo, GRID_UPLOAD_CAPTION, true); gridTermInfo.setImmediate(true);/*from ww w . j av a2 s . c o m*/ gridTermInfo.setWidth("100%"); gridTermInfo.setHeight("-1px"); cboService = CommonUtils.buildComboBox("term.information.service"); cboService.setRequired(true); cboService.setRequiredError(CommonMessages.messageRequire("customerStatusForm.service")); cboMineName = CommonUtils.buildComboBox("term.information.mineName"); cboMineName.setRequired(true); tfMineName = CommonUtils.buildTextField(BundleUtils.getString("term.information.mineName"), 100); tfMineName.setRequired(true); gridTermInfo.addComponent(cboService, 2, 1); gridTermInfo.addComponent(cboMineName, 3, 1); btnAddMineName = new Button(BundleUtils.getString("button.add.mineName")); btnAddMineName.setIcon(new ThemeResource(Constants.ICON.ADD)); btnAddMineName.setDisableOnClick(true); btnAddMineName.addStyleName("v-button-link"); gridTermInfo.addComponent(btnAddMineName, 3, 2); uFileCommonInfo = new Upload(); uFileCommonInfo.setCaption(Constants.NULL); uFileTermInfo = new Upload(); uFileTermInfo.setCaption(Constants.NULL); uFileCommonInfo.setWidth("100%"); uFileTermInfo.setWidth("100%"); gridTermInfo.addComponent(uFileTermInfo, 0, 1, 1, 1); gridTermInfo.addComponent(uFileCommonInfo, 0, 0, 1, 0); gridTermInfo.setComponentAlignment(uFileCommonInfo, Alignment.MIDDLE_CENTER); gridTermInfo.setComponentAlignment(uFileTermInfo, Alignment.MIDDLE_CENTER); }
From source file:com.anphat.list.controller.CategoryListController.java
public void initTable() { beanItemContainerCategoryList = new BeanItemContainer<>(CategoryListDTO.class); tblCategoryList.addGeneratedColumn(lblDelete, new CustomTable.ColumnGenerator() { @Override//from w ww. ja v a2 s. c om public Object generateCell(CustomTable source, final Object itemId, Object columnId) { final CategoryListDTO categoryListDTO = (CategoryListDTO) itemId; ThemeResource iconVi = new ThemeResource("img/icon_delete.png"); Image image = new Image(null, iconVi); image.addClickListener(new MouseEvents.ClickListener() { @Override public void click(MouseEvents.ClickEvent event) { ConfirmDialog.show(UI.getCurrent(), BundleUtils.getString("titleMessage"), BundleUtils.getString("bodyMessage"), BundleUtils.getString("yes"), BundleUtils.getString("no"), new ConfirmDialog.Listener() { @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { categoryListDTO.setEndDate(DateUtil.date2ddMMyyyyHHMMss(new Date())); String message = serviceCategoryList .updateCategoryList(categoryListDTO); if (message.equals(Constants.SUCCESS)) { Notification.show(BundleUtils.getString("delete.success")); tblCategoryList.removeItem(itemId); } else { Notification.show(BundleUtils.getString("delete.fail")); } } else { // User did not confirm } } }); } }); return image; } }); tblCategoryList.addGeneratedColumn("custQuantityDetail", new CustomTable.ColumnGenerator() { @Override public Object generateCell(CustomTable source, final Object itemId, Object columnId) { final CategoryListDTO categoryListDTO = (CategoryListDTO) itemId; if (DataUtil.isStringNullOrEmpty(categoryListDTO.getCustQuantity())) { return ""; } Button btnDetail = new Button(categoryListDTO.getCustQuantity()); btnDetail.setStyleName(Constants.ICON.V_LINK); btnDetail.addStyleName("v-link-button-left"); btnDetail.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { LinkedHashMap<String, CustomTable.Align> headerCustomerTable = BundleUtils .getHeadersFilter("customer.status.detail"); String captionCustomerTable = BundleUtils.getString("customer.table.detail.caption"); String lang = "customer"; CustomerDialog customerDialog = new CustomerDialog(headerCustomerTable, captionCustomerTable, lang); customerDialog.initDialog(mapServices, mapCustServiceStatus, CustomerDTO.class); List<CustomerDTO> lstCustomerOfMineName = WSCustomer .getListCustomerOfMineName(categoryListDTO.getId()); customerDialog.setCustomerList2Table(lstCustomerOfMineName); UI.getCurrent().addWindow(customerDialog); event.getButton().setEnabled(true); } }); return btnDetail; } }); tblCategoryList.addGeneratedColumn("devidedQuantityDetail", new CustomTable.ColumnGenerator() { @Override public Object generateCell(CustomTable source, final Object itemId, Object columnId) { final CategoryListDTO categoryListDTO = (CategoryListDTO) itemId; if (DataUtil.isStringNullOrEmpty(categoryListDTO.getDividedQuantity())) { return ""; } Button btnDetail = new Button(categoryListDTO.getDividedQuantity()); btnDetail.setStyleName(Constants.ICON.V_LINK); btnDetail.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { LinkedHashMap<String, CustomTable.Align> headerCustomerTable = BundleUtils .getHeadersFilter("devided.customer.status.detail"); String captionCustomerTable = BundleUtils .getString("customer.devided.table.detail.caption"); String lang = "customer"; CustomerDialog customerDialog = new CustomerDialog(headerCustomerTable, captionCustomerTable, lang); customerDialog.initDialog(mapServices, mapCustServiceStatus, CustomerDTO.class); List<CustomerDTO> lstCustomerOfMineName = WSCustomer .getListDevidedCustomerOfMineName(categoryListDTO.getId()); customerDialog.setCustomerList2Table(lstCustomerOfMineName); UI.getCurrent().addWindow(customerDialog); event.getButton().setEnabled(true); } }); return btnDetail; } }); tblCategoryList.addGeneratedColumn(lblEdit, new CustomTable.ColumnGenerator() { @Override public Object generateCell(CustomTable source, final Object itemId, Object columnId) { final CategoryListDTO categoryListDTO = (CategoryListDTO) itemId; ThemeResource iconVi = new ThemeResource("img/icon_edit.png"); Image image = new Image(null, iconVi); image.addClickListener(new MouseEvents.ClickListener() { @Override public void click(MouseEvents.ClickEvent event) { InsertOrUpdate(categoryListDTO, false); } }); return image; } }); // tableUtils.generateColumn(tblCategoryList); CommonUtils.setVisibleBtnTablePanel(panelCategoryList, true, false, true, true); CommonFunctionTableFilter.initTable(panelCategoryList, headerData, beanItemContainerCategoryList, BundleUtils.getString("table.list.categoryList"), 10, "categoryList.header", true, true, false, false, false); tblCategoryList.setColumnExpandRatio("description", 2); tblCategoryList.setColumnExpandRatio("receivedDate", 1); tblCategoryList.setColumnExpandRatio("endDate", 1); tblCategoryList.setColumnExpandRatio("code", 1); tblCategoryList.setColumnExpandRatio("name", 1); }
From source file:com.anphat.list.controller.DialogAddMapStaffCustomerController.java
private void initStaffTable(CommonTableFilterPanel filterPanel, boolean isAddTable) { filterPanel.getToolbar().setVisible(false); if (isAddTable) { containerLeft = new BeanItemContainer(StaffDTO.class); tblLeft = filterPanel.getMainTable(); tableUtils = new TableUtils(); tableUtils.generateColumn(tblLeft); tblLeft.setColumnExpandRatio(Constants.STAFF.NAME, 6); tblLeft.setColumnExpandRatio(Constants.STAFF.CODE, 3); tblLeft.setColumnExpandRatio(Constants.STAFF.STAFF_TYPE, 3); tblLeft.setColumnExpandRatio(Constants.CHECKBOX_COLUMN, 1); CommonFunctionTableFilter.initTable(filterPanel, headerStaffLeft, containerLeft, captionStaffTable, tblSize, langStaff);/*from ww w. j a va 2 s . co m*/ tblLeft.setColumnHeader(Constants.CHECKBOX_COLUMN, ""); CommonUtils.convertFieldAppParamTable(tblLeft, Constants.STAFF.STAFF_TYPE, "STAFF_TYPE"); } else { containerRight = new BeanItemContainer(MapStaffCustomerDTO.class); if (!DataUtil.isListNullOrEmpty(lstMapStaffCustomerDTOs)) { containerRight.addAll(lstMapStaffCustomerDTOs); } tblRight = filterPanel.getMainTable(); tblRight.addGeneratedColumn("delete", new CustomTable.ColumnGenerator() { @Override public Object generateCell(final CustomTable source, final Object itemId, Object columnId) { MapStaffCustomerDTO sdto = (MapStaffCustomerDTO) itemId; if (!DataUtil.isStringNullOrEmpty(sdto.getMapId())) { return ""; } Button btnDelete = new Button(new ThemeResource(Constants.ICON.CANCEL)); btnDelete.addStyleName(Constants.ICON.V_LINK); btnDelete.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { source.removeItem(itemId); tblRight.resetPage(); } }); return btnDelete; } }); tblRight.setColumnWidth("delete", 60); tblRight.setColumnExpandRatio("staffName", 3); tblRight.setColumnExpandRatio("staffCode", 1); tblRight.setColumnExpandRatio("staffType", 1); CommonFunctionTableFilter.initTable(filterPanel, headerStaffRight, containerRight, captionStaffCustomerTable, tblSize, langStaff); tblRight.setColumnHeader("delete", Constants.NULL); CommonUtils.convertFieldAppParamTable(tblRight, Constants.STAFF.STAFF_TYPE, "STAFF_TYPE"); } }