[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Dropping Java objects as text
|
My application uses a TreeViewer to let users edit "bookmarks" and organize
them in folders. When users drag bookmarks and folders within the viewer,
they are transferred as serialized objects using a subclass of
ByteArrayTransfer. This has been implemented and is working fine. I want
to be able to drag these same items *out* of the application so an external
text representation can be dropped into other applications.
I'm a bit stuck at this point. The drop data can't be the external text
representation because it wouldn't be appropriate for internal drops.
Currently the drop data is a reference to the object itself, which works
fine for internal drops and seems like the right thing to do. However,
since the drop data isn't the external text representation, I can't use
TextTransfer directly.
The natural thing to do seems to be to subclass TextTransfer and override
javaToNative, but TextTransfer is designed to prevent subclassing -- it has
no public or protected constructors.
I think I need to subclass ByteArrayTransfer (or Transfer) and implement
getTypeNames() and getTypeIds() to return the same values as
TextTransfer.getTypeNames() and TextTransfer.getTypeIds(). Where do I get
these values? I would like to delegate to the TextTransfer
implementations, but they're protected. I don't see any API in the dnd
package that lets me retrieve the platform-specific names and IDs for
dropping text.
Am I going about this the right way? What am I missing? Any tips would be
much appreciated.
Thanks,
David