Package com.vaadin.ui

Examples of com.vaadin.ui.ComboBox


        return value;
    }

    private ComboBox getComboBox(final Label value) {
        final ComboBox combobox = new ComboBox("MyCaption");
        combobox.setDescription("ComboBox with more than 10 elements in it's dropdown list.");

        combobox.setImmediate(true);

        for (int i = 1; i <= ITEM_COUNT; i++) {
            combobox.addItem(String.format(ITEM_NAME_TEMPLATE, i));
        }

        combobox.addValueChangeListener(new ValueChangeListener() {
            @Override
            public void valueChange(ValueChangeEvent event) {
                value.setValue(String.valueOf(event.getProperty().getValue()));
            }
        });
View Full Code Here


        return "Testcase for ComboBox in PopupView. Make the window narrower than the popup: the focused (2) one wraps button to second row AND seems narrower than (1), the unfocused one (1) works as expected.";
    }

    @Override
    protected void setup() {
        final ComboBox cb1 = new ComboBox();
        cb1.setWidth("260px");
        // cb.focus();
        PopupView pv1 = new PopupView("<u>1. expected (click)</u>", cb1);
        getLayout().addComponent(pv1);

        final ComboBox cb2 = new ComboBox();
        cb2.setWidth("260px");
        PopupView pv2 = new PopupView("<u>2. focused (click)</u>", cb2);
        pv2.addListener(new PopupVisibilityListener() {

            @Override
            public void popupVisibilityChange(PopupVisibilityEvent event) {
                cb2.focus();
            }
        });
        getLayout().addComponent(pv2);

    }
View Full Code Here

    }

    private void createUI(AbstractOrderedLayout layout) {
        VerticalLayout ol;
        Panel p;
        ComboBox cb;

        ol = new VerticalLayout();
        p = new Panel(ol);
        p.setCaption("Combobox without width");
        // p.setWidth("100px");
        cb = new ComboBox();
        // cb.setCaption("A combobox");
        // cb.setWidth("100%");
        ol.addComponent(cb);
        layout.addComponent(p);

        ol = new VerticalLayout();
        p = new Panel(ol);
        p.setCaption("Combobox without width with caption");
        // p.setWidth("100px");
        cb = new ComboBox();
        cb.setCaption("A combobox");
        // cb.setWidth("100px");
        ol.addComponent(cb);
        layout.addComponent(p);

        ol = new VerticalLayout();
        p = new Panel(ol);
        p.setCaption("Combobox 100px wide");
        // p.setWidth("100px");
        cb = new ComboBox();
        // cb.setCaption("A combobox");
        cb.setWidth("100px");
        ol.addComponent(cb);
        layout.addComponent(p);

        ol = new VerticalLayout();
        p = new Panel(ol);
        p.setCaption("Combobox 100px wide with caption");
        // p.setWidth("100px");
        cb = new ComboBox();
        cb.setCaption("A combobox");
        cb.setWidth("100px");
        ol.addComponent(cb);
        layout.addComponent(p);

        ol = new VerticalLayout();
        p = new Panel(ol);
        p.setCaption("Combobox 500px wide");
        // p.setWidth("500px");
        cb = new ComboBox();
        // cb.setCaption("A combobox");
        cb.setWidth("500px");
        ol.addComponent(cb);
        layout.addComponent(p);

        ol = new VerticalLayout();
        p = new Panel(ol);
        p.setCaption("Combobox 500px wide with caption");
        // p.setWidth("500px");
        cb = new ComboBox();
        cb.setCaption("A combobox");
        cb.setWidth("500px");
        ol.addComponent(cb);
        layout.addComponent(p);

        ol = new VerticalLayout();
        p = new Panel(ol);
        p.setCaption("Combobox 100% wide inside 200px panel");
        p.setWidth("200px");
        ol.setWidth("100%");
        cb = new ComboBox();
        // cb.setCaption("A combobox");
        cb.setWidth("100%");
        // cb.setWidth("500px");
        ol.addComponent(cb);
        layout.addComponent(p);

        ol = new VerticalLayout();
        p = new Panel(ol);
        p.setCaption("Combobox 100% wide inside 200px panel with caption");
        p.setWidth("200px");
        ol.setWidth("100%");
        cb = new ComboBox();
        cb.setCaption("A combobox");
        cb.setWidth("100%");
        ol.addComponent(cb);
        layout.addComponent(p);

    }
View Full Code Here

        FormLayout layout = new FormLayout();
        final TextField textField = new TextField("TextField");
        textField.setEnabled(false);
        layout.addComponent(textField);

        final ComboBox combobox = new ComboBox("Combobox");
        combobox.setEnabled(false);
        layout.addComponent(combobox);

        final NativeSelect nativeSelect = new NativeSelect("NativeSelect");
        nativeSelect.setEnabled(false);
        layout.addComponent(nativeSelect);

        final CheckBox checkBox = new CheckBox("Checkbox");
        checkBox.setEnabled(false);
        layout.addComponent(checkBox);

        layout.addComponent(new Button("Toggle components enabled",
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        combobox.setEnabled(!combobox.isEnabled());
                        textField.setEnabled(!textField.isEnabled());
                        checkBox.setEnabled(!checkBox.isEnabled());
                        nativeSelect.setEnabled(!nativeSelect.isEnabled());
                    }
                }));
View Full Code Here

        addComponent(btClear);
    }

    private ComboBox createComboBox(String caption) {
        ComboBox cb = new ComboBox(caption);
        cb.setImmediate(true);
        cb.addItem(1);
        cb.setItemCaption(1, "icon test");
        cb.setItemIcon(1, new ThemeResource("menubar/img/checked.png"));
        return cb;
    }
View Full Code Here

                }
                combo.setValue("Item 3");
            }
        });

        combo = new ComboBox();
        combo.setImmediate(true);
        combo.setContainerDataSource(ds1);
        combo.addListener(new ValueChangeListener() {

            @Override
View Full Code Here

    @Override
    protected void setup(VaadinRequest request) {
        (getLayout()).setSpacing(true);

        ComboBox cb = getComboBox("A combobox", false, "default");
        addComponent(cb);

        cb = getComboBox("A combobox with input prompt", false, "default-prompt");
        cb.setInputPrompt("Please select");
        addComponent(cb);

        cb = getComboBox("A combobox with null item", true, "null");
        addComponent(cb);

        cb = getComboBox("A combobox with null item and input prompt", true, "null-prompt");
        cb.setInputPrompt("Please select");
        addComponent(cb);

        cb = getComboBox("A combobox with filteringMode off", false, "filtering-off");
        cb.setFilteringMode(FilteringMode.OFF);
        addComponent(cb);

    }
View Full Code Here

    protected Integer getTicketNumber() {
        return 3268;
    }

    private ComboBox getComboBox(String caption, boolean addNullItem, String id) {
        ComboBox cb = new ComboBox(caption);
        cb.setImmediate(true);
        if (addNullItem) {
            cb.addItem("Null item");
            cb.setNullSelectionItemId("Null item");
        }
        cb.addItem("Value 1");
        cb.addItem("Value 2");
        cb.addItem("Value 3");

        cb.setId(id);

        return cb;
    }
View Full Code Here

public class ComboBoxInputPrompt extends AbstractTestUI {

    @Override
    protected void setup(VaadinRequest request) {
        final ComboBox cb1 = new ComboBox("Normal");
        cb1.setInputPrompt("Normal input prompt");

        final ComboBox cb2 = new ComboBox("Disabled");
        cb2.setEnabled(false);
        cb2.setInputPrompt("Disabled input prompt");

        final ComboBox cb3 = new ComboBox("Read-only");
        cb3.setReadOnly(true);
        cb3.setInputPrompt("Read-only input prompt");

        Button enableButton = new Button("Toggle enabled",
                new Button.ClickListener() {

                    @Override
                    public void buttonClick(ClickEvent event) {
                        cb2.setEnabled(!cb2.isEnabled());
                        cb3.setReadOnly(!cb3.isReadOnly());
                    }
                });

        addComponents(cb1, cb2, cb3, enableButton);
    }
View Full Code Here

        BeanItemContainer<Person> container = new BeanItemContainer<Person>(
                Person.class);
        container.addAll(list);

        ComboBox box = new ComboBox("Duplicate captions test Box");
        box.setId("ComboBox");
        box.setImmediate(true);
        box.addValueChangeListener(new ValueChangeListener() {

            @Override
            public void valueChange(
                    com.vaadin.data.Property.ValueChangeEvent event) {
                Person p = (Person) event.getProperty().getValue();
                log.log("Person = " + p.getFirstName() + " " + p.getLastName());
            }
        });
        box.setContainerDataSource(container);
        box.setItemCaptionMode(ItemCaptionMode.PROPERTY);
        box.setItemCaptionPropertyId("lastName");

        addComponent(log);

        addComponent(box);
        addComponent(new Button("Focus this"));
View Full Code Here

TOP

Related Classes of com.vaadin.ui.ComboBox

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.