Author Topic: Broadcast Events - COM API  (Read 3910 times)

Dave Akehurst

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Broadcast Events - COM API
« on: June 25, 2014, 11:41:02 pm »
If I write an EA add-in I can write code that responds to a 'broadcast event'
[http://www.sparxsystems.com/enterprise_architect_user_guide/10/automation_and_scripting/broadcastevents.html]

e.g.
public void EA_OnContextItemChanged(EA.Repository Repository, string GUID, EA.ObjectType ot) {
}

How do I write similar code to respond to these broadcast events if I am writing an application that is no an add-in but is similarly using the COM API?

This should be possible, seeing as add-ins are similarly using the COM API.

I would expect the tlb file(s) to have some kind of event interface in them to which I can subscribe!

thanks

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13065
  • Karma: +544/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Broadcast Events - COM API
« Reply #1 on: June 25, 2014, 11:51:58 pm »
It only works if your application is an add-in.

"Broadcasted events" is really a euphemism for "we call an operation with a specific name on all registered add-ins"

So when EA changes context it loops all registered add-ins, checks of they have declared a public operation with the signature EA_OnContextItemChanged(EA.Repository , string , EA.ObjectType )
and then calls that operation.

Can I ask why you don't want to create an add-in? I don't really see the downside.

Geert

Dave Akehurst

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Broadcast Events - COM API
« Reply #2 on: June 26, 2014, 01:10:59 am »
>"Broadcasted events" is really a euphemism for "we call an operation with a specific name on all registered add-ins"

hmm....poor API.
How do I get sparx to provide a proper event api for this then? :-)

I don't want to use an add-in primarily because I am using java over com to interact with EA from an eclipse plugin.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Broadcast Events - COM API
« Reply #3 on: June 26, 2014, 01:45:26 am »
Wow - Java over COM and Eclipse on top of that? Somebody likes pain. :)

So to add to that pain, you can always write a simple Add-In which just forwards "events" from EA to your Eclipse plug-in over whatever protocol you prefer.

As of EA 11, you can load Add-Ins after starting EA from the automation interface. So you could have your Eclipse plug-in start EA, hide the window, connect to the repository, load the Add-Ins and sit back and wait for the events to roll in.

As long as you stick to the one-way events (void functions) you should be OK. Adding support for two-way ones (bool functions which wait for a response) would be another level of pain.

/Uffe
My theories are always correct, just apply them to the right reality.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13065
  • Karma: +544/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Broadcast Events - COM API
« Reply #4 on: June 26, 2014, 04:16:36 pm »
Quote
How do I get sparx to provide a proper event api for this then? :-)

Send in a Feature Request and then wait and hope (and pray?)

Geert

Dave Akehurst

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Broadcast Events - COM API
« Reply #5 on: June 26, 2014, 10:10:54 pm »
> As of EA 11, you can load Add-Ins after starting EA from the automation interface.

thanks, is this documented somewhere?

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Broadcast Events - COM API
« Reply #6 on: June 26, 2014, 10:33:06 pm »
In the Help file, Automation and Scripting -- Enterprise Architect Object Model -- Reference -- Repository Package -- Repository Class.

The method is called LoadAddins() aaaaaand that's it. But according to http://www.sparxsystems.com/products/ea/history.html, it "allows add-ins to be loaded when Enterprise Architect is opened from automation".

When using new features like this, you can use Repository.LibraryVersion to check which version of the EA runtime you're running against. This may or may not be of use to you depending on your deployment situation.

/Uffe
My theories are always correct, just apply them to the right reality.