Package java.awt.dnd

Examples of java.awt.dnd.DropTargetDropEvent


                dropAction = e.getDropAction();
                break;
            }
            case DRAG_DROP:
            {
                DropTargetDropEvent e = (DropTargetDropEvent)currentEvent;
                context.getDropTarget().drop(e);
                dropAction = e.getDropAction();
                break;
            }
            case DRAG_LEAVE:
            {
                context.getDropTarget().dragExit(currentEvent);
View Full Code Here


        AbstractComponent mockCanvasComponent = new TestComponent();
        AbstractComponent mockDropComponent = new TestComponent();
        CanvasManifestation canvas = new CanvasManifestation(mockCanvasComponent, mockCanvasViewInfo);
        DropTarget dt = canvas.getDropTarget();
       
        DropTargetDropEvent mockDTDE = Mockito.mock(DropTargetDropEvent.class);
        Transferable mockTransferable = Mockito.mock(Transferable.class);
        View[] mockViews = { Mockito.mock(View.class) };
       
        Mockito.when(mockViews[0].getManifestedComponent()).thenReturn(mockDropComponent);
        Mockito.when(mockViews[0].getInfo()).thenReturn(mockCanvasViewInfo);
        Mockito.when(mockPersistence.getComponent(Mockito.anyString())).thenReturn(mockDropComponent);
        Mockito.when(mockDTDE.getTransferable()).thenReturn(mockTransferable);
        Mockito.when(mockTransferable.isDataFlavorSupported(View.DATA_FLAVOR)).thenReturn(true);
        Mockito.when(mockDTDE.getLocation()).thenReturn(new Point(0,0));
        Mockito.when(mockTransferable.getTransferData(View.DATA_FLAVOR)).thenReturn(mockViews);
       
        dt.drop(mockDTDE);
    }
View Full Code Here

    private TransferSupport createPasteTransferSupport(Component comp, Transferable transferable) {
        return new TransferSupport(comp, transferable);
    }
   
    private TransferSupport createDropTransferSupport(Component comp, Transferable transferable, DataFlavor[] flavors) throws Exception {
        DropTargetDropEvent event = mock(DropTargetDropEvent.class);
        when(event.getTransferable()).thenReturn(transferable);
        when(event.getCurrentDataFlavors()).thenReturn(flavors);
        when(event.getLocation()).thenReturn(new Point(0,0));
       
        Constructor<TransferSupport> constructor = TransferSupport.class.getDeclaredConstructor(Component.class, DropTargetEvent.class);
        constructor.setAccessible(true);
        return constructor.newInstance(comp, event);
    }
View Full Code Here

            dataObject = new WinDataTransfer.IDataObject(dataObjectPtr);
            DataSnapshot snapshot = new DataSnapshot(dataObject);
            transferable = new DataProxy(snapshot);
        }

        DropTargetDropEvent e = new DropTargetDropEvent(
                context, new Point(x, y),
                WinDragSource.getDndActions(userAction),
                WinDragSource.getDndActions(sourceActions));
       
        int ret = dispatchEvent(e, DRAG_DROP);
View Full Code Here

                dropAction = e.getDropAction();
                break;
            }
            case DRAG_DROP:
            {
                DropTargetDropEvent e = (DropTargetDropEvent)currentEvent;
                context.getDropTarget().drop(e);
                dropAction = e.getDropAction();
                break;
            }
            case DRAG_LEAVE:
            {
                context.getDropTarget().dragExit(currentEvent);
View Full Code Here

            // Set transferable
            try {
                // XXX Java 1.3 and 1.4 workaround for:
                // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4378091
                Transferable transferable =
                    new DropTargetDropEvent(dtde.getDropTargetContext(),
                                            dtde.getLocation(), 0, 0)
                        .getTransferable();
                // Transferable transferable = dtde.getTransferable();
                DataFlavor[] flavors = transferable.getTransferDataFlavors();
                for (int i = 0; i < flavors.length; i++) {
View Full Code Here

                if ((local = getJVMLocalSourceTransferable()) != null)
                    setCurrentJVMLocalSourceTransferable(null);
            }

            try {
                ((DropTargetListener)dt).drop(new DropTargetDropEvent(dtc,
                                                                      hots,
                                                                      currentDA,
                                                                      currentSA,
                                                                      local != null));
            } finally {
View Full Code Here

            sourceActions = ev.getSourceActions();
            flavors = ev.getCurrentDataFlavors();
            location = ev.getLocation();
        }
        else if (e instanceof DropTargetDropEvent) {
            DropTargetDropEvent ev = (DropTargetDropEvent)e;
            currentAction = ev.getDropAction();
            sourceActions = ev.getSourceActions();
            flavors = ev.getCurrentDataFlavors();
            location = ev.getLocation();
        }
        if (isSupported(flavors)) {
            int availableActions = getDropActionsForFlavors(flavors);
            currentAction = getDropAction(e, currentAction, sourceActions, availableActions);
            if (currentAction != DragHandler.NONE) {
View Full Code Here

                    + " act=" + DragHandler.actionString(ev.getDropAction());
            }
            else if (e instanceof DropTargetDropEvent) {
                DropTargetContext dtc = e.getDropTargetContext();
                DropTarget dt = dtc.getDropTarget();
                DropTargetDropEvent ev = (DropTargetDropEvent)e;
                msg += ": src=" + DragHandler.actionString(ev.getSourceActions())
                + " tgt=" + DragHandler.actionString(dt.getDefaultActions())
                + " act=" + DragHandler.actionString(ev.getDropAction());
            }
            if (!msg.equals(lastAction)) {
                System.out.println(lastAction = msg);
            }
        }
View Full Code Here

TOP

Related Classes of java.awt.dnd.DropTargetDropEvent

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.