Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: utkarsh on May 15, 2008, 09:46:21 pm

Title: Selection of element in tree from addin
Post by: utkarsh on May 15, 2008, 09:46:21 pm
Hi,

I am developing a addin in which i need to select an element in the grid; on the selection of which the element should be located in the tree in the project browser. How can I do this?

Thanks for help in advance.
Title: Re: Selection of element in tree from addin
Post by: Eve on May 16, 2008, 08:34:43 am
Handle EA_OnContextItemChanged (http://www.sparxsystems.com.au/EAUserGuide/index.html?ea_oncontextitemchanged.htm) and call Repository.ShowInProjectView() (http://www.sparxsystems.com.au/EAUserGuide/index.html?repository3.htm).
Title: Re: Selection of element in tree from addin
Post by: utkarsh on May 22, 2008, 01:28:57 am
Thanks.

I think I was not able to explain my requirement correctly. When I select an item from a addin, I need to locate and select the element in the tree and expand that perticular node in the tree. I tried the Repository.ShowInProjectView() but it do not displays(expand) the tree.
Thanks for your help.
Title: Re: Selection of element in tree from addin
Post by: Frank Horn on May 22, 2008, 03:40:18 am
If Repository.ShowInProjectView() does not expand the tree view to make the selected object visible, I would consider this a bug, which you may want to officially report.

The only workaround I can think of is using windows api to get the tree view's handle and send it WM_WhatsItsName messages to make it select and expand nodes. But that's hardly worth it.
Title: Re: Selection of element in tree from addin
Post by: utkarsh on May 24, 2008, 04:59:29 pm
I realised that ShowInProjectView() works but not in all cases. It expands the tree node in project browser but for only sometimes. Strange!!

Is it has something to do with a perticular type/sterotype of an element or is it a bug in the API?

Please suggest.
Thanks.
Title: Re: Selection of element in tree from addin
Post by: «Midnight» on May 24, 2008, 08:53:26 pm
Do you have a project where it fails? If so, send it in as an attachment to a bug report or email to Sparx support. They need to see one of the special cases.
Title: Re: Selection of element in tree from addin
Post by: utkarsh on May 27, 2008, 02:32:21 pm
I found out the problem now.

ShowInProjectView() do not works for package.

Can you please tell me how can I select a package from the addin?

Thanks.
Title: Re: Selection of element in tree from addin
Post by: Frank Horn on May 27, 2008, 04:40:11 pm
How do you select the package from your add in?

If you select it just like other elements (classes and things) by element ID, you may end up passing not the Package object but the package's Element property (which is an Element object with Type="Package") to the ShowInProjectView() method.
Title: Re: Selection of element in tree from addin
Post by: utkarsh on May 27, 2008, 07:34:26 pm
Thanks for the insight Frank.

I was passing the package's element GUID which was wrong. I found the package by GUID and it worked.

Thanks a lot :)