Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: etaha on January 30, 2018, 09:05:54 am

Title: Change element status after user change any element attribute
Post by: etaha on January 30, 2018, 09:05:54 am
Is there a way/event to change status of an element after user change any attribute of an element?
For example, if element status is approved I need to revert it back proposed in case user change element name/description/tagvalue etc..
Thanks in Advance.
Title: Re: Change element status after user change any element attribute
Post by: qwerty on January 30, 2018, 09:50:14 am
You need to write an add-in for that (or use Geert Bellekens' EA-Matic). There's a broadcast event which tells you that an element has changes and you can do further action.

q.
Title: Re: Change element status after user change any element attribute
Post by: etaha on January 30, 2018, 07:01:17 pm
Thanks a lot.
I've checked all broadcast events documentation amd EA-Matics available events; but I couldn't figure out which event to use.
There are events for pre-posting/deleting element but none for modify element.
Title: Re: Change element status after user change any element attribute
Post by: Uffe on January 30, 2018, 07:17:17 pm
Hello,

You're looking for EA_OnNotifyContextItemModified. It's in with the other context item events.

Note, however, that semantically this approach will only ever give you a partial solution. It doesn't cover all cases where something is changed which affects en element (eg inherited attributes).


/Uffe
Title: Re: Change element status after user change any element attribute
Post by: etaha on January 30, 2018, 07:21:12 pm
I'll check that event; It's wierd that it's under contextmenu.
Thanks you all.
Title: Re: Change element status after user change any element attribute
Post by: qwerty on January 30, 2018, 07:43:19 pm
Hehe. EA is not only unique in its user interface but also in its documentation.  The people from planet Sparx have a different mindset than us common earthlings.

q.
Title: Re: Change element status after user change any element attribute
Post by: Uffe on January 30, 2018, 10:19:09 pm
I'll check that event; It's wierd that it's under contextmenu.
It's not context menu -- it's context item.

The context item events tell you when the user has changed the selection in the GUI, double-clicked something or made changes to the currently selected thing (element, diagram, etc).

So they're GUI-related, but nothing to do with any menus.

/U
Title: Re: Change element status after user change any element attribute
Post by: etaha on January 31, 2018, 07:37:16 am
Thanks for the note..and sorry I didn't notice it..

I've register that event with EA-Matic and it works, but there is an issue when user wants to change to Approve this will automatically revert to Proposed
Code: [Select]
function EA_OnNotifyContextItemModified(GUID, ot)
Dim el
If ot = EA.ObjectType.otRequirement then
    Set el = Repository.GetElementByGuid(GUID)
if el.Status = "Approved" then
el.Status = "Proposed"
el.Update()
end if
end if
end function
Is there a way to know the updated attributes of the element?
Thanks a lot.
Title: Re: Change element status after user change any element attribute
Post by: Nabil on January 31, 2018, 02:52:12 pm
By default there is no method says which are the attributes got updated. You have to do a compare, then update . EA_OnNotifyContextItemModified will be triggered when current context item has been modified
Title: Re: Change element status after user change any element attribute
Post by: etaha on January 31, 2018, 03:12:20 pm
Thanks for the reply..
As per my tests, this event is not triggered unless user clicks on Apply or Ok buttons, which is after the changes happened and no way to get element attributes' values before updated by this event only.
Any ideas?
Thanks in Advance...
Title: Re: Change element status after user change any element attribute
Post by: Nabil on January 31, 2018, 04:36:16 pm
You have to get the previous values in session for a compare. When the user clicks next element/connector/diagram EA_OnContextItemChanged event will get triggered.
Title: Re: Change element status after user change any element attribute
Post by: etaha on January 31, 2018, 06:16:26 pm
Many thanks.. I'll try it out.
Title: Re: Change element status after user change any element attribute
Post by: etaha on February 01, 2018, 01:34:26 am
Appreciated. Many thanks to all. It works.