We communicate between Webapp and our application thru GET/POST queries and servlets.
So all handlers of my actions implemented in Java.
This is exactly what we do ourselves for the builtin actions.
It seems that you try to implement your version of the builtin Save action. Right?
I can share how we solved these problems with the builtin version of the Save action.
1) I open new document.
2) Make new changes. In Java I need know that document isDirty for change actions status (action Save - Enable)
In the JS code we listen for the "DIRTY_STATUS_CHANGED" event. When the document is not dirty, the JS Save action "isEnabled" method returns false. Moreover, we refresh the toolbar rendering of the Save action using ActionsManager#refreshActions.
3) I click Save. IF save was succesfull I need change Save to Disasble.
The Save action is a AJAX call. Its response message contains the success state of the Save action. Based on that we set/reset the dirty flag.
4) Then I close Tab with editor in our appication and I need know that is editor has changes to offer to user save them
You should listen for the "DIRTY_STATUS_CHANGED" event and add a "unload" listener in JS to prevent the user from leaving the page.
1) isDirty editor. We use it very often but you don't have normal API for that.
I guess the above explanations address this question. Please let me know if the suggestions above are not applicable in your case.
2) action.setEnable(true) Important for upper case. And I need make normal ReadOnly mode with disabled actions
I understand that you have an action that turns a selection in "uppercase" letters and you want to disable it once the letters are made uppercase. Does it insert an XML element, or it just changes the text? Is it an action defined in the framework, or it is added by the plugin?
You can use the AbstractAction#isEnabled and ActionsManager#refreshActionsStatus to enable/disable the action. We currently miss JS API to retrieve the selected text, but that can be added in the upcoming release.
3) Insert and refresh content which came from out application inside editor. As I wrote here topic13372.html#p39242
I understand that the user changes the content of the XML file outside the oXygen editor and you want to force the editor to reload the content. Right?
Assuming this is the case, you need:
1. make the JS code aware that the document content was changed
- One option is that you know in the JS code that embeds the iframe that the content was refreshed. In this case you can use window.postMessage.
- Another option is to have the JS code check whether the document was changed from time to time and on every window focus.
- Another option is to use websockets to provide real-time updates to the JS code. Beware that replacing the editor content while the user is editing may not be desirable.
2. reload the content
- You can invoke an AuthorOperation to reload the content of the document. We have Java API that we use for example when switching back from the text-mode editor: ro.sync.ecss.common.WebappAccess.setTextModeState(AuthorDocumentModel, WebappTextModeState).
Please let me know if I made false assumptions about your situation.