This topic describes the implementation of drag and drop within IBM Director.
Note, the word "drag" is generally used to indicate the process of both dragging and dropping an object. The use of "drag and drop" is therefore normally considered unacceptable because of the inherent redundancy. In this topic, because the actions of icons at various stages of the drag and the drop processes are under consideration, both terms are used explicitly. "Drag" is specifically intended to mean the process of taking an icon and copying or moving it to a location without completing the action (i.e., "dropping" the icon).
In IBM Director Version 4.2 and beyond, drag and drop is implemented using the JDK java.awt.dnd package. Unlike the previous in-house implementation of drag and drop, when dragging from IBM Director a DragSource can now be dropped onto DropTargets in applications (such as WordPad) outside of IBM Director. Using this implementation of drag and drop, you must take care to select the appropriate drag and drop action, since the drag cursor associated with a drag and drop action conveys information to the user.
When a drag begins, the DragSource Component must provide a "Transferable" for the drag. The Transferable contains one or more "DataFlavors." Think of the Transferable as a suitcase and the DataFlavors as its contents. The DataFlavors contained in the Transferable typically provide multiple representations of specific information in the DragSource. DropTargets will query the Transferable to see if it contains something useful. IBM Director contains a set of Transferables which might be of interest to DropTargets in IBM Director Console Extensions. Similarly, IBM IBM Director framework DropTargets might recognize these Transferables if they are provided by Console Extensions.
Using this new drag and drop implementation, the ability to drag objects between windows becomes a matter of the DragSource advertising what it has to offer and the DropTarget accepting offers it is capable of handling. This is very flexible and has a great deal of potential. A useful overview can be found at:
http://www.javaworld.com/javaworld/jw-03-1999/jw-03-dragndrop_p.html
The most common actions used are DnDConstants.ACTION_MOVE and DnDConstants.ACTION_COPY.
DnDConstants.ACTION_MOVE indicates that the DragSource from which the drag originated is modified when the drop is accepted by a DropTarget. A good place to use this cursor is on an Add/Remove panel such as those used in the IBM Director User Administration User Editor.
![]() |
Windows Move Cursor |
![]() |
Linux Move Cursor |
The following cursors indicate to the user that there is no valid DropTarget beneath the cursor during an ACTION_MOVE drag:
![]() |
Windows "No Move" Cursor |
![]() |
Linux "No Move" Cursor |
DnDConstants.ACTION_COPY indicates that the DragSource from which the drag originated will not be modified when the drop is accepted by a DropTarget. The main console uses this action.
![]() |
Windows Copy Cursor |
![]() |
Linux Copy Cursor |
The following cursors indicate to the user that there is no valid DropTarget beneath the cursor during an ACTION_COPY drag:
![]() |
Windows "No Copy" Cursor |
![]() |
Linux "No Copy" Cursor |
There is also a DnDConstants.ACTION_COPY_OR_MOVE action which can be used when either a copy or move operation is permitted. When a Component supports both Copy and Move, a normal drag from the component performs a move and a Control-drag performs a copy.
IBM Director framework Transferables that might be of interest to Console Extensions are found in the com.tivoli.twg.guilibs package and are listed here. TOIDSetFlavor, MOIDSetFlavor and FOIDSetFlavor are also included in the com.tivoli.twg.guilibs package. StringValueSet is included in the com.tivoli.twg.libs package.
TWGFilterTransferable:
A Transferable used to transfer information
about a set of filter objects. One DragSource providing this object is the
Groups Pane of the Console.
TWGManagedObjectTransferable:
A Transferable used to transfer
information about a set of managed objects. One DragSource providing this object
is the Group Contents Pane of the Console.
TWGTaskTransferable:
A Transferable used to transfer information
about a set of task objects. One DragSource providing this object is the Tasks
Pane of the Console.
In JDK1.4.1, on which IBM Director Version 5.1 is based, the UI classes of many Java widgets have been outfitted with default drag/drop mechanisms. An example is the JTextComponent family of widgets which will accept String DataFlavors. If one of these widgets uses a KeyListener to catch and analyze the incoming text for characters it considers valid (such as digits), drop will act like a paste and can cause a NumberFormatException. Even if your widget has been outfitted to handle Paste Actions, additional code might be required to handle these drop actions.