Page 1 of 1

ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Posted: Mon Jan 22, 2018 7:29 pm
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

Re: ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Posted: Tue Jan 23, 2018 10:21 am
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

Re: ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Posted: Tue Jan 23, 2018 5:31 pm
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.

Re: ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Posted: Tue Jan 23, 2018 5:35 pm
by bpopp
Thanks for the tip re: copy/paste from Windows, by the way. That's a good work around.

Re: ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Posted: Thu Jan 25, 2018 9:47 am
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

Re: ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Posted: Sat Jan 27, 2018 12:51 am
by bpopp
That's awesome and worked perfectly. Thanks for following up!