Example usage for com.vaadin.ui Button setId

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

Introduction

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

Prototype

@Override
    public void setId(String id) 

Source Link

Usage

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

private HorizontalLayout setDetailsForm(String strUID, String strAction) {
    cDetailsAndOperations = new HorizontalLayout();
    cDetailsAndOperations.setSizeUndefined();

    cUPersonalDetails = new FormLayout();
    cUPersonalDetails.setMargin(false);//from  w w  w .  j av a  2 s  . c  o  m
    cUPersonalDetails.setSpacing(false);
    cUPersonalDetails.setStyleName("frm_details_personal_info");
    cUPersonalDetails.setSizeUndefined();
    cDetailsAndOperations.addComponent(cUPersonalDetails);

    arrLAllFormFields = new ArrayList<Object>();

    final String btnEditId = "edit";
    arrLAllEditableFields = new ArrayList<Object>();
    arrLTfEditableVals = new ArrayList<String>();

    final Button btnEdit = new Button();
    btnEdit.setId(btnEditId);
    btnEdit.setIcon(FontAwesome.EDIT);
    btnEdit.setStyleName(ValoTheme.BUTTON_ICON_ONLY);
    btnEdit.setStyleName("btn_link");
    btnEdit.setVisible(false);

    final Button btnCancel = new Button();
    btnCancel.setId(btnEditId);
    btnCancel.setIcon(FontAwesome.UNDO);
    btnCancel.setStyleName(ValoTheme.BUTTON_ICON_ONLY);
    btnCancel.setStyleName("btn_link");
    btnCancel.setVisible(false);

    cBtnEditCancel = new HorizontalLayout();
    cBtnEditCancel.setSizeUndefined();
    cBtnEditCancel.addComponent(btnEdit);

    setData(strUID, strAction);
    return cDetailsAndOperations;
}

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 w  w  . j  a  v  a  2s  .  c o  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

@SuppressWarnings("unchecked")
private void addLinksTable() {

    container.addContainerProperty("S/N", Integer.class, 0);
    container.addContainerProperty("Username", String.class, null);
    container.addContainerProperty("MSISDN", String.class, null);
    container.addContainerProperty("Email", String.class, null);
    container.addContainerProperty("Action", Button.class, null);

    StringBuilder sb = new StringBuilder();

    sb.append(/*from w w  w.ja v  a  2  s . c o m*/
            " SELECT concat(ahd.firstname,' ',ahd.lastname) as Name, ah.username as 'username', ah.msisdn as msisdn, ah.email as email ");
    sb.append(" FROM linkaccountrelations pl, accountholders ah, accountholderdetails ahd ");
    sb.append(" where linkstatus = 'LINKED' ");
    sb.append(" and ah.accountholderdetailid = ahd.accountdetailsid ");
    sb.append(" and pl.childuserresourceid = ah.accountholderid ");
    sb.append(" and parentuserresourceid in (select accountholderid from accountholders ");
    sb.append(" where (username = '" + curUser + "'))");

    String drivers = "com.mysql.jdbc.Driver";
    try {
        Class<?> driver_class = Class.forName(drivers);
        Driver driver = (Driver) driver_class.newInstance();
        DriverManager.registerDriver(driver);

        Connection conn = DriverManager.getConnection(MatsWebPortalUI.conf.DB, MatsWebPortalUI.conf.UN,
                MatsWebPortalUI.conf.PW);

        Statement stmt = conn.createStatement();

        ResultSet rs = stmt.executeQuery(sb.toString());

        int x = 0;
        Property<String> pUn;
        Property<String> pMsisdn;
        Property<String> pEmail;
        Property<Integer> pSn;
        Property<Button> pBtn;

        String un;
        String msisdn;
        String email;
        Object rid;
        Button btnLink;
        Item r;

        while (rs.next()) {

            x++;

            un = rs.getString("username");
            msisdn = rs.getString("msisdn");
            email = rs.getString("email");

            rid = container.addItem();
            r = container.getItem(rid);

            pSn = r.getItemProperty("S/N");
            pUn = r.getItemProperty("Username");
            pMsisdn = r.getItemProperty("MSISDN");
            pEmail = r.getItemProperty("Email");
            pBtn = r.getItemProperty("Action");
            btnLink = new Button();
            btnLink.setIcon(FontAwesome.UNLINK);
            btnLink.setStyleName("btn_link");
            btnLink.setDescription("Unlink this account.");
            btnLink.addClickListener(new UNLinkClickHandler());
            btnLink.setId(un);
            btnLink.setData(rid);

            pSn.setValue(x);
            pUn.setValue(un);
            pMsisdn.setValue(msisdn);
            pEmail.setValue(email);
            pBtn.setValue(btnLink);

        }

        tb.setContainerDataSource(container);
        if (x > 30)
            x = 30;
        tb.setPageLength(x);

    } catch (SQLException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {

        errorHandler(e);
    }

}

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

@SuppressWarnings("unchecked")
private void updateLinksTable(String un) {
    StringBuilder sb = new StringBuilder();

    sb.append(/* w  w w. java2 s  .c  o  m*/
            " SELECT concat(ahd.firstname,' ',ahd.lastname) as Name, ah.username as 'username', ah.msisdn as msisdn, ah.email as email ");
    sb.append(" FROM linkaccountrelations pl, accountholders ah, accountholderdetails ahd ");
    sb.append(" where linkstatus = 'LINKED' and username = '" + un + "'");
    sb.append(" and ah.accountholderdetailid = ahd.accountdetailsid ");
    sb.append(" and pl.childuserresourceid = ah.accountholderid");

    String drivers = "com.mysql.jdbc.Driver";
    try {
        Class<?> driver_class = Class.forName(drivers);
        Driver driver = (Driver) driver_class.newInstance();
        DriverManager.registerDriver(driver);

        Connection conn = DriverManager.getConnection(MatsWebPortalUI.conf.DB, MatsWebPortalUI.conf.UN,
                MatsWebPortalUI.conf.PW);

        Statement stmt = conn.createStatement();

        ResultSet rs = stmt.executeQuery(sb.toString());

        Property<String> pUn;
        Property<String> pMsisdn;
        Property<String> pEmail;
        Property<Integer> pSn;
        Property<Button> pBtn;

        String msisdn;
        String email;
        Object rid;
        Button btnLink;
        Item r;

        while (rs.next()) {
            int x = container.size() + 1;
            un = rs.getString("username");
            msisdn = rs.getString("msisdn");
            email = rs.getString("email");

            rid = container.addItem();
            r = container.getItem(rid);

            pSn = r.getItemProperty("S/N");
            pUn = r.getItemProperty("Username");
            pMsisdn = r.getItemProperty("MSISDN");
            pEmail = r.getItemProperty("Email");
            pBtn = r.getItemProperty("Action");
            btnLink = new Button();
            btnLink.setIcon(FontAwesome.UNLINK);
            btnLink.setStyleName("btn_link");
            btnLink.setDescription("Unlink this account.");
            btnLink.addClickListener(new UNLinkClickHandler());
            btnLink.setId(un);
            btnLink.setData(rid);

            pSn.setValue(x);
            pUn.setValue(un);
            pMsisdn.setValue(msisdn);
            pEmail.setValue(email);
            pBtn.setValue(btnLink);

        }

        tb.setContainerDataSource(container);
        int t = container.size();
        if (t > 30)
            t = 30;
        tb.setPageLength(t);

    } catch (SQLException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {

        errorHandler(e);
    }

}

From source file:de.symeda.sormas.ui.caze.CasesView.java

License:Open Source License

public CasesView() {
    super(VIEW_NAME);
    originalViewTitle = getViewTitleLabel().getValue();

    criteria = ViewModelProviders.of(CasesView.class).get(CaseCriteria.class);
    if (criteria.getArchived() == null) {
        criteria.archived(false);//from  w ww .  j  a  v  a2  s .  c o  m
    }

    grid = new CaseGrid();
    grid.setCriteria(criteria);
    gridLayout = new VerticalLayout();
    gridLayout.addComponent(createFilterBar());
    gridLayout.addComponent(createStatusFilterBar());
    gridLayout.addComponent(grid);
    gridLayout.setMargin(true);
    gridLayout.setSpacing(false);
    gridLayout.setSizeFull();
    gridLayout.setExpandRatio(grid, 1);
    gridLayout.setStyleName("crud-main-layout");

    grid.getDataProvider().addDataProviderListener(e -> updateStatusButtons());

    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_IMPORT)) {
        Button importButton = new Button(I18nProperties.getCaption(Captions.actionImport));
        importButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        importButton.setIcon(VaadinIcons.UPLOAD);
        importButton.addClickListener(e -> {
            Window popupWindow = VaadinUiUtil.showPopupWindow(new CaseImportLayout());
            popupWindow.setCaption(I18nProperties.getString(Strings.headingImportCases));
            popupWindow.addCloseListener(c -> {
                grid.reload();
            });
        });
        addHeaderComponent(importButton);
    }

    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_EXPORT)) {
        PopupButton exportButton = new PopupButton(I18nProperties.getCaption(Captions.export));
        exportButton.setId("export");
        exportButton.setIcon(VaadinIcons.DOWNLOAD);
        VerticalLayout exportLayout = new VerticalLayout();
        exportLayout.setSpacing(true);
        exportLayout.setMargin(true);
        exportLayout.addStyleName(CssStyles.LAYOUT_MINIMAL);
        exportLayout.setWidth(200, Unit.PIXELS);
        exportButton.setContent(exportLayout);
        addHeaderComponent(exportButton);

        Button basicExportButton = new Button(I18nProperties.getCaption(Captions.exportBasic));
        basicExportButton.setId("basicExport");
        basicExportButton.setDescription(I18nProperties.getString(Strings.infoBasicExport));
        basicExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        basicExportButton.setIcon(VaadinIcons.TABLE);
        basicExportButton.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(basicExportButton);

        StreamResource streamResource = new GridExportStreamResource(grid, "sormas_cases",
                "sormas_cases_" + DateHelper.formatDateForExport(new Date()) + ".csv");
        FileDownloader fileDownloader = new FileDownloader(streamResource);
        fileDownloader.extend(basicExportButton);

        Button extendedExportButton = new Button(I18nProperties.getCaption(Captions.exportDetailed));
        extendedExportButton.setId("extendedExport");
        extendedExportButton.setDescription(I18nProperties.getString(Strings.infoDetailedExport));
        extendedExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        extendedExportButton.setIcon(VaadinIcons.FILE_TEXT);
        extendedExportButton.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(extendedExportButton);

        StreamResource extendedExportStreamResource = DownloadUtil.createCsvExportStreamResource(
                CaseExportDto.class,
                (Integer start, Integer max) -> FacadeProvider.getCaseFacade()
                        .getExportList(UserProvider.getCurrent().getUuid(), grid.getCriteria(), start, max),
                (propertyId, type) -> {
                    String caption = I18nProperties.getPrefixCaption(CaseExportDto.I18N_PREFIX, propertyId,
                            I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, propertyId,
                                    I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, propertyId,
                                            I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, propertyId,
                                                    I18nProperties.getPrefixCaption(EpiDataDto.I18N_PREFIX,
                                                            propertyId,
                                                            I18nProperties.getPrefixCaption(
                                                                    HospitalizationDto.I18N_PREFIX,
                                                                    propertyId))))));
                    if (Date.class.isAssignableFrom(type)) {
                        caption += " (" + DateHelper.getLocalShortDatePattern() + ")";
                    }
                    return caption;
                }, "sormas_cases_" + DateHelper.formatDateForExport(new Date()) + ".csv");
        new FileDownloader(extendedExportStreamResource).extend(extendedExportButton);

        Button sampleExportButton = new Button(I18nProperties.getCaption(Captions.exportSamples));
        sampleExportButton.setId("sampleExport");
        sampleExportButton.setDescription(I18nProperties.getString(Strings.infoSampleExport));
        sampleExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        sampleExportButton.setIcon(VaadinIcons.FILE_TEXT);
        sampleExportButton.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(sampleExportButton);

        StreamResource sampleExportStreamResource = DownloadUtil.createCsvExportStreamResource(
                SampleExportDto.class,
                (Integer start, Integer max) -> FacadeProvider.getSampleFacade()
                        .getExportList(UserProvider.getCurrent().getUuid(), grid.getCriteria(), start, max),
                (propertyId, type) -> {
                    String caption = I18nProperties.getPrefixCaption(SampleExportDto.I18N_PREFIX, propertyId,
                            I18nProperties.getPrefixCaption(SampleDto.I18N_PREFIX, propertyId,
                                    I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, propertyId,
                                            I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, propertyId,
                                                    I18nProperties.getPrefixCaption(
                                                            AdditionalTestDto.I18N_PREFIX, propertyId)))));
                    if (Date.class.isAssignableFrom(type)) {
                        caption += " (" + DateHelper.getLocalShortDatePattern() + ")";
                    }
                    return caption;
                }, "sormas_samples_" + DateHelper.formatDateForExport(new Date()) + ".csv");
        new FileDownloader(sampleExportStreamResource).extend(sampleExportButton);

        // Warning if no filters have been selected
        Label warningLabel = new Label(I18nProperties.getString(Strings.infoExportNoFilters), ContentMode.HTML);
        warningLabel.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(warningLabel);
        warningLabel.setVisible(false);

        exportButton.addClickListener(e -> {
            warningLabel.setVisible(!criteria.hasAnyFilterActive());
        });
    }

    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_MERGE)) {
        Button mergeDuplicatesButton = new Button(I18nProperties.getCaption(Captions.caseMergeDuplicates));
        mergeDuplicatesButton.setId("mergeDuplicates");
        mergeDuplicatesButton.setIcon(VaadinIcons.COMPRESS_SQUARE);
        mergeDuplicatesButton
                .addClickListener(e -> ControllerProvider.getCaseController().navigateToMergeCasesView());
        addHeaderComponent(mergeDuplicatesButton);
    }

    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_CREATE)) {
        createButton = new Button(I18nProperties.getCaption(Captions.caseNewCase));
        createButton.setId("create");
        createButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        createButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        createButton.addClickListener(e -> ControllerProvider.getCaseController().create());
        addHeaderComponent(createButton);
    }

    addComponent(gridLayout);
}

From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropAbsoluteLayoutDemo.java

License:Apache License

@Override
public Component getLayout() {
    // start-source
    final DDAbsoluteLayout layout = new DDAbsoluteLayout();
    layout.setId("layout");
    layout.setSizeFull();/*from   w w w. j a v  a 2  s.  c o m*/

    // Enable dragging components
    layout.setDragMode(LayoutDragMode.CLONE);

    // Enable dropping components
    layout.setDropHandler(new DefaultAbsoluteLayoutDropHandler());

    // Add some components
    Label lbl = new Label("This is an Absolute layout, you can freely drag the components around");
    layout.addComponent(lbl);
    Button btn = new Button("Button 1", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            Notification.show("Click!");
        }
    });
    btn.setId("button");
    layout.addComponent(btn, "left:50px; top:50px");
    Link link = new Link("A link to Vaadin", new ExternalResource("http://www.vaadin.com"));
    layout.addComponent(link, "left:200px; top:100px");

    // end-source
    return layout;
}

From source file:fr.amapj.view.engine.menu.MenuPart.java

License:Open Source License

private CssLayout buildMenu(CssLayout menu, CssLayout menuItemsLayout, List<MenuDescription> allMenus,
        Navigator navigator, AmapUI ui) {

    final HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName("valo-menu-title");
    menu.addComponent(top);/* www. ja va  2s . co  m*/

    final Button showMenu = new Button("Menu", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            if (menu.getStyleName().contains("valo-menu-visible")) {
                menu.removeStyleName("valo-menu-visible");
            } else {
                menu.addStyleName("valo-menu-visible");
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName("valo-menu-toggle");
    showMenu.setIcon(FontAwesome.LIST);
    menu.addComponent(showMenu);

    String nomAmap = new ParametresService().getParametres().nomAmap;
    Label title = new Label("<h2>" + nomAmap + "</h2>", ContentMode.HTML);
    title.setSizeUndefined();
    top.addComponent(title);
    top.setExpandRatio(title, 1);

    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");

    SessionParameters p = SessionManager.getSessionParameters();
    MenuItem settingsItem = settings.addItem(p.userPrenom + " " + p.userNom, null, null);
    settingsItem.addItem("Se dconnecter", new MenuBar.Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            new PasswordManager().disconnect();
            ui.buildLoginView(null, null, null);
        }
    });

    menu.addComponent(settings);

    menuItemsLayout.setPrimaryStyleName("valo-menuitems");
    menu.addComponent(menuItemsLayout);

    boolean first = true;
    String firstEntry = null;
    Button firstButton = null;

    for (MenuDescription menuDescription : allMenus) {
        final String view = menuDescription.getMenuName().name().toLowerCase();
        final String titleView = menuDescription.getMenuName().getTitle();

        if (menuDescription.getCategorie() != null) {
            Label l = new Label(menuDescription.getCategorie(), ContentMode.HTML);
            l.setPrimaryStyleName("valo-menu-subtitle");
            l.addStyleName("h4");
            l.setSizeUndefined();
            menuItemsLayout.addComponent(l);
        }

        final Button b = new Button(titleView, new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                setSelected(event.getButton(), menuItemsLayout);
                navigator.navigateTo("/" + view);
            }
        });

        b.setId("amapj.menu." + view);
        b.setHtmlContentAllowed(true);
        b.setPrimaryStyleName("valo-menu-item");
        b.setIcon(menuDescription.getMenuName().getFont());
        menuItemsLayout.addComponent(b);

        viewNameToMenuButton.put("/" + view, b);

        if (first) {
            first = false;
            firstButton = b;
            firstEntry = view;
        }
    }

    // Gestion de l'url
    String f = Page.getCurrent().getUriFragment();
    if (f != null && f.startsWith("!")) {
        f = f.substring(1);
    }
    if (f == null || f.equals("") || f.equals("/")) {
        navigateWithProtect(navigator, "/" + firstEntry);
        setSelected(firstButton, menuItemsLayout);
    } else {
        navigateWithProtect(navigator, f);
        setSelected(viewNameToMenuButton.get(f), menuItemsLayout);
    }

    return menu;
}

From source file:io.subutai.plugin.accumulo.ui.manager.AddNodeWindow.java

public AddNodeWindow(final Accumulo accumulo, final ExecutorService executorService, final Tracker tracker,
        final AccumuloClusterConfig accumuloClusterConfig, Set<EnvironmentContainerHost> nodes,
        final NodeType nodeType) {
    super("Add New Node");
    setModal(true);//from  w  w w  .j  a  va  2  s  . co m

    setWidth(650, Unit.PIXELS);
    setHeight(450, Unit.PIXELS);

    GridLayout content = new GridLayout(1, 3);
    content.setSizeFull();
    content.setMargin(true);
    content.setSpacing(true);

    HorizontalLayout topContent = new HorizontalLayout();
    topContent.setSpacing(true);

    content.addComponent(topContent);
    topContent.addComponent(new Label("Nodes:"));

    final ComboBox hadoopNodes = new ComboBox();
    hadoopNodes.setId("HadoopNodesCb");
    hadoopNodes.setImmediate(true);
    hadoopNodes.setTextInputAllowed(false);
    hadoopNodes.setNullSelectionAllowed(false);
    hadoopNodes.setRequired(true);
    hadoopNodes.setWidth(200, Unit.PIXELS);
    for (EnvironmentContainerHost node : nodes) {
        hadoopNodes.addItem(node);
        hadoopNodes.setItemCaption(node, node.getHostname());
    }

    if (nodes.size() == 0) {
        return;
    }
    hadoopNodes.setValue(nodes.iterator().next());

    topContent.addComponent(hadoopNodes);

    final Button addNodeBtn = new Button("Add");
    addNodeBtn.setId("AddSelectedNode");
    topContent.addComponent(addNodeBtn);

    final Button ok = new Button("Ok");

    addNodeBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            addNodeBtn.setEnabled(false);
            ok.setEnabled(false);
            showProgress();
            EnvironmentContainerHost containerHost = (EnvironmentContainerHost) hadoopNodes.getValue();
            final UUID trackID = accumulo.addNode(accumuloClusterConfig.getClusterName(),
                    containerHost.getHostname(), nodeType);
            executorService.execute(new Runnable() {
                public void run() {
                    while (track) {
                        TrackerOperationView po = tracker.getTrackerOperation(AccumuloClusterConfig.PRODUCT_KEY,
                                trackID);
                        if (po != null) {
                            setOutput(po.getDescription() + "\nState: " + po.getState() + "\nLogs:\n"
                                    + po.getLog());
                            if (po.getState() != OperationState.RUNNING) {
                                hideProgress();
                                ok.setEnabled(true);
                                break;
                            }
                        } else {
                            setOutput("Product operation not found. Check logs");
                            break;
                        }
                        try {
                            Thread.sleep(1000);
                        } catch (InterruptedException ex) {
                            break;
                        }
                    }
                }
            });
        }
    });

    outputTxtArea = new TextArea("Operation output");
    outputTxtArea.setId("outputTxtArea");
    outputTxtArea.setRows(13);
    outputTxtArea.setColumns(43);
    outputTxtArea.setImmediate(true);
    outputTxtArea.setWordwrap(true);

    content.addComponent(outputTxtArea);

    indicator = new Label();
    indicator.setId("indicator");
    indicator.setIcon(new ThemeResource("img/spinner.gif"));
    indicator.setContentMode(ContentMode.HTML);
    indicator.setHeight(11, Unit.PIXELS);
    indicator.setWidth(50, Unit.PIXELS);
    indicator.setVisible(false);

    ok.setId("btnOk");
    ok.setStyleName("default");
    ok.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            //close window
            track = false;
            close();
        }
    });

    HorizontalLayout bottomContent = new HorizontalLayout();
    bottomContent.addComponent(indicator);
    bottomContent.setComponentAlignment(indicator, Alignment.MIDDLE_RIGHT);
    bottomContent.addComponent(ok);

    content.addComponent(bottomContent);
    content.setComponentAlignment(bottomContent, Alignment.MIDDLE_RIGHT);

    setContent(content);
}

From source file:io.subutai.plugin.accumulo.ui.manager.Manager.java

private void populateMastersTable(final Table table, Set<EnvironmentContainerHost> containerHosts,
        final boolean masters) {
    table.removeAllItems();//from  ww  w  .  j  a  v  a2 s .c  om
    for (final EnvironmentContainerHost containerHost : containerHosts) {
        List<NodeType> rolesOfNode = accumuloClusterConfig.getMasterNodeRoles(containerHost.getId());
        for (final NodeType role : rolesOfNode) {
            final Button checkBtn = new Button(CHECK_BUTTON_CAPTION);
            checkBtn.setId(containerHost.getIpByInterfaceName("eth0") + "-accumuloCheck");

            final Button destroyBtn = new Button(DESTROY_BUTTON_CAPTION);
            destroyBtn.setId(containerHost.getIpByInterfaceName("eth0") + "-accumuloDestroy");

            final Label resultHolder = new Label();
            resultHolder.setId(containerHost.getIpByInterfaceName("eth0") + "accumuloResult");

            HorizontalLayout availableOperations = new HorizontalLayout();
            availableOperations.setSpacing(true);

            addGivenComponents(availableOperations, checkBtn);
            addStyleName(checkBtn, destroyBtn, availableOperations);

            table.addItem(
                    new Object[] { containerHost.getHostname(), containerHost.getIpByInterfaceName("eth0"),
                            filterNodeRole(role.name()), resultHolder, availableOperations },
                    null);

            checkBtn.addClickListener(new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    PROGRESS_ICON.setVisible(true);
                    disableButtons(checkBtn, destroyBtn);
                    executorService
                            .execute(new CheckTask(accumulo, tracker, accumuloClusterConfig.getClusterName(),
                                    containerHost.getHostname(), new CompleteEvent() {
                                        public void onComplete(String result) {
                                            synchronized (PROGRESS_ICON) {
                                                resultHolder.setValue(parseStatus(result, role));
                                                enableButtons(destroyBtn, checkBtn);
                                                PROGRESS_ICON.setVisible(false);
                                            }
                                        }
                                    }));
                }
            });
        }
    }
}

From source file:io.subutai.plugin.accumulo.ui.manager.Manager.java

private void populateTracersTable(final Table table, Set<EnvironmentContainerHost> containerHosts,
        final boolean masters) {
    table.removeAllItems();/*from   w ww  .  j  a  v a2 s.  c  o m*/
    for (final EnvironmentContainerHost containerHost : containerHosts) {
        final Button checkBtn = new Button(CHECK_BUTTON_CAPTION);
        checkBtn.setId(containerHost.getIpByInterfaceName("eth0") + "-accumuloCheck");
        final Button destroyBtn = new Button(DESTROY_BUTTON_CAPTION);
        destroyBtn.setId(containerHost.getIpByInterfaceName("eth0") + "-accumuloDestroy");
        final Label resultHolder = new Label();
        resultHolder.setId(containerHost.getIpByInterfaceName("eth0") + "accumuloResult");

        HorizontalLayout availableOperations = new HorizontalLayout();
        availableOperations.setSpacing(true);

        addGivenComponents(availableOperations, checkBtn, destroyBtn);
        addStyleName(checkBtn, destroyBtn, availableOperations);

        table.addItem(
                new Object[] { containerHost.getHostname(), containerHost.getIpByInterfaceName("eth0"),
                        filterNodeRole(NodeType.ACCUMULO_TRACER.name()), resultHolder, availableOperations },
                null);

        checkBtn.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                PROGRESS_ICON.setVisible(true);
                disableButtons(checkBtn, destroyBtn);
                executorService.execute(new CheckTask(accumulo, tracker, accumuloClusterConfig.getClusterName(),
                        containerHost.getHostname(), new CompleteEvent() {
                            public void onComplete(String result) {
                                synchronized (PROGRESS_ICON) {
                                    resultHolder.setValue(parseStatus(result, NodeType.ACCUMULO_TRACER));
                                    enableButtons(checkBtn, destroyBtn);
                                    PROGRESS_ICON.setVisible(false);
                                }
                            }
                        }));
            }
        });

        destroyBtn.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {

                if (accumuloClusterConfig.getTracers().size() == 1) {
                    show("This is last tracer node in cluster, please destroy whole cluster");
                    return;
                }

                ConfirmationDialog alert = new ConfirmationDialog(
                        String.format("Do you want to destroy the %s node?", containerHost.getHostname()),
                        "Yes", "No");
                alert.getOk().addClickListener(new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent clickEvent) {
                        UUID trackID = accumulo.destroyNode(accumuloClusterConfig.getClusterName(),
                                containerHost.getHostname(), NodeType.ACCUMULO_TRACER);

                        ProgressWindow window = new ProgressWindow(executorService, tracker, trackID,
                                AccumuloClusterConfig.PRODUCT_KEY);
                        window.getWindow().addCloseListener(new Window.CloseListener() {
                            @Override
                            public void windowClose(Window.CloseEvent closeEvent) {
                                refreshClustersInfo();
                            }
                        });
                        contentRoot.getUI().addWindow(window.getWindow());
                    }
                });
                contentRoot.getUI().addWindow(alert.getAlert());
            }
        });
    }
}