summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorelijahe <elijahe@ca.ibm.com>2014-05-22 16:50:12 -0400
committerelijahe <elijahe@ca.ibm.com>2014-05-22 16:50:12 -0400
commit8b3d8d1e7926147e442e7e641c811f3fd93eec0e (patch)
tree515e9ef20fb119fd1fdbf52c1ff8281363364ccb
parent3a5e26a9dd428e473be77c82a17e03e3153de47b (diff)
downloadorg.eclipse.orion.client-origin/searchMultipleFolders.zip
org.eclipse.orion.client-origin/searchMultipleFolders.tar.gz
org.eclipse.orion.client-origin/searchMultipleFolders.tar.bz2
Multiple folder selection WIPorigin/searchMultipleFolders
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/crawler/searchCrawler.js69
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/globalSearch/advSearchOptContainer.js70
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/searchResults.js2
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js6
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/search/search.js26
5 files changed, 109 insertions, 64 deletions
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/crawler/searchCrawler.js b/bundles/org.eclipse.orion.client.ui/web/orion/crawler/searchCrawler.js
index 76b7b8f..825f15b 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/crawler/searchCrawler.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/crawler/searchCrawler.js
@@ -38,7 +38,7 @@ define(['i18n!orion/crawler/nls/messages', 'require', 'orion/i18nUtil', 'orion/s
this._searchParams = searchParams;
this.searchHelper = (this._searchOnName || this._buildSkeletonOnly) ? null: mSearchUtils.generateSearchHelper(searchParams);
this._location = options && options.location;
- this._childrenLocation = options && options.childrenLocation ? options.childrenLocation : this._location;
+ this._childrenLocation = options && options.childrenLocation ? options.childrenLocation : this._location;
this._reportOnCancel = options && options.reportOnCancel;
this._cancelled = false;
this._statusService = this.registry.getService("orion.page.message"); //$NON-NLS-0$
@@ -192,39 +192,48 @@ define(['i18n!orion/crawler/nls/messages', 'require', 'orion/i18nUtil', 'orion/s
return matches;
};
- SearchCrawler.prototype._visitRecursively = function(directoryLocation){
- var results = [];
+ SearchCrawler.prototype._visitRecursively = function(directoryLocations){
+ var allDeferreds = [];
var _this = this;
- if(this._fetchChildrenCallBack){
- this._fetchChildrenCallBack(directoryLocation);
- }
- return (_this._progressService ? this._progressService.progress(_this.fileClient.fetchChildren(directoryLocation), "Crawling search for children of " + directoryLocation) : _this.fileClient.fetchChildren(directoryLocation)).then(function(children) { //$NON-NLS-0$
- for (var i = 0; i < children.length ; i++){
- if(children[i].Directory!==undefined && children[i].Directory===false){
- if(_this._searchOnName){
- results.push(_this._buildSingleSkeleton(children[i]));
- } else if(_this._buildSkeletonOnly){
- results.push(_this._buildSingleSkeleton(children[i]));
- }else if(!_this._cancelled) {
- var contentType = mContentTypes.getFilenameContentType(children[i].Name, _this.contentTypesCache);
- if(contentType && (contentType['extends'] === "text/plain" || contentType.id === "text/plain") && _this._fileNameMatches(children[i].Name)){ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
- var fileDeferred = _this._sniffSearch(children[i]);
- results.push(fileDeferred);
- _this._deferredArray.push(fileDeferred);
+
+ directoryLocations.forEach(function(directoryLocation){
+ var results = [];
+ if(this._fetchChildrenCallBack){
+ this._fetchChildrenCallBack(directoryLocation);
+ }
+
+ var directoryDeferred = (_this._progressService ? this._progressService.progress(_this.fileClient.fetchChildren(directoryLocation), "Crawling search for children of " + directoryLocation) : _this.fileClient.fetchChildren(directoryLocation)).then(function(children) { //$NON-NLS-0$
+ for (var i = 0; i < children.length ; i++){
+ if(children[i].Directory!==undefined && children[i].Directory===false){
+ if(_this._searchOnName){
+ results.push(_this._buildSingleSkeleton(children[i]));
+ } else if(_this._buildSkeletonOnly){
+ results.push(_this._buildSingleSkeleton(children[i]));
+ }else if(!_this._cancelled) {
+ var contentType = mContentTypes.getFilenameContentType(children[i].Name, _this.contentTypesCache);
+ if(contentType && (contentType['extends'] === "text/plain" || contentType.id === "text/plain") && _this._fileNameMatches(children[i].Name)){ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ var fileDeferred = _this._sniffSearch(children[i]);
+ results.push(fileDeferred);
+ _this._deferredArray.push(fileDeferred);
+ }
+ }
+ } else if (children[i].Location) {
+ if(_this._cancelled) {
+ break;
+ } else {
+ var folderDeferred = _this._visitRecursively([children[i].ChildrenLocation]);
+ results.push(folderDeferred);
+ _this._deferredArray.push(folderDeferred);
}
- }
- } else if (children[i].Location) {
- if(_this._cancelled) {
- break;
- } else {
- var folderDeferred = _this._visitRecursively(children[i].ChildrenLocation);
- results.push(folderDeferred);
- _this._deferredArray.push(folderDeferred);
}
}
- }
- return Deferred.all(results);
- });
+ return Deferred.all(results);
+ });
+
+ allDeferreds.push(directoryDeferred);
+ }, this);
+
+ return Deferred.all(allDeferreds);
};
SearchCrawler.prototype._hitOnceWithinFile = function( fileContentText){
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/globalSearch/advSearchOptContainer.js b/bundles/org.eclipse.orion.client.ui/web/orion/globalSearch/advSearchOptContainer.js
index 12da19e..ee2f000 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/globalSearch/advSearchOptContainer.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/globalSearch/advSearchOptContainer.js
@@ -94,7 +94,7 @@ define([
var resource = ""; //$NON-NLS-0$
this._searchLocations.forEach(function(searchLocation){
if (resource) {
- resource = resource.concat(","); //$NON-NLS-0$
+ resource = resource.concat(":"); //$NON-NLS-0$
}
resource = resource.concat(searchLocation);
}, this);
@@ -115,7 +115,9 @@ define([
loadSearchParams: function(searchParams){
this._searchParams = searchParams;
//TODO handle resource parameter containing multiple resources once multiple file/folder search is enabled (see getOptions())
- this._rootURL = this.fileClient.fileServiceRootURL(this._searchParams.resource);
+ this._rootURL = this.fileClient.fileServiceRootURL(this._searchParams.resource.split(":")[0]);
+
+ this._searchLocations = this._searchParams.resource.split(":");
var loadRootOnly = function() {
this._searchLocations = [this._rootURL];
@@ -126,19 +128,17 @@ define([
this.dispatchEvent({type: "rootChanged", root: this._rootURL}); //$NON-NLS-0$
if ((this._searchParams.resource.length > 0) && (this._rootURL !== this._searchParams.resource)) {
- this._serviceRegistry.getService("orion.page.progress").progress(this.fileClient.read(this._searchParams.resource, true), "Getting file metadata " + this._searchParams.resource).then( //$NON-NLS-1$ //$NON-NLS-0$
- function(meta) {
- if (this._searchScopeSection) {
- this._searchLocations = [this._searchParams.resource];
-
- if (this._searchScopeExplorer) {
- this._searchScopeExplorer.loadRoot(this._rootURL).then(function(){
- this._searchScopeExplorer.reveal(meta);
- }.bind(this));
- }
- }
- }.bind(this),
- loadRootOnly);
+ if (this._searchScopeSection && this._searchScopeExplorer) {
+ this._searchScopeExplorer.loadRoot(this._rootURL).then(function(){
+ this._searchLocations.forEach(function(resource){
+ this._serviceRegistry.getService("orion.page.progress").progress(this.fileClient.read(resource, true), "Getting file metadata " + resource).then( //$NON-NLS-1$ //$NON-NLS-0$
+ function(meta) {
+ this._searchScopeExplorer.reveal(meta);
+ }.bind(this),
+ loadRootOnly);
+ }, this);
+ }.bind(this));
+ }
} else {
loadRootOnly();
}
@@ -387,8 +387,11 @@ define([
}.bind(this));
this._fileNamePatternsInput.addEventListener("blur", function(){
- var correctedPatterns = mSearchUtils.getFileNamePatternsArray(this._fileNamePatternsInput.value).join(", ");
- this._fileNamePatternsInput.value = correctedPatterns;
+ var patternString = this._fileNamePatternsInput.value;
+ if (patternString) {
+ var correctedPatterns = mSearchUtils.getFileNamePatternsArray(patternString).join(", ");
+ this._fileNamePatternsInput.value = correctedPatterns;
+ }
this._fileNamePatternsHint.classList.remove("fileNamePatternsHintVisible"); //$NON-NLS-0$
}.bind(this));
@@ -405,14 +408,13 @@ define([
},
_initSearchScope: function() {
- this._searchLocations = [];
var resource = mPageUtil.matchResourceParameters().resource;
this._rootURL = this.fileClient.fileServiceRootURL(resource);
if (resource) {
- this._searchLocations.push(resource);
+ this._searchLocations = resource.split(":"); //$NON-NLS-0$
} else {
- this._searchLocations.push(this._rootURL);
+ this._searchLocations = [this._rootURL];
}
this._searchScopeDiv = lib.$("#searchScope", this._parentDiv); //$NON-NLS-0$
@@ -442,7 +444,7 @@ define([
}
if (this._searchLocations) {
- this._searcher.setLocationbyURL(this._searchLocations.join(","));
+ this._searcher.setLocationbyURL(this._searchLocations.join(":"));
}
this._setSearchScopeTitle();
@@ -460,7 +462,7 @@ define([
});
this._searchScopeSection.embedExplorer(this._searchScopeExplorer, scopeExplorerNode);
- this._searchScopeExplorer.setCommandsVisible(true, "singleSelection"); //$NON-NLS-0$ //TODO remove "singleSelection" once multiple selection is supported
+ this._searchScopeExplorer.setCommandsVisible(true);
this._searchScopeExplorer.loadRoot(this._rootURL);
},
@@ -627,6 +629,30 @@ define([
loadRoot: function(root) {
var path = root || this.fileClient.fileServiceRootURL();
return this.loadResourceList(path);
+ },
+ // Overrides FileExplorer.reveal(item, root)
+ reveal: function(item, reroot) {
+ return this.showItem(item, reroot).then(function(result) {
+ var navHandler = this.getNavHandler();
+ if (navHandler) {
+ navHandler.cursorOn(result, true);
+
+ var selections = this.selection.getSelections();
+ var model = null;
+ var alreadySelected = selections.some(function(selection){
+ if (selection.Location === result.Location){
+ return true; //found it, stop iterating
+ }
+ return false;
+ });
+
+ if (!alreadySelected) {
+ //select model
+ navHandler.setSelection(result, true, true);
+ }
+ }
+ return result;
+ }.bind(this));
}
});
ScopeExplorer.prototype.constructor = ScopeExplorer;
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/searchResults.js b/bundles/org.eclipse.orion.client.ui/web/orion/searchResults.js
index e6f4401..d349f5a 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/searchResults.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/searchResults.js
@@ -90,7 +90,7 @@ define(['i18n!orion/search/nls/messages', 'orion/i18nUtil','require', 'orion/web
if(this.crawling){
lib.empty(parent);
parent.appendChild(document.createTextNode(""));
- crawler = new mSearchCrawler.SearchCrawler(this.registry, this.fileService, searchParams, {childrenLocation: this.searcher.getChildrenLocation()});
+ crawler = new mSearchCrawler.SearchCrawler(this.registry, this.fileService, searchParams, {location: this.searcher.getSearchLocation()});
crawler.search(function(jsonData, incremental){that._renderSearchResult(true, resultsNode, searchParams, jsonData, incremental);});
} else {
lib.empty(parent);
diff --git a/bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js b/bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js
index ca0f946..62ae418 100644
--- a/bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js
+++ b/bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js
@@ -125,7 +125,9 @@ define(["orion/Deferred", "orion/xhr", "orion/URL-shim", "orion/operation", "ori
newKeyword = encodeURIComponent(newKeyword);
}
}
- return "?" + "sort=" + newSort + "&rows=" + searchParams.rows + "&start=" + searchParams.start + "&q=" + newKeyword + "+Location:" + searchParams.resource + "*";
+ var location = searchParams.resource.split(":");
+ location = location.join("*:") + "*";
+ return "?" + "sort=" + newSort + "&rows=" + searchParams.rows + "&start=" + searchParams.start + "&q=" + newKeyword + "+Location:" + location;
}
/**
@@ -638,4 +640,4 @@ define(["orion/Deferred", "orion/xhr", "orion/URL-shim", "orion/operation", "ori
}
return FileServiceImpl;
-}); \ No newline at end of file
+});
diff --git a/bundles/org.eclipse.orion.client.ui/web/search/search.js b/bundles/org.eclipse.orion.client.ui/web/search/search.js
index 4a8b5dc..3404fa4 100644
--- a/bundles/org.eclipse.orion.client.ui/web/search/search.js
+++ b/bundles/org.eclipse.orion.client.ui/web/search/search.js
@@ -19,22 +19,30 @@ define(['i18n!orion/search/nls/messages', 'require', 'orion/browserCompatibility
mSearchClient, mFileClient, mOperationsClient, mSearchResults, mGlobalCommands, mContentTypes, mSearchUtils, PageUtil, lib, mAdvSearchOptContainer) {
function setPageInfo(serviceRegistry, fileClient, commandService, searcher, searchResultsGenerator, searchBuilder, searchParams, progress){
- var searchLoc = searchParams.resource;
+ var searchLoc = searchParams.resource.split(":");
var title = searchParams.replace ? messages["Replace All Matches"] : messages["Search Results"];
- if(searchLoc){
- if(searchLoc === fileClient.fileServiceRootURL(searchLoc)){
- searcher.setRootLocationbyURL(searchLoc);
- searcher.setLocationbyURL(searchLoc);
+ if(searchLoc && searchLoc[0]){
+ var rootURL = fileClient.fileServiceRootURL(searchLoc[0]);
+ if(searchLoc[0] === rootURL){
+ searcher.setRootLocationbyURL(rootURL);
+ searcher.setLocationbyURL(searchParams.resource);
mGlobalCommands.setPageTarget({task: "Search", title: title, serviceRegistry: serviceRegistry, //$NON-NLS-0$
commandService: commandService, searchService: searcher, fileService: fileClient, breadcrumbRootName: "Search", staticBreadcrumb: true}); //$NON-NLS-0$
- searcher.setChildrenLocationbyURL(searchLoc);
+ searcher.setChildrenLocationbyURL(searchParams.resource);
searchBuilder.loadSearchParams(searchParams);
searchResultsGenerator.loadResults(searchParams);
} else {
- (progress ? progress.progress(fileClient.read(searchLoc, true), "Loading file metadata " + searchLoc) : fileClient.read(searchLoc, true)).then( //$NON-NLS-0$
+ (progress ? progress.progress(fileClient.read(searchLoc[0], true), "Loading file metadata " + searchLoc[0]) : fileClient.read(searchLoc[0], true)).then( //$NON-NLS-0$
function(metadata) {
- mGlobalCommands.setPageTarget({task: "Search", title: title, target: metadata, serviceRegistry: serviceRegistry, //$NON-NLS-0$
- fileService: fileClient, commandService: commandService, searchService: searcher, staticBreadcrumb: true, breadcrumbRootName: "Search"}); //$NON-NLS-0$
+// mGlobalCommands.setPageTarget({task: "Search", title: title, target: metadata, serviceRegistry: serviceRegistry, //$NON-NLS-0$
+// fileService: fileClient, commandService: commandService, searchService: searcher, staticBreadcrumb: true, breadcrumbRootName: "Search"}); //$NON-NLS-0$
+// searchBuilder.loadSearchParams(searchParams);
+// searchResultsGenerator.loadResults(searchParams);
+ searcher.setRootLocationbyURL(rootURL);
+ searcher.setLocationbyURL(searchParams.resource);
+ mGlobalCommands.setPageTarget({task: "Search", title: title, serviceRegistry: serviceRegistry, //$NON-NLS-0$
+ commandService: commandService, searchService: searcher, fileService: fileClient, staticBreadcrumb: true, breadcrumbRootName: "Search"}); //$NON-NLS-0$
+ searcher.setChildrenLocationbyURL(searchParams.resource);
searchBuilder.loadSearchParams(searchParams);
searchResultsGenerator.loadResults(searchParams);
}.bind(this),