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:ch.bfh.ti.soed.hs16.srs.yellow.views.MainView.java

License:Open Source License

public MainView() {

    setSizeFull();//from ww  w. j  a  v  a  2 s. c om

    headerLayout = new HorizontalLayout();
    date = new Date();
    limitDate = Calendar.getInstance();
    limitDate.setTime(date);
    limitDate.add(Calendar.YEAR, 1);
    lastDate = limitDate.getTime();

    fromDate.setValue(date);
    fromDate.setRangeStart(date);
    fromDate.setRangeEnd(lastDate);
    fromDate.setImmediate(true);
    fromDate.setResolution(Resolution.MINUTE);

    toDate.setRangeStart(date);
    toDate.setRangeEnd(lastDate);
    toDate.setImmediate(true);
    toDate.setResolution(Resolution.MINUTE);

    objSelect.setSizeFull();
    equipSelect.setSizeFull();
    fromDate.setSizeFull();
    toDate.setSizeFull();
    searchBtn.setSizeFull();

    signupBtn.addClickListener(e -> {
        navigationRoot.navigator.navigateTo(NavigationRoot.SIGNUPVIEW);
    });

    loginBtn.addClickListener(e -> {
        navigationRoot.navigator.navigateTo(NavigationRoot.LOGINVIEW);
    });

    searchBtn.addClickListener(evt -> {
        Notification.show("Sorry, search will be made later with Vaadin Grid.");
    });

    loginLayout.addComponents(signupBtn, loginBtn);

    headerLayout.addComponent(titleLbl);
    leftVLayout.addComponents(fromDate, objSelect);
    leftVLayout.setSpacing(true);
    leftVLayout.setSizeFull();
    rightVLayout.addComponents(toDate, equipSelect);
    rightVLayout.setSpacing(true);
    rightVLayout.setSizeFull();
    inputLayout.addComponents(leftVLayout, rightVLayout);
    inputLayout.setSpacing(true);
    inputLayout.setSizeFull();

    searchLayout.addComponents(headerLayout, inputLayout, searchBtn);
    searchLayout.setComponentAlignment(headerLayout, Alignment.TOP_CENTER);
    searchLayout.setMargin(true);
    searchLayout.setSpacing(true);
    searchLayout.setWidth(500, Sizeable.Unit.PIXELS);

    panelContent.addComponents(loginLayout, searchLayout);
    panelContent.setComponentAlignment(searchLayout, Alignment.MIDDLE_CENTER);
    panelContent.setComponentAlignment(loginLayout, Alignment.TOP_RIGHT);
    panel.setContent(panelContent);
    setCompositionRoot(panelContent);
}

From source file:ch.bfh.ti.soed.hs16.srs.yellow.views.SignUpView.java

License:Open Source License

public SignUpView() {

    sUName.setRequired(true);/*from w w w .  j av a2 s  .  co m*/
    sPwd.setRequired(true);
    fName.setRequired(true);
    lName.setRequired(true);
    emailField.setRequired(true);

    sUName.setSizeFull();
    sPwd.setSizeFull();
    fName.setSizeFull();
    lName.setSizeFull();
    emailField.setSizeFull();
    sSignUpBtn.setSizeFull();

    backBtn.addClickListener(e -> {
        navigationRoot.navigator.navigateTo(NavigationRoot.MAINVIEW);
    });

    sSignUpBtn.addClickListener(e -> {
        String result = checkIfAllFieldsAreValid();
        if (!(result == "")) {
            Notification.show(result);
        } else if (checkIfAllTextEntryNonEmpty()) {
            jpaProxyDataAccessor.makeCustomer(this.sUName.getValue(), this.sPwd.getValue());
            Notification.show("User created successfully");
            backBtn.click();
        } else {
            Notification.show("Please fill all required fields to create an user!");
        }
    });

    signFormLayout.addComponents(sUName, sPwd, fName, lName, emailField, sSignUpBtn);
    signFormLayout.setMargin(true);
    signFormLayout.setWidth(500, Sizeable.Unit.PIXELS);

    sHeader.addComponent(backBtn);

    signVLayout.addComponents(sHeader, signFormLayout);
    signVLayout.setSpacing(true);
    signVLayout.setComponentAlignment(signFormLayout, Alignment.MIDDLE_CENTER);
    signVLayout.setComponentAlignment(sHeader, Alignment.TOP_RIGHT);

    setCompositionRoot(signVLayout);
}

From source file:ch.wscr.management.ui.view.MemberView.java

private void setCommitHandler(final Grid grid) {
    grid.getEditorFieldGroup().addCommitHandler(new FieldGroup.CommitHandler() {
        @Override// ww w .  j av a2 s.c  om
        public void preCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException {
            // Do nothing
        }

        @Override
        public void postCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException {
            BeanItem<Member> item = (BeanItem<Member>) commitEvent.getFieldBinder().getItemDataSource();

            memberRepository.saveAndFlush(item.getBean());

            Notification.show("Daten gespeichert");
        }
    });
}

From source file:cirad.cgh.vcf2fasta.view.Vcf2fastaForm.java

License:Open Source License

private ClickListener getSubmitButtonClickListener() {
    return new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @SuppressWarnings("rawtypes")
        @Override/*from  w ww .ja  v a  2  s  . c o  m*/
        public void buttonClick(ClickEvent event) {
            try {
                resultLayout.removeAllComponents();

                fieldGroup.commit();

                /*
                System.out.println(vcf2fastaInputBean.getAnalysis());
                System.out.println(vcf2fastaInputBean.getAccession());
                System.out.println(vcf2fastaInputBean.getContig());
                System.out.println(vcf2fastaInputBean.getInterval());
                */

                UI.getCurrent().setPollInterval(200);
            } catch (CommitException e) {
                Map<Field<?>, InvalidValueException> invalidFields = e.getInvalidFields();
                for (Map.Entry<Field<?>, InvalidValueException> invalidField : invalidFields.entrySet()) {
                    ((AbstractField) invalidField.getKey()).setValidationVisible(true);
                }
                if (invalidFields.isEmpty()) {
                    e.printStackTrace();
                    Notification.show("VCF2FASTA ERROR, Please try again");
                }
            }
        }
    };
}

From source file:co.edu.icesi.academ.client.perfiles.administrador.PanelEditarMateria.java

License:Open Source License

/**
 * The constructor should first build the main layout, set the
 * composition root and then do any custom initialization.
 *
 * The constructor will not be automatically regenerated by the
 * visual editor.//from   w w  w  .ja v  a2  s  . c  om
 */
public PanelEditarMateria(MateriaBO materiaBO, BloqueBO bloqueBO) {
    this.setMateria(materiaBO);
    buildMainLayout();
    setCompositionRoot(mainLayout);

    // TODO add user code here

    this.bloqueBO = bloqueBO;
    txt_codigo.setValue(materiaBO.getCodigo());
    txt_codigo.setEnabled(false);
    txt_nombre.setValue(materiaBO.getNombre());

    btn_guardar.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            Notification.show("listo pa guaradar :P");
            MateriaBO materiaBO = new MateriaBO();
            materiaBO.setCodigo(txt_codigo.getValue().toString());
            materiaBO.setNombre(txt_nombre.getValue().toString());
            ControladorAdministrador.getInstance().editarMateria(materiaBO);
            actualizaMateriasVistas();
            actualizaListaMaterias();
        }
    });

}

From source file:co.edu.icesi.academ.client.perfiles.administrador.PanelProgramasBloques.java

License:Open Source License

/**
 * The constructor should first build the main layout, set the
 * composition root and then do any custom initialization.
 *
 * The constructor will not be automatically regenerated by the
 * visual editor.//from   w w w  .j  a v  a  2 s  .c  o  m
 */
public PanelProgramasBloques() {
    buildMainLayout();
    setCompositionRoot(mainLayout);

    btnEditarPrograma.setVisible(false);

    btnEditarPrograma.setEnabled(false);
    btnAsociar.setEnabled(false);
    btnDesasociar.setEnabled(false);

    btnEditarPrograma.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            int p = Integer.parseInt(tableProgramas.getValue().toString());
            ProgramaBO bo = listProgramas.get(p);
            PanelEditarPrograma panelEditarPrograma = new PanelEditarPrograma(bo);
            ControladorAdministrador.getInstance().getAcademUI().mostrarVentanaEmergente(panelEditarPrograma,
                    "Editar programa");
        }
    });

    tableProgramas.addContainerProperty("Cdigo", Integer.class, null);
    tableProgramas.addContainerProperty("Programa", ProgramaBO.class, null);
    tableProgramas.addContainerProperty("Descripcin", String.class, null);
    tableProgramas.setImmediate(true);
    tableProgramas.setNullSelectionAllowed(false);
    tableProgramas.setSelectable(true);

    tableProgramas.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            try {
                btnAsociar.setEnabled(false);
                btnDesasociar.setEnabled(false);
                btnEditarPrograma.setEnabled(true);
                int i = Integer.parseInt(tableProgramas.getValue().toString());
                ControladorAdministrador.getInstance().cargarBloquesAsociadosPrograma(listProgramas.get(i));
                ControladorAdministrador.getInstance().cargarBloquesNoAsociadosPrograma(listProgramas.get(i));
            } catch (Exception e) {
                cargarProgramas(ControladorAdministrador.getInstance().darListaProgramas());
                Notification.show(e.getMessage() + " panelBloqueProgr");
            }
        }
    });

    tableBloquesAsociados.addContainerProperty("Bloques asociados", BloqueBO.class, null);
    tableBloquesAsociados.setImmediate(true);
    tableBloquesAsociados.setNullSelectionAllowed(false);
    tableBloquesAsociados.setSelectable(true);

    tableBloquesNoAsociados.addContainerProperty("Bloques no asociados", BloqueBO.class, null);
    tableBloquesNoAsociados.setImmediate(true);
    tableBloquesNoAsociados.setNullSelectionAllowed(false);
    tableBloquesNoAsociados.setSelectable(true);

    tableBloquesAsociados.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            try {
                Integer.parseInt(tableBloquesAsociados.getValue().toString());
                btnDesasociar.setEnabled(true);
            } catch (Exception e) {
                btnDesasociar.setEnabled(false);
            }
        }
    });

    tableBloquesNoAsociados.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            try {
                Integer.parseInt(tableBloquesNoAsociados.getValue().toString());
                btnAsociar.setEnabled(true);
            } catch (Exception e) {
                btnAsociar.setEnabled(false);
            }
        }
    });

    btnAsociar.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                int b = Integer.parseInt(tableBloquesNoAsociados.getValue().toString());
                BloqueBO bloque = listBloqNoAsoc.get(b);
                int p = Integer.parseInt(tableProgramas.getValue().toString());
                ProgramaBO programa = listProgramas.get(p);

                ControladorAdministrador.getInstance().asociarBloquesAPrograma(bloque, programa);
                ControladorAdministrador.getInstance().cargarBloquesAsociadosPrograma(programa);
                ControladorAdministrador.getInstance().cargarBloquesNoAsociadosPrograma(programa);

            } catch (Exception e) {
            }
        }
    });

    btnDesasociar.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                int b = Integer.parseInt(tableBloquesAsociados.getValue().toString());
                BloqueBO bloque = listBloqAsoc.get(b);
                int p = Integer.parseInt(tableProgramas.getValue().toString());
                ProgramaBO programa = listProgramas.get(p);

                ControladorAdministrador.getInstance().desAsociarBloquesAPrograma(bloque, programa);
                ControladorAdministrador.getInstance().cargarBloquesAsociadosPrograma(programa);
                ControladorAdministrador.getInstance().cargarBloquesNoAsociadosPrograma(programa);

            } catch (Exception e) {
            }
        }
    });

    btnCrearPrograma.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            ControladorAdministrador.getInstance().getAcademUI()
                    .mostrarVentanaEmergente(new PanelCrearPrograma(), "Crear programa");
        }
    });

}

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

@Override
public OutputStream receiveUpload(String filename, String mimeType) {
    try {/*from   ww w .  ja va2 s. c o m*/
        isCreateSheet = true;
        this.mimeType = mimeType;
        this.fileName = filename;
        File file = new File(Constants.PATH_UPLOAD + "Error");
        file.deleteOnExit();
        if (!filename.equals("")) {
            try {
                if (mimeType.equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
                        || mimeType.equals("application/vnd.ms-excel")) {
                    if (mimeType.equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) {
                        tempFile = File.createTempFile(Constants.PATH_UPLOAD + filename, "xlsx");
                        //                                Notification.show(BundleUtils.getString("common.message.excelfomat"));
                    } else {
                        tempFile = File.createTempFile(Constants.PATH_UPLOAD + filename, "xls");
                    }
                    isSucc = true;
                    tempFile.deleteOnExit();
                } else {
                    Notification.show(BundleUtils.getString("common.message.invalidfileformat"));
                    return new FileOutputStream(file);
                }

                return new FileOutputStream(tempFile);
            } catch (IOException e) {
                Notification.show(BundleUtils.getString("common.message.invalidfileformat"));
                return new FileOutputStream(file);
            }
        } else {
            isSucc = false;
            Notification.show(BundleUtils.getString("common.message.notselectfileyet"));
            return new FileOutputStream(file);
        }
    } catch (Exception e) {
        return null;
    }
}

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 a  va  2s  .c  o m*/
        public Object generateCell(CustomTable source, final Object itemId, Object columnId) {
            final CategoryListDTO categoryListDTO = (CategoryListDTO) itemId;
            ThemeResource iconVi = new ThemeResource("img/icon_delete.png");
            Image image = new Image(null, iconVi);
            image.addClickListener(new MouseEvents.ClickListener() {
                @Override
                public void click(MouseEvents.ClickEvent event) {
                    ConfirmDialog.show(UI.getCurrent(), BundleUtils.getString("titleMessage"),
                            BundleUtils.getString("bodyMessage"), BundleUtils.getString("yes"),
                            BundleUtils.getString("no"), new ConfirmDialog.Listener() {
                                @Override
                                public void onClose(ConfirmDialog dialog) {
                                    if (dialog.isConfirmed()) {
                                        categoryListDTO.setEndDate(DateUtil.date2ddMMyyyyHHMMss(new Date()));
                                        String message = serviceCategoryList
                                                .updateCategoryList(categoryListDTO);
                                        if (message.equals(Constants.SUCCESS)) {
                                            Notification.show(BundleUtils.getString("delete.success"));
                                            tblCategoryList.removeItem(itemId);
                                        } else {
                                            Notification.show(BundleUtils.getString("delete.fail"));
                                        }
                                    } else {
                                        // User did not confirm
                                    }
                                }
                            });
                }
            });

            return image;
        }

    });
    tblCategoryList.addGeneratedColumn("custQuantityDetail", new CustomTable.ColumnGenerator() {
        @Override
        public Object generateCell(CustomTable source, final Object itemId, Object columnId) {
            final CategoryListDTO categoryListDTO = (CategoryListDTO) itemId;
            if (DataUtil.isStringNullOrEmpty(categoryListDTO.getCustQuantity())) {
                return "";
            }
            Button btnDetail = new Button(categoryListDTO.getCustQuantity());
            btnDetail.setStyleName(Constants.ICON.V_LINK);
            btnDetail.addStyleName("v-link-button-left");
            btnDetail.addClickListener(new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    LinkedHashMap<String, CustomTable.Align> headerCustomerTable = BundleUtils
                            .getHeadersFilter("customer.status.detail");
                    String captionCustomerTable = BundleUtils.getString("customer.table.detail.caption");
                    String lang = "customer";
                    CustomerDialog customerDialog = new CustomerDialog(headerCustomerTable,
                            captionCustomerTable, lang);
                    customerDialog.initDialog(mapServices, mapCustServiceStatus, CustomerDTO.class);
                    List<CustomerDTO> lstCustomerOfMineName = WSCustomer
                            .getListCustomerOfMineName(categoryListDTO.getId());
                    customerDialog.setCustomerList2Table(lstCustomerOfMineName);
                    UI.getCurrent().addWindow(customerDialog);
                    event.getButton().setEnabled(true);
                }
            });
            return btnDetail;
        }

    });
    tblCategoryList.addGeneratedColumn("devidedQuantityDetail", new CustomTable.ColumnGenerator() {
        @Override
        public Object generateCell(CustomTable source, final Object itemId, Object columnId) {
            final CategoryListDTO categoryListDTO = (CategoryListDTO) itemId;
            if (DataUtil.isStringNullOrEmpty(categoryListDTO.getDividedQuantity())) {
                return "";
            }
            Button btnDetail = new Button(categoryListDTO.getDividedQuantity());
            btnDetail.setStyleName(Constants.ICON.V_LINK);
            btnDetail.addClickListener(new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    LinkedHashMap<String, CustomTable.Align> headerCustomerTable = BundleUtils
                            .getHeadersFilter("devided.customer.status.detail");
                    String captionCustomerTable = BundleUtils
                            .getString("customer.devided.table.detail.caption");
                    String lang = "customer";
                    CustomerDialog customerDialog = new CustomerDialog(headerCustomerTable,
                            captionCustomerTable, lang);
                    customerDialog.initDialog(mapServices, mapCustServiceStatus, CustomerDTO.class);
                    List<CustomerDTO> lstCustomerOfMineName = WSCustomer
                            .getListDevidedCustomerOfMineName(categoryListDTO.getId());
                    customerDialog.setCustomerList2Table(lstCustomerOfMineName);
                    UI.getCurrent().addWindow(customerDialog);
                    event.getButton().setEnabled(true);
                }
            });
            return btnDetail;
        }

    });
    tblCategoryList.addGeneratedColumn(lblEdit, new CustomTable.ColumnGenerator() {
        @Override
        public Object generateCell(CustomTable source, final Object itemId, Object columnId) {
            final CategoryListDTO categoryListDTO = (CategoryListDTO) itemId;
            ThemeResource iconVi = new ThemeResource("img/icon_edit.png");
            Image image = new Image(null, iconVi);
            image.addClickListener(new MouseEvents.ClickListener() {
                @Override
                public void click(MouseEvents.ClickEvent event) {
                    InsertOrUpdate(categoryListDTO, false);
                }
            });

            return image;
        }

    });
    //        tableUtils.generateColumn(tblCategoryList);
    CommonUtils.setVisibleBtnTablePanel(panelCategoryList, true, false, true, true);
    CommonFunctionTableFilter.initTable(panelCategoryList, headerData, beanItemContainerCategoryList,
            BundleUtils.getString("table.list.categoryList"), 10, "categoryList.header", true, true, false,
            false, false);
    tblCategoryList.setColumnExpandRatio("description", 2);
    tblCategoryList.setColumnExpandRatio("receivedDate", 1);
    tblCategoryList.setColumnExpandRatio("endDate", 1);
    tblCategoryList.setColumnExpandRatio("code", 1);
    tblCategoryList.setColumnExpandRatio("name", 1);
}

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

public void deptActionListener() {

    ShortcutUtils.setShortcutKey(listDepartmentsAndStaffUI.getBtnSearchDept());
    ShortcutUtils.doTextChangeUppercase(searchFormDeptController.getSearchDepartmentForm().getTxtDeptCode());
    listDepartmentsAndStaffUI.getBtnSearchDept().addClickListener(new Button.ClickListener() {

        @Override/*from w ww  . j av a 2s .  co  m*/
        public void buttonClick(Button.ClickEvent event) {
            doSearchDepartments();
            CommonFunction.enableButtonAfterClick(event);
        }
    });

    btnResetDept.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            doResetInputDept();
            CommonFunction.enableButtonAfterClick(event);
        }
    });

    btnAddDept.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            DialogCreateDepartment dialogCreateDepartment = new DialogCreateDepartment(
                    BundleUtils.getString("department.management.panel.addDepartment"), new DepartmentDTO());
            dialogCreateDepartmentController = new DialogCreateDepartmentController(dialogCreateDepartment,
                    Constants.ADD, tblDepartment, tblStaff, staffForm.getF9Departments());
            dialogCreateDepartmentController.init(new DepartmentDTO());
            UI.getCurrent().addWindow(dialogCreateDepartment);
            CommonFunction.enableButtonAfterClick(event);
        }
    });

    btnEditDept.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Set<DepartmentDTO> selectedValues = (Set<DepartmentDTO>) tblDepartment.getValue();
            if (selectedValues != null) {
                List<DepartmentDTO> lstDepartment = Lists.newArrayList();
                for (DepartmentDTO departmentDTO : selectedValues) {
                    lstDepartment.add(departmentDTO);
                }
                if (selectedValues.size() == 1) {
                    DepartmentDTO departmentDTO;
                    departmentDTO = (DepartmentDTO) selectedValues.toArray()[0];
                    DialogCreateDepartment dialogCreateContract = new DialogCreateDepartment(
                            BundleUtils.getString("department.management.panel.updateDepartment"),
                            departmentDTO);
                    dialogCreateDepartmentController = new DialogCreateDepartmentController(
                            dialogCreateContract, Constants.EDIT, tblDepartment, tblStaff,
                            staffForm.getF9Departments());
                    dialogCreateDepartmentController.init(departmentDTO);
                    UI.getCurrent().addWindow(dialogCreateContract);
                } else {
                    Notification.show(BundleUtils.getString("dept.staff.alert.message.pleasechoose"));
                }
            } else {
                CommonUtils.showChoseOne();
            }
            CommonFunction.enableButtonAfterClick(event);
        }
    });

    btnCopyDept.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            //                DepartmentDTO selectedValues = (DepartmentDTO) tblDepartment.getValue();
            Set<DepartmentDTO> selectedValues = (Set<DepartmentDTO>) tblDepartment.getValue();
            if (selectedValues != null) {
                List<DepartmentDTO> lstDepartment = Lists.newArrayList();
                for (DepartmentDTO departmentDTO : selectedValues) {
                    lstDepartment.add(departmentDTO);
                }
                if (selectedValues.size() == 1) {
                    DepartmentDTO departmentDTO = (DepartmentDTO) selectedValues.toArray()[0];
                    DialogCreateDepartment dialogCreateContract = new DialogCreateDepartment(
                            BundleUtils.getString("department.management.panel.copyDepartment"), departmentDTO);
                    dialogCreateDepartmentController = new DialogCreateDepartmentController(
                            dialogCreateContract, Constants.COPY, tblDepartment, tblStaff,
                            staffForm.getF9Departments());
                    dialogCreateDepartmentController.init(departmentDTO);
                    UI.getCurrent().addWindow(dialogCreateContract);
                } else {
                    Notification.show(BundleUtils.getString("dept.staff.alert.message.pleasechoose"));
                }
            } else {
                CommonUtils.showChoseOne();
            }
            CommonFunction.enableButtonAfterClick(event);
        }
    });

    listDepartmentController.getBtnDel().addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            selectedValues = (Set<DepartmentDTO>) tblDepartment.getValue();

            if (selectedValues.isEmpty()) {
                CommonUtils.showChoseOne();
            } else {
                final DepartmentDTO departmentDTO = (DepartmentDTO) selectedValues.toArray()[0];
                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) {
                                // tiepnv6 edit 16h 15/07/15
                                // check neu phong ban la cha thi khong xoa
                                if (deptIsParent(departmentDTO)) {
                                    Notification.show(
                                            BundleUtils.getString("dept.staff.required.delete.staff.1"),
                                            Notification.Type.HUMANIZED_MESSAGE);
                                    return;
                                }
                                //check neu bang phong ban co nhan vien thi xoa phong ban fai xoa het nv
                                if (!checkHasValue(departmentDTO)) {
                                    if (dialog.isConfirmed()) {
                                        List<DepartmentDTO> lstDeptDel = Lists.newArrayList();
                                        lstDeptDel.addAll(selectedValues);
                                        if (selectedValues.size() > 1) {
                                            //neu dept khong co dept cap con thi xoa
                                            List<DepartmentDTO> listChildOfDept = Lists.newArrayList();
                                            DepartmentDTO deptDTODel = new DepartmentDTO();
                                            deptDTODel = lstDeptDel.get(0);
                                            listChildOfDept = getChildDepartment(deptDTODel);
                                            if (listChildOfDept != null) {
                                                // Notification with default settings for a warning
                                                String showDepartmentChild = "";
                                                for (DepartmentDTO listChildOfDept1 : listChildOfDept) {
                                                    listChildOfDept1.getName();
                                                    showDepartmentChild += listChildOfDept1.getName() + ", ";
                                                }
                                                Notification notif = new Notification(
                                                        BundleUtils.getString("Warning"),
                                                        BundleUtils
                                                                .getString("message.required.deleteDepartment")
                                                                + "<br/>" + showDepartmentChild,
                                                        Notification.Type.TRAY_NOTIFICATION);
                                                notif.setDelayMsec(20000);
                                                notif.setPosition(Position.BOTTOM_RIGHT);
                                                notif.setStyleName("mystyle");
                                                notif.show(Page.getCurrent());
                                                //
                                            } else {
                                                message = doDeleteLstDept(lstDeptDel);
                                            }
                                            if (message.contains(Constants.SUCCESS)) {
                                                for (DepartmentDTO deptDTO : lstDeptDel) {
                                                    tblDepartment.removeItem(deptDTO);
                                                }
                                                tblDepartment.refreshRowCache();
                                                tblDepartment.resetPage();
                                                CommonUtils
                                                        .showDeleteSuccess(BundleUtils.getString("department"));
                                            } else {
                                                CommonUtils.showDeleteFail(BundleUtils.getString("department"));
                                            }
                                        } else {
                                            //                                                tblDepartment = listDepartmentsAndStaffUI.getTblListDepartmentUI().getMainTable();
                                            List<DepartmentDTO> listDepartment = Lists.newArrayList();
                                            selectedValues = (Set<DepartmentDTO>) tblDepartment.getValue();
                                            DepartmentDTO departmentDTO = (DepartmentDTO) selectedValues
                                                    .toArray()[0];
                                            //                                                departmentDTO.setUserNameLogging("Username");
                                            listDepartment.add(departmentDTO);
                                            message = doDeleteLstDept(listDepartment);
                                            if (message.contains(Constants.SUCCESS)) {

                                                tblDepartment.removeItem(departmentDTO);
                                                tblDepartment.resetPage();
                                                CommonUtils
                                                        .showDeleteSuccess(BundleUtils.getString("department"));
                                            } else {
                                                CommonUtils.showDeleteFail(BundleUtils.getString("department"));
                                            }
                                        }
                                    }
                                } else {
                                    Notification.show(BundleUtils.getString("dept.staff.required.delete.staff"),
                                            Notification.Type.HUMANIZED_MESSAGE);
                                }
                            }
                        });
            }
            CommonFunction.enableButtonAfterClick(event);
        }

    });
    btnAddMapStaffCusts.setDisableOnClick(true);
    btnAddMapStaffCusts.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Set<StaffDTO> selectedValues = (Set<StaffDTO>) tblStaff.getValue();
            if (!DataUtil.isListNullOrEmpty(Lists.newArrayList(selectedValues))) {
                MapStaffCustomerDialog dialogAddMapStaffGoods = new MapStaffCustomerDialog();
                MapStaffCustomerController mapStaffCustomerController = new MapStaffCustomerController(
                        dialogAddMapStaffGoods, Lists.newArrayList(selectedValues), lstAllAppParams);
                DataUtil.reloadWindow(dialogAddMapStaffGoods);
                UI.getCurrent().addWindow(dialogAddMapStaffGoods);
            } else {
                CommonMessages.showWarningMessage(BundleUtils.getString("notification.staff.customer.choice"));
            }
            CommonFunction.enableButtonAfterClick(event);
        }
    });
}

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

public void staffActionListener() {

    ShortcutUtils.setShortcutKey(listDepartmentsAndStaffUI.getBtnSearchEmp());
    listDepartmentsAndStaffUI.getBtnSearchEmp().addClickListener(new Button.ClickListener() {

        @Override//  w ww  .  j a v a2 s.c om
        public void buttonClick(Button.ClickEvent event) {
            doSearchStaff();
        }
    });

    btnResetEmp.addClickListener(new Button.ClickListener() {

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

    btnAddEmp.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Set<DepartmentDTO> selectedValues = (Set<DepartmentDTO>) tblDepartment.getValue();
            if (selectedValues != null) {
                List<DepartmentDTO> lstDepartment = Lists.newArrayList();
                for (DepartmentDTO ddto : selectedValues) {
                    lstDepartment.add(ddto);
                }
                if (selectedValues.size() == 1) {
                    DepartmentDTO deptDTO = (DepartmentDTO) selectedValues.toArray()[0];
                    DialogCreateStaff dialogCreateStaff = new DialogCreateStaff(
                            BundleUtils.getString("staff.management.panel.addStaff"), new StaffDTO(), deptDTO);
                    dialogCreateStaffController = new DialogCreateStaffController(dialogCreateStaff,
                            Constants.ADD, tblStaff);
                    dialogCreateStaffController.init(new StaffDTO(), null, deptDTO);
                    UI.getCurrent().addWindow(dialogCreateStaff);
                } else {
                    Notification.show(BundleUtils.getString("dept.staff.alert.message.pleasechooseonedept"));
                }
            } else {
                CommonUtils.showChoseOne();
            }
            CommonFunction.enableButtonAfterClick(event);
        }
    });
    //160311 NgocND6 xu ly su kien khi click button chuyen quyen quan ly hang hoa
    btnTransferRole.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Set<StaffDTO> selectedValues = (Set<StaffDTO>) tblStaff.getValue();
            if (selectedValues != null) {
                List<StaffDTO> lstStaff = Lists.newArrayList();
                for (StaffDTO staffDTO : selectedValues) {
                    lstStaff.add(staffDTO);
                }
                if (selectedValues.size() == 1) {
                    StaffDTO staffDTO = (StaffDTO) selectedValues.toArray()[0];
                    if (staffDTO.getStatus().equalsIgnoreCase("1")) {
                        //                            DialogTRGM dtrgm = new DialogTRGM(BundleUtils.getString("transfer.goods.manage.tranfgoodsmanagetitle"));
                        //                            dialogTRGMController = new DialogTRGMController(dtrgm, staffDTO);
                        //                            UI.getCurrent().addWindow(dtrgm);
                    } else {
                        Notification.show(BundleUtils.getString("dept.staff.alert.message.notActive"));
                    }
                } else {
                    Notification.show(BundleUtils.getString("transfer.goods.manage.coldselectstaff"));
                }
            } else {
                Notification.show(BundleUtils.getString("transfer.goods.manage.coldselectstaff"));
            }
        }
    });

    btnEditEmp.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Set<StaffDTO> selectedValues = (Set<StaffDTO>) tblStaff.getValue();
            if (selectedValues != null) {
                List<StaffDTO> lstStaff = Lists.newArrayList();
                for (StaffDTO staffDTO : selectedValues) {
                    lstStaff.add(staffDTO);
                }
                if (selectedValues.size() == 1) {
                    StaffDTO staffDTO = (StaffDTO) selectedValues.toArray()[0];
                    DialogCreateStaff dialogCreateStaff = new DialogCreateStaff(
                            BundleUtils.getString("staff.management.panel.updateStaff"), staffDTO, null);
                    dialogCreateStaffController = new DialogCreateStaffController(dialogCreateStaff,
                            Constants.EDIT, tblStaff);
                    dialogCreateStaffController.init(lstStaff.get(0), deptId, null);
                    UI.getCurrent().addWindow(dialogCreateStaff);

                } else {
                    Notification.show(BundleUtils.getString("dept.staff.alert.message.pleasechoose"));
                }
            } else {
                CommonUtils.showChoseOne();
            }
            CommonFunction.enableButtonAfterClick(event);
        }
    });

    btnCopyEmp.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Set<StaffDTO> selectedValues = (Set<StaffDTO>) tblStaff.getValue();
            if (selectedValues != null) {
                List<StaffDTO> lstStaff = Lists.newArrayList();
                for (StaffDTO staffDTO : selectedValues) {
                    lstStaff.add(staffDTO);
                }
                if (selectedValues.size() == 1) {
                    StaffDTO staffDTO = (StaffDTO) selectedValues.toArray()[0];
                    DialogCreateStaff dialogCreateStaff = new DialogCreateStaff(
                            BundleUtils.getString("staff.management.panel.copyStaff"), staffDTO, null);
                    dialogCreateStaffController = new DialogCreateStaffController(dialogCreateStaff,
                            Constants.COPY, tblStaff);
                    dialogCreateStaffController.init(lstStaff.get(0), deptId, null);
                    UI.getCurrent().addWindow(dialogCreateStaff);
                } else {
                    Notification.show(BundleUtils.getString("dept.staff.alert.message.pleasechoose"));
                }
            } else {
                CommonUtils.showChoseOne();
            }
            CommonFunction.enableButtonAfterClick(event);
        }
    });

    listStaffController.getBtnDel().addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            selectedStaffValues = (Set<StaffDTO>) tblStaff.getValue();
            if (selectedStaffValues.isEmpty()) {
                CommonUtils.showChoseOne();
            } else {
                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 (!checkStaffHasValue(staffDTO)) {
                                if (dialog.isConfirmed()) {
                                    List<StaffDTO> lstStaffDel = Lists.newArrayList();
                                    lstStaffDel.addAll(selectedStaffValues);
                                    if (selectedStaffValues.size() > 1) {
                                        //add user loging
                                        StaffDTO userLog = new StaffDTO();
                                        //                                            userLog.setUserNameLogging("Username");
                                        lstStaffDel.add(userLog);
                                        message = doDeleteLstStaff(lstStaffDel);
                                        if (message.contains(Constants.SUCCESS)) {
                                            for (StaffDTO staffDTO : lstStaffDel) {
                                                tblStaff.removeItem(staffDTO);
                                            }
                                            tblStaff.resetPage();
                                            CommonUtils.showDeleteSuccess(BundleUtils.getString("staff"));
                                        } else {
                                            CommonUtils.showDeleteFail(BundleUtils.getString("staff"));
                                        }
                                    } else {
                                        tblStaff = listDepartmentsAndStaffUI.getTblListStaffUI().getMainTable();
                                        selectedStaffValues = (Set<StaffDTO>) tblStaff.getValue();
                                        StaffDTO staffDTO = (StaffDTO) selectedStaffValues.toArray()[0];
                                        //                                            staffDTO.setUserNameLogging("Username");
                                        message = doDeleteStaff(staffDTO);
                                        if (message.contains(Constants.SUCCESS)) {
                                            tblStaff.removeItem(staffDTO);
                                            tblStaff.resetPage();
                                            CommonUtils.showDeleteSuccess(BundleUtils.getString("staff"));
                                        } else {
                                            CommonUtils.showDeleteFail(BundleUtils.getString("staff"));
                                        }
                                    }
                                }
                            }
                        });
            }
            CommonFunction.enableButtonAfterClick(event);
        }

    });

    addBtnAssignRolesClickedListener();
}