List of usage examples for com.vaadin.ui Image Image
public Image(String caption, Resource source)
From source file:annis.gui.ReportBugWindow.java
License:Apache License
private void addScreenshotPreview(Layout layout, final byte[] rawImage, String mimeType) { StreamResource res = new StreamResource(new ScreenDumpStreamSource(rawImage), "screendump_" + UUID.randomUUID().toString() + ".png"); res.setMIMEType(mimeType);//from w w w. j av a2s .co m final Image imgScreenshot = new Image("Attached screenshot", res); imgScreenshot.setAlternateText( "Screenshot of the ANNIS browser window, " + "no other window or part of the desktop is captured."); imgScreenshot.setVisible(false); imgScreenshot.setWidth("100%"); Button btShowScreenshot = new Button("Show attached screenshot", new ShowScreenshotClickListener(imgScreenshot)); btShowScreenshot.addStyleName(BaseTheme.BUTTON_LINK); btShowScreenshot.setIcon(FontAwesome.PLUS_SQUARE_O); layout.addComponent(btShowScreenshot); layout.addComponent(imgScreenshot); }
From source file:au.org.scoutmaster.views.ContactView.java
private DateField overviewTab() { // Overview tab final SMMultiColumnFormLayout<Contact> overviewForm = new SMMultiColumnFormLayout<Contact>(3, this.fieldGroup); overviewForm.setColumnFieldWidth(0, 100); overviewForm.setColumnLabelWidth(1, 0); overviewForm.setColumnFieldWidth(1, 140); overviewForm.setColumnLabelWidth(2, 40); overviewForm.setColumnFieldWidth(2, 80); overviewForm.setMargin(true);//from w w w. j av a 2 s . c om // overviewForm.setColumnLabelWidth(0, 100); // overviewForm.setColumnLabelWidth(1, 0); // overviewForm.setColumnLabelWidth(2, 60); // overviewForm.setColumnFieldWidth(0, 100); // overviewForm.setColumnFieldWidth(1, 100); // overviewForm.setColumnFieldWidth(2, 20); // overviewForm.setSizeFull(); final FormHelper<Contact> formHelper = overviewForm.getFormHelper(); // overviewForm.setMargin(true); this.tabs.addTab(overviewForm, "Overview"); overviewForm.bindBooleanField("Active", Contact_.active); overviewForm.newLine(); overviewForm.colspan(3); this.groupRoleField = formHelper.new EntityFieldBuilder<GroupRole>().setLabel("Role") .setField(Contact_.groupRole).setListFieldName(GroupRole_.name).build(); this.groupRoleField.addValueChangeListener(this.changeListener); overviewForm.newLine(); overviewForm.colspan(3); overviewForm.bindTextField("Firstname", Contact_.firstname); overviewForm.newLine(); overviewForm.colspan(3); overviewForm.bindTextField("Middle name", Contact_.middlename); overviewForm.newLine(); overviewForm.colspan(3); overviewForm.bindTextField("Lastname", Contact_.lastname); overviewForm.newLine(); this.birthDate = overviewForm.bindDateField("Birth Date", Contact_.birthDate, "yyyy-MM-dd", Resolution.DAY); // fieldOverviewSectionEligibity = overviewForm.addTextField(null); // fieldOverviewSectionEligibity.setReadOnly(true); this.ageField = overviewForm.bindLabel("Age"); // overviewForm.setComponentAlignment(this.ageField, // Alignment.MIDDLE_LEFT); overviewForm.newLine(); overviewForm.bindEnumField("Gender", Contact_.gender, Gender.class); overviewForm.newLine(); overviewForm.colspan(3); overviewForm.bindBooleanField("Do Not Send Bulk Communications", Contact_.doNotSendBulkCommunications); overviewForm.newLine(); overviewForm.colspan(3); overviewForm.bindEnumField("Preferred Communications", Contact_.preferredCommunications, PreferredCommunications.class); overviewForm.newLine(); overviewForm.colspan(3); final TextField homeEmail = overviewForm.bindTextField("Home Email", Contact_.homeEmail); final String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath(); final FileResource resource = new FileResource(new File(basepath + "/WEB-INF/images/email.png")); this.homeEmailImage = new Image(null, resource); this.homeEmailImage.setDescription("Click to send an email"); this.homeEmailImage.addClickListener(new MouseEventLogged.ClickListener() { private static final long serialVersionUID = 1L; @Override public void clicked(final com.vaadin.event.MouseEvents.ClickEvent event) { showMailForm(homeEmail); } }); overviewForm.addComponent(this.homeEmailImage); this.homeEmailImage.setVisible(false); overviewForm.newLine(); overviewForm.colspan(3); final TextField workEmail = overviewForm.bindTextField("Work Email", Contact_.workEmail); this.workEmailImage = new Image(null, resource); this.workEmailImage.setDescription("Click to send an email"); overviewForm.addComponent(this.workEmailImage); this.workEmailImage.addClickListener(new MouseEventLogged.ClickListener() { private static final long serialVersionUID = 1L; @Override public void clicked(final com.vaadin.event.MouseEvents.ClickEvent event) { showMailForm(workEmail); } }); this.workEmailImage.setVisible(false); overviewForm.newLine(); overviewForm.bindTextField("Phone 1", "phone1.phoneNo"); overviewForm.bindEnumField(null, "phone1.phoneType", PhoneType.class); this.primaryPhone1 = overviewForm.bindBooleanField("Primary", Contact_.phone1.getName() + "." + Phone_.primaryPhone.getName()); this.primaryPhone1.addValueChangeListener(new PhoneChangeListener()); overviewForm.newLine(); overviewForm.bindTextField("Phone 2", "phone2.phoneNo"); overviewForm.bindEnumField(null, "phone2.phoneType", PhoneType.class); this.primaryPhone2 = overviewForm.bindBooleanField("Primary", "phone2.primaryPhone"); this.primaryPhone2.addValueChangeListener(new PhoneChangeListener()); overviewForm.newLine(); overviewForm.bindTextField("Phone 3", "phone3.phoneNo"); overviewForm.bindEnumField(null, "phone3.phoneType", PhoneType.class); this.primaryPhone3 = overviewForm.bindBooleanField("Primary", "phone3.primaryPhone"); this.primaryPhone3.addValueChangeListener(new PhoneChangeListener()); overviewForm.newLine(); overviewForm.colspan(3); overviewForm.bindTextField("Street", "address.street"); overviewForm.newLine(); overviewForm.colspan(3); overviewForm.bindTextField("City", "address.city"); overviewForm.newLine(); overviewForm.bindTextField("State", "address.state"); overviewForm.bindTextField("Postcode", "address.postcode"); overviewForm.newLine(); overviewForm.colspan(3); this.tagField = overviewForm.bindTagField(this, "Tags", Contact_.tags); // tabs.addTab(overviewForm, "Contact"); return this.birthDate; }
From source file:ch.bfh.ti.soed.hs16.srs.view.views.helpers.Header.java
License:Open Source License
public Header() { /* init objects */ this.layout = new VerticalLayout(); // find application in directory String basePath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath(); // image as file resource // TODO Yep, logo appears. However, file should be retrieved from // location within JAR file. Consult Vaadin documentation on how to do // this./*from w w w. j a va2 s. c o m*/ FileResource fileResource = new FileResource(new File(basePath + File.separator + "VAADIN" + File.separator + "themes" + File.separator + "mytheme" + File.separator + "srsLogo.jpg")); Image pic = new Image("", fileResource); /* add components to layout */ this.layout.addComponents(pic); }
From source file:com.adonis.ui.menu.Menu.java
public Menu(PersonService personService, VehicleService vehicleService, Navigator navigator) { this.navigator = navigator; setPrimaryStyleName(ValoTheme.MENU_ROOT); menuPart = new CssLayout(); menuPart.addStyleName(ValoTheme.MENU_PART); setPersonsCrudProperties(personService); setVehiclesCrudProperties(vehicleService); // header of the menu final HorizontalLayout top = new HorizontalLayout(); top.addStyleName(ValoTheme.MENU_TITLE); top.setSpacing(true);/* www .j a va 2s . c o m*/ Label title = new Label("Vehicle manager"); title.addStyleName(ValoTheme.LABEL_H1); title.setSizeUndefined(); Image image = new Image(null, new ThemeResource("img/car.png")); image.setStyleName(ValoTheme.MENU_LOGO); top.addComponent(image); top.addComponent(title); menuPart.addComponent(top); // logout menu item // HorizontalLayout logoutLayout = new HorizontalLayout(); // logoutLayout.addStyleName(ValoTheme.MENU_ITEM); // logoutLayout.setSpacing(false); // // MenuBar logoutMenu = new MenuBar(); // logoutMenu.setStyleName(VALO_MENUITEMS); // logoutMenu.addItem("Logout", new MenuBar.Command() { // // @Override // public void menuSelected(MenuBar.MenuItem selectedItem) { // VaadinSession.getCurrent().getSession().invalidate(); // Page.getCurrent().reload(); // } // }); // // logoutMenu.addStyleName("user-menu"); // Image logout = new Image(null, new ThemeResource("img/logout.png")); // logoutLayout.addComponent(logout, 0); // logoutLayout.addComponent(logoutMenu, 1); // menuPart.addComponent(logoutLayout); // button for toggling the visibility of the menu when on a small screen showMenu = new Button("Menu", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) { menuPart.removeStyleName(VALO_MENU_VISIBLE); } else { menuPart.addStyleName(VALO_MENU_VISIBLE); } } }); showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY); showMenu.addStyleName(ValoTheme.BUTTON_SMALL); showMenu.addStyleName(VALO_MENU_TOGGLE); // showMenu.setIcon(FontAwesome.NAVICON); menuPart.addComponent(showMenu); // container for the navigation buttons, which are added by addView() menuItemsLayout = new CssLayout(); menuItemsLayout.setPrimaryStyleName(VALO_MENUITEMS); menuPart.addComponent(menuItemsLayout); addComponent(menuPart); addStyleName("backImage"); }
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/*from ww w .j a v a 2s . com*/ 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.list.controller.CategoryListController.java
public void initTable() { beanItemContainerCategoryList = new BeanItemContainer<>(CategoryListDTO.class); tblCategoryList.addGeneratedColumn(lblDelete, new CustomTable.ColumnGenerator() { @Override/* w w w . j av a 2 s.com*/ 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.ObjectsController.java
public void initTable() { beanItemContainerObjects = new BeanItemContainer<>(ObjectsDTO.class); tblObjects.setSortDisabled(true);// www . j av a 2s . 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);/*from www. j a va2 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);//from w w w . j av 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 w w w . j av a 2 s. c o m 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); }