Example usage for com.vaadin.ui Notification show

List of usage examples for com.vaadin.ui Notification show

Introduction

In this page you can find the example usage for com.vaadin.ui Notification show.

Prototype

public static Notification show(String caption) 

Source Link

Document

Shows a notification message on the middle of the current page.

Usage

From source file:com.anphat.list.controller.ObjectsController.java

public void InsertOrUpdate(final ObjectsDTO objectsDTO) {
    popupAddObjects = new PopupAddObjects();
    ComboComponent combo = new ComboComponent();
    combo.fillDataCombo(popupAddObjects.getCbxStatus(), Constants.NULL, Constants.ACTIVE);
    //        BeanItemContainer containerStatus = new BeanItemContainer<>(AppParamsDTO.class);
    //        containerStatus.addAll(lstStatus);
    //        CommonUtils.initCombobox(popupAddObjects.getCbxStatus(), containerStatus, Constants.APP_PARAMS.PAR_NAME);
    if (objectsDTO.getCode() != null) {
        popupAddObjects.getTxtCode().setValue(objectsDTO.getCode());
    } else {//from   w  ww . ja  v a 2 s.  c o m
        popupAddObjects.getTxtCode().setValue("");
    }
    if (objectsDTO.getName() != null) {
        popupAddObjects.getTxtName().setValue(objectsDTO.getName());
    } else {
        popupAddObjects.getTxtName().setValue("");
    }
    if (objectsDTO.getUrl() != null) {
        popupAddObjects.getTxtUrl().setValue(objectsDTO.getUrl());
    } else {
        popupAddObjects.getTxtUrl().setValue("");
    }
    if (objectsDTO.getDescription() != null) {
        popupAddObjects.getTxtDescription().setValue(objectsDTO.getDescription());
    } else {
        popupAddObjects.getTxtDescription().setValue("");
    }
    if (objectsDTO.getObjectType() != null) {
        popupAddObjects.getTxtObjectType().setValue(objectsDTO.getObjectType());
    } else {
        popupAddObjects.getTxtObjectType().setValue("");
    }
    if (objectsDTO.getStatus() != null) {
        AppParamsDTO statusDefault = null;
        for (AppParamsDTO status : lstStatus) {
            if (status.getParCode().equals(objectsDTO.getStatus())) {
                statusDefault = status;
            }
        }
        popupAddObjects.getCbxStatus().setValue(statusDefault);
    } else {
        popupAddObjects.getCbxStatus().setValue(null);
    }

    popupAddObjects.getBtnSave().addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {

            if (popupAddObjects.getTxtCode().getValue() != null
                    || popupAddObjects.getTxtCode().getValue().equals("")) {
                objectsDTO.setCode(popupAddObjects.getTxtCode().getValue());
            } else {
                Notification.show(BundleUtils.getString("objects.code.isnotnull"));
                event.getButton().setEnabled(true);
                return;
            }
            if (popupAddObjects.getTxtName().getValue() != null
                    || popupAddObjects.getTxtName().getValue().equals("")) {
                objectsDTO.setName(popupAddObjects.getTxtName().getValue());
            } else {
                Notification.show(BundleUtils.getString("objects.code.isnotnull"));
                event.getButton().setEnabled(true);
                return;
            }
            objectsDTO.setAppId("1");
            objectsDTO.setUrl(popupAddObjects.getTxtUrl().getValue());
            objectsDTO.setDescription(popupAddObjects.getTxtDescription().getValue());
            objectsDTO.setObjectType(popupAddObjects.getTxtObjectType().getValue());
            AppParamsDTO status = (AppParamsDTO) popupAddObjects.getCbxStatus().getValue();
            if (status != null) {
                objectsDTO.setStatus(status.getParCode());
            } else {
                Notification.show(BundleUtils.getString("Objects.status.require"));
            }
            if (objectsDTO.getObjectId() == null) {
                try {
                    ResultDTO resultDTO = serviceObjects.insertObjects(objectsDTO);
                    if (resultDTO.getMessage().equals(Constants.SUCCESS)) {
                        CommonMessages.showMessageImportSuccess("function.object");
                    } else {
                        CommonMessages.showInsertFail("function.object");
                    }

                } catch (Exception e) {
                    CommonMessages.showInsertFail("function.object");
                }

            } else {
                try {
                    String message = serviceObjects.updateObjects(objectsDTO);
                    if (message.equals(Constants.SUCCESS)) {
                        CommonMessages.showMessageUpdateSuccess("function.object");
                    } else {
                        CommonMessages.showUpdateFail("function.object");
                    }
                } catch (Exception e) {
                    CommonMessages.showUpdateFail("function.object");
                }
            }
            event.getButton().setEnabled(true);
        }
    });
    popupAddObjects.getBtnClose().addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            popupAddObjects.close();
        }
    });

    UI.getCurrent().addWindow(popupAddObjects);
}

From source file:com.anphat.list.controller.PriceInfoController.java

public void InsertOrUpdate(final PriceInfoDTO priceInfoDTO) {
    popupAddPriceInfo = new PopupAddPriceInfo();
    popupAddPriceInfo.setIsUpdate(isUpdate);

    if (!isUpdate) {
        priceInfoDTO.setId(null);//from  w  ww.  j  av a 2 s  .c  om
    }

    BeanItemContainer containerProvider = new BeanItemContainer<>(AppParamsDTO.class);
    containerProvider.addAll(lstProvider);
    CommonUtils.initCombobox(popupAddPriceInfo.getCbxProvider(), containerProvider,
            Constants.APP_PARAMS.PAR_NAME);
    BeanItemContainer containerType = new BeanItemContainer<>(AppParamsDTO.class);
    containerType.addAll(lstType);
    CommonUtils.initCombobox(popupAddPriceInfo.getCbxType(), containerType, Constants.APP_PARAMS.PAR_NAME);
    BeanItemContainer containerStatus = new BeanItemContainer<>(AppParamsDTO.class);
    containerStatus.addAll(lstStatus);
    CommonUtils.initCombobox(popupAddPriceInfo.getCbxStatus(), containerStatus, Constants.APP_PARAMS.PAR_NAME);
    //        comboComponent.fillDataCombo(popupAddPriceInfo.getCbxStatus(), "", "1");
    if (priceInfoDTO.getCode() != null) {
        popupAddPriceInfo.getTxtCode().setValue(priceInfoDTO.getCode());
    } else {
        popupAddPriceInfo.getTxtCode().setValue("");
    }
    if (priceInfoDTO.getName() != null) {
        popupAddPriceInfo.getTxtName().setValue(priceInfoDTO.getName());
    } else {
        popupAddPriceInfo.getTxtName().setValue("");
    }
    if (priceInfoDTO.getPrice() != null) {
        popupAddPriceInfo.getTxtPrice().setValue(priceInfoDTO.getPrice());
    } else {
        popupAddPriceInfo.getTxtPrice().setValue("");
    }
    if (priceInfoDTO.getTokenPrice() != null) {
        popupAddPriceInfo.getTxtTokenPrice().setValue(priceInfoDTO.getTokenPrice());
    } else {
        popupAddPriceInfo.getTxtTokenPrice().setValue("");
    }
    if (priceInfoDTO.getProvider() != null) {
        AppParamsDTO providerDefault = null;
        for (AppParamsDTO provider : lstProvider) {
            if (provider.getParCode().equals(priceInfoDTO.getProvider())) {
                providerDefault = provider;
            }
        }
        popupAddPriceInfo.getCbxProvider().setValue(providerDefault);
    } else {
        popupAddPriceInfo.getCbxProvider().setValue(null);
    }
    if (priceInfoDTO.getType() != null) {
        AppParamsDTO typeDefault = null;
        for (AppParamsDTO type : lstType) {
            if (type.getParCode().equals(priceInfoDTO.getType())) {
                typeDefault = type;
            }
        }
        popupAddPriceInfo.getCbxType().setValue(typeDefault);
    } else {
        popupAddPriceInfo.getCbxType().setValue(null);
    }
    if (priceInfoDTO.getStatus() != null) {
        //            AppParamsDTO statusDefault = null;
        //            for (AppParamsDTO status : lstStatus) {
        //                if (status.getParCode().equals(priceInfoDTO.getStatus())) {
        //                    statusDefault = status;
        //                }
        //            }
        //            popupAddPriceInfo.getCbxStatus().setValue(statusDefault);
        comboComponent.fillDataCombo(popupAddPriceInfo.getCbxStatus(), "", priceInfoDTO.getStatus());
    } else {
        comboComponent.fillDataCombo(popupAddPriceInfo.getCbxStatus(), "", "1");
    }

    popupAddPriceInfo.getBtnSave().addClickListener((event) -> {
        if (popupAddPriceInfo.getTxtCode().getValue() != null
                || popupAddPriceInfo.getTxtCode().getValue().equals("")) {
            priceInfoDTO.setCode(popupAddPriceInfo.getTxtCode().getValue());
        } else {
            Notification.show(BundleUtils.getString("priceInfo.code.isnotnull"));
            return;
        }
        priceInfoDTO.setName(popupAddPriceInfo.getTxtName().getValue());
        priceInfoDTO.setPrice(popupAddPriceInfo.getTxtPrice().getValue());
        priceInfoDTO.setTokenPrice(popupAddPriceInfo.getTxtTokenPrice().getValue());
        AppParamsDTO provider = (AppParamsDTO) popupAddPriceInfo.getCbxProvider().getValue();
        priceInfoDTO.setProvider(provider.getParCode());
        AppParamsDTO type = (AppParamsDTO) popupAddPriceInfo.getCbxType().getValue();
        priceInfoDTO.setType(type.getParCode());
        AppParamsDTO status = (AppParamsDTO) popupAddPriceInfo.getCbxStatus().getValue();
        priceInfoDTO.setStatus(status.getParCode());
        if (priceInfoDTO.getId() == null) {
            try {
                ResultDTO resultDTO = servicePriceInfo.insertPriceInfo(priceInfoDTO);
                if (Constants.SUCCESS.equals(resultDTO.getMessage())) {
                    PriceInfoDTO priceInfoDTO1 = new PriceInfoDTO(priceInfoDTO);
                    priceInfoDTO1.setId(resultDTO.getId());
                    tblPriceInfo.unselect(priceInfoDTO);
                    tblPriceInfo.addItemAfter(null, priceInfoDTO1);
                    tblPriceInfo.select(priceInfoDTO1);
                    popupAddPriceInfo.close();
                    CommonUtils.showInsertSuccess(BundleUtils.getString("price.info"));
                } else {
                    CommonUtils.showInsertFail(BundleUtils.getString("price.info"));
                }

            } catch (Exception e) {
                CommonUtils.showInsertFail(BundleUtils.getString("price.info"));
            }

        } else {
            try {
                String message = servicePriceInfo.updatePriceInfo(priceInfoDTO);
                if (message.equals(Constants.SUCCESS)) {
                    CommonUtils.reloadTable(tblPriceInfo, priceInfoDTO);
                    popupAddPriceInfo.close();
                    CommonUtils.showUpdateSuccess(BundleUtils.getString("price.info"));
                } else {
                    CommonUtils.showUpdateFail(BundleUtils.getString("price.info"));

                }
            } catch (Exception e) {
                CommonUtils.showUpdateFail(BundleUtils.getString("price.info"));
            }
        }
    });
    popupAddPriceInfo.getBtnClose().addClickListener(e -> {
        popupAddPriceInfo.close();
    });

    UI.getCurrent().addWindow(popupAddPriceInfo);
}

From source file:com.anphat.list.controller.RolesController.java

public void InsertOrUpdate(final RolesDTO rolesDTO) {
    popupAddRoles = new PopupAddRoles();

    BeanItemContainer containerStatus = new BeanItemContainer<>(AppParamsDTO.class);
    containerStatus.addAll(lstStatus);//from ww w. j a  va 2 s.  c o  m
    CommonUtils.initCombobox(popupAddRoles.getCbxStatus(), containerStatus, Constants.APP_PARAMS.PAR_NAME);
    if (rolesDTO.getCode() != null) {
        popupAddRoles.getTxtCode().setValue(rolesDTO.getCode());
    } else {
        popupAddRoles.getTxtCode().setValue("");
    }
    if (rolesDTO.getName() != null) {
        popupAddRoles.getTxtName().setValue(rolesDTO.getName());
    } else {
        popupAddRoles.getTxtName().setValue("");
    }
    if (rolesDTO.getDescription() != null) {
        popupAddRoles.getTxtDescription().setValue(rolesDTO.getDescription());
    } else {
        popupAddRoles.getTxtDescription().setValue("");
    }
    if (rolesDTO.getStatus() != null) {
        AppParamsDTO statusDefault = null;
        for (AppParamsDTO status : lstStatus) {
            if (status.getParCode().equals(rolesDTO.getStatus())) {
                statusDefault = status;
            }
        }
        popupAddRoles.getCbxStatus().setValue(statusDefault);
    } else {
        popupAddRoles.getCbxStatus().setValue(null);
    }

    popupAddRoles.getBtnSave().addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (popupAddRoles.getTxtCode().getValue() != null
                    || popupAddRoles.getTxtCode().getValue().equals("")) {
                rolesDTO.setCode(popupAddRoles.getTxtCode().getValue());
            } else {
                Notification.show(BundleUtils.getString("roles.code.isnotnull"));
                return;
            }
            if (popupAddRoles.getTxtName().getValue() != null
                    || popupAddRoles.getTxtName().getValue().equals("")) {
                rolesDTO.setName(popupAddRoles.getTxtName().getValue());
            } else {
                Notification.show(BundleUtils.getString("roles.code.isnotnull"));
                return;
            }
            AppParamsDTO status = (AppParamsDTO) popupAddRoles.getCbxStatus().getValue();
            rolesDTO.setStatus(status.getParCode());
            if (rolesDTO.getRoleId() == null) {
                try {
                    ResultDTO resultDTO = serviceRoles.insertRoles(rolesDTO);
                    if (resultDTO.getMessage().equals(Constants.SUCCESS)) {
                        Notification.show(BundleUtils.getString("roles.insert.success"));
                    } else {
                        Notification.show(BundleUtils.getString("roles.insert.fail"));
                    }

                } catch (Exception e) {
                    Notification.show(BundleUtils.getString("roles.insert.fail"));
                }

            } else {
                try {
                    String message = serviceRoles.updateRoles(rolesDTO);
                    if (message.equals(Constants.SUCCESS)) {
                        Notification.show(BundleUtils.getString("roles.update.success"));
                    } else {
                        Notification.show(BundleUtils.getString("roles.update.fail"));
                    }
                } catch (Exception e) {
                    Notification.show(BundleUtils.getString("roles.update.fail"));
                }
            }
        }
    });
    popupAddRoles.getBtnClose().addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            popupAddRoles.close();
        }
    });

    UI.getCurrent().addWindow(popupAddRoles);
}

From source file:com.anphat.list.controller.RolesController.java

public void initTable() {

    tblRoles.setSortDisabled(true);/*from   w  ww . j a  v  a 2 s.com*/
    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 InsertOrUpdate(final ServicesDTO servicesDTO) {
    popupAddServices = new PopupAddServices();

    BeanItemContainer containerStatus = new BeanItemContainer<>(AppParamsDTO.class);
    containerStatus.addAll(lstStatus);/*from  w  ww . j av  a2s  .co m*/
    CommonUtils.initCombobox(popupAddServices.getCbxStatus(), containerStatus, Constants.APP_PARAMS.PAR_NAME);
    BeanItemContainer containerType = new BeanItemContainer<>(AppParamsDTO.class);
    containerType.addAll(lstType);
    CommonUtils.initCombobox(popupAddServices.getCbxType(), containerType, Constants.APP_PARAMS.PAR_NAME);
    if (servicesDTO.getCode() != null) {
        popupAddServices.getTxtCode().setValue(servicesDTO.getCode());
    } else {
        popupAddServices.getTxtCode().setValue("");
    }
    if (servicesDTO.getDescription() != null) {
        popupAddServices.getTxtDescription().setValue(servicesDTO.getDescription());
    } else {
        popupAddServices.getTxtDescription().setValue("");
    }
    if (servicesDTO.getExpiryDate() != null) {
        try {
            popupAddServices.getPopExpiryDate()
                    .setValue(DateUtil.convertStringToTime(servicesDTO.getExpiryDate(), "dd/MM/yyyy HH:mm:ss"));
        } catch (ParseException ex) {
            Logger.getLogger(ServicesController.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {
        popupAddServices.getPopExpiryDate().setValue(null);
    }
    if (servicesDTO.getIssueDate() != null) {
        try {
            popupAddServices.getPopIssueDate()
                    .setValue(DateUtil.convertStringToTime(servicesDTO.getIssueDate(), "dd/MM/yyyy HH:mm:ss"));
        } catch (ParseException ex) {
            Logger.getLogger(ServicesController.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {
        popupAddServices.getPopIssueDate().setValue(null);
    }
    if (servicesDTO.getName() != null) {
        popupAddServices.getTxtName().setValue(servicesDTO.getName());
    } else {
        popupAddServices.getTxtName().setValue("");
    }
    if (servicesDTO.getServiceGroup() != null) {
        popupAddServices.getTxtServiceGroup().setValue(servicesDTO.getServiceGroup());
    } else {
        popupAddServices.getTxtServiceGroup().setValue("");
    }
    if (servicesDTO.getStatus() != null) {
        AppParamsDTO statusDefault = null;
        for (AppParamsDTO status : lstStatus) {
            if (status.getParCode().equals(servicesDTO.getStatus())) {
                statusDefault = status;
            }
        }
        popupAddServices.getCbxStatus().setValue(statusDefault);
    } else {
        popupAddServices.getCbxStatus().setValue(null);
    }
    if (servicesDTO.getType() != null) {
        AppParamsDTO typeDefault = null;
        for (AppParamsDTO type : lstType) {
            if (type.getParCode().equals(servicesDTO.getType())) {
                typeDefault = type;
            }
        }
        popupAddServices.getCbxType().setValue(typeDefault);
    } else {
        popupAddServices.getCbxType().setValue(null);
    }

    popupAddServices.getBtnSave().addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (popupAddServices.getTxtCode().getValue() != null
                    || popupAddServices.getTxtCode().getValue().equals("")) {
                servicesDTO.setCode(popupAddServices.getTxtCode().getValue());
            } else {
                Notification.show(BundleUtils.getString("services.code.isnotnull"));
                return;
            }
            Date expiryDate = popupAddServices.getPopExpiryDate().getValue();
            if (expiryDate != null) {
                servicesDTO.setExpiryDate(DateUtil.date2ddMMyyyyString(expiryDate));
            } else {
                servicesDTO.setExpiryDate(null);
            }
            Date issueDate = popupAddServices.getPopIssueDate().getValue();
            if (issueDate != null) {
                servicesDTO.setIssueDate(DateUtil.date2ddMMyyyyString(issueDate));
            } else {
                Notification.show(BundleUtils.getString("Services.issueDate.require"));
            }
            if (popupAddServices.getTxtName().getValue() != null
                    || popupAddServices.getTxtName().getValue().equals("")) {
                servicesDTO.setName(popupAddServices.getTxtName().getValue());
            } else {
                Notification.show(BundleUtils.getString("services.code.isnotnull"));
                return;
            }
            servicesDTO.setServiceGroup(popupAddServices.getTxtServiceGroup().getValue());
            AppParamsDTO status = (AppParamsDTO) popupAddServices.getCbxStatus().getValue();
            if (status != null) {
                servicesDTO.setStatus(status.getParCode());
            } else {
                Notification.show(BundleUtils.getString("Services.status.require"));
            }
            AppParamsDTO type = (AppParamsDTO) popupAddServices.getCbxType().getValue();
            servicesDTO.setType(type.getParCode());
            if (servicesDTO.getServiceId() == null) {
                try {
                    ResultDTO resultDTO = serviceServices.insertServices(servicesDTO);
                    if (resultDTO.getMessage().equals(Constants.SUCCESS)) {
                        Notification.show(BundleUtils.getString("services.insert.success"));
                    } else {
                        Notification.show(BundleUtils.getString("services.insert.fail"));
                    }

                } catch (Exception e) {
                    Notification.show(BundleUtils.getString("services.insert.fail"));
                }

            } else {
                try {
                    String message = serviceServices.updateServices(servicesDTO);
                    if (message.equals(Constants.SUCCESS)) {
                        Notification.show(BundleUtils.getString("services.update.success"));
                    } else {
                        Notification.show(BundleUtils.getString("services.update.fail"));
                    }
                } catch (Exception e) {
                    Notification.show(BundleUtils.getString("services.update.fail"));
                }
            }
        }
    });
    popupAddServices.getBtnClose().addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            popupAddServices.close();
        }
    });

    UI.getCurrent().addWindow(popupAddServices);
}

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 ww w  .j av  a2  s  . co  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);
}

From source file:com.before.vaadin.ui.CustomerView.java

public void save(Customer customer) {
    if (customer.getCustomerId() == null) {
        cf.create(customer);/*w ww .j  a v a 2 s  . c o m*/
    } else {
        cf.edit(customer);
    }
    listEntities();
    Notification.show("Saved!");
}

From source file:com.cavisson.gui.dashboard.components.calender.NotificationTestUI.java

License:Apache License

@Override
protected void init(com.vaadin.server.VaadinRequest request) {
    GridLayout content = new GridLayout(1, 2);
    content.setSizeFull();/*from   w w w.  j ava  2 s  .  c om*/
    content.setRowExpandRatio(1, 1.0f);
    setContent(content);
    final Button btn = new Button("Show working notification", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Notification.show("This will disappear when you move your mouse!");
        }
    });
    content.addComponent(btn);

    provider = new DummyEventProvider();
    final Calendar cal = new Calendar(provider);
    cal.setLocale(Locale.US);
    cal.setSizeFull();
    cal.setHandler(new DateClickHandler() {
        @Override
        public void dateClick(DateClickEvent event) {
            provider.addEvent(event.getDate());
            Notification.show("This should disappear, but if wont unless clicked.");

            // this requestRepaint call interferes with the notification
            cal.markAsDirty();
        }
    });
    content.addComponent(cal);

    java.util.Calendar javaCal = java.util.Calendar.getInstance();
    javaCal.set(java.util.Calendar.YEAR, 2000);
    javaCal.set(java.util.Calendar.MONTH, 0);
    javaCal.set(java.util.Calendar.DAY_OF_MONTH, 1);
    Date start = javaCal.getTime();
    javaCal.set(java.util.Calendar.DAY_OF_MONTH, 31);
    Date end = javaCal.getTime();

    cal.setStartDate(start);
    cal.setEndDate(end);
}

From source file:com.cavisson.gui.dashboard.components.charts.Impl.PieChart.java

@Override
public Component getChart() {
    Chart chart = new Chart(ChartType.PIE);

    Configuration conf = chart.getConfiguration();
    chart.setSizeFull();//from   w ww.ja va 2 s .co  m
    conf.setTitle("Browser usage year 2010");

    PlotOptionsPie plotOptions = new PlotOptionsPie();
    plotOptions.setCursor(Cursor.POINTER);
    Labels dataLabels = new Labels();
    dataLabels.setEnabled(true);
    dataLabels.setColor(SolidColor.BLACK);
    dataLabels.setConnectorColor(SolidColor.BLACK);
    dataLabels.setFormatter("''+ this.point.name +': '+ this.percentage +' %'");
    //plotOptions.setDataLabels(dataLabels);
    //conf.setPlotOptions(plotOptions);

    conf.setSeries(getBrowserMarketShareSeries());

    chart.addLegendItemClickListener(new LegendItemClickListener() {
        @Override
        public void onClick(LegendItemClickEvent event) {
            Notification.show("Legend item click" + " : " + event.getSeriesItemIndex() + " : "
                    + ((DataSeries) event.getSeries()).get(event.getSeriesItemIndex()).getName());
        }
    });
    chart.drawChart();
    return chart;
}