Package com.vaadin.ui.DragAndDropWrapper

Examples of com.vaadin.ui.DragAndDropWrapper.WrapperTargetDetails


                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();
View Full Code Here


            }

            @Override
            public void drop(DragAndDropEvent event) {

                WrapperTargetDetails ed = (WrapperTargetDetails) event
                        .getTargetDetails();
                Transferable ctr = event.getTransferable();
                if (ctr.getSourceComponent() != null) {
                    // use "component" (from DragDropPane) if available, else
                    // take
                    // the source component
                    Component component = (Component) ctr.getData("component");
                    if (component == null) {
                        component = ctr.getSourceComponent();
                    }

                    if (component.getParent() != layout) {
                        if (ctr instanceof DataBoundTransferable) {
                            // Item has been dragged, construct a Label from
                            // Item id
                            Label l = new Label();
                            l.setSizeUndefined();
                            l.setValue("ItemId : "
                                    + ((DataBoundTransferable) ctr).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 {
                        // drag started and ended inside the this Pane

                        DragAndDropWrapper.WrapperTransferable tr = (WrapperTransferable) event
                                .getTransferable();

                        MouseEventDetails start = tr.getMouseDownEvent();

                        MouseEventDetails eventDetails = ed.getMouseEvent();

                        int deltaX = eventDetails.getClientX()
                                - start.getClientX();
                        int deltaY = eventDetails.getClientY()
                                - start.getClientY();
View Full Code Here

TOP

Related Classes of com.vaadin.ui.DragAndDropWrapper.WrapperTargetDetails

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.