how to access created stereotype

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

how to access created stereotype

Postby Petar Blagoev » Mon Jun 04, 2007 4:26 pm

i created my own module with different stereotypes. When I load this
module into a project I would like to make default assigment to a
stereotype form this module, when a new class is drawn.
I do this as following:
Stereotype stereotype = StereotypesHelper.getStereotype(Application.
getInstance().getProject(), "sName");
>> stereotype is not null
... (where classElement is a ClassImpl object recieved from
stereotype.getAppliedStereotypeInstance() = null?!?
Is there a different way how to access and assigne Stereotypes to a
ClassDiagramms through
When I do this steps through MD-GUI the
stereotype.getAppliedStereotypeInstance() id noy null.

Best Regards,
Composed with Newz Crawler 1.8
Petar Blagoev
Posts Rating:

Re: how to access created stereotype

Postby Martynas Lelevicius » Tue Jun 05, 2007 4:48 am

Hi Petar,

Use StereotypesHelper for stereotypes accessing.

// get applied stereotype
Stereotype stereotype =
StereotypesHelper.getAppliedStereotypeByString(element, "StereotypeName");
// get all aplied stereotypes
List stereotypes = StereotypesHelper.getStereotypes(element);

// apply stereotype
StereotypesHelper.addStereotype(element, stereotype);

Martynas Lelevicius
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

Martynas Lelevicius
Posts Rating:

Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 1 guest