Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: RainerQ on October 26, 2010, 08:55:42 pm
-
Hello,
how can I assign a specific TaggedValueType to a element?
This seams not to work...
myElement.TaggedValues.AddNew("<TaggedValueType>", "");
Thanks for help.
Regards
Rainer
-
Rainer,
My code to add a tagged values to an element:
/// <summary>
/// adds a tagged value to this element
/// </summary>
/// <param name="name">the name of the tagged value</param>
/// <returns>the added tagged value</returns>
public override UMLTaggedValue addTaggedValue(string name)
{
return (UMLTaggedValue)EAWrapperFactory.createEAWrapper((EAModel)this.getModel(), this.wrappedElement.TaggedValues.AddNew(name, "TaggedValue"));
}So I guess your code you work if you do:
myElement.TaggedValues.AddNew("<TaggedValueType>", "TaggedValue");
Just be careful with the name of the tagged value. If you have defined your tagged value as part of a profile you'll have to use the FQN as in "ProfileName:TaggedValueName" (or "ProfileName::TaggedValueName", i don't remember exactly)
There should be some posts about that in this forum.
Geert
-
Hi Geert,
thanks for your replay. Actually my code did works (partially).
Here is what I do:
- create new PropertyValueTypes
- create a new element (Requiremnt)
- assign a set of taggedValues.
My problem now is, that when I select the new created requirement, it shows the assigned tagged values, but not the default values.
If I shut down EA and restart it, the default values are shown. Also if I then create more Requirements through my addin all default values of the TaggedValues are shown correctly from now on.
My conclution is, that I am missing some Update or Refresh after creating the TaggedValueTypes...
Regards
Rainer
-
Can you post the code that creates the taggedValues?
Geert
-
Hi Geert,
here the code.
// creating the TaggedValueTypes
//=====================
repository.PropertyTypes.Refresh();
string property = "StoryPoints";
string description = "Estimated complexity of the user story";
string notes = "Type=enum;" + Environment.NewLine +
"Values=0,1,2,3,5,8,13;" + Environment.NewLine +
"Default=2;";
PropertyType tagType = repository.PropertyTypes.AddNew(property, "");
tagType.Description = description;
tagType.Detail = notes;
tagType.Update();
repository.PropertyTypes.Refresh();
Regards
Rainer
-
Seems perfectly ok to me.
If it's really necesarry you could to a reload of your model, but I would leave it as is. After all, after a restart of EA you see the default values so...
(PS. IIRC The default value isn't actually filled in in the database. Its left null and the EA GUI will pretend it has the default value, but my memory could be failing me.)
-
Hi Geert,
thanks for your help. I guess I will the leave it as it is. Maybe some when later I will stumble over a solution to this minor issue.
Regards
Rainer