Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix for Bug 370050. Images in the open resources dialog.
  • Loading branch information
Andrew Eisenberg committed Feb 3, 2012
1 parent 996dca5 commit 8ada97d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bundles/org.eclipse.orion.client.core/web/edit/setup.js
Expand Up @@ -338,7 +338,7 @@ exports.setUpEditor = function(serviceRegistry, preferences, isReadOnly){
dojo.place(document.createTextNode("\"" + searchPattern + "\"..."), b, "only");
searchFloat.style.display = "block";
var query = searcher.createSearchQuery(searchPattern, null, "Name");
var renderer = mSearchRenderer.makeRenderFunction(searchFloat, false, null);
var renderer = mSearchRenderer.makeRenderFunction(searchFloat, false);
searcher.search(query, inputManager.getInput(), renderer);
}, 0);
return true;
Expand Down
Expand Up @@ -26,10 +26,12 @@ define( ['require', 'dojo', 'dijit', 'orion/auth', 'orion/util', 'orion/searc
* @public
* @param {DOMNode} resultsNode Node under which results will be added.
* @param {String} [heading] the heading text (HTML), or null if none required
* @param {Function(DOMNode)} [onResultReady] If any results were found, this is called on the resultsNode.
* @param {Function(DOMNode)} onResultReady (optional) If any results were found, this is called on the resultsNode.
* @param {Function(DOMNode)} decorator (optional) A function to be called that knows how to decorate each row in the result table
* This function is passed a <td> element.
* @returns a render function.
*/
function makeRenderFunction(resultsNode, heading, onResultReady) {
function makeRenderFunction(resultsNode, heading, onResultReady, decorator) {

/**
* Displays links to resources under the given DOM node.
Expand Down Expand Up @@ -75,7 +77,7 @@ define( ['require', 'dojo', 'dijit', 'orion/auth', 'orion/util', 'orion/searc

var foundValidHit = false;
dojo.empty(resultsNode);
if (resources.length > 0) {
if (resources && resources.length > 0) {
var table = document.createElement('table');
for (var i=0; i < resources.length; i++) {
var resource = resources[i];
Expand Down Expand Up @@ -112,6 +114,9 @@ define( ['require', 'dojo', 'dijit', 'orion/auth', 'orion/util', 'orion/searc
resourceLink.setAttribute('href', loc);
col.appendChild(resourceLink);
appendPath(col, resource);
if (decorator) {
decorator(col);
}
}
dojo.place(table, resultsNode, "last");
if (typeof(onResultReady) === "function") {
Expand Down
Expand Up @@ -162,14 +162,25 @@ var OpenResourceDialog = dojo.declare("orion.widgets.OpenResourceDialog", [dijit
if (favs.navigator) {
favs = favs.navigator;
}
var renderFunction = that.searchRenderer.makeRenderFunction(that.favresults, false, dojo.hitch(that, that.decorateResult));
var renderFunction = that.searchRenderer.makeRenderFunction(that.favresults, false,
dojo.hitch(that, that.decorateResult), that.showFavoritesImage);
renderFunction(favs);
if (favs && favs.length > 0) {
dojo.place("<hr/>", that.favresults, "last");
}
};
},

/** @private */
showFavoritesImage : function(col) {
var image = new Image();
dojo.addClass(image, "commandSprite");
dojo.addClass(image, "core-sprite-makeFavorite");
dojo.addClass(image, "commandImage");
// without an image, chrome will draw a border (?)
image.src = require.toUrl("images/none.png");
col.appendChild(image);
},

/** @private */
checkSearch: function() {
Expand Down Expand Up @@ -200,7 +211,7 @@ var OpenResourceDialog = dojo.declare("orion.widgets.OpenResourceDialog", [dijit
var that = this;
setTimeout(function() {
var query = that.searcher.createSearchQuery(null, text, "Name");
var renderFunction = that.searchRenderer.makeRenderFunction(that.results, false, dojo.hitch(that, that.decorateResult), true);
var renderFunction = that.searchRenderer.makeRenderFunction(that.results, false, dojo.hitch(that, that.decorateResult));
that.searcher.search(query, false, renderFunction);
}, 0);
}
Expand Down

0 comments on commit 8ada97d

Please sign in to comment.