Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: SomersetGraham on April 04, 2012, 01:03:11 am

Title: MDG Technologies
Post by: SomersetGraham on April 04, 2012, 01:03:11 am
Hi
I have an MDG technology that defines a profile and toolboxes that enable me to create various classes on my diagrams.
What I would like to to is when an operation is added to one these classes, the operation should automatically have a set of tagged values.
Can this be achieved through the use of profiles/MDG

Thanks
Title: Re: MDG Technologies
Post by: Makulik on April 04, 2012, 01:36:44 am
I had a similar case with attributes.
The only way I know is to define a separate stereotype for your operation,
users of your technology need to drop the operations from the toolbox to the class then.
Another option is to do this using an AddIn.

HTH
Günther
Title: Re: MDG Technologies
Post by: SomersetGraham on April 04, 2012, 02:03:55 am
Thanks
I'll give it a  try
Title: Re: MDG Technologies
Post by: qwerty on April 04, 2012, 03:08:52 am
The only other way is to catch one of the OnPost events triggered by EA and react accordingly.

q.
Title: Re: MDG Technologies
Post by: KP on April 04, 2012, 09:16:07 am
Quote
The only other way is to catch one of the OnPost events triggered by EA and react accordingly.

q.
EA_OnPostNewMethod (http://www.sparxsystems.com/uml_tool_guide/sdk_for_enterprise_architect/ea_onpostnewmethod.htm)
Title: Re: MDG Technologies
Post by: SomersetGraham on April 04, 2012, 06:50:31 pm
Hi
Thanks for the replies
How do I extract the MethodID from the EA.EventProperties passed to EA_OnPostNewMethod?
Title: Re: MDG Technologies
Post by: qwerty on April 04, 2012, 07:59:53 pm
OnPost passes the object. So you find it at parm2.MethodID. (N.B. I have used connector and element where it is that way so I guess method is alike.)

The OnPre instead gives you a collection with key/value pairs where you can find it.

q.
Title: Re: MDG Technologies
Post by: SomersetGraham on April 04, 2012, 08:06:34 pm
Hi
I have tried this
Code: [Select]
public bool EA_OnPostNewMethod(EA.Repository Repository, EA.EventProperties Info)
        {
            int id;
            id = Info.MethodID;
            return false;
        }
but it doesn't compile!
Sorry if I'm missing the obvious
Title: Re: MDG Technologies
Post by: qwerty on April 04, 2012, 09:07:09 pm
Sorry, I'm no Cxx guru. But try EA.Method  (or what it is called) since that is what you get - the EA object for a method.

q.
Title: Re: MDG Technologies
Post by: Makulik on April 04, 2012, 09:29:09 pm
I guess it's C#, right?
Effectively the EventProperties is a collection which can be accessed with String type keys. The key to use should be "MethodID", it's s.th. like
Info.Get("MethodID"), which returns you a Variant containing the ID. With this you can call int.Parse(Info.Get("MethodID").ToString()).

HTH
Günther
Title: Re: MDG Technologies
Post by: SomersetGraham on April 04, 2012, 11:05:40 pm
Thanks
Title: Re: MDG Technologies
Post by: philchudley on April 06, 2012, 09:57:20 am
Hi

What I would try is to create a UML profile where a stereotype that extends the metaclass operation is created.

As usual attributes added to the stereotype will become tagged values for the operation.
 
You should be able to add the operation, change its stereotype and then the tagged values will be there.

It worked for me for attributes, so I see no reason why it should not work for operations although I haven;t tried it.

Add the profile to the MDG in the usual manner.

Hope this helps

Cheers

Phil
Title: Re: MDG Technologies
Post by: philchudley on April 06, 2012, 10:10:56 am
Follow up, I have just conducted a simple test and what I described in the previous post does indeed work as described.

Cheers

Phil
Title: Re: MDG Technologies
Post by: SomersetGraham on April 10, 2012, 05:36:25 pm
Thanks for your help
got it working now