类java.awt.dnd.InvalidDnDOperationException源码实例Demo

下面列出了怎么用java.awt.dnd.InvalidDnDOperationException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: dragonwell8_jdk   文件: XDragSourceProtocol.java
/**
 * Initializes a drag operation with the specified supported drop actions,
 * contents and data formats.
 *
 * @param actions a bitwise mask of <code>DnDConstants</code> that represent
 *                the supported drop actions.
 * @param contents the contents for the drag operation.
 * @param formats an array of Atoms that represent the supported data formats.
 * @param formats an array of Atoms that represent the supported data formats.
 * @throws InvalidDnDOperationException if a drag operation is already
 * initialized.
 * @throws IllegalArgumentException if some argument has invalid value.
 * @throws XException if some X call failed.
 */
public final void initializeDrag(int actions, Transferable contents,
                                 Map formatMap, long[] formats)
  throws InvalidDnDOperationException,
         IllegalArgumentException, XException {
    XToolkit.awtLock();
    try {
        try {
            if (initialized) {
                throw new InvalidDnDOperationException("Already initialized");
            }

            initializeDragImpl(actions, contents, formatMap, formats);

            initialized = true;
        } finally {
            if (!initialized) {
                cleanup();
            }
        }
    } finally {
        XToolkit.awtUnlock();
    }
}
 
源代码2 项目: TencentKona-8   文件: SunDropTargetContextPeer.java
void dispatchEvent(SunDropTargetEvent e) {
    int id = e.getID();

    switch (id) {
    case SunDropTargetEvent.MOUSE_ENTERED:
        dispatchEnterEvent(e);
        break;
    case SunDropTargetEvent.MOUSE_DRAGGED:
        dispatchMotionEvent(e);
        break;
    case SunDropTargetEvent.MOUSE_EXITED:
        dispatchExitEvent(e);
        break;
    case SunDropTargetEvent.MOUSE_DROPPED:
        dispatchDropEvent(e);
        break;
    default:
        throw new InvalidDnDOperationException();
    }
}
 
源代码3 项目: TencentKona-8   文件: XDragSourceProtocol.java
/**
 * Initializes a drag operation with the specified supported drop actions,
 * contents and data formats.
 *
 * @param actions a bitwise mask of <code>DnDConstants</code> that represent
 *                the supported drop actions.
 * @param contents the contents for the drag operation.
 * @param formats an array of Atoms that represent the supported data formats.
 * @param formats an array of Atoms that represent the supported data formats.
 * @throws InvalidDnDOperationException if a drag operation is already
 * initialized.
 * @throws IllegalArgumentException if some argument has invalid value.
 * @throws XException if some X call failed.
 */
public final void initializeDrag(int actions, Transferable contents,
                                 Map formatMap, long[] formats)
  throws InvalidDnDOperationException,
         IllegalArgumentException, XException {
    XToolkit.awtLock();
    try {
        try {
            if (initialized) {
                throw new InvalidDnDOperationException("Already initialized");
            }

            initializeDragImpl(actions, contents, formatMap, formats);

            initialized = true;
        } finally {
            if (!initialized) {
                cleanup();
            }
        }
    } finally {
        XToolkit.awtUnlock();
    }
}
 
源代码4 项目: 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);
}
 
源代码5 项目: jdk8u60   文件: SunDropTargetContextPeer.java
void dispatchEvent(SunDropTargetEvent e) {
    int id = e.getID();

    switch (id) {
    case SunDropTargetEvent.MOUSE_ENTERED:
        dispatchEnterEvent(e);
        break;
    case SunDropTargetEvent.MOUSE_DRAGGED:
        dispatchMotionEvent(e);
        break;
    case SunDropTargetEvent.MOUSE_EXITED:
        dispatchExitEvent(e);
        break;
    case SunDropTargetEvent.MOUSE_DROPPED:
        dispatchDropEvent(e);
        break;
    default:
        throw new InvalidDnDOperationException();
    }
}
 
源代码6 项目: openjdk-jdk8u   文件: SunDropTargetContextPeer.java
void dispatchEvent(SunDropTargetEvent e) {
    int id = e.getID();

    switch (id) {
    case SunDropTargetEvent.MOUSE_ENTERED:
        dispatchEnterEvent(e);
        break;
    case SunDropTargetEvent.MOUSE_DRAGGED:
        dispatchMotionEvent(e);
        break;
    case SunDropTargetEvent.MOUSE_EXITED:
        dispatchExitEvent(e);
        break;
    case SunDropTargetEvent.MOUSE_DROPPED:
        dispatchDropEvent(e);
        break;
    default:
        throw new InvalidDnDOperationException();
    }
}
 
源代码7 项目: jdk8u60   文件: WToolkit.java
/**
 * create the peer for a DragSourceContext
 */

@Override
public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
    final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent());
    if (f != null) {
        return f.createDragSourceContextPeer(dge);
    }

    return WDragSourceContextPeer.createDragSourceContextPeer(dge);
}
 
源代码8 项目: openjdk-jdk8u   文件: SunDragSourceContextPeer.java
/**
 * initiate a DnD operation ...
 */

public void startDrag(DragSourceContext dsc, Cursor c, Image di, Point p)
  throws InvalidDnDOperationException {

    /* Fix for 4354044: don't initiate a drag if event sequence provided by
     * DragGestureRecognizer is empty */
    if (getTrigger().getTriggerEvent() == null) {
        throw new InvalidDnDOperationException("DragGestureEvent has a null trigger");
    }

    dragSourceContext = dsc;
    cursor            = c;
    sourceActions     = getDragSourceContext().getSourceActions();
    dragImage         = di;
    dragImageOffset   = p;

    Transferable transferable  = getDragSourceContext().getTransferable();
    SortedMap<Long,DataFlavor> formatMap = DataTransferer.getInstance().
        getFormatsForTransferable(transferable, DataTransferer.adaptFlavorMap
            (getTrigger().getDragSource().getFlavorMap()));
    long[] formats = DataTransferer.getInstance().
        keysToLongArray(formatMap);
    startDrag(transferable, formats, formatMap);

    /*
     * Fix for 4613903.
     * Filter out all mouse events that are currently on the event queue.
     */
    discardingMouseEvents = true;
    EventQueue.invokeLater(new Runnable() {
            public void run() {
                discardingMouseEvents = false;
            }
        });
}
 
源代码9 项目: openjdk-jdk8u   文件: XDragSourceContextPeer.java
private void throwGrabFailureException(String msg, int grabStatus)
  throws InvalidDnDOperationException {
    String msgCause = "";
    switch (grabStatus) {
    case XConstants.GrabNotViewable:  msgCause = "not viewable";    break;
    case XConstants.AlreadyGrabbed:   msgCause = "already grabbed"; break;
    case XConstants.GrabInvalidTime:  msgCause = "invalid time";    break;
    case XConstants.GrabFrozen:       msgCause = "grab frozen";     break;
    default:                           msgCause = "unknown failure"; break;
    }
    throw new InvalidDnDOperationException(msg + ": " + msgCause);
}
 
源代码10 项目: dragonwell8_jdk   文件: SunDropTargetContextPeer.java
/**
 * 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;
    }
}
 
源代码11 项目: openjdk-jdk8u   文件: SunDropTargetContextPeer.java
/**
 * acceptDrag
 */

public synchronized void acceptDrag(int dragOperation) {
    if (currentDT == null) {
        throw new InvalidDnDOperationException("No Drag pending");
    }
    currentDA = mapOperation(dragOperation);
    if (currentDA != DnDConstants.ACTION_NONE) {
        dragRejected = false;
    }
}
 
源代码12 项目: dragonwell8_jdk   文件: SunDragSourceContextPeer.java
/**
 * initiate a DnD operation ...
 */

public void startDrag(DragSourceContext dsc, Cursor c, Image di, Point p)
  throws InvalidDnDOperationException {

    /* Fix for 4354044: don't initiate a drag if event sequence provided by
     * DragGestureRecognizer is empty */
    if (getTrigger().getTriggerEvent() == null) {
        throw new InvalidDnDOperationException("DragGestureEvent has a null trigger");
    }

    dragSourceContext = dsc;
    cursor            = c;
    sourceActions     = getDragSourceContext().getSourceActions();
    dragImage         = di;
    dragImageOffset   = p;

    Transferable transferable  = getDragSourceContext().getTransferable();
    SortedMap<Long,DataFlavor> formatMap = DataTransferer.getInstance().
        getFormatsForTransferable(transferable, DataTransferer.adaptFlavorMap
            (getTrigger().getDragSource().getFlavorMap()));
    long[] formats = DataTransferer.getInstance().
        keysToLongArray(formatMap);
    startDrag(transferable, formats, formatMap);

    /*
     * Fix for 4613903.
     * Filter out all mouse events that are currently on the event queue.
     */
    discardingMouseEvents = true;
    EventQueue.invokeLater(new Runnable() {
            public void run() {
                discardingMouseEvents = false;
            }
        });
}
 
源代码13 项目: dragonwell8_jdk   文件: SunDragSourceContextPeer.java
/**
 * set cursor
 */

public void setCursor(Cursor c) throws InvalidDnDOperationException {
    synchronized (this) {
        if (cursor == null || !cursor.equals(c)) {
            cursor = c;
            // NOTE: native context can be null at this point.
            // setNativeCursor() should handle it properly.
            setNativeCursor(getNativeContext(), c,
                            c != null ? c.getType() : 0);
        }
    }
}
 
源代码14 项目: openjdk-jdk8u   文件: SunDropTargetContextPeer.java
/**
 * 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;
    }
}
 
源代码15 项目: dragonwell8_jdk   文件: WToolkit.java
/**
 * create the peer for a DragSourceContext
 */

@Override
public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
    final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent());
    if (f != null) {
        return f.createDragSourceContextPeer(dge);
    }

    return WDragSourceContextPeer.createDragSourceContextPeer(dge);
}
 
protected void initializeDragImpl(int actions, Transferable contents,
                                  Map formatMap, long[] formats)
  throws InvalidDnDOperationException,
    IllegalArgumentException, XException {

    long window = XDragSourceProtocol.getDragSourceWindow();

    /* Write the Motif DnD initiator info on the root XWindow. */
    try {
        int index = MotifDnDConstants.getIndexForTargetList(formats);

        MotifDnDConstants.writeDragInitiatorInfoStruct(window, index);
    } catch (XException xe) {
        cleanup();
        throw xe;
    } catch (InvalidDnDOperationException idoe) {
        cleanup();
        throw idoe;
    }

    if (!MotifDnDConstants.MotifDnDSelection.setOwner(contents, formatMap,
                                                      formats,
                                                      XConstants.CurrentTime)) {
        cleanup();
        throw new InvalidDnDOperationException("Cannot acquire selection ownership");
    }
}
 
源代码17 项目: dragonwell8_jdk   文件: XDragSourceContextPeer.java
/**
 * set cursor
 */

public void setCursor(Cursor c) throws InvalidDnDOperationException {
    XToolkit.awtLock();
    try {
        super.setCursor(c);
    } finally {
        XToolkit.awtUnlock();
    }
}
 
源代码18 项目: dragonwell8_jdk   文件: XDragSourceContextPeer.java
private void throwGrabFailureException(String msg, int grabStatus)
  throws InvalidDnDOperationException {
    String msgCause = "";
    switch (grabStatus) {
    case XConstants.GrabNotViewable:  msgCause = "not viewable";    break;
    case XConstants.AlreadyGrabbed:   msgCause = "already grabbed"; break;
    case XConstants.GrabInvalidTime:  msgCause = "invalid time";    break;
    case XConstants.GrabFrozen:       msgCause = "grab frozen";     break;
    default:                           msgCause = "unknown failure"; break;
    }
    throw new InvalidDnDOperationException(msg + ": " + msgCause);
}
 
源代码19 项目: dragonwell8_jdk   文件: XToolkit.java
public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
    final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent());
    if (f != null) {
        return f.createDragSourceContextPeer(dge);
    }

    return XDragSourceContextPeer.createDragSourceContextPeer(dge);
}
 
源代码20 项目: TencentKona-8   文件: SunDropTargetContextPeer.java
public static void setCurrentJVMLocalSourceTransferable(Transferable t) throws InvalidDnDOperationException {
    synchronized(_globalLock) {
        if (t != null && currentJVMLocalSourceTransferable != null) {
                throw new InvalidDnDOperationException();
        } else {
            currentJVMLocalSourceTransferable = t;
        }
    }
}
 
源代码21 项目: TencentKona-8   文件: SunDropTargetContextPeer.java
/**
 * acceptDrag
 */

public synchronized void acceptDrag(int dragOperation) {
    if (currentDT == null) {
        throw new InvalidDnDOperationException("No Drag pending");
    }
    currentDA = mapOperation(dragOperation);
    if (currentDA != DnDConstants.ACTION_NONE) {
        dragRejected = false;
    }
}
 
源代码22 项目: jdk8u60   文件: XDragSourceContextPeer.java
/**
 * set cursor
 */

public void setCursor(Cursor c) throws InvalidDnDOperationException {
    XToolkit.awtLock();
    try {
        super.setCursor(c);
    } finally {
        XToolkit.awtUnlock();
    }
}
 
源代码23 项目: TencentKona-8   文件: SunDropTargetContextPeer.java
/**
 * 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;
    }
}
 
源代码24 项目: TencentKona-8   文件: SunDragSourceContextPeer.java
/**
 * initiate a DnD operation ...
 */

public void startDrag(DragSourceContext dsc, Cursor c, Image di, Point p)
  throws InvalidDnDOperationException {

    /* Fix for 4354044: don't initiate a drag if event sequence provided by
     * DragGestureRecognizer is empty */
    if (getTrigger().getTriggerEvent() == null) {
        throw new InvalidDnDOperationException("DragGestureEvent has a null trigger");
    }

    dragSourceContext = dsc;
    cursor            = c;
    sourceActions     = getDragSourceContext().getSourceActions();
    dragImage         = di;
    dragImageOffset   = p;

    Transferable transferable  = getDragSourceContext().getTransferable();
    SortedMap<Long,DataFlavor> formatMap = DataTransferer.getInstance().
        getFormatsForTransferable(transferable, DataTransferer.adaptFlavorMap
            (getTrigger().getDragSource().getFlavorMap()));
    long[] formats = DataTransferer.getInstance().
        keysToLongArray(formatMap);
    startDrag(transferable, formats, formatMap);

    /*
     * Fix for 4613903.
     * Filter out all mouse events that are currently on the event queue.
     */
    discardingMouseEvents = true;
    EventQueue.invokeLater(new Runnable() {
            public void run() {
                discardingMouseEvents = false;
            }
        });
}
 
源代码25 项目: TencentKona-8   文件: SunDragSourceContextPeer.java
/**
 * set cursor
 */

public void setCursor(Cursor c) throws InvalidDnDOperationException {
    synchronized (this) {
        if (cursor == null || !cursor.equals(c)) {
            cursor = c;
            // NOTE: native context can be null at this point.
            // setNativeCursor() should handle it properly.
            setNativeCursor(getNativeContext(), c,
                            c != null ? c.getType() : 0);
        }
    }
}
 
源代码26 项目: TencentKona-8   文件: SunDragSourceContextPeer.java
public static void setDragDropInProgress(boolean b)
  throws InvalidDnDOperationException {
    synchronized (SunDragSourceContextPeer.class) {
        if (dragDropInProgress == b) {
            throw new InvalidDnDOperationException(getExceptionMessage(b));
        }
        dragDropInProgress = b;
    }
}
 
源代码27 项目: openjdk-jdk8u   文件: XDragSourceContextPeer.java
/**
 * set cursor
 */

public void setCursor(Cursor c) throws InvalidDnDOperationException {
    XToolkit.awtLock();
    try {
        super.setCursor(c);
    } finally {
        XToolkit.awtUnlock();
    }
}
 
源代码28 项目: TencentKona-8   文件: WToolkit.java
/**
 * create the peer for a DragSourceContext
 */

@Override
public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
    final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent());
    if (f != null) {
        return f.createDragSourceContextPeer(dge);
    }

    return WDragSourceContextPeer.createDragSourceContextPeer(dge);
}
 
源代码29 项目: TencentKona-8   文件: MotifDnDDragSourceProtocol.java
protected void initializeDragImpl(int actions, Transferable contents,
                                  Map formatMap, long[] formats)
  throws InvalidDnDOperationException,
    IllegalArgumentException, XException {

    long window = XDragSourceProtocol.getDragSourceWindow();

    /* Write the Motif DnD initiator info on the root XWindow. */
    try {
        int index = MotifDnDConstants.getIndexForTargetList(formats);

        MotifDnDConstants.writeDragInitiatorInfoStruct(window, index);
    } catch (XException xe) {
        cleanup();
        throw xe;
    } catch (InvalidDnDOperationException idoe) {
        cleanup();
        throw idoe;
    }

    if (!MotifDnDConstants.MotifDnDSelection.setOwner(contents, formatMap,
                                                      formats,
                                                      XConstants.CurrentTime)) {
        cleanup();
        throw new InvalidDnDOperationException("Cannot acquire selection ownership");
    }
}
 
源代码30 项目: jdk8u60   文件: MotifDnDDragSourceProtocol.java
protected void initializeDragImpl(int actions, Transferable contents,
                                  Map formatMap, long[] formats)
  throws InvalidDnDOperationException,
    IllegalArgumentException, XException {

    long window = XDragSourceProtocol.getDragSourceWindow();

    /* Write the Motif DnD initiator info on the root XWindow. */
    try {
        int index = MotifDnDConstants.getIndexForTargetList(formats);

        MotifDnDConstants.writeDragInitiatorInfoStruct(window, index);
    } catch (XException xe) {
        cleanup();
        throw xe;
    } catch (InvalidDnDOperationException idoe) {
        cleanup();
        throw idoe;
    }

    if (!MotifDnDConstants.MotifDnDSelection.setOwner(contents, formatMap,
                                                      formats,
                                                      XConstants.CurrentTime)) {
        cleanup();
        throw new InvalidDnDOperationException("Cannot acquire selection ownership");
    }
}
 
 类所在包
 类方法
 同包方法