Book a Demo

Author Topic: Event in project browser  (Read 4667 times)

damien

  • EA User
  • **
  • Posts: 41
  • Karma: +0/-0
    • View Profile
Event in project browser
« on: July 03, 2008, 11:42:08 pm »
Hello,

i would perform an action when a new element is added to my diagram, i redefine the Function EA_OnPreNewElement method. It's work but i have a problem when i add a new element in my diagram by drag and drop from an existing element from the project browser the EA_OnPreNewElement isn't call.

What is the method to redefine to perform my action ?


«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Event in project browser
« Reply #1 on: July 04, 2008, 12:02:11 am »
For some reason this event seems not to fire when a new element is added via the toolbox. The 'post' event does fire. Note though that most of the element properties are not filled in when that event fires (at least in the case of the toolbox 'version' of the event); they are set when EA's properties dialog exits, or when your code finishes up (if you cancel the EA handler).

This presents all kinds of difficulties, including your situation. The problem has been discussed in the forum before, but I don't think the Sparxians offered comments or dealt with the problem.

Perhaps you'd care to report this as a bug, which might help getting it resolved - the more of us who report it the better chance it will make the list for upcoming resolution - regardless of whether you can make your add-in work with the 'post' event.

You'll find the appropriate bug report form by clicking the Report a Bug link below the Support link near the bottom of any forum page. Please post back if Sparx responds to keep the rest of us informed.

David
No, you can't have it!

damien

  • EA User
  • **
  • Posts: 41
  • Karma: +0/-0
    • View Profile
Re: Event in project browser
« Reply #2 on: July 04, 2008, 12:16:19 am »
Thanks you for your answer, i will report this bug and keep you inform of their answer.

damien

  • EA User
  • **
  • Posts: 41
  • Karma: +0/-0
    • View Profile
Re: Event in project browser
« Reply #3 on: July 04, 2008, 05:42:59 pm »
The answer of the bug report (Thank for their very quickly answer) :

When dragging an existing item from the Project Browser onto the
diagram, you are not actually creating a new element, just a reference
to an existing element.  There is no broadcast event for adding an
existing element to a diagram.

The only time this drag-and-drop action will result in a new element is
if you are creating an "Instance" of the element, or a 'Generalization'.


Apparently, it's not possible to perform an action when an existing element is added to a diagram via the project browser
« Last Edit: July 04, 2008, 05:45:21 pm by damien »

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Event in project browser
« Reply #4 on: July 04, 2008, 10:07:58 pm »
That makes sense as far as it goes.

But there should be some form of event or signal when something is added to a diagram, regardless of where it came from.

You can almost feel this if you take a look at the AdviseElementChange and AdviseConnector change methods of the Repository class. These fire events (within EA, perhaps not to an add-in) that update diagram objects and links when their 'parents' are changed. IMHO EA should complete the loop here, and advise running code when an instance is created (or changed or deleted). This would be a separate (but similar) call to the 'element' and 'connector' event sets. After all, instances are model components too...

Since you are closest to this now, perhaps you'd make the feature request. I suggest you start a new thread in the Suggestions section, and post the details there. Then make a feature request to Sparx and paste in the name and URL of the thread. Finally, post back to the thread and let us know what Sparx says (now that this is a requested feature rather than a support query).

The above is a 'local best practice' that's often used here in the forum. It allows Sparx to participate in any resulting discussion. Often some useful refinements are proposed, and sometimes even workarounds.

David
No, you can't have it!

damien

  • EA User
  • **
  • Posts: 41
  • Karma: +0/-0
    • View Profile
Re: Event in project browser
« Reply #5 on: July 07, 2008, 05:58:48 pm »
I make a feature request : here