前页 | 后页 |
EA_GetCompartmentData
This event occurs when Enterprise Architect is instructed to redraw an element. It requests that the Add-In provide the data to populate the element's compartment.Syntax
Function EA_GetCompartmentData (Repository As EA.Repository, sCompartment As String, sGUID As String, oType As EA.ObjectType) As VariantThe EA_QueryAvailableCompartments function syntax contains these parameters.
Parameter |
Type |
See also |
---|---|---|
Repository |
EA.Repository Direction: IN Description: An EA.Repository object representing the currently open Enterprise Architect model. Poll its members to retrieve model data and user interface status information. |
Repository Class |
sCompartment |
String Direction: IN Description: The name of the compartment for which data is being requested. |
|
sGUID |
String Direction: IN Description: The GUID of the element for which data is being requested. |
|
oType |
ObjectType Direction: IN Description: The type of the element for which data is being requested. |
ObjectType |
Return Value
A variant containing a formatted string. The format is illustrated in this example:Example
Function EA_GetCompartmentData(Repository As EA.Repository, sCompartment As String, sGUID As String, oType As EA.ObjectType) As VariantIf Repository Is Nothing Then
Exit Function
End If
Dim sCompartmentData As String
Dim oXML As MSXML2.DOMDocument
Dim Nodes As MSXML2.IXMLDOMNodeList
Dim Node1 As MSXML2.IXMLDOMNode
Dim Node As MSXML2.IXMLDOMNode
Dim sData As String
sCompartmentData = ""
Set oXML = New MSXML2.DOMDocument
sData = ""
On Error GoTo ERR_GetCompartmentData
oXML.loadXML (Repository.GetTreeXMLByGUID(sGUID))
Set Node1 = oXML.selectSingleNode("//ModelItem")
If Node1 Is Nothing Then
Exit Function
End If
sCompartmentData = sCompartmentData + "Name=" + sCompartment + ";"
sCompartmentData = sCompartmentData + "OwnerGUID=" + sGUID + ";"
sCompartmentData = sCompartmentData + "Options=SkipIfOnDiagram&_eq_^1&_sc_^"
Select Case sCompartment
Case "parts"
Set Nodes = Node1.selectNodes("ModelItem(@Metatype=""Part"")")
For Each Node In Nodes
sData = sData + "Data&_eq_^" + Node.Attributes.getNamedItem("Name").nodeValue + "&_sc_^"
sData = sData + "GUID&_eq_^" + Node.Attributes.getNamedItem("GUID").nodeValue + "&_sc_^,"
Next
Case "ports"
Set Nodes = Node1.selectNodes("ModelItem(@Metatype=""Port"")")
For Each Node In Nodes
sData = sData + "Data&_eq_^" + Node.Attributes.getNamedItem("Name").nodeValue + "&_sc_^"
sData = sData + "GUID&_eq_^" + Node.Attributes.getNamedItem("GUID").nodeValue + "&_sc_^,"
Next
End Select
If there is no data to display, then don't return any compartment data
If sData <> "" Then
sCompartmentData = sCompartmentData + "CompartmentData=" + sData + ";"
Else
sCompartmentData = ""
End If
EA_GetCompartmentData = sCompartmentData
Exit Function
ERR_GetCompartmentData:
EA_GetCompartmentData = ""
End Function