Package com.vaadin.ui

Examples of com.vaadin.ui.AbstractSelect$DefaultNewItemHandler


    }

    private <T extends Field> T createEnumField(Class<?> type,
            Class<T> fieldType) {
        if (AbstractSelect.class.isAssignableFrom(fieldType)) {
            AbstractSelect s = createCompatibleSelect((Class<? extends AbstractSelect>) fieldType);
            populateWithEnumData(s, (Class<? extends Enum>) type);
            return (T) s;
        }

        return null;
View Full Code Here


        return (T) field;
    }

    protected AbstractSelect createCompatibleSelect(
            Class<? extends AbstractSelect> fieldType) {
        AbstractSelect select;
        if (fieldType.isAssignableFrom(ListSelect.class)) {
            select = new ListSelect();
            select.setMultiSelect(false);
        } else if (fieldType.isAssignableFrom(NativeSelect.class)) {
            select = new NativeSelect();
        } else if (fieldType.isAssignableFrom(OptionGroup.class)) {
            select = new OptionGroup();
            select.setMultiSelect(false);
        } else if (fieldType.isAssignableFrom(Table.class)) {
            Table t = new Table();
            t.setSelectable(true);
            select = t;
        } else {
            select = new ComboBox(null);
        }
        select.setImmediate(true);
        select.setNullSelectionAllowed(false);

        return select;
    }
View Full Code Here

                        if (asModal.getValue().booleanValue()) {
                            w.setModal(true);
                        }

                        AbstractSelect s1 = new OptionGroup();
                        s1.setCaption("1. Select output format");
                        s1.addItem("Excel sheet");
                        s1.addItem("CSV plain text");
                        s1.setValue("Excel sheet");
                        s1.setImmediate(true);

                        s2 = new Select();
                        s2.addItem("Separate by comma (,)");
                        s2.addItem("Separate by colon (:)");
                        s2.addItem("Separate by semicolon (;)");
                        s2.setEnabled(false);

                        s1.addListener(new ValueChangeListener() {

                            @Override
                            public void valueChange(ValueChangeEvent event) {
                                String v = (String) event.getProperty()
                                        .getValue();
View Full Code Here

        // Selects, caption + item icons
        Class<?>[] selects = { ComboBox.class, NativeSelect.class,
                ListSelect.class, TwinColSelect.class, OptionGroup.class };
        for (Class<?> clazz : selects) {
            AbstractSelect sel;
            try {
                sel = (AbstractSelect) clazz.newInstance();
            } catch (Exception e) {
                e.printStackTrace();
                continue;
            }
            sel.setCaption(clazz.getSimpleName());
            sel.setIcon(icon);
            sel.addItem("One");
            sel.setItemIcon("One", icon);
            sel.addItem("Two");
            sel.setItemIcon("Two", icon);
            gl.addComponent(sel);
        }

        // MenuBar, caption + item + sub-item icons
        MenuBar menu = new MenuBar();
View Full Code Here

                    Table new_name = (Table) c;
                    new_name.setContainerDataSource(TestForTablesInitialColumnWidthLogicRendering
                            .getTestTable(5, 100).getContainerDataSource());

                } else {
                    AbstractSelect new_name = (AbstractSelect) c;
                    Container cont = TestForTablesInitialColumnWidthLogicRendering
                            .getTestTable(2, 8).getContainerDataSource();
                    new_name.setContainerDataSource(cont);
                    new_name.setItemCaptionPropertyId(cont
                            .getContainerPropertyIds().iterator().next());

                }
            } else if (c instanceof ComponentContainer) {
                ComponentContainer new_name = (ComponentContainer) c;
                new_name.addComponent(new Label("component 1 in test container"));
                new_name.addComponent(new Button("component 2"));
            } else if (c instanceof Embedded) {
                Embedded em = (Embedded) c;
                em.setSource(new ThemeResource("test.png"));
            } else if (c instanceof Label) {
                ((Label) c).setValue("Test label");
View Full Code Here

        Panel test = createTestBench(new CheckBox());
        test.setCaption("CheckBox (configured from button)");
        main.addComponent(test);

        AbstractSelect s = new TwinColSelect();
        fillSelect(s, 20);
        test = createTestBench(s);
        test.setCaption("TwinColSelect (configured from select)");
        main.addComponent(test);

        s = new NativeSelect();
        fillSelect(s, 20);
        test = createTestBench(s);
        test.setCaption("Native (configured from select)");
        main.addComponent(test);

        s = new OptionGroup();
        fillSelect(s, 20);
        test = createTestBench(s);
        test.setCaption("OptionGroup (configured from select)");
        main.addComponent(test);

        s = new OptionGroup();
        fillSelect(s, 20);
        s.setMultiSelect(true);
        test = createTestBench(s);
        test.setCaption("OptionGroup + multiselect manually (configured from select)");
        main.addComponent(test);

        final Button b = new Button("refresh view", new Button.ClickListener() {
View Full Code Here

        f.setCaption(f.getClass().getSimpleName());
        lo.addComponent(f);

        if (f instanceof AbstractSelect) {
            AbstractSelect s = (AbstractSelect) f;
            s.addItem("Foo");
            s.addItem("Bar");
        }

        Button focus = new Button("focus");
        focus.addListener(new Button.ClickListener() {
            @Override
View Full Code Here

        HorizontalLayout hl = new HorizontalLayout();
        hl.setSpacing(true);
        hl.setMargin(new MarginInfo(true, false, false, false));
        l.addComponent(hl);

        AbstractSelect cb = new ComboBox();
        AbstractSelect nat = new NativeSelect();
        AbstractSelect list = new ListSelect();
        AbstractSelect twincol = new TwinColSelect();

        for (int i = 0; i < 50; i++) {
            cb.addItem("Item " + i);
            nat.addItem("Item " + i);
            list.addItem("Item " + i);
            twincol.addItem("Item " + i);
        }

        hl.addComponent(cb);
        hl.addComponent(nat);
        hl.addComponent(list);
View Full Code Here

    }

    private <T extends Field> T createEnumField(Class<?> type,
            Class<T> fieldType) {
        if (AbstractSelect.class.isAssignableFrom(fieldType)) {
            AbstractSelect s = createCompatibleSelect((Class<? extends AbstractSelect>) fieldType);
            populateWithEnumData(s, (Class<? extends Enum>) type);
            return (T) s;
        }

        return null;
View Full Code Here

        return (T) field;
    }

    protected AbstractSelect createCompatibleSelect(
            Class<? extends AbstractSelect> fieldType) {
        AbstractSelect select;
        if (fieldType.isAssignableFrom(ListSelect.class)) {
            select = new ListSelect();
            select.setMultiSelect(false);
        } else if (fieldType.isAssignableFrom(NativeSelect.class)) {
            select = new NativeSelect();
        } else if (fieldType.isAssignableFrom(OptionGroup.class)) {
            select = new OptionGroup();
            select.setMultiSelect(false);
        } else if (fieldType.isAssignableFrom(Table.class)) {
            Table t = new Table();
            t.setSelectable(true);
            select = t;
        } else {
            select = new ComboBox(null);
        }
        select.setImmediate(true);
        select.setNullSelectionAllowed(false);

        return select;
    }
View Full Code Here

TOP

Related Classes of com.vaadin.ui.AbstractSelect$DefaultNewItemHandler

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.