Page 1 of 1

Adding a Action to a MagicDraw Menu

PostPosted: Thu Feb 23, 2006 5:51 am
by Raul Lorenzo
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,

Re: Adding a Action to a MagicDraw Menu

PostPosted: Tue Feb 28, 2006 11:37 am
by Tomas Pugzlys
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,
>


Re: Adding a Action to a MagicDraw Menu

PostPosted: Tue Feb 28, 2006 7:53 pm
by Raul Lorenzo
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,