'Refresh' after inserting element with AuthorDocumentController
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 17
- Joined: Tue Sep 05, 2023 12:14 am
'Refresh' after inserting element with AuthorDocumentController
Hello Team,
I am trying to implement custom AuthorDnDListener.
On authorDrop(), I am creating new element and adding to the document.
After adding element, it is not displaying properly in Author page. Check screenshot-1 for reference. Here I have added xref element and image element using DnD operation. Link icon is not available for xref element and image element is not rendering with image.
But after doing 'save' and 'refresh' operation, it is displaying properly. Check screenshot-2 for reference. Link icon is available with xref and image is displaying for image element.
I am calling authorDocumentController.refreshNodeReferences() and authorEditorPage.refresh(), but it is not working.
Please check code snippet for more details.
How to properly refresh the Author page after inserting the element?
How can I achieve results as per screenshot-2 programmatically (without doing manual 'save' and 'refresh' operation) ?
Thanks,
AbhiK
I am trying to implement custom AuthorDnDListener.
On authorDrop(), I am creating new element and adding to the document.
After adding element, it is not displaying properly in Author page. Check screenshot-1 for reference. Here I have added xref element and image element using DnD operation. Link icon is not available for xref element and image element is not rendering with image.
But after doing 'save' and 'refresh' operation, it is displaying properly. Check screenshot-2 for reference. Link icon is available with xref and image is displaying for image element.
I am calling authorDocumentController.refreshNodeReferences() and authorEditorPage.refresh(), but it is not working.
Please check code snippet for more details.
Code: Select all
public boolean authorDrop(Transferable transferable, DropTargetDropEvent event) {
String path = (String) transferable.getTransferData(DataFlavor.stringFlavor);
WSEditorPage editorPage = editorAccess.getCurrentPage();
WSAuthorEditorPage authorEditorPage = (WSAuthorEditorPage) editorPage;
int position = authorEditorPage.getCaretOffset();
AuthorDocumentController authorDocumentController = authorEditorPage.getDocumentController();
AuthorElement element = authorDocumentController.createElement("xref");
authorDocumentController.insertElement(position, element);
authorDocumentController.setAttribute("href", new AttrValue(path), element);
AuthorNode rootNode = authorDocumentController.getAuthorDocumentNode();
// Refresh operation
authorDocumentController.refreshNodeReferences(rootNode);
authorDocumentController.refreshNodeReferences(element);
SwingUtilities.invokeLater(() -> {
authorEditorPage.refresh(element);
authorEditorPage.refresh();
});
return true;
}
How can I achieve results as per screenshot-2 programmatically (without doing manual 'save' and 'refresh' operation) ?
Thanks,
AbhiK
screenshot-1.png
screenshot-2.png
You do not have the required permissions to view the files attached to this post.
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: 'Refresh' after inserting element with AuthorDocumentController
Hi,
The DITA "xref" element has default attributes with default values like the DITA @class attribute. And these default attributes do not get computed if you create the element just with the name.
I suggest this replacement code instead:
Regards,
Radu
The DITA "xref" element has default attributes with default values like the DITA @class attribute. And these default attributes do not get computed if you create the element just with the name.
I suggest this replacement code instead:
Code: Select all
AuthorDocumentFragment frag = authorDocumentController.createNewDocumentFragmentInContext("<xref href=\"" + path + "\"/>", position);
authorDocumentController.insertFragment(position, frag);
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “SDK-API, Frameworks - Document Types”
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