01 package ideExtensions.dragDropSimple;
02
03 import com.bea.ide.core.datatransfer.DataTransferSvc;
04
05 import java.awt.Component;
06 import javax.swing.JPanel;
07 import javax.swing.JPanel;
08 import javax.swing.JScrollPane;
09 import java.awt.GridLayout;
10
11 /**
12 * A frame view that displays a tree with example data for dragging
13 * and dropping. This view registers the tree as a participant in
14 * drag/drop operations using the data transfer service.
15 */
16 public class TreePanelView extends JPanel
17 implements com.bea.ide.ui.frame.IFrameView
18 {
19 /**
20 * Called by the IDE to retrieve the user interface that should be
21 * displayed in the frame.
22 *
23 * @param viewId The id, if any, for the frame specified in the frame's
24 * extension.xml file.
25 * @return The user interface to display within the frame's
26 * boundaries.
27 */
28 public Component getView(String viewId)
29 {
30 return this;
31 }
32
33 /**
34 * Called by the IDE to discover whether this frame is available
35 * for display; only called if the frame's extension.xml includes
36 * the askavailable attribute set to "true".
37 *
38 * @return <code>true</code> if the frame should be available;
39 * <code>false</code> if it should not be.
40 */
41 public boolean isAvailable()
42 {
43 return true;
44 }
45
46 /**
47 * Constructs this view panel by creating a new instance of the
48 * SimpleTree and placing it within a scrolling pane. This code
49 * also registers the tree contained by this panel as supporting
50 * drag/drop actions, specifying the drag/drop driver to use.
51 */
52 public TreePanelView()
53 {
54 super(new GridLayout(1, 0));
55 SimpleTree tree = new SimpleTree();
56 JScrollPane treePane = new JScrollPane(tree);
57 this.add(treePane);
58
59 /**
60 * Register a drag/drop driver for the tree, specifying that
61 * this is an action to copy data from source to target (rather
62 * than, say, a move action) and that a drag image should be
63 * used.
64 */
65 DataTransferSvc.get().registerDnDSupport(tree,
66 new SimpleTreeDragDropDriver(),
67 javax.swing.TransferHandler.COPY,
68 true);
69 }
70 }
|