List of usage examples for com.vaadin.server ThemeResource ThemeResource
public ThemeResource(String resourceId)
From source file:com.adonis.ui.menu.Menu.java
private void createViewButtonWithEditableImage(final String name, String caption, String nameImage) { Button button = new Button(caption, new ClickListener() { @Override// w ww . j a v a 2 s . c o m public void buttonClick(ClickEvent event) { navigator.navigateTo(name); } }); button.setPrimaryStyleName(ValoTheme.BUTTON_FRIENDLY); // button.setWidth(50, Unit.PERCENTAGE); image.setWidth(90, Unit.PIXELS); image.setHeight(90, Unit.PIXELS); FileReader.createDirectoriesFromCurrent(getInitialPath()); final Image image = new Image("", new ThemeResource("img/" + nameImage)); try { FileReader.copyFile(VaadinUtils.getResourcePath(nameImage), VaadinUtils.getInitialPath() + File.separator + nameImage); image.setSource(new FileResource(new File(VaadinUtils.getInitialPath() + File.separator + nameImage))); } catch (IOException e) { e.printStackTrace(); image.setSource(new ThemeResource("img/" + nameImage)); } // image.setWidth(50, Unit.PERCENTAGE); image.setWidth(90, Unit.PIXELS); image.setHeight(90, Unit.PIXELS); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setPrimaryStyleName(ValoTheme.MENU_ITEM); horizontalLayout.addComponents(image, button); image.addClickListener(new MouseEvents.ClickListener() { @Override public void click(MouseEvents.ClickEvent event) { uploadFieldImage = new UploadField(); uploadFieldImage.setAcceptFilter("image/*"); uploadFieldImage.getUpload().addListener(new com.vaadin.v7.ui.Upload.FailedListener() { @Override public void uploadFailed(com.vaadin.v7.ui.Upload.FailedEvent event) { uploadFieldImage.clearDefaulLayout(); horizontalLayout.removeComponent(uploadFieldImage); } private static final long serialVersionUID = 1L; }); horizontalLayout.addComponent(uploadFieldImage, 2); uploadFieldImage.getUpload().addListener(new com.vaadin.v7.ui.Upload.SucceededListener() { @Override public void uploadSucceeded(com.vaadin.v7.ui.Upload.SucceededEvent event) { File file = (File) uploadFieldImage.getValue(); try { showUploadedImage(uploadFieldImage, image, file.getName(), nameImage); } catch (IOException e) { e.printStackTrace(); } uploadFieldImage.clearDefaulLayout(); horizontalLayout.removeComponent(uploadFieldImage); } }); uploadFieldImage.setFieldType(UploadField.FieldType.FILE); horizontalLayout.markAsDirty(); // image.setWidth(50, Unit.PERCENTAGE); image.setWidth(90, Unit.PIXELS); image.setHeight(90, Unit.PIXELS); image.setVisible(false); image.markAsDirty(); horizontalLayout.addComponent(image, 0); } }); button.setVisible(true); image.setVisible(true); menuItemsLayout.addComponents(horizontalLayout); viewButtons.put(name, button); }
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 a va 2 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. jav a 2 s. c o m*/ 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.ContractTemplateListController.java
public void initTable() { beanItemContainerContractTemplateList = new BeanItemContainer<>(ContractTemplateListDTO.class); tblContractTemplateList.addGeneratedColumn("download", new CustomTable.ColumnGenerator() { @Override//from w ww .ja v a 2s. co m public Object generateCell(CustomTable source, Object itemId, Object columnId) { ContractTemplateListDTO ctldto = (ContractTemplateListDTO) itemId; Link btnDownload; btnDownload = new Link("Ti v?", new ThemeResource(Constants.ICON.DOCX)); btnDownload.setImmediate(true); File file = new File(Constants.PATH_TEMPLATE + ctldto.getPathFile()); if (file.exists()) { FileDownloader downloader = new FileDownloader(file, ctldto.getPathFile()); btnDownload.setResource(downloader); return btnDownload; } else { return ""; } } }); CommonFunctionTableFilter.initTable(panelContractTemplateList, headerData, beanItemContainerContractTemplateList, BundleUtils.getString("table.list.contractTemplateList"), 10, "contractTemplateList.header", true, true, false, false, false); CommonUtils.convertFieldAppParamTable(panelContractTemplateList.getMainTable(), "status", Constants.APP_PARAMS.COMMON_STATUS, mapStatus); CommonUtils.convertFieldAppParamTable(panelContractTemplateList.getMainTable(), "service", Constants.APP_PARAMS.SERVICE_TYPE, mapService); CommonUtils.convertFieldAppParamTable(panelContractTemplateList.getMainTable(), "type", Constants.APP_PARAMS.TYPE_CONTRACT, mapType); CommonUtils.convertFieldAppParamTable(panelContractTemplateList.getMainTable(), "provider", Constants.APP_PARAMS.PROVIDER, mapProvider); panelContractTemplateList.getCoppyButton().setVisible(false); panelContractTemplateList.getDeleteButton().setVisible(false); tblContractTemplateList.setMultiSelect(false); }
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 www . ja va2s. c o 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"); } }
From source file:com.anphat.list.controller.DialogAddMapStaffCustomerController.java
private void initCustTable(CommonTableFilterPanel filterPanel, boolean isAddTable) { filterPanel.getToolbar().setVisible(false); if (isAddTable) { containerLeft = new BeanItemContainer(CustomerDTO.class); tblLeft = filterPanel.getMainTable(); tableUtils = new TableUtils(); tableUtils.generateColumn(tblLeft); tblLeft.setColumnExpandRatio(Constants.CUSTOMER.NAME, 3); tblLeft.setColumnExpandRatio(Constants.CUSTOMER.CODE, 1); tblLeft.setColumnWidth(Constants.CHECKBOX_COLUMN, 40); CommonFunctionTableFilter.initTable(filterPanel, headerCustLeft, containerLeft, captionCustTable, tblSize, langCust);//from w w w . j a va 2s . c o m tblLeft.setColumnHeader(Constants.CHECKBOX_COLUMN, ""); } 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) { final MapStaffCustomerDTO sdto = (MapStaffCustomerDTO) itemId; if (DataUtil.isStringNullOrEmpty(sdto.getMapId())) { Button btnCancel = new Button(new ThemeResource(Constants.ICON.CANCEL)); btnCancel.setDescription(BundleUtils.getString("common.button.cancel")); btnCancel.addStyleName(Constants.ICON.V_LINK); btnCancel.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { source.removeItem(itemId); tblRight.resetPage(); } }); return btnCancel; } else { Button btnDelete = new Button(new ThemeResource(Constants.ICON.DELETE)); btnDelete.setDescription(BundleUtils.getString("common.button.delete")); btnDelete.addStyleName(Constants.ICON.V_LINK); btnDelete.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { ConfirmDialog.show(UI.getCurrent(), BundleUtils.getString("delete.item.title"), BundleUtils.getString("delete.item.body"), BundleUtils.getString("yes"), BundleUtils.getString("no"), new ConfirmDialog.Listener() { @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { String returnValue = WSMapStaffCustomer .deleteMapStaffCustomer(sdto.getMapId()); if (returnValue.equalsIgnoreCase(Constants.SUCCESS)) { tblRight.removeItem(itemId); tblRight.resetPage(); Notification.show(BundleUtils.getString("actionSuccess"), Notification.Type.HUMANIZED_MESSAGE); } else { Notification.show(BundleUtils.getString("actionFail"), Notification.Type.ERROR_MESSAGE); } } } }); } }); return btnDelete; } } }); // tblRight.addGeneratedColumn("cancel", 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 btnCancel = new Button(new ThemeResource(Constants.ICON.CANCEL)); // btnCancel.setDescription(BundleUtils.getString("common.button.cancel")); // btnCancel.addStyleName(Constants.ICON.V_LINK); // btnCancel.addClickListener(new Button.ClickListener() { // // @Override // public void buttonClick(Button.ClickEvent event) { // source.removeItem(itemId); // tblRight.resetPage(); // } // }); // return btnCancel; // } // }); tblRight.setColumnWidth("delete", 100); // tblRight.setColumnWidth("cancel", 60); tblRight.setColumnExpandRatio("custName", 3); tblRight.setColumnExpandRatio("custCode", 1); CommonFunctionTableFilter.initTable(filterPanel, headerCustRight, containerRight, captionCustTableView, tblSize, langCust); tblRight.setColumnHeader("delete", BundleUtils.getString("common.button.delete") + "/" + BundleUtils.getString("common.button.cancel")); // tblRight.setColumnHeader("cancel", ""); } }
From source file:com.anphat.list.controller.ObjectsController.java
public void initTable() { beanItemContainerObjects = new BeanItemContainer<>(ObjectsDTO.class); tblObjects.setSortDisabled(true);/* w ww. j a va2 s .c o m*/ tblObjects.addGeneratedColumn(lblDelete, new CustomTable.ColumnGenerator() { @Override public Object generateCell(CustomTable source, final Object itemId, Object columnId) { final ObjectsDTO objectsDTO = (ObjectsDTO) 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(), "Thng bo", "Bn c mun thc hin?", "C", "Khng", new ConfirmDialog.Listener() { @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { objectsDTO.setStatus(Constants.DEACTIVE); String message = serviceObjects.updateObjects(objectsDTO); if (message.equals(Constants.SUCCESS)) { CommonMessages.showMessageDeleteSuccess("function.object"); tblObjects.removeItem(itemId); } else { CommonMessages.showDeleteFail("function.object"); } } } }); } }); return image; } }); tblObjects.addGeneratedColumn(lblEdit, new CustomTable.ColumnGenerator() { @Override public Object generateCell(CustomTable source, final Object itemId, Object columnId) { final ObjectsDTO objectsDTO = (ObjectsDTO) 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(objectsDTO); } }); return image; } }); CommonUtils.setVisibleBtnTablePanel(panelObjects, true, true, false, true); CommonFunctionTableFilter.initTable(panelObjects, headerData, beanItemContainerObjects, BundleUtils.getString("table.list.objects"), 10, "objects.header", true, true, false, false, false); CommonUtils.convertFieldAppParamTable(tblObjects, "status", Constants.APP_PARAMS.COMMON_STATUS, mapCode2Name); }
From source file:com.anphat.list.controller.RolesController.java
public void initTable() { tblRoles.setSortDisabled(true);//ww w. j av a 2 s . co m tblRoles.addGeneratedColumn(lblDelete, new CustomTable.ColumnGenerator() { @Override public Object generateCell(CustomTable source, final Object itemId, Object columnId) { final RolesDTO rolesDTO = (RolesDTO) 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("d"), BundleUtils.getString("bodyMessage"), BundleUtils.getString("yes"), BundleUtils.getString("no"), new ConfirmDialog.Listener() { @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { rolesDTO.setStatus(Constants.DEACTIVE); String message = serviceRoles.updateRoles(rolesDTO); if (message.equals(Constants.SUCCESS)) { Notification.show(BundleUtils.getString("delete.success")); tblRoles.removeItem(itemId); } else { Notification.show(BundleUtils.getString("delete.fail")); } } else { // User did not confirm } } }); } }); return image; } }); tblRoles.addGeneratedColumn(lblEdit, new CustomTable.ColumnGenerator() { @Override public Object generateCell(CustomTable source, final Object itemId, Object columnId) { final RolesDTO rolesDTO = (RolesDTO) 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(rolesDTO); } }); return image; } }); tableUtils.generateColumn(tblRoles); CommonUtils.setVisibleBtnTablePanel(panelRoles, true, true, false, true); initTable(headerData); }
From source file:com.anphat.list.controller.ServicesController.java
public void initTable() { beanItemContainerServices = new BeanItemContainer<>(ServicesDTO.class); CommonFunctionTableFilter.initTable(panelServices, headerData, beanItemContainerServices, BundleUtils.getString("table.list.services"), 10, "services.header", true, true, false, false, false);/* w w w .j a v a2 s . c o m*/ tblServices.setSortDisabled(true); tblServices.addGeneratedColumn(lblDelete, new CustomTable.ColumnGenerator() { @Override public Object generateCell(CustomTable source, final Object itemId, Object columnId) { final ServicesDTO servicesDTO = (ServicesDTO) 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(), "Thng bo", "B?n c mu?n th?c hi?n?", "C", "Khng", new ConfirmDialog.Listener() { @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { servicesDTO.setStatus(Constants.DEACTIVE); String message = serviceServices.updateServices(servicesDTO); if (message.equals(Constants.SUCCESS)) { Notification.show(BundleUtils.getString("delete.success")); tblServices.removeItem(itemId); } else { Notification.show(BundleUtils.getString("delete.fail")); } } else { // User did not confirm } } }); } }); return image; } }); tblServices.addGeneratedColumn(lblEdit, new CustomTable.ColumnGenerator() { @Override public Object generateCell(CustomTable source, final Object itemId, Object columnId) { final ServicesDTO servicesDTO = (ServicesDTO) 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(servicesDTO); } }); return image; } }); tableUtils.generateColumn(tblServices); CommonUtils.setVisibleBtnTablePanel(panelServices, true, true, false, true); tblServices.setVisibleColumns(headerServices); }
From source file:com.anphat.list.controller.TaxAuthorityController.java
public void initTable() { beanItemContainerTaxAuthority = new BeanItemContainer<>(TaxAuthorityDTO.class); tblTaxAuthority.setSortDisabled(true); tblTaxAuthority.addGeneratedColumn(lblDelete, new CustomTable.ColumnGenerator() { @Override//from www .ja va2s. c om public Object generateCell(CustomTable source, final Object itemId, Object columnId) { final TaxAuthorityDTO taxAuthorityDTO = (TaxAuthorityDTO) 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()) { taxAuthorityDTO.setStatus(Constants.DEACTIVE); String message = serviceTaxAuthority .updateTaxAuthority(taxAuthorityDTO); if (message.equals(Constants.SUCCESS)) { Notification.show(BundleUtils.getString("delete.success")); tblTaxAuthority.removeItem(itemId); } else { Notification.show(BundleUtils.getString("delete.fail")); } } else { // User did not confirm } } }); } }); return image; } }); tblTaxAuthority.addGeneratedColumn(lblEdit, new CustomTable.ColumnGenerator() { @Override public Object generateCell(CustomTable source, final Object itemId, Object columnId) { final TaxAuthorityDTO taxAuthorityDTO = (TaxAuthorityDTO) 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(taxAuthorityDTO, false); } }); return image; } }); // tableUtils.generateColumn(tblTaxAuthority); CommonFunctionTableFilter.initTable(panelTaxAuthority, headerData, beanItemContainerTaxAuthority, BundleUtils.getString("table.list.taxAuthority"), 10, "taxAuthority.header", true, true, false, false, false); CommonUtils.setVisibleBtnTablePanel(panelTaxAuthority, true, false, true, true); CommonUtils.convertFieldAppParamTable(tblTaxAuthority, Constants.TAXAUTHORITY.STATUS, Constants.APP_PARAMS.COMMON_STATUS); }