Example usage for com.vaadin.ui HorizontalLayout setStyleName

List of usage examples for com.vaadin.ui HorizontalLayout setStyleName

Introduction

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

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

From source file:com.skysql.manager.ui.WarningWindow.java

License:Open Source License

/**
 * Instantiates a new warning window./*from  w ww.  j a v  a2  s . co m*/
 *
 * @param caption the caption
 * @param message the message
 * @param label the label
 * @param okListener the ok listener
 */
public WarningWindow(String caption, String message, String label, Button.ClickListener okListener) {
    super(caption, "60%");

    HorizontalLayout wrapper = new HorizontalLayout();
    wrapper.setWidth("100%");
    wrapper.setMargin(true);
    VerticalLayout iconLayout = new VerticalLayout();
    iconLayout.setWidth("100px");
    wrapper.addComponent(iconLayout);
    Embedded image = new Embedded(null, new ThemeResource("img/warning.png"));
    iconLayout.addComponent(image);
    VerticalLayout textLayout = new VerticalLayout();
    textLayout.setSizeFull();
    wrapper.addComponent(textLayout);
    wrapper.setExpandRatio(textLayout, 1.0f);

    Label msgLabel = new Label(message);
    msgLabel.addStyleName("warning");
    textLayout.addComponent(msgLabel);
    textLayout.setComponentAlignment(msgLabel, Alignment.MIDDLE_CENTER);

    HorizontalLayout buttonsBar = new HorizontalLayout();
    buttonsBar.setStyleName("buttonsBar");
    buttonsBar.setSizeFull();
    buttonsBar.setSpacing(true);
    buttonsBar.setMargin(true);
    buttonsBar.setHeight("49px");

    Label filler = new Label();
    buttonsBar.addComponent(filler);
    buttonsBar.setExpandRatio(filler, 1.0f);

    Button cancelButton = new Button("Cancel");
    buttonsBar.addComponent(cancelButton);
    buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT);

    cancelButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(Button.ClickEvent event) {
            warningWindow.close();
        }
    });

    Button okButton = new Button(label);
    okButton.addClickListener(okListener);
    buttonsBar.addComponent(okButton);
    buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT);

    VerticalLayout windowLayout = (VerticalLayout) this.getContent();
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);
    windowLayout.addComponent(wrapper);
    windowLayout.addComponent(buttonsBar);

}

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  www .  ja  va  2s.c  om

    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 getManageUserMenu() {

    VerticalLayout cManageUserMenu = new VerticalLayout();
    cManageUserMenu.setStyleName("c_u_manage_menu");
    cManageUserMenu.setSizeUndefined();/*  w  ww.j a v  a2  s .c om*/

    HorizontalLayout cManageAndAddTab = new HorizontalLayout();

    final BtnTabLike btnPersonal = new BtnTabLike("Basic", null);
    btnPersonal.setStyleName("btn_tab_like btn_tab_like_active");
    btnPersonal.setEnabled(false);

    final BtnTabLike btnLinks = new BtnTabLike("Manage Downlines", null);

    final BtnTabLike btnProfile = new BtnTabLike("User Profile", null);

    final BtnTabLike btnAccount = new BtnTabLike("Account", null);
    // BtnTabLike btnAuth = new BtnTabLike("Authentication", null);
    final BtnTabLike btnLog = new BtnTabLike("Log", null);
    cManageAndAddTab.addComponent(btnPersonal);
    cManageAndAddTab.addComponent(btnAccount);
    if (xcontainer.getItem(xrid).getItemProperty("Profile Type").getValue().toString()
            .equals("MATS_DEALER_USER_PROFILE"))
        cManageAndAddTab.addComponent(btnLinks);

    cManageAndAddTab.addComponent(btnProfile);

    // cManageAndAddTab.addComponent(btnAuth);
    cManageAndAddTab.addComponent(btnLog);

    // arrLTabBtns.add(btnAuth);

    btnPersonal.setEnabled(false);

    ArrayList<HorizontalLayout> arrLSubTabs = new ArrayList<HorizontalLayout>();

    final HorizontalLayout cManUserSubMenu = getAddUserSubMenu(btnLog, btnPersonal, btnAccount, btnLinks,
            btnProfile);

    arrLSubTabs.add(cManUserSubMenu);

    cManageUserMenu.addComponent(cManageAndAddTab);
    cManageUserMenu.addComponent(cManUserSubMenu);

    btnPersonal.addClickListener(new Button.ClickListener() {

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

        @Override
        public void buttonClick(ClickEvent event) {

            btnPersonal.setEnabled(false);
            btnPersonal.setStyleName("btn_tab_like btn_tab_like_active");

            if (!btnAccount.isEnabled())
                p = cA;
            if (!btnLinks.isEnabled())
                p = cL;

            if (!btnProfile.isEnabled())
                p = cProf;

            btnAccount.setEnabled(true);
            btnAccount.setStyleName("btn_tab_like");

            btnLinks.setEnabled(true);
            btnLinks.setStyleName("btn_tab_like");

            btnProfile.setEnabled(true);
            btnProfile.setStyleName("btn_tab_like");

            if (!isfromsub) {
                p = (HorizontalLayout) cPerAccAuthInfo.getComponent(0);
                cPerAccAuthInfo.replaceComponent(p, cP);
            } else {
                prevL = (HorizontalLayout) cPerAccAuthInfo.getComponent(0);
                cPerAccAuthInfo.replaceComponent(prevL, cP);

                btnLog.setEnabled(true);
                btnLog.setStyleName("btn_tab_like");
                cManUserSubMenu.setStyleName("c_sub_menu_invisible");
                isfromsub = false;
            }

            cpop.center();

        }
    });

    btnAccount.addClickListener(new Button.ClickListener() {

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

        @Override
        public void buttonClick(ClickEvent event) {

            btnAccount.setEnabled(false);
            btnAccount.setStyleName("btn_tab_like btn_tab_like_active");

            if (!btnPersonal.isEnabled())
                p = cP;
            if (!btnLinks.isEnabled())
                p = cL;

            if (!btnProfile.isEnabled())
                p = cProf;

            btnPersonal.setEnabled(true);
            btnPersonal.setStyleName("btn_tab_like");

            btnLinks.setEnabled(true);
            btnLinks.setStyleName("btn_tab_like");

            btnProfile.setEnabled(true);
            btnProfile.setStyleName("btn_tab_like");

            if (!isfromsub) {
                if (cA == null)
                    cA = getADC();
                p = (HorizontalLayout) cPerAccAuthInfo.getComponent(0);
                cPerAccAuthInfo.replaceComponent(p, cA);

            } else {
                if (cA == null)
                    cA = getADC();
                prevL = (HorizontalLayout) cPerAccAuthInfo.getComponent(0);
                cPerAccAuthInfo.replaceComponent(prevL, cA);

                isfromsub = false;
                btnLog.setEnabled(true);
                btnLog.setStyleName("btn_tab_like");
                cManUserSubMenu.setStyleName("c_sub_menu_invisible");

            }

            cpop.center();

        }
    });

    btnLinks.addClickListener(new Button.ClickListener() {

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

        @Override
        public void buttonClick(ClickEvent event) {
            btnLinks.setEnabled(false);
            btnLinks.setStyleName("btn_tab_like btn_tab_like_active");

            if (!btnPersonal.isEnabled())
                p = cP;
            if (!btnAccount.isEnabled())
                p = cA;
            if (!btnProfile.isEnabled())
                p = cProf;

            btnPersonal.setEnabled(true);
            btnPersonal.setStyleName("btn_tab_like");

            btnAccount.setEnabled(true);
            btnAccount.setStyleName("btn_tab_like");

            btnProfile.setEnabled(true);
            btnProfile.setStyleName("btn_tab_like");

            if (!isfromsub) {
                if (cL == null)
                    cL = getLC();

                p = (HorizontalLayout) cPerAccAuthInfo.getComponent(0);
                cPerAccAuthInfo.replaceComponent(p, cL);

            } else {
                if (cL == null)
                    cL = getLC();
                prevL = (HorizontalLayout) cPerAccAuthInfo.getComponent(0);
                cPerAccAuthInfo.replaceComponent(prevL, cL);

                isfromsub = false;
                btnLog.setEnabled(true);
                btnLog.setStyleName("btn_tab_like");
                cManUserSubMenu.setStyleName("c_sub_menu_invisible");

            }

            cpop.center();

        }
    });

    btnProfile.addClickListener(new Button.ClickListener() {

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

        @Override
        public void buttonClick(ClickEvent event) {
            btnProfile.setEnabled(false);
            btnProfile.setStyleName("btn_tab_like btn_tab_like_active");

            if (!btnPersonal.isEnabled())
                p = cP;
            if (!btnAccount.isEnabled())
                p = cA;
            if (!btnLinks.isEnabled())
                p = cL;
            if (btnProfile.isEnabled()) {
                return;
            }

            btnPersonal.setEnabled(true);
            btnPersonal.setStyleName("btn_tab_like");

            btnAccount.setEnabled(true);
            btnAccount.setStyleName("btn_tab_like");

            btnLinks.setEnabled(true);
            btnLinks.setStyleName("btn_tab_like");

            if (!isfromsub) {
                if (cProf == null)
                    cProf = getPC();

                p = (HorizontalLayout) cPerAccAuthInfo.getComponent(0);
                cPerAccAuthInfo.replaceComponent(p, cProf);

            } else {
                if (cProf == null)
                    cProf = getPC();
                prevL = (HorizontalLayout) cPerAccAuthInfo.getComponent(0);
                cPerAccAuthInfo.replaceComponent(prevL, cProf);

                isfromsub = false;
                btnLog.setEnabled(true);
                btnLog.setStyleName("btn_tab_like");
                cManUserSubMenu.setStyleName("c_sub_menu_invisible");

            }

            cpop.center();

        }
    });

    cManUserSubMenu.setSizeUndefined();

    return cManageUserMenu;

}

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

private HorizontalLayout getAddUserSubMenu(final BtnTabLike btnAddUser, final BtnTabLike btnPersonal,
        final BtnTabLike btnAccount, final BtnTabLike btnLinks, final BtnTabLike btnProfile) {
    final HorizontalLayout cAddUserSubMenu = new HorizontalLayout();
    cAddUserSubMenu.setStyleName("c_sub_menu_invisible");
    cAddUserSubMenu.setSizeUndefined();//from  w w  w  .ja  v a 2 s  .  c  o m

    final BtnTabLike btnAct = new BtnTabLike("Account Activity Log", null);

    final BtnTabLike btnAcc = new BtnTabLike("Account Change Log", null);

    btnAct.setStyleName("btn_tab_like btn_tab_like_active");
    btnAct.setEnabled(false);

    cAddUserSubMenu.addComponent(btnAct);
    cAddUserSubMenu.addComponent(btnAcc);

    btnAddUser.addClickListener(new Button.ClickListener() {

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

        @Override
        public void buttonClick(ClickEvent event) {
            cAddUserSubMenu.setStyleName("c_sub_menu_visible");
            isfromsub = true;
            btnAddUser.setEnabled(false);
            btnAddUser.setStyleName("btn_tab_like btn_tab_like_active");

            HorizontalLayout p = (HorizontalLayout) cPerAccAuthInfo.getComponent(0);

            if (!btnPersonal.isEnabled()) {
                btnPersonal.setEnabled(true);
                btnPersonal.setStyleName("btn_tab_like");

                cP = p;
                if (cLP == null && prevL == null) {
                    btnAct.setEnabled(false);
                    btnAct.setStyleName("btn_tab_like btn_tab_like_active");

                    btnAcc.setEnabled(true);
                    btnAcc.setStyleName("btn_tab_like");

                    cLP = getAccLog();
                    cPerAccAuthInfo.replaceComponent(p, cLP);
                } else {
                    cPerAccAuthInfo.replaceComponent(p, prevL);
                }

            } else if (!btnAccount.isEnabled()) {

                btnAccount.setEnabled(true);
                btnAccount.setStyleName("btn_tab_like");
                cA = p;
                if (cLP == null && prevL == null) {
                    btnAct.setEnabled(false);
                    btnAct.setStyleName("btn_tab_like btn_tab_like_active");

                    btnAcc.setEnabled(true);
                    btnAcc.setStyleName("btn_tab_like");

                    cLP = getActLog();
                    cPerAccAuthInfo.replaceComponent(p, cLP);
                } else {
                    cPerAccAuthInfo.replaceComponent(p, prevL);
                }

            } else if (!btnLinks.isEnabled()) {

                btnLinks.setEnabled(true);
                btnLinks.setStyleName("btn_tab_like");
                cL = p;
                if (cLP == null && prevL == null) {
                    btnAct.setEnabled(false);
                    btnAct.setStyleName("btn_tab_like btn_tab_like_active");

                    btnAcc.setEnabled(true);
                    btnAcc.setStyleName("btn_tab_like");

                    cLP = getActLog();
                    cPerAccAuthInfo.replaceComponent(p, cLP);
                } else {
                    cPerAccAuthInfo.replaceComponent(p, prevL);
                }

            } else if (!btnProfile.isEnabled()) {

                btnProfile.setEnabled(true);
                btnProfile.setStyleName("btn_tab_like");
                cProf = p;
                if (cLP == null && prevL == null) {
                    btnAct.setEnabled(false);
                    btnAct.setStyleName("btn_tab_like btn_tab_like_active");

                    btnAcc.setEnabled(true);
                    btnAcc.setStyleName("btn_tab_like");

                    cLP = getActLog();
                    cPerAccAuthInfo.replaceComponent(p, cLP);
                } else {
                    cPerAccAuthInfo.replaceComponent(p, prevL);
                }

            }

            cpop.center();

        }
    });

    btnAcc.addClickListener(new Button.ClickListener() {

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

        @Override
        public void buttonClick(ClickEvent event) {

            btnAcc.setEnabled(false);
            btnAcc.setStyleName("btn_tab_like btn_tab_like_active");

            btnAct.setEnabled(true);
            btnAct.setStyleName("btn_tab_like");

            cLA = (HorizontalLayout) cPerAccAuthInfo.getComponent(0);
            cPerAccAuthInfo.replaceComponent(cLA, cLP);

            cpop.center();

        }

    });

    btnAct.addClickListener(new Button.ClickListener() {

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

        @Override
        public void buttonClick(ClickEvent event) {

            btnAct.setEnabled(false);
            btnAct.setStyleName("btn_tab_like btn_tab_like_active");

            btnAcc.setEnabled(true);
            btnAcc.setStyleName("btn_tab_like");
            if (cLA == null)
                cLA = getActLog();

            cLP = (HorizontalLayout) cPerAccAuthInfo.getComponent(0);
            cPerAccAuthInfo.replaceComponent(cLP, cLA);

            cpop.center();

        }
    });

    return cAddUserSubMenu;
}

From source file:cz.zcu.pia.social.network.frontend.components.posts.ComponentPost.java

/**
 * Adds click listeners to the buttons//from   w ww  .j av a2s  .  co  m
 */
private void addClickListeners() {
    this.likes.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Post post = componentPostService.updateLikeRating(postId);
            numberOfLikes = post.getLikeCount();
            numberOfDisagrees = post.getHateCount();
            updateHateLike();

        }
    });
    this.disagrees.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Post post = componentPostService.updateDisagreeRating(postId);

            numberOfLikes = post.getLikeCount();
            numberOfDisagrees = post.getHateCount();
            updateHateLike();
        }
    });
    this.tags.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window subWindow = new Window(msgs.getMessage("post.tags"));

            subWindow.setModal(true);
            subWindow.center();
            subWindow.setWidth(400, Unit.PIXELS);
            subWindow.setHeight(110, Unit.PIXELS);
            subWindow.setResizable(false);
            Panel panel = new Panel();

            panel.setSizeFull();
            HorizontalLayout tagsWrapper = new HorizontalLayout();
            tagsWrapper.setStyleName("margin-left-big");
            panel.setContent(tagsWrapper);
            tagsWrapper.setSpacing(true);
            tagsWrapper.setMargin(true);
            tagsWrapper.setSizeUndefined();

            for (Tag t : postService.getPostTags(postId)) {
                CustomLayout tag = new CustomLayout("tag");
                Button tagLabel = new Button(t.getTagName());
                tag.addComponent(tagLabel, "button");

                tagsWrapper.addComponent(tag);
            }

            subWindow.setContent(panel);
            UI.getCurrent().addWindow(subWindow);
        }
    });
    this.comments.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window subWindow = new Window(msgs.getMessage("post.comments"));

            subWindow.setModal(true);
            subWindow.center();
            subWindow.setWidth(400, Unit.PIXELS);
            subWindow.setHeight(600, Unit.PIXELS);
            subWindow.setResizable(true);

            ComponentPostComments componentPostComments = applicationContext
                    .getBean(ComponentPostComments.class, postId);
            subWindow.setContent(componentPostComments);
            UI.getCurrent().addWindow(subWindow);
        }
    });
    this.name.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window subWindow = new Window(msgs.getMessage("header.profile") + "- " + name.getCaption());

            subWindow.setModal(true);
            subWindow.center();
            subWindow.setWidth(400, Unit.PIXELS);
            subWindow.setHeight(350, Unit.PIXELS);
            subWindow.setResizable(true);

            Users user = postService.getPostById(postId).getUser();
            ComponentProfilePost profilePost = applicationContext.getBean(ComponentProfilePost.class, user);

            subWindow.setContent(profilePost);
            UI.getCurrent().addWindow(subWindow);
        }
    });
}

From source file:de.gedoplan.webclients.vaadin.views.CustomerDetailView.java

public void init() {
    Double discount = customerService.calculateCustomerDiscount(customer.getCustomerID()).getDiscount();
    Label name = new Label(new PropertyFormatter(form.getProperty(Customer_.companyName)) {
        @Override//  w w  w.  j  a  v a  2s. co m
        public String format(Object value) {
            return value + " (" + customer.getCustomerID() + ")";
        }

        @Override
        public Object parse(String formattedValue) throws Exception {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    });
    name.setStyleName(ValoTheme.LABEL_BOLD);
    Label rabattLabel = new Label(Messages.customer_discount.value());
    rabattLabel.setStyleName(ValoTheme.LABEL_BOLD);
    rabattLabel.setSizeUndefined();
    Label rabatt = new Label(new DecimalFormat("#0.00").format(discount) + "%");
    rabatt.setSizeUndefined();
    rabatt.addStyleName(ValoTheme.LABEL_COLORED);
    rabatt.addStyleName(ValoTheme.LABEL_BOLD);
    HorizontalLayout headline = new HorizontalLayout(name, rabattLabel, rabatt);
    headline.setComponentAlignment(rabatt, Alignment.TOP_RIGHT);
    headline.setExpandRatio(name, 1);
    headline.setWidth(100, Unit.PERCENTAGE);
    headline.setSpacing(true);
    headline.setStyleName(ValoTheme.LAYOUT_WELL);
    headline.setMargin(new MMarginInfo(false, true));
    Panel panel = new Panel();
    panel.setContent(form);
    setMargin(true);
    setSpacing(true);
    addComponents(headline, panel);
}

From source file:de.kaiserpfalzEdv.vaadin.PiraccUI.java

License:Apache License

protected void showMainView() {
    HorizontalLayout screen = new HorizontalLayout();

    CssLayout viewContainer = new CssLayout();
    viewContainer.addStyleName("valo-content");
    viewContainer.setSizeFull();//from w w w  .  jav a2  s.  co  m

    screen.setStyleName("main-screen");
    screen.addComponent(menu);
    screen.addComponent(viewContainer);
    screen.setExpandRatio(viewContainer, 1);
    screen.setSizeFull();

    Navigator navigator = new Navigator(this, viewContainer);
    navigator.addProvider(viewProvider);

    addStyleName(ValoTheme.UI_WITH_MENU);
    setContent(screen);

    if (isNotBlank(getNavigator().getState())) {
        getNavigator().navigateTo(getNavigator().getState());
    }

    menu.generate();
}

From source file:ed.cracken.pos.ui.purchases.PurchaserView.java

/**
 * top bar includes product's code// w w w .j  a  v  a 2 s .co m
 *
 * @return
 */
public HorizontalLayout createTopBar() {

    productCode = new TextField();
    productCode.setStyleName("filter-textfield");
    productCode.setInputPrompt("Codigo Producto");
    productCode.setImmediate(true);
    productCode.addTextChangeListener((FieldEvents.TextChangeEvent event) -> {
        if (!event.getText().isEmpty()) {
            viewLogic.findAndAddProduct(event.getText());
        }
    });

    productName = new TextField();
    productPrice = new TextField();
    productQuantity = new TextField();

    addProductBtn = new Button("Buscar");
    addProductBtn.setIcon(FontAwesome.SEARCH);
    addProductBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    addProductBtn.setIcon(FontAwesome.PLUS_CIRCLE);
    addProductBtn.addClickListener((Button.ClickEvent event) -> {
        if (!productCode.getValue().isEmpty()) {
            viewLogic.findAndAddProduct(productCode.getValue());
        }
    });

    HorizontalLayout topLayout = new HorizontalLayout(productCode, addProductBtn);
    topLayout.setStyleName("top-bar");
    topLayout.setSpacing(true);
    return topLayout;
}

From source file:ed.cracken.pos.ui.seller.SellerView.java

/**
 * top bar includes product's code// ww w  .j  a v a  2  s. c o  m
 *
 * @return
 */
public HorizontalLayout createTopBar() {
    productCode = new TextField();
    productCode.setStyleName("filter-textfield");
    productCode.setInputPrompt("Codigo Producto");
    productCode.setImmediate(true);
    productCode.addTextChangeListener((FieldEvents.TextChangeEvent event) -> {
        if (!event.getText().isEmpty()) {
            viewLogic.findAndAddProduct(event.getText());
        }
    });

    addProductBtn = new Button("Buscar");
    addProductBtn.setIcon(FontAwesome.SEARCH);
    addProductBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    addProductBtn.setIcon(FontAwesome.PLUS_CIRCLE);
    addProductBtn.addClickListener((Button.ClickEvent event) -> {
        if (!productCode.getValue().isEmpty()) {
            viewLogic.findAndAddProduct(productCode.getValue());
        }
    });

    HorizontalLayout topLayout = new HorizontalLayout(productCode, addProductBtn);
    topLayout.setStyleName("top-bar");
    topLayout.setSpacing(true);
    return topLayout;
}

From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionDashboard.java

License:Open Source License

public void initGuiTL() {
    setSizeUndefined();//  w  ww .  j  a  va2 s.  com
    setWidth(APPLICATION_SCREEN_WIDTH);
    //    setHeight("855px"); //ACTIONDASHBOARD_H);

    Label sp;
    addComponent(sp = new Label());
    sp.setHeight("10px");

    HorizontalLayout titleHL = new HorizontalLayout();
    titleHL.setWidth("95%");
    addComponent(titleHL);

    titleHL.addComponent(sp = new Label());
    sp.setWidth("20px");
    Component titleC;
    titleHL.addComponent(titleC = Mmowgli2UI.getGlobals().getMediaLocator().getActionDashboardTitle());
    titleHL.setComponentAlignment(titleC, Alignment.MIDDLE_LEFT);

    titleHL.addComponent(sp = new Label());
    sp.setWidth("1px");
    titleHL.setExpandRatio(sp, 1.0f);

    titleHL.addComponent(howToWinActionButt);
    howToWinActionButt.setDescription(howWinAction_tt);

    AbsoluteLayout absL = new AbsoluteLayout();
    addComponent(absL);

    absL.setWidth(APPLICATION_SCREEN_WIDTH);
    absL.setHeight(ACTIONDASHBOARD_H);

    MediaLocator medLoc = Mmowgli2UI.getGlobals().getMediaLocator();

    AbsoluteLayout mainAbsLay = new AbsoluteLayout(); // offset it from master
    mainAbsLay.setWidth(APPLICATION_SCREEN_WIDTH);
    mainAbsLay.setHeight(ACTIONDASHBOARD_H);
    absL.addComponent(mainAbsLay, ACTIONDASHBOARD_OFFSET_POS);

    // Now the background     
    Embedded backgroundImage = new Embedded(null, medLoc.getActionDashboardPlanBackground());
    backgroundImage.setWidth(ACTIONDASHBOARD_W);
    backgroundImage.setHeight(ACTIONDASHBOARD_H);
    mainAbsLay.addComponent(backgroundImage, "top:0px;left:0px");

    HorizontalLayout tabsHL = new HorizontalLayout();
    tabsHL.setStyleName("m-actionDashboardBlackTabs");
    tabsHL.setSpacing(false);

    tabsHL.addComponent(sp = new Label());
    sp.setWidth("12px");

    TabClickHandler tabHndlr = new TabClickHandler();
    actionPlansTabButt.setStyleName("m-actionDashboardActionPlansTab");
    actionPlansTabButt.addClickListener(tabHndlr);
    actionPlansTabButt.setId(ACTION_DASHBOARD_ACTION_PLANS_TAB);
    tabsHL.addComponent(actionPlansTabButt);

    tabsHL.addComponent(sp = new Label());
    sp.setWidth("1px");

    myPlansTabButt.setStyleName("m-actionDashboardMyPlansTab");
    myPlansTabButt.addClickListener(tabHndlr);
    myPlansTabButt.setId(ACTION_DASHBOARD_MY_ACTION_PLANS_TAB);
    tabsHL.addComponent(myPlansTabButt);
    myPlansTabButt.addStyleName("m-transparent-background"); // initially

    tabsHL.addComponent(sp = new Label());
    sp.setWidth("1px");

    needAuthorsTabButt.setStyleName("m-actionDashboardNeedAuthorsTab");
    needAuthorsTabButt.addClickListener(tabHndlr);
    needAuthorsTabButt.setId(ACTION_DASHBOARD_NEED_AUTHORS_TAB);
    tabsHL.addComponent(needAuthorsTabButt);
    needAuthorsTabButt.addStyleName("m-transparent-background"); // initially

    absL.addComponent(tabsHL, "left:7px;top:8px");

    // stack the pages
    absL.addComponent(actionPlansTab, ACTIONDASHBOARD_TABCONTENT_POS);
    actionPlansTab.initGuiTL();

    absL.addComponent(myPlansTab, ACTIONDASHBOARD_TABCONTENT_POS);
    myPlansTab.initGuiTL();
    myPlansTab.setVisible(false);

    absL.addComponent(needAuthorsTab, ACTIONDASHBOARD_TABCONTENT_POS);
    needAuthorsTab.initGuiTL();
    needAuthorsTab.setVisible(false);

    User me = Mmowgli2UI.getGlobals().getUserTL();
    Set<ActionPlan> invitedSet = me.getActionPlansInvited();
    if (invitedSet != null && (invitedSet.size()) > 0) {
        Notification note = new Notification("<center>You're invited to an Action Plan!</center>",
                "<center> Look for the \"you're invited to join!\" notice.<br/>"
                        + "First, check out the plan.  Then, if you want to join,<br/>"
                        + "click the link to become an author." + "</center>",
                Type.HUMANIZED_MESSAGE, true); // allow html

        note.setPosition(Position.MIDDLE_CENTER);
        note.setDelayMsec(5000);// 5 secs
        note.show(Page.getCurrent());
    }
}