| Index: Source/devtools/front_end/NavigatorView.js
|
| diff --git a/Source/devtools/front_end/NavigatorView.js b/Source/devtools/front_end/NavigatorView.js
|
| index 23a9186b6cd8bc88c23244e29c4cdbd82b39fbe6..c20f4fbce5f4d4dd4e9983e0ad91b4c23f7fff4b 100644
|
| --- a/Source/devtools/front_end/NavigatorView.js
|
| +++ b/Source/devtools/front_end/NavigatorView.js
|
| @@ -61,7 +61,7 @@ WebInspector.NavigatorView = function()
|
| WebInspector.NavigatorView.Events = {
|
| ItemSelected: "ItemSelected",
|
| ItemSearchStarted: "ItemSearchStarted",
|
| - FileRenamed: "FileRenamed"
|
| + ItemRenamingRequested: "ItemRenamingRequested"
|
| }
|
|
|
| WebInspector.NavigatorView.iconClassForType = function(type)
|
| @@ -252,17 +252,12 @@ WebInspector.NavigatorView.prototype = {
|
| }
|
| },
|
|
|
| - _fileRenamed: function(uiSourceCode, newTitle)
|
| - {
|
| - var data = { uiSourceCode: uiSourceCode, name: newTitle };
|
| - this.dispatchEventToListeners(WebInspector.NavigatorView.Events.FileRenamed, data);
|
| - },
|
| -
|
| /**
|
| * @param {WebInspector.UISourceCode} uiSourceCode
|
| */
|
| - handleRename: function(uiSourceCode, callback)
|
| + requestRename: function(uiSourceCode)
|
| {
|
| + this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.ItemRenamingRequested, uiSourceCode);
|
| },
|
|
|
| /**
|
| @@ -271,24 +266,21 @@ WebInspector.NavigatorView.prototype = {
|
| */
|
| rename: function(uiSourceCode, callback)
|
| {
|
| - var uri = uiSourceCode.uri();
|
| - var node = this._uiSourceCodeNodes[uri];
|
| + var node = this._uiSourceCodeNodes[uiSourceCode.uri()];
|
| if (!node)
|
| return null;
|
| - /**
|
| - * @param {boolean} renameCommitted
|
| - */
|
| - function callbackWrapper(renameCommitted)
|
| - {
|
| - if (renameCommitted) {
|
| - delete this._uiSourceCodeNodes[uri];
|
| - this._uiSourceCodeNodes[uiSourceCode.uri()] = node;
|
| - }
|
| + node.rename(callback);
|
| + },
|
|
|
| - if (callback)
|
| - callback(renameCommitted);
|
| - }
|
| - node.rename(callbackWrapper.bind(this));
|
| + /**
|
| + * @param {WebInspector.UISourceCode} uiSourceCode
|
| + * @param {string} oldURI
|
| + */
|
| + _titleChanged: function(uiSourceCode, oldURI)
|
| + {
|
| + var node = this._uiSourceCodeNodes[oldURI];
|
| + delete this._uiSourceCodeNodes[oldURI];
|
| + this._uiSourceCodeNodes[uiSourceCode.uri()] = node;
|
| },
|
|
|
| reset: function()
|
| @@ -569,6 +561,8 @@ WebInspector.NavigatorSourceTreeElement.prototype = {
|
|
|
| _shouldRenameOnMouseDown: function()
|
| {
|
| + if (!this._uiSourceCode.canRename())
|
| + return false;
|
| var isSelected = this === this.treeOutline.selectedTreeElement;
|
| var isFocused = this.treeOutline.childrenListElement.isSelfOrAncestor(document.activeElement);
|
| return isSelected && isFocused && !WebInspector.isBeingEdited(this.treeOutline.element);
|
| @@ -585,7 +579,7 @@ WebInspector.NavigatorSourceTreeElement.prototype = {
|
| function rename()
|
| {
|
| if (this._shouldRenameOnMouseDown())
|
| - this._navigatorView.handleRename(this._uiSourceCode);
|
| + this._navigatorView.requestRename(this._uiSourceCode);
|
| }
|
| },
|
|
|
| @@ -866,6 +860,8 @@ WebInspector.NavigatorUISourceCodeTreeNode.prototype = {
|
|
|
| _titleChanged: function(event)
|
| {
|
| + var oldURI = /** @type {string} */ (event.data);
|
| + this._navigatorView._titleChanged(this._uiSourceCode, oldURI);
|
| this.updateTitle();
|
| },
|
|
|
| @@ -910,8 +906,22 @@ WebInspector.NavigatorUISourceCodeTreeNode.prototype = {
|
|
|
| function commitHandler(element, newTitle, oldTitle)
|
| {
|
| - if (newTitle && newTitle !== oldTitle)
|
| - this._navigatorView._fileRenamed(this._uiSourceCode, newTitle);
|
| + if (newTitle !== oldTitle) {
|
| + this._treeElement.titleText = newTitle;
|
| + this._uiSourceCode.rename(newTitle, renameCallback.bind(this));
|
| + return;
|
| + }
|
| + afterEditing.call(this, true);
|
| + }
|
| +
|
| + function renameCallback(success)
|
| + {
|
| + if (!success) {
|
| + WebInspector.markBeingEdited(treeOutlineElement, false);
|
| + this.updateTitle();
|
| + this.rename(callback);
|
| + return;
|
| + }
|
| afterEditing.call(this, true);
|
| }
|
|
|
|
|