RefreshReference without making doc dirty
Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
-
- Posts: 280
- Joined: Thu Nov 28, 2013 9:32 am
- Location: Hamburg/Germany
- Contact:
RefreshReference without making doc dirty
Hi,
I'm using an AuthorReferenceResolver to display some status information to the author.
And I have an AuthorOperationWithResult that changes this information so I'm calling AuthorDocumentController.refreshNodeReferences().
This works fine, except that this will cause to document to be marked as modified.
So I tried this:
But it doesn't work and I get a warning in the log:
I might as well trigger the refresh from javascript but could not find a way to do it from there.
Any ideas?
Thanks and regards,
Patrik
I'm using an AuthorReferenceResolver to display some status information to the author.
And I have an AuthorOperationWithResult that changes this information so I'm calling AuthorDocumentController.refreshNodeReferences().
This works fine, except that this will cause to document to be marked as modified.
So I tried this:
Code: Select all
final boolean isModified = authorAccess.getEditorAccess().isModified();
authorAccess.getDocumentController().refreshNodeReferences(statusNode);
if (!isModified) {
authorAccess.getEditorAccess().setModified(false);
}
Code: Select all
ro.sync.ecss.webapp.access.j - Calling isModified() is not supported while a "compound edit" is in progress. Note that a "compound edit" is created automatically when invoking an AuthorOperation that does not extend AuthorOperationWithCustomUndoBehavior
Any ideas?
Thanks and regards,
Patrik
-
- Posts: 81
- Joined: Wed Jul 20, 2016 8:22 am
Re: RefreshReference without making doc dirty
Post by mihai_coanda »
Hello Patrik,
As mentioned in the warning you received if an AuthorOperation is invoked it will automatically mark the document as dirty by creating a "compound edit".
If you want to prevent this behavior, your operation should implement the AuthorOperationWithCustomUndoBehavior marker interface.
Regards,
Michael
As mentioned in the warning you received if an AuthorOperation is invoked it will automatically mark the document as dirty by creating a "compound edit".
If you want to prevent this behavior, your operation should implement the AuthorOperationWithCustomUndoBehavior marker interface.
Regards,
Michael
Michael
https://www.oxygenxml.com
https://www.oxygenxml.com
-
- Posts: 280
- Joined: Thu Nov 28, 2013 9:32 am
- Location: Hamburg/Germany
- Contact:
Re: RefreshReference without making doc dirty
I already tried that and failed bacause I thought i would nee to implement AuthorOperationWithCustomUndoBehavior instead of AuthorOperationWithResult.
But now I realized I just had to add this interface and it works fine.
Thanks a lot - once again! :)
Patrik
But now I realized I just had to add this interface and it works fine.
Thanks a lot - once again! :)
Patrik
-
- Posts: 280
- Joined: Thu Nov 28, 2013 9:32 am
- Location: Hamburg/Germany
- Contact:
Re: RefreshReference without making doc dirty
Hi again.
I just noticed that the log entry
also occurs when doing a git-commit without modifications.
Took me some time to realize this was not my fault (at least I'm pretty sure)... ;)
You might want to take a look on it.
Regards,
Patrik
I just noticed that the log entry
Code: Select all
1212098 WARN [ http-nio-8080-exec-8 ] ro.sync.ecss.webapp.access.j - Calling setModified() is not supported while a "compound edit" is in progress. Note that a "compound edit" is created automatically when invoking an AuthorOperation that does not extend AuthorOperationWithCustomUndoBehavior
Took me some time to realize this was not my fault (at least I'm pretty sure)... ;)
You might want to take a look on it.
Regards,
Patrik
-
- Posts: 280
- Joined: Thu Nov 28, 2013 9:32 am
- Location: Hamburg/Germany
- Contact:
Re: RefreshReference without making doc dirty
I still have a problem with the refreshreference:
I added the call of an AuthorOperation after the git-commit to rfresh the reference. But the setModified(false) doesn't work there - and I get no warning in the log.
Here is my minimized code for this issue:
I was also looking into the documentation for setModified and found this:
And in all other cases it was working fine!?
Still the most important question for me remains: How can I refresh the references after a commit without making the document dirty.
Thanks and regards,
Patrik
I added the call of an AuthorOperation after the git-commit to rfresh the reference. But the setModified(false) doesn't work there - and I get no warning in the log.
Here is my minimized code for this issue:
Code: Select all
@WebappCompatible
@WebappRestSafe
public class CommitRefreshTest extends AuthorOperationWithResult implements AuthorOperationWithCustomUndoBehavior {
public String doOperation(AuthorDocumentModel model, ArgumentsMap args) throws AuthorOperationException {
try {
final AuthorAccess authorAccess = model.getAuthorAccess();
final AuthorNode node = authorAccess.getDocumentController().getNodeAtOffset(0);
System.out.println("CommitRefreshTest: " + node.getDisplayName());
authorAccess.getDocumentController().refreshNodeReferences(node);
authorAccess.getEditorAccess().setModified(false);
} catch (BadLocationException e) {
final AuthorOperationException ex = new AuthorOperationException(e.getMessage(), e);
ex.setOperationRejectedOnPurpose(true);
}
return null;
}
}
Code: Select all
goog.events.listenOnce(workspace, sync.api.Workspace.EventType.EDITOR_LOADED, function(e) {
var editor = e.editor;
goog.events.listenOnce(e.editor, sync.api.Editor.EventTypes.ACTIONS_LOADED, function(e) {
var commitAction = editor.getActionsManager().getActionById('Git/Commit');
var oldActionPerformed = commitAction.actionPerformed;
commitAction.actionPerformed = function(callback) {
oldActionPerformed.call(commitAction, function(callback) {
if (!editor.isDirty()) {
console.log('Git/Commit - Done and doc not dirty so it was successful.');
editor.getActionsManager().invokeOperation(
'com.gdvdl.TgicServiceCatalog.operations.CommitRefreshTest',
{}, // no parameters
null, // no callback
null,
true // This is a background operation - it does not update the document
);
} else {
console.log('Git/Commit - Done but doc is still dirty so it was not successful.');
}
})
};
});
});
This also confuses me. How should I use this method to mark a document as clean other than by invoking it with false?For Web Author, can be used to mark the document as clean and to make sure that the clean state is properly identified after a series of undo/redo operations. This method has some limitations:
.
- It does not automatically update the client-side editor dirty status.
- [...]
- it does nothing if invoked with false
And in all other cases it was working fine!?
Still the most important question for me remains: How can I refresh the references after a commit without making the document dirty.
Thanks and regards,
Patrik
-
- Site Admin
- Posts: 95
- Joined: Thu Jun 09, 2016 2:01 pm
Re: RefreshReference without making doc dirty
Post by Gabriel Titerlea »
You can call after you invoke the CommitRefreshTest operation. See this forum post [1].
Best,
Gabriel
[1] topic13562.html#p40382
Code: Select all
this.editor.setDirty(false);
Best,
Gabriel
[1] topic13562.html#p40382
-
- Posts: 280
- Joined: Thu Nov 28, 2013 9:32 am
- Location: Hamburg/Germany
- Contact:
Re: RefreshReference without making doc dirty
Great, that works for me as well! :)
Thanks!
Patrik
Thanks!
Patrik
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service