AuthorDnDListener - Can't get my objet
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 124
- Joined: Tue May 29, 2012 5:42 pm
AuthorDnDListener - Can't get my objet
Post by sebastienlavandier »
Hi,
In my application, I make a drag and drop action of a swing objet to an xml document, with a AuthorDnDListener which is in a framework and a java.awt.datatransfer.Transferable with a TransferHandler which are in a plugin.
That works !
But now I want to make some tests/update on the xml document during the DnD actions, and I don't want do that in the TransferHandler /exportDone() function. I want do all my test/update during the Dnd Action in the same place, most specially in the AuthorDnDListener/authorDrop function.
public boolean authorDrop(Transferable transferable, DropTargetDropEvent dropTargetDropEvent)
But in this function I can't cast the transferable to my transferableObjet, I don't understand why, and this one works in the TransferHandler /exportDone() function.
protected void exportDone(JComponent c, java.awt.datatransfer.Transferable transferable, int action)
Tool tool = (Tool) transferable.getTransferData(ToolTransferable.TOOL_DATAFLAVOR);
The exception message is :
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: com._4dconcept.docAdvance.authorNeo.plugin.views.tools.SpareTool cannot be cast to com._4dconcept.docAdvance.authorNeo.plugin.views.tools.SpareTool
Do you have an idea ? or an example ?
Thanks in advance.
In my application, I make a drag and drop action of a swing objet to an xml document, with a AuthorDnDListener which is in a framework and a java.awt.datatransfer.Transferable with a TransferHandler which are in a plugin.
That works !
But now I want to make some tests/update on the xml document during the DnD actions, and I don't want do that in the TransferHandler /exportDone() function. I want do all my test/update during the Dnd Action in the same place, most specially in the AuthorDnDListener/authorDrop function.
public boolean authorDrop(Transferable transferable, DropTargetDropEvent dropTargetDropEvent)
But in this function I can't cast the transferable to my transferableObjet, I don't understand why, and this one works in the TransferHandler /exportDone() function.
protected void exportDone(JComponent c, java.awt.datatransfer.Transferable transferable, int action)
Tool tool = (Tool) transferable.getTransferData(ToolTransferable.TOOL_DATAFLAVOR);
The exception message is :
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: com._4dconcept.docAdvance.authorNeo.plugin.views.tools.SpareTool cannot be cast to com._4dconcept.docAdvance.authorNeo.plugin.views.tools.SpareTool
Do you have an idea ? or an example ?
Thanks in advance.
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: AuthorDnDListener - Can't get my objet
Hi Sebastien,
You have a custom view contributed by a plugin and you somehow drag and drop content from it to the Author page, correct?
So you probably have a JAR library containing the com._4dconcept.docAdvance.authorNeo.plugin.views.tools.SpareTool class which you have added both to the plugin.xml and to the framework's Classpath list, right?
Oxygen creates separate Java class loaders for each loaded plugin and framework.
The object is created on the plugin's class loader and when it gets dropped the callback is made in the framework's class loader where the object cannot be cast to the class because it was created on a different class loader.
Your options would be:
1) Call the object's methods using Java Reflection on the framework's side.
2) If the "SpareTool" object would be serializable it could probably be possible to serialize it to a byte array output stream and then to de-serialize it in the framework class loader.
We'll see if we can make improvements to allow in certain cases a plugin and a framework to share a class loader.
Regards,
Radu
You have a custom view contributed by a plugin and you somehow drag and drop content from it to the Author page, correct?
So you probably have a JAR library containing the com._4dconcept.docAdvance.authorNeo.plugin.views.tools.SpareTool class which you have added both to the plugin.xml and to the framework's Classpath list, right?
Oxygen creates separate Java class loaders for each loaded plugin and framework.
The object is created on the plugin's class loader and when it gets dropped the callback is made in the framework's class loader where the object cannot be cast to the class because it was created on a different class loader.
Your options would be:
1) Call the object's methods using Java Reflection on the framework's side.
2) If the "SpareTool" object would be serializable it could probably be possible to serialize it to a byte array output stream and then to de-serialize it in the framework class loader.
We'll see if we can make improvements to allow in certain cases a plugin and a framework to share a class loader.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 12
- Joined: Sun Feb 27, 2011 10:30 am
Re: AuthorDnDListener - Can't get my objet
Hello Radu,
I work with Sebastien.
Your description of our issues is right.
On one side we have a plugin with a custom view. User can d&d content from the view to the author.
On the other side we have a framework which handle the d&d and transform the content of the d&d according to the xml schema.
The content is a class shared between the plugin and the framework what causes the class cast.
On a developer point of view, I think the separation between plugin and framework is not always suitable because plugin (ie. view) and framework is tightly coupled.
Regards,
Nicolas
I work with Sebastien.
Your description of our issues is right.
On one side we have a plugin with a custom view. User can d&d content from the view to the author.
On the other side we have a framework which handle the d&d and transform the content of the d&d according to the xml schema.
The content is a class shared between the plugin and the framework what causes the class cast.
On a developer point of view, I think the separation between plugin and framework is not always suitable because plugin (ie. view) and framework is tightly coupled.
Regards,
Nicolas
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: AuthorDnDListener - Can't get my objet
Hi Nicolas,
We'll try to make some improvements in this area after Oxygen 14.0 is released.
Maybe even come up with the concept of a plugin which is also a framework.
Would any of the workaround I gave be suitable for you?
Regards,
Radu
I agree with this and you are not the only ones having such problems.On a developer point of view, I think the separation between plugin and framework is not always suitable because plugin (ie. view) and framework is tightly coupled.
We'll try to make some improvements in this area after Oxygen 14.0 is released.
Maybe even come up with the concept of a plugin which is also a framework.
Would any of the workaround I gave be suitable for you?
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 124
- Joined: Tue May 29, 2012 5:42 pm
Re: AuthorDnDListener - Can't get my objet
Post by sebastienlavandier »
Hi,
I tested both solutions (retrospection / Serialisation). Both works well !
Thanks again.
Bye
I tested both solutions (retrospection / Serialisation). Both works well !
Thanks again.
Bye
Return to “SDK-API, Frameworks - Document Types”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service