Example usage for com.vaadin.ui Embedded setDescription

List of usage examples for com.vaadin.ui Embedded setDescription

Introduction

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

Prototype

public void setDescription(String description) 

Source Link

Document

Sets the component's description.

Usage

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

License:Open Source License

/**
 * Asynch refresh.//ww w  .j  a va2 s. c o m
 *
 * @param updaterThread the updater thread
 */
private void asynchRefresh(final UpdaterThread updaterThread) {

    ManagerUI managerUI = getSession().getAttribute(ManagerUI.class);

    nodeInfo = (NodeInfo) getSession().getAttribute(ClusterComponent.class);
    final String newNodeID = nodeInfo.getID();

    final UserInfo userInfo = (UserInfo) getSession().getAttribute(UserInfo.class);

    TaskRecord taskRecord = nodeInfo.getTask();
    final String taskID = (taskRecord != null && taskRecord.getState().equals("running")) ? taskRecord.getID()
            : null;

    // update command history section
    TaskInfo taskInfo = new TaskInfo(null, nodeInfo.getParentID(), nodeInfo.getID());
    final ArrayList<TaskRecord> tasksList = taskInfo.getTasksList();

    managerUI.access(new Runnable() {
        @Override
        public void run() {
            // Here the UI is locked and can be updated

            ManagerUI.log("PanelControl access run() - taskID: " + taskID);

            RunningTask runningTask = nodeInfo.getCommandTask();

            DateConversion dateConversion = getSession().getAttribute(DateConversion.class);
            boolean adjust = dateConversion.isAdjustedToLocal();
            String format = dateConversion.getFormat();

            if (!newNodeID.equals(lastNodeID) || (tasksList != null && tasksList.size() != oldTasksCount)
                    || adjust != updaterThread.adjust || !format.equals(updaterThread.format)) {

                updaterThread.adjust = adjust;
                updaterThread.format = format;

                logsTable.removeAllItems();

                if (tasksList != null) {

                    oldTasksCount = tasksList.size();
                    firstObject = null;
                    for (TaskRecord taskRecord : tasksList) {
                        Embedded info = null;
                        if (taskRecord.getState().equals(CommandStates.States.error.name())) {
                            info = new Embedded(null, new ThemeResource("img/alert.png"));
                            info.addStyleName("infoButton");
                            info.setDescription(taskRecord.getError());
                        }
                        Object itemID = logsTable.addItem(new Object[] { taskRecord.getCommand(),
                                CommandStates.getDescriptions().get(taskRecord.getState()), info,
                                dateConversion.adjust(taskRecord.getStart()),
                                dateConversion.adjust(taskRecord.getEnd()), taskRecord.getSteps(),
                                taskRecord.getParams(), taskRecord.getUserID() }, taskRecord.getID());
                        if (firstObject == null) {
                            firstObject = itemID;
                        }

                    }
                }
            } else if (tasksList.size() > 0 && firstObject != null) {
                // update top of the list with last task info
                TaskRecord taskRecord = tasksList.get(0);
                Embedded info = null;
                if (taskRecord.getState().equals(CommandStates.States.error.name())) {
                    info = new Embedded(null, new ThemeResource("img/alert.png"));
                    info.addStyleName("infoButton");
                    info.setDescription(taskRecord.getError());
                }
                Item tableRow = logsTable.getItem(firstObject);
                tableRow.getItemProperty("State")
                        .setValue(CommandStates.getDescriptions().get(taskRecord.getState()));
                tableRow.getItemProperty("Info").setValue(info);
                tableRow.getItemProperty("Completed").setValue(dateConversion.adjust(taskRecord.getEnd()));
            }

            // task is running although it was not started by us
            if (taskID != null && runningTask == null) {
                runningTask = new RunningTask(null, nodeInfo, commandSelect);
                runningTask.addRefreshListener(refreshListener);
            }

            if (!newNodeID.equals(lastNodeID)) {
                commandSelect.removeAllItems();
                nodeInfo.updateCommands();
            }
            if (nodeInfo.getCommands() == null || nodeInfo.getCommands().getNames().isEmpty()) {
                commandSelect.removeAllItems();
                oldcommands = null;
                placeholderLabel.setValue("No Command is currently available on this node");
            } else {
                placeholderLabel.setValue("No Command is currently running on this node");
                String commands[] = new String[nodeInfo.getCommands().getNames().keySet().size()];
                nodeInfo.getCommands().getNames().keySet().toArray(commands);
                if (!newNodeID.equals(lastNodeID) || !Arrays.equals(commands, oldcommands)) {
                    oldcommands = commands;
                    commandSelect.removeValueChangeListener(commandListener);

                    // rebuild list of commands with what node is accepting
                    commandSelect.removeAllItems();
                    if ((commands != null) && (commands.length != 0)) {
                        for (String command : commands) {
                            commandSelect.addItem(command);
                        }
                    }

                    commandSelect.addValueChangeListener(commandListener);
                }

                commandSelect.removeValueChangeListener(commandListener);
                String selected = (runningTask != null) ? runningTask.getCommand() : null;
                commandSelect.select(selected);
                commandSelect.addValueChangeListener(commandListener);

            }
            commandSelect.setEnabled(taskID != null ? false : true);

            if (runningTask != null) {
                VerticalLayout newScriptingLayout = runningTask.getLayout();
                newLayout.replaceComponent(runningContainerLayout, newScriptingLayout);
                runningContainerLayout = newScriptingLayout;
            } else if (runningContainerLayout != placeholderLayout) {
                newLayout.replaceComponent(runningContainerLayout, placeholderLayout);
                newLayout.setComponentAlignment(placeholderLayout, Alignment.MIDDLE_CENTER);
                runningContainerLayout = placeholderLayout;
            }

            lastNodeID = newNodeID;
        }
    });

}

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

License:Open Source License

/**
 * Instantiates a new system form./*  w  ww  .  j  av  a2 s  .  co m*/
 *
 * @param system the system
 * @param description the description
 * @param commitButton the commit button
 */
SystemForm(final SystemRecord system, String description, final Button commitButton) {
    this.system = system;

    setMargin(new MarginInfo(true, true, false, true));
    setSpacing(false);

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

    Embedded info = new Embedded(null, new ThemeResource("img/info.png"));
    info.addStyleName("infoButton");
    String infoText = "<table border=0 cellspacing=3 cellpadding=0 summary=\"\">\n"
            + "     <tr bgcolor=\"#ccccff\">" + "         <th align=left>Field"
            + "         <th align=left>Description" + "     <tr>" + "         <td><code>Name</code>"
            + "         <td>Name of the system" + "     <tr bgcolor=\"#eeeeff\">"
            + "         <td><code>Type</code>" + "         <td>Type of the system e.g. aws or galera"
            + "     <tr>" + "         <td><code>Database Username</code>"
            + "         <td>System default for database user name" + "     <tr bgcolor=\"#eeeeff\">"
            + "         <td><code>Database Password</code>"
            + "         <td>System default for database password" + "     <tr>"
            + "         <td><code>Replication Username</code>"
            + "         <td>System default for replication user name" + "     <tr bgcolor=\"#eeeeff\">"
            + "         <td><code>Replication Password</code>"
            + "         <td>System default for replication password" + " </table>" + " </blockquote>";
    info.setDescription(infoText);

    formDescription.addComponent(info);
    Label labelDescription = new Label(description);
    formDescription.addComponent(labelDescription);
    formDescription.setComponentAlignment(labelDescription, Alignment.MIDDLE_LEFT);
    addComponent(formDescription);

    addComponent(form);
    form.setImmediate(false);
    form.setFooter(null);
    form.setDescription(null);

    String value;
    if ((value = system.getName()) != null) {
        name.setValue(value);
    }
    form.addField("name", name);
    name.focus();
    name.setImmediate(true);
    name.addValidator(new SystemNameValidator(system.getName()));

    for (String systemType : SystemTypes.getList().keySet()) {
        this.systemType.addItem(systemType);
    }
    systemType.select(system.getSystemType() != null ? system.getSystemType() : SystemTypes.DEFAULT_SYSTEMTYPE);
    systemType.setNullSelectionAllowed(false);
    systemType.setEnabled(false);
    form.addField("systemType", systemType);

    if ((value = system.getDBUsername()) != null) {
        dbUsername.setValue(value);
    } else {
        dbUsername.setValue("skysql");
    }
    form.addField("dbusername", dbUsername);
    dbUsername.setRequired(true);
    dbUsername.setImmediate(true);
    dbUsername.setRequiredError("Database Username is a required field");
    dbUsername.addValidator(new UserNotRootValidator(dbUsername.getCaption()));

    if ((value = system.getDBPassword()) != null) {
        dbPassword.setValue(value);
    }
    form.addField("dbpassword", dbPassword);
    dbPassword.setRequired(true);
    dbPassword.setImmediate(false);
    dbPassword.setRequiredError("Database Password is a required field");

    if ((value = system.getDBPassword()) != null) {
        dbPassword2.setValue(value);
    }
    form.addField("dbpassword2", dbPassword2);
    dbPassword2.setRequired(true);
    dbPassword2.setImmediate(true);
    dbPassword2.setRequiredError("Confirm Password is a required field");
    dbPassword2.addValidator(new Password2Validator(dbPassword));

    if ((value = system.getRepUsername()) != null) {
        repUsername.setValue(value);
    } else {
        repUsername.setValue("repluser");
    }
    form.addField("repusername", repUsername);
    repUsername.setRequired(true);
    repUsername.setImmediate(true);
    repUsername.setRequiredError("Replication Username is a required field");
    repUsername.addValidator(new UserNotRootValidator(repUsername.getCaption()));
    repUsername.addValidator(new UserDifferentValidator(dbUsername));

    if ((value = system.getRepPassword()) != null) {
        repPassword.setValue(value);
    }
    form.addField("reppassword", repPassword);
    repPassword.setRequired(true);
    repPassword.setImmediate(true);
    repPassword.setRequiredError("Replication Password is a required field");
    repPassword.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void valueChange(ValueChangeEvent event) {
            commitButton.setClickShortcut(KeyCode.ENTER);
        }
    });

    if ((value = system.getRepPassword()) != null) {
        repPassword2.setValue(value);
    }
    form.addField("reppassword2", repPassword2);
    repPassword2.setRequired(true);
    repPassword2.setImmediate(true);
    repPassword2.setRequiredError("Confirm Password is a required field");
    repPassword2.addValidator(new Password2Validator(repPassword));
    repPassword2.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void valueChange(ValueChangeEvent event) {
            commitButton.focus();
        }
    });

}

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

private VerticalLayout getNewUserContainer() {

    VerticalLayout cAgentInfo = new VerticalLayout();

    Embedded emb = new Embedded(null, new ThemeResource("img/add_user_small.png"));
    emb.setDescription("add new user");
    emb.setStyleName("search_user_img");
    emb.setSizeUndefined();/*from   w  w  w. j av  a 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:edu.nps.moves.mmowgli.modules.cards.CallToActionPage.java

License:Open Source License

public void initGui() {
    Object sessKey = HSess.checkInit();
    Label spacer = new Label();
    spacer.setWidth(CALLTOACTION_HOR_OFFSET_STR);
    addComponent(spacer);//from w  ww . ja  va  2 s .co  m
    VerticalLayout mainVl = new VerticalLayout();
    addComponent(mainVl);
    mainVl.setSpacing(true);
    mainVl.setWidth("100%");

    MovePhase phase = MovePhase.getCurrentMovePhaseTL();
    String sum = phase.getCallToActionBriefingSummary();
    String tx = phase.getCallToActionBriefingText();
    Media v = phase.getCallToActionBriefingVideo();

    Embedded headerImg = new Embedded(null, Mmowgli2UI.getGlobals().mediaLocator().getCallToActionBang());
    headerImg.setDescription("Review motivation and purpose of this game");

    NativeButton needButt = new NativeButton();
    needButt.setStyleName("m-weNeedYourHelpButton");

    vidPan = new VideoWithRightTextPanel(v, headerImg, sum, tx, needButt); // needImg);
    vidPan.initGui();
    mainVl.addComponent(vidPan);

    String playCardString = Game.getTL().getCurrentMove().getCurrentMovePhase().getPlayACardTitle();
    NativeButton butt;
    if (!mockupOnly)
        butt = new IDNativeButton(playCardString, MmowgliEvent.PLAYIDEACLICK);
    else
        butt = new NativeButton(playCardString); // no listener
    butt.addStyleName("borderless");
    butt.addStyleName("m-calltoaction-playprompt");
    butt.setDescription("View existing cards and play new ones");
    mainVl.addComponent(butt);
    mainVl.setComponentAlignment(butt, Alignment.MIDDLE_CENTER);
    HSess.checkClose(sessKey);
}

From source file:edu.nps.moves.mmowgli.modules.cards.CardSummaryLine.java

License:Open Source License

@Override
public void initGui() {
    Card c = Card.getTL(cardId);//w  w  w.  j a  v  a 2 s. c o m
    String tooltip = c.getText();

    User auth = c.getAuthor();

    Label lab = new Label(dateForm.format(c.getCreationDate()));
    lab.setWidth(6.0f, Unit.EM);
    addComponent(lab);
    setComponentAlignment(lab, Alignment.MIDDLE_LEFT);
    lab.addStyleName("m-cursor-pointer");
    lab.setDescription(tooltip);

    addComponent(lab = new Label(c.getCardType().getTitle()));
    lab.setWidth(5.0f, Unit.EM);
    setComponentAlignment(lab, Alignment.MIDDLE_LEFT);
    lab.addStyleName("m-cursor-pointer");
    lab.setDescription(tooltip);

    MediaLocator mLoc = Mmowgli2UI.getGlobals().getMediaLocator();
    Embedded emb = new Embedded(null, mLoc.getCardDot(c.getCardType()));
    emb.setWidth("19px");
    emb.setHeight("15px");
    addComponent(emb);
    setComponentAlignment(emb, Alignment.MIDDLE_LEFT);
    emb.addStyleName("m-cursor-pointer");
    emb.setDescription(tooltip);

    addComponent(lab = new Label(c.getText()));
    lab.setHeight(1.0f, Unit.EM);
    ;
    setComponentAlignment(lab, Alignment.MIDDLE_LEFT);
    setExpandRatio(lab, 1.0f); // all the extra
    lab.addStyleName("m-cursor-pointer");
    lab.setDescription(tooltip);

    if (auth.getAvatar() != null) {
        avatar = new Embedded(null, mLoc.locate(auth.getAvatar().getMedia(), 32));
        avatar.setWidth("24px");
        avatar.setHeight("24px");
        addComponent(avatar);
        setComponentAlignment(avatar, Alignment.MIDDLE_LEFT);
        avatar.addStyleName("m-cursor-pointer");
        avatar.setDescription(tooltip);
    }
    IDButton uButt = new IDButton(c.getAuthorName(), SHOWUSERPROFILECLICK, c.getAuthor().getId());
    uButt.addStyleName(BaseTheme.BUTTON_LINK);
    uButt.setWidth(8.0f, Unit.EM);
    addComponent(uButt);
    setComponentAlignment(uButt, Alignment.MIDDLE_LEFT);
    uButt.setDescription(tooltip);
}

From source file:edu.vcu.csbc.vahmpexplorer.main.VaHMPExplorer.java

public Component createToolBar(boolean loggedIn) {
    HorizontalLayout h = new HorizontalLayout();
    h.setMargin(true);/*from  w  w  w .j a  v a2s .  com*/
    h.setWidth("100%");

    Embedded headerImg = new Embedded(null, new ThemeResource("../vahmpexplorer/img/header.png"));
    headerImg.setWidth(311, Embedded.UNITS_PIXELS);
    headerImg.setHeight(45, Embedded.UNITS_PIXELS);
    headerImg.setType(Embedded.TYPE_IMAGE);
    headerImg.setStyleName(BaseTheme.BUTTON_LINK);
    headerImg.setDescription("Version " + HelpMessages.VERSION);
    h.addComponent(headerImg);

    if (loggedIn) {
        Panel panel = new Panel();
        Label loggedInUser = new Label(
                "Welcome: " + user.getFirstName() + " " + user.getLastName() + " (" + user.getLogin() + ")");
        changePassword = new Button("Change Password");
        changePassword.setStyleName(BaseTheme.BUTTON_LINK);
        changePassword.addListener((Button.ClickListener) this);

        logout = new Button("Logout");
        logout.setStyleName(BaseTheme.BUTTON_LINK);
        logout.addListener((Button.ClickListener) this);

        HorizontalLayout hl = new HorizontalLayout();
        hl.setSpacing(true);
        hl.addComponent(changePassword);
        hl.addComponent(logout);

        panel.addComponent(loggedInUser);
        panel.addComponent(hl);
        h.addComponent(panel);
        h.setComponentAlignment(panel, Alignment.MIDDLE_RIGHT);
    }
    PopupView help = new PopupView(new MainHelpPopup());
    h.addComponent(help);
    h.setComponentAlignment(help, Alignment.MIDDLE_RIGHT);
    h.setComponentAlignment(headerImg, Alignment.MIDDLE_LEFT);
    return h;
}

From source file:org.apache.ace.webui.vaadin.component.BaseObjectPanel.java

License:Apache License

/**
 * Factory method to create an embeddable icon.
 * /* w  w  w. j a v a2  s .  c  o  m*/
 * @param name
 *            the name of the icon to use (is also used as tooltip text);
 * @param res
 *            the resource denoting the actual icon.
 * @return an embeddable icon, never <code>null</code>.
 */
protected Embedded createIcon(String name, Resource res) {
    Embedded embedded = new Embedded(name, res);
    embedded.setType(Embedded.TYPE_IMAGE);
    embedded.setDescription(name);
    embedded.setHeight(ICON_HEIGHT + "px");
    embedded.setWidth(ICON_WIDTH + "px");
    return embedded;
}

From source file:org.eclipse.hawkbit.ui.decorators.SPUIEmbedDecorator.java

License:Open Source License

/**
 * Decorate.// ww  w  .j a va2s  .  co m
 * 
 * @param spUIEmbdValue
 *            as DTO
 * @return Embedded as UI
 */
public static Embedded decorate(final SPUIEmbedValue spUIEmbdValue) {
    final Embedded spUIEmbd = new Embedded();
    spUIEmbd.setImmediate(spUIEmbdValue.isImmediate());
    spUIEmbd.setType(spUIEmbdValue.getType());

    if (null != spUIEmbdValue.getId()) {
        spUIEmbd.setId(spUIEmbdValue.getId());
    }

    if (null != spUIEmbdValue.getData()) {
        spUIEmbd.setData(spUIEmbdValue.getData());
    }

    if (null != spUIEmbdValue.getStyleName()) {
        spUIEmbd.setStyleName(spUIEmbdValue.getStyleName());
    }

    if (null != spUIEmbdValue.getSource()) {
        spUIEmbd.setSource(new ThemeResource(spUIEmbdValue.getSource()));
    }

    if (null != spUIEmbdValue.getMimeType()) {
        spUIEmbd.setMimeType(spUIEmbdValue.getMimeType());
    }

    if (null != spUIEmbdValue.getDescription()) {
        spUIEmbd.setDescription(spUIEmbdValue.getDescription());
    }

    return spUIEmbd;
}

From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.ReviewComponent.java

License:Open Source License

private void paintReviewGrid() {
    if (reviewGrid == null) {
        reviewGrid = new GridLayout(2, currentPageLength);
        reviewGrid.setSizeFull();/*from  w w w  . j ava  2  s.  c  o  m*/
        reviewGrid.setSpacing(true);
        layout.addComponent(reviewGrid);
    } else {
        reviewGrid.removeAllComponents();
    }
    int rows = reviewGrid.getRows();
    if (rows != currentPageLength) {
        reviewGrid.setRows(Math.min(size, currentPageLength));
    }

    int row = 0;
    List<ReviewEntry> latestReviews = getLatestReviews(currentPage, currentPageLength);
    for (ReviewEntry review : latestReviews) {
        ProjectRating rating = review.getRating();
        Embedded e = new Embedded(null, getIcon(rating));
        e.setDescription(getDescription(rating));
        e.setWidth("22px"); //$NON-NLS-1$
        e.setHeight("22px"); //$NON-NLS-1$
        reviewGrid.addComponent(e, 0, row);

        StringBuilder sb = new StringBuilder();
        sb.append("<span style=\"white-space:normal\">"); //$NON-NLS-1$
        sb.append(HtmlUtils.clean(review.getComment()));
        sb.append("<br>"); //$NON-NLS-1$
        sb.append("<span style=\"font-size:x-small\">").append(" posted by "); //$NON-NLS-1$
        sb.append(StringEscapeUtils.escapeHtml(review.getVoter()));
        sb.append(" "); //$NON-NLS-1$

        long deltaMillis = System.currentTimeMillis() - review.getTimestamp();
        long deltaDays = deltaMillis / MILLIS_PER_DAY;
        if (deltaDays > 0) {
            sb.append(deltaDays);
            sb.append(" days ago");
        } else {
            long deltaHours = deltaMillis / MILLIS_PER_HOUR;
            if (deltaHours > 0) {
                sb.append(deltaHours).append(" hours ago");
            } else {
                long deltaMinutes = deltaMillis / MILLIS_PER_MINUTE;
                if (deltaMinutes > 0) {
                    sb.append(deltaMinutes).append(" minutes ago");
                } else {
                    sb.append(" just now");
                }
            }
            sb.append("</span></span>"); //$NON-NLS-1$
        }
        CssLayout css = new CssLayout();
        css.setSizeFull();
        Label comment = new Label(sb.toString(), Label.CONTENT_XHTML);
        comment.setSizeUndefined();
        css.addComponent(comment);
        reviewGrid.addComponent(css, 1, row);
        reviewGrid.setColumnExpandRatio(1, 1.0f);
        ++row;
    }
}

From source file:org.hip.vif.web.util.RatingValue.java

License:Open Source License

/** @return {@link Component} the rating value as embedded gif. */
public Component render() {
    final Embedded out = new Embedded(null, new ThemeResource(String.format(TMPL_IMG, img)));
    out.setStyleName("vif-rating-value"); //$NON-NLS-1$
    out.setDescription(messages.getMessage(msgKey));
    return out;//from  ww w.j  a v a2  s.  c o m
}