Get next valid position to insert a fragment

Post here questions and problems related to oXygen frameworks/document types.
Denis
Posts: 47
Joined: Thu Jun 19, 2014 3:55 pm

Get next valid position to insert a fragment

Post 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
Denis Zygann
KGU Consulting GmbH
http://www.kgu-consulting.com
Radu
Posts: 9434
Joined: Fri Jul 09, 2004 5:18 pm

Re: Get next valid position to insert a fragment

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply