java.awt.dnd.DragSourceDragEvent Java Examples

The following examples show how to use java.awt.dnd.DragSourceDragEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SunDragSourceContextPeer.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
EventDispatcher(int dispatchType, DragSourceEvent event) {
    switch (dispatchType) {
    case DISPATCH_ENTER:
    case DISPATCH_MOTION:
    case DISPATCH_CHANGED:
    case DISPATCH_MOUSE_MOVED:
        if (!(event instanceof DragSourceDragEvent)) {
            throw new IllegalArgumentException("Event: " + event);
        }
        break;
    case DISPATCH_EXIT:
        break;
    case DISPATCH_FINISH:
        if (!(event instanceof DragSourceDropEvent)) {
            throw new IllegalArgumentException("Event: " + event);
        }
        break;
    default:
        throw new IllegalArgumentException("Dispatch type: " +
                                           dispatchType);
    }

    this.dispatchType  = dispatchType;
    this.event         = event;
}
 
Example #2
Source File: SunDragSourceContextPeer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected final void postDragSourceDragEvent(final int targetAction,
                                             final int modifiers,
                                             final int x, final int y,
                                             final int dispatchType) {

    final int dropAction =
        SunDragSourceContextPeer.convertModifiersToDropAction(modifiers,
                                                              sourceActions);

    DragSourceDragEvent event =
        new DragSourceDragEvent(getDragSourceContext(),
                                dropAction,
                                targetAction & sourceActions,
                                modifiers, x, y);
    EventDispatcher dispatcher = new EventDispatcher(dispatchType, event);

    SunToolkit.invokeLaterOnAppContext(
        SunToolkit.targetToAppContext(getComponent()), dispatcher);

    startSecondaryEventLoop();
}
 
Example #3
Source File: SunDragSourceContextPeer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
EventDispatcher(int dispatchType, DragSourceEvent event) {
    switch (dispatchType) {
    case DISPATCH_ENTER:
    case DISPATCH_MOTION:
    case DISPATCH_CHANGED:
    case DISPATCH_MOUSE_MOVED:
        if (!(event instanceof DragSourceDragEvent)) {
            throw new IllegalArgumentException("Event: " + event);
        }
        break;
    case DISPATCH_EXIT:
        break;
    case DISPATCH_FINISH:
        if (!(event instanceof DragSourceDropEvent)) {
            throw new IllegalArgumentException("Event: " + event);
        }
        break;
    default:
        throw new IllegalArgumentException("Dispatch type: " +
                                           dispatchType);
    }

    this.dispatchType  = dispatchType;
    this.event         = event;
}
 
Example #4
Source File: SunDragSourceContextPeer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
EventDispatcher(int dispatchType, DragSourceEvent event) {
    switch (dispatchType) {
    case DISPATCH_ENTER:
    case DISPATCH_MOTION:
    case DISPATCH_CHANGED:
    case DISPATCH_MOUSE_MOVED:
        if (!(event instanceof DragSourceDragEvent)) {
            throw new IllegalArgumentException("Event: " + event);
        }
        break;
    case DISPATCH_EXIT:
        break;
    case DISPATCH_FINISH:
        if (!(event instanceof DragSourceDropEvent)) {
            throw new IllegalArgumentException("Event: " + event);
        }
        break;
    default:
        throw new IllegalArgumentException("Dispatch type: " +
                                           dispatchType);
    }

    this.dispatchType  = dispatchType;
    this.event         = event;
}
 
Example #5
Source File: SunDragSourceContextPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
EventDispatcher(int dispatchType, DragSourceEvent event) {
    switch (dispatchType) {
    case DISPATCH_ENTER:
    case DISPATCH_MOTION:
    case DISPATCH_CHANGED:
    case DISPATCH_MOUSE_MOVED:
        if (!(event instanceof DragSourceDragEvent)) {
            throw new IllegalArgumentException("Event: " + event);
        }
        break;
    case DISPATCH_EXIT:
        break;
    case DISPATCH_FINISH:
        if (!(event instanceof DragSourceDropEvent)) {
            throw new IllegalArgumentException("Event: " + event);
        }
        break;
    default:
        throw new IllegalArgumentException("Dispatch type: " +
                                           dispatchType);
    }

    this.dispatchType  = dispatchType;
    this.event         = event;
}
 
Example #6
Source File: SunDragSourceContextPeer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
EventDispatcher(int dispatchType, DragSourceEvent event) {
    switch (dispatchType) {
    case DISPATCH_ENTER:
    case DISPATCH_MOTION:
    case DISPATCH_CHANGED:
    case DISPATCH_MOUSE_MOVED:
        if (!(event instanceof DragSourceDragEvent)) {
            throw new IllegalArgumentException("Event: " + event);
        }
        break;
    case DISPATCH_EXIT:
        break;
    case DISPATCH_FINISH:
        if (!(event instanceof DragSourceDropEvent)) {
            throw new IllegalArgumentException("Event: " + event);
        }
        break;
    default:
        throw new IllegalArgumentException("Dispatch type: " +
                                           dispatchType);
    }

    this.dispatchType  = dispatchType;
    this.event         = event;
}
 
Example #7
Source File: SunDragSourceContextPeer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected final void postDragSourceDragEvent(final int targetAction,
                                             final int modifiers,
                                             final int x, final int y,
                                             final int dispatchType) {

    final int dropAction =
        SunDragSourceContextPeer.convertModifiersToDropAction(modifiers,
                                                              sourceActions);

    DragSourceDragEvent event =
        new DragSourceDragEvent(getDragSourceContext(),
                                dropAction,
                                targetAction & sourceActions,
                                modifiers, x, y);
    EventDispatcher dispatcher = new EventDispatcher(dispatchType, event);

    SunToolkit.invokeLaterOnAppContext(
        SunToolkit.targetToAppContext(getComponent()), dispatcher);

    startSecondaryEventLoop();
}
 
Example #8
Source File: SunDragSourceContextPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
protected final void postDragSourceDragEvent(final int targetAction,
                                             final int modifiers,
                                             final int x, final int y,
                                             final int dispatchType) {

    final int dropAction =
        SunDragSourceContextPeer.convertModifiersToDropAction(modifiers,
                                                              sourceActions);

    DragSourceDragEvent event =
        new DragSourceDragEvent(getDragSourceContext(),
                                dropAction,
                                targetAction & sourceActions,
                                modifiers, x, y);
    EventDispatcher dispatcher = new EventDispatcher(dispatchType, event);

    SunToolkit.invokeLaterOnAppContext(
        SunToolkit.targetToAppContext(getComponent()), dispatcher);

    startSecondaryEventLoop();
}
 
Example #9
Source File: SunDragSourceContextPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected final void postDragSourceDragEvent(final int targetAction,
                                             final int modifiers,
                                             final int x, final int y,
                                             final int dispatchType) {

    final int dropAction =
        SunDragSourceContextPeer.convertModifiersToDropAction(modifiers,
                                                              sourceActions);

    DragSourceDragEvent event =
        new DragSourceDragEvent(getDragSourceContext(),
                                dropAction,
                                targetAction & sourceActions,
                                modifiers, x, y);
    EventDispatcher dispatcher = new EventDispatcher(dispatchType, event);

    SunToolkit.invokeLaterOnAppContext(
        SunToolkit.targetToAppContext(getComponent()), dispatcher);

    startSecondaryEventLoop();
}
 
Example #10
Source File: FrameDragViewHandler.java    From weblaf with GNU General Public License v3.0 6 votes vote down vote up
@NotNull
@Override
protected Point calculateViewRelativeLocation ( @NotNull final WebDockableFrame frame, @NotNull final DragSourceDragEvent event )
{
    final Point location = super.calculateViewRelativeLocation ( frame, event );
    final WebDockablePane pane = frame.getDockablePane ();
    if ( pane != null )
    {
        final Dimension size = pane.getModel ().getElement ( frame.getId () ).getSize ();
        final Dimension current = frame.getSize ();
        if ( current.width > size.width && Math.abs ( location.x ) > size.width )
        {
            location.x = location.x * size.width / current.width;
        }
        return location;
    }
    else
    {
        throw new DragException ( "Unable to drag frame that is not attached to a WebDockablePane: " + frame.getId () );
    }
}
 
Example #11
Source File: SunDragSourceContextPeer.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
EventDispatcher(int dispatchType, DragSourceEvent event) {
    switch (dispatchType) {
    case DISPATCH_ENTER:
    case DISPATCH_MOTION:
    case DISPATCH_CHANGED:
    case DISPATCH_MOUSE_MOVED:
        if (!(event instanceof DragSourceDragEvent)) {
            throw new IllegalArgumentException("Event: " + event);
        }
        break;
    case DISPATCH_EXIT:
        break;
    case DISPATCH_FINISH:
        if (!(event instanceof DragSourceDropEvent)) {
            throw new IllegalArgumentException("Event: " + event);
        }
        break;
    default:
        throw new IllegalArgumentException("Dispatch type: " +
                                           dispatchType);
    }

    this.dispatchType  = dispatchType;
    this.event         = event;
}
 
Example #12
Source File: SunDragSourceContextPeer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
EventDispatcher(int dispatchType, DragSourceEvent event) {
    switch (dispatchType) {
    case DISPATCH_ENTER:
    case DISPATCH_MOTION:
    case DISPATCH_CHANGED:
    case DISPATCH_MOUSE_MOVED:
        if (!(event instanceof DragSourceDragEvent)) {
            throw new IllegalArgumentException("Event: " + event);
        }
        break;
    case DISPATCH_EXIT:
        break;
    case DISPATCH_FINISH:
        if (!(event instanceof DragSourceDropEvent)) {
            throw new IllegalArgumentException("Event: " + event);
        }
        break;
    default:
        throw new IllegalArgumentException("Dispatch type: " +
                                           dispatchType);
    }

    this.dispatchType  = dispatchType;
    this.event         = event;
}
 
Example #13
Source File: SunDragSourceContextPeer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
protected final void postDragSourceDragEvent(final int targetAction,
                                             final int modifiers,
                                             final int x, final int y,
                                             final int dispatchType) {

    final int dropAction =
        SunDragSourceContextPeer.convertModifiersToDropAction(modifiers,
                                                              sourceActions);

    DragSourceDragEvent event =
        new DragSourceDragEvent(getDragSourceContext(),
                                dropAction,
                                targetAction & sourceActions,
                                modifiers, x, y);
    EventDispatcher dispatcher = new EventDispatcher(dispatchType, event);

    SunToolkit.invokeLaterOnAppContext(
        SunToolkit.targetToAppContext(getComponent()), dispatcher);

    startSecondaryEventLoop();
}
 
Example #14
Source File: SunDragSourceContextPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
EventDispatcher(int dispatchType, DragSourceEvent event) {
    switch (dispatchType) {
    case DISPATCH_ENTER:
    case DISPATCH_MOTION:
    case DISPATCH_CHANGED:
    case DISPATCH_MOUSE_MOVED:
        if (!(event instanceof DragSourceDragEvent)) {
            throw new IllegalArgumentException("Event: " + event);
        }
        break;
    case DISPATCH_EXIT:
        break;
    case DISPATCH_FINISH:
        if (!(event instanceof DragSourceDropEvent)) {
            throw new IllegalArgumentException("Event: " + event);
        }
        break;
    default:
        throw new IllegalArgumentException("Dispatch type: " +
                                           dispatchType);
    }

    this.dispatchType  = dispatchType;
    this.event         = event;
}
 
Example #15
Source File: SunDragSourceContextPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
EventDispatcher(int dispatchType, DragSourceEvent event) {
    switch (dispatchType) {
    case DISPATCH_ENTER:
    case DISPATCH_MOTION:
    case DISPATCH_CHANGED:
    case DISPATCH_MOUSE_MOVED:
        if (!(event instanceof DragSourceDragEvent)) {
            throw new IllegalArgumentException("Event: " + event);
        }
        break;
    case DISPATCH_EXIT:
        break;
    case DISPATCH_FINISH:
        if (!(event instanceof DragSourceDropEvent)) {
            throw new IllegalArgumentException("Event: " + event);
        }
        break;
    default:
        throw new IllegalArgumentException("Dispatch type: " +
                                           dispatchType);
    }

    this.dispatchType  = dispatchType;
    this.event         = event;
}
 
Example #16
Source File: SunDragSourceContextPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
protected final void postDragSourceDragEvent(final int targetAction,
                                             final int modifiers,
                                             final int x, final int y,
                                             final int dispatchType) {

    final int dropAction =
        SunDragSourceContextPeer.convertModifiersToDropAction(modifiers,
                                                              sourceActions);

    DragSourceDragEvent event =
        new DragSourceDragEvent(getDragSourceContext(),
                                dropAction,
                                targetAction & sourceActions,
                                modifiers, x, y);
    EventDispatcher dispatcher = new EventDispatcher(dispatchType, event);

    SunToolkit.invokeLaterOnAppContext(
        SunToolkit.targetToAppContext(getComponent()), dispatcher);

    startSecondaryEventLoop();
}
 
Example #17
Source File: AbstractObjectHoverBehavior.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void moved ( @NotNull final DragSourceDragEvent event )
{
    /**
     * No extra updates required on this event.
     */
}
 
Example #18
Source File: AbstractTreeTransferHandler.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
public final void dropActionChanged(DragSourceDragEvent dsde)  {
        int action = dsde.getDropAction();
        if (action == DnDConstants.ACTION_COPY) {
                dsde.getDragSourceContext().setCursor(DragSource.DefaultCopyDrop);
        }
        else  {
                if (action == DnDConstants.ACTION_MOVE) {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
                } 
                else {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
                }
        }
}
 
Example #19
Source File: DragAdapter.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void started ( final DragSourceDragEvent event )
{
    /**
     * Do nothing by default.
     */
}
 
Example #20
Source File: KeyStoreEntryDragGestureListener.java    From keystore-explorer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Drag target entered.
 *
 * @param evt
 *            Drag event
 */
@Override
public void dragEnter(DragSourceDragEvent evt) {
	// Show drag cursor
	DragSourceContext ctx = evt.getDragSourceContext();
	ctx.setCursor(cursor);
}
 
Example #21
Source File: AbstractTreeTransferHandler.java    From binnavi with Apache License 2.0 5 votes vote down vote up
@Override
public final void dragEnter(final DragSourceDragEvent dsde) {
  final int action = dsde.getDropAction();
  if (action == DnDConstants.ACTION_COPY) {
    dsde.getDragSourceContext().setCursor(DragSource.DefaultCopyDrop);
  } else {
    if (action == DnDConstants.ACTION_MOVE) {
      dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
    } else {
      dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
    }
  }
}
 
Example #22
Source File: SunDragSourceContextPeer.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    DragSourceContext dragSourceContext =
        SunDragSourceContextPeer.this.getDragSourceContext();
    try {
        switch (dispatchType) {
        case DISPATCH_ENTER:
            dragSourceContext.dragEnter((DragSourceDragEvent)event);
            break;
        case DISPATCH_MOTION:
            dragSourceContext.dragOver((DragSourceDragEvent)event);
            break;
        case DISPATCH_CHANGED:
            dragSourceContext.dropActionChanged((DragSourceDragEvent)event);
            break;
        case DISPATCH_EXIT:
            dragSourceContext.dragExit(event);
            break;
        case DISPATCH_MOUSE_MOVED:
            dragSourceContext.dragMouseMoved((DragSourceDragEvent)event);
            break;
        case DISPATCH_FINISH:
            try {
                dragSourceContext.dragDropEnd((DragSourceDropEvent)event);
            } finally {
                SunDragSourceContextPeer.this.cleanup();
            }
            break;
        default:
            throw new IllegalStateException("Dispatch type: " +
                                            dispatchType);
        }
    } finally {
         SunDragSourceContextPeer.this.quitSecondaryEventLoop();
    }
}
 
Example #23
Source File: SunDragSourceContextPeer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    DragSourceContext dragSourceContext =
        SunDragSourceContextPeer.this.getDragSourceContext();
    try {
        switch (dispatchType) {
        case DISPATCH_ENTER:
            dragSourceContext.dragEnter((DragSourceDragEvent)event);
            break;
        case DISPATCH_MOTION:
            dragSourceContext.dragOver((DragSourceDragEvent)event);
            break;
        case DISPATCH_CHANGED:
            dragSourceContext.dropActionChanged((DragSourceDragEvent)event);
            break;
        case DISPATCH_EXIT:
            dragSourceContext.dragExit(event);
            break;
        case DISPATCH_MOUSE_MOVED:
            dragSourceContext.dragMouseMoved((DragSourceDragEvent)event);
            break;
        case DISPATCH_FINISH:
            try {
                dragSourceContext.dragDropEnd((DragSourceDropEvent)event);
            } finally {
                SunDragSourceContextPeer.this.cleanup();
            }
            break;
        default:
            throw new IllegalStateException("Dispatch type: " +
                                            dispatchType);
        }
    } finally {
         SunDragSourceContextPeer.this.quitSecondaryEventLoop();
    }
}
 
Example #24
Source File: AbstractTreeTransferHandler.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
public final void dragOver(DragSourceDragEvent dsde) {
        int action = dsde.getDropAction();
        if (action == DnDConstants.ACTION_COPY) {
                dsde.getDragSourceContext().setCursor(DragSource.DefaultCopyDrop);
        } 
        else  {
                if (action == DnDConstants.ACTION_MOVE) {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
                } 
                else  {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
                }
        }
}
 
Example #25
Source File: AbstractTreeTransferHandler.java    From binnavi with Apache License 2.0 5 votes vote down vote up
@Override
public final void dropActionChanged(final DragSourceDragEvent dsde) {
  final int action = dsde.getDropAction();
  if (action == DnDConstants.ACTION_COPY) {
    dsde.getDragSourceContext().setCursor(DragSource.DefaultCopyDrop);
  } else {
    if (action == DnDConstants.ACTION_MOVE) {
      dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
    } else {
      dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
    }
  }
}
 
Example #26
Source File: AbstractHoverBehavior.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void moved ( @NotNull final DragSourceDragEvent event )
{
    /**
     * No extra updates required on this event.
     */
}
 
Example #27
Source File: JTreeUtil.java    From Logisim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public final void dragEnter(DragSourceDragEvent dsde) {
	int action = dsde.getDropAction();
	if (action == DnDConstants.ACTION_COPY) {
		dsde.getDragSourceContext().setCursor(DragSource.DefaultCopyDrop);
	} else {
		if (action == DnDConstants.ACTION_MOVE) {
			dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
		} else {
			dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
		}
	}
}
 
Example #28
Source File: SunDragSourceContextPeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    DragSourceContext dragSourceContext =
        SunDragSourceContextPeer.this.getDragSourceContext();
    try {
        switch (dispatchType) {
        case DISPATCH_ENTER:
            dragSourceContext.dragEnter((DragSourceDragEvent)event);
            break;
        case DISPATCH_MOTION:
            dragSourceContext.dragOver((DragSourceDragEvent)event);
            break;
        case DISPATCH_CHANGED:
            dragSourceContext.dropActionChanged((DragSourceDragEvent)event);
            break;
        case DISPATCH_EXIT:
            dragSourceContext.dragExit(event);
            break;
        case DISPATCH_MOUSE_MOVED:
            dragSourceContext.dragMouseMoved((DragSourceDragEvent)event);
            break;
        case DISPATCH_FINISH:
            try {
                dragSourceContext.dragDropEnd((DragSourceDropEvent)event);
            } finally {
                SunDragSourceContextPeer.this.cleanup();
            }
            break;
        default:
            throw new IllegalStateException("Dispatch type: " +
                                            dispatchType);
        }
    } finally {
         SunDragSourceContextPeer.this.quitSecondaryEventLoop();
    }
}
 
Example #29
Source File: FrameDragViewHandler.java    From weblaf with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
public WebDockableFrame getComponent ( @NotNull final FrameDragData object, @NotNull final DragSourceDragEvent event )
{
    final WebDockablePane pane = dockablePane.get ();
    if ( pane != null )
    {
        return pane.getFrame ( object.getId () );
    }
    else
    {
        final String msg = "Unable to resolve WebDockablePane for dragged frame with identifier: %s";
        throw new DragException ( String.format ( msg, object.getId () ) );
    }
}
 
Example #30
Source File: SunDragSourceContextPeer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    DragSourceContext dragSourceContext =
        SunDragSourceContextPeer.this.getDragSourceContext();
    try {
        switch (dispatchType) {
        case DISPATCH_ENTER:
            dragSourceContext.dragEnter((DragSourceDragEvent)event);
            break;
        case DISPATCH_MOTION:
            dragSourceContext.dragOver((DragSourceDragEvent)event);
            break;
        case DISPATCH_CHANGED:
            dragSourceContext.dropActionChanged((DragSourceDragEvent)event);
            break;
        case DISPATCH_EXIT:
            dragSourceContext.dragExit(event);
            break;
        case DISPATCH_MOUSE_MOVED:
            dragSourceContext.dragMouseMoved((DragSourceDragEvent)event);
            break;
        case DISPATCH_FINISH:
            try {
                dragSourceContext.dragDropEnd((DragSourceDropEvent)event);
            } finally {
                SunDragSourceContextPeer.this.cleanup();
            }
            break;
        default:
            throw new IllegalStateException("Dispatch type: " +
                                            dispatchType);
        }
    } finally {
         SunDragSourceContextPeer.this.quitSecondaryEventLoop();
    }
}