Author Topic: Model based add-in not picking up new diagram version  (Read 2325 times)

PeteC

  • EA User
  • **
  • Posts: 91
  • Karma: +1/-0
    • View Profile
Model based add-in not picking up new diagram version
« on: April 28, 2022, 08:43:05 pm »
I have written a model based add-in that interrogates the value of the diagram version on diagram close, using the EA_OnPostCloseDiagram event. If the user has edited the diagram version but NOT clicked out (so the cursor is still active in the version box) then the new value is not picked up with theDiagram.Version (where theDiagram is the current diagram that is being closed), which results in my add-in not working as expected as it does not have what the user thinks is the version number. If the user clicks elsewhere and then closes the diagram the new value is picked up (which means my add-in works as expected).

I've tried adding Repository.SaveDiagram(theDiagram.DiagramID) but even that does not cause the new version to be detected.

Inevitably users will not remember to click out of the box (even I have forgotten and could not initially work out why it was not working a couple of months after writing it). Is there any way that I can force a new entry that has been entered to be picked up within the add-in? I imagine this applies to any text field that is being entered at the time of diagram close so could catch out add-ins written by others as well.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Model based add-in not picking up new diagram version
« Reply #1 on: April 28, 2022, 11:32:58 pm »
I would guess you are left to (more) try and error. EA has a couple of GUI design flaws and bugs. I feel with you...

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13402
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Model based add-in not picking up new diagram version
« Reply #2 on: April 29, 2022, 02:58:31 am »
If you are lucky, a combination of SaveDiagram + Repository.GetDiagramByID might result in an object with the correct version.

Geert

PeteC

  • EA User
  • **
  • Posts: 91
  • Karma: +1/-0
    • View Profile
Re: Model based add-in not picking up new diagram version
« Reply #3 on: April 29, 2022, 06:46:01 pm »
So Geert's suggestion seems to work - the add-in has to re-read the diagram to pickup changes made when saved, that's perhaps not unreasonable but easy to miss.

However, that introduces (for me) another disadvantage that the diagram modified date is ALWAYS changed. That's a disadvantage as I am auto-incrementing the diagram version if any changes are made (if the user manually saves the diagram then the modified date has changed and if the diagram tab is prefixed with a * then my add-in enforces a save as it knows the diagram is updated but not saved, which also updates the modified date). My decision on whether the diagram has been modified (rather than just opened and closed) is based on the modified date changing.

The step of enforced saving means that opening and closing the diagram causes the version to auto-increment as the modified date is changed.

I tried changing SaveDiagram to the CloseDiagram method but that just resulted in EA closing (I assume crashing - CloseDiagram appears to be incompatible with the EA_OnPostCloseDiagram event.

Unless there is any other method I can use to enforce field entries to be updated, the only alternative I have at the moment is to enforce opening the system output and displaying a message in the state when it is possible that the user has failed to click out of the field entry (I know I could also display a dialog box, but that will become more annoying given that the majority of the time opening and closing a diagram without modification does not merit attention).

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13402
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Model based add-in not picking up new diagram version
« Reply #4 on: April 29, 2022, 07:07:58 pm »
You might be able to achieve the wanted result using a database trigger.

I know database triggers are frowned upon, but it would work.

Geert

Daiim

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Model based add-in not picking up new diagram version
« Reply #5 on: May 02, 2022, 05:20:44 am »
I'd guess database also is only updated when EA stores the diagram properties and that is earliest (if not explicitly saved) when the input field looses fokus. Or am I wrong?

I have had a couple of discussions with architects that wanted to know how to do versioning with EA. Maybe you can explain a bit deeper what you try to achive with your approach.
In these talks it always pointed out, that the understanding of modelling lagged some of these points:
  • Fact: diagrams are NOT part of your model
  • Case 1: visual changes (layout, colors, ..)
  • Case 2: diagram content changes (visualized artifacts/links)
  • Case 3: model changes via diagram (added/deleted artifacts links within model scope)
1) Changes within diagrams are reflected with the "Modified Date"
2) Changes within visualized model subsets can be reflected with the version number (this can be catched with events for adding/deleting diagram objects/links)
3) Changes within the model can be catched up with events for adding/deleting (model) artifacts/links. as changes to the model will change (in general) multiple diagrams, this case usually requires a higher versioning concept to track/restore changes for diagrams, e.g. baselining.

« Last Edit: May 02, 2022, 06:03:31 am by Daiim »