API method to check for warnings and undo
Oxygen general issues.
-
- Posts: 2
- Joined: Mon Jun 06, 2011 6:46 pm
API method to check for warnings and undo
Hello,
I'm trying to do two things...
1) Check for warnings. (They'll only be for track change issues, and unfortunately Oxygen doesn't always throw a warning when track changes are messed up. An example is when the XML is missing a start or end tag for change tracking, such as when an oxy_insert_start and _end set are nested inside another insert--which should never happen but it does occasionally. While I'm at it, how come some of these warnings and track-change highlighting mishaps when the tags go missing only show once the document is closed and reopened?)
I don't need specific warning/error checking--I just want to be able to check in my doOperation override after some action has been performed, whether or not that action unexpectedly caused an error or warning to pop up (no exception is thrown--must be a validation related warning/error, but where is it defined what throws an error since the <?oxy_....?> tags aren't in the DTD?). Is this implemented anywhere in the API, or is there a workaround that would allow me to detect whether or not a warning or error exists?
2) (If #1 is possible) Undo the operation if there is indeed an error or warning. Is it easier to simulate the CTRL+Z keypress, or shall I go through the AuthorActionsProvider?
With that class, I did a .getAuthorCommonActions().toString() and noted that the following key/value existed in the Map. The toString method yielded:
Edit/Edit_Undo=ro.sync.ecss.component.i.e.e.f@f5b1fb
But I'm unsure what to send to .invokeAction() This undo functionality should remain static, no? It seems like I shouldn't have to get the Map of common actions each time, search it for undo, then send that element to invoke it.
Thank you!
I'm trying to do two things...
1) Check for warnings. (They'll only be for track change issues, and unfortunately Oxygen doesn't always throw a warning when track changes are messed up. An example is when the XML is missing a start or end tag for change tracking, such as when an oxy_insert_start and _end set are nested inside another insert--which should never happen but it does occasionally. While I'm at it, how come some of these warnings and track-change highlighting mishaps when the tags go missing only show once the document is closed and reopened?)
I don't need specific warning/error checking--I just want to be able to check in my doOperation override after some action has been performed, whether or not that action unexpectedly caused an error or warning to pop up (no exception is thrown--must be a validation related warning/error, but where is it defined what throws an error since the <?oxy_....?> tags aren't in the DTD?). Is this implemented anywhere in the API, or is there a workaround that would allow me to detect whether or not a warning or error exists?
2) (If #1 is possible) Undo the operation if there is indeed an error or warning. Is it easier to simulate the CTRL+Z keypress, or shall I go through the AuthorActionsProvider?
With that class, I did a .getAuthorCommonActions().toString() and noted that the following key/value existed in the Map. The toString method yielded:
Edit/Edit_Undo=ro.sync.ecss.component.i.e.e.f@f5b1fb
But I'm unsure what to send to .invokeAction() This undo functionality should remain static, no? It seems like I shouldn't have to get the Map of common actions each time, search it for undo, then send that element to invoke it.
Thank you!
-
- Posts: 9446
- Joined: Fri Jul 09, 2004 5:18 pm
Re: API method to check for warnings and undo
Hi,
When an XML document is opened in the Author page the change tracking information is no longer present as processing instructions in the document but is converted to a set of highlights. When the document is saved the highlights are again converted to processing instructions. If there is a bug in the serializer, this is the only way in which the processing instructions can be wrongly saved. So after re-opening the XML file, the Author page senses that change tracking PIs are not properly matched and ignores some of them (we should indeed give some warnings in this case, I added an improvement request).
From what I understand you are directly working with the Author API (in an custom operation). No edit that you are performing on the XML document using the API should break the change tracking.
We had small problems with the change tracking handling in the past and we fixed them and we had no more problems reported since Oxygen 12.2. What Oxygen version are you using? Can you upgrade to 12.2?
If such problems can be reproduced with the latest Oxygen I would be really interested if you have a set of operations performed with the API which break the change tracking.
The change tracking highlights can be accessed through the API like:
and thus you can check if you are editing in a change tracking highlight.
To undo an edit you can either:
or if you started a compound edit (recommanded approach):
or indeed you can invoke the Undo action like:
Regards,
Radu
When an XML document is opened in the Author page the change tracking information is no longer present as processing instructions in the document but is converted to a set of highlights. When the document is saved the highlights are again converted to processing instructions. If there is a bug in the serializer, this is the only way in which the processing instructions can be wrongly saved. So after re-opening the XML file, the Author page senses that change tracking PIs are not properly matched and ignores some of them (we should indeed give some warnings in this case, I added an improvement request).
From what I understand you are directly working with the Author API (in an custom operation). No edit that you are performing on the XML document using the API should break the change tracking.
We had small problems with the change tracking handling in the past and we fixed them and we had no more problems reported since Oxygen 12.2. What Oxygen version are you using? Can you upgrade to 12.2?
If such problems can be reproduced with the latest Oxygen I would be really interested if you have a set of operations performed with the API which break the change tracking.
The change tracking highlights can be accessed through the API like:
Code: Select all
authorAccess.getReviewController().getChangeHighlights();
To undo an edit you can either:
Code: Select all
//Undo a change.
authorAccess.getDocumentController().getUndoManager().undo();
Code: Select all
try {
authorAccess.getDocumentController().beginCompoundEdit();
///ALL EDITS ARE DONE HERE
//Cancel a compound operation, undo all edits which have been done since the beginCompoundEdit was called
authorAccess.getDocumentController().cancelCompoundEdit();
} finally{
authorAccess.getDocumentController().endCompoundEdit();
}
Code: Select all
//Actually this is a javax.swing.Action implementation but is obfuscated
Object undoAction = authorAccess.getEditorAccess().getActionsProvider().getAuthorCommonActions().get("Edit/Edit_Undo");
authorAccess.getEditorAccess().getActionsProvider().invokeAction(undoAction);
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 2
- Joined: Mon Jun 06, 2011 6:46 pm
Re: API method to check for warnings and undo
Thanks for the info!
I updated to version 12.2, but all of the different problems we're having with our API code related to modifying the document and change tracking is still triggering track-change warnings and problems without warnings (e.g. removing track changes from the rest of the document without throwing any warnings). If I narrow down the code to something simple and still reproducible I'll post it to see if anything obvious to you is causing the problems (as it stands it's at least a few hundred lines). 12.2 did somewhat fix a problem we were having with comments and tabbing, since it now uses the <?oxy tags for comments, but removed the ability to add comments wherever we needed them (now they're only allowed where text would be allowed).
I updated to version 12.2, but all of the different problems we're having with our API code related to modifying the document and change tracking is still triggering track-change warnings and problems without warnings (e.g. removing track changes from the rest of the document without throwing any warnings). If I narrow down the code to something simple and still reproducible I'll post it to see if anything obvious to you is causing the problems (as it stands it's at least a few hundred lines). 12.2 did somewhat fix a problem we were having with comments and tabbing, since it now uses the <?oxy tags for comments, but removed the ability to add comments wherever we needed them (now they're only allowed where text would be allowed).
-
- Posts: 9446
- Joined: Fri Jul 09, 2004 5:18 pm
Re: API method to check for warnings and undo
Hi,
Yes, it would be great if you could give us some sample code using the API which breaks the change tracking.
Regards,
Radu
Yes, it would be great if you could give us some sample code using the API which breaks the change tracking.
The comment actions have been around since Oxygen 12.0. They always used <?oxy_comment_start... and <?oxy_comment_end?> processing instructions to mark the commented content when the XML is serialized.12.2 did somewhat fix a problem we were having with comments and tabbing, since it now uses the <?oxy tags for comments
Can you tell me more about this situation? Maybe some steps to show how you work with the Author. Comments can be virtually added anywhere.but removed the ability to add comments wherever we needed them (now they're only allowed where text would be allowed).
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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