Examples of DropHandler


Examples of com.vaadin.event.dd.DropHandler

        dragStart.setHTML5DataFlavor("Text", "HTML5!");
        addComponent(dragStart);

        DragAndDropWrapper dropTarget = new DragAndDropWrapper(new Label(
                "over here"));
        dropTarget.setDropHandler(new DropHandler() {

            @Override
            public AcceptCriterion getAcceptCriterion() {
                return AcceptAll.get();
            }
View Full Code Here

Examples of com.vaadin.event.dd.DropHandler

        dragAndDropWrapper2 = new DragAndDropWrapper(cssLayout);
        dragAndDropWrapper2
                .setCaption("Drop here or sort with dd (wrapper(csslayout(n*wrapper(label))))");

        dh = new DropHandler() {

            @Override
            public AcceptCriterion getAcceptCriterion() {
                return AcceptAll.get();
            }
View Full Code Here

Examples of com.vaadin.event.dd.DropHandler

         * Moves items in tree (and could work in Table too). Also supports
         * "building" tree.
         *
         * TODO fix algorithm, broken in some cases.
         */
        DropHandler itemSorter = new DropHandler() {

            @SuppressWarnings("unused")
            private void populateSubTree(HierarchicalContainer idx,
                    HierarchicalContainer subtree, Object itemId) {
                Collection<?> children = subtree.getChildren(itemId);
View Full Code Here

Examples of com.vaadin.event.dd.DropHandler

        l.setSizeUndefined();
        cssLayout.addComponent(l);
        DragAndDropWrapper dragAndDropWrapper = new DragAndDropWrapper(
                cssLayout);
        dragAndDropWrapper.setSizeUndefined();
        dragAndDropWrapper.setDropHandler(new DropHandler() {

            @Override
            public AcceptCriterion getAcceptCriterion() {
                return AcceptAll.get();
            }
View Full Code Here

Examples of com.vaadin.event.dd.DropHandler

        final Table target = createTable("Target");

        source1.setDragMode(TableDragMode.ROW);
        source2.setDragMode(TableDragMode.ROW);

        target.setDropHandler(new DropHandler() {
            @Override
            public AcceptCriterion getAcceptCriterion() {
                return new SourceIs(source1, source2);
            }
View Full Code Here

Examples of com.vaadin.event.dd.DropHandler

         * Moves items in tree (and could work in Table too). Also supports
         * "building" tree.
         *
         * TODO fix algorithm, broken in some cases.
         */
        DropHandler itemSorter = new DropHandler() {

            @SuppressWarnings("unused")
            private void populateSubTree(HierarchicalContainer idx,
                    HierarchicalContainer subtree, Object itemId) {
                Collection<?> children = subtree.getChildren(itemId);
View Full Code Here

Examples of com.vaadin.event.dd.DropHandler

        tree1.setItemCaptionPropertyId("name");
        tree1.setItemIconPropertyId("icon");

        tree1.setDragMode(TreeDragMode.NODE);

        DropHandler dropHandler = new DropHandler() {
            @Override
            public AcceptCriterion getAcceptCriterion() {
                return AcceptAll.get();
            }
View Full Code Here

Examples of com.vaadin.event.dd.DropHandler

                }
            });

            if (file instanceof Folder) {

                setDropHandler(new DropHandler() {

                    @Override
                    public AcceptCriterion getAcceptCriterion() {
                        return new Not(SourceIsTarget.get());
                    }
View Full Code Here

Examples of com.vaadin.event.dd.DropHandler

                }
                return false;
            }
        };

        wrapper.setDropHandler(new DropHandler() {

            @Override
            public AcceptCriterion getAcceptCriterion() {
                return serverSideCriterion;
            }
View Full Code Here

Examples of com.vaadin.event.dd.DropHandler

        // Set the tree in drag source mode
        tree.setDragMode(TreeDragMode.NODE);

        // Allow the tree to receive drag drops and handle them
        tree.setDropHandler(new DropHandler() {
            @Override
            public AcceptCriterion getAcceptCriterion() {
                // Accept drops in the middle of container items
                // and below and above all items.
                return new Or(Tree.TargetItemAllowsChildren.get(), new Not(
                        VerticalLocationIs.MIDDLE));
            }

            @Override
            public void drop(DragAndDropEvent event) {
                // Wrapper for the object that is dragged
                DataBoundTransferable t = (DataBoundTransferable) event
                        .getTransferable();

                TreeTargetDetails target = (TreeTargetDetails) event
                        .getTargetDetails();

                // Get ids of the dragged item and the target item
                Object sourceItemId = t.getData("itemId");
                Object targetItemId = target.getItemIdOver();

                // On which side of the target the item was dropped
                VerticalDropLocation location = target.getDropLocation();

                HierarchicalContainer container = (HierarchicalContainer) tree
                        .getContainerDataSource();

                BeanItem<?> beanItem = null;
                if (sourceItemId instanceof BeanItem<?>) {
                    beanItem = (BeanItem<?>) sourceItemId;
                } else if (sourceItemId instanceof InventoryObject) {
                    beanItem = new BeanItem<InventoryObject>(
                            (InventoryObject) sourceItemId);
                }

                // Remove the item from the source container and
                // add it to the tree's container
                Container sourceContainer = t.getSourceContainer();
                sourceContainer.removeItem(sourceItemId);
                tree.addItem(beanItem);
                InventoryObject bean = (InventoryObject) beanItem.getBean();
                tree.setChildrenAllowed(beanItem, bean.isContainer());

                // Drop right on an item -> make it a child
                if (location == VerticalDropLocation.MIDDLE) {
                    tree.setParent(beanItem, targetItemId);
                } else if (location == VerticalDropLocation.TOP) {
                    Object parentId = container.getParent(targetItemId);
                    tree.setParent(beanItem, parentId);
                    container.moveAfterSibling(beanItem, targetItemId);
                    container.moveAfterSibling(targetItemId, beanItem);
                }

                // Drop below another item -> make it next
                else if (location == VerticalDropLocation.BOTTOM) {
                    Object parentId = container.getParent(targetItemId);
                    tree.setParent(beanItem, parentId);
                    container.moveAfterSibling(beanItem, targetItemId);
                }

                tree.setItemCaption(beanItem, bean.getName());
            }
        });

        // Have a table that allows dragging from
        final Table table = new Table("Inventory List");
        table.setDragMode(TableDragMode.ROW);

        // Initialize the table container
        ArrayList<InventoryObject> collection = new ArrayList<InventoryObject>();
        collection.add(new InventoryObject("Dummy Item", 0.0, false));
        final BeanItemContainer<InventoryObject> tableContainer = new BeanItemContainer<InventoryObject>(
                collection);
        table.setContainerDataSource(tableContainer);
        table.setVisibleColumns(new String[] { "name", "weight" });
        table.removeAllItems();

        // Allow the table to receive drops and handle them
        table.setDropHandler(new DropHandler() {
            @Override
            public AcceptCriterion getAcceptCriterion() {
                return new Not(VerticalLocationIs.MIDDLE);
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.