| Method from sun.awt.dnd.SunDragSourceContextPeer Detail: |
public static void checkDragDropInProgress() throws InvalidDnDOperationException {
if (dragDropInProgress) {
throw new InvalidDnDOperationException(getExceptionMessage(true));
}
}
|
public static boolean checkEvent(AWTEvent event) {
if (discardingMouseEvents && event instanceof MouseEvent) {
MouseEvent mouseEvent = (MouseEvent)event;
if (!(mouseEvent instanceof SunDropTargetEvent)) {
return false;
}
}
return true;
}
Filters out all mouse events that were on the java event queue when
startDrag was called. |
public static int convertModifiersToDropAction(int modifiers,
int supportedActions) {
int dropAction = DnDConstants.ACTION_NONE;
/*
* Fix for 4285634.
* Calculate the drop action to match Motif DnD behavior.
* If the user selects an operation (by pressing a modifier key),
* return the selected operation or ACTION_NONE if the selected
* operation is not supported by the drag source.
* If the user doesn't select an operation search the set of operations
* supported by the drag source for ACTION_MOVE, then for
* ACTION_COPY, then for ACTION_LINK and return the first operation
* found.
*/
switch (modifiers & (InputEvent.SHIFT_DOWN_MASK |
InputEvent.CTRL_DOWN_MASK)) {
case InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK:
dropAction = DnDConstants.ACTION_LINK; break;
case InputEvent.CTRL_DOWN_MASK:
dropAction = DnDConstants.ACTION_COPY; break;
case InputEvent.SHIFT_DOWN_MASK:
dropAction = DnDConstants.ACTION_MOVE; break;
default:
if ((supportedActions & DnDConstants.ACTION_MOVE) != 0) {
dropAction = DnDConstants.ACTION_MOVE;
} else if ((supportedActions & DnDConstants.ACTION_COPY) != 0) {
dropAction = DnDConstants.ACTION_COPY;
} else if ((supportedActions & DnDConstants.ACTION_LINK) != 0) {
dropAction = DnDConstants.ACTION_LINK;
}
}
return dropAction & supportedActions;
}
|
protected final void dragDropFinished(boolean success,
int operations,
int x,
int y) {
DragSourceEvent event =
new DragSourceDropEvent(getDragSourceContext(),
operations & sourceActions,
success, x, y);
EventDispatcher dispatcher =
new EventDispatcher(DISPATCH_FINISH, event);
SunToolkit.invokeLaterOnAppContext(
SunToolkit.targetToAppContext(getComponent()), dispatcher);
startSecondaryEventLoop();
setNativeContext(0);
}
upcall from native code via implemented class (do) |
protected final void dragExit(int x,
int y) {
DragSourceEvent event =
new DragSourceEvent(getDragSourceContext(), x, y);
EventDispatcher dispatcher =
new EventDispatcher(DISPATCH_EXIT, event);
SunToolkit.invokeLaterOnAppContext(
SunToolkit.targetToAppContext(getComponent()), dispatcher);
startSecondaryEventLoop();
}
|
protected Component getComponent() {
return component;
}
|
public Cursor getCursor() {
return cursor;
}
|
protected DragSourceContext getDragSourceContext() {
return dragSourceContext;
}
|
protected synchronized long getNativeContext() {
return nativeCtxt;
}
|
protected DragGestureEvent getTrigger() {
return trigger;
}
|
protected final void postDragSourceDragEvent(int targetAction,
int modifiers,
int x,
int y,
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();
}
|
public void quitSecondaryEventLoop() {
}
|
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);
}
}
}
|
public static void setDragDropInProgress(boolean b) throws InvalidDnDOperationException {
if (dragDropInProgress == b) {
throw new InvalidDnDOperationException(getExceptionMessage(b));
}
synchronized (SunDragSourceContextPeer.class) {
if (dragDropInProgress == b) {
throw new InvalidDnDOperationException(getExceptionMessage(b));
}
dragDropInProgress = b;
}
}
|
protected synchronized void setNativeContext(long ctxt) {
nativeCtxt = ctxt;
}
|
abstract protected void setNativeCursor(long nativeCtxt,
Cursor c,
int cType)
downcall into native code |
protected synchronized void setTrigger(DragGestureEvent dge) {
trigger = dge;
if (trigger != null) {
component = trigger.getComponent();
} else {
component = null;
}
}
|
abstract protected void startDrag(Transferable trans,
long[] formats,
Map formatMap)
|
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();
Transferable transferable = getDragSourceContext().getTransferable();
SortedMap 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;
}
});
}
initiate a DnD operation ... |
public void startSecondaryEventLoop() {
}
|
public void transferablesFlavorsChanged() {
}
Notify the peer that the transferables' DataFlavors have changed.
No longer useful as the transferables are determined at the time
of the drag. |