Package com.vlsolutions.swing.docking.event

Examples of com.vlsolutions.swing.docking.event.DockDragEvent


            processHotSwap(underMouse, e.getComponent(), null, true);
            return true;
        } else if (underMouse instanceof DockDropReceiver) {
//      MouseEvent convertMouse;
            DropProcess process = new DropProcess(e, dockableDragSource, umInfo);
            DockDragEvent event = process.findAcceptableEvent(e);


            if (event.isDragAccepted() && process.isDockingActionAccepted()) {// triggers vetoable listeners
                return process.dropIfPossible();
            } else if (process.canDockableBeDetached() // Not accepted on the desktop //2005/10/07
                    && process.checkDockableWillBeDetached()) {
                Point location = new Point(e.getPoint());
                SwingUtilities.convertPointToScreen(location, e.getComponent());
View Full Code Here


        if (targetDesktop == null) {   //2006/09/11
            // deny drag gesture when desktops aren't compatible
            if (underMouseNullDesktop != null) { // we've found a dock drop receiver
                // we send a really simple event
                DockDragEvent event = new DockDragEvent(desktop, dragSource, e);
                ((DockDropReceiver) underMouseNullDesktop).processDockableDrag(event);
            }
            // finished
            shapePainterStrategy.showStopDragCursor();
            setDropShape(null, shapePainterStrategy);
            return;
        } else if (targetDesktop.getContext() != desktop.getContext()) {   //2006/09/11
            // deny drag gesture when desktops aren't compatible
            shapePainterStrategy.showStopDragCursor();
            setDropShape(null, shapePainterStrategy);
            return;
        }



        int dx = dragPoint.x - startDragPoint.x;
        int dy = dragPoint.y - startDragPoint.y;
        if (Math.abs(dx) < 20 && Math.abs(dy) < 10) {
            // deny drag gesture when too near from start point 2005/11/15
            shapePainterStrategy.showStopDragCursor();
            setDropShape(null, shapePainterStrategy);
            return;
        }


        // 2005/11/08 support for full height/width docking

        DockingPanel dp = targetDesktop.getDockingPanel();

        Insets i = targetDesktop.getDockingPanelInsets();
        Rectangle deskBounds = new Rectangle(i.left, i.top,
                targetDesktop.getWidth() - i.left - i.right, targetDesktop.getHeight() - i.top - i.bottom);
        Rectangle innerBounds = new Rectangle(deskBounds);
        innerBounds.x += 5;
        innerBounds.y += 5;
        innerBounds.width -= 10;
        innerBounds.height -= 10;

        if (deskBounds.contains(dragPoint) && !innerBounds.contains(dragPoint) && underMouse != null && targetDesktop.isAncestorOf(underMouse)) {
            // at less than 5 pixels from a border, promote DockingPanel as the receiver
            underMouse = dp;
        }

        // go up the hierarchy until we find a component that can receive a drop
        while (underMouse != null && underMouse != targetDesktop &&
                !(underMouse instanceof DockDropReceiver)) {
            underMouse = underMouse.getParent();
        }

        umInfo.underMouse = underMouse; // resync


        if (underMouse == null) {// || isAncestorOf(dockableDragSource.getDockableContainer(), underMouse)){
            // it's not possible to drop a parent on one of its children
            // so we're goind to try and detach it
            if (underMouse instanceof DockDropReceiver) {
                // but we still have to use the reference on drop receiver to display a floating drag shape
                this.dropReceiver = (DockDropReceiver) underMouse;
            }
            DragProcess process = new DragProcess(dockableDragSource, umInfo);
            if (process.canDockableBeDetached() && process.checkAndDetachDockable(shapePainterStrategy)) {
                // this method manages the detachement
            } else {
                // refused (vetoed)
                shapePainterStrategy.showStopDragCursor();
                setDropShape(null, shapePainterStrategy);
            }
        } else if (underMouse instanceof DockDropReceiver && e.isControlDown()) { //2005/11/08 HOT SWAP FUNCTION
            processHotSwap(underMouse, dragged, shapePainterStrategy, false);
        } else if (underMouse instanceof DockDropReceiver) {
            // loop if it returns null
            DragProcess process = new DragProcess(dockableDragSource, umInfo);
            DockDragEvent event = process.findAcceptableEvent(e);
            // will it cause a state change ?
            // a state change occur when switching between CLOSED, HIDDEN, and DOCKED
            // in this context, the drag event can only be generated by a hidden dockable
            // (if there is a way to drag its button) or an already docked dockable (no state change)

            if (event.isDragAccepted() && process.isDockingActionAccepted()) {
                shapePainterStrategy.showDragCursor();
                setDropShape(event.getDropShape(), shapePainterStrategy);
            } else if (process.canDockableBeDetached() && process.checkAndDetachDockable(shapePainterStrategy)) {
                // detach done by the "if"
            } else {
                event.rejectDrag(); // vetoed by listeners
                shapePainterStrategy.showStopDragCursor();
                setDropShape(null, shapePainterStrategy);
            }
        } else {// not above a drop receiver, might be detachable
            DragProcess process = new DragProcess(dockableDragSource, umInfo);
View Full Code Here

            this.futureLocation = DockingUtilities.getDockableLocationFromHierarchy(umInfo.underMouse);
        }

        /** search until a drag event is accepted or rejected (not delegated) */
        public DockDragEvent findAcceptableEvent(MouseEvent e) {
            DockDragEvent event;
            boolean loop = false;
            Component underMouse = umInfo.underMouse;
            do {
                dropReceiver = (DockDropReceiver) underMouse;
                MouseEvent convertMouse = SwingUtilities.convertMouseEvent(
                        (Component) e.getSource(),
                        e, underMouse);
                DockableDragSource dragSource = ((DockableDragSource) e.getSource());

                event = new DockDragEvent(umInfo.desktop, dragSource, convertMouse);
                dropReceiver.processDockableDrag(event);
                if (event.isDragAccepted()) {
                } else if (event.isDragDelegated()) {
                    // find another dropper
                    underMouse = underMouse.getParent();
                    while (underMouse != null && underMouse != umInfo.desktop &&
                            !(underMouse instanceof DockDropReceiver)) {
                        underMouse = underMouse.getParent();
                    }
                }

                if (event.isDragAccepted()) {
                    loop = false;
                } else if (event.isDragDelegated() &&
                        underMouse instanceof DockDropReceiver) {
                    loop = true;
                } else {
                    loop = false;
                }
            } while (loop);
            if (event != null) {
                this.dockingActionEvent = event.getDockingAction();
                umInfo.underMouse = underMouse; // 2007/01/06
            }
            return event;
        }
View Full Code Here

TOP

Related Classes of com.vlsolutions.swing.docking.event.DockDragEvent

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.