Adding a Action to a MagicDraw Menu

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Adding a Action to a MagicDraw Menu

Postby Raul Lorenzo » Thu Feb 23, 2006 5:51 am

Hi,

I have this code get it from MainMenuConfigurator in examples directory.
I want to add my plugin to the Tools Menu of Magic Draw.
Why does this code create another menu instead adding to the one existing?

String HERRAMIENTAS="Tools";
public void configure(ActionsManager mngr)
{
// searching for Tools action category
ActionsCategory category = (ActionsCategory)
mngr.getActionFor(HERRAMIENTAS);

if( category == null )
{
// creating new category
category = new MDActionsCategory(HERRAMIENTAS,HERRAMIENTAS);
category.setNested(true);
mngr.addCategory(category);
}
category.addAction(action);
}

Thanks in advance,
Raul Lorenzo
 
Posts Rating:

Re: Adding a Action to a MagicDraw Menu

Postby Tomas Pugzlys » Tue Feb 28, 2006 11:37 am

Hello,

Every menu item in MagicDraw main menu corresponds to an action with
action id.
Action id constants are defined in ActionsID class.

Use ActionsID.TOOLS constant to get tools menu item.
You need to change your code line to the following:
ActionsCategory category = (ActionsCategory)
mngr.getActionFor(ActionsID.TOOLS);

Best regards,
--
Tomas Pugzlys
Programmer
No Magic Lithuanian Development Center
Savanoriu pr. 363- IV, LT-49425, Kaunas
P.O. box 2166, LT-44011, Kaunas
Phone: +370 37 324032 Fax: +370 37 320670
e-mail : tomasp
WWW: http://www.magicdraw.com
--
MagicDraw - UML Made Simple

nntp://news.nomagic.com/nomagic.products.magicdrawuml.openapi wrote:
> Hi,
>
> I have this code get it from MainMenuConfigurator in examples directory.
> I want to add my plugin to the Tools Menu of Magic Draw.
> Why does this code create another menu instead adding to the one existing?
>
> String HERRAMIENTAS="Tools";
> public void configure(ActionsManager mngr)
> {
> // searching for Tools action category
> ActionsCategory category = (ActionsCategory)
> mngr.getActionFor(HERRAMIENTAS);
>
> if( category == null )
> {
> // creating new category
> category = new MDActionsCategory(HERRAMIENTAS,HERRAMIENTAS);
> category.setNested(true);
> mngr.addCategory(category);
> }
> category.addAction(action);
> }
>
> Thanks in advance,
>

Tomas Pugzlys
 
Posts Rating:

Re: Adding a Action to a MagicDraw Menu

Postby Raul Lorenzo » Tue Feb 28, 2006 7:53 pm

Ok, thanks

Tomas Pugzlys escribió:
> Hello,
>
> Every menu item in MagicDraw main menu corresponds to an action with
> action id.
> Action id constants are defined in ActionsID class.
>
> Use ActionsID.TOOLS constant to get tools menu item.
> You need to change your code line to the following:
> ActionsCategory category = (ActionsCategory)
> mngr.getActionFor(ActionsID.TOOLS);
>
> Best regards,
Raul Lorenzo
 
Posts Rating:


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 0 guests