'Refresh' after inserting element with AuthorDocumentController
Posted: Tue Sep 05, 2023 1:16 am
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