How to add Tool, Menu Items and its action at the run time

Having trouble installing Oxygen? Got a bug to report? Post it all here.
mveerasamy
Posts: 10
Joined: Fri Oct 02, 2009 12:24 am

How to add Tool, Menu Items and its action at the run time

Post by mveerasamy »

Hi

I want to create new toolbar item and a new menu Item and map these items to an new action at run time. Is it Possible?

My Requirement is
I have one custom Action class which will insert different XML fragments according to the parameter. I am reading these fragments and parameters from a properties file. My User will simply edit the properties file and add the values through another UI.

According to my knowledge in Oxygen my user have to create separate actions for each parameter( eventhough all are pointing the Same Action Class). Also he have to create separate menu Item and separate toolbar item to call this new action. he have to do this from (Options=>Preferences=>Document Type Association=>Editing my Framework)

But I donnt want my user to edit my framework directly. Instead i want to write a class which will get the XML Fragment from user and do all these things for him.

Now my questions:

1) Is there any API available in Oxygen to create toolbar, menubar and an action. (Basically to modify the framework)

2) If i open the myWork.framework under Program Files\Oxygen XML Editor 11\frameworks\myWork\
and adding the following sections thorough my program.

Code: Select all


Adding new toolbar under 
/serialized/map/entry/documentTypeDescriptor-array/documentTypeDescriptor/field/authorExtension/field/toolbar/field/toolbarEntry-array/toolbarItem

<toolbarItem>
<field name="actionID">
<String xml:space="preserve"> MyActionParam1</String>
</field>
<toolbarItem>

and adding new menu under
/serialized/map[1]/entry[1]/documentTypeDescriptor-array[1]/documentTypeDescriptor[1]/field[4]/authorExtension[1]/field[4]/menu[1]/field[4]/menuEntry-array[1]/menu[7]

<menu>
<field name="label">
<String xml:space="preserve">Execute MyAction with Param1</String>
</field>
<field name="accessKey">
<String xml:space="preserve"/>
</field>
<field name="iconPath">
<String xml:space="preserve"/>
</field>
<field name="menuEntriesDescriptorList">
<menuEntry-array>
<menuItem>
<field name="actionID">
<String xml:space="preserve">MyActionParam1</String>
</field>
</menuItem>
</menuEntry-array>
</field>
</menu>

Also Registering new Action by adding the following segment under
/serialized/map[1]/entry[1]/documentTypeDescriptor-array[1]/documentTypeDescriptor[1]/field[4]/authorExtension[1]/field[3]/action-array[1]/action[45]

<action>
<field name="id">
<String xml:space="preserve"> MyActionParam1</String>
</field>
<field name="name">
<String xml:space="preserve">Custom Action with Param1</String>
</field>
<field name="description">
<String xml:space="preserve">To Execute Custom Action with Param1
</String>
</field>
<field name="largeIconPath">
<String xml:space="preserve"/>
</field>
<field name="smallIconPath">
<String xml:space="preserve"/>
</field>
<field name="accessKey">
<String xml:space="preserve"/>
</field>
<field name="accelerator">
<String xml:space="preserve">ctrl shift 1</String>
</field>
<field name="actionModes">
<actionMode-array>
<actionMode>
<field name="xpathCondition">
<String xml:space="preserve">ancestor-or-self::body</String>
</field>
<field name="argValues">
<map>
<entry>
<String xml:space="preserve">action</String>
<String xml:space="preserve">Param1</String>
</entry>
</map>
</field>
<field name="operationID">
<String xml:space="preserve">
com.myproj.oxygen.framework.actions.CustonOperation
<!--Here my CustonOperation will invoke my methods according to the Parameter.-->
</String>
</field>
</actionMode>
</actionMode-array>
</field>
</action>
3)Even if I added in myWork.framework will it be enough? is there any other place should i have to addd/register?

Thanks in advance,
Muthu
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: How to add Tool, Menu Items and its action at the run time

Post by sorin_ristache »

Hello,
mveerasamy wrote:I want to create new toolbar item and a new menu Item and map these items to an new action at run time. Is it Possible?
Yes it is possible. See below.
mveerasamy wrote:According to my knowledge in Oxygen my user have to create separate actions for each parameter( eventhough all are pointing the Same Action Class). Also he have to create separate menu Item and separate toolbar item to call this new action. he have to do this from (Options=>Preferences=>Document Type Association=>Editing my Framework)
No you don't have to create an action for each parameter. You can request the parameter from the user for example with a dialog box that is displayed by your custom action. The menu item and the toolbar button must be configured based on your custom action from Preferences -> Document Type Association -- Edit your framework but this must be done only once.
mveerasamy wrote:But I donnt want my user to edit my framework directly. Instead i want to write a class which will get the XML Fragment from user and do all these things for him.

Your user does not have to edit the framework. You edit the framework once from Preferences -> Document Type Association (select in Developer mode) and after that you distribute the file myWork.framework to each author that will use the framework with your custom action in Oxygen Author mode. The user that will receive myWork.framework from you will use the framework only in Content Author mode, not Developer mode so that it will not be allowed to edit the framework in Preferences -> Document Type Association.
mveerasamy wrote:1) Is there any API available in Oxygen to create toolbar, menubar and an action. (Basically to modify the framework)
No. You add the custom action to the framework and add the action to the menu and the toolbar of Oxygen Author mode by modifying the framework in Developer mode from Preferences -> Document Type Association as I specified above. When you press OK in the Preferences dialog the myWork.framework file is saved and you can distribute it to the Content Author user.
mveerasamy wrote:2) If i open the myWork.framework under Program Files\Oxygen XML Editor 11\frameworks\myWork\
and adding the following sections thorough my program.
That is not recommended. You should not edit the .framework file directly. You should edit it by editing the framework from Preferences -> Document Type Association.
mveerasamy wrote:3)Even if I added in myWork.framework will it be enough? is there any other place should i have to addd/register?
That will be enough. After you configure the framework in Preferences -> Document Type Association you distribute to the Content Author user the .framework file and the jar file that contains custom action.


Regards,
Sorin
Post Reply