summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorAndrew Eisenberg2012-01-21 01:22:01 (EST)
committer sfranklin2012-01-21 16:16:53 (EST)
commit3330a4c1cb7617cb66e3032cb6768da6c23a9260 (patch)
tree59f594a3faecad553bf5f43de9e67a14c75abffb
parent9141f44ecb33890f119ff586d8bc0487c920dff9 (diff)
downloadorg.eclipse.orion.client-3330a4c1cb7617cb66e3032cb6768da6c23a9260.zip
org.eclipse.orion.client-3330a4c1cb7617cb66e3032cb6768da6c23a9260.tar.gz
org.eclipse.orion.client-3330a4c1cb7617cb66e3032cb6768da6c23a9260.tar.bz2
Fix for bug369010, bug 368896, and bug 349785.
No duplicates allowed for favorites. Case insensitive sorting of favorites.
-rw-r--r--bundles/org.eclipse.orion.client.core/web/orion/favorites.js15
-rw-r--r--bundles/org.eclipse.orion.client.core/web/orion/fileCommands.js16
-rw-r--r--bundles/org.eclipse.orion.client.core/web/orion/navoutliner.js9
3 files changed, 36 insertions, 4 deletions
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/favorites.js b/bundles/org.eclipse.orion.client.core/web/orion/favorites.js
index 0ff2439..a516dc2 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/favorites.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/favorites.js
@@ -112,6 +112,15 @@ define(['require', 'dojo', 'orion/util'], function(require, dojo, mUtil){
this._notifyListeners();
},
+ hasFavorite: function(path) {
+ for (var i in this._favorites) {
+ if (this._favorites[i].path === path) {
+ return true;
+ }
+ }
+ return false;
+ },
+
removeSearch: function(query) {
for (var i in this._searches) {
if (this._searches[i].query === query) {
@@ -186,9 +195,11 @@ define(['require', 'dojo', 'orion/util'], function(require, dojo, mUtil){
},
_sorter: function(fav1,fav2) {
- if (fav1.name > fav2.name) {
+ var name1 = fav1.name.toLowerCase();
+ var name2 = fav2.name.toLowerCase();
+ if (name1 > name2) {
return 1;
- } else if (fav1.name < fav2.name) {
+ } else if (name1 < name2) {
return -1;
} else {
return 0;
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/fileCommands.js b/bundles/org.eclipse.orion.client.core/web/orion/fileCommands.js
index 6f16414..fe5097b 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/fileCommands.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/fileCommands.js
@@ -309,7 +309,21 @@ define(["require", "dojo", "orion/util", "orion/commands", "orion/editor/regex",
}
return true;},
callback: function(data) {
- serviceRegistry.getService("orion.core.favorite").makeFavorites(data.items);
+ var items = dojo.isArray(data.items) ? data.items : [data.items];
+ var favService = serviceRegistry.getService("orion.core.favorite");
+ var doAdd = function(item) {
+ return function(result) {
+ if (!result) {
+ favService.makeFavorites(item);
+ } else {
+ serviceRegistry.getService("orion.page.message").setMessage("Duplicate favorite...ignoring", 2000);
+ }
+ };
+ };
+ for (var i = 0; i < items.length; i++) {
+ var item = items[i];
+ favService.hasFavorite(item.Location).then(doAdd(item));
+ }
}});
commandService.addCommand(favoriteCommand, "object");
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/navoutliner.js b/bundles/org.eclipse.orion.client.core/web/orion/navoutliner.js
index 04df76f..100706a 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/navoutliner.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/navoutliner.js
@@ -123,7 +123,14 @@ define(['require', 'dojo', 'orion/util', 'orion/commands'], function(require, do
var spacer= dojo.byId("spacer");
mUtil.getUserText(imageId+"EditBox", spacer, true, "",
function(newText) {
- reg.getService("orion.core.favorite").addFavoriteUrl(newText);
+ var favService = reg.getService("orion.core.favorite");
+ favService.hasFavorite(newText).then(function(result) {
+ if (!result) {
+ favService.addFavoriteUrl(newText);
+ } else {
+ reg.getService("orion.page.message").setMessage("Dubplicate favorite...ignoring", 2000);
+ }
+ });
},
null, "Type or paste a URL"
);