be.ugent.caagt.swirl.dnd
Interface DragHandler
public interface DragHandler
Handles the 'drag' part of a drag-and-drop operation of a local object of given type.
Used in conjunction with
LocalTransferHandler
.
void | exportDone(JComponent source, JComponent target, Object[] objects, Class> type, int action) - Invoked after data has been dragged from the given source
component and dropped onto the given target component.
|
Class | getExportedClass(JComponent source) - Return the class of objects being exported from the given source.
|
Object | getExportedObjects(JComponent source) - Return the object(s) to be exported by a drag
or cut-and-paste operation from the given source.
|
int | getSourceActions(JComponent source) - Returns the type of transfer actions supported by the given component.
|
boolean | isTransferAllowed(JComponent source, JComponent target) - Indicates whether this handler allows a transfer from the given source to the given target.
|
exportDone
public void exportDone(JComponent source,
JComponent target,
Object[] objects,
Class> type,
int action)
Invoked after data has been dragged from the given source
component and dropped onto the given target component. Typically, when the action
is
MOVE
and source and target are not the same (or are not views
of the same model),
the objects need to be removed from the source. When the
action is
COPY
or
LINK
, nothing needs to be done.
source
- The component that was the source of the data.target
- The component that was the target of the data, or null
if the target is not a LocalTransferHandler
.objects
- Array of objects which have been exportedtype
- Element type of this arrayaction
- the actual action that was performed
LocalTransferHandler.exportDone
getExportedClass
public Class getExportedClass(JComponent source)
Return the class of objects being exported from the given source. If this
returns null, the class of the object
returned by
getExportedObjects(JComponent)
is used, or the element type if an array is returned.
getExportedObjects
public Object getExportedObjects(JComponent source)
Return the object(s) to be exported by a drag
or cut-and-paste operation from the given source. If multiple
objects are exported at the same time, this should return an array.
getSourceActions
public int getSourceActions(JComponent source)
Returns the type of transfer actions supported by the given component.
Should return one the constants
COPY
,
MOVE
,
COPY_OR_MOVE
,
LINK
or
NONE
, cf.
LocalTransferHandler
.
isTransferAllowed
public boolean isTransferAllowed(JComponent source,
JComponent target)
Indicates whether this handler allows a transfer from the given source to the given target.
Typically this either returns true
always, or returns
true if and only if the source and target are different.
A more sophisticated implementation
would instead compare the underlying models of the components.