Skip to content

Commit 8ba3043

Browse files
some class keywords visualization as icons with labels add
1 parent 63d372b commit 8ba3043

File tree

7 files changed

+133
-29
lines changed

7 files changed

+133
-29
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ An UML Class explorer for InterSystems Caché.
1010

1111
## Screenshots
1212

13-
![2015-04-21_214058](https://cloud.githubusercontent.com/assets/4989256/7525432/180dafd8-f512-11e4-80dc-3c5721d3b858.png)
13+
![Demo](https://cloud.githubusercontent.com/assets/4989256/7586381/19008d24-f8b5-11e4-8893-a63d5373dfa1.png)
1414

1515
## Installation
1616

17+
To install Caché UML Explorer, you need to import UMLExplorer package to Caché and then set up a WEB-application.
18+
1719
###### Import classes to Caché
1820
To install Caché UML class explorer, download the [latest release](https://github.com/ZitRos/CacheUMLExplorer/releases) or build project by yourself. Then import XML file inside <code>Cache</code> directory of archive or directory.
1921

cache/projectTemplate.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Class name="UMLExplorer.ClassView">
44
<Description>
55
Class contains methods that return structured classes/packages data.</Description>
6-
<TimeChanged>63680,46308.140173</TimeChanged>
6+
<TimeChanged>63684,52343.305666</TimeChanged>
77
<TimeCreated>63653,67019.989197</TimeCreated>
88

99
<Method name="getClassTree">
@@ -62,10 +62,14 @@ Return structured data about class.</Description>
6262
do oData.classes.%DispatchSetProperty(classDefinition.Name, oClass) // prevent from recursive setup
6363
set package = $LISTTOSTRING($LIST($LISTFROMSTRING(classDefinition.Name, "."), 1, *-1),".")
6464
set oProperties = ##class(%ZEN.proxyObject).%New()
65+
set oClass.super = classDefinition.Super
6566
set oClass.NAMESPACE = $NAMESPACE
6667
set oClass.SYSTEM = classDefinition.System
68+
set oClass.PROCEDUREBLOCK = classDefinition.ProcedureBlock
6769
set oClass.ABSTRACT = classDefinition.Abstract
68-
set oClass.super = classDefinition.Super
70+
set oClass.FINAL = classDefinition.Final
71+
set oClass.HIDDEN = classDefinition.Hidden
72+
set oClass.classType = classDefinition.ClassType
6973
7074
if (oData.restrictPackage) && ('..inPackage(oData.basePackageName, package)) quit oClass
7175
@@ -263,7 +267,7 @@ Returns structured package data</Description>
263267
</Class>
264268

265269

266-
<Project name="UMLExplorer" LastModified="2015-05-08 00:09:34.590786">
270+
<Project name="UMLExplorer" LastModified="2015-05-08 19:38:35.423206">
267271
<Items>
268272
<ProjectItem name="UMLExplorer.ClassView" type="CLS"></ProjectItem>
269273
<ProjectItem name="UMLExplorer.Router" type="CLS"></ProjectItem>

gulpfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ gulp.task("addHTMLFile", ["clean"], function () {
9797
.pipe(gulp.dest("build/web/"));
9898
});
9999

100-
gulp.task("copyLICENSE", ["clean"], function (){
100+
gulp.task("copyLICENSE", ["clean"], function () {
101101
return gulp.src("LICENSE")
102102
.pipe(gulp.dest("build/"));
103103
});
104104

105-
gulp.task("copyREADME", ["clean"], function (){
105+
gulp.task("copyREADME", ["clean"], function () {
106106
return gulp.src("readme.md")
107107
.pipe(gulp.dest("build/"));
108108
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "CacheUMLExplorer",
3-
"version": "0.6.1",
3+
"version": "0.7.0",
44
"description": "An UML Class explorer for InterSystems Caché",
55
"directories": {
66
"test": "test"

web/js/ClassView.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,48 @@ ClassView.prototype.openClassDoc = function (className, nameSpace) {
7373

7474
};
7575

76+
/**
77+
* Returns array of signs to render or empry array.
78+
*
79+
* @private
80+
* @param classMetaData
81+
*/
82+
ClassView.prototype.getClassSigns = function (classMetaData) {
83+
84+
var signs = [];
85+
86+
if (classMetaData["classType"]) signs.push({
87+
icon: lib.image.greenPill,
88+
text: classMetaData["classType"],
89+
textStyle: "fill:rgb(130,0,255)"
90+
});
91+
if (classMetaData["ABSTRACT"]) signs.push({
92+
icon: lib.image.iceCube,
93+
text: "Abstract",
94+
textStyle: "fill:rgb(130,0,255)"
95+
});
96+
if (classMetaData["FINAL"]) signs.push({
97+
icon: lib.image.blueFlag,
98+
text: "Final",
99+
textStyle: "fill:rgb(130,0,255)"
100+
});
101+
if (classMetaData["SYSTEM"]) signs.push({
102+
icon: lib.image.chip,
103+
text: "System/" + classMetaData["SYSTEM"]
104+
});
105+
if (classMetaData["PROCEDUREBLOCK"] === 0) signs.push({
106+
icon: lib.image.moleculeCubeCross,
107+
text: "NotProcBlock"
108+
});
109+
if (classMetaData["HIDDEN"]) signs.push({
110+
icon: lib.image.ghost,
111+
text: "Hidden"
112+
});
113+
114+
return signs;
115+
116+
};
117+
76118
/**
77119
* @param {string} name
78120
* @param classMetaData
@@ -90,7 +132,7 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
90132
};
91133

92134
var classInstance = new joint.shapes.uml.Class({
93-
name: (classMetaData["ABSTRACT"] ? ["<<Abstract>>", name] : [name]),
135+
name: name,
94136
params: (function (params) {
95137
var arr = [], n;
96138
for (n in params) {
@@ -129,6 +171,7 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
129171
self.openClassDoc(name, classMetaData["NAMESPACE"]);
130172
}
131173
},
174+
classSigns: this.getClassSigns(classMetaData),
132175
SYMBOL_12_WIDTH: self.SYMBOL_12_WIDTH
133176
});
134177

web/js/Lib.js

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

web/jsLib/joint.shapes.uml.js

Lines changed: 63 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,24 @@ joint.shapes.uml.Class = joint.shapes.basic.Generic.extend({
2323
'<rect class="uml-class-methods-rect"/>',
2424
'<text class="uml-class-methods-label">Methods</text>',
2525
'</g>',
26-
//'<image xlink:href="img/icons/yellowCube.png" x="3" y="3" width="12" height="12"/>',
27-
//'<text fill="black" font-size="12" x="16" y="13">System</text>',
2826
'<text class="uml-class-name-text"/>',
2927
'<text class="uml-class-params-text"/>',
3028
'<text class="uml-class-attrs-text"/>',
3129
'<text class="uml-class-methods-text"/>',
3230
'</g>'
3331
].join(''),
3432

33+
HEAD_EMPTY_LINES: 0, // controls number of empty lines in header
34+
3535
defaults: joint.util.deepSupplement({
3636

3737
type: 'uml.Class',
3838

39-
size: { width: 300, height: 300 },
39+
MIN_WIDTH: 100,
40+
size: { width: 0, height: 300 },
4041

4142
attrs: {
42-
rect: { 'width': 200 },
43+
rect: { 'width': 0 },
4344

4445
'.uml-class-name-rect': { 'stroke': 'black', 'stroke-width': 1, 'fill': '#3498db' },
4546
'.uml-class-params-rect': { 'stroke': 'black', 'stroke-width': 1, 'fill': 'white' },
@@ -77,27 +78,72 @@ joint.shapes.uml.Class = joint.shapes.basic.Generic.extend({
7778
name: [],
7879
params: [],
7980
attributes: [],
80-
methods: []
81+
methods: [],
82+
classSigns: []
8183

8284
}, joint.shapes.basic.Generic.prototype.defaults),
8385

84-
initialize: function() {
86+
initialize: function () {
87+
88+
var rects = [
89+
{ type: 'name', text: this.getClassName() },
90+
{ type: 'params', text: this.get('params') },
91+
{ type: 'attrs', text: this.get('attributes') },
92+
{ type: 'methods', text: this.get('methods') }
93+
],
94+
self = this,
95+
classSigns = this.get('classSigns'),
96+
SYMBOL_12_WIDTH = this.get('SYMBOL_12_WIDTH') || 6.6,
97+
i, blockWidth, left = 3, top = 3, w;
98+
99+
// preserve space for sub-labels
100+
w = 0; for (i in classSigns) {
101+
w += classSigns[i].text.length * SYMBOL_12_WIDTH + (classSigns[i].icon ? 13 : 0) + (i ? 3 : 0);
102+
i = 1;
103+
}
104+
105+
this.defaults.size.width = Math.max(this.defaults.MIN_WIDTH, Math.min(w, 250));
106+
_.each(rects, function (rect) {
107+
(rect.text instanceof Array ? rect.text : [rect.text]).forEach(function (s) {
108+
var t = s.split("\x1b")[0].length*SYMBOL_12_WIDTH + 8;
109+
if (t > self.defaults.size.width) {
110+
self.defaults.size.width = t;
111+
}
112+
});
113+
});
114+
115+
blockWidth = this.defaults.size.width;
85116

86-
this.on('change:name change:attributes change:methods', function() {
117+
if (classSigns.length) this.HEAD_EMPTY_LINES = 1;
118+
119+
for (i in classSigns) {
120+
w = classSigns[i].text.length*SYMBOL_12_WIDTH + (classSigns[i].icon ? 13 : 0);
121+
if (left + w - 3 > blockWidth) { top += 12; left = 3; this.HEAD_EMPTY_LINES++; }
122+
this.markup += '<g transform="translate(' + left + ', ' + top + ')">' +
123+
(classSigns[i].icon ? '<image xlink:href="' + classSigns[i].icon +
124+
'" width="13" height="13"/>' : '') + '<text fill="black" font-size="11" ' +
125+
(classSigns[i].textStyle ? 'style="' + classSigns[i].textStyle + '"' : '') +
126+
' x="' + (classSigns[i].icon ? 13 : 0) + '" y="10">' + classSigns[i].text +
127+
'</text></g>';
128+
left += w + 3;
129+
}
130+
131+
this.on('change:name change:attributes change:methods', function () {
87132
this.updateRectangles();
88133
this.trigger('uml-update');
89134
}, this);
90135

91136
this.updateRectangles();
92137

93138
joint.shapes.basic.Generic.prototype.initialize.apply(this, arguments);
139+
94140
},
95141

96-
getClassName: function() {
142+
getClassName: function () {
97143
return this.get('name');
98144
},
99145

100-
updateRectangles: function() {
146+
updateRectangles: function () {
101147

102148
var attrs = this.get('attrs'),
103149
self = this,
@@ -110,25 +156,19 @@ joint.shapes.uml.Class = joint.shapes.basic.Generic.extend({
110156
{ type: 'methods', text: this.get('methods') }
111157
];
112158

113-
var offsetY = 0,
114-
maxWidth = 100;
159+
var offsetY = 0;
115160

116161
var dp = self.get("directProps") || {},
117162
nameClickHandler = dp.nameClickHandler;
118163

119-
_.each(rects, function (rect) {
120-
(rect.text instanceof Array ? rect.text : [rect.text]).forEach(function (s) { var t = s.split("\x1b")[0].length*SYMBOL_12_WIDTH + 8; if (t > maxWidth) {
121-
maxWidth = t;
122-
}});
123-
});
124-
125-
this.attributes.size.width = maxWidth; // max width assign
126-
127164
_.each(rects, function(rect) {
128165

129166
var lines = _.isArray(rect.text) ? rect.text : [rect.text];
130167

131-
//if (rect.type === "name") lines.unshift("");
168+
if (rect.type === "name") {
169+
if (self.HEAD_EMPTY_LINES) lines.unshift("");
170+
for (var i = 0; i < self.HEAD_EMPTY_LINES; i++) lines.unshift("");
171+
}
132172

133173
var rectHeight = lines.length * 12 + (lines.length ? 10 : 0),
134174
rectText = attrs['.uml-class-' + rect.type + '-text'],
@@ -156,7 +196,9 @@ joint.shapes.uml.Class = joint.shapes.basic.Generic.extend({
156196
});
157197

158198
this.attributes.size.height = offsetY;
159-
this.attributes.attrs.rect.width = maxWidth;
199+
this.attributes.size.width = this.defaults.size.width; // max width assign
200+
this.attributes.attrs.rect.width = this.defaults.size.width;
201+
160202
}
161203

162204
});

0 commit comments

Comments
 (0)