Book a Demo

Author Topic: Diagram Link Styles  (Read 5838 times)

Martin Walke

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Diagram Link Styles
« on: May 07, 2010, 11:59:35 pm »
Hi all,

Can anyone help me in setting the style of a diagramlink?

When I read a link's style, I get "Mode=3;EOID=424B22C5;SOID=C83E62F7;Color=-1;LWidth=0;"

I want to set the colour but a) what do the other parameters mean (the non-obvious ones) and b) do I have to set all of them or just the one I want to change.

I've tried just setting "color=255;" and doing a .Update but it doesn't seem to work.

I think I understand how the diagramlink vs connectors work but where is this info actually documented. :-?

TIA
Martin

Martin Walke

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Diagram Link Styles
« Reply #1 on: May 10, 2010, 07:45:45 pm »
Ok - exploring further, and looking at other forum posts particularly
http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1250840058, the links that I want to manipulate exist in the t_diagramlinks table but if I use the Ishidden property, it doesn't work but if I modify the EAP file directly I had hide and show the link.

Has anyone had any joy at all in manipulating the diagram links from the API?

If I use SQL injection it seems works correctly.

Is this a bug?

« Last Edit: May 10, 2010, 07:48:20 pm by MartinWalke »

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Diagram Link Styles
« Reply #2 on: May 10, 2010, 09:55:46 pm »
Hi Martin,

Try:

Code: [Select]
EADiagram.DiagramLinks.Delete(iEADiagramLinkIndex);
EADiagramLink.IsHidden = true;
EADiagramLink.Update();

You need to iterate through the set of DiagramLinks until you find the right one, delete it from the collections then set the IsHidden to true.

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Diagram Link Styles
« Reply #3 on: May 10, 2010, 09:57:20 pm »
Martin,

Could you post a snippet of the code you are using to manipulate the style?

I guess you do know that you have to refresh the diagram before the changes are visible?

Geert

Martin Walke

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Diagram Link Styles
« Reply #4 on: May 10, 2010, 11:04:15 pm »
Hi guys,

My bad!

I thought I'd got this figured out but what was happening was - it was creating the links when I did a .LayoutDiagramEx call but I was trying to manipulate the links before that. :-[

However, having got that sorted and yes Geert I did realise I had to refresh the diagram  ;), it doesn't show the change until I close and reopen the diagram.

Here's my
Code: [Select]


Public Function ChangeStyle(DLinkStyle As String, parameter As String, value As String) As String

  Dim parms
  Dim i As Integer
  Dim found As Boolean

  ChangeStyle = DLinkStyle
  parms = Split(DLinkStyle, ";")
  found = False
  For i = 0 To UBound(parms) - 1
  
    If UCase(Split(parms(i), "=")(0)) = UCase(parameter) Then
      parms(i) = parameter & "=" & value
      found = True
      Exit For
    End If
  Next
  
  If found Then ChangeStyle = Join(parms, ";")

End Function

=================================

For i = 1 To UBound(ConstraintValues)
  
    For j = 0 To dia.DiagramLinks.Count - 1
      Set dl = dia.DiagramLinks.GetAt(j)
      If dl.ConnectorID = ConstraintValues(i).ConnectorID Then        
        dl.Style = ChangeStyle(dl.Style, "Color", "255")
        dl.Update
        Exit For
      End If
    Next
  
  Next
    
  getCurrentRepository.RefreshOpenDiagrams False

ConstraintValues() is simply structure array (the structure contains the ConnectorId and other info) that contains a list of those connectors that have constraints defined against them.

The whole purpose here is to show, on the diagram via colours, which connectors have constraints and which don't.

Martin

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Diagram Link Styles
« Reply #5 on: May 10, 2010, 11:17:50 pm »
Hi Martin,

I'm happy you figured it out.
Nice idea to give the relations with constraints a different color, I can really see the usefulness of that.

Geert

Martin Walke

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Diagram Link Styles
« Reply #6 on: May 10, 2010, 11:20:52 pm »
Thanks Geert.

The problem sort of still exists, in that I have to close and open the diagram before I can see the coloured links. Even though I'm using RefreshOpenDiagrams what else should I be doing?


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Diagram Link Styles
« Reply #7 on: May 10, 2010, 11:42:26 pm »
What happens if you change the parameter to true?
Or otherwise you could refresh each diagram separately using Repository.ReloadDiagram (long DiagramID) (allows you to only reload those diagrams that actually have been changed)

If that doesn't work you could close the diagrams with Repository.CloseDiagram (long DiagramID) and open them again with Repository.OpenDiagram (long DiagramID).

Geert




Martin Walke

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Diagram Link Styles
« Reply #8 on: May 11, 2010, 12:08:27 am »
Perfect! Thanks Geert.

I'd already tried .RefreshOpenDiagrams True but reloading the diagram sorted it out.

Great! [smiley=thumbsup.gif]