summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorelijahe2013-11-20 14:48:58 (EST)
committer Silenio Quarti2013-11-21 10:39:30 (EST)
commitafb9e15af04830e1d888988ef139a866e57f042c (patch)
treed33fa65c815fd36a519b6875c0a302c98721735c
parent0388876db29c23ba9d53cec68db4788a02015ab5 (diff)
downloadorg.eclipse.orion.client-afb9e15af04830e1d888988ef139a866e57f042c.zip
org.eclipse.orion.client-afb9e15af04830e1d888988ef139a866e57f042c.tar.gz
org.eclipse.orion.client-afb9e15af04830e1d888988ef139a866e57f042c.tar.bz2
Bug 394861 - outliner should provide filtering
- Moved filter input into sidebar toolbar area - Added primitive regexp filter support (* = any string, ? = any character) --Signed-off-by: Elijah El-Haddad <elijahe@ca.ibm.com>
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/edit/common.css11
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/nls/root/messages.js2
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/outliner.js80
3 files changed, 42 insertions, 51 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 e98d632..0007fcc 100644
--- a/bundles/org.eclipse.orion.client.ui/web/edit/common.css
+++ b/bundles/org.eclipse.orion.client.ui/web/edit/common.css
@@ -16,17 +16,10 @@
.outlineFilter {
border: 1px solid lightgrey;
- margin-left: 0;
text-align: left;
- position: fixed;
- top: 75px;
- left: 2px;
width: 250px;
-}
-
-.outlineFilterCell {
- min-height: 25px;
- height: 25px;
+ position: absolute;
+ top: 5px;
}
.outlineRowHidden {
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/nls/root/messages.js b/bundles/org.eclipse.orion.client.ui/web/orion/nls/root/messages.js
index 59780bf..4691011 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/nls/root/messages.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/nls/root/messages.js
@@ -86,5 +86,5 @@ define({
"OutlineProgress": "Getting outline for ${0} from ${1}",
"UnknownError": "An unknown error occurred.",
"UnknownWarning": "An unknown warning occurred.",
- "Filter": "Filter"
+ "Filter": "Filter (* = any string, ? = any character)"
});
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 9329569..24abd8e 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/outliner.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/outliner.js
@@ -81,45 +81,6 @@ define([
return link;
};
- OutlineRenderer.prototype.getCellHeaderElement = function(col_no){
- var th = null;
- var input;
-
- if (0 === col_no) {
- th = document.createElement("th"); //$NON-NLS-0$
- th.classList.add("outlineFilterCell");
-
- input = document.createElement("input"); //$NON-NLS-0$
- input.className = "outlineFilter"; //$NON-NLS-0$
- input.placeholder = messages["Filter"]; //$NON-NLS-0$
- input.type="text"; //$NON-NLS-0$
- input.addEventListener("input", function (e) { //$NON-NLS-0$
- this.explorer.filterChanged(input.value);
- }.bind(this));
-
- input.addEventListener("keydown", function (e) { //$NON-NLS-0$
- var navHandler = null;
- var firstNode = null;
- if (e.keyCode === lib.KEY.DOWN) {
- input.blur();
- navHandler = this.explorer.getNavHandler();
- navHandler.focus();
- if (navHandler.getTopLevelNodes()) {
- firstNode = navHandler.getTopLevelNodes()[0];
- navHandler.cursorOn(firstNode, false, true);
- if (firstNode.isHidden) {
- navHandler.iterate(true, false, false, true);
- }
- }
- }
- }.bind(this), false);
-
- th.appendChild(input);
- }
-
- return th;
- };
-
//This is an optional function for explorerNavHandler. It performs an action when Enter is pressed on a table row.
//The explorerNavHandler hooked up by the explorer will check if this function exists and call it on Enter key press.
OutlineRenderer.prototype.performRowAction = function(event, item) {
@@ -154,12 +115,17 @@ define([
OutlineExplorer.prototype.filterChanged = function (filter) {
var navHandler = this.getNavHandler();
var itemMap = this.model.getIdItemMap();
- var item;
+ var item = 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 .?
for (var id in itemMap) {
if (itemMap.hasOwnProperty(id)) {
item = itemMap[id];
- if (-1 === item.label.indexOf(filter)) {
+ if (-1 === item.label.search(modifiedFilter)) {
//hide
navHandler.getRowDiv(item).classList.add("outlineRowHidden"); //$NON-NLS-0$
item.isHidden = true;
@@ -374,6 +340,7 @@ define([
},
createViewMode: function(provider) {
this.setSelectedProvider(provider);
+ this._createFilterInput();
this.generateOutline();
},
destroyViewMode: function(provider) {
@@ -382,6 +349,37 @@ define([
this.explorer = null;
}
},
+
+ _createFilterInput: function() {
+ var input = document.createElement("input"); //$NON-NLS-0$
+
+ input.classList.add("outlineFilter"); //$NON-NLS-0$
+ input.placeholder = messages["Filter"]; //$NON-NLS-0$
+ input.type="text"; //$NON-NLS-0$
+ input.addEventListener("input", function (e) { //$NON-NLS-0$
+ this.explorer.filterChanged(input.value);
+ }.bind(this));
+
+ input.addEventListener("keydown", function (e) { //$NON-NLS-0$
+ var navHandler = null;
+ var firstNode = null;
+ if (e.keyCode === lib.KEY.DOWN) {
+ input.blur();
+ navHandler = this.explorer.getNavHandler();
+ navHandler.focus();
+ if (navHandler.getTopLevelNodes()) {
+ firstNode = navHandler.getTopLevelNodes()[0];
+ navHandler.cursorOn(firstNode, false, true);
+ if (firstNode.isHidden) {
+ navHandler.iterate(true, false, false, true);
+ }
+ }
+ }
+ }.bind(this), false);
+
+ this._toolbar.appendChild(input);
+ },
+
/**
* Called when the inputManager's contentType has changed, so we need to look up the capable outline providers.
* @param {String} fileContentType