ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Post here questions and problems related to oXygen frameworks/document types.
bpopp
Posts: 37
Joined: Tue Nov 30, 2010 7:34 pm

ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Post by bpopp »

I've written a custom ExternalObjectInsertionHandler to add references from one XML to another (both files have .xml extensions). This extension is working fine when dragging files from the project window, but when I drag an XML file from the Windows File Explorer (more typical use case), the XML file opens in Oxygen and does not fire the extension. Oddly enough, dragging an image from Windows to the same file does trigger the extension as expected.

How do I control which file types are handled by the extension? Thanks for any tips.

Brian
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Post by Radu »

Hi Brian,

This is an expected behavior.
Whenever an XML document is dropped in Oxygen we somehow need to know if the end user wants to open that file in Oxygen or if they want to insert a reference to it. We considered that when dropping files from the Project the highest likelihood is for people to want to insert references to them (as they can always double click the files in the Project view to open them in Oxygen).
But for drops coming from outside of Oxygen, if they are images we consider that probably people want references to them (and call the API) but for XML file types we consider that probably people want to open them in Oxygen.
Unfortunately this cannot be controlled on your side but if you want we can consider adding some API or setting to control this behavior.

By the way, also Copying files from Windows Explorer (any type of files) and then pasting them in Oxygen should also call your API extension.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
bpopp
Posts: 37
Joined: Tue Nov 30, 2010 7:34 pm

Re: ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Post by bpopp »

Thanks Radu. Obviously I'm bias, but I think it would be very useful for all drags to go through the extension, and then allow the use of a return code or overridden function to determine whether the extension should or has dealt with the event. For my particular use case, my "project" file is a proprietary XML file (similar to a DITA map) and I am trying to provide users with an interface to be able to quickly add references to other XML files.
bpopp
Posts: 37
Joined: Tue Nov 30, 2010 7:34 pm

Re: ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Post by bpopp »

Thanks for the tip re: copy/paste from Windows, by the way. That's a good work around.
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Post by Radu »

Hi Brian,

As I was looking into how we can add new API to allow you to control this, I found out that we do have that possibility.
Basically in your AuthorExternalObjectInsertionHandler implementation you should override this acceptSource base method:

Code: Select all

  /**
* @see ro.sync.ecss.extensions.api.AuthorExternalObjectInsertionHandler#acceptSource(ro.sync.ecss.extensions.api.AuthorAccess, int)
*/
@Override
public boolean acceptSource(AuthorAccess authorAccess, int source) {
return source == DND_EXTERNAL || super.acceptSource(authorAccess, source);
}
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
bpopp
Posts: 37
Joined: Tue Nov 30, 2010 7:34 pm

Re: ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Post by bpopp »

That's awesome and worked perfectly. Thanks for following up!
Post Reply