@@ -73,7 +73,7 @@ export class DgmlManager {
73
73
}
74
74
}
75
75
76
- public addNodesAndLinks ( xmlDoc : Document , nodes : Node [ ] , nodeInfoDictionary : { [ id : string ] : NetworkNode } , edges : Edge [ ] ) {
76
+ public addNodesAndLinks ( xmlDoc : Document , nodes : Node [ ] , nodeInfoDictionary : { [ id : string ] : NetworkNode } , edges : Edge [ ] ) {
77
77
const nodesElement = this . addNodeToRoot ( xmlDoc , "Nodes" ) ;
78
78
const linksElement = this . addNodeToRoot ( xmlDoc , "Links" ) ;
79
79
const categoryDictionary : { [ nodeType : string ] : Category } = { } ;
@@ -84,13 +84,16 @@ export class DgmlManager {
84
84
this . generateDirectedGraphNodesXml ( xmlDoc , node , nodesElement ) ;
85
85
const categoryId = NodeType [ node . nodeType ] ;
86
86
if ( ! ( categoryId in categoryDictionary ) ) {
87
- categoryDictionary [ categoryId ] = new Category ( categoryId , categoryId , node . getNodeTypeColor ( node . nodeType ) , '' ) ;
87
+ categoryDictionary [ categoryId ] = new Category ( categoryId , categoryId , node . getNodeTypeColor ( node . nodeType ) , '' , '' ) ;
88
+ }
89
+ if ( ! ( 'File' in categoryDictionary ) ) {
90
+ categoryDictionary [ 'File' ] = new Category ( 'File' , '' , '' , '' , 'File' ) ;
88
91
}
89
92
} ) ;
90
93
edges . forEach ( edge => {
91
94
const categoryId = ArrowType [ edge . arrowType ] ;
92
95
if ( ! ( categoryId in categoryDictionary ) ) {
93
- categoryDictionary [ categoryId ] = new Category ( categoryId , categoryId , '' , edge . getEdgeTypeColor ( edge . arrowType ) ) ;
96
+ categoryDictionary [ categoryId ] = new Category ( categoryId , categoryId , '' , edge . getEdgeTypeColor ( edge . arrowType ) , '' ) ;
94
97
}
95
98
this . generateDirectedGraphLinksXml ( xmlDoc , edge , linksElement ) ;
96
99
} ) ;
@@ -127,9 +130,10 @@ export class DgmlManager {
127
130
if ( node . tsFilename ) {
128
131
nodeElement . setAttribute ( "TypescriptFilepath" , node . tsFilename ) ;
129
132
}
133
+ this . addCategoryRef ( xmlDoc , nodeElement , 'File' ) ;
130
134
this . addNode ( nodesElement , nodeElement ) ;
131
135
}
132
-
136
+
133
137
private calculateBounds ( position : Position , boundingBox : BoundingBox ) : string {
134
138
const width = boundingBox . right - boundingBox . left ;
135
139
const height = boundingBox . bottom - boundingBox . top ;
@@ -141,17 +145,28 @@ export class DgmlManager {
141
145
this . addLinkNode ( xmlDoc , linksElement , edge . source , edge . target , categoryId ) ;
142
146
}
143
147
148
+ private addCategoryRef ( xmlDoc : Document , node : Element , categoryRef : string ) {
149
+ const categoryElement = xmlDoc . createElement ( "Category" ) ;
150
+ categoryElement . setAttribute ( "Ref" , categoryRef ) ;
151
+ node . appendChild ( categoryElement ) ;
152
+ }
153
+
144
154
private addCategory ( xmlDoc : Document , categoriesElement : Element | null , category : Category ) {
145
- if ( categoriesElement !== null && ( category . backgroundColor || category . stroke ) ) {
155
+ if ( categoriesElement !== null && ( category . backgroundColor || category . stroke || category . icon ) ) {
146
156
const categoryElement = xmlDoc . createElement ( "Category" ) ;
147
157
categoryElement . setAttribute ( "Id" , category . id ) ;
148
- categoryElement . setAttribute ( "Label" , category . label ) ;
158
+ if ( category . label ) {
159
+ categoryElement . setAttribute ( "Label" , category . label ) ;
160
+ }
149
161
if ( category . backgroundColor ) {
150
162
categoryElement . setAttribute ( "Background" , category . backgroundColor ) ;
151
163
}
152
164
if ( category . stroke ) {
153
165
categoryElement . setAttribute ( "Stroke" , category . stroke ) ;
154
166
}
167
+ if ( category . icon ) {
168
+ categoryElement . setAttribute ( "Icon" , category . icon ) ;
169
+ }
155
170
categoryElement . setAttribute ( "IsTag" , "True" ) ;
156
171
this . addNode ( categoriesElement , categoryElement ) ;
157
172
}
@@ -180,7 +195,7 @@ export class DgmlManager {
180
195
const propertyElement = xmlDoc . createElement ( "Property" ) ;
181
196
propertyElement . setAttribute ( "Id" , idValue ) ;
182
197
propertyElement . setAttribute ( "DataType" , datatypeValue ) ;
183
- if ( label !== undefined && label . length > 0 ) {
198
+ if ( label !== undefined && label . length > 0 ) {
184
199
propertyElement . setAttribute ( "Label" , label ) ;
185
200
}
186
201
if ( isReference !== undefined && isReference ) {
0 commit comments