Book a Demo

Author Topic: moving connectors  (Read 3354 times)

gpc

  • EA User
  • **
  • Posts: 111
  • Karma: +0/-0
    • View Profile
moving connectors
« on: October 14, 2007, 11:59:44 pm »
Hi,
Relative newbie to automation interface.
I wish to replace one class with another within a project. This works fine so far, but when it comes to sequence diagrams I've hit a bit of a problem http://www.sparxsystems.com/yabbimages/sad.gif
Sad.
I can created a new DiagramObject, but how do I move a connector from one Element to another. Simply changing the ID tags doesn't seem to work and I'm not sure how these relate to the "owning" Element.
Any help greatly appreciated.
Thanks.
:-[

gpc

  • EA User
  • **
  • Posts: 111
  • Karma: +0/-0
    • View Profile
Re: moving connectors
« Reply #1 on: October 15, 2007, 02:46:26 am »
Just to clarify; I have, say, class1 calling func1 of class2 in a sequence diagram. I wish to convert this to class1 calling func1 of class3 or class3 calling func1 of class2.
This is easy enough to do via the user interface, but how do I do this via the automation interface?

zgraja

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: moving connectors
« Reply #2 on: November 26, 2007, 07:19:22 am »
I've had the same problem. I was trying to replace one class by another. I have inserted new class through automation interface into the diagram, created a copy of all messages belonging to old class and than deleted old class with its messages, but the new messages didn't ocupy positions of deleted messages on the timeline of inserted classifier. The order was the same, but positions not. I was searching on possibility to move message through AutInt up or down on the timeline to correct this, but didn't find. I didn't find even possibility to read position of the message on the timeline. But there is a possibility to move message from one class object to another without creating any copies of messages. Function MoveMessages on listing below, moves all messages connected to element EFrom to element ETo on diagram Diagram (EFrom and ETo must exist on the diagram before this function is called). I hope it will help.

   Private Function MoveMessages(ByVal Diagram As EA.Diagram, ByVal EFrom As EA.Element, ByVal ETo As EA.Element) As Boolean
       Dim i As Integer
       Dim m1 As EA.Connector
       Dim counter As Integer

       counter = EFrom.Connectors.Count
       If counter = 0 Then
           Return True
       End If
       For i = 0 To counter - 1
           m1 = EFrom.Connectors.GetAt(i)
           If m1.DiagramID = Diagram.DiagramID Then
               If m1.ClientID = EFrom.ElementID Then
                   m1.ClientID = ETo.ElementID
               End If
               If m1.SupplierID = EFrom.ElementID Then
                   m1.SupplierID = ETo.ElementID
               End If
               If m1.Update Then
                   EFrom.Update()
                   ETo.Update()
               Else
                   MsgBox(m1.GetLastError())
                   Return False
               End If
           End If
       Next
       Return True
   End Function