Skip to content

Commit 561fd1a

Browse files
Show only mapped classes checkbox add
1 parent ceeee06 commit 561fd1a

7 files changed

+65
-26
lines changed

cache/projectTemplate.xml

+10-8
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,24 @@ Return list with all namespaces</Description>
3232
<Description>
3333
Returns structured class tree with all classes available in current namespace</Description>
3434
<ClassMethod>1</ClassMethod>
35-
<FormalSpec>namespace:%String</FormalSpec>
35+
<FormalSpec>namespace:%String,showMapped=0</FormalSpec>
3636
<ReturnType>%ZEN.proxyObject</ReturnType>
3737
<Implementation><![CDATA[
3838
zn:$GET(namespace)'="" namespace
3939
set resp = ##class(%ZEN.proxyObject).%New()
4040
41-
set classes = ##class(%ResultSet).%New("%Dictionary.ClassDefinition:Summary")
41+
set showSystem = (namespace="%SYS")
42+
do $System.OBJ.GetClassList(.classes, "/system="_showSystem_" /percent="
43+
_showSystem_" /mapped=" _ showMapped)
4244
set objects = ##class(%Library.ArrayOfObjects).%New()
4345
set lastParts = $LB()
4446
4547
set level = 1
4648
do objects.SetAt(resp, level)
4749
48-
do classes.Execute()
49-
while (classes.Next()) {
50-
set name = classes.Data("Name")
51-
if ($EXTRACT(name, 1, 1) = "%") && ($NAMESPACE '= "%SYS") { continue }
50+
set name = $order(classes(""))
51+
while (name '= "") {
52+
//if ($EXTRACT(name, 1, 1) = "%") && ($NAMESPACE '= "%SYS") { continue }
5253
set parts = $LISTFROMSTRING(name, ".")
5354
set level = 1
5455
while ((level < $LISTLENGTH(parts)) && ($LISTGET(lastParts, level) = ("/"_$LISTGET(parts, level)))) {
@@ -67,12 +68,13 @@ Returns structured class tree with all classes available in current namespace</D
6768
do objects.SetAt(resp, level)
6869
}
6970
if ($LISTLENGTH(parts) = level) {
70-
do resp.%DispatchSetProperty($LISTGET(parts, level), classes.Data("Hidden"))
71+
do resp.%DispatchSetProperty($LISTGET(parts, level), 0)
7172
}
7273
set lastParts = parts
7374
for i=1:1:$LISTLENGTH(lastParts)-1 {
7475
set $LIST(lastParts, i) = "/"_$LISTGET(lastParts, i)
7576
}
77+
set name = $order(classes(name))
7678
}
7779
7880
quit objects.GetAt(1)
@@ -461,7 +463,7 @@ Method returns whole class tree visible in the current namespace.</Description>
461463
<ClassMethod>1</ClassMethod>
462464
<ReturnType>%Status</ReturnType>
463465
<Implementation><![CDATA[
464-
do ##class(ClassExplorer.ClassView).getClassTree(%request.Get("namespace")).%ToJSON(, "o")
466+
do ##class(ClassExplorer.ClassView).getClassTree(%request.Get("namespace"), %request.Get("mapped")).%ToJSON(, "o")
465467
return $$$OK
466468
]]></Implementation>
467469
</Method>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "CacheClassExplorer",
3-
"version": "1.18.1",
3+
"version": "1.19.0",
44
"description": "Class Explorer for InterSystems Caché",
55
"directories": { "test": "test" },
66
"dependencies": {},

web/css/treeView.css

+12-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
z-index: 1;
1717
}
1818

19-
.ui-sideSearchBlock > input {
19+
.ui-sideSearchBlock input[type=search] {
2020
display: block;
2121
box-sizing: border-box;
2222
border: 1px solid gray;
@@ -26,6 +26,17 @@
2626
height: 22px;
2727
}
2828

29+
.ui-sideSearchBlock label {
30+
cursor: pointer;
31+
user-select: none;
32+
-moz-user-select: none;
33+
-ms-user-select: none;
34+
}
35+
36+
.ui-sideSearchBlock input[type=checkbox] {
37+
vertical-align: middle;
38+
}
39+
2940
.tv-package-name.minimized + .tv-package-content {
3041
display: none;
3142
}

web/index.html

+9-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@
3838
<div class="ui-body" id="ui-body">
3939
<div class="ui-sideBlock">
4040
<div class="ui-sideSearchBlock" id="searchBlock">
41-
<input type="search" id="classTreeSearch" placeholder="Search in class tree..."/>
41+
<div>
42+
<label>
43+
<input type="checkbox" id="showMappedCheckbox"/>
44+
Show Mapped Classes
45+
</label>
46+
</div>
47+
<div>
48+
<input type="search" id="classTreeSearch" placeholder="Search in class tree..."/>
49+
</div>
4250
</div>
4351
<div id="treeView">
4452

web/js/CacheClassExplorer.js

+3-10
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ var CacheClassExplorer = function (treeViewContainer, classViewContainer) {
5050
subLabel: id("subLabel"),
5151
closeHelp: id("closeHelp"),
5252
settingsExtraText: id("settingsExtraText"),
53+
showMappedCheckbox: id("showMappedCheckbox"),
5354
settings: {
5455
showDataTypesOnDiagram: id("setting.showDataTypesOnDiagram"),
5556
showClassIcons: id("setting.showClassIcons"),
@@ -150,16 +151,10 @@ CacheClassExplorer.prototype.updateNamespaces = function (nsData) {
150151
*/
151152
CacheClassExplorer.prototype.setNamespace = function (namespace) {
152153

153-
var self = this;
154-
155154
this.NAMESPACE = namespace;
156155
this.classTree.setSelectedClassList([]);
157156

158-
self.classTree.container.textContent = "";
159-
self.classTree.showLoader();
160-
this.source.getClassTree(function (err, data) {
161-
if (!err) self.classTree.updateTree(data);
162-
});
157+
this.classTree.update();
163158

164159
this.updateNamespace();
165160
this.updateURL();
@@ -269,9 +264,7 @@ CacheClassExplorer.prototype.init = function () {
269264

270265
restored = this.restoreFromURL();
271266
this.classTree.showLoader();
272-
this.source.getClassTree(function (err, data) {
273-
if (!err) self.classTree.updateTree(data);
274-
});
267+
this.classTree.init();
275268
this.source.getNamespacesInfo(function (err, data) {
276269
if (restored && restored.namespace) data.currentNamespace = restored.namespace;
277270
if (!err) self.updateNamespaces(data);

web/js/ClassTree.js

+26-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var ClassTree = function (parent, treeViewContainer) {
1515
this.SELECTED_TYPE = null; // "class" || "package"
1616
this.SELECTED_ELEMENT = null;
1717
this.SELECTED_LEVEL = null;
18+
this.INCLUDE_MAPPED = this.cacheClassExplorer.elements.showMappedCheckbox.checked;
1819
this.treeObject = null;
1920
/**
2021
* @private
@@ -25,6 +26,10 @@ var ClassTree = function (parent, treeViewContainer) {
2526
this.cacheClassExplorer.elements.classTreeSearch.addEventListener("input", function (e) {
2627
self.searchChanged.call(self, (e.target || e.srcElement).value);
2728
});
29+
this.cacheClassExplorer.elements.showMappedCheckbox.addEventListener("change", function () {
30+
self.INCLUDE_MAPPED = self.cacheClassExplorer.elements.showMappedCheckbox.checked;
31+
self.update();
32+
});
2833

2934
window.addEventListener("resize", function () {
3035
self.updateSizes();
@@ -34,6 +39,19 @@ var ClassTree = function (parent, treeViewContainer) {
3439

3540
};
3641

42+
ClassTree.prototype.update = function () {
43+
44+
var self = this;
45+
46+
this.cacheClassExplorer.elements.classTreeSearch.value = "";
47+
this.container.textContent = "";
48+
this.showLoader();
49+
this.cacheClassExplorer.source.getClassTree(this.INCLUDE_MAPPED, function (err, data) {
50+
if (!err) self.updateTree(data);
51+
});
52+
53+
};
54+
3755
ClassTree.prototype.setSelectedClassList = function (list) {
3856

3957
// this enables saved view to be consistent for any class names order
@@ -70,7 +88,8 @@ ClassTree.prototype.removeLoader = function () {
7088
if (!this.loader) return;
7189

7290
this.cacheClassExplorer.elements.classTreeSearch.value = "";
73-
this.loader.parentNode.removeChild(this.loader);
91+
if (this.loader.parentNode)
92+
this.loader.parentNode.removeChild(this.loader);
7493
this.loader = null;
7594

7695
};
@@ -255,7 +274,7 @@ ClassTree.prototype.updateTree = function (treeObject, doNotChangeRoot) {
255274
arr = [];
256275

257276
for (i in object) {
258-
arr.push({ name: getRealName(i), val: object[i] });
277+
arr.push({ name: getRealName(i), val: object[i], isPackage: i[0] === "/" });
259278
}
260279

261280
arr.sort(function (a, b) {
@@ -268,7 +287,7 @@ ClassTree.prototype.updateTree = function (treeObject, doNotChangeRoot) {
268287
if (rec = append(
269288
rootElement,
270289
element.name,
271-
typeof element.val === "object",
290+
element.isPackage,
272291
path.join("."),
273292
level
274293
)) {
@@ -282,4 +301,8 @@ ClassTree.prototype.updateTree = function (treeObject, doNotChangeRoot) {
282301

283302
if (!doNotChangeRoot) this.treeObject = treeObject;
284303

304+
};
305+
306+
ClassTree.prototype.init = function () {
307+
this.update();
285308
};

web/js/Source.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ var Source = function (cacheUMLExplorer) {
99

1010
/**
1111
* Return class tree.
12+
* @param {boolean} includeMapped
1213
* @param {Source~dataCallback} callback
1314
*/
14-
Source.prototype.getClassTree = function (callback) {
15+
Source.prototype.getClassTree = function (includeMapped, callback) {
1516

1617
lib.load(
1718
this.URL + "/GetClassTree"
18-
+ (this.cue.NAMESPACE ? "?namespace=" + encodeURIComponent(this.cue.NAMESPACE) : ""),
19+
+ (this.cue.NAMESPACE ? "?namespace=" + encodeURIComponent(this.cue.NAMESPACE) : "")
20+
+ "&mapped=" + (includeMapped ? "1" : "0"),
1921
null,
2022
callback
2123
);

0 commit comments

Comments
 (0)