org.eclipse.emf.edit.ui.dnd
Class LocalTransfer

java.lang.Object
  extended by org.eclipse.swt.dnd.Transfer
      extended by org.eclipse.swt.dnd.ByteArrayTransfer
          extended by org.eclipse.emf.edit.ui.dnd.LocalTransfer

public class LocalTransfer
extends org.eclipse.swt.dnd.ByteArrayTransfer

This derived implementation of a byte array transfer short circuits the transfer process so that a local transfer does not serialize the object and hence can and will return the original object, not just a clone. You only really need ever know about LocalTransfer.getInstance(), so that you can include it in when adding drag support to a viewer. See EditingDomainViewerDropAdapter and ViewerDragAdapter for more details.

As an added guard, the time is recorded and serialized in javaToNative to that native to java can ensure that it's returns the value that was really to have been transferred.


Method Summary
static LocalTransfer getInstance()
          This returns the one instance of this transfer agent.
 String[] getTypeNames()
          This returns the transfer names that this agent supports.
 void javaToNative(Object object, org.eclipse.swt.dnd.TransferData transferData)
          This records the object and current time and encodes only the current time into the transfer data.
 Object nativeToJava(org.eclipse.swt.dnd.TransferData transferData)
          This decodes the time of the transfer and returns the recorded the object if the recorded time and the decoded time match.
 
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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static LocalTransfer getInstance()
This returns the one instance of this transfer agent.


getTypeNames

public String[] getTypeNames()
This returns the transfer names that this agent supports.

Specified by:
getTypeNames in class org.eclipse.swt.dnd.Transfer

javaToNative

public void javaToNative(Object object,
                         org.eclipse.swt.dnd.TransferData transferData)
This records the object and current time and encodes only the current time into the transfer data.

Overrides:
javaToNative in class org.eclipse.swt.dnd.ByteArrayTransfer

nativeToJava

public Object nativeToJava(org.eclipse.swt.dnd.TransferData transferData)
This decodes the time of the transfer and returns the recorded the object if the recorded time and the decoded time match.

Overrides:
nativeToJava in class org.eclipse.swt.dnd.ByteArrayTransfer


Copyright © 2014. All Rights Reserved.