Author Topic: Selection of element in tree from addin  (Read 5210 times)

utkarsh

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Selection of element in tree from addin
« 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.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: Selection of element in tree from addin
« Reply #1 on: May 16, 2008, 08:34:43 am »

utkarsh

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Re: Selection of element in tree from addin
« Reply #2 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.

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: Selection of element in tree from addin
« Reply #3 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.

utkarsh

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Re: Selection of element in tree from addin
« Reply #4 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.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Selection of element in tree from addin
« Reply #5 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.
No, you can't have it!

utkarsh

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Re: Selection of element in tree from addin
« Reply #6 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.

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: Selection of element in tree from addin
« Reply #7 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.

utkarsh

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Re: Selection of element in tree from addin
« Reply #8 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 :)