Bug 409636 - prevent attempts to delete/rename the workspace
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js b/bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js
index 9e4d5fa..0b9b0d4 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js
@@ -462,14 +462,15 @@
 			choices.push({name: messages["Choose folder..."], callback: prompt});
 			return choices;
 		}
-		
+
 		var oneOrMoreFilesOrFolders = function(item) {
 			var items = Array.isArray(item) ? item : [item];
 			if (items.length === 0) {
 				return false;
 			}
 			for (var i=0; i < items.length; i++) {
-				if (!items[i].Location) {
+				item = items[i];
+				if (!item.Location || item.Projects /*Workspace root, not a file or folder*/) {
 					return false;
 				}
 			}
@@ -514,7 +515,7 @@
 					if (Array.isArray(item)) {
 						return item.length === 1 && item[0].Name;
 					}
-					return item.Location;
+					return item.Location && !item.Projects;
 				},
 				parameters: new mCommandRegistry.ParametersDescription(null, {},
 					function(commandInvocation) {
@@ -535,7 +536,7 @@
 						Deferred.when(getLogicalModelItems(item), function(logicalItems) {
 							item = logicalItems.item;
 							var parent = logicalItems.parent;
-							if (parent.Projects) {
+							if (parent && parent.Projects) {
 								//special case for moving a project. We want to move the project rather than move the project's content
 								parent.Projects.some(function(project) {
 									if (project.Id === item.Id) {
@@ -648,7 +649,7 @@
 							return Deferred.when(getLogicalModelItems(item), function(logicalItems) {
 								item = logicalItems.item;
 								var parent = logicalItems.parent;
-								if (parent.Projects) {
+								if (parent && parent.Projects) {
 									//special case for deleting a project. We want to remove the project rather than delete the project's content
 									deleteLocation = null;
 									parent.Projects.some(function(project) {
@@ -671,14 +672,12 @@
 											parent: parent
 										});
 										dispatchModelEvent({ type: "delete", oldValue: item, newValue: null, parent: parent });
-									}, function(error) {
-										errorHandler(error);
-									});
+									}, errorHandler);
 							});
 						});
 						Deferred.all(deferredDeletes).then(function() {
 							dispatchModelEvent({ type: "deleteMultiple", items: summary }); //$NON-NLS-0$
-						});
+						}, errorHandler);
 					}
 				);	
 			}});