Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaeverywhere committed Apr 28, 2015
2 parents 0f9f92a + 4c5b4b7 commit 5069262
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 19 deletions.
1 change: 1 addition & 0 deletions cache/projectTemplate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ return structured data about class</Description>
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()
Expand Down
8 changes: 8 additions & 0 deletions web/css/classView.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion web/css/treeView.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
31 changes: 21 additions & 10 deletions web/js/ClassTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand All @@ -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;
Expand All @@ -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 = [];
Expand All @@ -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();

Expand Down
32 changes: 27 additions & 5 deletions web/js/ClassView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

};
Expand Down Expand Up @@ -60,17 +62,28 @@ 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
* @returns {joint.shapes.uml.Class}
*/
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) {
Expand All @@ -79,7 +92,7 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
};

return new joint.shapes.uml.Class({
name: name,
name: nameArr = (classMetaData["ABSTRACT"] ? ["<<Abstract>>", name] : [name]),
attributes: attrArr = (function (params, ps) {
var arr = [], n;
for (n in params) {
Expand All @@ -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"
Expand All @@ -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
}
});

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion web/jsLib/joint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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');
}
Expand Down
10 changes: 8 additions & 2 deletions web/jsLib/joint.shapes.uml.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() },
Expand All @@ -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;

});
Expand Down

0 comments on commit 5069262

Please sign in to comment.