Page 1 of 1

Get next valid position to insert a fragment

Posted: Fri Oct 24, 2014 3:28 pm
by Denis
Hi,

we are using the Eclipse Oxygen Author in Version 15.2.

I am using the

Code: Select all


try {
documentController.insertFragmentSchemaAware(offset, fragment);
} catch (AuthorOperationException e) {}

method to insert a fragment. If the exception will be thrown, the method will not insert anything of course.

My question is: How I can get the next possible offset, where the fragment can be dropped?
It would be nice, when I can open the same dialog, which will be shown if the offset is not valid for this fragment.

Best regards
Denis

Re: Get next valid position to insert a fragment

Posted: Fri Oct 24, 2014 3:53 pm
by Radu
Hi Denis,
It would be nice, when I can open the same dialog, which will be shown if the offset is not valid for this fragment.
I do not understand very well what you want to accomplish.
That dialog which shows alternative strategies is not API so you cannot show it from your side.

At the same time you have API to see if a certain fragment can be inserted in a certain place in the Author editing mode:

AuthorDocumentController.getAuthorSchemaManager().canInsertDocumentFragment(AuthorDocumentFragment, int, short)

So you can try at the current offset and if it fails you can try around it, for example try before the current node or after it, or before the parent node and so on. That's about what we do in order to decide what alternate strategies to present to the user.

Regards,
Radu