24.08.2015 Views

Oxygen XML Author plugin 13.2.0

Oxygen XML Author plugin 13.2.0

Oxygen XML Author plugin 13.2.0

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Table 1: Interfaces for the DnD listener<strong>Author</strong> Developer Guide | 217InterfaceDescriptionro.sync.exml.editor.xmleditor.pageauthor.<strong>Author</strong>CustomDnDHandler Receives callbacks from the <strong>Oxygen</strong> <strong>XML</strong> <strong>Author</strong> <strong>plugin</strong>standalone application for Drag And Drop in <strong>Author</strong> mode.com.oxygenxml.editor.editors.author.<strong>Author</strong>DnDListener Receives callbacks from the <strong>Oxygen</strong> <strong>XML</strong> <strong>Author</strong> <strong>plugin</strong>Eclipse <strong>plugin</strong> for Drag And Drop in <strong>Author</strong> mode.com.oxygenxml.editor.editors.TextDnDListenerReceives callbacks from the <strong>Oxygen</strong> <strong>XML</strong> <strong>Author</strong> <strong>plugin</strong>Eclipse <strong>plugin</strong> for Drag And Drop in Text mode.Configuring a References ResolverYou need to provide a handler for resolving references and obtain the content they refer. In our case the element whichhas references is ref and the attribute indicating the referred resource is location. You will have to implement a Javaextension class for obtaining the referred resources.Note: The Javadoc documentation of the <strong>Author</strong> API used in the example files is available on the <strong>Oxygen</strong> <strong>XML</strong>website. Also it can be downloaded as a zip archive from the website.1. Create the class simple.documentation.framework.ReferencesResolver. This class must implementthe ro.sync.ecss.extensions.api.<strong>Author</strong>ReferenceResolver interface.import ro.sync.ecss.extensions.api.<strong>Author</strong>ReferenceResolver;import ro.sync.ecss.extensions.api.<strong>Author</strong>Access;import ro.sync.ecss.extensions.api.node.AttrValue;import ro.sync.ecss.extensions.api.node.<strong>Author</strong>Element;import ro.sync.ecss.extensions.api.node.<strong>Author</strong>Node;public class ReferencesResolverimplements <strong>Author</strong>ReferenceResolver {2. The hasReferences method verifies if the handler considers the node to have references. It takes as argumentan <strong>Author</strong>Node that represents the node which will be verified. The method will return true if the node isconsidered to have references. In our case, to be a reference the node must be an element with the name ref and itmust have an attribute named location.public boolean hasReferences(<strong>Author</strong>Node node) {boolean hasReferences = false;if (node.getType() == <strong>Author</strong>Node.NODE_TYPE_ELEMENT) {<strong>Author</strong>Element element = (<strong>Author</strong>Element) node;if ("ref".equals(element.getLocalName())) {AttrValue attrValue = element.getAttribute("location");hasReferences = attrValue != null;}}return hasReferences;}3. The method getDisplayName returns the display name of the node that contains the expanded referred content.It takes as argument an <strong>Author</strong>Node that represents the node for which the display name is needed. The referredcontent engine will ask this <strong>Author</strong>ReferenceResolver implementation what is the display name for eachnode which is considered a reference. In our case the display name is the value of the location attribute from the refelement.public String getDisplayName(<strong>Author</strong>Node node) {String displayName = "ref-fragment";

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!