Eclipse Platform
Release 3.0

org.eclipse.ui.part
Class EditorInputTransfer

java.lang.Object
  extended byorg.eclipse.swt.dnd.Transfer
      extended byorg.eclipse.swt.dnd.ByteArrayTransfer
          extended byorg.eclipse.ui.part.EditorInputTransfer

public class EditorInputTransfer
extends ByteArrayTransfer

The EditorInputTransfer class is used to transfer an IEditorInput and corresponding editorId from one part to another in a drag and drop operation. Only opening of internal editors is supported.

In every drag and drop operation there is a DragSource and a DropTarget. When a drag occurs a Transfer is used to marshall the drag data from the source into a byte array. If a drop occurs another Transfer is used to marshall the byte array into drop data for the target.

This class can be used for a Viewer or an SWT component directly. A singleton is provided which may be serially reused (see getInstance). For an implementor of IEditorInput to be supported by EditorInputTransfer, it must provide a proper implementation of IEditorInput.getPersistable. For further details, consult the org.eclipse.ui.elementFactories extension point.

The data for a transfer is represented by the EditorInputData class, and a convenience method createEditorInputData is provided. A DragSource.dragSetData implementation should set the data to an array of EditorInputData. In this way, the dragging of multiple editor inputs is supported.

Below is an example of how to set the data for dragging a single editor input using a EditorInputTransfer.

 public void dragSetData(DragSourceEvent event) {
 		if (EditorInputTransfer.getInstance().isSupportedType(event.dataType)) {
 
 			EditorInputTransfer.EditorInputData data = 
 				EditorInputTransfer.
 				createEditorInputData(EDITOR_ID, getEditorInput());
 			event.data = new EditorInputTransfer.EditorInputData [] {data};
 		}
 }
 

See Also:
StructuredViewer, DropTarget, DragSource, IEditorInput, IPersistableElement, IElementFactory

Nested Class Summary
static class EditorInputTransfer.EditorInputData
           
 
Method Summary
static EditorInputTransfer.EditorInputData createEditorInputData(String editorId, IEditorInput input)
           
static EditorInputTransfer getInstance()
          Returns the singleton instance.
protected  int[] getTypeIds()
          Returns the platform specfic ids of the data types that can be converted using this transfer agent.
protected  String[] getTypeNames()
          Returns the platform specfic names of the data types that can be converted using this transfer agent.
 void javaToNative(Object data, TransferData transferData)
          This implementation of javaToNative converts a java byte[] to a platform specific representation.
 Object nativeToJava(TransferData transferData)
          This implementation of nativeToJava converts a platform specific representation of a byte array to a java byte[].
 
Methods inherited from class org.eclipse.swt.dnd.ByteArrayTransfer
getSupportedTypes, isSupportedType
 
Methods inherited from class org.eclipse.swt.dnd.Transfer
registerType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static EditorInputTransfer getInstance()
Returns the singleton instance.

Returns:
the singleton instance

getTypeIds

protected int[] getTypeIds()
Description copied from class: Transfer
Returns the platform specfic ids of the data types that can be converted using this transfer agent.

Specified by:
getTypeIds in class Transfer
Returns:
the platform specfic ids of the data types that can be converted using this transfer agent

getTypeNames

protected String[] getTypeNames()
Description copied from class: Transfer
Returns the platform specfic names of the data types that can be converted using this transfer agent.

Specified by:
getTypeNames in class Transfer
Returns:
the platform specfic names of the data types that can be converted using this transfer agent.

javaToNative

public void javaToNative(Object data,
                         TransferData transferData)
Description copied from class: ByteArrayTransfer
This implementation of javaToNative converts a java byte[] to a platform specific representation. For additional information see Transfer#javaToNative.

Overrides:
javaToNative in class ByteArrayTransfer
Parameters:
data - a java byte[] containing the data to be converted
transferData - an empty TransferData object; this object will be filled in on return with the platform specific format of the data
See Also:
Transfer.javaToNative(java.lang.Object, org.eclipse.swt.dnd.TransferData)

nativeToJava

public Object nativeToJava(TransferData transferData)
Description copied from class: ByteArrayTransfer
This implementation of nativeToJava converts a platform specific representation of a byte array to a java byte[]. For additional information see Transfer#nativeToJava.

Overrides:
nativeToJava in class ByteArrayTransfer
Parameters:
transferData - the platform specific representation of the data to be been converted
Returns:
a java byte[] containing the converted data if the conversion was successful; otherwise null
See Also:
Transfer.nativeToJava(org.eclipse.swt.dnd.TransferData)

createEditorInputData

public static EditorInputTransfer.EditorInputData createEditorInputData(String editorId,
                                                                        IEditorInput input)

Eclipse Platform
Release 3.0

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.