@@ -18,40 +18,40 @@ import javax.swing.Icon
18
18
* Element manager for Graphviz diagrams
19
19
* Similar to JdlUmlElementManager in JHipster UML implementation
20
20
*/
21
- class GraphvizElementManager : AbstractDiagramElementManager <GraphvizNodeData >() {
22
- override fun findInDataContext (dataContext : DataContext ): GraphvizNodeData ? {
21
+ class CodeTopologyElementManager : AbstractDiagramElementManager <GraphNodeData >() {
22
+ override fun findInDataContext (dataContext : DataContext ): GraphNodeData ? {
23
23
val psiFile = CommonDataKeys .PSI_FILE .getData(dataContext) ? : return null
24
24
val virtualFile = psiFile.virtualFile ? : return null
25
25
if (! isDotFile(virtualFile)) return null
26
26
return getRootData(psiFile.project, virtualFile)
27
27
}
28
28
29
29
override fun isAcceptableAsNode (element : Any? ): Boolean {
30
- return element is GraphvizEntityNodeData || element is GraphvizSimpleNodeData
30
+ return element is GraphEntityNodeData || element is GraphSimpleNodeData
31
31
}
32
32
33
33
/* *
34
34
* Get node items (fields for entities, attributes for simple nodes)
35
35
*/
36
- override fun getNodeItems (nodeElement : GraphvizNodeData ): Array <Any > {
36
+ override fun getNodeItems (nodeElement : GraphNodeData ): Array <Any > {
37
37
return when (nodeElement) {
38
- is GraphvizEntityNodeData -> nodeElement.getFields().toTypedArray()
39
- is GraphvizSimpleNodeData -> {
38
+ is GraphEntityNodeData -> nodeElement.getFields().toTypedArray()
39
+ is GraphSimpleNodeData -> {
40
40
nodeElement.getAttributes().map { (key, value) ->
41
- GraphvizAttributeItem (key, value)
41
+ GraphAttributeItem (key, value)
42
42
}.toTypedArray()
43
43
}
44
44
else -> ArrayUtil .EMPTY_OBJECT_ARRAY
45
45
}
46
46
}
47
47
48
- override fun getElementTitle (element : GraphvizNodeData ): String? {
48
+ override fun getElementTitle (element : GraphNodeData ): String? {
49
49
return element.getName()
50
50
}
51
51
52
- override fun getNodeTooltip (element : GraphvizNodeData ): String? {
52
+ override fun getNodeTooltip (element : GraphNodeData ): String? {
53
53
return when (element) {
54
- is GraphvizEntityNodeData -> {
54
+ is GraphEntityNodeData -> {
55
55
buildString {
56
56
append(" Entity: ${element.getName()} " )
57
57
append(" \n Fields: ${element.getFields().size} " )
@@ -67,7 +67,7 @@ class GraphvizElementManager : AbstractDiagramElementManager<GraphvizNodeData>()
67
67
}
68
68
}
69
69
}
70
- is GraphvizSimpleNodeData -> {
70
+ is GraphSimpleNodeData -> {
71
71
buildString {
72
72
append(" Node: ${element.getName()} " )
73
73
if (element.getDisplayLabel() != element.getName()) {
@@ -83,16 +83,16 @@ class GraphvizElementManager : AbstractDiagramElementManager<GraphvizNodeData>()
83
83
}
84
84
85
85
override fun canBeBuiltFrom (element : Any? ): Boolean {
86
- return element is GraphvizDiagramRootData || super .canBeBuiltFrom(element)
86
+ return element is GraphDiagramRootData || super .canBeBuiltFrom(element)
87
87
}
88
88
89
89
override fun getItemName (
90
- nodeElement : GraphvizNodeData ? ,
90
+ nodeElement : GraphNodeData ? ,
91
91
nodeItem : Any? ,
92
92
builder : DiagramBuilder
93
93
): SimpleColoredText ? {
94
94
return when (nodeItem) {
95
- is GraphvizNodeField -> {
95
+ is GraphNodeField -> {
96
96
val displayName = nodeItem.getDisplayName()
97
97
val attributes = when (nodeItem.changeStatus) {
98
98
ChangeStatus .ADDED -> SimpleTextAttributes .REGULAR_BOLD_ATTRIBUTES
@@ -101,55 +101,55 @@ class GraphvizElementManager : AbstractDiagramElementManager<GraphvizNodeData>()
101
101
}
102
102
SimpleColoredText (displayName, attributes)
103
103
}
104
- is GraphvizAttributeItem -> SimpleColoredText (nodeItem.key, SimpleTextAttributes .REGULAR_ATTRIBUTES )
104
+ is GraphAttributeItem -> SimpleColoredText (nodeItem.key, SimpleTextAttributes .REGULAR_ATTRIBUTES )
105
105
else -> null
106
106
}
107
107
}
108
108
109
109
override fun getItemType (
110
- nodeElement : GraphvizNodeData ? ,
110
+ nodeElement : GraphNodeData ? ,
111
111
nodeItem : Any? ,
112
112
builder : DiagramBuilder ?
113
113
): SimpleColoredText ? {
114
114
return when (nodeItem) {
115
- is GraphvizNodeField -> {
115
+ is GraphNodeField -> {
116
116
nodeItem.type?.let {
117
117
SimpleColoredText (it, SimpleTextAttributes .REGULAR_ATTRIBUTES )
118
118
}
119
119
}
120
- is GraphvizAttributeItem -> SimpleColoredText (nodeItem.value, SimpleTextAttributes .REGULAR_ATTRIBUTES )
120
+ is GraphAttributeItem -> SimpleColoredText (nodeItem.value, SimpleTextAttributes .REGULAR_ATTRIBUTES )
121
121
else -> null
122
122
}
123
123
}
124
124
125
125
override fun getItemIcon (
126
- nodeElement : GraphvizNodeData ? ,
126
+ nodeElement : GraphNodeData ? ,
127
127
nodeItem : Any? ,
128
128
builder : DiagramBuilder ?
129
129
): Icon ? {
130
130
return when (nodeItem) {
131
- is GraphvizNodeField -> {
131
+ is GraphNodeField -> {
132
132
if (nodeItem.isRequired()) {
133
133
PlatformIcons .FIELD_ICON // Could use a different icon for required fields
134
134
} else {
135
135
PlatformIcons .FIELD_ICON
136
136
}
137
137
}
138
- is GraphvizAttributeItem -> PlatformIcons .METHOD_ICON
138
+ is GraphAttributeItem -> PlatformIcons .METHOD_ICON
139
139
else -> null
140
140
}
141
141
}
142
142
143
- companion object {
143
+ companion object Companion {
144
144
/* *
145
145
* Create root data for a DOT file
146
146
*/
147
- fun getRootData (project : Project , virtualFile : VirtualFile ): GraphvizDiagramRootData {
148
- val disposable = project.getService(GraphvizDiagramService ::class .java)
147
+ fun getRootData (project : Project , virtualFile : VirtualFile ): GraphDiagramRootData {
148
+ val disposable = project.getService(CodeTopologyDiagramService ::class .java)
149
149
val filePointer = VirtualFilePointerManager .getInstance()
150
150
.create(virtualFile, disposable, null )
151
151
152
- return GraphvizDiagramRootData (filePointer)
152
+ return GraphDiagramRootData (filePointer)
153
153
}
154
154
155
155
/* *
0 commit comments