editor.createContentReader() not giving the text with the un
Posted: Fri Aug 16, 2013 7:05 am
Hey folks,
I am doing some Oxygen customizations and have run into a it of a problem.
I need to prevent the saving of the docs that do not have a valid XML, malformed or not conforming to the schema.
So in my plugin I add an WSEditorChangeListener in the applicationStarted method.
In the editorOpened method I add a WSEditorListener where I override the editorAboutToBeSavedVeto method to get the Editor content and validate it.
I use the editor.createContentReader() method to get the content.
According to the API doc the method
However, in the Author mode if I change something and hit save right away, the content I get in the listener does not have my change hence the validation succeeds.
However, the content being saved does have the change which is potentially invalid.
So the Editor's text representation in the author mode and the actual underlying text seem to be out of sync for a few moments.
Any idea how to fix or work around this problem please?
The code snippet showing the listeners' setup and the content retrieval are below.
Any help is greatly appreciated.
Thanks,
Andrey Shulinskiy
I am doing some Oxygen customizations and have run into a it of a problem.
I need to prevent the saving of the docs that do not have a valid XML, malformed or not conforming to the schema.
So in my plugin I add an WSEditorChangeListener in the applicationStarted method.
In the editorOpened method I add a WSEditorListener where I override the editorAboutToBeSavedVeto method to get the Editor content and validate it.
I use the editor.createContentReader() method to get the content.
According to the API doc the method
And it works like magic when I do the modifications in the Text mode.Create a reader over the whole editor's content (exactly the XML content which gets saved on disk). The unsaved changes are included
However, in the Author mode if I change something and hit save right away, the content I get in the listener does not have my change hence the validation succeeds.
However, the content being saved does have the change which is potentially invalid.
So the Editor's text representation in the author mode and the actual underlying text seem to be out of sync for a few moments.
Any idea how to fix or work around this problem please?
The code snippet showing the listeners' setup and the content retrieval are below.
Any help is greatly appreciated.
Thanks,
Andrey Shulinskiy
Code: Select all
public void applicationStarted(final StandalonePluginWorkspace pluginWorkspaceAccess) {
pluginWorkspaceAccess.addEditorChangeListener(
new WSEditorChangeListener() {
@Override
public void editorOpened(final URL editorLocation) {
final WSEditor editor = pluginWorkspaceAccess.getEditorAccess(editorLocation, StandalonePluginWorkspace.MAIN_EDITING_AREA);
if (editor != null) {
editor.addEditorListener(new WSEditorListener() {
@Override
public boolean editorAboutToBeSavedVeto(int operationType) {
Reader reader = null;
try {
reader = editor.createContentReader();