Author Topic: How to update DiagramLinks when add connector  (Read 3510 times)

x_honzi

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
How to update DiagramLinks when add connector
« on: July 15, 2009, 05:23:40 pm »
Hi,
Could you please someone tell me how to update DiagramLinks when add connector? It is not forwarded to it. In EA GUI it works fine. So there must be called something immediately after adding of connector but I tried several update and refresh methods and nothing worked.

Thank you

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: How to update DiagramLinks when add connector
« Reply #1 on: July 15, 2009, 09:08:26 pm »
Refresh or reload the diagram. Perhaps also reload the project, but work from the diagram 'outwards' until you get the right one.

You will find the Refresh and Reload methods for diagrams on the Repository class. You will also find a Refresh method for the model view. The method to Reload the project is on the Project class.
No, you can't have it!

x_honzi

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: How to update DiagramLinks when add connector
« Reply #2 on: July 16, 2009, 05:26:17 am »
Hi,
I tried for example this everything in same time:

Dim project As EA.Project=MyRepository.GetProjectInterface()
project.ReloadProject()
diagram.DiagramLinks.Refresh()
diagram.DiagramObjects.Refresh()
diagram.Update()
package.Update()
MyRepository.ReloadDiagram(diagram.DiagramID)

And still nothing works. Maybe it's not possible. By the way DiagramLinks.AddNew works somehow I don't know how because it added row with some strange values to database table t_diagramlinks but you know I need to add concrete connector to DiagramLinks that has been added to diagram before and which exists in element.connector collection.

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: How to update DiagramLinks when add connector
« Reply #3 on: July 16, 2009, 10:01:59 am »
A DiagramLink record is not automatically created after adding a Connector.  If no DiagramLink record exists in the database, the Connector will still be drawn on the diagram in EA using default values.  A DiagramLink record is typically not created by EA until the user makes a change to the location or appearance of the connector on the diagram.

If you wish to explicitly create a DiagramLink record for your new Connector, something like the following code should help accomplish this task.

Code: [Select]
Public Function CreateDiagramLink(ByRef conn As EA.Connector, ByRef diag As EA.Diagram, ByVal bIsHidden As Boolean) As EA.DiagramLink
    Dim newlink As EA.DiagramLink
    Set newlink = diag.DiagramLinks.AddNew("", "")
    newlink.ConnectorID = conn.ConnectorID
    newlink.IsHidden = bIsHidden
    newlink.Update
    Set CreateDiagramLink = newlink
End Function
With both DiagramObject and DiagramLink records, be careful that you do not add a duplicate record for the same object.  This can have undefined results when viewing through EA.

x_honzi

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: How to update DiagramLinks when add connector
« Reply #4 on: July 17, 2009, 04:55:38 pm »
Hi,
I've found my problem more complicated but it's solved through database. Thank you anyway, it might be helpful exactly for this problem I've posted.