summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorelijahe2013-12-06 13:21:35 (EST)
committer Silenio Quarti2013-12-06 16:22:39 (EST)
commitdda852120689fc484efdc0011aa0f43fef178d1c (patch)
treed49dce1b618d5c6056daec051a72c73963ff536c
parent35b50f4bc7ae05fc7555359d794b8d9d5c889656 (diff)
downloadorg.eclipse.orion.client-dda852120689fc484efdc0011aa0f43fef178d1c.zip
org.eclipse.orion.client-dda852120689fc484efdc0011aa0f43fef178d1c.tar.gz
org.eclipse.orion.client-dda852120689fc484efdc0011aa0f43fef178d1c.tar.bz2
Bug 422499 - Filtering for outliner does not find non-visible items
- Part2 of fix, traverse recursively showing parents of leafs --Signed-off-by: Elijah El-Haddad <elijahe@ca.ibm.com>
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/edit/common.css5
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorerNavHandler.js6
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/outliner.js91
3 files changed, 75 insertions, 27 deletions
diff --git a/bundles/org.eclipse.orion.client.ui/web/edit/common.css b/bundles/org.eclipse.orion.client.ui/web/edit/common.css
index f4b6cd5..bca9b46 100644
--- a/bundles/org.eclipse.orion.client.ui/web/edit/common.css
+++ b/bundles/org.eclipse.orion.client.ui/web/edit/common.css
@@ -20,6 +20,10 @@
width: 250px;
}
+.outlineRowMatchesFilter {
+ font-weight:bold;
+}
+
.outlineRowHidden {
display: none;
}
@@ -36,4 +40,3 @@
margin-bottom: -3px;
cursor: pointer;
}
-
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorerNavHandler.js b/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorerNavHandler.js
index af18100..a7a2e8f 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorerNavHandler.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/explorers/explorerNavHandler.js
@@ -485,7 +485,7 @@ exports.ExplorerNavHandler = (function() {
return value && value.rowDomNode ? value.rowDomNode : lib.node(modelId);
},
- iterate: function(forward, forceExpand, selecting, visibleOnly) {
+ iterate: function(forward, forceExpand, selecting, selectableOnly /* optional */) {
var currentItem = null;
if(this.topIterationNodes.length === 0){
@@ -497,8 +497,8 @@ exports.ExplorerNavHandler = (function() {
this._setCursorOnItem(forward, selecting);
}
- if (visibleOnly && currentItem) {
- while (currentItem && currentItem.isHidden) {
+ if (selectableOnly && currentItem) {
+ while (currentItem && currentItem.isNotSelectable) {
currentItem = this._modelIterator.iterate(forward, forceExpand);
if(currentItem){
this._setCursorOnItem(forward, selecting);
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/outliner.js b/bundles/org.eclipse.orion.client.ui/web/orion/outliner.js
index 5af7ab9..a394128 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/outliner.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/outliner.js
@@ -117,41 +117,86 @@ define([
var navHandler = this.getNavHandler();
var itemMap = this.model.getIdItemMap();
var item = null;
+ var modifiedFilter = null;
- //Create a filter which matches all input literally except for the * and the ? characters
- //As is the case for the file search dialog: (* = any string) and (? = any character)
- var modifiedFilter = "^" + filter.replace(/([.+^=!:${}()|\[\]\/\\])/g, "\\$1"); //add start of line character and escape all special characters except * and ?
- modifiedFilter = modifiedFilter.replace(/([*?])/g, ".$1"); //convert user input * and ? to .* and .?
+ if (filter) {
+ //Create a filter which matches all input literally except for the * and the ? characters
+ //As is the case for the file search dialog: (* = any string) and (? = any character)
+ modifiedFilter = "^" + filter.replace(/([.+^=!:${}()|\[\]\/\\])/g, "\\$1"); //add start of line character and escape all special characters except * and ?
+ modifiedFilter = modifiedFilter.replace(/([*?])/g, ".$1"); //convert user input * and ? to .* and .?
- if (previousFilter) {
- if (0 !== filter.indexOf(previousFilter)) {
- //this is not a more specific version of the previous filter, expand again
+ //figure out if we need to expand
+ if (previousFilter) {
+ if (0 !== filter.indexOf(previousFilter)) {
+ //this is not a more specific version of the previous filter, expand again
+ this.expandAll();
+ }
+ } else {
+ //there was no previous filter, expand all
this.expandAll();
}
} else {
- //previous filter not defined, expand all
+ //filter was emptied, expand all
this.expandAll();
}
- for (var id in itemMap) {
- if (itemMap.hasOwnProperty(id)) {
- item = itemMap[id];
- if (-1 === item.label.search(modifiedFilter)) {
- //hide
- navHandler.getRowDiv(item).classList.add("outlineRowHidden"); //$NON-NLS-0$
- item.isHidden = true;
- } else {
- //label matches filter, show row
- //TODO show parent rows also
- navHandler.getRowDiv(item).classList.remove("outlineRowHidden"); //$NON-NLS-0$
- item.isHidden = false;
- }
- }
+ // filter the tree nodes recursively
+ // this should also be done if the passed in filter is empty
+ // because it will traverse all the nodes and reset their states
+ var topLevelNodes = navHandler.getTopLevelNodes();
+ for (var i = 0; i < topLevelNodes.length ; i++){
+ this._filterRecursively(topLevelNodes[i], modifiedFilter);
}
previousFilter = filter;
};
+ OutlineExplorer.prototype._filterRecursively = function (node, filter) {
+ var navHandler = this.getNavHandler();
+ var self = this;
+ var rowDiv = navHandler.getRowDiv(node);
+ // true if the filter is null or if the node's label matches it
+ var nodeMatchesFilter = !filter || (-1 !== node.label.search(filter));
+
+ if (node.children) {
+ // if this node has children ensure it is expanded otherwise we've already filtered it out
+ if (navHandler.isExpanded(node)) {
+ var hasVisibleChildren = false;
+ node.children.forEach(function(childNode){
+ if (self._filterRecursively(childNode, filter)) {
+ hasVisibleChildren = true;
+ }
+ });
+ }
+
+ if (!hasVisibleChildren) {
+ this.myTree.collapse(node);
+ }
+ }
+
+ // set row visibility
+ var visible = hasVisibleChildren || nodeMatchesFilter;
+ if (visible) {
+ //show row
+ rowDiv.classList.remove("outlineRowHidden"); //$NON-NLS-0$
+ } else {
+ //hide
+ rowDiv.classList.add("outlineRowHidden"); //$NON-NLS-0$
+ };
+
+ // set visual indicator for matching rows
+ if (filter && nodeMatchesFilter) {
+ rowDiv.classList.add("outlineRowMatchesFilter"); //$NON-NLS-0$
+ } else {
+ rowDiv.classList.remove("outlineRowMatchesFilter"); //$NON-NLS-0$
+ }
+
+ // set node's keyboard traversal selectability
+ node.isNotSelectable = !nodeMatchesFilter;
+
+ return visible;
+ };
+
function OutlineModel(items, rootId) {
this.items = items;
this.root = {children: items};
@@ -392,7 +437,7 @@ define([
if (navHandler.getTopLevelNodes()) {
firstNode = navHandler.getTopLevelNodes()[0];
navHandler.cursorOn(firstNode, false, true);
- if (firstNode.isHidden) {
+ if (firstNode.isNotSelectable) {
navHandler.iterate(true, false, false, true);
}
}