oXygen 9.1 - writing a document plugin, how do I access it?
Oxygen general issues.
-
- Posts: 5
- Joined: Sun Jan 20, 2008 2:10 am
oXygen 9.1 - writing a document plugin, how do I access it?
So, I've written a DocumentPluginExtension for what used to be a command-line Java program (XML in, XML out).
Oxygen shows that it is initialized in Preferences -> Plugins. However, I have no idea how to invoke my plugin via the user interface. The documentation seems to indicate that it should be available when modifying the contextual menu, but it does not show up there. The documentation is a little sparse in this area. Can someone point me in the right direction?
Oxygen shows that it is initialized in Preferences -> Plugins. However, I have no idea how to invoke my plugin via the user interface. The documentation seems to indicate that it should be available when modifying the contextual menu, but it does not show up there. The documentation is a little sparse in this area. Can someone point me in the right direction?
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: oXygen 9.1 - writing a document plugin, how do I access it?
Post by sorin_ristache »
Hello,
Just follow the example of the action ReplaceTextAction (com.oxygenxml.editor.sample.extension.action.ReplaceTextAction) which is defined as an extension of the oXygen plugin in the plugin.xml file descriptor of the example Eclipse plugin included in the oXygen extensions development kit which you can find on the Community page:
The replace text action shows up on the contextual menu of the editor panel of an editor contributed by the oXygen plugin (the Oxygen XML Editor for example). You can find the complete source code of the action ReplaceTextAction in the development kit.
Regards,
Sorin
Just follow the example of the action ReplaceTextAction (com.oxygenxml.editor.sample.extension.action.ReplaceTextAction) which is defined as an extension of the oXygen plugin in the plugin.xml file descriptor of the example Eclipse plugin included in the oXygen extensions development kit which you can find on the Community page:
Code: Select all
<extension point="com.oxygenxml.editor.contextMenuAdditions">
<group id="Example_group_1">
<action
id="Example_action_1"
label="Replace selection"
icon="images/ReplaceText16.gif"
text="NEW_TEXT"
class="com.oxygenxml.editor.sample.extension.action.ReplaceTextAction"/>
</group>
</extension>
Regards,
Sorin
-
- Posts: 5
- Joined: Sun Jan 20, 2008 2:10 am
Re: oXygen 9.1 - writing a document plugin, how do I access it?
I appreciate the quick response. This is not using the Eclipse plugin though. This is a plugin for the standalone oXygen distribution, using OxygenPluginsDevelopmentKit.
I'm looking at plugin.dtd, and there is no mention of a group element or point attribute.
This was my original plugin.xml (edited):
I'm looking at plugin.dtd, and there is no mention of a group element or point attribute.
This was my original plugin.xml (edited):
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plugin SYSTEM "../plugin.dtd">
<plugin
name="Auto-tagger plugin"
description="Description of the plugin."
version="1.0.0"
vendor="sample vendor"
class="com.packagename.oxygen.TaggerPlugin">
<runtime>
<library name="lib/n4l.jar"/>
</runtime>
<extension type="documentProcessor" class="com.packagename.oxygen.TaggerPluginExtension"/>
</plugin>
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: oXygen 9.1 - writing a document plugin, how do I access it?
Post by sorin_ristache »
For oXygen standalone plugins just look at the source code of the sample plugins in the section Plugins of the Community page, for example the CapLines plugin. In your DocumentPluginExtension implementation you have to implement only the method process(DocumentPluginContext). The following is an example of plugin that appends the string "ABC" at the end of the edited document. You run the plugin by right clicking in the editor panel and selecting Plugins -> Insert Text. If you install the plugin correctly in a subfolder of the folder [oXygen-install-folder]/plugins you can see in Options -> Preferences -> Plugins the details that are specified in the plugin.xml descriptor of the plugin:
- InsertTextExtension.java:
- InsertTextPlugin.java:
- plugin.xml:
You can find details about creating and installing a plugin in the plugins development guide available on the same Community page.
Regards,
Sorin
- InsertTextExtension.java:
Code: Select all
package ro.sync.sample.plugin;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import ro.sync.exml.plugin.document.DocumentPluginContext;
import ro.sync.exml.plugin.document.DocumentPluginExtension;
import ro.sync.exml.plugin.document.DocumentPluginResult;
public class InsertTextExtension implements DocumentPluginExtension {
/**
* @see ro.sync.exml.plugin.document.DocumentPluginExtension#process(ro.sync.exml.plugin.document.DocumentPluginContext)
*/
public DocumentPluginResult process(DocumentPluginContext context) {
final Document doc = context.getDocument();
try {
doc.insertString(doc.getLength() - 1, "ABC", null);
} catch (BadLocationException e) {
e.printStackTrace();
}
return new DocumentPluginResult() {
public Document getProcessedDocument() {
return doc;
}
};
}
}
- InsertTextPlugin.java:
Code: Select all
package ro.sync.sample.plugin;
import ro.sync.exml.plugin.Plugin;
import ro.sync.exml.plugin.PluginDescriptor;
public class InsertTextPlugin extends Plugin {
private static InsertTextPlugin instance = null;
public InsertTextPlugin(PluginDescriptor descriptor) {
super(descriptor);
if (instance != null) {
throw new IllegalStateException("Already instantiated!");
}
instance = this;
}
public static InsertTextPlugin getInstance() {
return instance;
}
}
- plugin.xml:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plugin SYSTEM "../plugin.dtd">
<plugin
name="Insert Text"
description="Insert text in the editor"
version="1.0.0"
vendor="SyncRO"
class="ro.sync.sample.plugin.InsertTextPlugin">
<runtime>
<library name="lib/textInsert.jar"/>
</runtime>
<extension type="documentProcessor"
class="ro.sync.sample.plugin.InsertTextExtension"/>
</plugin>
Regards,
Sorin
-
- Posts: 5
- Joined: Sun Jan 20, 2008 2:10 am
Re: oXygen 9.1 - writing a document plugin, how do I access it?
Ah, I see it now! For some reason, I expected it to be available in Author mode.
I've been through all of the documentation, and I don't see anything about the following:
Is there a way to set up hotkeys for a plugin?
How are errors reported?
Is there an easy way to debug a plugin (console or some other logging method available)?
I've been through all of the documentation, and I don't see anything about the following:
Is there a way to set up hotkeys for a plugin?
How are errors reported?
Is there an easy way to debug a plugin (console or some other logging method available)?
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: oXygen 9.1 - writing a document plugin, how do I access it?
Post by sorin_ristache »
No, you cannot set a shortcut for a plugin. We will consider adding this in a future version of oXygen.
The developer of the plugin should add logging instructions in the code of the plugin and a method/external library to output the logging data. oXygen just executes the code of the plugin without restricting the plugin to a logging method or a logging message format.
Regards,
Sorin
The developer of the plugin should add logging instructions in the code of the plugin and a method/external library to output the logging data. oXygen just executes the code of the plugin without restricting the plugin to a logging method or a logging message format.
Regards,
Sorin
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service