Example usage for com.vaadin.ui ComboBox ComboBox

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

Introduction

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

Prototype

protected ComboBox(DataCommunicator<T> dataCommunicator) 

Source Link

Document

Constructs and initializes an empty combo box.

Usage

From source file:com.rex.components.valo.ComboBoxes.java

License:Apache License

public ComboBoxes() {
    setMargin(true);/*  w w  w  .j  a  v a  2  s.c  om*/

    Label h1 = new Label("Combo Boxes");
    h1.addStyleName("h1");
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    ComboBox combo = new ComboBox("Normal");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false));
    combo.setNullSelectionAllowed(false);
    combo.select(combo.getItemIds().iterator().next());
    combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    combo.setItemIcon(combo.getItemIds().iterator().next(), new ThemeResource("../runo/icons/16/document.png"));
    row.addComponent(combo);

    CssLayout group = new CssLayout();
    group.setCaption("Grouped with a Button");
    group.addStyleName("v-component-group");
    row.addComponent(group);

    combo = new ComboBox();
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false));
    combo.setNullSelectionAllowed(false);
    combo.select(combo.getItemIds().iterator().next());
    combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    combo.setWidth("240px");
    group.addComponent(combo);
    Button today = new Button("Do It");
    group.addComponent(today);

    combo = new ComboBox("Explicit size");
    combo.setInputPrompt("You can type here");
    combo.addItem("Option One");
    combo.addItem("Option Two");
    combo.addItem("Option Three");
    combo.setWidth("260px");
    combo.setHeight("60px");
    row.addComponent(combo);

    combo = new ComboBox("No text input allowed");
    combo.setInputPrompt("You can click here");
    combo.addItem("Option One");
    combo.addItem("Option Two");
    combo.addItem("Option Three");
    combo.setTextInputAllowed(false);
    combo.setNullSelectionAllowed(false);
    combo.select("Option One");
    row.addComponent(combo);

    combo = new ComboBox("Error");
    combo.setInputPrompt("You can type here");
    combo.addItem("Option One");
    combo.addItem("Option Two");
    combo.addItem("Option Three");
    combo.setNullSelectionAllowed(false);
    combo.select("Option One");
    combo.setComponentError(new UserError("Fix it, now!"));
    row.addComponent(combo);

    combo = new ComboBox("Error, borderless");
    combo.setInputPrompt("You can type here");
    combo.addItem("Option One");
    combo.addItem("Option Two");
    combo.addItem("Option Three");
    combo.setNullSelectionAllowed(false);
    combo.select("Option One");
    combo.setComponentError(new UserError("Fix it, now!"));
    combo.addStyleName("borderless");
    row.addComponent(combo);

    combo = new ComboBox("Disabled");
    combo.setInputPrompt("You can't type here");
    combo.addItem("Option One");
    combo.addItem("Option Two");
    combo.addItem("Option Three");
    combo.setEnabled(false);
    row.addComponent(combo);

    combo = new ComboBox("Custom color");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    combo.addStyleName("color1");
    row.addComponent(combo);

    combo = new ComboBox("Custom color");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    combo.addStyleName("color2");
    row.addComponent(combo);

    combo = new ComboBox("Custom color");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    combo.addStyleName("color3");
    row.addComponent(combo);

    combo = new ComboBox("Small");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    combo.addStyleName("small");
    row.addComponent(combo);

    combo = new ComboBox("Large");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    combo.addStyleName("large");
    row.addComponent(combo);

    combo = new ComboBox("Borderless");
    combo.setInputPrompt("You can type here");
    combo.addItem("Option One");
    combo.addItem("Option Two");
    combo.addItem("Option Three");
    combo.addStyleName("borderless");
    row.addComponent(combo);

    combo = new ComboBox("Tiny");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    combo.addStyleName("tiny");
    row.addComponent(combo);

    combo = new ComboBox("Huge");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    combo.addStyleName("huge");
    row.addComponent(combo);
}

From source file:com.save.employee.CreateNewAccountWindow.java

FormLayout getLayout() {
    FormLayout f = new FormLayout();
    f.setReadOnly(false);/*from w  w  w  .  j  a  v  a 2s .c  om*/
    f.setSpacing(true);
    f.setMargin(true);

    final TextField employeeNo = new TextField("Employee No: ");
    employeeNo.setWidth("100%");
    employeeNo.setRequired(true);
    employeeNo.setNullSettingAllowed(false);
    f.addComponent(employeeNo);

    final TextField firstname = new TextField("Firstname: ");
    firstname.setWidth("100%");
    firstname.setRequired(true);
    firstname.setNullSettingAllowed(false);
    f.addComponent(firstname);

    final TextField middlename = new TextField("Middlename: ");
    middlename.setWidth("100%");
    middlename.setRequired(true);
    middlename.setNullSettingAllowed(false);
    f.addComponent(middlename);

    final TextField lastname = new TextField("Lastname: ");
    lastname.setWidth("100%");
    lastname.setRequired(true);
    lastname.setNullSettingAllowed(false);
    f.addComponent(lastname);

    final OptionGroup gender = new OptionGroup("Gender: ");
    gender.addItem("Female");
    gender.addItem("Male");
    gender.addStyleName("horizontal");
    gender.setValue("Female");
    f.addComponent(gender);

    final ComboBox status = new ComboBox("Status: ");
    status.setWidth("100%");
    status.setNullSelectionAllowed(false);
    status.addItem("Single");
    status.addItem("Married");
    status.addItem("Widow");
    status.addItem("Separated");
    f.addComponent(status);

    Button saveBtn = new Button("SAVE");
    saveBtn.setWidth("100%");
    saveBtn.addClickListener((Button.ClickEvent event) -> {
        //TODO
        if (employeeNo.getValue().isEmpty() || employeeNo.getValue() == null) {
            Notification.show("Requried Emloyee ID", Notification.Type.WARNING_MESSAGE);
            return;
        }

        if (firstname.getValue().isEmpty() || firstname.getValue() == null) {
            Notification.show("Requried Firstname", Notification.Type.WARNING_MESSAGE);
            return;
        }

        if (middlename.getValue().isEmpty() || middlename.getValue() == null) {
            Notification.show("Requried Middlename", Notification.Type.WARNING_MESSAGE);
            return;
        }

        if (lastname.getValue().isEmpty() || lastname.getValue() == null) {
            Notification.show("Requried Lastname", Notification.Type.WARNING_MESSAGE);
            return;
        }

        if (status.getValue() == null) {
            Notification.show("Requried Status", Notification.Type.WARNING_MESSAGE);
        }

        if (employeeService.checkIfEmployeeNoExist(employeeNo.getValue().trim().toLowerCase())) {
            Notification.show("EmployeeId already Exist!", Notification.Type.ERROR_MESSAGE);
            return;
        }

        Employee e = new Employee();
        e.setEmployeeNo(employeeNo.getValue().trim().toLowerCase());
        e.setFirstname(firstname.getValue().trim().toLowerCase());
        e.setMiddlename(middlename.getValue().trim().toLowerCase());
        e.setLastname(lastname.getValue().trim().toLowerCase());
        e.setGender(gender.getValue().toString().trim().toLowerCase());
        e.setPersonalStatus(status.getValue().toString());

        boolean result = employeeService.createNewAccount(e);
        if (result) {
            close();
            getHsplit().setFirstComponent(new EmployeesDataGridProperties(getHsplit(), "personal"));
        }
    });
    f.addComponent(saveBtn);

    return f;
}

From source file:com.save.employee.PersonalInformationForm.java

public PersonalInformationForm(HorizontalSplitPanel hsplit, int employeeId, Grid grid, Object itemId) {
    this.hsplit = hsplit;
    this.employeeId = employeeId;
    this.grid = grid;
    this.itemId = itemId;

    setMargin(new MarginInfo(true, true, false, false));
    setWidth("80%");
    addStyleName("light");

    editBtn = new Button(BUTTON_CAPTION, editBtnListener);
    editBtn.setEnabled(false);/*from   w  w w.j  a v  a2 s. c om*/

    cancelBtn = new Button("CANCEL");
    cancelBtn.setEnabled(false);

    newEntryBtn = new Button("NEW ACCOUNT");

    employeeNoField = new TextField("Employee ID: ");
    employeeNoField.setWidth("50%");
    employeeNoField.setRequired(true);
    employeeNoField.setRequiredError("Required Employee ID!");
    addComponent(employeeNoField);

    firstname = new TextField("Firstname: ");
    firstname.setWidth("50%");
    firstname.setRequired(true);
    firstname.setRequiredError("Required Firstname!");
    addComponent(firstname);

    middlename = new TextField("Middlename: ");
    middlename.setWidth("50%");
    middlename.setRequired(true);
    middlename.setRequiredError("Required Middlename!");
    addComponent(middlename);

    lastname = new TextField("Lastname: ");
    lastname.setWidth("50%");
    lastname.setRequired(true);
    lastname.setRequiredError("Required Lastname!");
    addComponent(lastname);

    gender = new OptionGroup("Gender: ");
    gender.addItem("Female");
    gender.addItem("Male");
    gender.addStyleName("horizontal");
    addComponent(gender);

    status = new ComboBox("Status: ");
    status.setNullSelectionAllowed(false);
    status.addItem("Single");
    status.addItem("Married");
    status.addItem("Widow");
    status.addItem("Separated");
    addComponent(status);

    birthday = new DateField("Birthday");
    birthday.setValue(new Date());
    addComponent(birthday);

    if (getEmployeeId() != 0) {
        Employee e = es.getEmployeesPersonalDataById(getEmployeeId());
        employeeNoField.setValue(e.getEmployeeNo());
        firstname.setValue(e.getFirstname());
        middlename.setValue(e.getMiddlename());
        lastname.setValue(e.getLastname());
        gender.setValue(CommonUtilities.capitalizeFirstLetter(e.getGender()));
        status.setValue(e.getPersonalStatus());
        birthday.setValue((e.getDob() == null) ? new Date() : e.getDob());
        editBtn.setEnabled(true);
        cancelBtn.setEnabled(true);
    }

    setReadOnly(true);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setMargin(new MarginInfo(true, false, true, false));
    footer.setSpacing(true);
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    addComponent(footer);
    footer.addComponent(editBtn);
    footer.addComponent(cancelBtn);
    footer.addComponent(newEntryBtn);

    removeBtn = new Button("REMOVE ACCOUNT");
    removeBtn.addClickListener(removeBtnListener);
    addComponent(removeBtn);

    cancelBtn.addClickListener((Button.ClickEvent event) -> {
        setReadOnly(false);
        addStyleName("light");
        editBtn.setCaption(BUTTON_CAPTION);
        editBtn.removeStyleName("primary");
        setReadOnly(true);
        disableFields(false);
        newEntryBtn.setEnabled(true);
    });

    newEntryBtn.addClickListener((Button.ClickEvent event) -> {
        setReadOnly(true);
        addStyleName("light");
        editBtn.setCaption(BUTTON_CAPTION);
        editBtn.removeStyleName("primary");

        Window sub = new CreateNewAccountWindow(getHsplit());
        UI.getCurrent().addWindow(sub);
    });

    disableFields(false);
}

From source file:com.swifta.mats.web.usermanagement.AddUserModule.java

private VerticalLayout getNewUserContainer() {

    VerticalLayout cAgentInfo = new VerticalLayout();

    Embedded emb = new Embedded(null, new ThemeResource("img/add_user_small.png"));
    emb.setDescription("add new user");
    emb.setStyleName("search_user_img");
    emb.setSizeUndefined();//from  w ww .  ja  v a  2s .co m

    Label lbSearch = new Label("Add New User... ");

    // Label lbSearch = new Label("Search " + strUserType + " by: ");
    lbSearch.setSizeUndefined();
    lbSearch.setStyleName("label_search_user");
    lbSearch.setSizeUndefined();

    HorizontalLayout header = new HorizontalLayout();
    header.setHeightUndefined();
    header.setMargin(false);
    header.setSpacing(true);
    header.addComponent(emb);
    header.addComponent(lbSearch);
    header.setStyleName("search_user_header");

    cAgentInfo.addComponent(header);
    cAgentInfo.setComponentAlignment(header, Alignment.TOP_CENTER);

    VerticalLayout cBasic = new VerticalLayout();
    Label lbB = new Label("Basic");
    lbB.setStyleName("lb_frm_add_user");
    cBasic.addComponent(lbB);

    TextField tF = new TextField("First Name");
    arrLDFields.add(tF);
    arrLAllFields.add(tF);
    arrLGFields.add(tF);
    tFFN = tF;
    tF.setImmediate(true);
    tFFN.setRequired(true);
    cBasic.addComponent(tF);

    tF = new TextField("Middle Name");
    tFMN = tF;
    // tF.setImmediate(true);
    tFMN.setRequired(false);
    cBasic.addComponent(tF);
    arrLDFields.add(tF);
    arrLAllFields.add(tF);

    tF = new TextField("Last Name");
    tFLN = tF;
    tF.setImmediate(true);
    tFLN.setRequired(true);
    cBasic.addComponent(tF);
    arrLDFields.add(tF);
    arrLAllFields.add(tF);
    arrLGFields.add(tF);

    tF = new TextField("Territory");
    tFTerritory = tF;
    tFTerritory.setImmediate(true);
    tFTerritory.setRequired(true);
    tFTerritory.setVisible(false);
    cBasic.addComponent(tF);
    arrLDFields.add(tF);
    arrLAllFields.add(tF);
    // arrLGFields.add(tF);

    OptionGroup opt = new OptionGroup("Gender");

    opt.addItem("FEMALE");
    opt.addItem("MALE");
    optSex = opt;
    optSex.setRequired(true);
    optSex.setImmediate(true);
    cBasic.addComponent(opt);
    // arrLDFields.add(opt);
    arrLAllFields.add(opt);
    arrLGFields.add(opt);

    ComboBox combo = new ComboBox("Prefix");
    combo.addItem("Mr. ");
    combo.addItem("Mrs. ");
    combo.addItem("Dr. ");
    combo.addItem("Eng. ");
    combo.addItem("Prof. ");
    comboPref = combo;
    comboPref.select("Eng. ");
    //combo.addItems();
    cBasic.addComponent(combo);
    // arrLDFields.add(combo);
    arrLAllFields.add(combo);

    combo = new ComboBox("Suffix");
    combo.addItem("Ph.D");
    combo.addItem("M.B.A");
    combo.addItem("RA");
    combo.addItem("CISA ");
    // combo.select("Ph.D");
    comboSuff = combo;
    cBasic.addComponent(combo);
    // arrLDFields.add(combo);
    arrLAllFields.add(combo);

    combo = new ComboBox("Language");
    combo.addItem(1);
    // combo.select(1);
    combo.setItemCaption(1, "en-US");
    combo.addItem(2);
    combo.setItemCaption(2, "en-UK");
    combo.addItem(3);
    combo.setItemCaption(3, "fr");
    comboLang = combo;
    comboLang.setRequired(true);
    comboLang.setImmediate(true);
    cBasic.addComponent(combo);
    // arrLDFields.add(combo);
    arrLAllFields.add(combo);
    arrLGFields.add(combo);

    tF = new TextField("Occupation");
    // tF.setValue("Software Engineer");
    tFOcc = tF;
    tFOcc.setRequired(true);
    tFOcc.setImmediate(true);
    cBasic.addComponent(tF);
    // arrLDFields.add(tF);
    arrLAllFields.add(tF);
    arrLGFields.add(tF);

    tF = new TextField("Employer");
    // tF.setValue("Swifta");
    tFEmp = tF;
    cBasic.addComponent(tF);
    // arrLDFields.add(tF);
    arrLAllFields.add(tF);

    PopupDateField dF = new PopupDateField("DoB");
    Calendar cal = Calendar.getInstance();
    cal.set(1988, 11, 12);
    dFDoB = dF;
    cBasic.addComponent(dF);
    // arrLDFields.add(dF);
    arrLAllFields.add(dF);

    combo = new ComboBox("Country");
    comboCountry = combo;
    comboCountry.setRequired(true);
    cBasic.addComponent(combo);
    arrLDFields.add(combo);
    arrLAllFields.add(combo);
    arrLGFields.add(combo);

    combo = new ComboBox("State");
    comboState = combo;
    comboState.setRequired(true);
    comboState.setNullSelectionAllowed(false);
    cBasic.addComponent(combo);
    arrLDFields.add(combo);
    arrLAllFields.add(combo);
    arrLGFields.add(combo);

    combo = new ComboBox("Local Government");
    comboLG = combo;
    comboLG.setRequired(true);
    cBasic.addComponent(combo);
    arrLDFields.add(combo);
    arrLAllFields.add(combo);
    arrLGFields.add(combo);

    VerticalLayout cC = new VerticalLayout();

    HorizontalLayout cBAndCAndAcc = new HorizontalLayout();
    cBAndCAndAcc.addComponent(cBasic);
    cBAndCAndAcc.addComponent(cC);

    cCompany = new VerticalLayout();
    Label lbC = new Label("Identification");
    lbC.setStyleName("lb_frm_add_user");

    combo = new ComboBox("ID Type");
    combo.addItem("Passport Number");
    combo.addItem("National Registration Identification Number");
    combo.addItem("Drivers License Number");
    combo.addItem("Identification Card");
    combo.addItem("Employer Identification Number");
    comboIDType = combo;
    comboIDType.setRequired(true);
    comboIDType.setImmediate(true);
    cCompany.addComponent(combo);
    // arrLDFields.add(combo);
    arrLAllFields.add(combo);
    arrLGFields.add(combo);

    tF = new TextField("ID No.");
    // tF.setValue("001");
    tFIDNo = tF;
    tFIDNo.setRequired(true);
    tFIDNo.setImmediate(true);
    cCompany.addComponent(tF);
    // arrLDFields.add(tF);
    arrLAllFields.add(tF);
    arrLGFields.add(tF);

    tF = new TextField("Issuer");
    tFIssuer = tF;
    cCompany.addComponent(tF);
    // arrLDFields.add(tF);
    arrLAllFields.add(tF);

    dF = new PopupDateField("Issue Date");
    // cal = Calendar.getInstance();
    cal.set(12, 12, 12);
    // dF.setValue(cal.getTime());
    dFDoI = dF;
    // cal.clear();

    cal = Calendar.getInstance();
    Date dToday = cal.getTime();

    cal.set(1970, 0, 1);
    Date dMin = cal.getTime();

    dFDoI.addValidator(new DateRangeValidator("Invalid issue date. Please select a date Earlier/Today.", dMin,
            dToday, null));
    cCompany.addComponent(dF);
    // arrLDFields.add(dF);
    arrLAllFields.add(dF);
    arrLGFields.add(dF);

    dFDoI.setImmediate(true);

    dF = new PopupDateField("Expiry Date");
    cal.set(14, 12, 12);
    dFDoE = dF;
    DateRangeValidator drv = new DateRangeValidator("ID is Expired", dToday, null, null);
    dFDoE.addValidator(drv);

    dFDoI.setRequired(true);
    dFDoI.setImmediate(true);

    dFDoE.setRequired(true);
    dFDoE.setImmediate(true);

    cCompany.addComponent(dF);
    // arrLDFields.add(dF);
    arrLAllFields.add(dF);
    arrLGFields.add(dF);

    cC.addComponent(cCompany);

    VerticalLayout pC = new VerticalLayout();
    lbC = new Label("Primary Contacts");
    HorizontalLayout cLbc = new HorizontalLayout();
    cLbc.setSizeUndefined();
    cLbc.setMargin(new MarginInfo(true, false, false, false));
    cLbc.addComponent(lbC);
    pC.addComponent(cLbc);
    cxPC = pC;

    tF = new TextField("Mobile Phone No.");
    tFPMNo = tF;
    pC.addComponent(tF);
    // arrLDFields.add(tF);
    arrLAllFields.add(tF);

    tF = new TextField("Alt. Phone No.");
    tFPANo = tF;
    pC.addComponent(tF);
    // arrLDFields.add(tF);
    arrLAllFields.add(tF);

    tF = new TextField("Email Address");
    // tF.setValue("pwndz172@gmail.com");
    tFPEmail = tF;
    tFPEmail.addValidator(new EmailValidator("Invalid Email address."));
    tFPEmail.setImmediate(true);
    pC.addComponent(tF);
    cC.addComponent(pC);
    // arrLDFields.add(tF);
    arrLAllFields.add(tF);
    tFPEmail.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 6060653158010946535L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            if (event.getProperty().getValue() == null || event.getProperty().getValue().toString().isEmpty()) {
                arrLGFields.remove(tFPEmail);
            } else {
                arrLGFields.add(tFPEmail);
            }

        }

    });

    VerticalLayout sC = new VerticalLayout();
    lbC = new Label("Secondary Contacts");
    cLbc = new HorizontalLayout();
    cLbc.setSizeUndefined();
    cLbc.setMargin(new MarginInfo(true, false, false, false));
    cLbc.addComponent(lbC);
    // arrLDFields.add(lbC);
    // arrLAllFields.add(lbC);
    cxSC = sC;
    sC.addComponent(cLbc);

    tF = new TextField("Mobile Phone No.");
    tFSMNo = tF;
    sC.addComponent(tF);
    // arrLDFields.add(tF);
    arrLAllFields.add(tF);

    tF = new TextField("Alt. Phone No.");
    // tF.setValue("+1804191152");
    tFSANo = tF;
    sC.addComponent(tF);
    // arrLDFields.add(tF);
    arrLAllFields.add(tF);

    tF = new TextField("E-mail Address");
    tFSEmail = tF;
    tFSEmail.addValidator(new EmailValidator("Invalid Email Address."));
    tFSEmail.setImmediate(true);
    sC.addComponent(tF);
    // arrLDFields.add(tF);
    arrLAllFields.add(tF);

    tFSEmail.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 6060653158010946535L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            if (event.getProperty().getValue() == null || event.getProperty().getValue().toString().isEmpty()) {

                arrLGFields.remove(tFSEmail);
            } else {
                arrLGFields.add(tFSEmail);
            }

        }

    });

    cC.addComponent(sC);

    VerticalLayout physicalC = new VerticalLayout();
    lbC = new Label("Physical Address");
    cLbc = new HorizontalLayout();
    cLbc.setSizeUndefined();
    cLbc.setMargin(new MarginInfo(true, false, false, false));
    cLbc.addComponent(lbC);
    physicalC.addComponent(cLbc);

    // arrLDFields.add(lbC);
    // arrLAllFields.add(lbC);

    tF = new TextField("Postal Code");
    tFPostalCode = tF;
    physicalC.addComponent(tF);
    // arrLDFields.add(tF);
    arrLAllFields.add(tF);

    tF = new TextField("Street");
    // tF.setValue("Yusuf Lule Rd.");
    tFStreet = tF;
    tFStreet.setRequired(true);
    tFStreet.setImmediate(true);
    physicalC.addComponent(tF);
    arrLDFields.add(tF);
    arrLAllFields.add(tF);
    arrLPAddr.add(tF);

    tF = new TextField("Province");
    tFProv = tF;
    physicalC.addComponent(tF);
    arrLDFields.add(tF);
    arrLAllFields.add(tF);
    arrLPAddr.add(tF);

    tF = new TextField("City");
    tFCity = tF;
    tFCity.setRequired(true);
    tFCity.setImmediate(true);
    physicalC.addComponent(tF);
    arrLDFields.add(tF);
    arrLAllFields.add(tF);
    arrLPAddr.add(tF);

    cC.addComponent(physicalC);
    tFPostalCode.setImmediate(true);

    VerticalLayout cAcc = new VerticalLayout();
    Label lbAcc = new Label("Account");
    lbAcc.setStyleName("lb_frm_add_user");
    cAcc.addComponent(lbAcc);
    ComboBox comboHierarchy = null;

    comboHierarchy = new ComboBox("Profile");

    Set<Entry<Integer, String>> set = profToID.entrySet();
    for (Entry<Integer, String> e : set) {
        comboHierarchy.addItem(e.getKey());
        comboHierarchy.setItemCaption(e.getKey(), e.getValue());
    }

    // comboHierarchy.select(1);
    comboProfile = comboHierarchy;
    comboProfile.setRequired(true);
    comboProfile.setImmediate(true);
    comboProfile.select(1);
    cAcc.addComponent(comboHierarchy);

    final VerticalLayout cLBody = new VerticalLayout();

    tF = new TextField("Username");
    // tF.setValue("Livepwndz");
    tFUN = tF;
    tFUN.setRequired(true);
    cLBody.addComponent(tF);
    arrLDFields.add(tF);
    arrLAllFields.add(tF);
    arrLGFields.add(tF);

    tF = new TextField("MSISDN");
    // tF.setValue("+256774191152");
    tFMSISDN = tF;
    tFMSISDN.setRequired(true);
    tFMSISDN.setImmediate(true);
    cLBody.addComponent(tF);
    arrLDFields.add(tF);
    arrLAllFields.add(tF);
    arrLGFields.add(tF);

    // / tF = new TextField("PIN");
    // / cLBody.addComponent(tF);

    tF = new TextField("Email");
    tFAccEmail = tF;
    tFAccEmail.addValidator(new EmailValidator("Invalid Email Address."));
    tFAccEmail.setRequired(true);
    tFAccEmail.setImmediate(true);
    cLBody.addComponent(tF);
    arrLDFields.add(tF);
    arrLAllFields.add(tF);
    arrLGFields.add(tF);

    combo = new ComboBox("Bank Domain");
    combo.addItem("Heritage Bank");
    // combo.select("Heritage Bank");
    comboBDomain = combo;
    cLBody.addComponent(combo);
    // arrLDFields.add(combo);
    arrLAllFields.add(combo);

    combo = new ComboBox("Bank Code ID");
    combo.addItem("001");
    // combo.select("001");
    comboBID = combo;
    cLBody.addComponent(comboBID);
    // arrLDFields.add(combo);
    arrLAllFields.add(combo);

    tF = new TextField("Bank Account");
    tFBAcc = tF;
    cLBody.addComponent(tF);
    // arrLDFields.add(tF);
    arrLAllFields.add(tF);

    combo = new ComboBox("Currency");
    combo.addItem(1);
    combo.setItemCaption(1, "US Dollars");
    comboCur = combo;
    cLBody.addComponent(combo);
    // arrLDFields.add(combo);
    arrLAllFields.add(combo);

    tF = new TextField("Clearing Number");
    tFClrNo = tF;
    cLBody.addComponent(tF);
    // arrLDFields.add(tF);
    arrLAllFields.add(tF);

    Label lbAccRec = new Label("Account Recovery");
    HorizontalLayout cLbAccRec = new HorizontalLayout();
    cLbAccRec.setSizeUndefined();
    cLbAccRec.setMargin(new MarginInfo(true, false, false, false));
    cLbAccRec.addComponent(lbAccRec);
    cLBody.addComponent(cLbAccRec);

    combo = new ComboBox("Security Question");
    combo.addItem(1);
    combo.addItem(2);
    combo.addItem(3);
    combo.setItemCaption(1, "What is your grandfather's last name?");
    combo.setItemCaption(2, "What was your favorite junior school teacher's name?");
    combo.setItemCaption(3, "What was one of your nicknames in school?");
    // combo.select(2);
    comboSecQn = combo;
    cLBody.addComponent(combo);

    tF = new TextField("Answer");
    // tF.setValue("Mrs. X");
    tFSecAns = tF;
    cLBody.addComponent(tF);

    CheckBox chk = new CheckBox("I accept the terms" + " and conditons.");
    chcTAndC = chk;
    chk.setStyleName("check_t_and_c");

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

        @Override
        public void valueChange(ValueChangeEvent event) {

            isValidatorAdded = false;

            /*
             * COMMENTED OUT BECAUSE THE FEATURE FOR CHANGING THE UI BASED
             * ON USER PROFILEL SELECTED HAS NOT BEEN FULLY TESTED if
             * (comboProfile.getValue() != null &&
             * comboProfile.getValue().equals(11)) {
             * btnSave.setEnabled(true); for (Field<?> f : arrLAllFields) {
             * f.setVisible(false); } for (Field<?> f : arrLDFields) {
             * f.setVisible(true); f.setRequired(true); }
             * 
             * tFFN.setCaption("Station Name"); tFMN.setCaption("Zone");
             * tFLN.setCaption("Sales Area");
             */
            /*
             * arrLPAddr.get(0).setCaption("Zone");
             * arrLPAddr.get(1).setCaption("Sales Area");
             * arrLPAddr.get(1).setRequired(true);
             * arrLPAddr.get(2).setCaption("Territory");
             */
            /*
             * cxSC.setVisible(false); cxPC.setVisible(false);
             * cCompany.setVisible(false); arrLValidatable = arrLDFields;
             * reset(); // btnSave.setEnabled(false);
             * 
             * return; }
             */
            btnSave.setEnabled(true);
            tFFN.setCaption("First Name");
            tFMN.setCaption("Middle Name");
            tFLN.setCaption("Last Name");

            for (Field<?> f : arrLAllFields) {
                f.setVisible(true);
                f.setRequired(false);
            }

            for (Field<?> f : arrLGFields) {
                f.setRequired(true);

            }

            /*
             * arrLPAddr.get(0).setCaption("Street");
             * arrLPAddr.get(1).setCaption("Province");
             * arrLPAddr.get(2).setCaption("City");
             */

            cxSC.setVisible(true);
            cxPC.setVisible(true);
            cCompany.setVisible(true);
            arrLValidatable = arrLGFields;
            reset();

        }

    });
    chk.addValueChangeListener(new ValueChangeListener() {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            // Notification.show(event.getProperty().getValue().toString());

        }

    });

    tFPostalCode.addValidator(new Validator() {

        private static final long serialVersionUID = 9193817369890607387L;

        @Override
        public void validate(Object value) throws InvalidValueException {
            if (value.toString().trim().isEmpty())
                return;

            try {
                Long.parseLong(tFPostalCode.getValue());
            } catch (Exception e) {
                tFPostalCode.focus();
                throw new InvalidValueException("Only digits in Postal Code field.");

            }

        }

    });

    comboCountry.addFocusListener(new FocusListener() {

        private static final long serialVersionUID = -5162384967736354225L;

        @Override
        public void focus(FocusEvent event) {
            if (isCSelected)
                return;
            Set<Entry<Integer, String>> es = (Set<Entry<Integer, String>>) getCountries().entrySet();
            if (es.size() == 0)
                return;
            Iterator<Entry<Integer, String>> itr = es.iterator();
            comboCountry.setNullSelectionAllowed(false);
            while (itr.hasNext()) {
                Entry<Integer, String> e = itr.next();
                comboCountry.addItem(e.getKey());
                comboCountry.setItemCaption(e.getKey(), e.getValue());
            }

            comboCountry.select(null);

            isCSelected = true;

        }

    });

    comboCountry.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -404551290095133508L;

        @Override
        public void valueChange(ValueChangeEvent event) {

            comboState.removeAllItems();
            comboLG.removeAllItems();

            if (comboCountry.getValue() == null)
                return;

            Set<Entry<Integer, String>> es = (Set<Entry<Integer, String>>) getStates(
                    Integer.valueOf(comboCountry.getValue().toString())).entrySet();

            if (es.isEmpty()) {
                return;
            }

            Iterator<Entry<Integer, String>> itr = es.iterator();
            while (itr.hasNext()) {
                Entry<Integer, String> e = itr.next();
                comboState.addItem(e.getKey());
                comboState.setItemCaption(e.getKey(), e.getValue());
            }

            comboState.select(null);

        }

    });

    comboState.addFocusListener(new FocusListener() {

        private static final long serialVersionUID = 892516817835461278L;

        @Override
        public void focus(FocusEvent event) {
            Object c = comboCountry.getValue();

            if (c == null) {
                Notification.show("Please select country first", Notification.Type.WARNING_MESSAGE);
                comboCountry.focus();
                return;

            }

        }

    });

    comboState.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 8849241310354979908L;

        @Override
        public void valueChange(ValueChangeEvent event) {

            comboLG.removeAllItems();
            if (comboState.getValue() == null)
                return;
            Set<Entry<Integer, String>> esl = (Set<Entry<Integer, String>>) getLGs(
                    Integer.valueOf(comboState.getValue().toString())).entrySet();
            if (esl.isEmpty()) {
                return;
            }

            Iterator<Entry<Integer, String>> itrl = esl.iterator();
            while (itrl.hasNext()) {
                Entry<Integer, String> e = itrl.next();
                comboLG.addItem(e.getKey());
                comboLG.setItemCaption(e.getKey(), e.getValue());
            }

        }

    });

    comboLG.addFocusListener(new FocusListener() {

        private static final long serialVersionUID = 8925916817835461278L;

        @Override
        public void focus(FocusEvent event) {

            Object s = comboState.getValue();
            if (comboCountry.getValue() == null) {
                Notification.show("Please select country first", Notification.Type.WARNING_MESSAGE);
                comboCountry.focus();
                return;

            }

            if (s == null) {
                Notification.show("Please select state first", Notification.Type.WARNING_MESSAGE);
                comboState.focus();
                return;

            }

        }

    });

    HorizontalLayout cChk = new HorizontalLayout();
    cChk.setSizeUndefined();
    cChk.setMargin(new MarginInfo(true, false, true, false));
    cChk.addComponent(chk);
    cLBody.addComponent(cChk);

    final VerticalLayout cRBody = new VerticalLayout();
    String strNameCap = "Username";

    tF = new TextField(strNameCap);
    cRBody.addComponent(tF);

    HorizontalLayout cAccBody = new HorizontalLayout();
    cAccBody.addComponent(cLBody);
    cAccBody.addComponent(cRBody);
    cLBody.setStyleName("c_body_visible");
    cRBody.setStyleName("c_body_invisible");
    cAcc.addComponent(cAccBody);

    cBAndCAndAcc.addComponent(cAcc);

    cC.setMargin(new MarginInfo(false, true, false, true));
    cAgentInfo.addComponent(cBAndCAndAcc);

    btnSave = new Button("Save");
    btnSave.setIcon(FontAwesome.SAVE);
    btnSave.setStyleName("btn_link");

    Button btnReset = new Button("Reset");
    btnReset.setIcon(FontAwesome.UNDO);
    btnReset.setStyleName("btn_link");
    HorizontalLayout cBtnSR = new HorizontalLayout();
    cBtnSR.addComponent(btnSave);
    cBtnSR.addComponent(btnReset);

    cAcc.addComponent(cBtnSR);

    arrLValidatable = arrLGFields;

    btnSave.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = -935880570210949227L;

        @Override
        public void buttonClick(ClickEvent event) {
            UserManagementService ums = new UserManagementService();

            String strResponse = "";
            String idtype = "";

            try {

                try {
                    if (!isValidatorAdded)
                        addValidators(arrLValidatable);
                    validate(arrLValidatable);

                } catch (InvalidValueException e) {
                    Notification.show("Message: ", e.getMessage(), Notification.Type.ERROR_MESSAGE);
                    return;
                }

                String bacc = (tFBAcc.getValue() == null) ? "" : tFBAcc.getValue().toString();
                int bid = (comboBID.getValue() == null) ? 0 : Integer.valueOf(comboBID.getValue().toString());

                String bd = (comboBDomain.getValue() == null) ? "" : comboBDomain.getValue().toString();
                String clrno = (tFClrNo.getValue() == null) ? "" : tFClrNo.getValue().toString();
                String cur = (comboCur.getValue() == null) ? "000" : comboCur.getValue().toString();
                String accEmail = (tFAccEmail.getValue() == null) ? "" : tFAccEmail.getValue().toString();
                String msisdn = (tFMSISDN.getValue() == null) ? "" : tFMSISDN.getValue().toString();
                int profid = (comboProfile.getValue() == null) ? 0
                        : Integer.valueOf(comboProfile.getValue().toString());
                String secQn = (comboSecQn.getValue() == null) ? "" : comboSecQn.getValue().toString();
                String secAns = (tFSecAns.getValue() == null) ? "" : tFSecAns.getValue().toString();
                String tAndC = (chcTAndC.getValue() == null) ? "" : chcTAndC.getValue().toString();
                String un = (tFUN.getValue() == null) ? "" : tFUN.getValue().toString();
                int country = (comboCountry.getValue() == null) ? 0
                        : (comboCountry.getValue().toString().trim().isEmpty()) ? 0
                                : Integer.valueOf(comboCountry.getValue().toString());
                Date dob = (dFDoB.getValue() == null) ? new Date() : dFDoB.getValue();
                String employer = (tFEmp.getValue() == null) ? "" : tFEmp.getValue().toString();
                String fn = (tFFN.getValue() == null) ? "" : tFFN.getValue().toString();
                String gender = (optSex.getValue() == null) ? ""
                        : optSex.getItemCaption(optSex.getValue()).toString();
                int lang = (comboLang.getValue() == null) ? 0
                        : (comboLang.getValue().toString().trim().isEmpty()) ? 0
                                : Integer.valueOf(comboLang.getValue().toString());
                String ln = (tFLN.getValue() == null) ? "" : tFLN.getValue().toString();
                int lgid = (comboLG.getValue() == null) ? 0
                        : (comboLG.getValue().toString().trim().isEmpty()) ? 0
                                : Integer.valueOf(comboLG.getValue().toString());

                String mn = (tFMN.getValue() == null) ? "" : tFMN.getValue().toString();
                String occ = (tFOcc.getValue() == null) ? "" : tFOcc.getValue().toString();
                String pref = (comboPref.getValue() == null) ? "" : comboPref.getValue().toString();
                int stateid = (comboState.getValue() == null) ? 0
                        : (comboState.getValue().toString().trim().isEmpty()) ? 0
                                : Integer.valueOf(comboState.getValue().toString());
                String suff = (comboSuff.getValue() == null) ? "" : comboSuff.getValue().toString();
                String city = (tFCity.getValue() == null) ? "" : tFCity.getValue().toString();
                String pcode = (tFPostalCode.getValue() == null) ? ""
                        : (tFPostalCode.getValue().isEmpty()) ? "000" : tFPostalCode.getValue().toString();
                String str = (tFStreet.getValue() == null) ? "" : tFStreet.getValue().toString();
                String prov = (tFProv.getValue() == null) ? "" : tFProv.getValue().toString();
                Date doe = (dFDoE.getValue() == null) ? new Date() : dFDoE.getValue();
                String idno = (tFIDNo.getValue() == null) ? "" : tFIDNo.getValue().toString();

                Date doi = (dFDoI.getValue() == null) ? new Date() : dFDoI.getValue();

                String issuer = (tFIssuer.getValue() == null) ? "" : tFIssuer.getValue().toString();
                String pem = (tFPEmail.getValue() == null) ? "" : tFPEmail.getValue().toString();
                String pmno = (tFPMNo.getValue() == null) ? "" : tFPMNo.getValue().toString();

                String pamno = (tFPANo.getValue() == null) ? "" : tFPANo.getValue().toString();
                String sem = (tFSEmail.getValue() == null) ? "" : tFSEmail.getValue().toString();
                String smno = (tFSMNo.getValue() == null) ? "" : tFSMNo.getValue().toString();
                String samno = (tFSANo.getValue() == null) ? "" : tFSANo.getValue().toString();

                // IdentificationType idtype =
                // ProvisioningStub.IdentificationType.Factory
                // .fromValue(comboIDType.getValue().toString());
                if (comboIDType.getValue() != null)
                    if (comboIDType.getValue().toString().equals("Passport Number")) {
                        idtype = ProvisioningStub.IdentificationType.PASSP.toString();
                        System.out.println("idtype>>>>>1 " + idtype);
                    } else if (comboIDType.getValue().toString()
                            .equals("National Registration Identification Number")) {
                        idtype = ProvisioningStub.IdentificationType.NRIN.toString();
                        System.out.println("idtype>>>>>2 " + idtype);
                    } else if (comboIDType.getValue().toString().equals("Drivers License Number")) {
                        idtype = ProvisioningStub.IdentificationType.DRLCS.toString();
                        System.out.println("idtype>>>>>3 " + idtype);
                    } else if (comboIDType.getValue().toString().equals("Identification Card")) {
                        idtype = ProvisioningStub.IdentificationType.IDCD.toString();
                        System.out.println("idtype>>>>>4 " + idtype);
                    } else if (comboIDType.getValue().toString().equals("Employer Identification Number")) {
                        idtype = ProvisioningStub.IdentificationType.EMID.toString();
                    }

                    else
                        idtype = "";

                System.out.println("idtype>>>>> " + idtype);

                System.out.println("idtype>>>>> " + ProvisioningStub.IdentificationType.PASSP.toString());

                strResponse = ums.registerUser(bacc, bid, bd, clrno, cur, accEmail, msisdn, profid, secQn,
                        secAns, tAndC, un, country, dob, employer, fn, gender, lang, ln, lgid, mn, occ, pref,
                        stateid, suff, city, pcode, str, prov, doe, idno, idtype, doi, issuer, pem, pmno, pamno,
                        sem, smno, samno);

            } catch (Exception e) {
                e.printStackTrace();
                Notification.show("Response: ", e.getMessage(), Notification.Type.ERROR_MESSAGE);

                System.out.println(e.getMessage());
                return;
            }

            if (strResponse.contains("completed") && strResponse.contains("successful")) {
                NotifCustom.show("Message: ", strResponse);
                reset();
            } else {
                Notification.show("Response: " + strResponse, Notification.Type.ERROR_MESSAGE);

                System.out.println(strResponse);
            }

        }
    });

    btnReset.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 3212854064282339617L;

        @Override
        public void buttonClick(ClickEvent event) {

            reset();

        }
    });

    return cAgentInfo;
}

From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java

private VerticalLayout getUDContainer(String strUID) {

    if (bee == null)
        bee = new UserDetailsBackEnd();

    hm = bee.getUD(strUID);/*from w  ww. j  a v a  2 s .  c o  m*/

    String strProf = hm.get("Profile Type");

    VerticalLayout cAgentInfo = new VerticalLayout();
    cAgentInfo.setMargin(new MarginInfo(true, false, true, false));
    cAgentInfo.setStyleName("c_details_test");
    cAgentInfo.setSizeUndefined();

    FormLayout cBasic = new FormLayout();

    // cBasic.setSpacing(true);
    Label lbB = new Label();
    lbB.setCaption("General");
    lbB.setStyleName("label_search_user u_d_t");

    cBasic.addComponent(lbB);
    String cap = "First Name";
    TextField tF = new TextField(cap);
    tFFN = tF;
    tFFN.setRequired(true);
    tF.setValue(hm.get(cap));

    addDatum("Username", hm.get("Username"), cBasic);
    addDatum("Profile", strProf, cBasic);
    addDatum("Account Status", hm.get("Status"), cBasic);
    addDatum("First Name", hm.get("First Name"), cBasic);

    tF = new TextField("Middle Name");
    addDatum("Middle Name", hm.get("Middle Name"), cBasic);
    addDatum("Last Name", hm.get("Last Name"), cBasic);
    addDatum("Gender", hm.get("Gender"), cBasic);
    addDatum("Occupation", hm.get("Occupation"), cBasic);
    addDatum("Date of Birth", hm.get("Date of Birth"), cBasic);
    addDatum("Country", hm.get("Country"), cBasic);
    addDatum("State", hm.get("State"), cBasic);
    addDatum("Local Government", hm.get("Local Government"), cBasic);

    VerticalLayout cC = new VerticalLayout();

    HorizontalLayout cBAndCAndAcc = new HorizontalLayout();
    cBAndCAndAcc.addComponent(cBasic);
    cBAndCAndAcc.addComponent(cC);

    FormLayout cCompany = new FormLayout();
    // Label lbC = new Label("Company");
    Label lbC = new Label();
    lbC.setCaption("Identification");
    lbC.setStyleName("label_search_user lb_frm_add_user u_d_t");

    combo = new ComboBox("ID Type");

    combo.addItem("Passport Number");
    combo.addItem("National Registration Identification Number");
    combo.addItem("Drivers License Number");
    combo.addItem("Identification Card");
    combo.addItem("Employer Identification Number");
    combo.select("Passport Number");
    comboIDType = combo;
    comboIDType.setRequired(true);

    cCompany.addComponent(lbC);
    addDatum("ID Type", hm.get("ID Type"), cCompany);
    addDatum("ID No.", hm.get("ID No."), cCompany);
    addDatum("Issuer", hm.get("Issuer"), cCompany);
    addDatum("Issue Date", hm.get("Issue Date"), cCompany);
    addDatum("Expiry Date", hm.get("Expiry Date"), cCompany);
    cC.addComponent(cCompany);

    FormLayout pC = new FormLayout();
    lbC = new Label();
    lbC.setCaption("Primary Contacts");
    lbC.setStyleName("label_search_user u_d_t");
    pC.addComponent(lbC);
    addDatum("Mobile Phone No.", hm.get("P-Mobile Phone No."), pC);
    addDatum("Alt. Phone No.", hm.get("P-Alt. Phone No."), pC);
    addDatum("Email Address", hm.get("Email"), pC);
    cC.addComponent(pC);

    FormLayout sC = new FormLayout();
    lbC = new Label();
    lbC.setCaption("Secondary Contacts");
    lbC.setStyleName("label_search_user lb_frm_add_user u_d_t");
    sC.addComponent(lbC);
    addDatum("Mobile Phone No.", hm.get("S-Mobile Phone No."), sC);
    addDatum("Alt. Phone No.", hm.get("S-Alt. Phone No."), sC);
    addDatum("Email Address", hm.get("Email"), sC);
    cC.addComponent(sC);

    FormLayout physicalC = new FormLayout();
    lbC = new Label();
    lbC.setCaption("Physical Address");
    lbC.setStyleName("label_search_user lb_frm_add_user u_d_t");
    physicalC.addComponent(lbC);
    StringBuilder sbAddr = new StringBuilder();

    String strp = hm.get("Postal Code");
    sbAddr.append((strp == null || strp.trim().isEmpty()) ? "" : "P.O.Box " + strp + ", ");
    strp = hm.get("Street");
    sbAddr.append((strp == null || strp.trim().isEmpty()) ? "" : strp + ", ");
    strp = hm.get("Province");
    sbAddr.append((strp == null || strp.trim().isEmpty()) ? "" : strp + ", ");

    strp = hm.get("State");
    sbAddr.append((strp == null || strp.trim().isEmpty()) ? "" : strp + ", ");

    strp = hm.get("Country");
    sbAddr.append((strp == null || strp.trim().isEmpty()) ? "." : strp);

    Label lb = new Label();
    lbC.setContentMode(ContentMode.HTML);

    lb.setStyleName("label_ud");
    lb.setCaption(sbAddr.toString());

    physicalC.addComponent(lb);

    cC.addComponent(physicalC);
    cC.addComponent(cBtnEditCancel);

    cC.setMargin(new MarginInfo(false, true, false, true));
    cAgentInfo.addComponent(cBAndCAndAcc);

    return cAgentInfo;
}

From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java

private HorizontalLayout getADC() {

    // Notification.show(strTbName);

    VerticalLayout cAgentInfo = new VerticalLayout();
    cAgentInfo.setMargin(new MarginInfo(true, true, true, true));
    cAgentInfo.setStyleName("c_details_test");

    // VerticalLayout cAcc = new VerticalLayout();
    Label lbAcc = new Label();

    lbAcc.setCaption("Account");
    lbAcc.setStyleName("label_search_user lb_frm_add_user u_d_t");

    // lbC.setCaption("Identification");
    // lbC.setStyleName("label_search_user lb_frm_add_user u_d_t");
    // lbAcc.setStyleName("lb_frm_add_user");

    ComboBox comboHierarchy = null;//w w w.  ja va 2 s . c o  m

    comboHierarchy = new ComboBox("Profile");

    final FormLayout cLBody = new FormLayout();
    cLBody.addComponent(lbAcc);
    // cLBody.setSpacing(true);

    comboHierarchy.addItem(1);
    comboHierarchy.setItemCaption(1, "MATS_ADMIN_USER_PROFILE");
    comboHierarchy.select(1);
    comboProfile = comboHierarchy;
    comboProfile.setRequired(true);
    // cAcc.addComponent(comboHierarchy);

    addDatum("Profile", hm.get("Profile Type"), cLBody);

    TextField tF = new TextField("Username");
    tF.setValue("Livepwndz");
    tFUN = tF;
    tFUN.setRequired(true); // cLBody.addComponent(tF);

    addDatum("Username", hm.get("Username"), cLBody);

    tF = new TextField("MSISDN");
    tF.setValue("+256774191152");
    tFMSISDN = tF;
    tFMSISDN.setRequired(true); // cLBody.addComponent(tF);

    addDatum("MSISDN", hm.get("MSISDN"), cLBody);

    tF = new TextField("PIN"); // / cLBody.addComponent(tF);

    tF = new TextField("Email");
    tFAccEmail = tF;
    tFAccEmail.setRequired(true);
    tFAccEmail.setValue("ppounds1@gmail.com"); //
    // cLBody.addComponent(tF);
    addDatum("Email", hm.get("Email"), cLBody);

    combo = new ComboBox("Bank Domain");
    combo.addItem("Stanbic Bank");
    combo.select("Stanbic Bank");
    comboBDomain = combo; //
    // cLBody.addComponent(combo);
    addDatum("Bank Domain", hm.get("Bank"), cLBody);

    combo = new ComboBox("Bank Code ID");
    combo.addItem("001");
    combo.select("001");
    comboBID = combo; // cLBody.addComponent(combo);
    addDatum("Bank Code ID", hm.get("Bank Code"), cLBody);

    tF = new TextField("Bank Account");
    tF.setValue("00232333452315");
    tFBAcc = tF; // tFBAcc.setValidationVisible(true); //
    tFBAcc.addValidator(new NoNull()); // cLBody.addComponent(tF);
    addDatum("Bank Account", hm.get("Bank Account"), cLBody);

    combo.addItem(1);
    combo.setItemCaption(1, "US Dollars");
    combo.select(1);
    comboCur = combo; // cLBody.addComponent(combo);

    addDatum("Currency", hm.get("Currency"), cLBody);

    tF = new TextField("Clearing Number");
    tF.setValue("00212");
    tFClrNo = tF; // cLBody.addComponent(tF);
    addDatum("Clearing No. ", hm.get("Clearing No."), cLBody);

    String strNameCap = "Username";

    tF = new TextField(strNameCap);

    HorizontalLayout cAccBody = new HorizontalLayout();
    cAccBody.addComponent(cLBody);
    cLBody.addComponent(cBtnEditCancel);

    cLBody.setStyleName("c_body_visible");

    // cAcc.addComponent(cAccBody);
    cAgentInfo.addComponent(cLBody);

    // cBAndCAndAcc.addComponent(cAcc);
    HorizontalLayout c = new HorizontalLayout();
    c.addComponent(cAgentInfo);

    return c;

}

From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java

private VerticalLayout getEUDContainer() {

    if (cBtnEditCancel != null)
        cBtnEditCancel.setVisible(false);

    HashMap<Integer, String> profToID = new HashMap<>();

    profToID.put(1, "MATS_ADMIN_USER_PROFILE");
    profToID.put(3, "MATS_FINANCIAL_CONTROLLER_USER_PROFILE");
    profToID.put(4, "MATS_CUSTOMER_CARE_USER_PROFILE");
    profToID.put(6, "MATS_SUPER_AGENT_USER_PROFILE");
    profToID.put(7, "MATS_SUB_AGENT_USER_PROFILE");
    profToID.put(11, "MATS_DEALER_USER_PROFILE");
    profToID.put(15, "MATS_SERVICE_PROVIDER_USER_PROFILE");

    VerticalLayout cAgentInfo = new VerticalLayout();
    cAgentInfo.setMargin(new MarginInfo(true, false, true, false));
    cAgentInfo.setStyleName("c_details_test");
    cAgentInfo.setSizeUndefined();/*from  w ww .j a v a  2  s .  co m*/
    VerticalLayout cBasic = new VerticalLayout();
    Label lbB = new Label("Basic");
    lbB.setStyleName("lb_frm_add_user");
    cBasic.addComponent(lbB);

    TextField tF = new TextField("First Name");
    tFFN = tF;
    tFFN.setRequired(true);
    tF.setValue("Paul");
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    cBasic.addComponent(tF);

    tF = new TextField("Middle Name");
    tF.setValue("Pwndz");
    tFMN = tF;
    tFMN.setRequired(true);
    cBasic.addComponent(tF);

    tF = new TextField("Last Name");
    tF.setValue("Kigozi");
    tFLN = tF;
    tFLN.setRequired(true);
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    cBasic.addComponent(tF);

    OptionGroup opt = new OptionGroup("Gender");

    opt.addItem("FEMALE");
    // opt.setItemCaption(1, "Female");

    opt.addItem("MALE");
    // opt.setItemCaption(2, "Male");
    opt.select("MALE");
    optSex = opt;
    optSex.setRequired(true);
    arrLAllFormFields.add(opt);
    arrLAllEditableFields.add(opt);
    arrLTfEditableVals.add(opt.getValue().toString());
    cBasic.addComponent(opt);

    ComboBox combo = new ComboBox("Prefix");
    combo.addItem("Mr. ");
    combo.addItem("Mrs. ");
    combo.addItem("Dr. ");
    combo.addItem("Eng. ");
    combo.addItem("Prof. ");
    comboPref = combo;
    comboPref.select("Eng. ");

    arrLAllFormFields.add(combo);
    arrLAllEditableFields.add(combo);
    arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString());
    cBasic.addComponent(combo);

    combo = new ComboBox("Suffix");
    combo.addItem("Ph.D");
    combo.addItem("M.B.A");
    combo.addItem("RA");
    combo.addItem("CISA ");
    combo.select("Ph.D");
    comboSuff = combo;
    arrLAllFormFields.add(combo);
    arrLAllEditableFields.add(combo);
    arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString());
    cBasic.addComponent(combo);

    combo = new ComboBox("Language");
    combo.addItem(1);
    combo.select(1);
    combo.setItemCaption(1, "en-US");
    combo.addItem(2);
    combo.setItemCaption(2, "en-UK");
    combo.addItem(3);
    combo.setItemCaption(3, "fr");
    comboLang = combo;
    comboLang.setRequired(true);
    arrLAllFormFields.add(combo);
    arrLAllEditableFields.add(combo);
    arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString());
    cBasic.addComponent(combo);

    tF = new TextField("Occupation");
    tF.setValue("Software Engineer");
    tFOcc = tF;
    tFOcc.setRequired(true);
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    cBasic.addComponent(tF);

    tF = new TextField("Employer");
    tF.setValue("Swifta");
    tFEmp = tF;
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    cBasic.addComponent(tF);

    PopupDateField dF = new PopupDateField("DoB");
    cal = Calendar.getInstance();
    cal.set(1988, 11, 12);
    dF.setValue(cal.getTime());
    dFDoB = dF;
    arrLAllFormFields.add(dF);
    arrLAllEditableFields.add(dF);
    arrLTfEditableVals.add(dF.getValue().toString());
    cBasic.addComponent(dF);

    combo = new ComboBox("Country");

    comboCountry = combo;
    comboCountry.setRequired(true);
    cBasic.addComponent(combo);

    combo = new ComboBox("State");
    comboState = combo;
    comboState.setRequired(true);
    comboState.setNullSelectionAllowed(false);
    arrLAllFormFields.add(combo);
    arrLAllEditableFields.add(combo);
    arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString());
    cBasic.addComponent(combo);

    combo = new ComboBox("Local Government");
    // combo.addItem(1);
    // combo.setItemCaption(1, "Ca. LG");
    // combo.select(1);
    comboLG = combo;
    comboLG.setRequired(true);
    arrLAllFormFields.add(combo);
    arrLAllEditableFields.add(combo);
    arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString());
    cBasic.addComponent(combo);

    /*
     * if (!(strUserType.equals("CCO") || strUserType.equals("BA"))) {
     * 
     * cBasic.addComponent(dF);
     * 
     * combo.addItem("Passport"); combo.addItem("Voter's Card");
     * combo.addItem("Driving License"); combo.addItem("National ID");
     * combo.addItem("Residential ID"); cBasic.addComponent(combo);
     * 
     * tF = new TextField("ID No."); cBasic.addComponent(tF);
     * 
     * combo = new ComboBox("State"); cBasic.addComponent(combo);
     * 
     * combo = new ComboBox("Country"); cBasic.addComponent(combo); }
     */

    VerticalLayout cC = new VerticalLayout();

    HorizontalLayout cBAndCAndAcc = new HorizontalLayout();
    cBAndCAndAcc.addComponent(cBasic);
    cBAndCAndAcc.addComponent(cC);

    VerticalLayout cCompany = new VerticalLayout();
    // Label lbC = new Label("Company");
    Label lbC = new Label("Identification");
    lbC.setStyleName("lb_frm_add_user");

    combo = new ComboBox("ID Type");

    combo.addItem("Passport Number");
    combo.addItem("National Registration Identification Number");
    combo.addItem("Drivers License Number");
    combo.addItem("Identification Card");
    combo.addItem("Employer Identification Number");
    combo.select("Passport Number");
    comboIDType = combo;
    comboIDType.setRequired(true);

    arrLAllFormFields.add(combo);
    arrLAllEditableFields.add(combo);
    arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString());
    cCompany.addComponent(combo);

    tF = new TextField("ID No.");
    tF.setValue("001");
    tFIDNo = tF;
    tFIDNo.setRequired(true);
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    cCompany.addComponent(tF);

    tF = new TextField("Issuer");
    tFIssuer = tF;
    tFIssuer.setValue("Republic of Uganda");
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    cCompany.addComponent(tF);

    dF = new PopupDateField("Issue Date");
    // cal = Calendar.getInstance();
    cal.set(12, 12, 12);
    dF.setValue(cal.getTime());
    dFDoI = dF;
    arrLAllFormFields.add(dF);
    arrLAllEditableFields.add(dF);
    arrLTfEditableVals.add(dF.getValue().toString());
    cCompany.addComponent(dF);

    dF = new PopupDateField("Expiry Date");
    // cal = Calendar.getInstance();
    cal.set(14, 12, 12);
    dF.setValue(cal.getTime());
    dF.setValue(cal.getTime());
    dFDoE = dF;
    dFDoE.setRequired(true);
    dFDoE.setImmediate(true);
    arrLAllFormFields.add(dF);
    arrLAllEditableFields.add(dF);
    arrLTfEditableVals.add(dF.getValue().toString());
    cCompany.addComponent(dF);

    cC.addComponent(cCompany);

    VerticalLayout pC = new VerticalLayout();
    lbC = new Label("Primary Contacts");
    HorizontalLayout cLbc = new HorizontalLayout();
    cLbc.setSizeUndefined();
    cLbc.setMargin(new MarginInfo(true, false, false, false));
    cLbc.addComponent(lbC);
    pC.addComponent(cLbc);

    tF = new TextField("Mobile Phone No.");
    tF.setValue("+256704191152");
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    tFPMNo = tF;

    pC.addComponent(tF);

    tF = new TextField("Alt. Phone No.");
    tF.setValue("+1704191152");
    tFPANo = tF;
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    pC.addComponent(tF);

    tF = new TextField("Email Address");
    tF.setValue("pwndz172@gmail.com");
    tFPEmail = tF;
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    pC.addComponent(tF);
    cC.addComponent(pC);

    VerticalLayout sC = new VerticalLayout();
    lbC = new Label("Secondary Contacts");
    cLbc = new HorizontalLayout();
    cLbc.setSizeUndefined();
    cLbc.setMargin(new MarginInfo(true, false, false, false));
    cLbc.addComponent(lbC);
    sC.addComponent(cLbc);

    tF = new TextField("Mobile Phone No.");
    tF.setValue("+256804191152");
    tFSMNo = tF;
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    sC.addComponent(tF);

    tF = new TextField("Alt. Phone No.");
    tF.setValue("+1804191152");
    tFSANo = tF;
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    sC.addComponent(tF);

    tF = new TextField("E-mail Address");
    tF.setValue("pkigozi@swifta.com");
    tFSEmail = tF;
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    sC.addComponent(tF);

    cC.addComponent(sC);

    VerticalLayout physicalC = new VerticalLayout();
    lbC = new Label("Physical Address");
    cLbc = new HorizontalLayout();
    cLbc.setSizeUndefined();
    cLbc.setMargin(new MarginInfo(true, false, false, false));
    cLbc.addComponent(lbC);
    physicalC.addComponent(cLbc);

    tF = new TextField("Street");
    tF.setValue("Yusuf Lule Rd.");
    tFStreet = tF;
    tFStreet.setRequired(true);
    physicalC.addComponent(tF);

    tF = new TextField("Postal Code");
    tF.setValue("23");
    tFPostalCode = tF;
    physicalC.addComponent(tF);

    tF = new TextField("City");
    tF.setValue("Kampala");
    tFCity = tF;
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    tFCity.setRequired(true);
    physicalC.addComponent(tF);

    tF = new TextField("Province");
    tF.setValue("Central");
    tFProv = tF;
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    physicalC.addComponent(tF);

    cC.addComponent(physicalC);

    /*
     * || strUserType.equals("BA"))) { tF = new TextField("Fax");
     * cC.addComponent(tF); // strAccTypeCaption = Hierarch }
     */

    /*
     * tF = new TextField("E-mail Address"); cC.addComponent(tF);
     * 
     * tF = new TextField("Physical Address"); cC.addComponent(tF);
     */

    VerticalLayout cAcc = new VerticalLayout();
    Label lbAcc = new Label("Account");
    lbAcc.setStyleName("lb_frm_add_user");
    cAcc.addComponent(lbAcc);
    ComboBox comboHierarchy = null;

    comboHierarchy = new ComboBox("Profile");

    Set<Entry<Integer, String>> set = profToID.entrySet();
    for (Entry<Integer, String> e : set) {
        comboHierarchy.addItem(e.getKey());
        comboHierarchy.setItemCaption(e.getKey(), e.getValue());
    }

    comboHierarchy.select(1);
    comboProfile = comboHierarchy;
    comboProfile.setRequired(true);
    arrLAllFormFields.add(comboProfile);
    arrLAllEditableFields.add(comboProfile);
    arrLTfEditableVals.add((comboProfile.getValue() == null) ? "" : comboProfile.getValue().toString());
    cAcc.addComponent(comboHierarchy);

    final VerticalLayout cLBody = new VerticalLayout();

    tF = new TextField("Username");
    tF.setValue("Livepwndz");
    tFUN = tF;
    tFUN.setRequired(true);
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    cLBody.addComponent(tF);

    tF = new TextField("MSISDN");
    tF.setValue("+256774191152");
    tFMSISDN = tF;
    tFMSISDN.setRequired(true);
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    cLBody.addComponent(tF);

    // / tF = new TextField("PIN");
    // / cLBody.addComponent(tF);

    tF = new TextField("Email");
    tFAccEmail = tF;
    tFAccEmail.setRequired(true);
    tFAccEmail.setValue("ppounds1@gmail.com");
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    cLBody.addComponent(tF);

    combo = new ComboBox("Bank Domain");
    combo.addItem("Stanbic Bank");
    combo.select("Stanbic Bank");
    comboBDomain = combo;
    arrLAllFormFields.add(combo);
    arrLAllEditableFields.add(combo);
    arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString());
    cLBody.addComponent(combo);

    combo = new ComboBox("Bank Code ID");
    combo.addItem("001");
    combo.select("001");
    comboBID = combo;
    arrLAllFormFields.add(combo);
    arrLAllEditableFields.add(combo);
    arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString());
    cLBody.addComponent(combo);

    tF = new TextField("Bank Account");
    tF.setValue("00232333452315");
    tFBAcc = tF;

    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    // tFBAcc.setValidationVisible(true);
    // tFBAcc.addValidator(new NoNull());
    cLBody.addComponent(tF);

    combo.addItem(1);
    combo.setItemCaption(1, "US Dollars");
    combo.select(1);
    comboCur = combo;
    arrLAllFormFields.add(combo);
    arrLAllEditableFields.add(combo);
    arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString());
    cLBody.addComponent(combo);

    tF = new TextField("Clearing Number");
    tF.setValue("00212");
    tFClrNo = tF;
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    cLBody.addComponent(tF);

    Label lbAccRec = new Label("Account Recovery");

    HorizontalLayout cLbAccRec = new HorizontalLayout();
    cLbAccRec.setSizeUndefined();
    cLbAccRec.setMargin(new MarginInfo(true, false, false, false));
    cLbAccRec.addComponent(lbAccRec);
    // cLBody.addComponent(cLbAccRec);

    combo = new ComboBox("Security Question");
    combo.addItem(1);
    combo.addItem(2);
    combo.addItem(3);
    combo.setItemCaption(1, "What is your grandfather's last name?");
    combo.setItemCaption(2, "What was your favorite junior school teacher's name?");
    combo.setItemCaption(3, "What was one of your nicknames in school?");
    combo.select(2);
    comboSecQn = combo;
    arrLAllFormFields.add(combo);
    arrLAllEditableFields.add(combo);
    arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString());
    // cLBody.addComponent(combo);

    tF = new TextField("Answer");
    tF.setValue("Mrs. X");
    tFSecAns = tF;
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    // cLBody.addComponent(tF);

    CheckBox chk = new CheckBox("I accept the terms" + " and conditons.");
    chcTAndC = chk;
    chk.setStyleName("check_t_and_c");
    chk.addValueChangeListener(new ValueChangeListener() {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            // Notification.show(event.getProperty().getValue().toString());

        }

    });

    comboCountry.addFocusListener(new FocusListener() {

        private static final long serialVersionUID = -5162384967736354225L;

        @Override
        public void focus(FocusEvent event) {
            if (isCSelected)
                return;
            Set<Entry<Integer, String>> es = (Set<Entry<Integer, String>>) getCountries().entrySet();
            if (es.size() == 0)
                return;
            Iterator<Entry<Integer, String>> itr = es.iterator();
            comboCountry.setNullSelectionAllowed(false);
            while (itr.hasNext()) {
                Entry<Integer, String> e = (Entry<Integer, String>) itr.next();
                comboCountry.addItem(e.getKey());
                comboCountry.setItemCaption(e.getKey(), e.getValue());
            }

            comboCountry.select(null);

            isCSelected = true;

        }

    });

    comboCountry.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -404551290095133508L;

        @Override
        public void valueChange(ValueChangeEvent event) {

            comboState.removeAllItems();
            comboLG.removeAllItems();

            if (comboCountry.getValue() == null)
                return;

            Set<Entry<Integer, String>> es = (Set<Entry<Integer, String>>) getStates(
                    Integer.valueOf(comboCountry.getValue().toString())).entrySet();

            if (es.isEmpty()) {
                return;
            }

            Iterator<Entry<Integer, String>> itr = es.iterator();
            while (itr.hasNext()) {
                Entry<Integer, String> e = itr.next();
                comboState.addItem(e.getKey());
                comboState.setItemCaption(e.getKey(), e.getValue());
            }

            comboState.select(null);

        }

    });

    comboState.addFocusListener(new FocusListener() {

        private static final long serialVersionUID = 892516817835461278L;

        @Override
        public void focus(FocusEvent event) {
            Object c = comboCountry.getValue();

            if (c == null) {
                Notification.show("Please select country first", Notification.Type.WARNING_MESSAGE);
                comboCountry.focus();
                return;

            }

        }

    });

    comboState.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 8849241310354979908L;

        @Override
        public void valueChange(ValueChangeEvent event) {

            comboLG.removeAllItems();
            if (comboState.getValue() == null)
                return;
            Set<Entry<Integer, String>> esl = (Set<Entry<Integer, String>>) getLGs(
                    Integer.valueOf(comboState.getValue().toString())).entrySet();
            if (esl.isEmpty()) {
                return;
            }

            Iterator<Entry<Integer, String>> itrl = esl.iterator();
            while (itrl.hasNext()) {
                Entry<Integer, String> e = itrl.next();
                comboLG.addItem(e.getKey());
                comboLG.setItemCaption(e.getKey(), e.getValue());
            }

        }

    });

    comboLG.addFocusListener(new FocusListener() {

        private static final long serialVersionUID = 8925916817835461278L;

        @Override
        public void focus(FocusEvent event) {

            Object s = comboState.getValue();
            if (comboCountry.getValue() == null) {
                Notification.show("Please select country first", Notification.Type.WARNING_MESSAGE);
                comboCountry.focus();
                return;

            }

            if (s == null) {
                Notification.show("Please select state first", Notification.Type.WARNING_MESSAGE);
                comboState.focus();
                return;

            }

        }

    });

    HorizontalLayout cChk = new HorizontalLayout();
    cChk.setSizeUndefined();
    cChk.setMargin(new MarginInfo(true, false, true, false));
    cChk.addComponent(chk);
    // cLBody.addComponent(cChk);

    final VerticalLayout cRBody = new VerticalLayout();
    String strNameCap = "Username";

    tF = new TextField(strNameCap);
    arrLAllFormFields.add(tF);
    arrLAllEditableFields.add(tF);
    arrLTfEditableVals.add(tF.getValue());
    cRBody.addComponent(tF);

    HorizontalLayout cAccBody = new HorizontalLayout();
    cAccBody.addComponent(cLBody);
    cAccBody.addComponent(cRBody);
    cLBody.setStyleName("c_body_visible");
    cRBody.setStyleName("c_body_invisible");
    cAcc.addComponent(cAccBody);

    cBAndCAndAcc.addComponent(cAcc);

    cC.setMargin(new MarginInfo(false, true, false, true));
    cAgentInfo.addComponent(cBAndCAndAcc);

    final String btnSaveId = "save";
    final String btnEditId = "edit";

    final Button btnEdit = new Button();
    btnEdit.setIcon(FontAwesome.SAVE);
    btnEdit.setId(btnSaveId);
    btnEdit.setStyleName("btn_link");

    final Button btnCancel = new Button();
    btnCancel.setVisible(true);
    btnCancel.setIcon(FontAwesome.UNDO);
    btnCancel.setStyleName("btn_link");

    final HorizontalLayout cBtnSR = new HorizontalLayout();
    cBtnSR.addComponent(btnEdit);
    cBtnSR.addComponent(btnCancel);

    // cBtnEditCancel

    cAcc.addComponent(cBtnSR);

    btnEdit.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = -935880570210949227L;

        @Override
        public void buttonClick(ClickEvent event) {

            /*
             * Prepare all Editable fields (Entire form) for editing.
             */
            if (event.getButton().getId().equals(btnEditId)) {

                /*
                 * By Default, btnCancel is not visible, until btnEdit is
                 * clicked. Only until then is it added and visible.
                 */

                if (!btnCancel.isVisible()) {
                    event.getButton().setId(btnSaveId);
                    event.getButton().setIcon(FontAwesome.SAVE);
                    btnCancel.setVisible(true);
                    cBtnSR.addComponent(btnCancel);
                }

                enableEditableFormFields(arrLAllEditableFields);

            } else {
                if (event.getButton().getId().equals(btnSaveId)) {
                    /*
                     * 
                     * 
                     * 
                     * 
                     * commit (save) changes i.e, send changes back to the
                     * server.
                     */

                    try {

                        validateAndSave();
                        // cUPersonalDetails.removeAllComponents();
                        // cUPersonalDetails.addComponent(getUDContainer());
                        // Notification.show("Details successfully saved.",
                        // Notification.Type.WARNING_MESSAGE);

                    } catch (Exception e) {
                        // Notification.show("Hello");
                        return;
                    }

                    // Remove undo button (btnCancel)
                    btnCancel.setVisible(false);

                    // Reset all Editable fields to readOnly after saving to
                    // the server
                    // disableEditableFields(arrLAllEditableFields);

                    // Reset btnEdit id to btnIdEdit and caption(icon) to
                    // FontAwesome.EDIT
                    btnEdit.setId(btnEditId);
                    btnEdit.setIcon(FontAwesome.EDIT);
                    btnEdit.setVisible(false);

                    // Reset Edit status to false
                    uDetailsEditStatus = false;

                }
            }

        }
    });

    btnCancel.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = -8179030387969880920L;

        @Override
        public void buttonClick(ClickEvent event) {
            resetForm(arrLAllEditableFields, arrLTfEditableVals);
            btnEdit.setId(btnEditId);
            btnEdit.setIcon(FontAwesome.EDIT);
            btnEdit.setVisible(false);
            btnCancel.setVisible(false);

        }
    });

    return cAgentInfo;
}

From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java

private void addLinkUserContainer() {

    VerticalLayout cDeletePrompt = new VerticalLayout();
    cPlaceholder.addComponent(cDeletePrompt);
    cPlaceholder.setComponentAlignment(cDeletePrompt, Alignment.MIDDLE_CENTER);
    // cDeletePrompt.setWidth("100%");
    cDeletePrompt.setStyleName("c_link");
    cDeletePrompt.setSpacing(true);//from   www.ja v a  2s.  c  o m
    String username = curUser;

    Label lbActivationPrompt = new Label(
            "<span style='text-align: center;'>Please enter Child Username to link to " + username
                    + "'s Account</span>");
    lbActivationPrompt.setContentMode(ContentMode.HTML);
    lbActivationPrompt.setWidth("300px");
    lbActivationPrompt.setStyleName("lb_link_user");

    cDeletePrompt.addComponent(lbActivationPrompt);
    cDeletePrompt.setComponentAlignment(lbActivationPrompt, Alignment.TOP_LEFT);

    VerticalLayout frmDeleteReason = new VerticalLayout();
    frmDeleteReason.setSizeUndefined();
    frmDeleteReason.setSpacing(true);
    frmDeleteReason.setMargin(true);
    cDeletePrompt.addComponent(frmDeleteReason);
    cDeletePrompt.setComponentAlignment(frmDeleteReason, Alignment.TOP_CENTER);

    tFU = new TextField("Child Username");
    tFU.setRequired(true);

    final ComboBox comboUProf = new ComboBox("Select Profile");
    comboUProf.setNullSelectionAllowed(false);
    comboUProf.setRequired(true);
    comboUProf.addItem(8);
    comboUProf.setItemCaption(8, "DEPOSIT_ONLY");

    comboUProf.addItem(9);
    comboUProf.setItemCaption(9, "DEPOSIT_AND_WITHDRAWAL");

    comboUProf.select(8);

    final TextField tFP = new TextField("Parent Account ID");
    tFP.setValue(username);
    tFP.setEnabled(false);

    final TextField tFInitUser = new TextField("Initiating User");
    tFInitUser.setValue(UI.getCurrent().getSession().getAttribute("user").toString());
    tFInitUser.focus();
    tFInitUser.setEnabled(false);

    frmDeleteReason.addComponent(tFU);
    frmDeleteReason.addComponent(comboUProf);
    frmDeleteReason.addComponent(tFP);
    frmDeleteReason.addComponent(tFInitUser);

    HorizontalLayout cPopupBtns = new HorizontalLayout();
    cPopupBtns.setSizeUndefined();
    cPopupBtns.setSpacing(true);

    final Button btnCancel = new Button();
    btnCancel.setIcon(FontAwesome.UNDO);
    btnCancel.setStyleName("btn_link");
    btnCancel.setDescription("Cancel");

    final Button btnSet = new Button("Link");
    btnSet.setDescription("Link specified account.");
    btnSet.setIcon(FontAwesome.LINK);
    cPopupBtns.addComponent(btnSet);
    cPopupBtns.addComponent(btnCancel);
    frmDeleteReason.addComponent(cPopupBtns);

    cDeletePrompt.setComponentAlignment(frmDeleteReason, Alignment.MIDDLE_CENTER);
    btnSet.setClickShortcut(KeyCode.ENTER, null);

    btnSet.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = -6318666715385643538L;

        @Override
        public void buttonClick(ClickEvent event) {

            tFU.validate();
            btnSet.setEnabled(false);
            btnCancel.setEnabled(false);

            Button btn = event.getButton();

            if (ums == null)
                ums = new UserManagementService();
            btn.setEnabled(false);

            String strResponse = null;
            try {

                strResponse = UserManagementService.linkUser(tFP.getValue(),
                        new Integer(comboUProf.getValue().toString()), tFInitUser.getValue(), tFU.getValue());

                if (strResponse.equals("The operation was successful and completed")) {

                    updateLinksTable(tFU.getValue());
                    cPlaceholder.setVisible(false);
                    tFU.setValue("");
                    btnLink.setVisible(true);

                    NotifCustom.show("Link", strResponse);

                } else {
                    NotifCustom.show("Link", strResponse);
                }

            } catch (RemoteException e) {

                e.printStackTrace();

            }

            btnSet.setEnabled(true);
            btnCancel.setEnabled(true);

        }
    });

    btnCancel.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 7161821652386306043L;

        @Override
        public void buttonClick(ClickEvent event) {
            btnLink.setVisible(true);
            cPlaceholder.setVisible(false);

        }

    });

}

From source file:com.terralcode.gestion.frontend.view.widgets.appointment.AppointmentView.java

private void buildAppointmentHeader() {
    //        Label section = new Label("Objetivo");
    //        section.addStyleName(ValoTheme.LABEL_H4);
    //        section.addStyleName(ValoTheme.LABEL_COLORED);
    //        rootLayout.addComponent(section);

    appointmentType = new OptionGroup("Tipo");
    appointmentType.setContainerDataSource(containerTypes);
    appointmentType.addStyleName("horizontal");
    appointmentType.setWidth("100%");
    //<editor-fold defaultstate="collapsed" desc="Enable customer and addresses combobox according to the selected appointment type">
    appointmentType.addValueChangeListener(new ValueChangeListener() {

        @Override//from   w  ww.j ava2s  .c om
        public void valueChange(Property.ValueChangeEvent event) {

            try {
                AppointmentType appType = (AppointmentType) event.getProperty().getValue();

                if (appType.getCode().equals("VIS")) {
                    //customer.setEnabled(true);
                    //address.setEnabled(true);
                    //contactNotes.setEnabled(false);

                    //contactNotes.setValue("");
                }
                if (appType.getCode().equals("COM")) {
                    //customer.setEnabled(true);
                    //address.setEnabled(false);
                    //contactNotes.setEnabled(false);

                    //address.setValue(null);
                    //contactNotes.setValue("");
                }
                if (appType.getCode().equals("CON")) {
                    //customer.setEnabled(false);
                    //address.setEnabled(false);
                    //contactNotes.setEnabled(true);

                    //customer.setValue(null);
                    //address.setValue(null);
                }
            } catch (Exception e) {
            }

        }

    });
    //</editor-fold>
    rootLayout.addComponent(appointmentType);

    reason = new ComboBox("Motivo");
    reason.setContainerDataSource(containerReasons);
    reason.setTextInputAllowed(false);
    reason.setWidth("100%");
    rootLayout.addComponent(reason);

    Label customerSection = new Label("Cliente");
    customerSection.addStyleName(ValoTheme.LABEL_H4);
    customerSection.addStyleName(ValoTheme.LABEL_COLORED);
    rootLayout.addComponent(customerSection);
    buildCustomer();
    buildAddress();
    buildContactInfo();

    contactNotes = new TextField("Otro");
    contactNotes.setWidth("100%");
    contactNotes.setInputPrompt("Introduzca contacto o direccin...");
    rootLayout.addComponent(contactNotes);

    Label scheduleSection = new Label("Programacin");
    scheduleSection.addStyleName(ValoTheme.LABEL_H4);
    scheduleSection.addStyleName(ValoTheme.LABEL_COLORED);
    rootLayout.addComponent(scheduleSection);

    startTime = new PopupDateField("Fecha");
    startTime.setTextFieldEnabled(false);
    startTime.setLocale(new Locale("es", "ES"));
    startTime.setResolution(Resolution.MINUTE);
    startTime.setDateFormat("dd/MM/yyyy HH:mm");
    startTime.setConverter(new DateToCalendarConverter());
    //startTime.setWidth(15, Unit.EM);
    rootLayout.addComponent(startTime);

    //        aqui los comerciales
    trades = new OptionGroup("Comerciales");
    trades.setContainerDataSource(containerTrades);
    trades.setConverter(new SetToListConverter());
    trades.setNullSelectionAllowed(false);
    trades.setMultiSelect(true);
    trades.setImmediate(true);
    rootLayout.addComponent(trades);

    //        // Los propositos de la visita
    //        purpose = new OptionGroup("Propsito");
    //        purpose.setContainerDataSource(containerPurpose);
    //        purpose.setConverter(new SetToListConverter());
    //        purpose.setNullSelectionAllowed(false);
    //        purpose.setMultiSelect(true);
    //        purpose.setImmediate(true);
    //        rootLayout.addComponent(purpose);

    //        HorizontalLayout wrapper = new HorizontalLayout();
    //        wrapper.setCaption("Fecha");
    //        wrapper.addComponent(startTime);
    //        wrapper.addComponent(timeLapse);
    //        //wrapper.setComponentAlignment(timeLapse, Alignment.TOP_LEFT);
    //        wrapper.setWidth("100%");
    //        wrapper.setExpandRatio(startTime, 1);
    //        wrapper.setExpandRatio(timeLapse, 1);
    //        rootLayout.addComponent(wrapper);
    //        contactInfo = new ComboBox();
    //        contactInfo.setTextInputAllowed(false);
    //        contactInfo.setInputPrompt("Seleccione un contacto...");
    //        contactInfo.setWidth("100%");
    //        rootLayout.addComponent(contactInfo);

    //        reasonNotes = new TextArea("Notas previas");
    //        reasonNotes.setWidth("100%");
    //        reasonNotes.setInputPrompt("Anotaciones del motivo...");
    //        rootLayout.addComponent(reasonNotes);

}

From source file:com.terralcode.gestion.frontend.view.widgets.appointment.AppointmentView.java

private void buildAppointmentContent() {
    Label section = new Label("Resultado");
    section.addStyleName(ValoTheme.LABEL_H4);
    section.addStyleName(ValoTheme.LABEL_COLORED);
    rootLayout.addComponent(section);/*from w w w  . ja v a  2s  . c om*/

    //Duracin de la cita
    timeLapse = new ComboBox("Duracin");
    timeLapse.setContainerDataSource(containerTimeLapses);
    timeLapse.setTextInputAllowed(false);
    timeLapse.setInputPrompt("Duracin...");
    rootLayout.addComponent(timeLapse);

    //Kilometraje
    distance = new TextField("Kms");
    distance.setNullRepresentation("");
    rootLayout.addComponent(distance);

    //Notas
    notes = new TextArea("Resumen");
    //notes.setSizeFull();
    notes.setInputPrompt("Introduzca notas...");
    rootLayout.addComponent(notes);

    // Los resultados de la visita
    purposes = new OptionGroup("Resultados");
    purposes.setContainerDataSource(containerPurposes);
    purposes.setConverter(new SetToListConverter());
    purposes.setNullSelectionAllowed(true);
    purposes.setMultiSelect(true);
    purposes.setImmediate(true);
    rootLayout.addComponent(purposes);

    //Quejas registradas
    buildAppointmentComplaints();
}