Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: stao on June 29, 2010, 06:37:15 pm

Title: How to add a Tagged Value to Connector / Operation
Post by: stao on June 29, 2010, 06:37:15 pm
Hi everyone
i try to add Tagged Values to Connectors and to Operations.
For some reason it does not work.
Adding Tagged Values to Elements works well.
the same code leads to an exception for Cons and Ops.

EA.TaggedValue tag=EA.TaggedValue)newObject.TaggedValues.AddNew("bound", "true");

or

foreach(EA.TaggedValue tag in link.TaggedValues) {
                    System.Windows.Forms.MessageBox.Show(tag.Name);
                }

exception as well.

In EA Help it says:

"The following model components can use the Tagged Values window as a convenient way to quickly view and modify Tagged Values:"

Operations : Owned properties only.
Connectors : Owned properties only.
Elements : Elements display their own Tagged Values along with any inherited values

I dont know exactly what is meant whith that.. :/

Stao
 
Title: Re: How to add a Tagged Value to Connector / Opera
Post by: Geert Bellekens on June 29, 2010, 10:07:02 pm
Stao,

Lookup the definition of the EA.Collection.Addnew operation.
"true" is not a type of an element to add. Should be something like "TaggedValue" or "ConnectorTag" or something like that.

Geert
Title: Re: How to add a Tagged Value to Connector / Opera
Post by: Nizam Mohamed on June 30, 2010, 11:03:06 am
Stao,
 This should work in most cases, are you missing a Update (newObject.Update).

Please refer to the "Method Lifecycle Example" script supplied with EA8.0 which demonstrates adding, iterating and deleting tagged values to a method.

Same applies to connector and roles too.
Title: Re: How to add a Tagged Value to Connector / Opera
Post by: stao on June 30, 2010, 06:32:27 pm
solved.
elements have TaggedValues
methods have MethodTags
connectors have ConnectorTags.

so it has to be

foreach(EA.ConnectorTag tag in link.TaggedValues) {
                   System.Windows.Forms.MessageBox.Show(tag.Name);
}

@ Geert

Value and Name of the Tagged Value (ConTag.. MethodTag)
can be everything. Has to be a String