I would like to verify, each time someone wants to modify the name of an Entity (DM), that no other Entity (DM) has the same short name.
I created a macro connected via the "MetaAttributeUpdateTool" to my "Uml ClassName" Attribute.
Here is the content of my macro :
'MegaContext(Fields,Types) 'Uses(Components) Option Explicit ' Must be implemented - returns the kind of the control Function AttCtl_GetDefaultKind() As String AttCtl_GetDefaultKind = "Edit" End Function 'May be implemented to overload the update of the object - returns False to invoke default implementation Function AttCtl_Update(Context As MegaUpdateToolContext,Status As Integer,ErrorMessage As String) As Boolean Dim oRoot Dim strTest as string Set oRoot = Context.GetRoot If oRoot.getobjectfromid(Context.MegaObject.getClassID).name = "Entité (MD)" And oRoot.getSelection("Select [Entité (MD)] Where [Nom court] = """ & context.EditText & """").count > 0 Then ErrorMessage = "Une entité (MD) portant ce nom existe déjà." & vbcrlf & "Modification non autorisée." Status = 3 AttCtl_Update = False End If End Function
It works really fine when someone tries to modify the name of the Entity in the Caracteristics tab, but if, for example, someone wants to modify the name of the Entity in a diagram striking the "F2" key, well it doesn't work anymore.
I guess I should have another value then "Edit" for the AttCtl_GetDefaultKind function, but I don't know which one I should use. Please help...
Solved! Go to Solution.
MetaAttributeUpdateTools are used to control how attributes are displayed and how they behave in property pages.
They are not called when attribute is modified in "inline" or "batch" context.
The main issue is that the "UML ClassName" attribute is already implemented by a standard macro, so it is unsafe to replace it with another macro.
If it was a different attribute, you could have redefined it as "virtual" and implemented specific behavior in the SetAttributeValue function.
Thanks for your always rapid and precise answers :-)
Another way for me would be to cancel the namespace for the entity (DM) metaclass.
But I tried and it does not seem so easy. Any idea ?