Example usage for com.vaadin.ui Button addClickListener

List of usage examples for com.vaadin.ui Button addClickListener

Introduction

In this page you can find the example usage for com.vaadin.ui Button addClickListener.

Prototype

public Registration addClickListener(ClickListener listener) 

Source Link

Document

Adds the button click listener.

Usage

From source file:com.anphat.customer.controller.CustomerContactController.java

private void addBtnAddContactClickListener(Button btn, final CustomerContactDTO contactDTO) {
    btn.addClickListener(new Button.ClickListener() {
        @Override//from w  w w.j  a  v a  2s. com
        public void buttonClick(Button.ClickEvent event) {
            CustomerContactDialog contactDialog = new CustomerContactDialog(
                    BundleUtils.getString("customerCareHistoryForm"), lstCustomerServiceStatus, lstCustContact);
            if (contactDTO != null) {
                contactDialog.fillData2Dialog(contactDTO);
            }
            UI.getCurrent().addWindow(contactDialog);
            addListenerBtnSaveContact(contactDialog);
            event.getButton().setEnabled(true);
        }
    });
}

From source file:com.anphat.customer.controller.CustomerContactController.java

private void addListenerBtnSaveContact(final CustomerContactDialog contactDialog) {
    Button btnSave = contactDialog.getBtnSave();
    ShortcutUtils.setShortcutKey(btnSave);
    btnSave.addClickListener(new CommonButtonClickListener() {
        CustomerContactDTO contactDTO;/* w  ww .j a va  2  s .c  om*/

        @Override
        public void execute() {
            CustomerCareHistoryDTO careHistoryDTO = contactDialog.getInputCustomerCareObject(selectedCust);
            if (DataUtil.isStringNullOrEmpty(contactDTO.getId())) {
                ResultDTO result = WSCustomerContact.insertCustomerContact(contactDTO);
                if (result != null && Constants.SUCCESS.equals(result.getMessage())) {
                    ResultDTO resultCare = saveCustomerCareHistory(careHistoryDTO);
                    if (resultCare != null && Constants.SUCCESS.equals(resultCare.getMessage())) {
                        contactDialog.close();
                        CommonMessages.showMessageImportSuccess("customerCareHistoryForm");
                        if (DataUtil.isListNullOrEmpty(lstCustContact)) {
                            lstCustContact = new ArrayList<>();
                        }
                        lstCustContact.add(0, contactDTO);
                        setData2TableContact();
                        if (careHistoryDialog != null && careHistoryDialog.isVisible()) {
                            careHistoryDialog.addContact2ListContact(contactDTO);
                        }
                    }
                } else {
                    CommonMessages.showInsertFail("customerCareHistoryForm");
                }
            } else {
                // 14/05/2017: Cp nht lin h khi c thay i t ng?i dng
                String updateContactResult = updateCustomerContact(contactDTO);
                //Luu thong tin nhat ky goi
                ResultDTO resultCare = saveCustomerCareHistory(careHistoryDTO);
                if (resultCare != null && Constants.SUCCESS.equals(resultCare.getMessage())) {
                    contactDialog.close();
                    CommonMessages.showMessageImportSuccess("customerCareHistoryForm");
                    if (DataUtil.isListNullOrEmpty(lstCustContact)) {
                        lstCustContact = new ArrayList<>();
                    }
                    lstCustContact.add(0, contactDTO);
                    setData2TableContact();
                    if (careHistoryDialog != null && careHistoryDialog.isVisible()) {
                        careHistoryDialog.addContact2ListContact(contactDTO);
                    }
                } else {
                    CommonMessages.showInsertFail("customerCareHistoryForm");
                }
            }
        }

        @Override
        public boolean isValidated() {
            contactDTO = contactDialog.getInputContactObject(selectedCust);
            //                contactDTO.setStaffCode();
            if (DataUtil.isStringNullOrEmpty(contactDTO.getName())) {
                contactDialog.getTxtName().focus();
                CommonMessages.messageRequire("customerContact.name");
                return false;
            }
            if (DataUtil.isStringNullOrEmpty(contactDTO.getTelNumber())) {
                contactDialog.getTxtTelNumber().focus();
                CommonMessages.messageRequire("customerContact.telNumber");
                return false;
            }
            if (contactDialog.getTaNotes().isEmpty()) {
                contactDialog.getTaNotes().focus();
                CommonMessages.messageRequire("customerContact.notes");
                return false;
            }
            AppParamsDTO custStatus = (AppParamsDTO) contactDialog.getOgCustStatus().getValue();
            if (custStatus == null) {
                contactDialog.getOgCustStatus().focus();
                CommonMessages.messageRequire("customerContact.status");
                return false;
            }
            return true;
        }
    });
}

From source file:com.anphat.customer.controller.CustomerContactController.java

private void addListenerBtnSaveContactWhenEditCare(final CustomerContactDialog contactDialog,
        final CustomerCareHistoryDTO editDTO) {
    Button btnSave = contactDialog.getBtnSave();
    ShortcutUtils.setShortcutKey(btnSave);
    btnSave.addClickListener(new CommonButtonClickListener() {
        CustomerContactDTO contactDTO;//from  ww w.  ja  v a 2  s  . com

        @Override
        public void execute() {
            CustomerCareHistoryDTO careHistoryDTO = contactDialog.getInputCustomerCareObject(selectedCust);
            //Luu thong tin nhat ky goi
            careHistoryDTO.setId(editDTO.getId());
            careHistoryDTO.setContact(contactDTO.getName());
            careHistoryDTO.setTelNumber(contactDTO.getTelNumber());
            // 14/05/2017: Cp nht lin h khi c thay i t ng?i dng
            String updateContactResult = updateCustomerContact(contactDTO);
            ResultDTO resultCare = saveCustomerCareHistory(careHistoryDTO);
            if (resultCare != null && Constants.SUCCESS.equals(resultCare.getMessage())) {
                contactDialog.close();
                CommonMessages.showMessageImportSuccess("customerCareHistoryForm");
                if (DataUtil.isListNullOrEmpty(lstCustContact)) {
                    lstCustContact = new ArrayList<>();
                }
                lstCustContact.add(0, contactDTO);
                setData2TableContact();
                if (careHistoryDialog != null && careHistoryDialog.isVisible()) {
                    careHistoryDialog.addContact2ListContact(contactDTO);
                }

            }

        }

        @Override
        public boolean isValidated() {
            contactDTO = contactDialog.getInputContactObject(selectedCust);
            if (DataUtil.isStringNullOrEmpty(contactDTO.getName())) {
                contactDialog.getTxtName().focus();
                CommonMessages.messageRequire("customerContact.name");
                return false;
            }
            if (DataUtil.isStringNullOrEmpty(contactDTO.getTelNumber())) {
                contactDialog.getTxtTelNumber().focus();
                CommonMessages.messageRequire("customerContact.telNumber");
                return false;
            }
            if (contactDialog.getTaNotes().isEmpty()) {
                contactDialog.getTaNotes().focus();
                CommonMessages.messageRequire("customerContact.notes");
                return false;
            }
            AppParamsDTO custStatus = (AppParamsDTO) contactDialog.getOgCustStatus().getValue();
            if (custStatus == null) {
                contactDialog.getOgCustStatus().focus();
                CommonMessages.messageRequire("customerContact.status");
                return false;
            }
            return true;
        }
    });
}

From source file:com.anphat.customer.controller.CustomerContactController.java

private void addListenerCreateCustCareHistory() {
    CommonUtils.setVisibleBtnTablePanel(panelTblHistory, true, false, false, false);
    Button btnAddCustCareHistory = panelTblHistory.getAddButton();
    btnAddCustCareHistory.setCaption(BundleUtils.getString("label.history.care.addNew"));
    ShortcutUtils.setShortkeyAddNew(btnAddCustCareHistory);
    btnAddCustCareHistory.addClickListener(new CommonButtonClickListener() {

        @Override//from w ww  . j  ava 2s. c om
        public void execute() {
            List<CustomerContactDTO> lstCustContactDTOs = Lists.newArrayList();
            lstCustContactDTOs.addAll(
                    (Collection<? extends CustomerContactDTO>) panelTblContact.getMainTable().getItemIds());
            careHistoryDialog = new CustomerCareHistoryDialog(
                    BundleUtils.getString("customerCareHistoryForm.insert"), lstServices,
                    lstCustomerServiceStatus, lstCustContactDTOs);
            UI.getCurrent().addWindow(careHistoryDialog);
            addListenerBtnSaveCareHistory(careHistoryDialog);
            addBtnAddContactClickListener(careHistoryDialog.getBtnAddContact(), null);
        }
    });
}

From source file:com.anphat.customer.controller.CustomerContactController.java

private void addListenerBtnSaveCareHistory(final CustomerCareHistoryDialog careDialog) {
    Button btnSave = careDialog.getBtnSave();
    ShortcutUtils.setShortcutKey(btnSave);
    btnSave.addClickListener(new CommonButtonClickListener() {
        String taNotes;/*from   ww  w.ja v a  2  s.c  om*/
        CustomerContactDTO contact;

        @Override
        public boolean isValidated() {
            taNotes = DataUtil.getStringNullOrZero(careDialog.getTaNotes().getValue());
            contact = (CustomerContactDTO) careDialog.getF9Contact().codeCombo.getValue();
            if (contact == null || DataUtil.isStringNullOrEmpty(contact.getName())) {
                careDialog.getF9Contact().codeCombo.focus();
                CommonMessages.showMessageRequired("customerCareHistoryForm.contact");
                return false;
            }
            if (DataUtil.isStringNullOrEmpty(taNotes)) {
                careDialog.getTaNotes().focus();
                CommonMessages.showMessageRequired("customerCareHistoryForm.notes");
                return false;
            }

            return true;
        }

        @Override
        public void execute() {
            CustomerCareHistoryDTO careHistoryDTO = careDialog.getInputObject(selectedCust);
            ResultDTO result = saveCustomerCareHistory(careHistoryDTO);
            if (result != null && Constants.SUCCESS.equals(result.getMessage())) {
                careDialog.close();
            }
        }
    });
}

From source file:com.anphat.customer.controller.ListCustomerControllerForOnePage.java

private void initTable(int pageLength) {
    tblCustomer = panel.getMainTable();/*  w ww .  j av  a  2 s  .c  o  m*/
    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.list.controller.CategoryListController.java

public void initTable() {
    beanItemContainerCategoryList = new BeanItemContainer<>(CategoryListDTO.class);

    tblCategoryList.addGeneratedColumn(lblDelete, new CustomTable.ColumnGenerator() {
        @Override/*from  www. j a  v  a 2s  .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.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);/*  www  .  ja v a2  s .  c om*/
        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  ww w .j  ava2 s .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.ListStaffController.java

private void initTable() {
    itemContainer = new BeanItemContainer<>(StaffDTO.class);
    //add detail link into tblstaff
    tblStaffs.addGeneratedColumn("resetPassword", new CustomTable.ColumnGenerator() {
        @Override//  w  ww .j a va 2 s . c  o m
        public Object generateCell(CustomTable source, final Object itemId, Object columnId) {
            final Button linkDetails = new Button();
            linkDetails.setIcon(FontAwesome.KEY);
            linkDetails.setStyleName(Runo.BUTTON_LINK);
            linkDetails.addStyleName("v-button-link-left");
            linkDetails.addClickListener(new Button.ClickListener() {

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    final StaffDTO staffDTO = (StaffDTO) itemId;
                    ConfirmDialog.show(UI.getCurrent(), "Reset mt khu",
                            "?t li mt khu mc nh cho ti khon " + staffDTO.getName(),
                            "?ng ", "Hu b?", new ConfirmDialog.Listener() {
                                @Override
                                public void onClose(ConfirmDialog dialog) {
                                    if (dialog.isConfirmed()) {
                                        staffDTO.setPassword(
                                                DataUtil.md5(BundleUtils.getStringCas("password_default")));
                                        // Confirmed to continue
                                        String result = WSStaff.updateStaff(staffDTO);
                                        if (Constants.SUCCESS.equalsIgnoreCase(result)) {
                                            CommonMessages.showMessageUpdateSuccess("pass");
                                        }
                                    }
                                }
                            });
                }
            });
            linkDetails.setDescription(BundleUtils.getString("resetPassword"));
            return linkDetails;
        }
    });
    tblStaffs.addGeneratedColumn("detailRole", new CustomTable.ColumnGenerator() {

        @Override
        public Object generateCell(CustomTable source, final Object itemId, Object columnId) {
            final Button btnAddRole = new Button(BundleUtils.getString("detail.roles"));
            btnAddRole.setStyleName(Runo.BUTTON_LINK);
            btnAddRole.addStyleName("v-button-link-left");
            btnAddRole.addClickListener(new Button.ClickListener() {

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    StaffDTO staffDTO = (StaffDTO) itemId;
                    MapStaffRolesDiaglog diaglog = new MapStaffRolesDiaglog(
                            BundleUtils.getString("map.staff.roles.view"));
                    diaglog.setTblRolesVisiableOnly();

                    MapStaffRolesController controller = new MapStaffRolesController(diaglog);
                    controller.initOnlyView(staffDTO);
                    UI.getCurrent().addWindow(diaglog);
                }
            });
            btnAddRole.setDescription(BundleUtils.getString("lb.header.staff.addCustomer.decr"));
            return btnAddRole;
        }
    });
    //160316 NgocND6 them chuc nang hang hoa quan ly cua tung nhan vien
    tblStaffs.addGeneratedColumn("goodsManage", new CustomTable.ColumnGenerator() {

        @Override
        public Object generateCell(CustomTable source, final Object itemId, Object columnId) {
            final Button linkDetails = new Button(BundleUtils.getString("lb.header.staff.goodsManage"));
            linkDetails.setStyleName(Runo.BUTTON_LINK);
            linkDetails.addStyleName("v-button-link-left");
            linkDetails.addClickListener(new Button.ClickListener() {

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    //                        StaffDTO staffDTO = (StaffDTO) itemId;
                    //                        if (staffDTO.getStatus().equalsIgnoreCase("1")) {
                    //                            getListMapStaffCustomer(staffDTO);
                    //                            if (listMapStaffCustomer != null) {
                    //                                DialogGoodsManagement dialogGoodsManagement = new DialogGoodsManagement(BundleUtils.getString("transfer.goods.manage.managoodsassignstaff"));
                    //                                dialogGoodsManagement.initDialog();
                    //                                DialogGoodsManagementController dgmc = new DialogGoodsManagementController(staffDTO, dialogGoodsManagement);
                    //                                UI.getCurrent().addWindow(dialogGoodsManagement);
                    //                            }else{
                    //                                Notification.show(BundleUtils.getString("transfer.goods.manage.staffdontassigncust"), Notification.Type.WARNING_MESSAGE);
                    //                            }
                    //                        } else {
                    //                            Notification.show(BundleUtils.getString("dept.staff.alert.message.notActive"));
                    //                        }
                }
            });
            linkDetails.setDescription(BundleUtils.getString("lb.header.staff.addCustomer.decr"));
            return linkDetails;
        }
    });
    tableUtils = new TableUtils();
    tableUtils.generateColumn(tblStaffs);
    CommonFunctionTableFilter.initTable(staffTablePanel, headerData, itemContainer, captionfieldsetListStaff, 5,
            "lb.header.staff");
    CommonUtils.convertFieldAppParamTable(tblStaffs, Constants.STAFF.STATUS,
            Constants.APP_PARAMS.COMMON_STATUS);
    CommonUtils.convertFieldAppParamTable(tblStaffs, Constants.STAFF.STAFF_TYPE,
            Constants.APP_PARAMS.STAFF_TYPE);
    //        tblStaffs.setColumnHeader("addStock", BundleUtils.getString("add.staff.for.stock"));

}