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.


Method Summary
 void exportDone(javax.swing.JComponent source, javax.swing.JComponent target, java.lang.Object[] objects, java.lang.Class<?> type, int action)
          Invoked after data has been dragged from the given source component and dropped onto the given target component.
 java.lang.Class getExportedClass(javax.swing.JComponent source)
          Return the class of objects being exported from the given source.
 java.lang.Object getExportedObjects(javax.swing.JComponent source)
          Return the object(s) to be exported by a drag or cut-and-paste operation from the given source.
 int getSourceActions(javax.swing.JComponent source)
          Returns the type of transfer actions supported by the given component.
 boolean isTransferAllowed(javax.swing.JComponent source, javax.swing.JComponent target)
          Indicates whether this handler allows a transfer from the given source to the given target.
 

Method Detail

isTransferAllowed

boolean isTransferAllowed(javax.swing.JComponent source,
                          javax.swing.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.

See Also:
LocalTransferHandler.isTransferAllowed(javax.swing.JComponent, javax.swing.JComponent)

getSourceActions

int getSourceActions(javax.swing.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.

See Also:
LocalTransferHandler.getSourceActions(javax.swing.JComponent)

exportDone

void exportDone(javax.swing.JComponent source,
                javax.swing.JComponent target,
                java.lang.Object[] objects,
                java.lang.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.

Parameters:
objects - Array of objects which have been exported
type - Element type of this array
action - the actual action that was performed
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.
See Also:
LocalTransferHandler.exportDone(javax.swing.JComponent, javax.swing.JComponent, java.lang.Object[], java.lang.Class, int)

getExportedObjects

java.lang.Object getExportedObjects(javax.swing.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.

See Also:
LocalTransferHandler.getExportedObjects(javax.swing.JComponent)

getExportedClass

java.lang.Class getExportedClass(javax.swing.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(javax.swing.JComponent) is used, or the element type if an array is returned.

See Also:
LocalTransferHandler.getExportedClass(javax.swing.JComponent)