diff options
author | Malgorzata Janczarska <malgorzata.tomczyk@pl.ibm.com> | 2013-10-25 19:28:29 +0200 |
---|---|---|
committer | Malgorzata Janczarska <malgorzata.tomczyk@pl.ibm.com> | 2013-10-25 19:28:29 +0200 |
commit | 090d3c39d539158c0b171a8ff29444c3f8d433f2 (patch) | |
tree | c5e55459f144a59f26e64ec641cb5e6faa38200e | |
parent | b1843c5fed26eff631bfcf01ea2c8bb47980fed2 (diff) | |
download | org.eclipse.orion.client-origin/Bug419076.zip org.eclipse.orion.client-origin/Bug419076.tar.gz org.eclipse.orion.client-origin/Bug419076.tar.bz2 |
Bug 419076 - Using "enter" vs. clicking on "Submit" in creating new Git Project has different behaviourorigin/Bug419076
4 files changed, 100 insertions, 4 deletions
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/projectClient.js b/bundles/org.eclipse.orion.client.core/web/orion/projectClient.js index a8000c2..882ae7a 100644 --- a/bundles/org.eclipse.orion.client.core/web/orion/projectClient.js +++ b/bundles/org.eclipse.orion.client.core/web/orion/projectClient.js @@ -143,6 +143,7 @@ define(['i18n!orion/navigate/nls/messages', 'orion/Deferred', 'orion/extensionCo createProject: function(workspaceLocation, projectMetadata){ return this.fileClient.createProject(workspaceLocation, projectMetadata.Name, null, true).then(function(fileMetadata){ + delete projectMetadata.Name; return this.initProject(fileMetadata.ContentLocation, projectMetadata); }.bind(this), function(error){return error;}, diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/folderView.js b/bundles/org.eclipse.orion.client.ui/web/orion/folderView.js index 0db7ac5..a9ada44 100644 --- a/bundles/org.eclipse.orion.client.ui/web/orion/folderView.js +++ b/bundles/org.eclipse.orion.client.ui/web/orion/folderView.js @@ -339,6 +339,7 @@ define([ if (this._node && this._node.parentNode) { this._node.parentNode.removeChild(this._node); } + this.projectView.destroy(); this._node = null; } }; diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/projectCommands.js b/bundles/org.eclipse.orion.client.ui/web/orion/projectCommands.js index 055891e..2722334 100644 --- a/bundles/org.eclipse.orion.client.ui/web/orion/projectCommands.js +++ b/bundles/org.eclipse.orion.client.ui/web/orion/projectCommands.js @@ -229,6 +229,25 @@ define(['i18n!orion/navigate/nls/messages', 'orion/webui/littlelib', 'orion/comm } } + + function dispatchNewProject(workspace, project){ + var dispatcher = explorer.modelEventDispatcher; + if (dispatcher && typeof dispatcher.dispatchEvent === "function") { //$NON-NLS-0$ + if(project.ContentLocation){ + fileClient.read(project.ContentLocation, true).then(function(folder){ + dispatcher.dispatchEvent( { type: "create", parent: workspace, newValue: folder}); + }, + function(){ + dispatcher.dispatchEvent( { type: "create", parent: workspace, newValue: null}); + }); + } else { + dispatcher.dispatchEvent( { type: "create", parent: workspace, newValue: null}); + } + } else { + explorer.changedItem(workspace, true); + } + } + dependencyTypes = dependencyTypes || []; var addFolderCommand = new mCommands.Command({ @@ -443,7 +462,7 @@ define(['i18n!orion/navigate/nls/messages', 'orion/webui/littlelib', 'orion/comm actionComment = "Getting content from " + handler.type; } progress.showWhile(handler.initProject(params, {WorkspaceLocation: item.Location}), actionComment).then(function(project){ - explorer.changedItem(item, true); + dispatchNewProject(item, project); }, function(error){ if(error.retry && error.addParamethers){ var paramDescps = []; @@ -528,7 +547,7 @@ define(['i18n!orion/navigate/nls/messages', 'orion/webui/littlelib', 'orion/comm } var item = forceSingleItem(data.items); progress.progress(projectClient.createProject(item.Location, {Name: name}), "Creating project " + name).then(function(project){ - explorer.changedItem(item, true); + dispatchNewProject(item, project); }); }, visibleWhen: function(item) { @@ -555,7 +574,7 @@ define(['i18n!orion/navigate/nls/messages', 'orion/webui/littlelib', 'orion/comm var dialog = new ImportDialog.ImportDialog({ importLocation: projectMetadata.ImportLocation, func: function() { - explorer.changedItem(item, true); + dispatchNewProject(item, projectInfo); } }); dialog.show(); diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/projects/projectView.js b/bundles/org.eclipse.orion.client.ui/web/orion/projects/projectView.js index cf5d26f..7df62f0 100644 --- a/bundles/org.eclipse.orion.client.ui/web/orion/projects/projectView.js +++ b/bundles/org.eclipse.orion.client.ui/web/orion/projects/projectView.js @@ -12,7 +12,8 @@ define(['orion/projects/projectExplorer', 'orion/selection', 'orion/URITemplate', - 'orion/webui/littlelib'], function(mProjectExplorer, Selection, URITemplate, lib) { + 'orion/webui/littlelib', + 'orion/fileCommands'], function(mProjectExplorer, Selection, URITemplate, lib, FileCommands) { var uriTemplate = new URITemplate("#{,resource,params*}"); //$NON-NLS-0$ @@ -22,6 +23,14 @@ define(['orion/projects/projectExplorer', this.serviceRegistry = options.serviceRegistry; this.commandService = options.commandService; this.projectClient = this.serviceRegistry.getService("orion.project.client"); //$NON-NLS-0$ + this.modelEventDispatcher = FileCommands.getModelEventDispatcher(); + var _self = this; + this.modelListener = function(event){_self.changedItemEvent.call(_self, event);}; + this._eventTypes = ["copy", "create", "delete", "import", //$NON-NLS-5$//$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$//$NON-NLS-0$ + "move"]; + this._eventTypes.forEach(function(eventType) { //$NON-NLS-1$//$NON-NLS-0$ + _self.modelEventDispatcher.addEventListener(eventType, _self.modelListener); + }); } ProjectView.prototype = { display: function(workspace, parent){ @@ -29,6 +38,62 @@ define(['orion/projects/projectExplorer', this.projectExplorer = new mProjectExplorer.ProjectExplorer(parent, this.serviceRegistry, new Selection.Selection(this.serviceRegistry), this.commandServic); this.changedItem(workspace); }, + changedItemEvent: function(event){ + if(!event.parent || !this.workspace || event.parent.Location!==this.workspace.Location || !this.projects){ + return; + } + this._handleChangedEvent(event.oldValue, event.newValue); + + }, + _handleChangedEvent: function(oldValue, newValue){ + var _self = this; + + if(oldValue && oldValue.ContentLocation && !oldValue.Children && !oldValue.ChildrenLocation){ + this.fileClient.loadWorkspace(oldValue.ContentLocation).then(function(fileMetadata){ + _self._handleChangedEvent(fileMetadata, newValue); + }); + return; + } + + if(newValue && newValue.ContentLocation && !newValue.Children && !newValue.ChildrenLocation){ + this.fileClient.loadWorkspace(newValue.ContentLocation).then(function(fileMetadata){ + _self._handleChangedEvent(oldValue, fileMetadata); + }); + return; + } + + if(newValue){ + this.projectClient.readProject(newValue, this.workspace).then(function(project){ + if(oldValue){ + for(var i=0; i<_self.projects.length; i++){ + if(oldValue.Location === _self.projects[i].ContentLocation){ + if(project){ + _self.projects[i] = project; + _self.projectExplorer.loadProjects(_self.projects); + } else { + _self.projects.splice(i, 1); + _self.projectExplorer.loadProjects(_self.projects); + } + return; + } + } + } else { + if(project){ + _self.projects.push(project); + _self.projectExplorer.loadProjects(_self.projects); + } + } + }); + } else if(oldValue){ + for(var i=0; i<_self.projects.length; i++){ + if(oldValue.Location === _self.projects[i].ContentLocation){ + _self.projects.splice(i, 1); + _self.projectExplorer.loadProjects(_self.projects); + return; + } + } + } + }, changedItem: function(parent, children, changeType){ var _self = this; if(changeType === "created" && parent.ContentLocation){ //$NON-NLS-0$ @@ -37,6 +102,8 @@ define(['orion/projects/projectExplorer', } if(parent){ _self.progress.progress(_self.projectClient.readAllProjects(parent), "Listing projects").then(function(projects){ + _self.workspace = parent; + _self.projects = projects; _self.projectExplorer.loadProjects(projects); lib.empty(_self.projectExplorer.newActionsSpan); _self.commandService.renderCommands(mProjectExplorer.newActionsScope, _self.projectExplorer.newActionsSpan, parent, _self.projectExplorer, "tool"); //$NON-NLS-0$ @@ -44,12 +111,20 @@ define(['orion/projects/projectExplorer', } else { _self.progress.progress(_self.fileClient.loadWorkspace(), "Getting workspace information").then(function(workspace){ _self.progress.progress(_self.projectClient.readAllProjects(parent), "Listing projects").then(function(projects){ + _self.workspace = workspace; + _self.projects = projects; _self.projectExplorer.loadProjects(projects); lib.empty(_self.projectExplorer.newActionsSpan); _self.commandService.renderCommands(mProjectExplorer.newActionsScope, _self.projectExplorer.newActionsSpan, parent, _self.projectExplorer, "tool"); //$NON-NLS-0$ }); }); } + }, + destroy: function(){ + var _self = this; + this._eventTypes.forEach(function(eventType) { + _self.modelEventDispatcher.removeEventListener(eventType, _self.modelListener); + }); } }; |