|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.dnd.DragSourceContext
The DragSourceContext
class is responsible for managing the
initiator side of the Drag and Drop protocol. In particular, it is responsible
for managing drag event notifications to the DragSourceListener
s
and DragSourceMotionListener
s, and providing the
Transferable
representing the source data for the drag operation.
Note that the DragSourceContext
itself
implements the DragSourceListener
and
DragSourceMotionListener
interfaces.
This is to allow the platform peer
(the DragSourceContextPeer
instance)
created by the DragSource
to notify
the DragSourceContext
of
state changes in the ongoing operation. This allows the
DragSourceContext
to interpose
itself between the platform and the
listeners provided by the initiator of the drag operation.
DragSourceListener
,
DragSourceMotionListener
,
Serialized FormField Summary | |
protected static int |
CHANGED
An int used by updateCurrentCursor()
indicating that the user operation has changed. |
private Cursor |
cursor
The current drag cursor. |
protected static int |
DEFAULT
An int used by updateCurrentCursor()
indicating that the Cursor should change
to the default (no drop) Cursor . |
private static Transferable |
emptyTransferable
|
protected static int |
ENTER
An int used by updateCurrentCursor()
indicating that the Cursor
has entered a DropTarget . |
private DragSourceListener |
listener
|
protected static int |
OVER
An int used by updateCurrentCursor()
indicating that the Cursor is
over a DropTarget . |
private DragSourceContextPeer |
peer
|
private static long |
serialVersionUID
|
private int |
sourceActions
A bitwise mask of DnDConstants that represents the set of
drop actions supported by the drag source for the drag operation associated
with this DragSourceContext. |
private Transferable |
transferable
|
private DragGestureEvent |
trigger
The event which triggered the start of the drag. |
private boolean |
useCustomCursor
true if the custom drag cursor is used instead of the
default one. |
Constructor Summary | |
DragSourceContext(DragSourceContextPeer dscp,
DragGestureEvent trigger,
Cursor dragCursor,
Image dragImage,
Point offset,
Transferable t,
DragSourceListener dsl)
Called from DragSource , this constructor creates a new
DragSourceContext given the
DragSourceContextPeer for this Drag, the
DragGestureEvent that triggered the Drag, the initial
Cursor to use for the Drag, an (optional)
Image to display while the Drag is taking place, the offset
of the Image origin from the hotspot at the instant of the
triggering event, the Transferable subject data, and the
DragSourceListener to use during the Drag and Drop
operation.
|
Method Summary | |
void |
addDragSourceListener(DragSourceListener dsl)
Add a DragSourceListener to this
DragSourceContext if one has not already been added.
|
void |
dragDropEnd(DragSourceDropEvent dsde)
Calls dragDropEnd on the
DragSourceListener s registered with this
DragSourceContext and with the associated
DragSource , and passes them the specified
DragSourceDropEvent . |
void |
dragEnter(DragSourceDragEvent dsde)
Calls dragEnter on the
DragSourceListener s registered with this
DragSourceContext and with the associated
DragSource , and passes them the specified
DragSourceDragEvent . |
void |
dragExit(DragSourceEvent dse)
Calls dragExit on the
DragSourceListener s registered with this
DragSourceContext and with the associated
DragSource , and passes them the specified
DragSourceEvent . |
void |
dragMouseMoved(DragSourceDragEvent dsde)
Calls dragMouseMoved on the
DragSourceMotionListener s registered with the
DragSource associated with this
DragSourceContext , and them passes the specified
DragSourceDragEvent . |
void |
dragOver(DragSourceDragEvent dsde)
Calls dragOver on the
DragSourceListener s registered with this
DragSourceContext and with the associated
DragSource , and passes them the specified
DragSourceDragEvent . |
void |
dropActionChanged(DragSourceDragEvent dsde)
Calls dropActionChanged on the
DragSourceListener s registered with this
DragSourceContext and with the associated
DragSource , and passes them the specified
DragSourceDragEvent . |
Component |
getComponent()
Returns the Component associated with this
DragSourceContext . |
Cursor |
getCursor()
Returns the current drag Cursor .
|
DragSource |
getDragSource()
Returns the DragSource
that instantiated this DragSourceContext . |
int |
getSourceActions()
Returns a bitwise mask of DnDConstants that
represent the set of drop actions supported by the drag source for the
drag operation associated with this DragSourceContext . |
Transferable |
getTransferable()
Returns the Transferable associated with
this DragSourceContext . |
DragGestureEvent |
getTrigger()
Returns the DragGestureEvent
that initially triggered the drag. |
private void |
readObject(ObjectInputStream s)
Deserializes this DragSourceContext . |
void |
removeDragSourceListener(DragSourceListener dsl)
Removes the specified DragSourceListener
from this DragSourceContext . |
void |
setCursor(Cursor c)
Sets the cursor for this drag operation to the specified Cursor . |
private void |
setCursorImpl(Cursor c)
|
void |
transferablesFlavorsChanged()
Notifies the peer that the Transferable 's
DataFlavor s have changed. |
protected void |
updateCurrentCursor(int dropOp,
int targetAct,
int status)
If the default drag cursor behavior is active, this method sets the default drag cursor for the specified selected operation, supported actions and status, otherwise this method does nothing. |
private void |
writeObject(ObjectOutputStream s)
Serializes this DragSourceContext . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final long serialVersionUID
protected static final int DEFAULT
int
used by updateCurrentCursor()
indicating that the Cursor
should change
to the default (no drop) Cursor
.
protected static final int ENTER
int
used by updateCurrentCursor()
indicating that the Cursor
has entered a DropTarget
.
protected static final int OVER
int
used by updateCurrentCursor()
indicating that the Cursor
is
over a DropTarget
.
protected static final int CHANGED
int
used by updateCurrentCursor()
indicating that the user operation has changed.
private static Transferable emptyTransferable
private transient DragSourceContextPeer peer
private DragGestureEvent trigger
private Cursor cursor
private transient Transferable transferable
private transient DragSourceListener listener
private boolean useCustomCursor
true
if the custom drag cursor is used instead of the
default one.
private final int sourceActions
DnDConstants
that represents the set of
drop actions supported by the drag source for the drag operation associated
with this DragSourceContext.
Constructor Detail |
public DragSourceContext(DragSourceContextPeer dscp, DragGestureEvent trigger, Cursor dragCursor, Image dragImage, Point offset, Transferable t, DragSourceListener dsl)
DragSource
, this constructor creates a new
DragSourceContext
given the
DragSourceContextPeer
for this Drag, the
DragGestureEvent
that triggered the Drag, the initial
Cursor
to use for the Drag, an (optional)
Image
to display while the Drag is taking place, the offset
of the Image
origin from the hotspot at the instant of the
triggering event, the Transferable
subject data, and the
DragSourceListener
to use during the Drag and Drop
operation.
DragSourceContextPeer
is null
NullPointerException
is thrown.
DragGestureEvent
is null
NullPointerException
is thrown.
Cursor
is null
no exception is thrown and
the default drag cursor behavior is activated for this drag operation.
Image
is null
no exception is thrown.
Image
is not null
and the offset is
null
NullPointerException
is thrown.
Transferable
is null
NullPointerException
is thrown.
DragSourceListener
is null
no exception
is thrown.
dscp
- the DragSourceContextPeer
for this dragtrigger
- the triggering eventdragCursor
- the initial Cursor
dragImage
- the Image
to drag (or null
)offset
- the offset of the image origin from the hotspot at the
instant of the triggering eventt
- the Transferable
dsl
- the DragSourceListener
IllegalArgumentException
- if the Component
associated
with the trigger event is null
.
IllegalArgumentException
- if the DragSource
for the
trigger event is null
.
IllegalArgumentException
- if the drag action for the
trigger event is DnDConstants.ACTION_NONE
.
IllegalArgumentException
- if the source actions for the
DragGestureRecognizer
associated with the trigger
event are equal to DnDConstants.ACTION_NONE
.
NullPointerException
- if dscp, trigger, or t are null, or
if dragImage is non-null and offset is nullMethod Detail |
public DragSource getDragSource()
DragSource
that instantiated this DragSourceContext
.
DragSource
that
instantiated this DragSourceContext
public Component getComponent()
Component
associated with this
DragSourceContext
.
Component
that started the dragpublic DragGestureEvent getTrigger()
DragGestureEvent
that initially triggered the drag.
public int getSourceActions()
DnDConstants
that
represent the set of drop actions supported by the drag source for the
drag operation associated with this DragSourceContext
.
public void setCursor(Cursor c)
Cursor
. If the specified Cursor
is null
, the default drag cursor behavior is
activated for this drag operation, otherwise it is deactivated.
c
- the Cursor
to display, or
null
to activate the default drag cursor
behaviorpublic Cursor getCursor()
Cursor
.
Cursor
public void addDragSourceListener(DragSourceListener dsl) throws TooManyListenersException
DragSourceListener
to this
DragSourceContext
if one has not already been added.
If a DragSourceListener
already exists,
this method throws a TooManyListenersException
.
dsl
- the DragSourceListener
to add.
Note that while null
is not prohibited,
it is not acceptable as a parameter.
TooManyListenersException
- if
a DragSourceListener
has already been added
TooManyListenersException
public void removeDragSourceListener(DragSourceListener dsl)
DragSourceListener
from this DragSourceContext
.
dsl
- the DragSourceListener
to remove;
note that while null
is not prohibited,
it is not acceptable as a parameterpublic void transferablesFlavorsChanged()
Transferable
's
DataFlavor
s have changed.
public void dragEnter(DragSourceDragEvent dsde)
dragEnter
on the
DragSourceListener
s registered with this
DragSourceContext
and with the associated
DragSource
, and passes them the specified
DragSourceDragEvent
.
dragEnter
in interface DragSourceListener
dsde
- the DragSourceDragEvent
public void dragOver(DragSourceDragEvent dsde)
dragOver
on the
DragSourceListener
s registered with this
DragSourceContext
and with the associated
DragSource
, and passes them the specified
DragSourceDragEvent
.
dragOver
in interface DragSourceListener
dsde
- the DragSourceDragEvent
public void dragExit(DragSourceEvent dse)
dragExit
on the
DragSourceListener
s registered with this
DragSourceContext
and with the associated
DragSource
, and passes them the specified
DragSourceEvent
.
dragExit
in interface DragSourceListener
dse
- the DragSourceEvent
public void dropActionChanged(DragSourceDragEvent dsde)
dropActionChanged
on the
DragSourceListener
s registered with this
DragSourceContext
and with the associated
DragSource
, and passes them the specified
DragSourceDragEvent
.
dropActionChanged
in interface DragSourceListener
dsde
- the DragSourceDragEvent
public void dragDropEnd(DragSourceDropEvent dsde)
dragDropEnd
on the
DragSourceListener
s registered with this
DragSourceContext
and with the associated
DragSource
, and passes them the specified
DragSourceDropEvent
.
dragDropEnd
in interface DragSourceListener
dsde
- the DragSourceDropEvent
public void dragMouseMoved(DragSourceDragEvent dsde)
dragMouseMoved
on the
DragSourceMotionListener
s registered with the
DragSource
associated with this
DragSourceContext
, and them passes the specified
DragSourceDragEvent
.
dragMouseMoved
in interface DragSourceMotionListener
dsde
- the DragSourceDragEvent
public Transferable getTransferable()
Transferable
associated with
this DragSourceContext
.
Transferable
protected void updateCurrentCursor(int dropOp, int targetAct, int status)
dropOp
- the user's currently selected operationtargetAct
- the current target's supported actionsstatus
- the constantprivate void setCursorImpl(Cursor c)
private void writeObject(ObjectOutputStream s) throws IOException
DragSourceContext
. This method first
performs default serialization. Next, this object's
Transferable
is written out if and only if it can be
serialized. If not, null
is written instead. In this case,
a DragSourceContext
created from the resulting deserialized
stream will contain a dummy Transferable
which supports no
DataFlavor
s. Finally, this object's
DragSourceListener
is written out if and only if it can be
serialized. If not, null
is written instead.
IOException
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException
DragSourceContext
. This method first
performs default deserialization for all non-transient
fields. This object's Transferable
and
DragSourceListener
are then deserialized as well by using
the next two objects in the stream. If the resulting
Transferable
is null
, this object's
Transferable
is set to a dummy Transferable
which supports no DataFlavor
s.
ClassNotFoundException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |