Example usage for com.vaadin.ui Button Button

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

Introduction

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

Prototype

public Button(Resource icon) 

Source Link

Document

Creates a new push button with the given icon.

Usage

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);/*  w  w  w .j a va  2 s . c om*/
        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.MapStaffCustomerController.java

/**
 * Khoi tao cac bang//w  w w  .ja  va 2s  .co  m
 */
private void initTables() {
    tblUtils = new TableUtils();
    //Khoi tao bang khach hang
    panelTableCustomer = mapStaffCustomerDialog.getPanelTblCustomer();
    tblCustomer = panelTableCustomer.getMainTable();
    tblUtils.generateColumn(tblCustomer);
    containerCustomer = new BeanItemContainer(CustomerDTO.class);
    CommonFunctionTableFilter.initTable(panelTableCustomer, HEADER_CUSTOMER, containerCustomer,
            CAPTION_CUSTOMER, 5, "customer");

    //Khoi tao bang khach hang
    panelTableMapStaffCustomer = mapStaffCustomerDialog.getPanelTblCustomerStatus();
    tblStaffMapCustomer = panelTableMapStaffCustomer.getMainTable();
    tblUtils.generateColumn(tblStaffMapCustomer);
    containerMapStaffCustomer = new BeanItemContainer(StaffDTO.class);
    containerMapStaffCustomer.addAll(lstStaffs);
    //Them nut chi tiet
    tblStaffMapCustomer.addGeneratedColumn("detail", new CustomTable.ColumnGenerator() {
        @Override
        public Object generateCell(CustomTable source, Object itemId, Object columnId) {
            final StaffDTO staff = (StaffDTO) itemId;
            if (DataUtil.isListNullOrEmpty(staff.getLstCustomers())) {
                return "";
            } else {
                Button btnDetail = new Button(BundleUtils.getString("statistic.list.detail"));
                btnDetail.setDisableOnClick(true);
                btnDetail.addStyleName(Runo.BUTTON_LINK);
                btnDetail.addStyleName("v-link-button-left");
                btnDetail.addClickListener(new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        CustomerDialog customerDialog = new CustomerDialog(mapServices, mapCustServiceStatus);
                        customerDialog.setData2Table(staff.getLstCustomers());
                        UI.getCurrent().addWindow(customerDialog);
                        event.getButton().setEnabled(true);
                    }
                });
                return btnDetail;
            }

        }
    });
    //Them nut so luong
    tblStaffMapCustomer.addGeneratedColumn("quanlity", new CustomTable.ColumnGenerator() {
        @Override
        public Object generateCell(CustomTable source, Object itemId, Object columnId) {
            StaffDTO staff = (StaffDTO) itemId;
            if (DataUtil.isListNullOrEmpty(staff.getLstCustomers())) {
                return 0;
            } else {
                return staff.getLstCustomers().size();
            }
        }
    });
    CommonFunctionTableFilter.initTable(panelTableMapStaffCustomer, HEADER_MAP_STAFF_CUSTOMER,
            containerMapStaffCustomer, CAPTION_MAP_STAFF_CUSTOMER, 5, "customerStatusForm");
}

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

/**
 * Khoi tao cac bang//w w  w . java2 s.  c  om
 */
private void initTables() {
    tblUtils = new TableUtils();
    //Khoi tao bang khach hang
    panelTableCustomer = mapStaffCustomerView.getPanelTblCustomer();
    tblCustomer = panelTableCustomer.getMainTable();
    tblUtils.generateColumn(tblCustomer);
    containerCustomer = new BeanItemContainer(CustomerDTO.class);
    CommonFunctionTableFilter.initTable(panelTableCustomer, HEADER_CUSTOMER, containerCustomer,
            CAPTION_CUSTOMER, 5, "customer");
    CommonUtils.convertFieldTable(tblCustomer, "taxAuthority", mapTaxAuthority);
    //        name#1,startTime#2,endTime#2,taxAuthority#1
    tblCustomer.setColumnExpandRatio("taxCode", 1);
    tblCustomer.setColumnExpandRatio("name", 2);
    tblCustomer.setColumnExpandRatio("startTime", 1);
    tblCustomer.setColumnExpandRatio("endTime", 1);
    tblCustomer.setColumnExpandRatio("taxAuthority", 1);
    //Khoi tao bang khach hang
    panelTableMapStaffCustomer = mapStaffCustomerView.getPanelTblCustomerStatus();
    tblStaffMapCustomer = panelTableMapStaffCustomer.getMainTable();
    tblUtils.generateColumn(tblStaffMapCustomer);
    containerMapStaffCustomer = new BeanItemContainer(StaffDTO.class);
    containerMapStaffCustomer.addAll(lstStaffs);
    //Them nut chi tiet
    tblStaffMapCustomer.addGeneratedColumn("detail", new CustomTable.ColumnGenerator() {
        @Override
        public Object generateCell(CustomTable source, Object itemId, Object columnId) {
            try {
                final StaffDTO staff = (StaffDTO) itemId;

                if (DataUtil.isStringNullOrEmpty(staff.getQuanlity()) || "0".equals(staff.getQuanlity())) {
                    return null;
                } else {
                    Button btnDetail = new Button(BundleUtils.getString("statistic.list.detail"));
                    btnDetail.setDisableOnClick(true);
                    btnDetail.addStyleName(Runo.BUTTON_LINK);
                    btnDetail.addStyleName("v-link-button-left");
                    btnDetail.addClickListener(new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent event) {
                            CustomerDialog customerDialog = new CustomerDialog(mapServices,
                                    mapCustServiceStatus);
                            customerDialog.setData2Table(staff.getLstCustomers());
                            UI.getCurrent().addWindow(customerDialog);
                            event.getButton().setEnabled(true);
                        }
                    });
                    return btnDetail;
                }
            } catch (NullValueInNestedPathException nvnpe) {
                return null;
            }
        }
    });
    //Them nut huy bo
    tblStaffMapCustomer.addGeneratedColumn("cancel", new CustomTable.ColumnGenerator() {
        @Override
        public Object generateCell(final CustomTable source, Object itemId, Object columnId) {
            try {
                final StaffDTO staff = (StaffDTO) itemId;
                if (DataUtil.isStringNullOrEmpty(staff.getQuanlity()) || "0".equals(staff.getQuanlity())) {
                    return null;
                } else {
                    Button btnDetail = new Button(BundleUtils.getString("statistic.list.cancel"));
                    btnDetail.setDisableOnClick(true);
                    btnDetail.addStyleName(Runo.BUTTON_LINK);
                    btnDetail.addStyleName("v-link-button-left");
                    btnDetail.addClickListener(new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent event) {
                            doReset(staff);
                        }
                    });
                    return btnDetail;
                }
            } catch (NullValueInNestedPathException nvnpe) {
                return null;
            }
        }
    });
    CommonFunctionTableFilter.initTable(panelTableMapStaffCustomer, HEADER_MAP_STAFF_CUSTOMER,
            containerMapStaffCustomer, CAPTION_MAP_STAFF_CUSTOMER, 5, "customerStatusForm");

}

From source file:com.antonjohansson.managementcenter.core.web.welcome.WelcomeView.java

License:Apache License

private Component getExistingConnectionLayout() {
    ComboBox connection = new ComboBox("Existing connection");
    connection.addItem("SQL Server 01");
    connection.addItem("Elasticsearch Server 01");
    connection.setWidth("400");
    connection.setNullSelectionAllowed(false);
    connection.setTextInputAllowed(false);

    Button connect = new Button("Connect");
    connect.addStyleName(ValoTheme.BUTTON_PRIMARY);
    connect.setClickShortcut(KeyCode.ENTER);
    connect.setWidth("120");

    HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);// www. jav a  2s.  c  om
    layout.addComponents(connection, connect);
    layout.setComponentAlignment(connect, Alignment.BOTTOM_LEFT);
    return layout;
}

From source file:com.antonjohansson.managementcenter.core.web.welcome.WelcomeView.java

License:Apache License

private Component getNewConnectionLayout() {
    engine = new ComboBox("New connection");
    engine.setWidth("400");
    engine.setNullSelectionAllowed(false);
    engine.setTextInputAllowed(false);//  w ww  . j  av a  2  s .c om

    create = new Button("Create");
    create.addStyleName(ValoTheme.BUTTON_PRIMARY);
    create.setClickShortcut(KeyCode.ENTER);
    create.setWidth("120");

    HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);
    layout.addComponents(engine, create);
    layout.setComponentAlignment(create, Alignment.BOTTOM_LEFT);
    return layout;
}

From source file:com.arcusys.liferay.vaadinplugin.ControlPanelUI.java

License:Apache License

private Button createChangeVersionButton() {
    Button button = new Button("Change version");
    button.setStyleName(BaseTheme.BUTTON_LINK);
    button.addClickListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            ChangeVersionWindow window = new ChangeVersionWindow();
            addWindow(window);//from w  ww.j a  v a 2 s  .  c  om
            window.initialize();
        }
    });
    return button;
}

From source file:com.arcusys.liferay.vaadinplugin.ControlPanelUI.java

License:Apache License

private Button createDetailsButton() {
    Button button = new Button("Details");
    button.setStyleName(BaseTheme.BUTTON_LINK);
    button.addClickListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            addWindow(new DetailsWindow());
        }/* w ww.ja v a2s . com*/
    });
    return button;
}

From source file:com.arcusys.liferay.vaadinplugin.ControlPanelUI.java

License:Apache License

private Button createUpdateVaadinVersionButton() {
    Button button = new Button("Upgrade");
    button.setImmediate(true);// www  .  ja v a  2s.  c  o  m
    button.setStyleName(BaseTheme.BUTTON_LINK);
    button.addClickListener(new Button.ClickListener() {

        public void buttonClick(Button.ClickEvent event) {

            if (!newestDownloadInfo.isExists()) {
                Notification.show(WARNING_UPGRADE_VAADIN_VERSION_NOT_FOUND, Notification.Type.ERROR_MESSAGE);
                return;
            }

            outputLog.log("Location for download: " + newestDownloadInfo.getDownloadUrl());

            try {
                addWindow(new WarningWindow(newestDownloadInfo));
            } catch (Exception ex) {
                outputLog.log(ex.getMessage());
            }
        }
    });
    return button;
}

From source file:com.bellkenz.modules.PersonalInformation.java

public ComponentContainer personalInformation() {
    employeeInformationDAO = new EmployeeInformationDAO(getEmployeeId());
    employeePersonalInformation = new EmployeePersonalInformation();

    GridLayout glayout = new GridLayout(5, 9);
    glayout.setSpacing(true);/* w w  w . j av a  2 s.c o m*/
    glayout.setMargin(true);

    final Panel imagePanel = new Panel();
    imagePanel.setStyleName("light");
    AbstractLayout panelLayout = (AbstractLayout) imagePanel.getContent();
    panelLayout.setMargin(false);
    imagePanel.setSizeFull();

    employeeImage = new Embedded(null, new ThemeResource("../myTheme/images/ronnie.jpg"));
    employeeImage.setImmediate(true);
    employeeImage.setWidth(90, Sizeable.UNITS_PIXELS);
    employeeImage.setHeight(90, Sizeable.UNITS_PIXELS);
    employeeImage.setStyleName("logo-img");
    imagePanel.addComponent(employeeImage);
    glayout.addComponent(employeeImage, 0, 0, 0, 1);
    glayout.setComponentAlignment(imagePanel, Alignment.MIDDLE_CENTER);

    firstname = createTextField("Firstname: ");
    glayout.addComponent(firstname, 1, 0, 2, 0);

    final TextField middlename = createTextField("Middlename: ");
    glayout.addComponent(middlename, 3, 0);

    final TextField lastname = createTextField("Lastname: ");
    glayout.addComponent(lastname, 4, 0);

    final TextField houseNo = createTextField("No: ");
    houseNo.setWidth("40px");
    glayout.addComponent(houseNo, 1, 1);

    final TextField street = createTextField("Street: ");
    street.setWidth("118");
    glayout.addComponent(street, 2, 1);

    final TextField city = createTextField("City: ");
    glayout.addComponent(city, 3, 1);

    final TextField zipCode = createTextField("Zip Code:");
    glayout.addComponent(zipCode, 4, 1);

    final TextField nickname = createTextField("Nickname: ");
    nickname.setWidth("90px");
    glayout.addComponent(nickname, 0, 2);

    final TextField permanentAddress = createTextField("Permanent/Provincial Address: ");
    permanentAddress.setWidth("533px");
    glayout.addComponent(permanentAddress, 1, 2, 4, 2);

    Button uploadPicture = new Button("Upload...");
    uploadPicture.setWidth("100%");
    uploadPicture.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (employeeId == null) {
                getWindow().showNotification("You did not select and Employee!",
                        Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            }

            Window uploadImage = new UploadImage(imagePanel, employeeImage, employeeId);
            uploadImage.setWidth("450px");
            if (uploadImage.getParent() == null) {
                getWindow().addWindow(uploadImage);
            }
            uploadImage.setModal(true);
            uploadImage.center();
        }
    });
    glayout.addComponent(uploadPicture, 0, 3);

    final TextField landline = createTextField("Landline #: ");
    glayout.addComponent(landline, 1, 3, 2, 3);

    final TextField mobileNo = createTextField("Mobile #: ");
    glayout.addComponent(mobileNo, 3, 3);

    final TextField age = createTextField("Age: ");
    glayout.addComponent(age, 4, 3);

    final TextField emailAddress = createTextField("Email Address: ");
    glayout.addComponent(emailAddress, 1, 4, 2, 4);

    final PopupDateField dob = (PopupDateField) createDateField("Date of Birth: ");
    glayout.addComponent(dob, 3, 4);

    final TextField height = createTextField("Height: ");
    glayout.addComponent(height, 4, 4);

    final ComboBox civilStatus = new ComboBox("Civil Status: ");
    civilStatus.setWidth("100%");
    dropDownBoxList.populateCivilStatusList(civilStatus);
    glayout.addComponent(civilStatus, 1, 5, 2, 5);

    final ComboBox gender = new ComboBox("Gender: ");
    gender.setWidth("100%");
    dropDownBoxList.populateGenderList(gender);
    glayout.addComponent(gender, 3, 5);

    final TextField weight = createTextField("Weigth: ");
    glayout.addComponent(weight, 4, 5);

    final TextField driversLicenseNo = createTextField("Drivers License: ");
    glayout.addComponent(driversLicenseNo, 1, 6, 2, 6);

    final TextField restrictionCode = createTextField("Restriction Code: ");
    glayout.addComponent(restrictionCode, 3, 6);

    final TextField religion = createTextField("Religion: ");
    glayout.addComponent(religion, 4, 6);

    final ComboBox division = new ComboBox("Division: ");
    division.setWidth("100%");
    dropDownBoxList.populateBranchComboBox(division);
    glayout.addComponent(division, 1, 7, 2, 7);

    final ComboBox department = dropDownBoxList.populateDepartment(new ComboBox());
    department.setWidth("100%");
    division.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (division.getValue() == null) {
            } else {
                divisionId = branchDAO.getBranchId(division.getValue().toString());
            }
        }

    });
    glayout.addComponent(department, 3, 7);

    final TextField position = createTextField("Position: ");
    glayout.addComponent(position, 4, 7);
    //glayout.setComponentAlignment(position, Alignment.BOTTOM_LEFT);

    Button transferButton = new Button("Transfer Employee");
    transferButton.setWidth("100%");
    transferButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (getEmployeeId() == null) {
                getWindow().showNotification("You did not select an Employee!",
                        Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            }

            Window subWindow = transferEmployee(getEmployeeId(), division, department, position);
            if (subWindow.getParent() == null) {
                getWindow().addWindow(subWindow);
            }
            subWindow.setModal(true);
            subWindow.center();
        }
    });
    glayout.addComponent(transferButton, 1, 8, 2, 8);
    glayout.setComponentAlignment(transferButton, Alignment.BOTTOM_CENTER);

    if (employeeId != null) {
        epiList = employeeInformationDAO.employeePersonalInformation();
        for (EmployeePersonalInformation epi : epiList) {
            final byte[] image = epi.getImage();
            if (image != null) {
                StreamResource.StreamSource imageSource = new StreamResource.StreamSource() {

                    @Override
                    public InputStream getStream() {
                        return new ByteArrayInputStream(image);
                    }

                };

                StreamResource imageResource = new StreamResource(imageSource, epi.getFirstname() + ".jpg",
                        getApplication());
                imageResource.setCacheTime(0);
                employeeImage.setSource(imageResource);
            }
            firstname.setValue(epi.getFirstname());
            middlename.setValue(epi.getMiddlename());
            lastname.setValue(epi.getLastname());
            houseNo.setValue(epi.getHouseNumber());

            street.setValue(epi.getStreet());
            city.setValue(epi.getStreet());
            zipCode.setValue(epi.getZipCode());
            nickname.setValue(epi.getNickname());
            permanentAddress.setValue(epi.getPermanentAddress());
            landline.setValue(epi.getLandlineNumber());
            mobileNo.setValue(epi.getMobileNumber());
            age.setValue(epi.getAge());
            emailAddress.setValue(epi.getEmailAddress());

            if (epi.getDob() != null) {
                dob.setValue(conUtil.parsingDate(epi.getDob()));
            } else {
                dob.setValue(null);
            }

            height.setValue(epi.getHeight());

            if (epi.getCivilStatus() != null) {
                Object civilStatusId = civilStatus.addItem();
                civilStatus.setItemCaption(civilStatusId, epi.getCivilStatus());
                civilStatus.setValue(civilStatusId);
            }

            if (epi.getGender() != null) {
                Object genderId = gender.addItem();
                gender.setItemCaption(genderId, epi.getGender());
                gender.setValue(genderId);
            }

            weight.setValue(epi.getWeight());
            driversLicenseNo.setValue(epi.getDriversLicense());
            restrictionCode.setValue(epi.getRestrictionCode());
            religion.setValue(epi.getReligion());
            position.setValue(epi.getPosition());

            Object divisionObjectId = division.addItem();
            division.setItemCaption(divisionObjectId, epi.getDivision());
            division.setValue(divisionObjectId);

            Object departmentObjectId = department.addItem();
            department.setItemCaption(departmentObjectId, epi.getDepartment());
            department.setValue(departmentObjectId);
        }
    }

    firstname.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            employeePersonalInformation.setFirstname(event.getProperty().getValue().toString());
        }
    });
    firstname.setImmediate(true);
    setInformation(employeePersonalInformation);

    return glayout;
}

From source file:com.bellkenz.modules.PersonalInformation.java

public Window transferEmployee(final String employeeId, final ComboBox div, final ComboBox dept,
        final TextField post) {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setMargin(true);/*from   w  w w.  j a  v a 2 s.  c o m*/
    vlayout.setSpacing(true);

    final Window subWindow = new Window("Transfer Employee", vlayout);
    subWindow.setWidth("200px");

    final ComboBox division = new ComboBox("Division: ");
    division.setWidth("100%");
    dropDownBoxList.populateBranchComboBox(division);
    subWindow.addComponent(division);

    final ComboBox department = dropDownBoxList.populateDepartment(new ComboBox());
    department.setWidth("100%");
    division.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (division.getValue() == null) {
            } else {
                divisionId = branchDAO.getBranchId(division.getValue().toString());
            }
        }

    });
    subWindow.addComponent(department);

    final TextField position = createTextField("Position: ");
    position.setWidth("100%");
    subWindow.addComponent(position);

    final PopupDateField entryDate = (PopupDateField) createDateField("Date of Entry: ");
    subWindow.addComponent(entryDate);

    Button updateButton = new Button("UPDATE");
    updateButton.setWidth("100%");
    updateButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (division.getValue() == null) {
                getWindow().showNotification("Select Division!", Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            }

            if (department.getValue() == null) {
                getWindow().showNotification("Select Department!", Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            }

            if (position.getValue() == null || position.getValue().toString().trim().isEmpty()) {
                getWindow().showNotification("Enter Position!", Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            }

            if (entryDate.getValue() == null) {
                getWindow().showNotification("Select Entry Date!", Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            }

            List<EmployeePositionHistory> ephList = new ArrayList<EmployeePositionHistory>();
            EmployeePositionHistory eph = new EmployeePositionHistory();
            eph.setBranch(division.getValue().toString());
            eph.setDepartment(department.getValue().toString());
            eph.setPosition(position.getValue().toString().trim().toLowerCase());
            eph.setEntryDate(conUtil.convertDateFormat(entryDate.getValue().toString()));
            ephList.add(eph);
            Integer deptId = departmentDAO.getDepartmentId(divisionId, department.getValue().toString());
            Boolean result = employeeInformationDAO.transferEmployee(ephList, deptId);
            if (result) {
                Object divObjectId = div.addItem();
                div.setItemCaption(divObjectId, division.getValue().toString());
                div.setValue(divObjectId);

                Object deptObjectId = dept.addItem();
                dept.setItemCaption(deptObjectId, department.getValue().toString());
                dept.setValue(deptObjectId);

                post.setValue(position.getValue().toString().trim().toLowerCase());

                (subWindow.getParent()).removeWindow(subWindow);
            } else {
                getWindow().showNotification("Cannot Transfer employee",
                        Window.Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });
    subWindow.addComponent(updateButton);

    return subWindow;
}