Book a Demo

Author Topic: OnPostNewElement AFTER properties are saved  (Read 6008 times)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
OnPostNewElement AFTER properties are saved
« on: April 17, 2012, 04:01:16 am »
I wanted to create some elements based on the name of an element. But OnPostNewElement is called BEFORE the properties window is closed. So I guess the method should actually be called OnPostNewElementButBeforePropertiesAreEntered.

Any geert-around for this? (Just a rhetoric question...)

q.

Stefan Bolleininger

  • EA User
  • **
  • Posts: 308
  • Karma: +0/-0
    • View Profile
Re: OnPostNewElement AFTER properties are saved
« Reply #1 on: April 17, 2012, 05:50:39 am »
With OnPostNewElement you can retrieve your elementID and take this into account:

Filter your type of elements you want to have specialized.
Let the System create you a normal element in the systems way and take the elementID
save all element processes from the normal system and prepare your element with your own-desired ones (don't forget element.update();
recall the EA propoties with your manipulated information :-)

you need some undocumentated commands for that kind of elementmanipulation  >:( >:(

i did that you close the element-dialog for the normal element-gerneration, suppressed it and changed the element parameters for my desires. afterwards i call the:
repository.OpenEaPropertyDlg(openelementdialog.ElementID, EaType.Element);

Best regards

Stefan
Enterprise Architect in "safetycritical development" like medical device industry. My free Add-in at my Website

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: OnPostNewElement AFTER properties are saved
« Reply #2 on: April 17, 2012, 07:03:12 am »
I think I got what you said, but that's not what I wanted. I wanted EA to call the OnPost after all user input is done. It doesn't do that....

So here's what I did: just catch the OnContextItemChanged and see whether it's the newly created element. Then act accordingly. That's EAUI - the EA way of what they call consistent.

q.

stao

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: OnPostNewElement AFTER properties are saved
« Reply #3 on: April 17, 2012, 07:47:15 am »
Another (hopefuly) solution would be to set a boolean value newElementCreated = true if the OnPostNew... method is finished (before the properties dialog is opened)
After the user close the properties dialog i guess the OnContextItemModified(..) method will be called.
if your newElementCreated boolean is true you can do whatever you want and reset you value to false.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: OnPostNewElement AFTER properties are saved
« Reply #4 on: April 17, 2012, 07:33:01 pm »
Yep. That's exactly what I did. I just omitted that part you described :-) Let's hope it will help someone else.

q.