Author Topic: EA_OnPreDeleteElement recognize deletion to late  (Read 645 times)

2ben7

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
EA_OnPreDeleteElement recognize deletion to late
« on: October 31, 2012, 08:37:27 pm »
Hallo,

i can need your help again. Would appreciate it.

What i have to do, to recognize a deleted element from the Repository ?
Im using EA_OnPreDeleteElement. But as the docu says, the event raises BEFORE it gets deleted from the Repository.

At the moment, i react for my plugin in this method. But if i do a SQL Query at the actual Repository(from the argument parameter list of the method), it is not always
secure, that the Element is still deleted from the repository.

How can i prevent this run condition ?
Also there is no EA_OnPostDeleteElement -EventMethod :(

qwerty

  • EA Guru
  • *****
  • Posts: 8972
  • Karma: +136/-124
  • I'm no guru at all
    • View Profile
Re: EA_OnPreDeleteElement recognize deletion to la
« Reply #1 on: October 31, 2012, 08:57:12 pm »
Not knowing your use case it's hard to tell. But it looks like you have to bite the bullet: poll the real deletion after a short time and react accordingly.

q.

2ben7

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: EA_OnPreDeleteElement recognize deletion to la
« Reply #2 on: October 31, 2012, 09:05:52 pm »
Yes i can explain the use case in more detail.
I have a control in my addin, which list all current diagrams of the model.

When i recognize, that there are one or more diagrams deleted
(even whole packages with several uncount diagrams inside),
i execute the fast SQLQuery("get all diagrams id`s or name from model")
to update the list to its current state.

I use EA_OnPreDeleteElement for this.

But as it seems, there is no valid reliable event, i can use to be sure, when Repository is really upated.

2ben7

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: EA_OnPreDeleteElement recognize deletion to la
« Reply #3 on: October 31, 2012, 11:19:06 pm »
Hi Paul,

but u forgot one nice problem :),
btw: i agree to what you said and i know the difference.

This event gets not triggered, if there are 2 diagrams in a Package. If i delete the package (which also result that the diagrams get deleted) i receive NO EA_OnPreDeleteDiagram event ->
EA_OnPreDeletePackage is triggered. So i don`t know which diagrams are updated.

So my great idea was to invoke SQL Query command again, but this result in the timing issues i described for my topic.

Yes, at the moment i use all 3 types of Delete methods.

Any ideas ?

Quote
A diagram is not the same as an element, you need to catch EA_OnPreDeleteDiagram for that  ;)

regards,

Paulus
« Last Edit: October 31, 2012, 11:22:13 pm by 2ben7 »

Paulus

  • EA User
  • **
  • Posts: 149
  • Karma: +0/-0
    • View Profile
Re: EA_OnPreDeleteElement recognize deletion to la
« Reply #4 on: October 31, 2012, 11:28:46 pm »
(sorry about x-posting)
What you could to is to start a timer in a separate thread that triggers an update of the control.

Alternatively instead of a timer just set a reload flag and catch the EA_OnContextItemChanged event that fires after each EA_OnPreDelete... event when deleting using the project browser. i think it will get fired after the element is destroyed so that would be a good moment to check the reload flag and refresh your control  8-).

best regards,

Paulus
« Last Edit: October 31, 2012, 11:30:21 pm by pmaessen »

2ben7

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: EA_OnPreDeleteElement recognize deletion to la
« Reply #5 on: November 01, 2012, 01:23:02 am »
thx in combination with ContextItemChanged, i could work it out !

Quote
(sorry about x-posting)
What you could to is to start a timer in a separate thread that triggers an update of the control.

Alternatively instead of a timer just set a reload flag and catch the EA_OnContextItemChanged event that fires after each EA_OnPreDelete... event when deleting using the project browser. i think it will get fired after the element is destroyed so that would be a good moment to check the reload flag and refresh your control  8-).

best regards,

Paulus