How to add a java-based action

Post here questions and problems related to oXygen frameworks/document types.
fsteimke
Posts: 80
Joined: Tue Jan 01, 2013 3:19 pm

How to add a java-based action

Post by fsteimke »

Hi,

we have to extend oxygen with a new, java-based action. I'd like to keep it as simple as possible and need a hint where to start.

We have to manage a list of UNICODE Characters together with some properties. We made a simple schema and a document instance, something like this:

Code: Select all


<characters>
<char codepoints="000A" subcategory="CONTROL" name="LINE FEED" blockName="BASIC_LATIN"/>
<char codepoints="000D" subcategory="CONTROL" name="CARRIAGE RETURN" blockName="BASIC_LATIN"/>
</characters>
(In reality there are much more properties, only some of them from unicode character database).

I'd like to extend Oxygen, so that, after choosing a new menu item, a form pops up where i can enter the hexcode of a new charcter. After doing so a new text fragment for the character shall be generated and inserted, with properties filled from some JAVA Code (UNICODE Properties of JAVA char datatype).

Im pretty sure this can be done, but where to start? Is it a Oxygen plugin, or is it something for authors SDK? Do you have samples which behave similar, so that i could learn from them? The whole thing could be done in text view as well as in author view.

Thanks in advance,
Frank
Radu
Posts: 9046
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to add a java-based action

Post by Radu »

Hi Frank,

Do you use a custom XML vocabulary? Have you already defined a framework/document type for it?
If so, you can use our Author SDK:

http://www.oxygenxml.com/oxygen_sdk.htm ... horing_SDK

to create a new custom Java-based operation which extends ro.sync.ecss.extensions.api.AuthorOperation. Your operation would read the XML file containing all characters, create a swing based-dialog, show it to the user and then use our ro.sync.ecss.extensions.api.AuthorDocumentController API to insert the text in the Author editor mode at the caret position.
Something like:

http://www.oxygenxml.com/doc/ug-editor/ ... HowTo.html

Once created the custom Java operation gets bundled in a JAR library which is contributed to the classpath of your custom document type.
Then you can create an action for it and add it to the toolbar, main or contextual menu:

http://www.oxygenxml.com/doc/ug-editor/ ... olbar.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Radu
Posts: 9046
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to add a java-based action

Post by Radu »

As an update on my previous post, I noticed your last remark in the post:
The whole thing could be done in text view as well as in author view.
The Author SDK can create operations only for the Author visual editing mode.
If you want a toolbar action to be used both in the Text and Author modes you will need to go another way and implement a Workspace Access plugin using our Plugins SDK:

http://www.oxygenxml.com/oxygen_sdk.htm ... er_Plugins

There is a sample "Workspace Access" plugin in the Plugins SDK. Such a plugin can contribute either with a custom toolbar to Oxygen or with an action to an already existing Oxygen toolbar. When invoked, the action could look and see what editor is currently selected and depending on the mode in which it is opened (Text or Author) use the API (which differs) to make changes to the editor content.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply