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 May 31, 2015
2 parents f08934a + d4f4320 commit 7400954
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 6 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ An UML Class explorer for InterSystems Caché.
+ Edit diagrams after build;
+ Export diagrams as an image;
+ View class methods code with syntax highlighting;
+ Zoom in and out, explore big packages and more.
+ Zoom in and out;
+ Search on diagram or in class tree;
+ Explore!

## Screenshots

![Demo](https://cloud.githubusercontent.com/assets/4989256/7898598/7d367720-070d-11e5-9177-dded6abf93e1.png)
![Demo](https://cloud.githubusercontent.com/assets/4989256/7902384/e7882a48-07c0-11e5-9c3f-7203a40263d2.png)

## Installation

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CacheUMLExplorer",
"version": "0.12.1",
"version": "0.13.1",
"description": "An UML Class explorer for InterSystems Caché",
"directories": {
"test": "test"
Expand Down
19 changes: 19 additions & 0 deletions web/css/classView.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,23 @@ text {

.line-clickable:hover {
fill: red;
}

.inlineSearchBlock {
display: inline-block;
vertical-align: bottom;
}

#diagramSearch {
display: block;
box-sizing: border-box;
border: 1px solid gray;
border-radius: 5px;
width: 200px;
margin: 4px 0 4px 4px;
height: 22px;
}

.element.highlighted {
outline: 4px solid rgba(255, 0, 0, 0.6);
}
29 changes: 29 additions & 0 deletions web/css/extras.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,35 @@
box-shadow: 0 0 5px 2px #ffcc1b;
}

.icon.search:after {
content: "";
position: absolute;
display: block;
width: 6px;
height: 6px;
left: 4px;
top: 4px;
border: 3px solid #fff;
background: transparent;
border-radius: 6px;
}

.icon.search:before {
content: "";
position: absolute;
display: block;
left: 14px;
top: 12px;
width: 3px;
height: 7px;
background: #fff;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
}

.icon.select {
width: auto;
color: white;
Expand Down
7 changes: 6 additions & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
<script type="text/javascript" src="js/Source.js"></script>
<script type="text/javascript" src="js/UI.js"></script>
<!-- endbuild -->
<link id="favicon" rel="shortcut icon" href="#"/>
</head>
<body onload="cue = new CacheUMLExplorer(document.getElementById('treeView'), document.getElementById('svgContainer'))">
<div class="ui-body" id="ui-body">
<div class="ui-sideBlock">
<div class="ui-sideSearchBlock" id="searchBlock">
<input type="search" id="classTreeSearch" placeholder="Search..."/>
<input type="search" id="classTreeSearch" placeholder="Search in class tree..."/>
</div>
<div id="treeView">

Expand All @@ -50,6 +51,10 @@
<div id="button.downloadSVG" class="icon download"></div>
</div>
<div class="ui-rightBottomToolBar">
<div class="inlineSearchBlock" id="diagramSearchBlock">
<input type="search" id="diagramSearch" placeholder="Search on diagram..."/>
</div>
<div id="button.diagramSearch" class="icon search"></div>
<div id="button.zoomIn" class="icon plus"></div>
<div id="button.zoomNormal" class="icon scaleNormal"></div>
<div id="button.zoomOut" class="icon minus"></div>
Expand Down
7 changes: 6 additions & 1 deletion web/js/CacheUMLExplorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var CacheUMLExplorer = function (treeViewContainer, classViewContainer) {
var id = function (e) { return document.getElementById(e); };

this.elements = {
favicon: id("favicon"),
uiBody: id("ui-body"),
className: id("className"),
treeViewContainer: treeViewContainer,
Expand All @@ -30,7 +31,9 @@ var CacheUMLExplorer = function (treeViewContainer, classViewContainer) {
methodViewBounds: id("methodViewBounds"),
namespaces: id("namespaces"),
classTreeSearch: id("classTreeSearch"),
searchBlock: id("searchBlock")
searchBlock: id("searchBlock"),
diagramSearch: id("diagramSearch"),
diagramSearchButton: id("button.diagramSearch")
};

this.UI = new UI(this);
Expand Down Expand Up @@ -119,6 +122,8 @@ CacheUMLExplorer.prototype.init = function () {
var self = this,
restored;

this.elements.favicon.href = lib.image.binoculars;

restored = this.restoreFromURL();
this.classTree.showLoader();
this.source.getClassTree(function (err, data) {
Expand Down
103 changes: 103 additions & 0 deletions web/js/ClassView.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,29 @@ var ClassView = function (parent, container) {
this.CLASS_DOC_PATH = "/csp/documatic/%25CSP.Documatic.cls";
this.SYMBOL_12_WIDTH = 6.6;

this.HIGHLIGHTED_VIEW = null;
this.SEARCH_INDEX = 0;

this.init();

};

ClassView.prototype.highlightElement = function (jointElement) {

if (this.HIGHLIGHTED_VIEW || (!jointElement && this.HIGHLIGHTED_VIEW)) {
this.HIGHLIGHTED_VIEW.unhighlight();
this.HIGHLIGHTED_VIEW = null;
}

if (!jointElement) return;
var view = this.paper.findViewByModel(jointElement);
if (!view) return;

view.highlight();
this.HIGHLIGHTED_VIEW = view;

};

ClassView.prototype.showLoader = function (html) {

var d2;
Expand Down Expand Up @@ -60,6 +79,9 @@ ClassView.prototype.resetView = function () {
this.objects = [];
this.paper.setOrigin(0, 0);
this.graph.clear();
this.HIGHLIGHTED_VIEW = null;
this.SEARCH_INDEX = 0;
this.cacheUMLExplorer.elements.diagramSearch.value = "";

};

Expand Down Expand Up @@ -268,6 +290,7 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
var classParams = classMetaData["parameters"],
classProps = classMetaData["properties"],
classMethods = classMetaData["methods"],
keyWordsArray = [name],
self = this;

var classInstance = new joint.shapes.uml.Class({
Expand All @@ -283,6 +306,7 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
params: (function (params) {
var arr = [], n;
for (n in params) {
keyWordsArray.push(n);
arr.push({
text: n + (params[n]["type"] ? ": " + params[n]["type"] : "")
});
Expand All @@ -292,6 +316,7 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
attributes: (function (ps) {
var arr = [], n;
for (n in ps) {
keyWordsArray.push(n);
arr.push({
text: n + (ps[n]["type"] ? ": " + ps[n]["type"] : ""),
icons: self.getMethodIcons(ps[n])
Expand All @@ -302,6 +327,7 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
methods: (function (met) {
var arr = [], n;
for (n in met) {
keyWordsArray.push(n);
arr.push({
text: n + (met[n]["returns"] ? ": " + met[n]["returns"] : ""),
styles: (function (t) {
Expand All @@ -319,6 +345,7 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
SYMBOL_12_WIDTH: self.SYMBOL_12_WIDTH
});

classInstance.SEARCH_KEYWORDS = keyWordsArray.join(",").toLowerCase();
this.objects.push(classInstance);
this.graph.addCell(classInstance);

Expand Down Expand Up @@ -562,6 +589,69 @@ ClassView.prototype.zoom = function (delta) {

};

/**
* Focus on joint instance.
* @param jointInstance
*/
ClassView.prototype.focusOnInstance = function (jointInstance) {

var bb = jointInstance.getBBox();

this.focusOnXY(bb.x + bb.width/2, bb.y + bb.height/2);

};

/**
* Focus on x and y coordinates considering scale.
* @param {number} x
* @param {number} y
*/
ClassView.prototype.focusOnXY = function (x, y) {

var sw = this.cacheUMLExplorer.elements.classViewContainer.offsetWidth,
sh = this.cacheUMLExplorer.elements.classViewContainer.offsetHeight,
scale = this.PAPER_SCALE;

this.paper.setOrigin(
-(x * scale) + sw/2,
-(y * scale) + sh/2
);

};

/**
* Find text on diagram and focus on element.
*
* @param {string} text
*/
ClassView.prototype.searchOnDiagram = function (text) {

var p, found = [], o;

if (!text) {
this.highlightElement(null);
return;
}

text = text.toLowerCase();

for (p in this.objects) {
if (this.objects[p].SEARCH_KEYWORDS.indexOf(text) !== -1) {
found.push(this.objects[p]);
}
}

if (found.length) {
o = found[this.SEARCH_INDEX % found.length];
this.focusOnInstance(o);
this.highlightElement(o);
return;
}

this.highlightElement(null);

};

ClassView.prototype.init = function () {

var p, self = this,
Expand Down Expand Up @@ -635,6 +725,19 @@ ClassView.prototype.init = function () {
this.cacheUMLExplorer.elements.helpButton.addEventListener("click", function () {
self.renderInfoGraphic();
});
this.cacheUMLExplorer.elements.diagramSearch.addEventListener("input", function (e) {
self.searchOnDiagram((e.target || e.srcElement).value);
});
this.cacheUMLExplorer.elements.diagramSearch.addEventListener("keydown", function (e) {
if (e.keyCode === 13) {
self.SEARCH_INDEX++;
self.searchOnDiagram((e.target || e.srcElement).value);
}
});
this.cacheUMLExplorer.elements.diagramSearchButton.addEventListener("click", function () {
self.SEARCH_INDEX++;
self.searchOnDiagram(self.cacheUMLExplorer.elements.diagramSearch.value);
});

this.SYMBOL_12_WIDTH = (function () {
var e = document.createElementNS("http://www.w3.org/2000/svg", "text"),
Expand Down
3 changes: 2 additions & 1 deletion web/js/Lib.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7400954

Please sign in to comment.