Skip to content

Commit 98cd0c0

Browse files
ready classView
1 parent 4c82760 commit 98cd0c0

12 files changed

+708
-84
lines changed

cache/projectTemplate.xml

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2015.2 (Build 540)" ts="2015-04-12 16:26:04">
3+
<Class name="UMLExplorer.ClassView">
4+
<Description>
5+
Class contains methods that return structured class data.</Description>
6+
<TimeChanged>63654,59126.207802</TimeChanged>
7+
<TimeCreated>63653,67019.989197</TimeCreated>
8+
9+
<Method name="getClassData">
10+
<ClassMethod>1</ClassMethod>
11+
<FormalSpec>classDefinition:%Dictionary.ClassDefinition</FormalSpec>
12+
<ReturnType>%ZEN.proxyObject</ReturnType>
13+
<Implementation><![CDATA[
14+
set oClass = ##class(%ZEN.proxyObject).%New()
15+
set oProperties = ##class(%ZEN.proxyObject).%New()
16+
set oClass.super = classDefinition.Super
17+
set oClass.properties = oProperties
18+
set count = classDefinition.Properties.Count()
19+
for i = 1:1:count {
20+
set oProp = ##class(%ZEN.proxyObject).%New()
21+
do oProperties.%DispatchSetProperty(classDefinition.Properties.GetAt(i).Name, oProp)
22+
do oProp.%DispatchSetProperty("private", classDefinition.Properties.GetAt(i).Private)
23+
do oProp.%DispatchSetProperty("readOnly", classDefinition.Properties.GetAt(i).ReadOnly)
24+
do oProp.%DispatchSetProperty("type", classDefinition.Properties.GetAt(i).Type)
25+
}
26+
27+
set oMethods = ##class(%ZEN.proxyObject).%New()
28+
set oClass.methods = oMethods
29+
set count = classDefinition.Methods.Count()
30+
for i = 1:1:count {
31+
set oMeth = ##class(%ZEN.proxyObject).%New()
32+
do oMethods.%DispatchSetProperty(classDefinition.Methods.GetAt(i).Name, oMeth)
33+
do oMeth.%DispatchSetProperty("private", classDefinition.Methods.GetAt(i).Private)
34+
do oMeth.%DispatchSetProperty("returns", classDefinition.Methods.GetAt(i).ReturnType)
35+
}
36+
37+
return oClass
38+
]]></Implementation>
39+
</Method>
40+
41+
<Method name="collectInheritance">
42+
<ClassMethod>1</ClassMethod>
43+
<FormalSpec>oData:%ZEN.proxyObject,baseClassDefinition:%Dictionary.ClassDefinition</FormalSpec>
44+
<ReturnType>%Status</ReturnType>
45+
<Implementation><![CDATA[
46+
set superParts = $LISTFROMSTRING(baseClassDefinition.Super, ",")
47+
if (oData.inheritance.%DispatchGetProperty(baseClassDefinition.Name) = "") {
48+
do oData.inheritance.%DispatchSetProperty(baseClassDefinition.Name, ##class(%ZEN.proxyObject).%New())
49+
}
50+
set oInherit = oData.inheritance.%DispatchGetProperty(baseClassDefinition.Name)
51+
for i=1:1:$LISTLENGTH(superParts) {
52+
set className = $LISTGET(superParts, i)
53+
do oInherit.%DispatchSetProperty(className, 1)
54+
if (oData.classes.%DispatchGetProperty(className) = "") {
55+
set cdef = ##class(%Dictionary.ClassDefinition).%OpenId(className)
56+
if (cdef '= "") {
57+
do oData.classes.%DispatchSetProperty(className, ..getClassData(cdef))
58+
do ..collectInheritance(oData, cdef)
59+
}
60+
}
61+
}
62+
return $$$OK
63+
]]></Implementation>
64+
</Method>
65+
66+
<Method name="getClassView">
67+
<ClassMethod>1</ClassMethod>
68+
<FormalSpec>baseClassDefinition:%Dictionary.ClassDefinition</FormalSpec>
69+
<Implementation><![CDATA[
70+
set oData = ##class(%ZEN.proxyObject).%New()
71+
set oData.classes = ##class(%ZEN.proxyObject).%New()
72+
set oData.inheritance = ##class(%ZEN.proxyObject).%New()
73+
do oData.classes.%DispatchSetProperty(baseClassDefinition.Name, ..getClassData(baseClassDefinition))
74+
75+
do ..collectInheritance(oData, baseClassDefinition)
76+
77+
return oData
78+
]]></Implementation>
79+
</Method>
80+
</Class>
81+
82+
83+
<Project name="UMLExplorer" LastModified="2015-04-12 16:26:04.713512">
84+
<Items>
85+
<ProjectItem name="UMLExplorer.Router" type="CLS"></ProjectItem>
86+
<ProjectItem name="UMLExplorer.ClassView" type="CLS"></ProjectItem>
87+
</Items>
88+
</Project>
89+
90+
91+
<Class name="UMLExplorer.Router">
92+
<Description>
93+
REST interface for UMLExplorer</Description>
94+
<Super>%CSP.REST</Super>
95+
<TimeChanged>63653,74965.264444</TimeChanged>
96+
<TimeCreated>63648,30450.187229</TimeCreated>
97+
98+
<XData name="UrlMap">
99+
<Data><![CDATA[
100+
<Routes>
101+
<Route Url="/Test" Method="GET" Call="Test"/>
102+
<Route Url="/GetClassTree" Method="GET" Call="GetClassTree"/>
103+
<Route Url="/GetClassView/:ClassName" Method="GET" Call="GetClassView"/>
104+
</Routes>
105+
]]></Data>
106+
</XData>
107+
108+
<Method name="GetClassTree">
109+
<Description>
110+
Method returns whole class tree visible in the current namespace.</Description>
111+
<ClassMethod>1</ClassMethod>
112+
<ReturnType>%Status</ReturnType>
113+
<Implementation><![CDATA[
114+
set resp = ##class(%ZEN.proxyObject).%New()
115+
set classes = ##class(%ResultSet).%New("%Dictionary.ClassDefinition:Summary")
116+
set objects = ##class(%Library.ArrayOfObjects).%New()
117+
set lastParts = $LB()
118+
119+
set level = 1
120+
do objects.SetAt(resp, level)
121+
122+
do classes.Execute()
123+
While (classes.Next()) {
124+
set name = classes.Data("Name")
125+
set parts = $LISTFROMSTRING(name, ".")
126+
set i = 0
127+
while (i < $LISTLENGTH(parts)) && ($LISTGET(lastParts, i + 1) = $LISTGET(parts, i + 1)) {
128+
set i = i + 1
129+
}
130+
set level = i + 1
131+
set resp = objects.GetAt(level)
132+
while ($LISTLENGTH(parts) > level) {
133+
set level = level + 1
134+
set resp = ##class(%ZEN.proxyObject).%New()
135+
do objects.GetAt(level - 1).%DispatchSetProperty($LISTGET(parts, level - 1), resp)
136+
do objects.SetAt(resp, level)
137+
}
138+
if ($LISTLENGTH(parts) = level) {
139+
do resp.%DispatchSetProperty($LISTGET(parts, level), classes.Data("Hidden"))
140+
}
141+
set lastParts = parts
142+
}
143+
144+
do objects.GetAt(1).%ToJSON(, "ou")
145+
return $$$OK
146+
]]></Implementation>
147+
</Method>
148+
149+
<Method name="GetClassView">
150+
<Description>
151+
Returns classTree by given class name</Description>
152+
<ClassMethod>1</ClassMethod>
153+
<FormalSpec>className:%String</FormalSpec>
154+
<ReturnType>%Status</ReturnType>
155+
<Implementation><![CDATA[
156+
set cdef = ##class(%Dictionary.ClassDefinition).%OpenId(className)
157+
if (cdef = "") quit ..Http404()
158+
set classData = ##class(UMLExplorer.ClassView).getClassView(cdef)
159+
do classData.%ToJSON(, "ou")
160+
return $$$OK
161+
]]></Implementation>
162+
</Method>
163+
164+
<Method name="Test">
165+
<Description>
166+
Method to test accessibility of REST interface.</Description>
167+
<ClassMethod>1</ClassMethod>
168+
<ReturnType>%Status</ReturnType>
169+
<Implementation><![CDATA[
170+
set resp = ##class(%ZEN.proxyObject).%New()
171+
set resp2 = ##class(%ZEN.proxyObject).%New()
172+
set resp2.Status = "OK"
173+
set resp.obj = resp2
174+
do resp.%ToJSON(, "o")
175+
return $$$OK
176+
]]></Implementation>
177+
</Method>
178+
</Class>
179+
</Export>

web/css/classView.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
#classView {
22
height: 100%;
3+
}
4+
5+
.uml-class-name-rect {
6+
fill: lightgray;
7+
}
8+
9+
.uml-class-attrs-rect, .uml-class-methods-rect {
10+
fill: white;
11+
}
12+
13+
text {
14+
font-family: monospace;
315
}

web/css/joint.min.css

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<link rel="stylesheet" href="css/classView.css"/>
1010
<link rel="stylesheet" href="css/joint.min.css"/>
1111
<script type="text/javascript" src="js/joint.min.js"></script>
12-
<script type="text/javascript" src="js/joint.shapes.uml.min.js"></script>
12+
<script type="text/javascript" src="js/joint.shapes.uml.js"></script>
1313
<script type="text/javascript" src="js/joint.layout.DirectedGraph.min.js"></script>
1414
<script type="text/javascript" src="js/ClassView.js"></script>
1515
<script type="text/javascript" src="js/Lib.js"></script>

web/js/CacheUMLExplorer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
var CacheUMLExplorer = function (treeViewContainer, classViewContainer) {
1010

1111
this.source = new Source();
12-
this.classTree = new ClassTree(treeViewContainer);
12+
this.classTree = new ClassTree(this, treeViewContainer);
1313
this.classView = new ClassView(classViewContainer);
1414

1515
this.init();

web/js/ClassTree.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
/**
22
* Class tree representation.
3+
* @param {CacheUMLExplorer} parent
34
* @param {HTMLElement} treeViewContainer
45
* @constructor
56
*/
6-
var ClassTree = function (treeViewContainer) {
7+
var ClassTree = function (parent, treeViewContainer) {
78

9+
this.cacheUMLExplorer = parent;
810
this.container = treeViewContainer;
911
this.loader = null;
1012
this.SELECTED_CLASS_NAME = null;
@@ -30,7 +32,9 @@ ClassTree.prototype.removeLoader = function () {
3032

3133
};
3234

33-
ClassTree.prototype.selectClass = function (element, className) {
35+
ClassTree.prototype.classSelected = function (element, className) {
36+
37+
var self = this;
3438

3539
this.SELECTED_CLASS_NAME = className;
3640

@@ -41,6 +45,13 @@ ClassTree.prototype.selectClass = function (element, className) {
4145

4246
if (!element.classList.contains("selected")) {
4347
element.classList.add("selected");
48+
this.cacheUMLExplorer.source.getClassView(className, function (err, data) {
49+
if (err) {
50+
console.error(err);
51+
} else {
52+
self.cacheUMLExplorer.classView.render(data);
53+
}
54+
});
4455
}
4556

4657
};
@@ -66,7 +77,7 @@ ClassTree.prototype.updateTree = function (treeObject) {
6677

6778
var el = e.target || e.srcElement;
6879

69-
self.selectClass(el, el.CLASS_NAME);
80+
self.classSelected(el, el.CLASS_NAME);
7081

7182
};
7283

0 commit comments

Comments
 (0)