Search in sources :

Example 1 with DragSourceEvent

use of java.awt.dnd.DragSourceEvent in project jdk8u_jdk by JetBrains.

the class SunDragSourceContextPeer method dragExit.

/**
     * upcall from native code
     */
protected final void dragExit(final int x, final int y) {
    DragSourceEvent event = new DragSourceEvent(getDragSourceContext(), x, y);
    EventDispatcher dispatcher = new EventDispatcher(DISPATCH_EXIT, event);
    SunToolkit.invokeLaterOnAppContext(SunToolkit.targetToAppContext(getComponent()), dispatcher);
    startSecondaryEventLoop();
}
Also used : DragSourceEvent(java.awt.dnd.DragSourceEvent)

Example 2 with DragSourceEvent

use of java.awt.dnd.DragSourceEvent in project freeplane by freeplane.

the class MNodeDragListener method dragGestureRecognized.

public void dragGestureRecognized(final DragGestureEvent e) {
    final MainView mainView = (MainView) e.getComponent();
    final NodeView nodeView = mainView.getNodeView();
    final MapView mapView = nodeView.getMap();
    mapView.select();
    if (!nodeView.isSelected()) {
        nodeView.getMap().getModeController().getController().getSelection().selectAsTheOnlyOneSelected(nodeView.getModel());
    }
    Rectangle bounds = new Rectangle(0, 0, mainView.getWidth(), mainView.getHeight());
    if (!bounds.contains(e.getDragOrigin()))
        return;
    final int dragActionType = e.getDragAction();
    if (dragActionType == DnDConstants.ACTION_MOVE) {
        final NodeModel node = nodeView.getModel();
        if (node.isRoot()) {
            if (!isLinkDragEvent(e))
                return;
        }
    }
    final String dragActionName;
    Cursor cursor = getCursorByAction(dragActionType);
    if (isLinkDragEvent(e)) {
        cursor = DragSource.DefaultLinkDrop;
        dragActionName = "LINK";
    } else if ((e.getTriggerEvent().getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) != 0) {
        cursor = DragSource.DefaultCopyDrop;
        dragActionName = "COPY";
    } else {
        dragActionName = "MOVE";
    }
    final Transferable t = ClipboardController.getController().copy(Controller.getCurrentController().getSelection());
    ((MindMapNodesSelection) t).setDropAction(dragActionName);
    try {
        e.startDrag(cursor, t, new DragSourceListener() {

            public void dragDropEnd(final DragSourceDropEvent dsde) {
            }

            public void dragEnter(final DragSourceDragEvent e) {
            }

            public void dragExit(final DragSourceEvent dse) {
            }

            public void dragOver(final DragSourceDragEvent dsde) {
            }

            public void dropActionChanged(final DragSourceDragEvent dsde) {
                dsde.getDragSourceContext().setCursor(getCursorByAction(dsde.getUserAction()));
            }
        });
    } catch (final InvalidDnDOperationException ex) {
    }
}
Also used : InvalidDnDOperationException(java.awt.dnd.InvalidDnDOperationException) MainView(org.freeplane.view.swing.map.MainView) DragSourceDragEvent(java.awt.dnd.DragSourceDragEvent) Rectangle(java.awt.Rectangle) Transferable(java.awt.datatransfer.Transferable) NodeView(org.freeplane.view.swing.map.NodeView) Cursor(java.awt.Cursor) DragSourceListener(java.awt.dnd.DragSourceListener) DragSourceEvent(java.awt.dnd.DragSourceEvent) NodeModel(org.freeplane.features.map.NodeModel) MapView(org.freeplane.view.swing.map.MapView) DragSourceDropEvent(java.awt.dnd.DragSourceDropEvent) MindMapNodesSelection(org.freeplane.features.clipboard.MindMapNodesSelection)

Example 3 with DragSourceEvent

use of java.awt.dnd.DragSourceEvent in project jdk8u_jdk by JetBrains.

the class SunDragSourceContextPeer method dragDropFinished.

/**
     * upcall from native code via implemented class (do)
     */
protected final void dragDropFinished(final boolean success, final int operations, final int x, final int y) {
    DragSourceEvent event = new DragSourceDropEvent(getDragSourceContext(), operations & sourceActions, success, x, y);
    EventDispatcher dispatcher = new EventDispatcher(DISPATCH_FINISH, event);
    SunToolkit.invokeLaterOnAppContext(SunToolkit.targetToAppContext(getComponent()), dispatcher);
    startSecondaryEventLoop();
    setNativeContext(0);
    dragImage = null;
    dragImageOffset = null;
}
Also used : DragSourceEvent(java.awt.dnd.DragSourceEvent) DragSourceDropEvent(java.awt.dnd.DragSourceDropEvent)

Aggregations

DragSourceEvent (java.awt.dnd.DragSourceEvent)3 DragSourceDropEvent (java.awt.dnd.DragSourceDropEvent)2 Cursor (java.awt.Cursor)1 Rectangle (java.awt.Rectangle)1 Transferable (java.awt.datatransfer.Transferable)1 DragSourceDragEvent (java.awt.dnd.DragSourceDragEvent)1 DragSourceListener (java.awt.dnd.DragSourceListener)1 InvalidDnDOperationException (java.awt.dnd.InvalidDnDOperationException)1 MindMapNodesSelection (org.freeplane.features.clipboard.MindMapNodesSelection)1 NodeModel (org.freeplane.features.map.NodeModel)1 MainView (org.freeplane.view.swing.map.MainView)1 MapView (org.freeplane.view.swing.map.MapView)1 NodeView (org.freeplane.view.swing.map.NodeView)1