Elments tab with java api
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 2
- Joined: Thu Feb 13, 2014 11:32 pm
Elments tab with java api
Hi,
I use WhatAttributesCanGoHereContext class to obtain a list of possible insert after the node elements, but the list is not identical with the items displayed in the tab element (after).
how I can have just the list of elements to be inserted after the node (as in the Elements tab) ?
here is my code :
Best regards,
Hmida.
I use WhatAttributesCanGoHereContext class to obtain a list of possible insert after the node elements, but the list is not identical with the items displayed in the tab element (after).
how I can have just the list of elements to be inserted after the node (as in the Elements tab) ?
here is my code :
Code: Select all
WhatElementsCanGoHereContext whatElementsCanGoHereContext = authorSchemaManager
.createWhatElementsCanGoHereContext(authorPageAccess.getCaretOffset());
if (whatElementsCanGoHereContext != null) {
List<CIElement> whatElementsCanGoHere = authorSchemaManager
.whatElementsCanGoHere(whatElementsCanGoHereContext);
if (whatElementsCanGoHere != null) {
for (CIElement ciElement : whatElementsCanGoHere) {
if("PAR_ET".equals(ciElement))
boolean find = true;
}
Hmida.
-
- Posts: 9449
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Elments tab with java api
Hi Hmida,
If you want to know the list of elements which can be inserted after the current element you need to create the context based on a caret offset which is after the element, something like:
Regards,
Radu
If you want to know the list of elements which can be inserted after the current element you need to create the context based on a caret offset which is after the element, something like:
Code: Select all
AuthorNode nodeAtOffset = authorAccess.getDocumentController().getNodeAtOffset(authorPage.getCaretOffset());
int offsetAfter = nodeAtOffset.getEndOffset() + 1;
WhatElementsCanGoHereContext contextAfter = authorSchemaManager.createWhatElementsCanGoHereContext(offsetAfter);
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 2
- Joined: Thu Feb 13, 2014 11:32 pm
Re: Elments tab with java api
Hi Radu,
This code work fine :
my xml doc :
How can I initialize the context dynamically :
When the user select the node '<b>', I want to know if it can insert an element at the end of the section (between <d> and </ Tag0>).
Regards,
Hmida.
This code work fine :
Code: Select all
if(position != null && position.equals("BEFOR")){
whatElementsCanGoHere = authorSchemaManager
.createWhatElementsCanGoHereContext(authorAccess
.getEditorAccess().getSelectionStart());
}else if(position != null && position.equals("AFTER")){
whatElementsCanGoHere = authorSchemaManager
.createWhatElementsCanGoHereContext(authorAccess
.getEditorAccess().getSelectionEnd());
}
if (whatElementsCanGoHere != null) {
List<CIElement> elements = authorSchemaManager.whatElementsCanGoHere(whatElementsCanGoHere);
if (elements != null) {
for (CIElement ciElement : elements) {
if(elementName != null && elementName.equals(ciElement.toString())){
canGoHere = true;
}
}}}
Code: Select all
<Tag0>
<a>
<b> (user select this node)
<c>
<d>
</Tag0>
When the user select the node '<b>', I want to know if it can insert an element at the end of the section (between <d> and </ Tag0>).
Regards,
Hmida.
-
- Posts: 9449
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Elments tab with java api
Hi Hmida,
You also have the API:
ro.sync.exml.workspace.api.editor.page.author.WSAuthorEditorPageBase.getFullySelectedNode()
to give you the node which is currently fully selected by the user.
Each node has getParent(), getStartOffset() and getEndOffset() methods.
Each parent node has a ro.sync.ecss.extensions.api.node.AuthorParentNode.getContentNodes() method which can be used to iterate child nodes.
The general AuthorNode architecture which is exposed via the API looks like this:
http://www.oxygenxml.com/InstData/Edito ... ecture.gif
You have a hierarchy of nodes which point to a common sequence containing all the text nodes from the XML document.
Regards,
Radu
I'm sorry but I do not understand.How can I initialize the context dynamically :
When the user select the node '<b>', I want to know if it can insert an element at the end of the section (between <d> and </ Tag0>).
You also have the API:
ro.sync.exml.workspace.api.editor.page.author.WSAuthorEditorPageBase.getFullySelectedNode()
to give you the node which is currently fully selected by the user.
Each node has getParent(), getStartOffset() and getEndOffset() methods.
Each parent node has a ro.sync.ecss.extensions.api.node.AuthorParentNode.getContentNodes() method which can be used to iterate child nodes.
The general AuthorNode architecture which is exposed via the API looks like this:
http://www.oxygenxml.com/InstData/Edito ... ecture.gif
You have a hierarchy of nodes which point to a common sequence containing all the text nodes from the XML document.
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