Merge branch 'refs/heads/master' of ssh://mjanczarska@dev.eclipse.org/gitroot/e4/org.eclipse.orion.client.git
diff --git a/bundles/org.eclipse.orion.client.core/static/js/auth.js b/bundles/org.eclipse.orion.client.core/static/js/auth.js
index 53b724e..a184d7e 100644
--- a/bundles/org.eclipse.orion.client.core/static/js/auth.js
+++ b/bundles/org.eclipse.orion.client.core/static/js/auth.js
@@ -6,7 +6,7 @@
  * 
  * Contributors: IBM Corporation - initial API and implementation
  ******************************************************************************/
-/*global dojo*/
+/*global dojo dijit handleAuthenticationError */
  /*
 	Authentication and authorization error handling. Adds methods that handle 401 and 403 responses for 
 	XHR calls.
@@ -32,16 +32,12 @@
 	});
 });
 
-function handleGetAuthenticationError(xhrArgs, ioArgs) {
-	handleAuthenticationError(ioArgs.xhr, function(){
-		dojo.xhrGet(xhrArgs); // retry GET
-	});
-}
-
 function handleGetAuthenticationError(xhrArgs, ioArgs, cb, eb) {
 	handleAuthenticationError(ioArgs.xhr, function(){
-		var dfd = dojo.xhrGet(xhrArgs); // retry GET
-		dfd.then(cb, eb); // add callback and errback
+		var dfd = dojo.xhrGet(xhrArgs); // retry GET

+		if (cb) {
+			dfd.then(cb, eb); // add callback and errback

+		}

 	});
 }
 
@@ -69,16 +65,17 @@
  * @param retry A function to invoke after authentication to retry the server request.
  */
 function handleAuthenticationError(error, retry) {
-	if (error.status == 403) { 
-		if (forbiddenAccessDlg == null)
+	if (error.status === 403) { 
+		if (forbiddenAccessDlg === null) {
 			forbiddenAccessDlg = new dijit.Dialog({
 		        title: "Forbidden access"
-		    });
+		    });

+		}
 		
 		forbiddenAccessDlg.set("content", error.message);
 		forbiddenAccessDlg.show();
 	}
-	if (error.status == 401) { 
+	if (error.status === 401) { 
 		var handle = dojo.subscribe("/auth", function(message){
 			retry();
 			dojo.unsubscribe(handle); // ... but only once
diff --git a/bundles/org.eclipse.orion.client.core/static/js/coding/coding.js b/bundles/org.eclipse.orion.client.core/static/js/coding/coding.js
index a21be79..6a2200e 100644
--- a/bundles/org.eclipse.orion.client.core/static/js/coding/coding.js
+++ b/bundles/org.eclipse.orion.client.core/static/js/coding/coding.js
@@ -25,11 +25,11 @@
 		serviceRegistry = new eclipse.ServiceRegistry();
 		pluginRegistry = new eclipse.PluginRegistry(serviceRegistry);
 		
-		// this is temporary
-		var jslintPlugin = pluginRegistry.getPlugin("/plugins/jslintPlugin.html");
-		if (jslintPlugin === null) {
-			pluginRegistry.installPlugin("/plugins/jslintPlugin.html");
-		}
+//		// this is temporary
+//		var jslintPlugin = pluginRegistry.getPlugin("/plugins/jslintPlugin.html");
+//		if (jslintPlugin === null) {
+//			pluginRegistry.installPlugin("/plugins/jslintPlugin.html");
+//		}
 
 		var inputService = new eclipse.InputService(serviceRegistry);
 		inputService.initializeContext({"manageDocumentTitle": true});	
diff --git a/bundles/org.eclipse.orion.client.core/static/js/fileClient.js b/bundles/org.eclipse.orion.client.core/static/js/fileClient.js
index 8992460..aed6299 100644
--- a/bundles/org.eclipse.orion.client.core/static/js/fileClient.js
+++ b/bundles/org.eclipse.orion.client.core/static/js/fileClient.js
@@ -27,10 +27,10 @@
 	function FileClient(serviceRegistry, pluginRegistry) {
 		this.serviceRegistry = serviceRegistry;
 		//ensure the plugin is installed
-		var filePlugin = pluginRegistry.getPlugin("/plugins/fileClientPlugin.html");
-		if (filePlugin === null) {
-			pluginRegistry.installPlugin("/plugins/fileClientPlugin.html");
-		}
+//		var filePlugin = pluginRegistry.getPlugin("/plugins/fileClientPlugin.html");
+//		if (filePlugin === null) {
+//			pluginRegistry.installPlugin("/plugins/fileClientPlugin.html");
+//		}
 	}
 	
 	FileClient.prototype = /**@lends eclipse.FileClient.prototype */
diff --git a/bundles/org.eclipse.orion.client.core/static/js/git-status/git-status-table.js b/bundles/org.eclipse.orion.client.core/static/js/git-status/git-status-table.js
index d2c1749..f032b6f 100644
--- a/bundles/org.eclipse.orion.client.core/static/js/git-status/git-status-table.js
+++ b/bundles/org.eclipse.orion.client.core/static/js/git-status/git-status-table.js
@@ -331,7 +331,8 @@
 		},
 		
 		removeProgressDiv: function(progressParentId , progressId){
-			dojo.place(document.createTextNode(""), progressParentId, "only");
+			if(dojo.byId(progressId))
+				dojo.place(document.createTextNode(""), progressParentId, "only");
 		},
 		
 		_loadBlock: function(renderer , interedtedGroup){
diff --git a/bundles/org.eclipse.orion.client.core/static/js/navigate-table/navigate-table.js b/bundles/org.eclipse.orion.client.core/static/js/navigate-table/navigate-table.js
index fd2ce74..2a6d4e9 100644
--- a/bundles/org.eclipse.orion.client.core/static/js/navigate-table/navigate-table.js
+++ b/bundles/org.eclipse.orion.client.core/static/js/navigate-table/navigate-table.js
@@ -32,15 +32,15 @@
 	new eclipse.GitService(serviceRegistry);
 	
 	// this is temporary
-	var unittestPlugin = pluginRegistry.getPlugin("/plugins/unittestPlugin.html");
-	if (unittestPlugin === null) {
-		pluginRegistry.installPlugin("/plugins/unittestPlugin.html");
-	}
-	
-	var gitPlugin = pluginRegistry.getPlugin("/plugins/gitPlugin.html");
-	if (gitPlugin === null) {
-		pluginRegistry.installPlugin("/plugins/gitPlugin.html");
-	}
+//	var unittestPlugin = pluginRegistry.getPlugin("/plugins/unittestPlugin.html");
+//	if (unittestPlugin === null) {
+//		pluginRegistry.installPlugin("/plugins/unittestPlugin.html");
+//	}
+//	
+//	var gitPlugin = pluginRegistry.getPlugin("/plugins/gitPlugin.html");
+//	if (gitPlugin === null) {
+//		pluginRegistry.installPlugin("/plugins/gitPlugin.html");
+//	}
 
 	
 	var treeRoot = {
diff --git a/bundles/org.eclipse.orion.client.core/static/js/pluginregistry.js b/bundles/org.eclipse.orion.client.core/static/js/pluginregistry.js
index ffc8248..9dad448 100644
--- a/bundles/org.eclipse.orion.client.core/static/js/pluginregistry.js
+++ b/bundles/org.eclipse.orion.client.core/static/js/pluginregistry.js
@@ -165,12 +165,17 @@
 };
 
 eclipse.PluginRegistry = function(serviceRegistry, opt_storage) {
+	var _self = this;
 	var _storage = opt_storage || localStorage || {};
 	var _plugins = [];
 	var _pluginEventTarget = new eclipse.EventTarget();
 	
-
-		var _managedHub = new OpenAjax.hub.ManagedHub({
+	// storage
+	var _defaultPlugins = {};
+	var _userPlugins;
+	
+	
+	var _managedHub = new OpenAjax.hub.ManagedHub({
 		log : function(message) {
 			console.log(message);
 		},
@@ -188,28 +193,102 @@
 		}
 	});
 
-	function _loadFromStorage() {
-		for (var i = 0; i < _storage.length; i++) {
-			var key = _storage.key(i);
-			if (key.indexOf("plugin.") === 0) {
-				var pluginURL = key.substring("plugin.".length);
-				var pluginData = JSON.parse(_storage[key]);
-				var plugin = new eclipse.Plugin(pluginURL, pluginData, internalRegistry); 
-				_plugins.push(plugin);
+	function _loadFromStorage() {

+		var plugin,

+			pluginURL,

+			pluginData,

+			key,

+			defaults;
+		

+		//default
+		defaults = _storage["/orion/preferences/default"] ? JSON.parse(_storage["/orion/preferences/default"]) : null;
+		if (defaults && defaults["/plugins"]) {
+			_defaultPlugins = defaults["/plugins"];
+			for(pluginURL in _defaultPlugins) {
+				if (_defaultPlugins.hasOwnProperty(pluginURL)) {
+					pluginURL = _normalizeURL(pluginURL);
+					key = "plugin." + pluginURL;
+					if (_storage[key]) {
+						pluginData = JSON.parse(_storage[key]);
+						plugin = new eclipse.Plugin(pluginURL, pluginData, internalRegistry); 
+						_plugins.push(plugin);
+					} else {
+						_self.installPlugin(pluginURL);
+					}
+				}
 			}
-		}	
+		}
+		

+		//user
+		_userPlugins = _storage["/orion/preferences/user/plugins"] ? JSON.parse(_storage["/orion/preferences/user/plugins"]) : null;
+		if (!_userPlugins) {
+			_userPlugins = {};
+		}
+		for(pluginURL in _userPlugins) {
+			if (_userPlugins.hasOwnProperty(pluginURL)) {
+				pluginURL = _normalizeURL(pluginURL);
+				key = "plugin." + pluginURL;
+				if (_storage[key]) {
+					pluginData = JSON.parse(_storage[key]);
+					plugin = new eclipse.Plugin(pluginURL, pluginData, internalRegistry); 
+					_plugins.push(plugin);
+				} else {
+					_self.installPlugin(pluginURL);
+				}
+			}
+		}
+		
+		
+		
+//		for (var i = 0; i < _storage.length; i++) {
+//			var key = _storage.key(i);
+//			if (key.indexOf("plugin.") === 0) {
+//				var pluginURL = key.substring("plugin.".length);
+//				var pluginData = JSON.parse(_storage[key]);
+//				var plugin = new eclipse.Plugin(pluginURL, pluginData, internalRegistry); 
+//				_plugins.push(plugin);
+//			}
+//		}	
 	}
 	
 	function _persist(plugin) {
+		var pluginURL;
 		_storage["plugin."+plugin.getLocation()] = JSON.stringify(plugin.getData());
+		for(pluginURL in _defaultPlugins) {
+			if (_defaultPlugins.hasOwnProperty(pluginURL)) {
+				if (plugin.getLocation() === _normalizeURL(pluginURL)) {
+					return;
+				}
+			}
+		}
+		for(pluginURL in _userPlugins) {
+			if (_userPlugins.hasOwnProperty(pluginURL)) {
+				if (plugin.getLocation() === _normalizeURL(pluginURL)) {
+					return;
+				}
+			}
+		}
+		_userPlugins[plugin.getLocation()] = true;
+		_storage["/orion/preferences/user/plugins"] = JSON.stringify(_userPlugins);
 	}
 
 	function _clear(plugin) {
+		var pluginURL;
+		
 		delete _storage["plugin."+plugin.getLocation()];
+		for(pluginURL in _userPlugins) {
+			if (_userPlugins.hasOwnProperty(pluginURL)) {
+				if (plugin.getLocation() === _normalizeURL(pluginURL)) {
+					delete _userPlugins[plugin.getLocation()];
+					_storage["/orion/preferences/user/plugins"] = JSON.stringify(_userPlugins);
+					return;
+				}
+			}
+		}
 	}
 	
 	function _normalizeURL(location) {
-		if (location.indexOf("://") == -1) {
+		if (location.indexOf("://") === -1) {
 			var temp = document.createElement('a');
 			temp.href = location;
 	        return temp.href;
diff --git a/bundles/org.eclipse.orion.client.core/static/js/preferences.js b/bundles/org.eclipse.orion.client.core/static/js/preferences.js
index d82eade..752d350 100644
--- a/bundles/org.eclipse.orion.client.core/static/js/preferences.js
+++ b/bundles/org.eclipse.orion.client.core/static/js/preferences.js
@@ -141,13 +141,15 @@
 					d.resolve(jsonData);
 				},
 				error: function(response, ioArgs) {
+					response.log=false;
 					if (ioArgs.xhr.status === 401) {
-						handleGetAuthenticationError(ioArgs.xhr, ioArgs);
+						handleGetAuthenticationError(this, ioArgs);
 					} else {
 						_currentPromise = null;
 						d.resolve({});
 					}
-				}
+				},
+				failOk: true
 			});
 		}
 		return d;
@@ -172,7 +174,7 @@
 			},
 			error: function(response, ioArgs) {
 				if (ioArgs.xhr.status === 401) {
-					handlePutAuthenticationError(ioArgs.xhr, ioArgs);
+					handlePutAuthenticationError(this, ioArgs);
 				} else {
 					d.resolve(); // consider throwing here
 				}
diff --git a/bundles/org.eclipse.orion.client.core/static/js/sites/edit-site.js b/bundles/org.eclipse.orion.client.core/static/js/sites/edit-site.js
index 6fcc2e9..649d1d5 100644
--- a/bundles/org.eclipse.orion.client.core/static/js/sites/edit-site.js
+++ b/bundles/org.eclipse.orion.client.core/static/js/sites/edit-site.js
@@ -27,10 +27,10 @@
 	var searcher = new eclipse.Searcher({serviceRegistry: serviceRegistry});

 	

 	// File operations

-	var filePlugin = pluginRegistry.getPlugin("/plugins/fileClientPlugin.html");

-	if (filePlugin === null) {

-		pluginRegistry.installPlugin("/plugins/fileClientPlugin.html");

-	}

+//	var filePlugin = pluginRegistry.getPlugin("/plugins/fileClientPlugin.html");

+//	if (filePlugin === null) {

+//		pluginRegistry.installPlugin("/plugins/fileClientPlugin.html");

+//	}

 	

 	eclipse.globalCommandUtils.generateBanner("toolbar", commandService, preferenceService, searcher);

 	

diff --git a/bundles/org.eclipse.orion.client.core/static/js/sites/sites.js b/bundles/org.eclipse.orion.client.core/static/js/sites/sites.js
index ebb25c7..2d86d7e 100644
--- a/bundles/org.eclipse.orion.client.core/static/js/sites/sites.js
+++ b/bundles/org.eclipse.orion.client.core/static/js/sites/sites.js
@@ -27,10 +27,10 @@
 	var searcher = new eclipse.Searcher({serviceRegistry: serviceRegistry});

 	

 	// File operations

-	var filePlugin = pluginRegistry.getPlugin("/plugins/fileClientPlugin.html");

-	if (filePlugin === null) {

-		pluginRegistry.installPlugin("/plugins/fileClientPlugin.html");

-	}

+//	var filePlugin = pluginRegistry.getPlugin("/plugins/fileClientPlugin.html");

+//	if (filePlugin === null) {

+//		pluginRegistry.installPlugin("/plugins/fileClientPlugin.html");

+//	}

 	

 	eclipse.globalCommandUtils.generateBanner("toolbar", commandService, preferenceService, searcher);

 	

diff --git a/bundles/org.eclipse.orion.client.users.ui/static/profile/js/usersClient.js b/bundles/org.eclipse.orion.client.users.ui/static/profile/js/usersClient.js
index 9eef257..133538b 100644
--- a/bundles/org.eclipse.orion.client.users.ui/static/profile/js/usersClient.js
+++ b/bundles/org.eclipse.orion.client.users.ui/static/profile/js/usersClient.js
@@ -15,10 +15,10 @@
 			function UsersClient(serviceRegistry, pluginRegistry) {

 				this.serviceRegistry = serviceRegistry;

 				//ensure the plugin is installed

-				var usersPlugin = pluginRegistry.getPlugin("/profile/userservicePlugin.html");

-				if (usersPlugin === null) {

-					pluginRegistry.installPlugin("/profile/userservicePlugin.html");

-				}

+//				var usersPlugin = pluginRegistry.getPlugin("/profile/userservicePlugin.html");

+//				if (usersPlugin === null) {

+//					pluginRegistry.installPlugin("/profile/userservicePlugin.html");

+//				}

 			}

 			

 			UsersClient.prototype = /**@lends eclipse.UsersClient.prototype */