Example usage for com.vaadin.ui FormLayout setWidth

List of usage examples for com.vaadin.ui FormLayout setWidth

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:cirad.cgh.vcf2fasta.view.Vcf2fastaForm.java

License:Open Source License

private void initComponents() {
    removeAllComponents();//from w w w  . jav  a  2  s.  co m

    fieldGroup = new BeanFieldGroup<Vcf2fastaInputBean>(Vcf2fastaInputBean.class);
    vcf2fastaInputBean = new Vcf2fastaInputBean(config);
    fieldGroup.setItemDataSource(vcf2fastaInputBean);

    FormLayout layout = new FormLayout();
    layout.setResponsive(true);
    layout.setMargin(true);
    layout.setWidth("100%");
    //layout.addStyleName("light");
    layout.setImmediate(true);
    addComponent(layout);

    Label section1;
    final ComboBox analysis_combo;
    final ComboBox accession_combo;
    Label section2;
    ComboBox contig_combo;
    TextField interval;
    Label section3;
    Component buttonLayout;
    Component progressLayout;

    section1 = new Label("Input");
    section1.addStyleName("h3 colored");
    layout.addComponent(section1);
    analysis_combo = getComboBox(ANALYSIS_CAPTION, ANALYSIS, getAnalysesList(), false);
    layout.addComponent(analysis_combo);
    accession_combo = getComboBox(ACCESSION_CAPTION, ACCESSION,
            getAccessionsList("Cassava 6.1 WGS Bredeson 61 accessions"), false);
    layout.addComponent(accession_combo);

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

        @Override
        public void valueChange(ValueChangeEvent event) {
            accession_combo.setContainerDataSource(getAccessionsList((String) analysis_combo.getValue()));
            accession_combo.select(accession_combo.getContainerDataSource().getItemIds().iterator().next());
        }
    });

    section2 = new Label("Parameters");
    section2.addStyleName("h3 colored");
    layout.addComponent(section2);
    contig_combo = getComboBox(CONTIG_CAPTION, CONTIG, getContigsList(), true);
    layout.addComponent(contig_combo);
    interval = getTextField(INTERVAL_CAPTION, INTERVAL, vcf2fastaUI.getConfig().getString("defaultInterval"),
            20);
    layout.addComponent(interval);

    section3 = new Label("Result");
    section3.addStyleName("h3 colored");
    layout.addComponent(section3);
    resultLayout = new VerticalLayout();
    resultLayout.setSizeFull();
    resultLayout.setMargin(true);
    resultLayout.setSpacing(true);
    resultLayout.addStyleName("light");
    layout.addComponent(resultLayout);

    layout.addComponent(new Label(""));

    buttonLayout = getSubmitLayout();
    layout.addComponent(buttonLayout);
    progressLayout = getProgressLayout();
    layout.addComponent(progressLayout);

    initCommitHandler();
}

From source file:com.cavisson.gui.dashboard.components.controls.Forms.java

License:Apache License

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

    Label title = new Label("Forms");
    title.addStyleName("h1");
    addComponent(title);

    final FormLayout form = new FormLayout();
    form.setMargin(false);
    form.setWidth("800px");
    form.addStyleName("light");
    addComponent(form);

    Label section = new Label("Personal Info");
    section.addStyleName("h2");
    section.addStyleName("colored");
    form.addComponent(section);
    StringGenerator sg = new StringGenerator();

    TextField name = new TextField("Name");
    name.setValue(sg.nextString(true) + " " + sg.nextString(true));
    name.setWidth("50%");
    form.addComponent(name);

    DateField birthday = new DateField("Birthday");
    birthday.setValue(new Date(80, 0, 31));
    form.addComponent(birthday);

    TextField username = new TextField("Username");
    username.setValue(sg.nextString(false) + sg.nextString(false));
    username.setRequired(true);
    form.addComponent(username);

    OptionGroup sex = new OptionGroup("Sex");
    sex.addItem("Female");
    sex.addItem("Male");
    sex.select("Male");
    sex.addStyleName("horizontal");
    form.addComponent(sex);

    section = new Label("Contact Info");
    section.addStyleName("h3");
    section.addStyleName("colored");
    form.addComponent(section);

    TextField email = new TextField("Email");
    email.setValue(sg.nextString(false) + "@" + sg.nextString(false) + ".com");
    email.setWidth("50%");
    email.setRequired(true);
    form.addComponent(email);

    TextField location = new TextField("Location");
    location.setValue(sg.nextString(true) + ", " + sg.nextString(true));
    location.setWidth("50%");
    location.setComponentError(new UserError("This address doesn't exist"));
    form.addComponent(location);

    TextField phone = new TextField("Phone");
    phone.setWidth("50%");
    form.addComponent(phone);

    HorizontalLayout wrap = new HorizontalLayout();
    wrap.setSpacing(true);
    wrap.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    wrap.setCaption("Newsletter");
    CheckBox newsletter = new CheckBox("Subscribe to newsletter", true);
    wrap.addComponent(newsletter);

    ComboBox period = new ComboBox();
    period.setTextInputAllowed(false);
    period.addItem("Daily");
    period.addItem("Weekly");
    period.addItem("Montly");
    period.setNullSelectionAllowed(false);
    period.select("Weekly");
    period.addStyleName("small");
    period.setWidth("10em");
    wrap.addComponent(period);
    form.addComponent(wrap);

    section = new Label("Additional Info");
    section.addStyleName("h4");
    section.addStyleName("colored");
    form.addComponent(section);

    TextField website = new TextField("Website");
    website.setInputPrompt("http://");
    website.setWidth("100%");
    form.addComponent(website);

    TextArea shortbio = new TextArea("Short Bio");
    shortbio.setValue(
            "Quis aute iure reprehenderit in voluptate velit esse. Cras mattis iudicium purus sit amet fermentum.");
    shortbio.setWidth("100%");
    shortbio.setRows(2);
    form.addComponent(shortbio);

    final RichTextArea bio = new RichTextArea("Bio");
    bio.setWidth("100%");
    bio.setValue(
            "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi  dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>");
    form.addComponent(bio);

    form.setReadOnly(true);
    bio.setReadOnly(true);

    Button edit = new Button("Edit", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            boolean readOnly = form.isReadOnly();
            if (readOnly) {
                bio.setReadOnly(false);
                form.setReadOnly(false);
                form.removeStyleName("light");
                event.getButton().setCaption("Save");
                event.getButton().addStyleName("primary");
            } else {
                bio.setReadOnly(true);
                form.setReadOnly(true);
                form.addStyleName("light");
                event.getButton().setCaption("Edit");
                event.getButton().removeStyleName("primary");
            }
        }
    });

    HorizontalLayout footer = new HorizontalLayout();
    footer.setMargin(new MarginInfo(true, false, true, false));
    footer.setSpacing(true);
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    form.addComponent(footer);
    footer.addComponent(edit);

    Label lastModified = new Label("Last modified by you a minute ago");
    lastModified.addStyleName("light");
    footer.addComponent(lastModified);
}

From source file:com.esspl.datagen.ui.TableSelectorView.java

License:Open Source License

protected Component createSelectors() throws SQLException {
    FormLayout l = new FormLayout();
    l.setWidth("100%");
    l.setSpacing(false);/*from w w  w . j  av  a  2 s. c om*/
    l.setMargin(true, false, true, false);

    String catalogTerm = (metadataRetriever != null) ? metadataRetriever.getCatalogTerm() : "DataBase";
    catalogTerm = catalogTerm.substring(0, 1).toUpperCase() + catalogTerm.substring(1, catalogTerm.length());
    List<String> catalogNames = (metadataRetriever != null) ? metadataRetriever.getCatalogs()
            : new ArrayList<String>();
    final ComboBox catalogs = new ComboBox(catalogTerm + ":", catalogNames);
    catalogs.setWidth("100%");
    catalogs.setNullSelectionAllowed(false);
    catalogs.setImmediate(true);
    catalogs.setVisible(!catalogNames.isEmpty());

    String schemaTerm = (metadataRetriever != null) ? metadataRetriever.getSchemaTerm().toLowerCase()
            : "DataBase";
    schemaTerm = schemaTerm.substring(0, 1).toUpperCase() + schemaTerm.substring(1, schemaTerm.length());

    List<String> schemaNames = (metadataRetriever != null) ? metadataRetriever.getSchemas()
            : new ArrayList<String>();
    final ComboBox schemas = new ComboBox(schemaTerm + ":", schemaNames);
    schemas.setWidth("100%");
    schemas.setNullSelectionAllowed(false);
    schemas.setImmediate(true);
    schemas.setVisible(!schemaNames.isEmpty());

    List<String> tableTypesList = (metadataRetriever != null) ? metadataRetriever.getTableTypes()
            : new ArrayList<String>();
    final ComboBox tableTypes = new ComboBox("Object:", tableTypesList);
    if (tableTypesList.contains("TABLE"))
        tableTypes.select("TABLE");
    tableTypes.setWidth("100%");
    tableTypes.setNullSelectionAllowed(false);
    tableTypes.setImmediate(true);

    ValueChangeListener valueChangeListener = new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            updateTableList(catalogs, schemas, tableTypes);
        }
    };

    catalogs.addListener(valueChangeListener);
    schemas.addListener(valueChangeListener);
    tableTypes.addListener(valueChangeListener);

    l.addComponent(catalogs);
    l.addComponent(schemas);
    l.addComponent(tableTypes);
    return l;
}

From source file:com.etest.valo.Forms.java

License:Apache License

public Forms() {
    setSpacing(true);/*from  w  w w.  j  a  v a2  s .co m*/
    setMargin(true);

    Label title = new Label("Forms");
    title.addStyleName("h1");
    addComponent(title);

    final FormLayout form = new FormLayout();
    form.setMargin(false);
    form.setWidth("800px");
    form.addStyleName("light");
    addComponent(form);

    Label section = new Label("Personal Info");
    section.addStyleName("h2");
    section.addStyleName("colored");
    form.addComponent(section);
    StringGenerator sg = new StringGenerator();

    TextField name = new TextField("Name");
    name.setValue(sg.nextString(true) + " " + sg.nextString(true));
    name.setWidth("50%");
    form.addComponent(name);

    DateField birthday = new DateField("Birthday");
    birthday.setValue(new Date(80, 0, 31));
    form.addComponent(birthday);

    TextField username = new TextField("Username");
    username.setValue(sg.nextString(false) + sg.nextString(false));
    username.setRequired(true);
    form.addComponent(username);

    OptionGroup sex = new OptionGroup("Sex");
    sex.addItem("Female");
    sex.addItem("Male");
    sex.select("Male");
    sex.addStyleName("horizontal");
    form.addComponent(sex);

    section = new Label("Contact Info");
    section.addStyleName("h3");
    section.addStyleName("colored");
    form.addComponent(section);

    TextField email = new TextField("Email");
    email.setValue(sg.nextString(false) + "@" + sg.nextString(false) + ".com");
    email.setWidth("50%");
    email.setRequired(true);
    form.addComponent(email);

    TextField location = new TextField("Location");
    location.setValue(sg.nextString(true) + ", " + sg.nextString(true));
    location.setWidth("50%");
    location.setComponentError(new UserError("This address doesn't exist"));
    form.addComponent(location);

    TextField phone = new TextField("Phone");
    phone.setWidth("50%");
    form.addComponent(phone);

    HorizontalLayout wrap = new HorizontalLayout();
    wrap.setSpacing(true);
    wrap.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    wrap.setCaption("Newsletter");
    CheckBox newsletter = new CheckBox("Subscribe to newsletter", true);
    wrap.addComponent(newsletter);

    ComboBox period = new ComboBox();
    period.setTextInputAllowed(false);
    period.addItem("Daily");
    period.addItem("Weekly");
    period.addItem("Monthly");
    period.setNullSelectionAllowed(false);
    period.select("Weekly");
    period.addStyleName("small");
    period.setWidth("10em");
    wrap.addComponent(period);
    form.addComponent(wrap);

    section = new Label("Additional Info");
    section.addStyleName("h4");
    section.addStyleName("colored");
    form.addComponent(section);

    TextField website = new TextField("Website");
    website.setInputPrompt("http://");
    website.setWidth("100%");
    form.addComponent(website);

    TextArea shortbio = new TextArea("Short Bio");
    shortbio.setValue(
            "Quis aute iure reprehenderit in voluptate velit esse. Cras mattis iudicium purus sit amet fermentum.");
    shortbio.setWidth("100%");
    shortbio.setRows(2);
    form.addComponent(shortbio);

    final RichTextArea bio = new RichTextArea("Bio");
    bio.setWidth("100%");
    bio.setValue(
            "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi  dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>");
    form.addComponent(bio);

    form.setReadOnly(true);
    bio.setReadOnly(true);

    Button edit = new Button("Edit", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            boolean readOnly = form.isReadOnly();
            if (readOnly) {
                bio.setReadOnly(false);
                form.setReadOnly(false);
                form.removeStyleName("light");
                event.getButton().setCaption("Save");
                event.getButton().addStyleName("primary");
            } else {
                bio.setReadOnly(true);
                form.setReadOnly(true);
                form.addStyleName("light");
                event.getButton().setCaption("Edit");
                event.getButton().removeStyleName("primary");
            }
        }
    });

    HorizontalLayout footer = new HorizontalLayout();
    footer.setMargin(new MarginInfo(true, false, true, false));
    footer.setSpacing(true);
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    form.addComponent(footer);
    footer.addComponent(edit);

    Label lastModified = new Label("Last modified by you a minute ago");
    lastModified.addStyleName("light");
    footer.addComponent(lastModified);
}

From source file:com.etest.view.systemadministration.faculty.FacultyFormWindow.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setSpacing(true);//from   w  w w. ja  v a 2s .co m
    form.setMargin(true);

    firstname.setWidth("100%");
    firstname.setIcon(FontAwesome.INFO);
    firstname.setRequired(true);
    firstname.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    form.addComponent(firstname);

    middlename.setWidth("100%");
    middlename.setIcon(FontAwesome.INFO);
    middlename.setRequired(true);
    middlename.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    form.addComponent(middlename);

    lastname.setWidth("100%");
    lastname.setIcon(FontAwesome.INFO);
    lastname.setRequired(true);
    lastname.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    form.addComponent(lastname);

    userType.setCaption("User Type: ");
    userType.setIcon(FontAwesome.USER_MD);
    userType.setRequired(true);
    form.addComponent(userType);

    username.setWidth("100%");
    username.setIcon(FontAwesome.USER);
    username.setRequired(true);
    username.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    form.addComponent(username);

    password1.setWidth("100%");
    password1.setIcon(FontAwesome.CODE);
    password1.setRequired(true);
    password1.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    form.addComponent(password1);

    password2.setWidth("100%");
    password2.setIcon(FontAwesome.CODE);
    password2.setRequired(true);
    password2.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    form.addComponent(password2);

    facultyBtn.setCaption(getButtonCaption());
    facultyBtn.setWidth("100%");
    facultyBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    facultyBtn.addStyleName(ValoTheme.BUTTON_SMALL);
    facultyBtn.addClickListener(buttonClickListener);
    form.addComponent(facultyBtn);

    if (getFacultyId() != 0) {
        Users u = fs.getFacultyInfoById(getFacultyId());
        firstname.setValue(u.getFirstname());
        middlename.setValue(u.getMiddlename());
        lastname.setValue(u.getLastname());
        username.setValue(u.getUsername_());
        userType.setValue(CommonVariableMap.getFacultyUserType(u.getUserType()));
        password1.setValue(u.getPassword_());
        password2.setValue(u.getPassword_());
    }

    return form;
}

From source file:com.etest.view.systemadministration.SemestralTeam.AddSemestralTeamMembersWindow.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setSpacing(true);//from  ww  w.  ja va  2s .c om

    faculty = CommonComboBox.getAllFacultyExceptTeamLeader("Add Team Member.. ", getFacultyId());
    faculty.setWidth("60%");
    faculty.setIcon(FontAwesome.USER);
    form.addComponent(faculty);

    addMemberBtn.setWidth("60%");
    addMemberBtn.setIcon(FontAwesome.SAVE);
    addMemberBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    addMemberBtn.addStyleName(ValoTheme.BUTTON_SMALL);
    addMemberBtn.addClickListener(buttonClickListener);
    form.addComponent(addMemberBtn);

    populateDataTable();
    form.addComponent(table);

    return form;
}

From source file:com.etest.view.systemadministration.SemestralTeamUI.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("400px");
    form.setSpacing(true);/*from   w w  w  .jav  a2 s .co  m*/

    subjects = CommonComboBox.getSubjectFromCurriculum("Subject..");
    subjects.setCaption("Curriculum: ");
    subjects.setIcon(FontAwesome.SEARCH);
    form.addComponent(subjects);

    schoolYear = CommonComboBox.getSchoolYear("School Year..");
    schoolYear.setCaption("School Year: ");
    schoolYear.setIcon(FontAwesome.SEARCH);
    form.addComponent(schoolYear);

    semester = CommonComboBox.getNormCourseOfferingComboBox("Semester..");
    semester.setCaption("Semester: ");
    semester.setIcon(FontAwesome.SEARCH);
    form.addComponent(semester);

    faculty = CommonComboBox.getAllFaculty("Select Faculty..");
    faculty.setCaption("Team Leader: ");
    faculty.setIcon(FontAwesome.USER);
    form.addComponent(faculty);

    Button saveBtn = new Button("Enroll Semestral Team");
    saveBtn.setWidth("100%");
    saveBtn.setIcon(FontAwesome.SAVE);
    saveBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    saveBtn.addStyleName(ValoTheme.BUTTON_SMALL);
    saveBtn.addClickListener(saveBtnClickListener);
    saveBtn.setImmediate(true);
    form.addComponent(saveBtn);

    return form;
}

From source file:com.etest.view.systemadministration.syllabus.SyllabusFormWindow.java

Component buildSyllabusForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);/*from  w w w. j  a  va 2 s  . c  o m*/

    subjects.setCaption("Subject: ");
    subjects.setWidth("50%");
    subjects.setIcon(FontAwesome.BOOK);
    subjects.addStyleName(ValoTheme.COMBOBOX_SMALL);
    form.addComponent(subjects);

    topicNo.setCaption("Topic No: ");
    topicNo.setWidth("50%");
    topicNo.setIcon(FontAwesome.TAG);
    topicNo.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    form.addComponent(topicNo);

    topic.setCaption("Topic: ");
    topic.setWidth("100%");
    topic.setIcon(FontAwesome.TAG);
    topic.setInputPrompt("Enter Topic..");
    topic.setRows(3);
    topic.addStyleName(ValoTheme.TEXTAREA_SMALL);
    form.addComponent(topic);

    estimatedTime.setCaption("Estimated Time: ");
    estimatedTime.setWidth("50%");
    estimatedTime.setIcon(FontAwesome.TAG);
    estimatedTime.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    form.addComponent(estimatedTime);

    Button save = new Button("SAVE");
    save.setWidth("50%");
    save.setIcon(FontAwesome.SAVE);
    save.addStyleName(ValoTheme.BUTTON_PRIMARY);
    save.addStyleName(ValoTheme.BUTTON_SMALL);
    save.addClickListener(buttonClickListener);

    Button update = new Button("UPDATE");
    update.setWidth("60%");
    update.setIcon(FontAwesome.PENCIL);
    update.addStyleName(ValoTheme.BUTTON_PRIMARY);
    update.addStyleName(ValoTheme.BUTTON_SMALL);
    update.addClickListener(buttonClickListener);

    Button remove = new Button("REMOVE");
    remove.setWidth("60%");
    remove.setIcon(FontAwesome.TRASH_O);
    remove.addStyleName(ValoTheme.BUTTON_PRIMARY);
    remove.addStyleName(ValoTheme.BUTTON_SMALL);
    remove.addClickListener(buttonClickListener);

    if (getSyllabusId() != 0) {
        s = ss.getSyllabusById(syllabusId);
        subjects.setValue(s.getCurriculumId());
        topicNo.setValue(String.valueOf(s.getTopicNo()));
        estimatedTime.setValue(String.valueOf(s.getEstimatedTime()));
        topic.setValue(s.getTopic());

        if (getButtonCaption().equals("edit")) {
            form.addComponent(update);
        } else {
            form.addComponent(remove);
        }
    } else {
        form.addComponent(save);
    }

    return form;
}

From source file:com.etest.view.testbank.CellCaseWindow.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);/*from  w  w  w  .ja v a  2s .c  o  m*/

    subject.setCaption("Subject: ");
    subject.setWidth("50%");
    subject.addValueChangeListener((new CurriculumPropertyChangeListener(topic)));
    form.addComponent(subject);

    topic.setCaption("Topic: ");
    topic.setWidth("80%");
    topic.setInputPrompt("Select a Topic..");
    topic.addStyleName(ValoTheme.COMBOBOX_SMALL);
    form.addComponent(topic);

    caseTopic = new TextArea();
    caseTopic.setCaption("Case: ");
    caseTopic.setWidth("100%");
    caseTopic.setRows(5);
    form.addComponent(caseTopic);

    HorizontalLayout hlayout = new HorizontalLayout();
    hlayout.setWidth("100%");
    hlayout.setSpacing(true);

    Button save = new Button("SAVE");
    save.setWidth("200px");
    save.setIcon(FontAwesome.SAVE);
    save.addStyleName(ValoTheme.BUTTON_PRIMARY);
    save.addStyleName(ValoTheme.BUTTON_SMALL);
    save.addClickListener(buttonClickListener);

    Button modify = new Button("MODIFY");
    modify.setWidth("200px");
    modify.setIcon(FontAwesome.EDIT);
    modify.addStyleName(ValoTheme.BUTTON_PRIMARY);
    modify.addStyleName(ValoTheme.BUTTON_SMALL);
    modify.addClickListener(buttonClickListener);

    Button approve = new Button("APPROVE");
    approve.setWidth("200px");
    approve.setIcon(FontAwesome.THUMBS_UP);
    approve.addStyleName(ValoTheme.BUTTON_PRIMARY);
    approve.addStyleName(ValoTheme.BUTTON_SMALL);
    approve.setEnabled(UserAccess.approve());
    approve.addClickListener(buttonClickListener);

    Button delete = new Button("DELETE");
    delete.setWidth("200px");
    delete.setIcon(FontAwesome.TRASH_O);
    delete.addStyleName(ValoTheme.BUTTON_PRIMARY);
    delete.addStyleName(ValoTheme.BUTTON_SMALL);
    delete.setEnabled(UserAccess.delete());
    delete.addClickListener(buttonClickListener);

    if (getCellCaseId() != 0) {
        CellCase cc = ccs.getCellCaseById(getCellCaseId());
        subject.setValue(cc.getCurriculumId());
        topic.setValue(cc.getSyllabusId());
        caseTopic.setValue(cc.getCaseTopic());

        approve.setVisible(cc.getApprovalStatus() == 0);
        hlayout.addComponent(approve);
        hlayout.setComponentAlignment(approve, Alignment.MIDDLE_RIGHT);

        hlayout.addComponent(modify);
        hlayout.setComponentAlignment(modify, Alignment.MIDDLE_RIGHT);

        hlayout.addComponent(delete);
        hlayout.setComponentAlignment(delete, Alignment.MIDDLE_RIGHT);
    } else {
        hlayout.addComponent(save);
        hlayout.setComponentAlignment(save, Alignment.MIDDLE_RIGHT);
    }

    form.addComponent(hlayout);
    form.setComponentAlignment(hlayout, Alignment.MIDDLE_RIGHT);

    return form;
}

From source file:com.etest.view.testbank.cellitem.CellCaseItemWindow.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);/*from   ww  w .  j  a v  a2s  .  c  om*/
    form.setSpacing(true);

    CellCase cc = ccs.getCellCaseById(getCellCaseId());
    Panel panel = new Panel();
    panel.setWidth("100%");
    panel.addStyleName(ValoTheme.PANEL_BORDERLESS);

    Label caseLabel = new Label();
    caseLabel.setCaption("CASE: ");
    caseLabel.setStyleName("bold-font-style");
    caseLabel.setWidth("80px");

    Label caseTopic = new Label();
    caseTopic.setValue(caseLabel.getCaption() + cc.getCaseTopic());
    caseTopic.setContentMode(ContentMode.RAW);
    caseTopic.addStyleName("wrapline");

    panel.setContent(caseTopic);
    form.addComponent(panel);

    form.addComponent(table);

    HorizontalLayout v = new HorizontalLayout();
    v.setWidth("100%");

    Button create = new Button("CREATE NEW STEM");
    create.setWidthUndefined();
    create.addStyleName(ValoTheme.BUTTON_LINK);
    create.addStyleName(ValoTheme.BUTTON_TINY);
    create.addStyleName(ValoTheme.BUTTON_QUIET);
    create.addClickListener(modifyBtnClickListener);
    v.addComponent(create);
    v.setComponentAlignment(create, Alignment.MIDDLE_RIGHT);
    form.addComponent(v);

    return form;
}