Book a Demo

Author Topic: Element.Methods.Delete(i) vs project tree update  (Read 5356 times)

Mike Pagel

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Element.Methods.Delete(i) vs project tree update
« on: August 24, 2012, 07:19:13 pm »
When using code like this

Code: [Select]
element.Methods.Delete(0);
element.Methods.Refresh();

the project tree is not updated. The element was of type Component and the method is still listed in the tree. However, the method is no longer part of the Operations dialog and reloading the model obviously clean up the tree as well.

Is there any way besides the very user-visible approach of reloading the owning package through RefreshModelView() to get the tree in sync?

Thanks,
Mike

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Element.Methods.Delete(i) vs project tree upda
« Reply #1 on: August 24, 2012, 10:27:14 pm »
Did you try Repository.AdviseElementChange (long ObjectID)?

Geert

Mike Pagel

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Element.Methods.Delete(i) vs project tree upda
« Reply #2 on: August 27, 2012, 04:24:18 pm »
Hi Geert,

yes, I tried that. Both, on the owning component as well as with the deleted method's id (just for the sake of testing, even though a method is not en EA element). But it has no effect.

Mike

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Element.Methods.Delete(i) vs project tree upda
« Reply #3 on: August 27, 2012, 04:28:32 pm »
And you tried a Element.Update() as well?

Geert

Mike Pagel

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Element.Methods.Delete(i) vs project tree upda
« Reply #4 on: August 28, 2012, 12:50:28 am »
Yes, this is crashing if called on the deleted method.  :-?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Element.Methods.Delete(i) vs project tree upda
« Reply #5 on: August 31, 2012, 08:25:54 pm »
void RefreshModelView (long ID) — Reloads the EaPackage with ID matching PackageID, updating the user interface.

Try this with the package id where the deleted element is contained.

q.

Mike Pagel

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Element.Methods.Delete(i) vs project tree upda
« Reply #6 on: August 31, 2012, 08:56:32 pm »
As I said in the original post, this is quite intrusive, highly visible to the user and looses the current element, since the refreshed tree is collapsed.

I think this is pretty much a bug.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Element.Methods.Delete(i) vs project tree upda
« Reply #7 on: August 31, 2012, 08:59:11 pm »
It is a bug. AdviseElementChange  should do the trick without the need for a RefreshModelView

Geert