blob: fa6c63a177437889dbd06ea6ed865a520414a583 [file] [log] [blame]
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.5 [en] (WinNT; I) [Netscape]">
<meta name="Author" content="Build">
<title>Eclipse Workbench Extension Point: Drop Actions</title>
</head>
<body link="#0000FF" vlink="#800080">
<center>
<h1>
Drop Actions</h1></center>
<b><i>Identifier: </i></b>org.eclipse.ui.dropActions
<p><b><i>Description: </i></b>This extension point is used to add drop
behaviour to views defined by other plugins.
<p>Due to the UI layering imposed by the plugin mechanism, views are often
not aware of the content and nature of other views. This can make drag
and drop operations between plugins difficult. For example, one may wish
to provide Java refactoring support whereby the user drags a method from
the Java editor’s content outliner into another java file in the resource
navigator.&nbsp; Since the resource navigator doesn’t know anything about
Java content, it doesn’t know how to behave when java methods are dropped
onto it.&nbsp; Similarly, an ISV may want to drop some of their content
into one of the Java viewers.
<p>The org.eclipse.ui.dropActions extension point is provided by the Platform to address
these situations. This mechanism delegates the drop behaviour back to the
originator of the drag operation. This behaviour is contained in an action
that must implement org.eclipse.ui.part.IDropActionDelegate.&nbsp;
The viewer that is the source of the drag operation must support the org.eclipse.ui.part.PluginTransfer
transfer type, and place a org.eclipse.ui.part.PluginTransferData object in the drag event.&nbsp;
See org.eclipse.jface.viewers.StructuredViewer#addDragSupport to learn how
to add drag support to a viewer.
<p><b><i>Configuration Markup:</i></b>
<p><tt>&nbsp;&nbsp; &lt;!ELEMENT dropContribution (action)*></tt><tt></tt>
<p><tt>&nbsp;&nbsp; &lt;!ELEMENT action*></tt>
<br><tt>&nbsp;&nbsp; &lt;!ATTLIST action</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CDATA #REQUIRED</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; class&nbsp;&nbsp;&nbsp; CDATA #REQUIRED</tt>
<br><tt>&nbsp;&nbsp; ></tt>
<ul>
<li>
<b>id</b> - a unique identifier that can be used to reference this action</li>
<li>
<b>class</b> - the name of the fully qualified class that implements org.eclipse.ui.part.IDropActionDelegate.</li>
</ul>
<p><br><b><i>Examples:</i></b>
<p>The following is an example of a drop action extension:
<p><tt>&nbsp; &lt;extension point="org.eclipse.ui.dropActions"></tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;action></tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id="my_drop_action"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class="com.xyz.eclipse.TestDropAction"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/action></tt>
<br><tt>&nbsp; &lt;/extension></tt><tt></tt>
<p>Here is an example of a drag listener that makes use of the drop action
defined above.
<p><tt>class MyDragListener extends DragSourceAdapter {</tt>
<br><tt>&nbsp;&nbsp;&nbsp; public void dragSetData(DragSourceEvent event)
{</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (PluginTransfer.getInstance().isSupportedType(event.dataType))
{</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
byte[] dataToSend = ...//enter the data to be sent.</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
event.data = new PluginTransferData(</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
"my_drop_action", dataToSend);</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</tt>
<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
<br><tt>}</tt><tt></tt>
<p>For a more complete example, see the Platform readme example
where drop action is defined in ReadmeDropActionDelegate,
and it is used by ReadmeContentOutlineDragListener.
<p><b><i>API Information: </i></b>The value of the <tt>class</tt> attribute
must be a fully qualified name of a Java class that implements <tt>org.eclipse.ui.part.IDropActionDelegate</tt>.
This class is loaded as late as possible to avoid loading the entire
plug-in before it is really needed.
<p><b><i>Supplied Implementation:</i></b> The workbench does not provide an implementation for this extension point.
Plug-ins can contribute to this extension point to add drop behavior to views defined by other plugins.
<p><a href="hglegal.htm"><img SRC="ngibmcpy.gif" ALT="Copyright IBM Corporation 2000, 2001" BORDER=0 height=12 width=195></a>
</body>
</html>