Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started 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.
-
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).
-
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.
-
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.
-
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.
-
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.
-
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.
-
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.
-
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 :)