Java Code Examples for java.awt.dnd.DnDConstants#ACTION_NONE

The following examples show how to use java.awt.dnd.DnDConstants#ACTION_NONE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XDragSourceContextPeer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private void doUpdateTargetWindow(long subwindow, long time) {
    long clientWindow = 0;
    long proxyWindow = 0;
    XDragSourceProtocol protocol = null;
    boolean isReceiver = false;

    if (subwindow != 0) {
        clientWindow = findClientWindow(subwindow);
    }

    if (clientWindow != 0) {
        Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
        while (dragProtocols.hasNext()) {
            XDragSourceProtocol dragProtocol = (XDragSourceProtocol)dragProtocols.next();
            if (dragProtocol.attachTargetWindow(clientWindow, time)) {
                protocol = dragProtocol;
                break;
            }
        }
    }

    /* Update the global state. */
    dragProtocol = protocol;
    targetAction = DnDConstants.ACTION_NONE;
    targetRootSubwindow = subwindow;
}
 
Example 2
Source File: WMouseDragGestureRecognizer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * determine the drop action from the event
 */

protected int mapDragOperationFromModifiers(MouseEvent e) {
    int mods = e.getModifiersEx();
    int btns = mods & ButtonMask;

    // Prohibit multi-button drags.
    if (!(btns == InputEvent.BUTTON1_DOWN_MASK ||
          btns == InputEvent.BUTTON2_DOWN_MASK ||
          btns == InputEvent.BUTTON3_DOWN_MASK)) {
        return DnDConstants.ACTION_NONE;
    }

    return
        SunDragSourceContextPeer.convertModifiersToDropAction(mods,
                                                              getSourceActions());
}
 
Example 3
Source File: XDragSourceContextPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void handleDragReply(int action, int x, int y, int modifiers) {
    if (action == DnDConstants.ACTION_NONE &&
        targetAction != DnDConstants.ACTION_NONE) {
        dragExit(x, y);
    } else if (action != DnDConstants.ACTION_NONE) {
        int type = 0;

        if (targetAction == DnDConstants.ACTION_NONE) {
            type = SunDragSourceContextPeer.DISPATCH_ENTER;
        } else {
            type = SunDragSourceContextPeer.DISPATCH_MOTION;
        }

        // Note that we use the modifiers state a
        postDragSourceDragEvent(action, modifiers, x, y, type);
    }

    targetAction = action;
}
 
Example 4
Source File: SunDropTargetContextPeer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * reject Drop
 */

public synchronized void rejectDrop() {
    if (dropStatus != STATUS_WAIT) {
        throw new InvalidDnDOperationException("invalid rejectDrop()");
    }
    dropStatus = STATUS_REJECT;
    /*
     * Fix for 4285634.
     * The target rejected the drop means that it doesn't perform any
     * drop action. This change is to make Solaris behavior consistent
     * with Win32.
     */
    currentDA = DnDConstants.ACTION_NONE;
    dropComplete(false);
}
 
Example 5
Source File: XDragSourceContextPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void doUpdateTargetWindow(long subwindow, long time) {
    long clientWindow = 0;
    long proxyWindow = 0;
    XDragSourceProtocol protocol = null;
    boolean isReceiver = false;

    if (subwindow != 0) {
        clientWindow = findClientWindow(subwindow);
    }

    if (clientWindow != 0) {
        Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
        while (dragProtocols.hasNext()) {
            XDragSourceProtocol dragProtocol = (XDragSourceProtocol)dragProtocols.next();
            if (dragProtocol.attachTargetWindow(clientWindow, time)) {
                protocol = dragProtocol;
                break;
            }
        }
    }

    /* Update the global state. */
    dragProtocol = protocol;
    targetAction = DnDConstants.ACTION_NONE;
    targetRootSubwindow = subwindow;
}
 
Example 6
Source File: XDragSourceContextPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void doUpdateTargetWindow(long subwindow, long time) {
    long clientWindow = 0;
    long proxyWindow = 0;
    XDragSourceProtocol protocol = null;
    boolean isReceiver = false;

    if (subwindow != 0) {
        clientWindow = findClientWindow(subwindow);
    }

    if (clientWindow != 0) {
        Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
        while (dragProtocols.hasNext()) {
            XDragSourceProtocol dragProtocol = (XDragSourceProtocol)dragProtocols.next();
            if (dragProtocol.attachTargetWindow(clientWindow, time)) {
                protocol = dragProtocol;
                break;
            }
        }
    }

    /* Update the global state. */
    dragProtocol = protocol;
    targetAction = DnDConstants.ACTION_NONE;
    targetRootSubwindow = subwindow;
}
 
Example 7
Source File: XDragSourceContextPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void doUpdateTargetWindow(long subwindow, long time) {
    long clientWindow = 0;
    long proxyWindow = 0;
    XDragSourceProtocol protocol = null;
    boolean isReceiver = false;

    if (subwindow != 0) {
        clientWindow = findClientWindow(subwindow);
    }

    if (clientWindow != 0) {
        Iterator<XDragSourceProtocol> dragProtocols =
            XDragAndDropProtocols.getDragSourceProtocols();
        while (dragProtocols.hasNext()) {
            XDragSourceProtocol dragProtocol = dragProtocols.next();
            if (dragProtocol.attachTargetWindow(clientWindow, time)) {
                protocol = dragProtocol;
                break;
            }
        }
    }

    /* Update the global state. */
    dragProtocol = protocol;
    targetAction = DnDConstants.ACTION_NONE;
    targetRootSubwindow = subwindow;
}
 
Example 8
Source File: XDnDConstants.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static int getJavaActionForXDnDAction(long xdndAction) {
    if (xdndAction == XA_XdndActionCopy.getAtom()) {
        return DnDConstants.ACTION_COPY;
    } else if (xdndAction == XA_XdndActionMove.getAtom()) {
        return DnDConstants.ACTION_MOVE;
    } else if (xdndAction == XA_XdndActionLink.getAtom()) {
        return DnDConstants.ACTION_LINK;
    } else {
        return DnDConstants.ACTION_NONE;
    }
}
 
Example 9
Source File: XMouseDragGestureRecognizer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invoked when a mouse button has been pressed on a component.
 */

public void mousePressed(MouseEvent e) {
    events.clear();

    if (mapDragOperationFromModifiers(e) != DnDConstants.ACTION_NONE) {
        try {
            motionThreshold = DragSource.getDragThreshold();
        } catch (Exception exc) {
            motionThreshold = 5;
        }
        appendEvent(e);
    }
}
 
Example 10
Source File: SunDropTargetContextPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * acceptDrop
 */

public synchronized void acceptDrop(int dropOperation) {
    if (dropOperation == DnDConstants.ACTION_NONE)
        throw new IllegalArgumentException("invalid acceptDrop() action");

    if (dropStatus == STATUS_WAIT || dropStatus == STATUS_ACCEPT) {
        currentDA = currentA = mapOperation(dropOperation & currentSA);

        dropStatus   = STATUS_ACCEPT;
        dropComplete = false;
    } else {
        throw new InvalidDnDOperationException("invalid acceptDrop()");
    }
}
 
Example 11
Source File: WMouseDragGestureRecognizer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invoked when the mouse exits a component.
 */

@Override
public void mouseExited(MouseEvent e) {

    if (!events.isEmpty()) { // gesture pending
        int dragAction = mapDragOperationFromModifiers(e);

        if (dragAction == DnDConstants.ACTION_NONE) {
            events.clear();
        }
    }
}
 
Example 12
Source File: XDnDConstants.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static int getJavaActionForXDnDAction(long xdndAction) {
    if (xdndAction == XA_XdndActionCopy.getAtom()) {
        return DnDConstants.ACTION_COPY;
    } else if (xdndAction == XA_XdndActionMove.getAtom()) {
        return DnDConstants.ACTION_MOVE;
    } else if (xdndAction == XA_XdndActionLink.getAtom()) {
        return DnDConstants.ACTION_LINK;
    } else {
        return DnDConstants.ACTION_NONE;
    }
}
 
Example 13
Source File: SunDropTargetContextPeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * actual processing on EventQueue Thread
 */

protected void processEnterMessage(SunDropTargetEvent event) {
    Component  c    = (Component)event.getSource();
    DropTarget dt   = c.getDropTarget();
    Point      hots = event.getPoint();

    local = getJVMLocalSourceTransferable();

    if (currentDTC != null) { // some wreckage from last time
        currentDTC.removeNotify();
        currentDTC = null;
    }

    if (c.isShowing() && dt != null && dt.isActive()) {
        currentDT  = dt;
        currentDTC = currentDT.getDropTargetContext();

        currentDTC.addNotify(this);

        currentA   = dt.getDefaultActions();

        try {
            ((DropTargetListener)dt).dragEnter(new DropTargetDragEvent(currentDTC,
                                                                       hots,
                                                                       currentDA,
                                                                       currentSA));
        } catch (Exception e) {
            e.printStackTrace();
            currentDA = DnDConstants.ACTION_NONE;
        }
    } else {
        currentDT  = null;
        currentDTC = null;
        currentDA   = DnDConstants.ACTION_NONE;
        currentSA   = DnDConstants.ACTION_NONE;
        currentA   = DnDConstants.ACTION_NONE;
    }

}
 
Example 14
Source File: SunDropTargetContextPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * rejectDrag
 */

public synchronized void rejectDrag() {
    if (currentDT == null) {
        throw new InvalidDnDOperationException("No Drag pending");
    }
    currentDA = DnDConstants.ACTION_NONE;
    dragRejected = true;
}
 
Example 15
Source File: MotifDnDDropTargetProtocol.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reset the state of the object.
 */
public void cleanup() {
    // Clear the reference to this protocol.
    XDropTargetEventProcessor.reset();

    if (targetXWindow != null) {
        notifyProtocolListener(targetXWindow, 0, 0,
                               DnDConstants.ACTION_NONE, sourceActions,
                               null, MouseEvent.MOUSE_EXITED);
    }

    if (sourceWindow != 0) {
        XToolkit.awtLock();
        try {
            XErrorHandlerUtil.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
            XlibWrapper.XSelectInput(XToolkit.getDisplay(), sourceWindow,
                                     sourceWindowMask);
            XErrorHandlerUtil.RESTORE_XERROR_HANDLER();
        } finally {
            XToolkit.awtUnlock();
        }
    }

    sourceWindow = 0;
    sourceWindowMask = 0;
    sourceProtocolVersion = 0;
    sourceActions = DnDConstants.ACTION_NONE;
    sourceFormats = null;
    sourceAtom = 0;
    userAction = DnDConstants.ACTION_NONE;
    sourceX = 0;
    sourceY = 0;
    targetXWindow = null;
    topLevelLeavePostponed = false;
}
 
Example 16
Source File: SunDropTargetContextPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * signal drop complete
 */

public synchronized void dropComplete(boolean success) {
    if (dropStatus == STATUS_NONE) {
        throw new InvalidDnDOperationException("No Drop pending");
    }

    if (currentDTC != null) currentDTC.removeNotify();

    currentDT  = null;
    currentDTC = null;
    currentT   = null;
    currentA   = DnDConstants.ACTION_NONE;

    synchronized(_globalLock) {
        currentJVMLocalSourceTransferable = null;
    }

    dropStatus   = STATUS_NONE;
    dropComplete = true;

    try {
        doDropDone(success, currentDA, local != null);
    } finally {
        currentDA = DnDConstants.ACTION_NONE;
        // The native context is invalid after the drop is done.
        // Clear the reference to prohibit access.
        nativeDragContext = 0;
    }
}
 
Example 17
Source File: XDnDDropTargetProtocol.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reset the state of the object.
 */
public void cleanup() {
    // Clear the reference to this protocol.
    XDropTargetEventProcessor.reset();

    if (targetXWindow != null) {
        notifyProtocolListener(targetXWindow, 0, 0,
                               DnDConstants.ACTION_NONE, null,
                               MouseEvent.MOUSE_EXITED);
    }

    if (sourceWindow != 0) {
        XToolkit.awtLock();
        try {
            XErrorHandlerUtil.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
            XlibWrapper.XSelectInput(XToolkit.getDisplay(), sourceWindow,
                                     sourceWindowMask);
            XErrorHandlerUtil.RESTORE_XERROR_HANDLER();
        } finally {
            XToolkit.awtUnlock();
        }
    }

    sourceWindow = 0;
    sourceWindowMask = 0;
    sourceProtocolVersion = 0;
    sourceActions = DnDConstants.ACTION_NONE;
    sourceFormats = null;
    trackSourceActions = false;
    userAction = DnDConstants.ACTION_NONE;
    sourceX = 0;
    sourceY = 0;
    targetXWindow = null;
}
 
Example 18
Source File: XDnDDropTargetProtocol.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public boolean sendResponse(long ctxt, int eventID, int action) {
    XClientMessageEvent xclient = new XClientMessageEvent(ctxt);

    if (xclient.get_message_type() !=
        XDnDConstants.XA_XdndPosition.getAtom()) {

        return false;
    }

    if (eventID == MouseEvent.MOUSE_EXITED) {
        action = DnDConstants.ACTION_NONE;
    }

    XClientMessageEvent msg = new XClientMessageEvent();
    try {
        msg.set_type((int)XConstants.ClientMessage);
        msg.set_window(xclient.get_data(0));
        msg.set_format(32);
        msg.set_message_type(XDnDConstants.XA_XdndStatus.getAtom());
        /* target window */
        msg.set_data(0, xclient.get_window());
        /* flags */
        long flags = 0;
        if (action != DnDConstants.ACTION_NONE) {
            flags |= XDnDConstants.XDND_ACCEPT_DROP_FLAG;
        }
        msg.set_data(1, flags);
        /* specify an empty rectangle */
        msg.set_data(2, 0); /* x, y */
        msg.set_data(3, 0); /* w, h */
        /* action accepted by the target */
        msg.set_data(4, XDnDConstants.getXDnDActionForJavaAction(action));

        XToolkit.awtLock();
        try {
            XlibWrapper.XSendEvent(XToolkit.getDisplay(),
                                   xclient.get_data(0),
                                   false, XConstants.NoEventMask,
                                   msg.pData);
        } finally {
            XToolkit.awtUnlock();
        }
    } finally {
        msg.dispose();
    }

    return true;
}
 
Example 19
Source File: SunDropTargetContextPeer.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

protected void processExitMessage(SunDropTargetEvent event) {
    Component         c   = (Component)event.getSource();
    DropTarget        dt  = c.getDropTarget();
    DropTargetContext dtc = null;

    if (dt == null) {
        currentDT = null;
        currentT  = null;

        if (currentDTC != null) {
            currentDTC.removeNotify();
        }

        currentDTC = null;

        return;
    }

    if (dt != currentDT) {

        if (currentDTC != null) {
            currentDTC.removeNotify();
        }

        currentDT  = dt;
        currentDTC = dt.getDropTargetContext();

        currentDTC.addNotify(this);
    }

    dtc = currentDTC;

    if (dt.isActive()) try {
        ((DropTargetListener)dt).dragExit(new DropTargetEvent(dtc));
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        currentA  = DnDConstants.ACTION_NONE;
        currentSA = DnDConstants.ACTION_NONE;
        currentDA = DnDConstants.ACTION_NONE;
        currentDT = null;
        currentT  = null;

        currentDTC.removeNotify();
        currentDTC = null;

        local = null;

        dragRejected = false;
    }
}
 
Example 20
Source File: SunDropTargetContextPeer.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

protected void processExitMessage(SunDropTargetEvent event) {
    Component         c   = (Component)event.getSource();
    DropTarget        dt  = c.getDropTarget();
    DropTargetContext dtc = null;

    if (dt == null) {
        currentDT = null;
        currentT  = null;

        if (currentDTC != null) {
            currentDTC.removeNotify();
        }

        currentDTC = null;

        return;
    }

    if (dt != currentDT) {

        if (currentDTC != null) {
            currentDTC.removeNotify();
        }

        currentDT  = dt;
        currentDTC = dt.getDropTargetContext();

        currentDTC.addNotify(this);
    }

    dtc = currentDTC;

    if (dt.isActive()) try {
        ((DropTargetListener)dt).dragExit(new DropTargetEvent(dtc));
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        currentA  = DnDConstants.ACTION_NONE;
        currentSA = DnDConstants.ACTION_NONE;
        currentDA = DnDConstants.ACTION_NONE;
        currentDT = null;
        currentT  = null;

        currentDTC.removeNotify();
        currentDTC = null;

        local = null;

        dragRejected = false;
    }
}