Author Topic: OnPostNewElement / ParentID  (Read 3502 times)

Eric Johannsen

  • EA User
  • **
  • Posts: 43
  • Karma: +0/-0
  • Model Driven Business[ch0174]
    • View Profile
OnPostNewElement / ParentID
« on: November 26, 2007, 02:58:00 pm »
I'm catching the EA_OnPostNewElement event in my plugin.

When a GUIElement is added to a Screen, I want to check that screen's stereotype to determine further procesing.

Trouble is, the GUIElement's ParentID property is zero.  Is this set after the OnPostNewElement event completes?  If so is there a way for me to achieve the desired behavior (process element after it is created and the ParentID is hooked up)?

Thanks,

Eric

Olga

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: OnPostNewElement / ParentID
« Reply #1 on: November 28, 2007, 03:45:02 am »
Is the parent of your element also an element or maybe it is a package?
ParentID is not zero only if parent is an element, otherwise your should look for PackageID.

Olga

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: OnPostNewElement / ParentID
« Reply #2 on: November 28, 2007, 04:12:12 am »
Eric,

There was a recent post about one or two events not firing correctly. I cannot remember, but I believe this problem came up as recently as build 818. I gather it is resolved for EA 7.1, which should enter beta very soon.

It might be worth your time to search the forum to see if you can find the post (go back a month or two). You can see if it was the same event.

David
No, you can't have it!

Eric Johannsen

  • EA User
  • **
  • Posts: 43
  • Karma: +0/-0
  • Model Driven Business[ch0174]
    • View Profile
Re: OnPostNewElement / ParentID
« Reply #3 on: November 28, 2007, 01:39:10 pm »
I didn't find the post you refer to, but I did search the forum going back 999 days for anything related to OnPostNewElement.  There were some posts but none were relevant.

I worked around the issue by setting a flag that this event was raised, then responding to the SECOND OnNotifyContextItemModified event that is fired.

Scarry to put that kind of a hack in the code, but I need th deal with the specific EA version my client is using at the moment.  They won't be upgrading to 7.x until at the earliest first quarter next year.

If anyone needs more details about the workaround reply to this post.  I have notifications setup for any replies and will be glad to help you out.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: OnPostNewElement / ParentID
« Reply #4 on: November 29, 2007, 05:03:55 am »
Eric,

First, the important thing is that you do have a workaround, at least for now. I agree it is a "scary" bit of code, but you can replace it later when this is resolved.

Second, I'd love it if you could share the fragment. I'm going to have this problem in the very near future. I'll send you coordinates using the forum direct message - check above and to the right of the top forum menu.

Third, as I mentioned, I wasn't sure if the earlier posts covered your problem. Obviously they did not. So...

Forth, and most important. This needs to be reported to Sparx as a bug. While Sparx does participate actively here, we are in a user forum. You need to get this directly into the Sparx support 'hopper' so that it gets addressed now. Here's the best practice we (the forum community) have been using for feature requests and bug reports (in this case the latter). Read through it once (you'll see why) and then give it a whirl.

To reach the appropriate page, click the Report a Bug or Feature Request (as appropriate) link below the Support link at the bottom of any forum page. You'll get to a one-page form that walks you through the information Sparx will need.

When you make the request, include the title of the forum thread you've started (or participated in). Also paste in the URL of the thread. This let's Sparx participate in the discussion, gauge user support for new features, and suggest workarounds.

[See, I told you to read through first. Depending on settings, IE (for example) can 'forget' all the stuff you've entered so far when you back up a few pages to get the URL. To avoid this situation when using IE, try opening a new copy of your page (control-N) and backing up with that copy, so you don't get your work erased.]

If relevant (such as in your case here) attach a compressed project (or other file) to provide an example to Sparx, so they can see what's happening.

If and when you hear back from Sparx on this, please revisit the forum thread, and let us (the rest of the EA community) know what you learn. This will keep us in the loop.

All the best,
David
No, you can't have it!