Package com.vaadin.data.util

Examples of com.vaadin.data.util.IndexedContainer


        }
        return eventContainer;
    }

    private static Indexed createTestIndexedContainer() {
        IndexedContainer container = new IndexedContainer();
        container.addContainerProperty("testCaption", String.class, "");
        container.addContainerProperty("testDescription", String.class, "");
        container.addContainerProperty("testStartDate", Date.class, null);
        container.addContainerProperty("testEndDate", Date.class, null);

        java.util.Calendar cal = java.util.Calendar.getInstance();
        for (int i = 1; i <= 10; i++) {
            Item item = container.getItem(container.addItem());
            item.getItemProperty("testCaption").setValue("Test " + i);
            item.getItemProperty("testDescription")
                    .setValue("Description " + i);
            item.getItemProperty("testStartDate").setValue(cal.getTime());
            item.getItemProperty("testEndDate").setValue(cal.getTime());
View Full Code Here


        layout.addComponent(comboBox);
        layout.addComponent(new TextField());
    }

    private IndexedContainer createContainer() {
        IndexedContainer container = new IndexedContainer();
        for (int i = 0; i < 100000; ++i) {
            container.addItem("Item " + i);
        }
        return container;
    }
View Full Code Here

                    NativeSelect select = new NativeSelect(
                            "Choose component to edit");

                    select.setNullSelectionAllowed(false);

                    IndexedContainer container = new IndexedContainer();
                    container.addContainerProperty("caption", String.class, "");
                    Iterator<Component> componentIterator = l
                            .getComponentIterator();
                    while (componentIterator.hasNext()) {
                        AbstractComponent next = (AbstractComponent) componentIterator
                                .next();
                        Item item = container.addItem(next);

                        String caption = next.getClass().getSimpleName();

                        caption += "; cap: " + next.getCaption() + "; debugid"
                                + getId();

                        if (next instanceof Property) {
                            caption += " value:"
                                    + ((Property<?>) next).getValue();
                        }

                        item.getItemProperty("caption").setValue(caption);
                    }
                    select.setContainerDataSource(container);
                    select.setItemCaptionPropertyId("caption");
                    select.setImmediate(true);

                    select.addListener(new ValueChangeListener() {
                        @Override
                        public void valueChange(ValueChangeEvent event) {
                            editcomponent((Component) event.getProperty()
                                    .getValue());
                            getMainWindow().removeWindow(chooser);
                        }

                    });

                    layout.addComponent(select);

                    getMainWindow().addWindow(chooser);

                }
            });

            addComponent(componentChooser);

            Button addComp = new Button("add component");
            addComp.addListener(new Button.ClickListener() {
                @Override
                public void buttonClick(ClickEvent event) {
                    VerticalLayout layout = new VerticalLayout();
                    layout.setMargin(true);
                    final Window chooser = new Window(
                            "Choose component type to add", layout);
                    layout.setSizeUndefined();
                    chooser.setModal(true);

                    NativeSelect select = new NativeSelect(
                            "Choose component to edit");

                    select.setNullSelectionAllowed(false);

                    IndexedContainer container = new IndexedContainer();

                    URL resource = AbstractComponent.class.getResource(".");
                    File directory = new File(resource.getFile());
                    if (directory.exists()) {
                        // Get the list of the files contained in the
                        // package
                        final String[] files = directory.list();
                        for (int j = 0; j < files.length; j++) {
                            // we are only interested in .class files
                            if (files[j].endsWith(".class")) {
                                // removes the .class extension
                                String p = resource.toString()
                                        + files[j].substring(0,
                                                files[j].length() - 6);
                                p = p.replaceAll(".*classes/", "");
                                p = p.replaceAll("/", ".");
                                Class<?> c;
                                try {
                                    c = Class.forName(p);
                                    if (AbstractComponent.class
                                            .isAssignableFrom(c)
                                            && !p.toLowerCase().contains(
                                                    "layout")
                                            && !p.toLowerCase().contains(
                                                    "abstract")) {
                                        container.addItem(c);
                                    }
                                } catch (ClassNotFoundException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                }
View Full Code Here

    private Tree tree;

    @Override
    protected void setup() {
        final IndexedContainer ds1 = new IndexedContainer();
        // ds1.addContainerProperty("caption", String.class, "");
        for (int i = 0; i < 32; i++) {
            ds1.addItem("ds1-" + i);
        }

        final IndexedContainer ds2 = new IndexedContainer();
        // ds2.addContainerProperty("caption", String.class, "");
        for (int i = 0; i < 32; i++) {
            ds2.addItem("ds2-" + i);
        }

        HorizontalLayout hl = new HorizontalLayout();
        hl.setWidth("100%");
View Full Code Here

    protected Integer getTicketNumber() {
        return 4515;
    }

    private Container createContainer() {
        IndexedContainer container = new IndexedContainer();
        container.addContainerProperty("col1", String.class, "");
        container.addContainerProperty("col2", String.class, "");
        container.addContainerProperty("col3", String.class, "");

        for (int i = 0; i < 100; i++) {
            Item item = container.addItem("item " + i);
            item.getItemProperty("col1").setValue("first" + i);
            item.getItemProperty("col2").setValue("middle" + i);
            item.getItemProperty("col3").setValue("last" + i);
        }
View Full Code Here

        private HorizontalSplitPanel initLeftSide() {
            final HorizontalSplitPanel leftSide = new HorizontalSplitPanel();
            leftSide.setHeight("100%");

            final IndexedContainer dataSource = new IndexedContainer();
            dataSource.addContainerProperty(propId, String.class, null);
            dataSource.addContainerProperty(propId2, String.class, null);
            final Object itemId = dataSource.addItem();
            dataSource
                    .getItem(itemId)
                    .getItemProperty(propId)
                    .setValue(
                            "Very long value that makes a scrollbar appear for sure");
            dataSource
                    .getItem(itemId)
                    .getItemProperty(propId2)
                    .setValue(
                            "Very long value that makes a scrollbar appear for sure");

            for (int i = 0; i < 150; i++) {
                Object id = dataSource.addItem();
                dataSource
                        .getItem(id)
                        .getItemProperty(propId)
                        .setValue(
                                (i == 100 ? "Very long value that makes a scrollbar appear for sure"
                                        : "Short"));
                dataSource.getItem(id).getItemProperty(propId2)
                        .setValue("Short");
            }

            table.setSizeFull();
            table.setContainerDataSource(dataSource);
            table.setVisibleColumns(new Object[] { propId });

            leftSide.setSecondComponent(table);

            Button button = new Button("Change col value to short");
            button.addListener(new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    // Change the column value to a short one --> Should remove
                    // the scrollbar
                    if (isLong) {
                        dataSource.getItem(itemId).getItemProperty(propId)
                                .setValue("Short value");
                        dataSource.getItem(itemId).getItemProperty(propId2)
                                .setValue("Short value");
                        isLong = false;
                    } else {
                        dataSource
                                .getItem(itemId)
                                .getItemProperty(propId)
                                .setValue(
                                        "Very long value that makes a scrollbar appear for sure");
                        dataSource
                                .getItem(itemId)
                                .getItemProperty(propId2)
                                .setValue(
                                        "Very long value that makes a scrollbar appear for sure");
                        isLong = true;
View Full Code Here

    @Override
    protected void setup(VaadinRequest request) {
        getContent().setSizeUndefined();

        IndexedContainer cont = new IndexedContainer();
        cont.addContainerProperty("number", String.class, null);
        for (int i = 0; i < 80; i++) {
            Item item = cont.addItem(i);
            item.getItemProperty("number").setValue(i + "");
        }
        Table table = new Table();
        table.setPageLength(0);
        table.setContainerDataSource(cont);
View Full Code Here

    private Table initTable() {
        Table table = new Table();
        table.setWidth("100%");

        IndexedContainer idx = new IndexedContainer();
        idx.addContainerProperty("firstname", String.class, null);
        idx.addContainerProperty("lastname", String.class, null);
        Item i = idx.addItem(1);
        i.getItemProperty("firstname").setValue("John");
        i.getItemProperty("lastname").setValue("Johnson");

        i = idx.addItem(2);
        i.getItemProperty("firstname").setValue("Jane");
        i.getItemProperty("lastname").setValue("Janeine");

        for (int index = 3; index < ROWS; index++) {
            i = idx.addItem(index);
            i.getItemProperty("firstname").setValue("Jane");
            i.getItemProperty("lastname").setValue("Janeine");
        }

        idx.addContainerProperty("fixed 50px column", String.class, "");

        idx.addContainerProperty("Expanded with 2", String.class, "foobar");

        table.setContainerDataSource(idx);

        table.setColumnHeader("firstname", "FirstName");
        table.setColumnHeader("lastname", "LastName (1)");
View Full Code Here

                        || itemId.equals(itemIdOver)) {
                    return; // no move happened
                }

                // IndexedContainer goodies... (hint: don't use it in real apps)
                IndexedContainer containerDataSource = (IndexedContainer) table
                        .getContainerDataSource();
                int newIndex = containerDataSource.indexOfId(itemIdOver) - 1;
                if (dropTargetData.getDropLocation() != VerticalDropLocation.TOP) {
                    newIndex++;
                }
                if (newIndex < 0) {
                    newIndex = 0;
                }
                Object idAfter = containerDataSource.getIdByIndex(newIndex);
                Collection<?> selections = (Collection<?>) table.getValue();
                if (selections != null && selections.contains(itemId)) {
                    // dragged a selected item, if multiple rows selected, drag
                    // them too (functionality similar to apple mail)
                    for (Object object : selections) {
                        moveAfter(containerDataSource, object, idAfter);
                    }

                } else {
                    // move just the dragged row, not considering selection at
                    // all
                    moveAfter(containerDataSource, itemId, idAfter);
                }

            }

            private void moveAfter(IndexedContainer containerDataSource,
                    Object itemId, Object idAfter) {
                try {
                    IndexedContainer clone = null;
                    clone = (IndexedContainer) containerDataSource.clone();
                    containerDataSource.removeItem(itemId);
                    Item newItem = containerDataSource.addItemAfter(idAfter,
                            itemId);
                    Item item = clone.getItem(itemId);
                    for (Object propId : item.getItemPropertyIds()) {
                        newItem.getItemProperty(propId).setValue(
                                item.getItemProperty(propId).getValue());
                    }
View Full Code Here

                        || itemId.equals(itemIdOver)) {
                    return; // no move happened
                }

                // IndexedContainer goodies... (hint: don't use it in real apps)
                IndexedContainer containerDataSource = (IndexedContainer) table
                        .getContainerDataSource();
                int newIndex = containerDataSource.indexOfId(itemIdOver) - 1;
                if (dropTargetData.getDropLocation() != VerticalDropLocation.TOP) {
                    newIndex++;
                }
                if (newIndex < 0) {
                    newIndex = 0;
                }
                Object idAfter = containerDataSource.getIdByIndex(newIndex);
                Collection<?> selections = (Collection<?>) table.getValue();
                if (selections != null && selections.contains(itemId)) {
                    // dragged a selected item, if multiple rows selected, drag
                    // them too (functionality similar to apple mail)
                    for (Object object : selections) {
                        moveAfter(containerDataSource, object, idAfter);
                    }

                } else {
                    // move just the dragged row, not considering selection at
                    // all
                    moveAfter(containerDataSource, itemId, idAfter);
                }

            }

            private void moveAfter(IndexedContainer containerDataSource,
                    Object itemId, Object idAfter) {
                try {
                    IndexedContainer clone = null;
                    clone = (IndexedContainer) containerDataSource.clone();
                    containerDataSource.removeItem(itemId);
                    Item newItem = containerDataSource.addItemAfter(idAfter,
                            itemId);
                    Item item = clone.getItem(itemId);
                    for (Object propId : item.getItemPropertyIds()) {
                        newItem.getItemProperty(propId).setValue(
                                item.getItemProperty(propId).getValue());
                    }
View Full Code Here

TOP

Related Classes of com.vaadin.data.util.IndexedContainer

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.