How to add Tool, Menu Items and its action at the run time
Posted: Fri Nov 06, 2009 3:11 am
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.
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
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>
Thanks in advance,
Muthu