1

I want to paste AuthorDocumentFragment (Oxygen) into TextArea (Java swing) of my modal dialog. But the element AuthorDocumentFragment is not supported for textarea. What do I do with this?

My code:

public void doOperation(final AuthorAccess authorAccess, final ArgumentsMap args)
        throws IllegalArgumentException, AuthorOperationException {
   AuthorNode[] nodeList2 = authorAccess.getDocumentController().findNodesByXPath("//*[@id]/child::node()", true, true, true);

    ArrayList<AuthorDocumentFragment> arrayList = new ArrayList<AuthorDocumentFragment>();

    for (AuthorNode i : nodeList2) {
        AuthorDocumentFragment newFragText = null;
        try {
            newFragText = authorAccess.getDocumentController().createDocumentFragment(i, true);
        } catch (BadLocationException e) {
            e.printStackTrace();
        }
        arrayList.add(newFragText);
    }
}

void jList1MouseClicked(java.awt.event.MouseEvent evt) {
    textAreaRefs.setText(???);
}
  • Umm.. [`AuthorDocumentFragment.toString()`](https://www.oxygenxml.com/InstData/Editor/SDK/javadoc/ro/sync/ecss/extensions/api/node/AuthorDocumentFragment.html#toString--)? – Andrew Thompson Apr 17 '20 at 14:39
  • I want to save my format. toString() will change my format and my fragment will be as string – Дарья Алабина Apr 17 '20 at 14:47
  • Well `String` is the only thing a `JTextArea` is designed to handle. So perhaps change the component to one that *can* adequately represent XML format data (e.g. a `JTree` as part of the solution). – Andrew Thompson Apr 17 '20 at 14:54
  • I want to have like this https://docplayer.net/docs-images/87/96728262/images/147-0.jpg but xml format should be not as xml. I want to do this in preview – Дарья Алабина Apr 17 '20 at 15:24

1 Answers1

0

The AuthorDocumentController API has a method to serialize an AuthorDocumentFragment to XML:

https://www.oxygenxml.com/InstData/Editor/SDK/javadoc/ro/sync/ecss/extensions/api/AuthorDocumentController.html#serializeFragmentToXML-ro.sync.ecss.extensions.api.node.AuthorDocumentFragment-

Radu Coravu
  • 1,754
  • 1
  • 9
  • 8