Book a Demo

Author Topic: Java API, react to change on diagram  (Read 7291 times)

gervais.b

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Java API, react to change on diagram
« on: November 02, 2016, 06:31:27 pm »
Hi there,

I have a Java app that use the Java API Bridge to query our enterprises repository. I would like to have this app, running as standalone, notified when an user changes something in a diagram.
Ideally I would like to warn the user about the consequence of his changes and trigger a long running process on my Java app if he confirm.

The first idea would be to create one add-in that would listen for changes and call a REST service when the user agree. But I have no idea on how to listen for changes on one specific diagram.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Java API, react to change on diagram
« Reply #1 on: November 02, 2016, 07:13:48 pm »
You have to use an add-in in order to be able to react to events in EA.

Unfortunately you cannot write add-ins in Java, only .Net

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Java API, react to change on diagram
« Reply #2 on: November 02, 2016, 08:24:36 pm »
A simple reason for the need of an add-in is that diagram changes are made local to a user in memory. Only when a save is issued, data are written to the database.

q.

gervais.b

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Java API, react to change on diagram
« Reply #3 on: November 02, 2016, 08:44:15 pm »
Only when a save is issued, data are written to the database.

Then ideally I would like to react "on_pre_save"

Unfortunately you cannot write add-ins in Java, only .Net
Thanks, that's a minor problem.
« Last Edit: November 02, 2016, 08:46:19 pm by gervais.b »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Java API, react to change on diagram
« Reply #4 on: November 02, 2016, 11:06:10 pm »
There's only EA_OnPostCloseDiagram (see http://www.sparxsystems.com/enterprise_architect_user_guide/13.0/automation/broadcastevents.html

q.

P.S. Don't forget to check out Geert's blog about writing an add-in.

gervais.b

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Java API, react to change on diagram
« Reply #5 on: November 02, 2016, 11:50:26 pm »
Because the idea would be to react when the user move or add one Component to a Node into a deployment diagram. Is it other/cleaner solutions than listening for EA_OnPostCloseDiagram event or polling the Diagram.ModifiedDate ?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Java API, react to change on diagram
« Reply #6 on: November 03, 2016, 06:13:29 am »
You could either subscribe to EA_OnPostNewDiagramObject (added something to a diagram) and/or EA_OnPostNewElement (any entirely new element).

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Java API, react to change on diagram
« Reply #7 on: November 03, 2016, 07:27:36 pm »
It seems like you should be checking the actual connection between the node and the component, not the location on the diagram.
You can do that by subscribing to the context events, checking the relation between the node and the component when it gets selected, and when something else gets selected.

The articles qwerty was referring too can be found here: http://bellekens.com/writing-ea-add-ins/

Geert