How to add custom classs/association types into diagram toolbar menu?

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

How to add custom classs/association types into diagram toolbar menu?

Postby Petar Blagoev » Tue Jun 19, 2007 11:20 am

Hallo,
after successfully loading my custom module/profile I would like to
add some more types into the diagram toolbar menu. For example: I've
defined some stereotypes with "class" as Metaclass, so I would like,
that they apear as types on the diagram toolbar menu under the "Class
Diagram/Class-DropDownMenu". How can I add these new types exectly at
that place, without creating a new dropdown submenu? The same I would
like to do with some new Associations, so when you click on them, to
be able to draw class, or association of named type.
Thanks a lot in advance!
Regards,
Petar
--
Composed with Newz Crawler 1.8 http://www.newzcrawler.com/
Petar Blagoev
 
Posts Rating:

Re: How to add custom classs/association types into diagram toolbar menu?

Postby Egle Blazaityte » Thu Jun 21, 2007 10:52 pm

Hello Petar,

What do you mean by saying "that they appear as types on the diagram toolbar
menu"? If I understand you correctly, you need to display some particular
stereotyped element in the class diagram toolbar menu. The stereotypes that
you need to use for the new element in the toolbar, should be added into
some module, which will be used in the customizing process.

In order to display custom stereotyped element in the Class diagram
toolbar, please open main menu, Diagrams, Customize.
1. Select the Class diagram and click "Edit".
2. In the 2nd step use module, which includes yours created stereotypes.
3. In the 3rd step click "Add toolbar"->"New Toolbar" and name it.
4. In the 4th step select the group to which you need to add the new button
and click "Add"->"New button".
5. In the opened dialog select Class as Model Element Type.
6. In the same dialog, Stereotypes tab, choose the desirable stereotype and
click OK.
7. Finish "Customize Diagram Wizard".
Newly added element will be visible in class diagram, in created toolbar.

> The same I would like to do with some new Associations, so when you click
> on them, to be able to draw class, or association of named type.

Could you please explain this in more details? Would you like to create a
new association item of some particular name or properties? Or would you
like to see some particular elements as the target while drawing the
association?

Regards,
Egle Blazaityte
Quality Assurance Engineer
No Magic Lithuanian Development Center
Savanoriu pr. 363, LT 49425 Kaunas
Phone: +370 37 324032 Fax: +370 37 320670
e-mail: egle.blazaityte
WWW: http://www.magicdraw.com
--
MagicDraw - Architecture made simple!
----- Original Message -----
From: "nntp://news.nomagic.com/nomagic.products.magicdrawuml.openapi"
<blagoev>
To: "Egle Blazaityte" <egle.blazaityte>
Sent: Wednesday, June 20, 2007 9:49 AM
Subject: How to add custom classs/association types into diagram toolbar
menu?


> Hallo,
> after successfully loading my custom module/profile I would like to
> add some more types into the diagram toolbar menu. For example: I've
> defined some stereotypes with "class" as Metaclass, so I would like,
> that they apear as types on the diagram toolbar menu under the "Class
> Diagram/Class-DropDownMenu". How can I add these new types exectly at
> that place, without creating a new dropdown submenu? The same I would
> like to do with some new Associations, so when you click on them, to
> be able to draw class, or association of named type.
> Thanks a lot in advance!
> Regards,
> Petar
> --
> Composed with Newz Crawler 1.8 http://www.newzcrawler.com/
>

Egle Blazaityte
 
Posts Rating:

Re: How to add custom classs/association types into diagram toolbar menu?

Postby Petar Blagoev » Sun Jun 24, 2007 11:53 am

24.06.2007 17:43:11
Egle Blazaityte <egle.blazaityte> wrote in message
30927594.1182494715056.JavaMail.tadjar@peleda

Hello Egle,
thanks fro your reply,

> Hello Petar,
>
> What do you mean by saying "that they appear as types on the
diagram toolbar
> menu"? If I understand you correctly, you need to display some
particular
actually I have created my owln module with some new stereotypes.
Most of them have a Class, or Element as metasteretype. So when I
draw a new Class into a Classdiagram a can set the Steretype to one
of this new steretypes by chooseing it form right click on the
class/steretypes. Okey this the one possibility to assign these my
custom steretypes from my module, but the point is, I want to
create/add some custom buttoms int the toolbar after loading my modul.
So my plugin has to recoginze when my module is loaded into the
project (already done) and add this default buttoms into the
ClassDiagram toolbar. For example now when you create a ClassDiagram
by defautl you can choose from Class-Menu(dropdawn buttons in the
toolbar of the classdiagram) 6 types of a Class(Class, Enumeration,
Signal, Datat Type, Primitive Type, Class by Pattern) and I would
like to add exactly there view more Class-Types (they are normal
Classes but with assignt Steretype that I allready defined in my
module). So you can click on one of them and draw a class with
assigned Steretype. Is it possible to add exectly there these new
Class-types?
by now I'm doing the following:
public class ClassDiagramToolbarConfigurator extends
BaseDiagramToolbarConfigurator{
...
public void configure(ActionsManager mngr){
logger.debug("mngr: " + mngr);
MDActionsManager actions = BaseToolbarActions.ACTIONS;
DiagramInnerToolbarConfiguration category= new
DiagramInnerToolbarConfiguration("ELEMENTS", null, "Elements", true);
mngr.addCategory(category);
category.addAction(actions.getActionFor(DrawClassAction.
DRAW_CLASS_ACTION));
}
}
public class MyAction extends NMAction implements ActionsGroups{
....
private void setDiagramToolbarActions(){
ClassDiagramToolbarAction toolbarAciton = new
ClassDiagramToolbarAction();
toolbarAciton.setDescription("MyClass");
ClassDiagramToolbarConfigurator diagramsConfigurator = new
ClassDiagramToolbarConfigurator(toolbarAciton);
ActionsConfiguratorsManager manager =
ActionsConfiguratorsManager.getInstance();
logger.debug("manager: " + manager);
manager.addDiagramShortcutsConfigurator(DiagramType.
UML_CLASS_DIAGRAM, diagramsConfigurator);
manager.addDiagramToolbarConfigurator(DiagramType.
UML_CLASS_DIAGRAM, diagramsConfigurator);
}
}
so I can add a custom Toolbar Menu called "Elements" into the
ClassDiagram view. Offcourse into "Elements" I can add all my custom
actions. But I want to put them on the proper place see above. All
classes under "Class" all my associations under "Association" and so
on.
> stereotyped element in the class diagram toolbar menu. The
stereotypes that
> you need to use for the new element in the toolbar, should be added
into
> some module, which will be used in the customizing process.
>
> In order to display custom stereotyped element in the Class diagram
> toolbar, please open main menu, Diagrams, Customize.
> 1. Select the Class diagram and click "Edit".
> 2. In the 2nd step use module, which includes yours created
stereotypes.
> 3. In the 3rd step click "Add toolbar"->"New Toolbar" and name it.
> 4. In the 4th step select the group to which you need to add the
new button
> and click "Add"->"New button".
> 5. In the opened dialog select Class as Model Element Type.
> 6. In the same dialog, Stereotypes tab, choose the desirable
stereotype and
> click OK.
> 7. Finish "Customize Diagram Wizard".
> Newly added element will be visible in class diagram, in created
toolbar.

well I would like that this procedure will do my plugin instead of
the user. So when someone installs my plugin (there will be to files
to copy under MacigDraw ones the module under ${MDHome}/profiles and
the plugin under ${MDHOme}/plugins)automatically by loading my module
into the project the plugin buttons and menus will be enabled and
displayd.
>
> > The same I would like to do with some new Associations, so when
you click
> > on them, to be able to draw class, or association of named type.
>
> Could you please explain this in more details? Would you like to
create a
> new association item of some particular name or properties? Or
would you
> like to see some particular elements as the target while drawing
the
> association?
yes see above, I would like to see my custom Associations as target
under "Association" Button in the toolbar of the ClassDiagram. So I
can ckilck on it and draw a Association with a associated
<<stereotype>> between two classes.
Regards,
Petar
>
> Regards,
> Egle Blazaityte
> Quality Assurance Engineer
> No Magic Lithuanian Development Center
> Savanoriu pr. 363, LT 49425 Kaunas
> Phone: +370 37 324032 Fax: +370 37 320670
> e-mail: egle.blazaityte
> WWW: http://www.magicdraw.com
> --
> MagicDraw - Architecture made simple!
> ----- Original Message -----
> From: "nntp://news.nomagic.com/nomagic.products.magicdrawuml.
openapi"
> <blagoev>
> To: "Egle Blazaityte" <egle.blazaityte>
> Sent: Wednesday, June 20, 2007 9:49 AM
> Subject: How to add custom classs/association types into diagram
toolbar
> menu?
>
>
> > Hallo,
> > after successfully loading my custom module/profile I would like
to
> > add some more types into the diagram toolbar menu. For example:
I've
> > defined some stereotypes with "class" as Metaclass, so I would
like,
> > that they apear as types on the diagram toolbar menu under the
"Class
> > Diagram/Class-DropDownMenu". How can I add these new types
exectly at
> > that place, without creating a new dropdown submenu? The same I
would
> > like to do with some new Associations, so when you click on them,
to
> > be able to draw class, or association of named type.
> > Thanks a lot in advance!
> > Regards,
> > Petar
> > --
> > Composed with Newz Crawler 1.8 http://www.newzcrawler.com/
> >
--
Composed with Newz Crawler 1.8 http://www.newzcrawler.com/
Petar Blagoev
 
Posts Rating:

Re: How to add custom classs/association types into diagram toolbar menu?

Postby Martynas Lelevicius » Mon Jul 09, 2007 5:30 am

Hello,

It is not possible to reconfigure diagram toolbar after diagram window is
opened through OpenAPI.
You can force reconfiguration only if you change the diagram toolbar user
mode.

To add your action to the "Class" menu group use this sample:

public void configure(ActionsManager mngr)
{
ActionsCategory classDiagramActions =
mngr.getCategory(ActionsID.CLASS_DIAGRAM_ELEMENTS);

// use more "clever" approach to find the right place
ActionsCategory classActions = ((ActionsCategory)
classDiagramActions.getActions().get(0));

// add your action here
classActions.addAction(...);
}

> well I would like that this procedure will do my plugin instead of
> the user. So when someone installs my plugin (there will be to files
> to copy under MacigDraw ones the module under ${MDHome}/profiles and
> the plugin under ${MDHOme}/plugins)automatically by loading my module
> into the project the plugin buttons and menus will be enabled and
> displayd.

There is no need to customize diagram for every user, you just need to
distribute the file <MD install>/data/diagrams/<Diagram
Type>/descriptor.xml, which stores customized diagram info.

Regards,
--
Martynas Lelevicius
Programmer
No Magic Lithuanian Development Center
Savanoriu pr. 363, LT-49425, Kaunas
P.O. box 2166, LT-44011, Kaunas
Phone: +370 37 324032 Fax: +370 37 320670
E-mail : marte
WWW: http://www.magicdraw.com

Martynas Lelevicius
 
Posts Rating:


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 0 guests