Hi Geert,
thank you for answering. Unfortunatelly that's not working. The documentation is extremely slim here. I'll go into more details what I have already tried out:
Here is the complete code of the script (don't mind the code comments):
function OnProjectBrowserScript()
{
// Get the type of element selected in the Project Browser
var treeSelectedType = Repository.GetTreeSelectedItemType();
switch ( treeSelectedType )
{
case ELEMENT_OT:
{
// Code for when an element is selected
var theElement as EA.Element;
var aTag as EA.TaggedValue;
theElement = Repository.GetTreeSelectedObject();
// dodavanje tagova na razini elementa, nije izdvojeno u zasebnu funkciju, moglo bi se jer je isti dio koda kao za paket.
aTag = theElement.TaggedValues.AddNew("LAUS_CC:Instalacija:Neprora[ch269]unskiKorisnici","True");
aTag.Update();
theElement.TaggedValues.Refresh();
aTag = null;
aTag = theElement.TaggedValues.AddNew("LAUS_CC:Instalacija:DuNeZupanija","True");
aTag.Update();
theElement.TaggedValues.Refresh();
aTag = null;
aTag = theElement.TaggedValues.AddNew("LAUS_CC:Instalacija:HZZO","True");
aTag.Update();
theElement.TaggedValues.Refresh();
aTag = null;
aTag = theElement.TaggedValues.AddNew("LAUS_CC:Instalacija:HZZOZZR","True");
aTag.Update();
theElement.TaggedValues.Refresh();
aTag = null;
aTag = theElement.TaggedValues.AddNew("LAUS_CC:Instalacija:ZZJZ","True");
aTag.Update();
theElement.TaggedValues.Refresh();
aTag = null;
aTag = theElement.TaggedValues.AddNew("LAUS_CC:Opis:ZaSve","<memo>");
//aTag.Notes = "kaj ima lima";
aTag.Update();
theElement.TaggedValues.Refresh();
aTag = null;
//dodavanje taga za opis za sve na razini atributa elementa
var attributes as EA.Collection;
attributes = theElement.Attributes;
var anAttributeTag as EA.AttributeTag;
anAttributeTag = null;
for ( var i = 0 ; i < attributes.Count ; i++ )
{
var currentAttribute as EA.Attribute;
currentAttribute = attributes.GetAt( i );
anAttributeTag = currentAttribute.TaggedValues.AddNew("LAUS_CC:Opis:ZaSve","<memo>");
anAttributeTag.Update();
currentAttribute.TaggedValues.Refresh();
anAttributeTag = null;
}
break;
}
case PACKAGE_OT:
{
// Code for when a package is selected
var thePackage as EA.Package;
var theElement as EA.Element;
var aTag as EA.TaggedValue;
thePackage = Repository.GetTreeSelectedObject();
theElement = thePackage.Element;
// dodavanje tagova na razini paketa, nije izdvojeno u zasebnu funkciju, moglo bi se jer je isti dio koda kao za element.
aTag = theElement.TaggedValues.AddNew("LAUS_CC:Instalacija:Neprora[ch269]unskiKorisnici","True");
aTag.Update();
theElement.TaggedValues.Refresh();
aTag = null;
aTag = theElement.TaggedValues.AddNew("LAUS_CC:Instalacija:DuNeZupanija","True");
aTag.Update();
theElement.TaggedValues.Refresh();
aTag = null;
aTag = theElement.TaggedValues.AddNew("LAUS_CC:Instalacija:HZZO","True");
aTag.Update();
theElement.TaggedValues.Refresh();
aTag = null;
aTag = theElement.TaggedValues.AddNew("LAUS_CC:Instalacija:HZZOZZR","True");
aTag.Update();
theElement.TaggedValues.Refresh();
aTag = null;
aTag = theElement.TaggedValues.AddNew("LAUS_CC:Instalacija:ZZJZ","True");
aTag.Update();
theElement.TaggedValues.Refresh();
aTag = null;
aTag = theElement.TaggedValues.AddNew("LAUS_CC:Opis:ZaSve","<memo>");
aTag.Update();
theElement.TaggedValues.Refresh();
aTag = null;
break;
}
default:
{
// Error message
Session.Prompt( "greška, to se ne može napraviti na ovom tipu UML elementa.", 0 );
}
}
}This code WORKS:
- the tags that are being added are defined on the Tagged Value Types tab of the UML Types dialog box.
- All tags that have "Instalacija" string in them are of type "Boolean"
- All tags that have "Opis" string in them are of type "Memo"
- when the script adds a tag like this: aTag = theElement.TaggedValues.AddNew("LAUS_CC:Instalacija:ZZJZ","True"); the first argument is used as the tag name, and the second argument is used as the TAG VALUE not as the tag type.
- in the previous example, if I put for the second argument value "Boolean" instead of "True", the value of the tag is "Boolean" instead of default value for that tag; and on the drop-down list for values for that tag in the Tagged Values window you can (and should) only select values True and False.
- on the other hand, if I change aTag = theElement.TaggedValues.AddNew("LAUS_CC:Opis:ZaSve","<memo>"); to aTag = theElement.TaggedValues.AddNew("LAUS_CC:Opis:ZaSve","WHATEVER I PUT HERE DOESN'T MATTER"); - it nevertheless creates tagged value of type Memo (as it should)...