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.

<strong>Author</strong> Developer Guide | 1816. Share the modifications with your colleagues. The files which should be shared are your customAction.jarlibrary and the .framework configuration file from theOXYGEN_INSTALL_DIR/frameworks/framework_dir directory.Java API - Extending <strong>Author</strong> Functionality through Java<strong>Oxygen</strong> <strong>XML</strong> <strong>Author</strong> has a built-in set of operations covering the insertion of text and <strong>XML</strong> fragments (see the <strong>Author</strong>Default Operations) and the execution of XPath expressions on the current document edited in <strong>Author</strong> mode. However,there are situations in which you need to extend this set. For instance if you need to enter an element whose attributesshould be edited by the user through a graphical user interface. Or the users must send the selected element content oreven the whole document to a server, for some kind of processing or the content authors must extract pieces of informationfrom a server and insert it directly into the edited <strong>XML</strong> document. Or you need to apply an XPath expression on thecurrent <strong>Author</strong> document and process the nodes of the result nodeset.The following sections contain the Java programming interface (API) available to the developers. You will need the<strong>Oxygen</strong> <strong>Author</strong> SDK available on the <strong>Oxygen</strong> <strong>XML</strong> <strong>Author</strong> <strong>plugin</strong> website which includes the source code of the <strong>Author</strong>operations in the predefined document types and the full documentation in Javadoc format of the public API availablefor the developer of <strong>Author</strong> custom actions.The next Java examples are making use of AWT classes. If you are developing extensions for the <strong>Oxygen</strong> <strong>XML</strong> <strong>Author</strong><strong>plugin</strong> <strong>XML</strong> Editor <strong>plugin</strong> for Eclipse you will have to use their SWT counterparts.It is assumed you already read the Configuring Actions, Menus, Toolbar section and you are familiar with the <strong>Oxygen</strong><strong>XML</strong> <strong>Author</strong> <strong>plugin</strong> <strong>Author</strong> customization. You can find the <strong>XML</strong> schema, CSS and <strong>XML</strong> sample in the Example FilesListings.Attention:Make sure the Java classes of your custom <strong>Author</strong> operations are compiled with the same Java version used by<strong>Oxygen</strong> <strong>XML</strong> <strong>Author</strong> <strong>plugin</strong> . Otherwise the classes may not be loaded by the Java virtual machine. For exampleif you run with a Java 1.6 virtual machine but the Java classes of your custom <strong>Author</strong> operations are compiledwith a Java 1.7 virtual machine then the custom operations cannot be loaded and used by the Java 1.6 virtualmachine.Example 1. Step by Step Example. Simple Use of a Dialog from an <strong>Author</strong> Operation.Let's start adding functionality for inserting images in the Simple Documentation Framework (shortly SDF). Theimages are represented by the image element. The location of the image file is represented by the value of the hrefattribute. In the Java implementation you will show a dialog with a text field, in which the user can enter a full URL, orhe can browse for a local file.1. Create a new Java project, in your IDE of choice. Create the lib folder in the project folder. Copy the oxygen.jarfile from the {oXygen_installation_directory}/lib folder into the newly created lib folder.oxygen.jar contains the Java interfaces you have to implement and the API needed to access the <strong>Author</strong> features.2. Create the simple.documentation.framework.InsertImageOperation class that implements thero.sync.ecss.extensions.api.<strong>Author</strong>Operation interface. This interface defines three methods:doOperation, getArguments and getDescriptionA short description of these methods follows:• The doOperation method is invoked when the action is performed either by pressing the toolbar button, byselecting the menu item or by pressing the shortcut key. The arguments taken by this methods can be one of thefollowing combinations:• an object of type ro.sync.ecss.extensions.api.<strong>Author</strong>Access and a map• argument names and values• The getArguments method is used by <strong>Oxygen</strong> <strong>XML</strong> <strong>Author</strong> <strong>plugin</strong> when the action is configured. It returnsthe list of arguments (name and type) that are accepted by the operation.• The getDescription method is used by <strong>Oxygen</strong> <strong>XML</strong> <strong>Author</strong> <strong>plugin</strong> when the operation is configured. Itreturns a description of the operation.

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

Saved successfully!

Ooh no, something went wrong!