Listen for changes on specific element / node
Oxygen general issues.
-
- Posts: 29
- Joined: Thu Jun 21, 2012 6:47 pm
- Location: Victoria BC, Canada
Listen for changes on specific element / node
I have a situation where if a user deletes a node from the document, I want to capture the event and ensure that the entire containing fragment is deleted. For example, the following:
If the user deletes the <text> (element)node I would like to check if the parent is a <heading> and if so delete the entire <heading><text>...</text></heading>. My initial approach was to create an extension bundle and register it with my framework, override createAuthorExtensionStateListener() and my implementation of AuthorExtensionStateListener sets a document filter on the controller.
MyAuthorDocumentFilter overrides deleteNode and delete functions from superclass but these methods do not appear to be called when a user deletes anything from the document. Do filter methods only get called through the api or does internal Oxygen code call them as well?
I have also tried registering my own implementation of AuthorListener which does respond to deleted nodes, text etc but assumed that a filter might be a better approach.
Am I on the right track or is there an easier way to capture and react to changes to specific nodes? Thanks.
Code: Select all
<heading>
<text>My Heading</text>
</heading>
Code: Select all
@Override
public void activated(AuthorAccess aa) {
aa.getDocumentController().setDocumentFilter(new MyAuthorDocumentFilter());
}
I have also tried registering my own implementation of AuthorListener which does respond to deleted nodes, text etc but assumed that a filter might be a better approach.
Am I on the right track or is there an easier way to capture and react to changes to specific nodes? Thanks.
-
- Posts: 9446
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Listen for changes on specific element / node
Hi,
The ro.sync.ecss.extensions.api.AuthorDocumentFilter.deleteNode(AuthorDocumentFilterBypass, AuthorNode) is usually called from actions specialized in moving or deleting entire nodes, for example if you delete a node from the Outline view, this action gets called.
If the user presses DEL or BACKSPACE in the editor then usually this callback gets called:
Then you would need to use the "ro.sync.ecss.extensions.api.AuthorDocumentController" API to see what exact XML code will be deleted. The user can press DEL or BACKSP either when he has a selection or when there is no selection so the start and end offsets may differ because of this.
Another workaround for you as you have already overwritten the "ExtensionsBundle" base would be to overwrite this method:
The Author SDK should contain the Java sources for ro.sync.ecss.extensions.docbook.DocbookSchemaAwareEditingHandler. And you could try to overwrite this method:
which deals explicitly with various deletions in the Author mode without any prior selection.
Regards,
Radu
The ro.sync.ecss.extensions.api.AuthorDocumentFilter.deleteNode(AuthorDocumentFilterBypass, AuthorNode) is usually called from actions specialized in moving or deleting entire nodes, for example if you delete a node from the Outline view, this action gets called.
If the user presses DEL or BACKSPACE in the editor then usually this callback gets called:
Code: Select all
ro.sync.ecss.extensions.api.AuthorDocumentFilter.delete(AuthorDocumentFilterBypass, int, int, boolean)
Another workaround for you as you have already overwritten the "ExtensionsBundle" base would be to overwrite this method:
Code: Select all
ro.sync.ecss.extensions.api.ExtensionsBundle.getAuthorSchemaAwareEditingHandler()
Code: Select all
ro.sync.ecss.extensions.api.AuthorSchemaAwareEditingHandlerAdapter#handleDelete(int, int, ro.sync.ecss.extensions.api.AuthorAccess, boolean)
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 29
- Joined: Thu Jun 21, 2012 6:47 pm
- Location: Victoria BC, Canada
Re: Listen for changes on specific element / node
Thanks Radu, I will try the filter approach you mentioned. I have obtained the sdk and it appears classes in the ro.sync.ecss.extensions.docbook package are obfuscated.
Thanks,
Chris
Thanks,
Chris
-
- Posts: 29
- Joined: Thu Jun 21, 2012 6:47 pm
- Location: Victoria BC, Canada
Re: Listen for changes on specific element / node
Update: I was able to implement AuthorSchemaAwareHandlingAdapter. I just had to go over the documentation a bit more carefully. Thanks.
-
- Posts: 9446
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Listen for changes on specific element / node
Hi Chris,
All the Java sources for the Java extensions implemented for the predefined document types (Docbook, DITA, TEI, XHTML) should be found in the folder oxygenAuthorSDK\samples\Oxygen Default Frameworks.
If you have any suggestions how we could improve the SDK or documentation in order to give developers a better start, please tell us.
Regards,
Radu
All the Java sources for the Java extensions implemented for the predefined document types (Docbook, DITA, TEI, XHTML) should be found in the folder oxygenAuthorSDK\samples\Oxygen Default Frameworks.
If you have any suggestions how we could improve the SDK or documentation in order to give developers a better start, please tell us.
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