Java Code Examples for java.awt.dnd.InvalidDnDOperationException

The following are top voted examples for showing how to use java.awt.dnd.InvalidDnDOperationException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OpenJSharp   File: SunDropTargetContextPeer.java   Source Code and License 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 2
Project: OpenJSharp   File: SunDropTargetContextPeer.java   Source Code and License 6 votes vote down vote up
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();
    }
}
 
Example 3
Project: OpenJSharp   File: XDragSourceProtocol.java   Source Code and License 6 votes vote down vote up
/**
 * 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();
    }
}
 
Example 4
Project: jdk8u-jdk   File: SunDropTargetContextPeer.java   Source Code and License 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
Project: jdk8u-jdk   File: SunDropTargetContextPeer.java   Source Code and License 6 votes vote down vote up
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();
    }
}
 
Example 6
Project: jdk8u-jdk   File: XDragSourceProtocol.java   Source Code and License 6 votes vote down vote up
/**
 * 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();
    }
}
 
Example 7
Project: openjdk-jdk10   File: SunDropTargetContextPeer.java   Source Code and License 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 8
Project: openjdk-jdk10   File: SunDropTargetContextPeer.java   Source Code and License 6 votes vote down vote up
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();
    }
}
 
Example 9
Project: openjdk-jdk10   File: XDragSourceProtocol.java   Source Code and License 6 votes vote down vote up
/**
 * Initializes a drag operation with the specified supported drop actions,
 * contents and data formats.
 *
 * @param actions a bitwise mask of {@code DnDConstants} 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<Long, DataFlavor> 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();
    }
}
 
Example 10
Project: openjdk9   File: SunDropTargetContextPeer.java   Source Code and License 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 11
Project: openjdk9   File: SunDropTargetContextPeer.java   Source Code and License 6 votes vote down vote up
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();
    }
}
 
Example 12
Project: openjdk9   File: XDragSourceProtocol.java   Source Code and License 6 votes vote down vote up
/**
 * Initializes a drag operation with the specified supported drop actions,
 * contents and data formats.
 *
 * @param actions a bitwise mask of {@code DnDConstants} 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<Long, DataFlavor> 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();
    }
}
 
Example 13
Project: jdk8u_jdk   File: SunDropTargetContextPeer.java   Source Code and License 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 14
Project: jdk8u_jdk   File: SunDropTargetContextPeer.java   Source Code and License 6 votes vote down vote up
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();
    }
}
 
Example 15
Project: lookaside_java-1.8.0-openjdk   File: SunDropTargetContextPeer.java   Source Code and License 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 16
Project: lookaside_java-1.8.0-openjdk   File: SunDropTargetContextPeer.java   Source Code and License 6 votes vote down vote up
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();
    }
}
 
Example 17
Project: lookaside_java-1.8.0-openjdk   File: XDragSourceProtocol.java   Source Code and License 6 votes vote down vote up
/**
 * 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();
    }
}
 
Example 18
Project: incubator-netbeans   File: DnDSupport.java   Source Code and License 5 votes vote down vote up
public void dragGestureRecognized( DragGestureEvent dge ) {
    Transferable t = null;
    
    if( dge.getComponent() instanceof CategoryButton ) {
        //trying to drag a palette category
        CategoryButton button = (CategoryButton)dge.getComponent();
        draggingCategory = button.getCategory();
        t = draggingCategory.getTransferable();
        
    } else if( dge.getComponent() instanceof CategoryList ) {
        //trying to drag a palette item
        CategoryList list = (CategoryList)dge.getComponent();
        int selIndex = list.locationToIndex( dge.getDragOrigin() );
        draggingItem = list.getItemAt( selIndex );
        if( null == draggingItem ) {
            return;
        }
        t = draggingItem.drag();
        dragSourceCategoryList = list;
    }
    if( null != t ) {
        dge.getDragSource().addDragSourceListener( getDragSourceListener() );
        try {
            dge.startDrag( null, t );
        } catch( InvalidDnDOperationException idndE ) {
            //attempt to fix #110670
            try {
                dge.startDrag( null, t );
            } catch( InvalidDnDOperationException e ) {
                ERR.log( Level.INFO, idndE.getMessage(), e );
            }
        }
    }
}
 
Example 19
Project: incubator-netbeans   File: IndexedCustomizer.java   Source Code and License 5 votes vote down vote up
/** Initiating the drag */
public void dragGestureRecognized(DragGestureEvent dge) {
    // check allowed actions
    if ((dge.getDragAction() & DnDConstants.ACTION_MOVE) == 0) {
        return;
    }

    // prepare transferable and start the drag
    int index = comp.locationToIndex(dge.getDragOrigin());

    // no index, then no dragging...
    if (index < 0) {
        return;
    }

    //      System.out.println("Starting drag..."); // NOI18N
    // create our flavor for transferring the index
    myFlavor = new DataFlavor(
            String.class, NbBundle.getBundle(IndexedCustomizer.class).getString("IndexedFlavor")
        );

    try {
        dge.startDrag(DragSource.DefaultMoveDrop, new IndexTransferable(myFlavor, index), this);

        // remember the gesture
        this.dge = dge;
    } catch (InvalidDnDOperationException exc) {
        Logger.getLogger(IndexedCustomizer.class.getName()).log(Level.WARNING, null, exc);

        // PENDING notify user - cannot start the drag
    }
}
 
Example 20
Project: VASSAL-src   File: SetupStack.java   Source Code and License 5 votes vote down vote up
public void dragGestureRecognized(DragGestureEvent dge) {

      Point mousePosition = dge.getDragOrigin();
      Point piecePosition = new Point(myStack.pos);

      // Check drag starts inside piece
      Rectangle r = myStack.stackConfigurer.getPieceBoundingBox();
      r.translate(piecePosition.x, piecePosition.y);
      if (!r.contains(mousePosition)) {
        return;
      }

      originalPieceOffsetX = piecePosition.x - mousePosition.x;
      originalPieceOffsetY = piecePosition.y - mousePosition.y;

      drawWin = null;

      makeDragCursor();
      setDragCursor();

      SwingUtilities.convertPointToScreen(mousePosition, drawWin);
      moveDragCursor(mousePosition.x, mousePosition.y);

      // begin dragging
      try {
        dge.startDrag(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR),
                      new StringSelection(""), this); // DEBUG
        dge.getDragSource().addDragSourceMotionListener(this);
      }
      catch (InvalidDnDOperationException e) {
        ErrorDialog.bug(e);
      }
    }
 
Example 21
Project: VASSAL-src   File: RegionGrid.java   Source Code and License 5 votes vote down vote up
public void dragGestureRecognized(DragGestureEvent dge) {

        final Point mousePosition = dge.getDragOrigin();
        dragStart = new Point(mousePosition);
        final Region r = grid.getRegion(mousePosition);
        if (r == null) {
          return;
        }

        Point piecePosition = new Point(r.getOrigin());

        originalPieceOffsetX = piecePosition.x - mousePosition.x;
        originalPieceOffsetY = piecePosition.y - mousePosition.y;

        drawWin = null;

        makeDragCursor();
        setDragCursor();

        SwingUtilities.convertPointToScreen(drawOffset, drawWin);
        SwingUtilities.convertPointToScreen(mousePosition, drawWin);
        moveDragCursor(mousePosition.x, mousePosition.y);

        // begin dragging
        try {
          dge.startDrag(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR),
                        new StringSelection(""), this); //$NON-NLS-1$
          dge.getDragSource().addDragSourceMotionListener(this);
        }
        catch (InvalidDnDOperationException e) {
          ErrorDialog.bug(e);
        }
      }
 
Example 22
Project: VASSAL-src   File: PieceMover.java   Source Code and License 5 votes vote down vote up
/** Fires after user begins moving the mouse several pixels over a map. */
public void dragGestureRecognized(DragGestureEvent dge) {
  try {
    beginDragging(dge);
  }
  // FIXME: Fix by replacing AWT Drag 'n Drop with Swing DnD.
  // Catch and ignore spurious DragGestures
  catch (InvalidDnDOperationException e) {
  }
}
 
Example 23
Project: OpenJSharp   File: SunDropTargetContextPeer.java   Source Code and License 5 votes vote down vote up
public static void setCurrentJVMLocalSourceTransferable(Transferable t) throws InvalidDnDOperationException {
    synchronized(_globalLock) {
        if (t != null && currentJVMLocalSourceTransferable != null) {
                throw new InvalidDnDOperationException();
        } else {
            currentJVMLocalSourceTransferable = t;
        }
    }
}
 
Example 24
Project: OpenJSharp   File: SunDropTargetContextPeer.java   Source Code and License 5 votes vote down vote up
/**
 * 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;
    }
}
 
Example 25
Project: OpenJSharp   File: SunDropTargetContextPeer.java   Source Code and License 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 26
Project: OpenJSharp   File: SunDropTargetContextPeer.java   Source Code and License 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 27
Project: OpenJSharp   File: SunDropTargetContextPeer.java   Source Code and License 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 28
Project: OpenJSharp   File: SunDragSourceContextPeer.java   Source Code and License 5 votes vote down vote up
/**
 * 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;
            }
        });
}
 
Example 29
Project: OpenJSharp   File: SunDragSourceContextPeer.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example 30
Project: OpenJSharp   File: SunDragSourceContextPeer.java   Source Code and License 5 votes vote down vote up
public static void setDragDropInProgress(boolean b)
  throws InvalidDnDOperationException {
    synchronized (SunDragSourceContextPeer.class) {
        if (dragDropInProgress == b) {
            throw new InvalidDnDOperationException(getExceptionMessage(b));
        }
        dragDropInProgress = b;
    }
}
 
Example 31
Project: OpenJSharp   File: WToolkit.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
}
 
Example 32
Project: OpenJSharp   File: MotifDnDDragSourceProtocol.java   Source Code and License 5 votes vote down vote up
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");
    }
}
 
Example 33
Project: OpenJSharp   File: XDragSourceContextPeer.java   Source Code and License 5 votes vote down vote up
/**
 * set cursor
 */

public void setCursor(Cursor c) throws InvalidDnDOperationException {
    XToolkit.awtLock();
    try {
        super.setCursor(c);
    } finally {
        XToolkit.awtUnlock();
    }
}
 
Example 34
Project: OpenJSharp   File: XDragSourceContextPeer.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 35
Project: OpenJSharp   File: XToolkit.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 36
Project: jdk8u-jdk   File: SunDropTargetContextPeer.java   Source Code and License 5 votes vote down vote up
public static void setCurrentJVMLocalSourceTransferable(Transferable t) throws InvalidDnDOperationException {
    synchronized(_globalLock) {
        if (t != null && currentJVMLocalSourceTransferable != null) {
                throw new InvalidDnDOperationException();
        } else {
            currentJVMLocalSourceTransferable = t;
        }
    }
}
 
Example 37
Project: jdk8u-jdk   File: SunDropTargetContextPeer.java   Source Code and License 5 votes vote down vote up
/**
 * 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;
    }
}
 
Example 38
Project: jdk8u-jdk   File: SunDropTargetContextPeer.java   Source Code and License 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 39
Project: jdk8u-jdk   File: SunDropTargetContextPeer.java   Source Code and License 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 40
Project: jdk8u-jdk   File: SunDropTargetContextPeer.java   Source Code and License 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 41
Project: jdk8u-jdk   File: SunDragSourceContextPeer.java   Source Code and License 5 votes vote down vote up
/**
 * 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;
            }
        });
}
 
Example 42
Project: jdk8u-jdk   File: SunDragSourceContextPeer.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example 43
Project: jdk8u-jdk   File: SunDragSourceContextPeer.java   Source Code and License 5 votes vote down vote up
public static void setDragDropInProgress(boolean b)
  throws InvalidDnDOperationException {
    synchronized (SunDragSourceContextPeer.class) {
        if (dragDropInProgress == b) {
            throw new InvalidDnDOperationException(getExceptionMessage(b));
        }
        dragDropInProgress = b;
    }
}
 
Example 44
Project: jdk8u-jdk   File: WToolkit.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
}
 
Example 45
Project: jdk8u-jdk   File: MotifDnDDragSourceProtocol.java   Source Code and License 5 votes vote down vote up
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");
    }
}
 
Example 46
Project: jdk8u-jdk   File: XDragSourceContextPeer.java   Source Code and License 5 votes vote down vote up
/**
 * set cursor
 */

public void setCursor(Cursor c) throws InvalidDnDOperationException {
    XToolkit.awtLock();
    try {
        super.setCursor(c);
    } finally {
        XToolkit.awtUnlock();
    }
}
 
Example 47
Project: jdk8u-jdk   File: XDragSourceContextPeer.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 48
Project: jdk8u-jdk   File: XToolkit.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 49
Project: openjdk-jdk10   File: SunDropTargetContextPeer.java   Source Code and License 5 votes vote down vote up
public static void setCurrentJVMLocalSourceTransferable(Transferable t) throws InvalidDnDOperationException {
    synchronized(_globalLock) {
        if (t != null && currentJVMLocalSourceTransferable != null) {
                throw new InvalidDnDOperationException();
        } else {
            currentJVMLocalSourceTransferable = t;
        }
    }
}
 
Example 50
Project: openjdk-jdk10   File: SunDropTargetContextPeer.java   Source Code and License 5 votes vote down vote up
/**
 * 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;
    }
}
 
Example 51
Project: openjdk-jdk10   File: SunDropTargetContextPeer.java   Source Code and License 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 52
Project: openjdk-jdk10   File: SunDropTargetContextPeer.java   Source Code and License 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 53
Project: openjdk-jdk10   File: SunDropTargetContextPeer.java   Source Code and License 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) {
        AWTAccessor.getDropTargetContextAccessor().reset(currentDTC);
    }

    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 54
Project: openjdk-jdk10   File: SunDragSourceContextPeer.java   Source Code and License 5 votes vote down vote up
/**
 * 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.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;
            }
        });
}
 
Example 55
Project: openjdk-jdk10   File: SunDragSourceContextPeer.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example 56
Project: openjdk-jdk10   File: SunDragSourceContextPeer.java   Source Code and License 5 votes vote down vote up
public static void setDragDropInProgress(boolean b)
  throws InvalidDnDOperationException {
    synchronized (SunDragSourceContextPeer.class) {
        if (dragDropInProgress == b) {
            throw new InvalidDnDOperationException(getExceptionMessage(b));
        }
        dragDropInProgress = b;
    }
}
 
Example 57
Project: openjdk-jdk10   File: MotifDnDDragSourceProtocol.java   Source Code and License 5 votes vote down vote up
protected void initializeDragImpl(int actions, Transferable contents,
                                  Map<Long, DataFlavor> 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");
    }
}
 
Example 58
Project: openjdk-jdk10   File: XDragSourceContextPeer.java   Source Code and License 5 votes vote down vote up
/**
 * set cursor
 */

public void setCursor(Cursor c) throws InvalidDnDOperationException {
    XToolkit.awtLock();
    try {
        super.setCursor(c);
    } finally {
        XToolkit.awtUnlock();
    }
}
 
Example 59
Project: openjdk-jdk10   File: XDragSourceContextPeer.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 60
Project: openjdk-jdk10   File: XToolkit.java   Source Code and License 5 votes vote down vote up
@Override
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);
}