Enterprise Architect version 14.0

download
purchase

enzh-CNcsnlfrdehiiditkoplptruskessv

My Profile

Social Media Channels

facebook  twitter  youtube   linkedin

Wednesday, 28 October 2009 11:47

Swap Element Name and Alias Properties

Written by
Rate this item
(0 votes)

'Swap a Method or an Attribute
Private Sub Swap(obj)
    Dim sTmp

    If obj.Style <> "" And obj.Name <> "" Then
        sTmp = obj.Name
        obj.Name = obj.Style
        obj.Style = sTmp
           
        obj.Update
       
        Repository.AdviseElementChange obj.ParentID
    End If
   
    'Parameters of Method
    If obj.ObjectType = 24 Then
  Dim i
        For i = 0 To obj.Parameters.Count - 1
            SwapParameter obj.Parameters(i)
        Next
    End If
   
End Sub

'Swap Parameters
Private Sub SwapParameter(param)

    Dim sTmp
    If param.Alias <> "" And param.Name <> "" Then
        sTmp = param.Name
        param.Name = param.Alias
        param.Alias = sTmp
       
        param.Update
    End If
   
End Sub

'Swap ConnectorEnds
Private Sub SwapConnectorEnd(connEnd)

 Dim sTmp

    If connEnd.Role <> "" And connEnd.Alias <> "" Then
        sTmp = connEnd.Role
        connEnd.Role = connEnd.Alias
        connEnd.Alias = sTmp
       
        connEnd.Update
    End If
   
End Sub

'Swap an Element
Private Sub SwapElement(elem)
    Dim method
    Dim attr
 Dim conn
    Dim i
    Dim sTmp
   
    ' Methods of Element
    For i = 0 To elem.Methods.Count - 1
        Set method = elem.Methods.GetAt(i)
               
        Swap method
    Next
           
    'Attributes of Element
    For i = 0 To elem.Attributes.Count - 1
        Set attr = elem.Attributes.GetAt(i)
           
        Swap attr
    Next

    'Connectors of Elements
    For i = 0 To elem.Connectors.Count -1
  Set conn = elem.Connectors.GetAt(i)

  If elem.ElementID = conn.SupplierID then
   If conn.Alias <> "" And conn.Name <> "" Then
    sTmp = conn.Alias
    conn.Alias = conn.Name
    conn.Name = sTmp
    conn.update
   End If

   SwapConnectorEnd conn.SupplierEnd
   SwapConnectorEnd conn.ClientEnd
 
   Repository.AdviseConnectorChange conn.connectorID
  End If
    Next

 'Element Name
    If elem.Alias <> "" And elem.Name <> "" Then
        sTmp = elem.Name
        elem.Name = elem.Alias
        elem.Alias = sTmp
       
        elem.Update
       
        Repository.AdviseElementChange elem.ElementID
    End If
       
End Sub

'Swap a Package
Private Sub SwapPackage(pkg)

    'Elements in Package
    Dim elem
    Dim i
    For i = 0 To pkg.Elements.Count - 1
        Set elem = pkg.Elements.GetAt(i)
               
        SwapElement elem
    Next
    
    'Packages in Package
    Dim childPkg
   
    For i = 0 To pkg.Packages.Count - 1
        Set childPkg = pkg.Packages.GetAt(i)
       
        SwapPackage childPkg
    Next
   
    'Package Name
    Dim sTmp
    If pkg.Alias <> "" And pkg.Name <> "" Then
        sTmp = pkg.Name
        pkg.Name = pkg.Alias
        pkg.Alias = sTmp
       
        pkg.Update
    End If
   
End Sub


'Main Function
Sub Main()

 SwapPackage Repository.GetTreeSelectedPackage

 Msgbox "Completed."+vbcrlf+"Please reload all opened diagram."

End Sub

'Call the Main function
Main

Read 3954 times
tkouno

Takeshi Kouno

Sparx Systems Japan (Chief Executive Officer)
 
Sparx Systems Japan offers regional support and sales in Japan, and develops RaQuest and some Add-ins for Enterprise Architect. For detail, visit https://www.sparxsystems.jp/en/ .

https://www.sparxsystems.jp/en/
Login to post comments