Java Code Examples for sun.awt.dnd.SunDropTargetEvent

The following examples show how to use sun.awt.dnd.SunDropTargetEvent. These examples are extracted from open source projects. 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 Project: jdk1.8-source-analysis   Source File: Container.java    License: Apache License 2.0 6 votes vote down vote up
private void trackMouseEnterExit(Component targetOver, MouseEvent e) {
    if (e instanceof SunDropTargetEvent) {
        trackDropTargetEnterExit(targetOver, e);
        return;
    }
    int id = e.getID();

    if ( id != MouseEvent.MOUSE_EXITED &&
         id != MouseEvent.MOUSE_DRAGGED &&
         id != LWD_MOUSE_DRAGGED_OVER &&
            !isMouseInNativeContainer) {
        // any event but an exit or drag means we're in the native container
        isMouseInNativeContainer = true;
        startListeningForOtherDrags();
    } else if (id == MouseEvent.MOUSE_EXITED) {
        isMouseInNativeContainer = false;
        stopListeningForOtherDrags();
    }
    Component tle = retargetMouseEnterExit(targetOver, e,
                                               targetLastEntered.get(),
                                               isMouseInNativeContainer);
    targetLastEntered = new WeakReference<>(tle);
}
 
Example 2
Source Project: Java8CN   Source File: Container.java    License: Apache License 2.0 6 votes vote down vote up
private void trackMouseEnterExit(Component targetOver, MouseEvent e) {
    if (e instanceof SunDropTargetEvent) {
        trackDropTargetEnterExit(targetOver, e);
        return;
    }
    int id = e.getID();

    if ( id != MouseEvent.MOUSE_EXITED &&
         id != MouseEvent.MOUSE_DRAGGED &&
         id != LWD_MOUSE_DRAGGED_OVER &&
            !isMouseInNativeContainer) {
        // any event but an exit or drag means we're in the native container
        isMouseInNativeContainer = true;
        startListeningForOtherDrags();
    } else if (id == MouseEvent.MOUSE_EXITED) {
        isMouseInNativeContainer = false;
        stopListeningForOtherDrags();
    }
    Component tle = retargetMouseEnterExit(targetOver, e,
                                               targetLastEntered.get(),
                                               isMouseInNativeContainer);
    targetLastEntered = new WeakReference<>(tle);
}
 
Example 3
protected void eventProcessed(SunDropTargetEvent e, int returnValue,
                              boolean dispatcherDone) {
    /* The native context is the pointer to the XClientMessageEvent
       structure. */
    long ctxt = getNativeDragContext();
    /* If the event was not consumed, send a response to the source. */
    try {
        if (ctxt != 0 && !e.isConsumed()) {
            Iterator dropTargetProtocols =
                XDragAndDropProtocols.getDropTargetProtocols();

            while (dropTargetProtocols.hasNext()) {
                XDropTargetProtocol dropTargetProtocol =
                    (XDropTargetProtocol)dropTargetProtocols.next();
                if (dropTargetProtocol.sendResponse(ctxt, e.getID(),
                                                    returnValue)) {
                    break;
                }
            }
        }
    } finally {
        if (dispatcherDone && ctxt != 0) {
            unsafe.freeMemory(ctxt);
        }
    }
}
 
Example 4
Source Project: dragonwell8_jdk   Source File: Container.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void trackMouseEnterExit(Component targetOver, MouseEvent e) {
    if (e instanceof SunDropTargetEvent) {
        trackDropTargetEnterExit(targetOver, e);
        return;
    }
    int id = e.getID();

    if ( id != MouseEvent.MOUSE_EXITED &&
         id != MouseEvent.MOUSE_DRAGGED &&
         id != LWD_MOUSE_DRAGGED_OVER &&
            !isMouseInNativeContainer) {
        // any event but an exit or drag means we're in the native container
        isMouseInNativeContainer = true;
        startListeningForOtherDrags();
    } else if (id == MouseEvent.MOUSE_EXITED) {
        isMouseInNativeContainer = false;
        stopListeningForOtherDrags();
    }
    Component tle = retargetMouseEnterExit(targetOver, e,
                                               targetLastEntered.get(),
                                               isMouseInNativeContainer);
    targetLastEntered = new WeakReference<>(tle);
}
 
Example 5
protected void eventProcessed(SunDropTargetEvent e, int returnValue,
                              boolean dispatcherDone) {
    /* The native context is the pointer to the XClientMessageEvent
       structure. */
    long ctxt = getNativeDragContext();
    /* If the event was not consumed, send a response to the source. */
    try {
        if (ctxt != 0 && !e.isConsumed()) {
            Iterator dropTargetProtocols =
                XDragAndDropProtocols.getDropTargetProtocols();

            while (dropTargetProtocols.hasNext()) {
                XDropTargetProtocol dropTargetProtocol =
                    (XDropTargetProtocol)dropTargetProtocols.next();
                if (dropTargetProtocol.sendResponse(ctxt, e.getID(),
                                                    returnValue)) {
                    break;
                }
            }
        }
    } finally {
        if (dispatcherDone && ctxt != 0) {
            unsafe.freeMemory(ctxt);
        }
    }
}
 
Example 6
Source Project: jdk8u-jdk   Source File: EventQueue.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static int eventToCacheIndex(AWTEvent e) {
    switch(e.getID()) {
    case PaintEvent.PAINT:
        return PAINT;
    case PaintEvent.UPDATE:
        return UPDATE;
    case MouseEvent.MOUSE_MOVED:
        return MOVE;
    case MouseEvent.MOUSE_DRAGGED:
        // Return -1 for SunDropTargetEvent since they are usually synchronous
        // and we don't want to skip them by coalescing with MouseEvent or other drag events
        return e instanceof SunDropTargetEvent ? -1 : DRAG;
    default:
        return e instanceof PeerEvent ? PEER : -1;
    }
}
 
Example 7
@Override
protected void processMotionMessage(SunDropTargetEvent event, boolean operationChanged) {
    boolean eventInsideTarget = isEventInsideTarget(event);
    if (event.getComponent().getDropTarget() == insideTarget) {
        if (!eventInsideTarget) {
            processExitMessage(event);
            return;
        }
    } else {
        if (eventInsideTarget) {
            processEnterMessage(event);
        } else {
            return;
        }
    }
    super.processMotionMessage(event, operationChanged);
}
 
Example 8
@Override
protected void eventPosted(final SunDropTargetEvent e) {
    if (e.getID() != SunDropTargetEvent.MOUSE_DROPPED) {
        Runnable runnable = new Runnable() {
                @Override
                public void run() {
                    e.getDispatcher().unregisterAllEvents();
                }
            };
        // NOTE: this PeerEvent must be a NORM_PRIORITY event to be
        // dispatched after this SunDropTargetEvent, but before the next
        // one, so we should pass zero flags.
        PeerEvent peerEvent = new PeerEvent(e.getSource(), runnable, 0);
        SunToolkit.executeOnEventHandlerThread(peerEvent);
    }
}
 
Example 9
@Override
protected void eventPosted(final SunDropTargetEvent e) {
    if (e.getID() != SunDropTargetEvent.MOUSE_DROPPED) {
        Runnable runnable = new Runnable() {
                @Override
                public void run() {
                    e.getDispatcher().unregisterAllEvents();
                }
            };
        // NOTE: this PeerEvent must be a NORM_PRIORITY event to be
        // dispatched after this SunDropTargetEvent, but before the next
        // one, so we should pass zero flags.
        PeerEvent peerEvent = new PeerEvent(e.getSource(), runnable, 0);
        SunToolkit.executeOnEventHandlerThread(peerEvent);
    }
}
 
Example 10
@Override
protected void processMotionMessage(SunDropTargetEvent event, boolean operationChanged) {
    boolean eventInsideTarget = isEventInsideTarget(event);
    if (event.getComponent().getDropTarget() == insideTarget) {
        if (!eventInsideTarget) {
            processExitMessage(event);
            return;
        }
    } else {
        if (eventInsideTarget) {
            processEnterMessage(event);
        } else {
            return;
        }
    }
    super.processMotionMessage(event, operationChanged);
}
 
Example 11
Source Project: jdk8u_jdk   Source File: EventQueue.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static int eventToCacheIndex(AWTEvent e) {
    switch(e.getID()) {
    case PaintEvent.PAINT:
        return PAINT;
    case PaintEvent.UPDATE:
        return UPDATE;
    case MouseEvent.MOUSE_MOVED:
        return MOVE;
    case MouseEvent.MOUSE_DRAGGED:
        // Return -1 for SunDropTargetEvent since they are usually synchronous
        // and we don't want to skip them by coalescing with MouseEvent or other drag events
        return e instanceof SunDropTargetEvent ? -1 : DRAG;
    default:
        return e instanceof PeerEvent ? PEER : -1;
    }
}
 
Example 12
@Override
protected void eventPosted(final SunDropTargetEvent e) {
    if (e.getID() != SunDropTargetEvent.MOUSE_DROPPED) {
        Runnable runnable = new Runnable() {
                @Override
                public void run() {
                    e.getDispatcher().unregisterAllEvents();
                }
            };
        // NOTE: this PeerEvent must be a NORM_PRIORITY event to be
        // dispatched after this SunDropTargetEvent, but before the next
        // one, so we should pass zero flags.
        PeerEvent peerEvent = new PeerEvent(e.getSource(), runnable, 0);
        SunToolkit.executeOnEventHandlerThread(peerEvent);
    }
}
 
Example 13
@Override
protected void processMotionMessage(SunDropTargetEvent event, boolean operationChanged) {
    boolean eventInsideTarget = isEventInsideTarget(event);
    if (event.getComponent().getDropTarget() == insideTarget) {
        if (!eventInsideTarget) {
            processExitMessage(event);
            return;
        }
    } else {
        if (eventInsideTarget) {
            processEnterMessage(event);
        } else {
            return;
        }
    }
    super.processMotionMessage(event, operationChanged);
}
 
Example 14
@Override
protected void eventPosted(final SunDropTargetEvent e) {
    if (e.getID() != SunDropTargetEvent.MOUSE_DROPPED) {
        Runnable runnable = new Runnable() {
                @Override
                public void run() {
                    e.getDispatcher().unregisterAllEvents();
                }
            };
        // NOTE: this PeerEvent must be a NORM_PRIORITY event to be
        // dispatched after this SunDropTargetEvent, but before the next
        // one, so we should pass zero flags.
        PeerEvent peerEvent = new PeerEvent(e.getSource(), runnable, 0);
        SunToolkit.executeOnEventHandlerThread(peerEvent);
    }
}
 
Example 15
protected void eventProcessed(SunDropTargetEvent e, int returnValue,
                              boolean dispatcherDone) {
    /* The native context is the pointer to the XClientMessageEvent
       structure. */
    long ctxt = getNativeDragContext();
    /* If the event was not consumed, send a response to the source. */
    try {
        if (ctxt != 0 && !e.isConsumed()) {
            Iterator dropTargetProtocols =
                XDragAndDropProtocols.getDropTargetProtocols();

            while (dropTargetProtocols.hasNext()) {
                XDropTargetProtocol dropTargetProtocol =
                    (XDropTargetProtocol)dropTargetProtocols.next();
                if (dropTargetProtocol.sendResponse(ctxt, e.getID(),
                                                    returnValue)) {
                    break;
                }
            }
        }
    } finally {
        if (dispatcherDone && ctxt != 0) {
            unsafe.freeMemory(ctxt);
        }
    }
}
 
Example 16
@Override
protected void eventPosted(final SunDropTargetEvent e) {
    if (e.getID() != SunDropTargetEvent.MOUSE_DROPPED) {
        Runnable runnable = new Runnable() {
                @Override
                public void run() {
                    e.getDispatcher().unregisterAllEvents();
                }
            };
        // NOTE: this PeerEvent must be a NORM_PRIORITY event to be
        // dispatched after this SunDropTargetEvent, but before the next
        // one, so we should pass zero flags.
        PeerEvent peerEvent = new PeerEvent(e.getSource(), runnable, 0);
        SunToolkit.executeOnEventHandlerThread(peerEvent);
    }
}
 
Example 17
Source Project: jdk8u_jdk   Source File: Container.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void trackMouseEnterExit(Component targetOver, MouseEvent e) {
    if (e instanceof SunDropTargetEvent) {
        trackDropTargetEnterExit(targetOver, e);
        return;
    }
    int id = e.getID();

    if ( id != MouseEvent.MOUSE_EXITED &&
         id != MouseEvent.MOUSE_DRAGGED &&
         id != LWD_MOUSE_DRAGGED_OVER &&
            !isMouseInNativeContainer) {
        // any event but an exit or drag means we're in the native container
        isMouseInNativeContainer = true;
        startListeningForOtherDrags();
    } else if (id == MouseEvent.MOUSE_EXITED) {
        isMouseInNativeContainer = false;
        stopListeningForOtherDrags();
    }
    Component tle = retargetMouseEnterExit(targetOver, e,
                                               targetLastEntered.get(),
                                               isMouseInNativeContainer);
    targetLastEntered = new WeakReference<>(tle);
}
 
Example 18
Source Project: Bytecoder   Source File: Container.java    License: Apache License 2.0 6 votes vote down vote up
private void trackMouseEnterExit(Component targetOver, MouseEvent e) {
    if (e instanceof SunDropTargetEvent) {
        trackDropTargetEnterExit(targetOver, e);
        return;
    }
    int id = e.getID();

    if ( id != MouseEvent.MOUSE_EXITED &&
         id != MouseEvent.MOUSE_DRAGGED &&
         id != LWD_MOUSE_DRAGGED_OVER &&
            !isMouseInNativeContainer) {
        // any event but an exit or drag means we're in the native container
        isMouseInNativeContainer = true;
        startListeningForOtherDrags();
    } else if (id == MouseEvent.MOUSE_EXITED) {
        isMouseInNativeContainer = false;
        stopListeningForOtherDrags();
    }
    Component tle = retargetMouseEnterExit(targetOver, e,
                                               targetLastEntered.get(),
                                               isMouseInNativeContainer);
    targetLastEntered = new WeakReference<>(tle);
}
 
Example 19
Source Project: openjdk-jdk8u   Source File: Container.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void trackMouseEnterExit(Component targetOver, MouseEvent e) {
    if (e instanceof SunDropTargetEvent) {
        trackDropTargetEnterExit(targetOver, e);
        return;
    }
    int id = e.getID();

    if ( id != MouseEvent.MOUSE_EXITED &&
         id != MouseEvent.MOUSE_DRAGGED &&
         id != LWD_MOUSE_DRAGGED_OVER &&
            !isMouseInNativeContainer) {
        // any event but an exit or drag means we're in the native container
        isMouseInNativeContainer = true;
        startListeningForOtherDrags();
    } else if (id == MouseEvent.MOUSE_EXITED) {
        isMouseInNativeContainer = false;
        stopListeningForOtherDrags();
    }
    Component tle = retargetMouseEnterExit(targetOver, e,
                                               targetLastEntered.get(),
                                               isMouseInNativeContainer);
    targetLastEntered = new WeakReference<>(tle);
}
 
Example 20
Source Project: openjdk-8   Source File: EventQueue.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static int eventToCacheIndex(AWTEvent e) {
    switch(e.getID()) {
    case PaintEvent.PAINT:
        return PAINT;
    case PaintEvent.UPDATE:
        return UPDATE;
    case MouseEvent.MOUSE_MOVED:
        return MOVE;
    case MouseEvent.MOUSE_DRAGGED:
        // Return -1 for SunDropTargetEvent since they are usually synchronous
        // and we don't want to skip them by coalescing with MouseEvent or other drag events
        return e instanceof SunDropTargetEvent ? -1 : DRAG;
    default:
        return e instanceof PeerEvent ? PEER : -1;
    }
}
 
Example 21
@Override
protected void eventPosted(final SunDropTargetEvent e) {
    if (e.getID() != SunDropTargetEvent.MOUSE_DROPPED) {
        Runnable runnable = new Runnable() {
                @Override
                public void run() {
                    e.getDispatcher().unregisterAllEvents();
                }
            };
        // NOTE: this PeerEvent must be a NORM_PRIORITY event to be
        // dispatched after this SunDropTargetEvent, but before the next
        // one, so we should pass zero flags.
        PeerEvent peerEvent = new PeerEvent(e.getSource(), runnable, 0);
        SunToolkit.executeOnEventHandlerThread(peerEvent);
    }
}
 
Example 22
protected void eventProcessed(SunDropTargetEvent e, int returnValue,
                              boolean dispatcherDone) {
    /* The native context is the pointer to the XClientMessageEvent
       structure. */
    long ctxt = getNativeDragContext();
    /* If the event was not consumed, send a response to the source. */
    try {
        if (ctxt != 0 && !e.isConsumed()) {
            Iterator dropTargetProtocols =
                XDragAndDropProtocols.getDropTargetProtocols();

            while (dropTargetProtocols.hasNext()) {
                XDropTargetProtocol dropTargetProtocol =
                    (XDropTargetProtocol)dropTargetProtocols.next();
                if (dropTargetProtocol.sendResponse(ctxt, e.getID(),
                                                    returnValue)) {
                    break;
                }
            }
        }
    } finally {
        if (dispatcherDone && ctxt != 0) {
            unsafe.freeMemory(ctxt);
        }
    }
}
 
Example 23
@Override
protected void processMotionMessage(SunDropTargetEvent event, boolean operationChanged) {
    boolean eventInsideTarget = isEventInsideTarget(event);
    if (event.getComponent().getDropTarget() == insideTarget) {
        if (!eventInsideTarget) {
            processExitMessage(event);
            return;
        }
    } else {
        if (eventInsideTarget) {
            processEnterMessage(event);
        } else {
            return;
        }
    }
    super.processMotionMessage(event, operationChanged);
}
 
Example 24
private void trackMouseEnterExit(Component targetOver, MouseEvent e) {
    if (e instanceof SunDropTargetEvent) {
        trackDropTargetEnterExit(targetOver, e);
        return;
    }
    int id = e.getID();

    if ( id != MouseEvent.MOUSE_EXITED &&
         id != MouseEvent.MOUSE_DRAGGED &&
         id != LWD_MOUSE_DRAGGED_OVER &&
            !isMouseInNativeContainer) {
        // any event but an exit or drag means we're in the native container
        isMouseInNativeContainer = true;
        startListeningForOtherDrags();
    } else if (id == MouseEvent.MOUSE_EXITED) {
        isMouseInNativeContainer = false;
        stopListeningForOtherDrags();
    }
    Component tle = retargetMouseEnterExit(targetOver, e,
                                               targetLastEntered.get(),
                                               isMouseInNativeContainer);
    targetLastEntered = new WeakReference<>(tle);
}
 
Example 25
Source Project: jdk8u-dev-jdk   Source File: Container.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Dispatches an event to a sub-component if necessary, and
 * returns whether or not the event was forwarded to a
 * sub-component.
 *
 * @param e the event
 */
boolean dispatchEvent(AWTEvent e) {
    boolean ret = false;

    /*
     * Fix for BugTraq Id 4389284.
     * Dispatch SunDropTargetEvents regardless of eventMask value.
     * Do not update cursor on dispatching SunDropTargetEvents.
     */
    if (e instanceof SunDropTargetEvent) {

        SunDropTargetEvent sdde = (SunDropTargetEvent) e;
        ret = processDropTargetEvent(sdde);

    } else {
        if (e instanceof MouseEvent && (eventMask & MOUSE_MASK) != 0) {
            MouseEvent me = (MouseEvent) e;
            ret = processMouseEvent(me);
        }

        if (e.getID() == MouseEvent.MOUSE_MOVED) {
            nativeContainer.updateCursorImmediately();
        }
    }

    return ret;
}
 
Example 26
/**
 * Could be called when DnD enters a heavyweight or synthesized in processMotionMessage
 */
@Override
protected void processEnterMessage(SunDropTargetEvent event) {
    Component c = event.getComponent();
    DropTarget dt = event.getComponent().getDropTarget();
    if (isEventInsideTarget(event)
            && dt != insideTarget
            && c.isShowing()
            && dt != null
            && dt.isActive()) {
        insideTarget = dt;
        super.processEnterMessage(event);
    }
}
 
Example 27
protected void eventPosted(final SunDropTargetEvent e) {
    if (e.getID() != SunDropTargetEvent.MOUSE_DROPPED) {
        Runnable runnable = new Runnable() {
                public void run() {
                    e.getDispatcher().unregisterAllEvents();
                }
            };
        // NOTE: this PeerEvent must be a NORM_PRIORITY event to be
        // dispatched after this SunDropTargetEvent, but before the next
        // one, so we should pass zero flags.
        PeerEvent peerEvent = new PeerEvent(e.getSource(), runnable, 0);
        SunToolkit.executeOnEventHandlerThread(peerEvent);
    }
}
 
Example 28
/**
 * Could be called when DnD exits a heavyweight or synthesized in processMotionMessage
 */
@Override
protected void processExitMessage(SunDropTargetEvent event) {
    if (event.getComponent().getDropTarget() == insideTarget) {
        insideTarget = null;
        super.processExitMessage(event);
    }
}
 
Example 29
private boolean processSunDropTargetEvent(SunDropTargetEvent event) {
    Object source = event.getSource();

    if (source instanceof Component) {
        ComponentPeer peer = ((Component)source).getPeer();
        if (peer instanceof XEmbedCanvasPeer) {
            XEmbedCanvasPeer xEmbedCanvasPeer = (XEmbedCanvasPeer)peer;
            /* The native context is the pointer to the XClientMessageEvent
               structure. */
            long ctxt = getNativeDragContext();

            if (logger.isLoggable(PlatformLogger.Level.FINER)) {
                logger.finer("        processing " + event + " ctxt=" + ctxt +
                             " consumed=" + event.isConsumed());
            }
            /* If the event is not consumed, pass it to the
               XEmbedCanvasPeer for processing. */
            if (!event.isConsumed()) {
                // NOTE: ctxt can be zero at this point.
                if (xEmbedCanvasPeer.processXEmbedDnDEvent(ctxt,
                                                           event.getID())) {
                    event.consume();
                    return true;
                }
            }
        }
    }

    return false;
}
 
Example 30
private boolean processSunDropTargetEvent(SunDropTargetEvent event) {
    Object source = event.getSource();

    if (source instanceof Component) {
        ComponentPeer peer = ((Component)source).getPeer();
        if (peer instanceof XEmbedCanvasPeer) {
            XEmbedCanvasPeer xEmbedCanvasPeer = (XEmbedCanvasPeer)peer;
            /* The native context is the pointer to the XClientMessageEvent
               structure. */
            long ctxt = getNativeDragContext();

            if (logger.isLoggable(PlatformLogger.Level.FINER)) {
                logger.finer("        processing " + event + " ctxt=" + ctxt +
                             " consumed=" + event.isConsumed());
            }
            /* If the event is not consumed, pass it to the
               XEmbedCanvasPeer for processing. */
            if (!event.isConsumed()) {
                // NOTE: ctxt can be zero at this point.
                if (xEmbedCanvasPeer.processXEmbedDnDEvent(ctxt,
                                                           event.getID())) {
                    event.consume();
                    return true;
                }
            }
        }
    }

    return false;
}