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

Hi,
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
Application.getInstance().getProject().getModel().getOwnedElement();)
classElement.setAppliedStereotypeInstance(stereotype.
getAppliedStereotypeInstance());
stereotype.getAppliedStereotypeInstance() = null?!?
Is there a different way how to access and assigne Stereotypes to a
ClassDiagramms through
OpenAPI?
When I do this steps through MD-GUI the
stereotype.getAppliedStereotypeInstance() id noy null.


Best Regards,
Petar
--
Composed with Newz Crawler 1.8 http://www.newzcrawler.com/
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.

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

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

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

cron