You can use the Workspace Access plugin extension (and provided sample Java code) for all these operations.
/** * Sample implementation for the "Check Out" method. * * @param pluginWorkspaceAccess The plugin workspace access (Workspace Access plugin). * @throws MalformedURLException */ private void checkOut(StandalonePluginWorkspace pluginWorkspaceAccess) throws MalformedURLException { //TODO Show the user a custom dialog for browsing the CMS //TODO after the user selected the resource create an URL with a custom protocol // which will uniquely map to the resource on the CMS using the URLHandler //something like: URL customURL = new URL("mycms://host/path/to/file.xml"); //Ask Oxygen to open the URL pluginWorkspaceAccess.open(customURL); //Oxygen will then your custom protocol handler to provide the contents for the resource "mycms://host/path/to/file.xml" //Your custom protocol handler will check out the file in a temporary directory for example and provide the content from it. //Oxygen will also pass through your URLHandler if you have any relative references which need to be opened/obtained. }Here is a diagram of the Check Out process:
//Add an additional browse action to all dialogs/places where Oxygen allows selecting an URL.
pluginWorkspaceAccess.addInputURLChooserCustomizer(new InputURLChooserCustomizer() {
public void customizeBrowseActions(List<Action> existingBrowseActions, final InputURLChooser chooser) {
//IMPORTANT, you also need to set a custom icon on the action for situations when its text is not used for display.
Action browseCMS = new AbstractAction("CMS") {
public void actionPerformed(ActionEvent e) {
URL chosenResource = browseCMSAndChooseResource();
if (chosenResource != null) {
try {
//Set the chosen resource in the dialog's combo box chooser.
chooser.urlChosen(chosenResource);
} catch (MalformedURLException e1) {
//
}
}
}
};
existingBrowseActions.add(browseCMS);
}
});
//Add a custom relative reference resolver for your custom protocol.
//Usually when inserting references from one URL to another Oxygen makes the inserted path relative.
//If your custom protocol needs special relativization techniques then it should set up a custom relative
//references resolver to be notified when resolving needs to be done.
pluginWorkspaceAccess.addRelativeReferencesResolver(
//Your custom URL protocol for which you already have a custom URLStreamHandlerPluginExtension set up.
"mycms",
//The relative references resolver
new RelativeReferenceResolver() {
public String makeRelative(URL baseURL, URL childURL) {
//Return the referenced path as absolute for example.
//return childURL.toString();
//Or return null for the default behavior.
return null;
}
});
Write the plugin.xml descriptor. Your plugin combines the two extensions using a single set of libraries. The descriptor would look like:
<!DOCTYPE plugin SYSTEM "../plugin.dtd"> <plugin name="CustomCMSAccess" description="Test" version="1.0.0" vendor="ACME" class="custom.cms.CMSAccessPlugin"> <runtime> <library name="lib/cmsaccess.jar"/> </runtime> <!--Access to add actions to the main menu and toolbars or to add custom views.--> <!--See the "ro.sync.sample.plugin.workspace.CustomWorkspaceAccessPluginExtension" Java sample for more details--> <extension type="WorkspaceAccess" class="custom.cms.CustomWorkspaceAccessPluginExtension"/> <!--The custom URL handler which will communicate with the CMS implementation--> <!--See the "ro.sync.sample.plugin.workspace.customprotocol.CustomProtocolURLHandlerExtension" Java sample for more details--> <extension type="URLHandler" class="custom.cms.CustomProtocolURLHandlerExtension"/> </plugin>
Create a cmsaccess.jar JAR archive containing your implementation classes.
Copy your new plugin directory in the plugins subfolder of the Oxygen XML Editor install folder and start Oxygen XML Editor.