Book a Demo

Author Topic: reloaddiagram - system crash  (Read 4390 times)

Danny F

  • EA User
  • **
  • Posts: 60
  • Karma: +0/-0
    • View Profile
reloaddiagram - system crash
« on: March 13, 2013, 09:24:09 pm »
     hi

the requirement :
- 2 states on a statechart diagram.
- when the user connects, disconnects or re-routes a connection between these to diagramobjects, the diagramobject changes color.

Solution (mine) :
- on a 'connect' action do a :
           Repository.SaveDiagram
           Repository.ReloadDiagram

For newly created connections and a delete of a connector this works.

When re-routing a connector (to a third state object) the system crashes.

this happens under EA 9.3 and EA 10.0
(Windows reports that they searching for a solutions but I don't really have a lot of faith in that  ;D )

a few more details for those who would want to investigate this ;)

For a new connection : the saveload is done in the EA_OnPostNew Connector

For a delete of a connection there is a trick to it :
The saveload is done in the EA_OnNotifyContextItemChanged on the diagram, which follows the delete action

For a re-route :
- saveload in the EA_OnNotifyContextItemModified : Crash

- the same trick as for delete doesn't work, because there is no EA_OnNotifyContextItemModified on the diagram following the re- routing  


Anybody any ideas ?

Many thanks in advance.







Reg.

Danny

Paulus

  • EA User
  • **
  • Posts: 152
  • Karma: +0/-0
    • View Profile
Re: reloaddiagram - system crash
« Reply #1 on: March 14, 2013, 08:16:12 am »
I played a bit with this and came up with the following snippet that will change the color of the source of the connector when re-routing, without needing a diagram save or refresh  8-).

Perhaps not very elegant but it demonstrates the point. Btw this works for new connectors as well, but not for deletes.

best regards,

Paulus

Code: [Select]
Sub EA_OnNotifyContextItemModified(GUID,ot)
    dim dgm as EA.Diagram
    set dgm = Repository.GetCurrentDiagram()
    if (ot = 7) then
        dim conn as EA.Connector
        set conn = GetConnectorByGuid(GUID)
        dim dgmObj as EA.DiagramObject
        for each dgmObj in dgm.DiagramObjects
            if dgmObj.ElementId = conn.ClientID then
                dgmObj.Style = "BCol=255;BFol=9342520;LCol=9342520;LWth=1;"
                dgmObj.Update
          end if
        next
    end if
end sub

Danny F

  • EA User
  • **
  • Posts: 60
  • Karma: +0/-0
    • View Profile
Re: reloaddiagram - system crash
« Reply #2 on: March 14, 2013, 05:43:01 pm »
Thanks Paulus

I set the color on the element, not on the DiagramObject.
There are in fact potentially a lot of nodes that need to change color when one connector is changed. And I wanted to avoid having to do the loops.

But maybe there lays my mistake ?
Reg.

Danny

Paulus

  • EA User
  • **
  • Posts: 152
  • Karma: +0/-0
    • View Profile
Re: reloaddiagram - system crash
« Reply #3 on: March 14, 2013, 06:11:49 pm »
Ehrm... no in fact makes perfect sense :-[.

I also got the error when calling save & reload but have you tried just calling update on the element and leave it at that?

Replacing the loop on diagramobjets with the snippet below seems to do the trick.

Code: [Select]
dim elt as EA.Element
set elt = Repository.GetElementByID(conn.ClientID)
elt.SetAppearance 1,3,3
elt.SetAppearance 1,0,100
elt.update()
« Last Edit: March 14, 2013, 06:14:48 pm by pmaessen »

Danny F

  • EA User
  • **
  • Posts: 60
  • Karma: +0/-0
    • View Profile
Re: reloaddiagram - system crash
« Reply #4 on: March 14, 2013, 07:14:59 pm »
Quote
have you tried just calling update on the element and leave it at that?

 :-[ :-[ No - why not, I don't know .......

It works  - soooo simple - thanks a million

Reg.

Danny

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: reloaddiagram - system crash
« Reply #5 on: March 14, 2013, 08:23:34 pm »
Just to make things clear: the element based appearance is valid immediately for all occurrences of the element in any diagram. Except - it's locally overwritten with an appearance for the single diagram. So if it's some global appearance you should store it in the single element via SetAppearance. Else you need to place it specifically in the single diagram objects in the Style property. (Orthogonality rules?)

q.
« Last Edit: March 14, 2013, 08:26:59 pm by qwerty »