Skip to content

Commit 9614a6e

Browse files
clickable class header refers to documentation
1 parent cc42a97 commit 9614a6e

File tree

5 files changed

+42
-5
lines changed

5 files changed

+42
-5
lines changed

cache/projectTemplate.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ return structured data about class</Description>
5858
set oClass = ##class(%ZEN.proxyObject).%New()
5959
6060
set oProperties = ##class(%ZEN.proxyObject).%New()
61+
set oClass.NAMESPACE = $NAMESPACE
6162
set oClass.super = classDefinition.Super
6263
set oClass.properties = oProperties
6364
set count = classDefinition.Properties.Count()

web/css/classView.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,12 @@ text {
2828
.centralText > div {
2929
display: table-cell;
3030
vertical-align: middle;
31+
}
32+
33+
.uml-class-name-text {
34+
cursor: help;
35+
}
36+
37+
.uml-class-name-text:hover {
38+
fill: red;
3139
}

web/js/ClassView.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ var ClassView = function (parent, container) {
1818
this.MIN_PAPER_SCALE = 0.2;
1919
this.MAX_PAPER_SCALE = 4;
2020

21+
this.CLASS_DOC_PATH = "/csp/documatic/%25CSP.Documatic.cls";
22+
2123
this.init();
2224

2325
};
@@ -60,6 +62,16 @@ ClassView.prototype.resetView = function () {
6062

6163
};
6264

65+
ClassView.prototype.openClassDoc = function (className, nameSpace) {
66+
67+
window.open(
68+
this.CLASS_DOC_PATH + "?LIBRARY=" + encodeURIComponent(nameSpace)
69+
+ "&CLASSNAME=" + encodeURIComponent(className),
70+
"_blank"
71+
);
72+
73+
};
74+
6375
/**
6476
* @param {string} name
6577
* @param classMetaData
@@ -70,7 +82,8 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
7082
var attrArr, methArr,
7183
classParams = classMetaData["parameters"],
7284
classProps = classMetaData["properties"],
73-
classMethods = classMetaData["methods"];
85+
classMethods = classMetaData["methods"],
86+
self = this;
7487

7588
var insertString = function (array, string, extraString) {
7689
string.match(/.{1,44}/g).forEach(function (p) {
@@ -79,7 +92,7 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
7992
};
8093

8194
return new joint.shapes.uml.Class({
82-
name: name,
95+
name: name + "\x1b" + JSON.stringify({ url: function () {alert(name)} }),
8396
attributes: attrArr = (function (params, ps) {
8497
var arr = [], n;
8598
for (n in params) {
@@ -108,6 +121,11 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
108121
}
109122
return arr;
110123
})(classMethods),
124+
directProps: {
125+
nameClickHandler: function () {
126+
self.openClassDoc(name, classMetaData["NAMESPACE"]);
127+
}
128+
},
111129
size: {
112130
width: 300,
113131
height: Math.max(attrArr.length*12.1, 15) + Math.max(methArr.length*12.1, 15) + 40

web/jsLib/joint.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17222,6 +17222,10 @@ if ( typeof window === "object" && typeof window.document === "object" ) {
1722217222
tspan.node.style[j] = setup["STYLES"][j];
1722317223
}
1722417224
}
17225+
if (opt.clickHandler) {
17226+
console.log(1);
17227+
tspan.node.onclick = opt.clickHandler;
17228+
}
1722517229
}
1722617230
// Make sure the textContent is never empty. If it is, add an additional
1722717231
// space (an invisible character) so that following lines are correctly
@@ -20943,7 +20947,7 @@ joint.dia.ElementView = joint.dia.CellView.extend({
2094320947

2094420948
$selected.each(function() {
2094520949

20946-
V(this).text(attrs.text + '', { lineHeight: attrs.lineHeight, textPath: attrs.textPath });
20950+
V(this).text(attrs.text + '', attrs);
2094720951
});
2094820952
specialAttributes.push('lineHeight','textPath');
2094920953
}

web/jsLib/joint.shapes.uml.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ joint.shapes.uml.Class = joint.shapes.basic.Generic.extend({
8282

8383
updateRectangles: function() {
8484

85-
var attrs = this.get('attrs');
85+
var attrs = this.get('attrs'),
86+
self = this;
8687

8788
var rects = [
8889
{ type: 'name', text: this.getClassName() },
@@ -92,15 +93,20 @@ joint.shapes.uml.Class = joint.shapes.basic.Generic.extend({
9293

9394
var offsetY = 0;
9495

96+
var dp = self.get("directProps") || {},
97+
nameClickHandler = dp.nameClickHandler;
98+
9599
_.each(rects, function(rect) {
96100

97101
var lines = _.isArray(rect.text) ? rect.text : [rect.text];
98102
var rectHeight = lines.length * 20 + 20;
99103

100104
attrs['.uml-class-' + rect.type + '-text'].text = lines.join('\n');
105+
if (nameClickHandler) {
106+
if (rect.type === "name") attrs['.uml-class-' + rect.type + '-text'].clickHandler = nameClickHandler;
107+
}
101108
attrs['.uml-class-' + rect.type + '-rect'].height = rectHeight;
102109
attrs['.uml-class-' + rect.type + '-rect'].transform = 'translate(0,'+ offsetY + ')';
103-
104110
offsetY += rectHeight;
105111

106112
});

0 commit comments

Comments
 (0)