Download XML Editor 11.2 User Manual

Transcript
Author Developer Guide
/**
* Performs the operation.
*/
public void doOperation(
AuthorAccess authorAccess,
ArgumentsMap arguments)
throws IllegalArgumentException,
AuthorOperationException {
JFrame oxygenFrame = (JFrame) authorAccess.getParentFrame();
String href = displayURLDialog(oxygenFrame);
if (href.length() != 0) {
// Creates the image XML fragment.
String imageFragment =
"<image xmlns='http://www.oxygenxml.com/sample/documentation' href='"
+ href + "'/>";
// Inserts this fragment at the caret position.
int caretPosition = authorAccess.getCaretOffset();
authorAccess.insertXMLFragment(imageFragment, caretPosition);
}
}
/**
* Has no arguments.
*
* @return null.
*/
public ArgumentDescriptor[] getArguments() {
return null;
}
/**
* @return A description of the operation.
*/
public String getDescription() {
return "Inserts an image element. Asks the user for a URL reference.";
}
The complete source code of this operation is found in the Example Files Listings, the Java Files section.
Important
Make sure you always specify the namespace of the inserted fragments.
3.
Package the compiled class into a jar file. An example of an ANT script that packages the classes directory
content into a jar archive named sdf.jar is listed below:
<?xml version="1.0" encoding="UTF-8"?>
<project name="project" default="dist">
<target name="dist">
308