ACTION_NONE源码实例Demo

java.awt.dnd.DnDConstants#ACTION_NONE源码实例Demo

下面列出了java.awt.dnd.DnDConstants#ACTION_NONE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk8u-jdk   文件: XDragSourceContextPeer.java
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;
}
 
/**
 * 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());
}
 
源代码3 项目: openjdk-jdk8u   文件: XDragSourceContextPeer.java
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;
}
 
源代码4 项目: openjdk-jdk8u   文件: XDragSourceContextPeer.java
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;
}
 
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;
}
 
源代码6 项目: jdk8u60   文件: SunDropTargetContextPeer.java
/**
 * 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);
}
 
源代码7 项目: openjdk-jdk8u-backup   文件: XDnDConstants.java
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;
    }
}
 
/**
 * 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;
}
 
/**
 * 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;
    }
}
 
/**
 * 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;
}
 
源代码11 项目: openjdk-jdk9   文件: SunDropTargetContextPeer.java
/**
 * rejectDrag
 */

public synchronized void rejectDrag() {
    if (currentDT == null) {
        throw new InvalidDnDOperationException("No Drag pending");
    }
    currentDA = DnDConstants.ACTION_NONE;
    dragRejected = true;
}
 
源代码12 项目: jdk8u-jdk   文件: SunDropTargetContextPeer.java
/**
 * 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;
    }

}
 
源代码13 项目: openjdk-jdk8u   文件: XDnDConstants.java
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;
    }
}
 
源代码14 项目: openjdk-jdk9   文件: WMouseDragGestureRecognizer.java
/**
 * 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();
        }
    }
}
 
源代码15 项目: openjdk-jdk9   文件: SunDropTargetContextPeer.java
/**
 * 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()");
    }
}
 
/**
 * 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);
    }
}
 
源代码17 项目: openjdk-jdk9   文件: XDragSourceContextPeer.java
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;
}
 
源代码18 项目: TencentKona-8   文件: SunDropTargetContextPeer.java
/**
 *
 */

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;
    }
}
 
源代码19 项目: jdk8u60   文件: SunDropTargetContextPeer.java
/**
 *
 */

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;
    }
}
 
源代码20 项目: TencentKona-8   文件: XDnDDropTargetProtocol.java
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;
}
 
如果文章对您有帮助,请点击页面广告。以鼓励作者做出的努力。
 方法所在类