diff --git a/cache/projectTemplate.xml b/cache/projectTemplate.xml index 70eef77..50cb861 100644 --- a/cache/projectTemplate.xml +++ b/cache/projectTemplate.xml @@ -58,6 +58,7 @@ return structured data about class set oClass = ##class(%ZEN.proxyObject).%New() set oProperties = ##class(%ZEN.proxyObject).%New() + set oClass.NAMESPACE = $NAMESPACE set oClass.super = classDefinition.Super set oClass.properties = oProperties set count = classDefinition.Properties.Count() diff --git a/web/css/classView.css b/web/css/classView.css index b76de0d..323c708 100644 --- a/web/css/classView.css +++ b/web/css/classView.css @@ -28,4 +28,12 @@ text { .centralText > div { display: table-cell; vertical-align: middle; +} + +.uml-class-name-text { + cursor: help; +} + +.uml-class-name-text:hover { + fill: red; } \ No newline at end of file diff --git a/web/css/treeView.css b/web/css/treeView.css index eb231b2..57b928b 100644 --- a/web/css/treeView.css +++ b/web/css/treeView.css @@ -11,7 +11,7 @@ display: none; } -.tv-class-name.selected { +.tv-class-name.selected, .tv-package-name.selected { box-shadow: inset 0 0 2px 2px #ffcc1b; } diff --git a/web/js/ClassTree.js b/web/js/ClassTree.js index b3b8b6a..9f55e26 100644 --- a/web/js/ClassTree.js +++ b/web/js/ClassTree.js @@ -65,7 +65,9 @@ ClassTree.prototype.packageSelected = function (element, packageName) { ClassTree.prototype.updateTree = function (treeObject) { var self = this, - div = function () { return document.createElement("div"); }; + div = function () { return document.createElement("div");}, + selectedClassElement = this.SELECTED_CLASS_NAME ? this.SELECTED_CLASS_NAME.split(".") : [], + sce = 0; // selectedClassElement level index var packageClick = function (e) { @@ -87,24 +89,32 @@ ClassTree.prototype.updateTree = function (treeObject) { }; - var append = function (rootElement, elementName, isPackage, path) { + var append = function (rootElement, elementName, isPackage, path, level) { - var el1 = div(), + var sel = selectedClassElement.length + && sce === level && selectedClassElement[sce] === elementName ? ++sce : null, + el1 = div(), el2, el3, el4; if (isPackage) { el1.className = "tv-package"; - (el2 = div()).className = "tv-package-name minimized"; el2.textContent = elementName; + (el2 = div()).className = "tv-package-name" + (sel ? "" : " minimized"); + el2.textContent = elementName; + if (sel && sce === selectedClassElement.length) { + el2.className += " selected"; + self.SELECTED_ELEMENT = el2; + } (el3 = div()).className = "tv-package-content"; el1.appendChild(el2); el1.appendChild(el3); el2.addEventListener("click", packageClick); el2.appendChild(el4 = div()); el4.className = "tv-rightListIcon icon list"; el4.addEventListener("click", function () { - self.packageSelected(el1, (path ? path + "." : path) + elementName); + self.packageSelected(el2, (path ? path + "." : path) + elementName); }); } else { - el1.className = "tv-class-name"; + if (sel) self.SELECTED_ELEMENT = el1; + el1.className = "tv-class-name" + (sel ? " selected" : ""); el1.textContent = elementName; el1.addEventListener("click", classClick); el1.CLASS_NAME = path + (path ? "." : "") + elementName; @@ -116,7 +126,7 @@ ClassTree.prototype.updateTree = function (treeObject) { }; - var build = function (rootElement, object, path) { + var build = function (rootElement, object, path, level) { var i, element, rec, arr = []; @@ -136,15 +146,16 @@ ClassTree.prototype.updateTree = function (treeObject) { rootElement, element.name, typeof element.val === "object", - path.join(".") + path.join("."), + level )) { - build(rec, element.val, path.concat([element.name])); + build(rec, element.val, path.concat([element.name]), level + 1); } } }; - build(this.container, treeObject, []); + build(this.container, treeObject, [], 0); this.removeLoader(); diff --git a/web/js/ClassView.js b/web/js/ClassView.js index 4847881..224188d 100644 --- a/web/js/ClassView.js +++ b/web/js/ClassView.js @@ -18,6 +18,8 @@ var ClassView = function (parent, container) { this.MIN_PAPER_SCALE = 0.2; this.MAX_PAPER_SCALE = 4; + this.CLASS_DOC_PATH = "/csp/documatic/%25CSP.Documatic.cls"; + this.init(); }; @@ -60,6 +62,16 @@ ClassView.prototype.resetView = function () { }; +ClassView.prototype.openClassDoc = function (className, nameSpace) { + + window.open( + this.CLASS_DOC_PATH + "?LIBRARY=" + encodeURIComponent(nameSpace) + + "&CLASSNAME=" + encodeURIComponent(className), + "_blank" + ); + +}; + /** * @param {string} name * @param classMetaData @@ -67,10 +79,11 @@ ClassView.prototype.resetView = function () { */ ClassView.prototype.createClassInstance = function (name, classMetaData) { - var attrArr, methArr, + var attrArr, methArr, nameArr, classParams = classMetaData["parameters"], classProps = classMetaData["properties"], - classMethods = classMetaData["methods"]; + classMethods = classMetaData["methods"], + self = this; var insertString = function (array, string, extraString) { string.match(/.{1,44}/g).forEach(function (p) { @@ -79,7 +92,7 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) { }; return new joint.shapes.uml.Class({ - name: name, + name: nameArr = (classMetaData["ABSTRACT"] ? ["<>", name] : [name]), attributes: attrArr = (function (params, ps) { var arr = [], n; for (n in params) { @@ -99,7 +112,8 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) { for (n in met) { insertString( arr, - "+ " + n + (met[n]["returns"] ? ": " + met[n]["returns"] : ""), + (met[n]["private"] ? "- " : "+ ") + n + + (met[n]["returns"] ? ": " + met[n]["returns"] : ""), (met[n]["classMethod"] ? "\x1b" + JSON.stringify({STYLES:{ textDecoration: "underline" @@ -108,9 +122,15 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) { } return arr; })(classMethods), + directProps: { + nameClickHandler: function () { + self.openClassDoc(name, classMetaData["NAMESPACE"]); + } + }, size: { width: 300, - height: Math.max(attrArr.length*12.1, 15) + Math.max(methArr.length*12.1, 15) + 40 + height: Math.max(nameArr.length*12.1, 0) + Math.max(attrArr.length*12.1, 0) + + Math.max(methArr.length*12.1, 0) + 30 } }); @@ -194,6 +214,7 @@ ClassView.prototype.loadClass = function (className) { var self = this; + this.cacheUMLExplorer.classTree.SELECTED_CLASS_NAME = className; this.showLoader(); this.cacheUMLExplorer.source.getClassView(className, function (err, data) { //console.log(data); @@ -215,6 +236,7 @@ ClassView.prototype.loadPackage = function (packageName) { var self = this; + this.cacheUMLExplorer.classTree.SELECTED_CLASS_NAME = packageName; this.showLoader(); this.cacheUMLExplorer.source.getPackageView(packageName, function (err, data) { //console.log(data); diff --git a/web/jsLib/joint.js b/web/jsLib/joint.js index 5321c7b..9e8085c 100644 --- a/web/jsLib/joint.js +++ b/web/jsLib/joint.js @@ -17222,6 +17222,9 @@ if ( typeof window === "object" && typeof window.document === "object" ) { tspan.node.style[j] = setup["STYLES"][j]; } } + if (opt.clickHandler) { + tspan.node.onclick = opt.clickHandler; + } } // Make sure the textContent is never empty. If it is, add an additional // space (an invisible character) so that following lines are correctly @@ -20943,7 +20946,7 @@ joint.dia.ElementView = joint.dia.CellView.extend({ $selected.each(function() { - V(this).text(attrs.text + '', { lineHeight: attrs.lineHeight, textPath: attrs.textPath }); + V(this).text(attrs.text + '', attrs); }); specialAttributes.push('lineHeight','textPath'); } diff --git a/web/jsLib/joint.shapes.uml.js b/web/jsLib/joint.shapes.uml.js index 4427e7e..603f9f7 100644 --- a/web/jsLib/joint.shapes.uml.js +++ b/web/jsLib/joint.shapes.uml.js @@ -82,7 +82,8 @@ joint.shapes.uml.Class = joint.shapes.basic.Generic.extend({ updateRectangles: function() { - var attrs = this.get('attrs'); + var attrs = this.get('attrs'), + self = this; var rects = [ { type: 'name', text: this.getClassName() }, @@ -92,15 +93,20 @@ joint.shapes.uml.Class = joint.shapes.basic.Generic.extend({ var offsetY = 0; + var dp = self.get("directProps") || {}, + nameClickHandler = dp.nameClickHandler; + _.each(rects, function(rect) { var lines = _.isArray(rect.text) ? rect.text : [rect.text]; var rectHeight = lines.length * 20 + 20; attrs['.uml-class-' + rect.type + '-text'].text = lines.join('\n'); + if (nameClickHandler) { + if (rect.type === "name") attrs['.uml-class-' + rect.type + '-text'].clickHandler = nameClickHandler; + } attrs['.uml-class-' + rect.type + '-rect'].height = rectHeight; attrs['.uml-class-' + rect.type + '-rect'].transform = 'translate(0,'+ offsetY + ')'; - offsetY += rectHeight; });