Package com.vaadin.ui

Examples of com.vaadin.ui.DragAndDropWrapper$WrapperTransferable


    private Label console = new Label("No activity detected yet",
            ContentMode.HTML);

    @Override
    protected void setup(VaadinRequest request) {
        final DragAndDropWrapper dndWrapper = new DragAndDropWrapper(
                new Button("Upload here by drag and dropping"));
        dndWrapper.setDropHandler(new DropHandler() {

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


    private AbsoluteLayout layout = new AbsoluteLayout();

    public AcceptAnythingWindow() {
        setCaption("Drop anything here");

        final DragAndDropWrapper wrapper = new DragAndDropWrapper(layout);
        wrapper.setDropHandler(new DropHandler() {

            @Override
            public AcceptCriterion getAcceptCriterion() {
                return AcceptAll.get();
            }

            @Override
            public void drop(DragAndDropEvent event) {
                WrapperTargetDetails ed = (WrapperTargetDetails) event
                        .getTargetDetails();
                Transferable transferable = event.getTransferable();
                TransferableImpl ctr = (TransferableImpl) transferable;
                Component component = ctr.getSourceComponent();
                if (component == wrapper) {
                    // if the drag source was wrapper we are interested about
                    // the dragged component
                    WrapperTransferable tr = (WrapperTransferable) transferable;
                    component = tr.getDraggedComponent();
                    // html5 drag created by wrapper set component null
                }

                if (component != null) {

                    if (component.getParent() != layout) {
                        if (transferable instanceof DataBoundTransferable) {
                            // Item has been dragged, construct a Label from
                            // Item id
                            Label l = new Label();
                            l.setSizeUndefined();
                            l.setValue("ItemId : "
                                    + ((DataBoundTransferable) transferable)
                                            .getItemId());
                            layout.addComponent(l);
                            component = l;

                        } else {
                            // we have a component that is been dragged, add
                            // it to this
                            layout.addComponent(component);
                        }

                        Integer left = ed.getAbsoluteLeft();
                        Integer top = ed.getAbsoluteTop();

                        MouseEventDetails eventDetails = ed.getMouseEvent();

                        int clientX = eventDetails.getClientX();
                        int clientY = eventDetails.getClientY();

                        try {
                            layout.getPosition(component).setTopValue(
                                    Float.valueOf(clientY - top));
                            layout.getPosition(component).setLeftValue(
                                    Float.valueOf(clientX - left));
                        } catch (Exception e) {
                            // TODO: handle exception
                        }
                    } else {

                        WrapperTransferable tr = (WrapperTransferable) transferable;
                        // drag ended inside the this Pane

                        MouseEventDetails start = tr.getMouseDownEvent();
                        MouseEventDetails eventDetails = ed.getMouseEvent();

                        int deltaX = eventDetails.getClientX()
                                - start.getClientX();
                        int deltaY = eventDetails.getClientY()
                                - start.getClientY();

                        ComponentPosition p = layout.getPosition(component);
                        p.setTopValue(p.getTopValue() + deltaY);
                        p.setLeftValue(p.getLeftValue() + deltaX);

                    }

                } else {
                    // drag coming outside of Vaadin
                    String object = (String) transferable.getData("Text");

                    String content = (String) transferable
                            .getData("fileContents");

                    Label l = new Label();
                    l.setCaption("Generated from HTML5 drag:");
                    if (object != null) {
                        l.setValue(object);
                    } else {
                        l.setValue("HTML5 dd");
                    }

                    l.setDescription(content);
                    l.setSizeUndefined();

                    layout.addComponent(l);

                }
                return;
            }
        });

        wrapper.setDragStartMode(DragStartMode.COMPONENT);
        wrapper.setSizeFull();
        setContent(wrapper);

        setWidth("250px");
        setHeight("100px");
    }
View Full Code Here

public class StartHtml5Drag extends TestBase {

    @Override
    protected void setup() {
        DragAndDropWrapper dragStart = new DragAndDropWrapper(new Label(
                "Drag me"));
        dragStart.setDragStartMode(DragStartMode.HTML5);
        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

                                                                 */

        Label l;

        l = new Label("Drag me");
        DragAndDropWrapper dragAndDropWrapper = new DragAndDropWrapper(l);
        dragAndDropWrapper.setDragStartMode(DragStartMode.COMPONENT);
        dragAndDropWrapper.setWidth("100px");
        dragAndDropWrapper.setHeight("100px");
        getLayout().addComponent(dragAndDropWrapper);

        l = new Label("Drag me too");
        dragAndDropWrapper = new DragAndDropWrapper(l);
        dragAndDropWrapper.setDragStartMode(DragStartMode.WRAPPER);
        dragAndDropWrapper.setWidth("100px");
        dragAndDropWrapper.setHeight("100px");
        getLayout().addComponent(dragAndDropWrapper);

        final CssLayout cssLayout = new CssLayout();
        cssLayout.setHeight("300px");

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

        dh = new DropHandler() {

View Full Code Here

        TestUtils.injectCSS(getMainWindow(), GREENBOXES + HIDEDRAGSOURCE);

        VerticalLayout l = new VerticalLayout();
        l.setWidth("400px");
        l.setHeight("100px");
        DragAndDropWrapper pane = new DragAndDropWrapper(cssLayout);
        pane.setSizeFull();
        l.addComponent(pane);

        addComponent(l);

        for (int i = 0; i < 4; i++) {
View Full Code Here

        }
    };

    public HorizontalSortableCssLayoutWithWrappers() {
        setCaption("Horizontally sortable csslayout via (ddwrappers):Try sorting blocks by draggin them");
        DragAndDropWrapper pane = new DragAndDropWrapper(cssLayout);
        setContent(pane);
        pane.setSizeFull();
        setWidth("400px");
        setHeight("100px");

        for (int i = 0; i < 4; i++) {
            cssLayout.addComponent(new WrappedLabel("Block"));
View Full Code Here

    public AcceptFromComponent(final Tree tree1) {
        setCaption("Checks the source is tree1 on server");

        layout = new AbsoluteLayout();
        DragAndDropWrapper wrapper = new DragAndDropWrapper(layout);

        setContent(wrapper);

        wrapper.setSizeFull();
        layout.setSizeFull();
        setWidth("450px");
        setHeight("150px");

        final ServerSideCriterion serverSideCriterion = new ServerSideCriterion() {

            @Override
            public boolean accept(DragAndDropEvent dragEvent) {
                Transferable transferable = dragEvent.getTransferable();
                if (transferable instanceof TransferableImpl) {
                    TransferableImpl componentTransferrable = (TransferableImpl) transferable;
                    if (componentTransferrable.getSourceComponent() == tree1) {
                        return true;
                    }
                }
                return false;
            }
        };

        wrapper.setDropHandler(new DropHandler() {

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

            }
        };
        Component l = new Label("Drag file on me");
        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

        }
    };

    public HorizontalLayoutSortableWithWrappers() {
        setCaption("Horizontally sortable layout via (ddwrappers): Try sorting blocks by dragging them");
        DragAndDropWrapper pane = new DragAndDropWrapper(layout);
        setContent(pane);
        pane.setSizeFull();
        setWidth("400px");
        setHeight("100px");

        for (int i = 0; i < 4; i++) {
            layout.addComponent(new WrappedLabel("Block"));
View Full Code Here

                    };

                    if (name.startsWith("XHRFILE")) {
                        String[] split = item.getFieldName().substring(7)
                                .split("\\.");
                        DragAndDropWrapper ddw = (DragAndDropWrapper) idPaintableMap
                                .get(split[0]);

                        try {
                            ddw.receiveFile(upstream, split[1]);
                        } catch (UploadException e) {
                            synchronized (application) {
                                handleChangeVariablesError(application, ddw, e,
                                        new HashMap<String, Object>());
                            }
View Full Code Here

TOP

Related Classes of com.vaadin.ui.DragAndDropWrapper$WrapperTransferable

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.