Page 1 of 1

Simultaneous dialogs with ExecuteMultipleActionsOperation

Posted: Fri Apr 12, 2019 2:55 pm
by Bruno.Ballarin
Hi,

In order to allow in one single toolbar command to create a xref and then to edit the outputclass attribute, I use a ExecuteMultipleActionsOperation with actionIDs: xref.insert, xref.type.

The xref.insert calls an Action built with the InsertXrefOperation (that includes a built-in dialog to select the xref source).
The xref.type calls an Action built with the ChangeAttributeOperation with "name" = "outputclass" and "value" set through a custom dialog ${ask('xref type:',combobox,('':'Standard:';'number':'Index-only:';'title':'Title-only:';'#':'Digit-only:'),'')}

When I launch the ExecuteMultipleActionsOperation, I got both dialogs simultaneously, the built-in InsertXrefOperation dialog and the custom ChangeAttributeOperation.value dialog, like if the second Operation is launched before the first operation built-in dialog is even answered and closed.

Is it normal behavior?

Is there a way to force the completion of the InsertXrefOperation before running the ChangeAttributeOperation?

Cheers,

Bruno

Re: Simultaneous dialogs with ExecuteMultipleActionsOperation

Posted: Mon Apr 15, 2019 3:04 pm
by alex_jitianu
Hello,

Unfortunately, it is an expected behavior. The dialog presented by InsertXrefOperation is not a modal dialog which means that after the dialog is presented, the action finishes and the ChangeAttributeOperation is invoked.
You'll have to use our Java-based API and set an AuthorDocumentFilter. Something like this:

Code: Select all



public void insertFragment(AuthorDocumentFilterBypass filterBypass, int offset, AuthorDocumentFragment frag) {
String value = EditorVariables.expandEditorVariables("${ask('Get the value')}", null);
// TODO Look inside the fragment and set the @outputclass attribute as needed.
List<AuthorNode> contentNodes = frag.getContentNodes();
if (contentNodes.size() > 1) {
for (AuthorNode authorNode : contentNodes) {
if (authorNode.getType() == AuthorNode.NODE_TYPE_ELEMENT
&& "xref".equals(authorNode.getName())) {
AuthorElement authorElement = (AuthorElement) authorNode;
}
}
}

super.insertFragment(filterBypass, offset, frag);
}

Our SDK is a good starting point to create such extensions: https://www.oxygenxml.com/oxygen_sdk/download.html
You can take a look at the oxygen-sample-framework submodule, which also contains a sample filter implementation (simple.documentation.framework.filters.SDFDocumentFilter).



Best regards,
Alex