Package com.vaadin.ui

Examples of com.vaadin.ui.FormLayout


                cssLayout.setStyleName("borders");
            }
            l = cssLayout;
        } else if (layoutClass == FormLayout.class) {
            if (formLayout == null) {
                formLayout = new FormLayout();
                formLayout.setStyleName("borders");
            }
            l = formLayout;
        } else {
            return null;
View Full Code Here


        return 2706;
    }

    @Override
    protected void setup() {
        FormLayout formLayout = new FormLayout();
        CheckBox control = new CheckBox("Messages On/Off");
        control.addListener(new ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {
                messages.setVisible((Boolean) event.getProperty().getValue());
                messages.setRequired(true);
                messages.setCaption("Messages visible");
            }

        });
        control.setImmediate(true);
        formLayout.addComponent(control);

        messages = new TextArea("Messages hidden");
        messages.setRows(10);
        messages.setColumns(40);
        messages.setVisible(false);
        messages.setEnabled(false);
        formLayout.addComponent(messages);

        addComponent(formLayout);
    }
View Full Code Here

public class FormLayoutTest extends AbstractIndexedLayoutTest {

    @Override
    protected Layout createLayout() {
        return new FormLayout();
    }
View Full Code Here

    Component[] children = new Component[] { new Label("A"), new Label("B"),
            new Label("C"), new Label("D") };

    @Test
    public void testConstructorWithComponents() {
        FormLayout l = new FormLayout(children);
        assertOrder(l, new int[] { 0, 1, 2, 3 });
    }
View Full Code Here

        assertOrder(l, new int[] { 0, 1, 2, 3 });
    }

    @Test
    public void testAddComponents() {
        FormLayout l = new FormLayout();
        l.addComponents(children);
        assertOrder(l, new int[] { 0, 1, 2, 3 });
    }
View Full Code Here

        modal.setResizable(false);
        modal.setDraggable(false);
        modal.setWidth("300px");
        final FieldGroup fieldGroup = new FieldGroup();

        FormLayout formLayout = new FormLayout();
        TextField captionField = new TextField("Caption");
        captionField.setImmediate(true);
        TextField descriptionField = new TextField("Description");
        descriptionField.setImmediate(true);
        DateField startField = new DateField("Start");
        startField.setResolution(Resolution.MINUTE);
        startField.setImmediate(true);
        DateField endField = new DateField("End");
        endField.setImmediate(true);
        endField.setResolution(Resolution.MINUTE);

        formLayout.addComponent(captionField);
        formLayout.addComponent(descriptionField);
        formLayout.addComponent(startField);
        formLayout.addComponent(endField);

        fieldGroup.bind(captionField, ContainerEventProvider.CAPTION_PROPERTY);
        fieldGroup.bind(descriptionField,
                ContainerEventProvider.DESCRIPTION_PROPERTY);
        fieldGroup.bind(startField, ContainerEventProvider.STARTDATE_PROPERTY);
View Full Code Here

public class TextAreaEventPropagation extends AbstractTestUIWithLog {

    @Override
    protected void setup(VaadinRequest request) {

        FormLayout form = new FormLayout();
        TextArea textArea = new TextArea("Text input");
        TextField textField = new TextField("Text field input");

        Button enterButton = new Button("Enter");
        enterButton.setClickShortcut(KeyCode.ENTER);
        enterButton.addClickListener(new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {

                log("Enter button pressed");
            }
        });

        Button shiftEnterButton = new Button("Shift-Enter");
        shiftEnterButton.setClickShortcut(KeyCode.ENTER, ModifierKey.SHIFT);
        shiftEnterButton.addClickListener(new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {

                log("Shift-Enter button pressed");
            }
        });

        Button ctrlEnterButton = new Button("Ctrl-Enter");
        ctrlEnterButton.setClickShortcut(KeyCode.ENTER, ModifierKey.CTRL);
        ctrlEnterButton.addClickListener(new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {

                log("Ctrl-Enter button pressed");
            }
        });

        Button escapeButton = new Button("Escape");
        escapeButton.setClickShortcut(KeyCode.ESCAPE);
        escapeButton.addClickListener(new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                log("Escape button pressed");
            }
        });

        form.addComponent(textArea);
        form.addComponent(textField);
        form.addComponent(enterButton);
        form.addComponent(escapeButton);
        form.addComponent(shiftEnterButton);
        form.addComponent(ctrlEnterButton);
        addComponent(form);

    }
View Full Code Here

    protected void setup(VaadinRequest request) {
        final VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        setContent(layout);

        final FormLayout formLayout = new FormLayout();

        final ComboBox combo = new ComboBox("Item:");
        combo.addItem("Item 1");
        combo.addItem("Item 2");
        combo.addItem("Item 3");
        combo.addItem("Item 4");
        combo.addValueChangeListener(new MyValueChangeListener());
        combo.setImmediate(true);

        Button btn1 = new Button("Click me");
        btn1.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                log.log("you clicked me");
            }
        });

        formLayout.addComponent(combo);
        formLayout.addComponent(btn1);

        layout.addComponent(formLayout);

        Button btn = new Button("Enable/Disable combobox",
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        combo.setEnabled(!combo.isEnabled());
                    }
                });
        layout.addComponent(btn);
        btn = new Button("Enable/Disable parent", new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                formLayout.setEnabled(!formLayout.isEnabled());
            }
        });
        layout.addComponent(btn);

    }
View Full Code Here

                cssLayout.setStyleName("borders");
            }
            l = cssLayout;
        } else if (layoutClass == FormLayout.class) {
            if (formLayout == null) {
                formLayout = new FormLayout();
                formLayout.setStyleName("borders");
            }
            l = formLayout;
        } else {
            return null;
View Full Code Here

        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);
View Full Code Here

TOP

Related Classes of com.vaadin.ui.FormLayout

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.