ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Post here questions and problems related to oXygen frameworks/document types.
bpopp
Posts: 37

ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Mon Jan 22, 2018 7:29 pm

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: 5809

Re: ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Tue Jan 23, 2018 10:21 am

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

Re: ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Tue Jan 23, 2018 5:31 pm

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

Re: ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Tue Jan 23, 2018 5:35 pm

Thanks for the tip re: copy/paste from Windows, by the way. That's a good work around.
Radu
Posts: 5809

Re: ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Thu Jan 25, 2018 9:47 am

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

Re: ExternalObjectInsertionHandler Not Firing for Dragged XML Files

Sat Jan 27, 2018 12:51 am

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

Return to “SDK-API, Frameworks - Document Types”

Who is online

Users browsing this forum: No registered users and 0 guests