| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @extends {WebInspector.VBox} | 33 * @extends {WebInspector.VBox} |
| 34 * @implements {WebInspector.ListWidget.Delegate} |
| 34 * @param {string} fileSystemPath | 35 * @param {string} fileSystemPath |
| 35 */ | 36 */ |
| 36 WebInspector.EditFileSystemView = function(fileSystemPath) | 37 WebInspector.EditFileSystemView = function(fileSystemPath) |
| 37 { | 38 { |
| 38 WebInspector.VBox.call(this); | 39 WebInspector.VBox.call(this, true); |
| 39 this.registerRequiredCSS("settings/settingsScreen.css"); | 40 this.registerRequiredCSS("settings/editFileSystemView.css"); |
| 40 this.element.classList.add("dialog-contents", "settings-dialog", "settings-t
ab"); | |
| 41 this._fileSystemPath = fileSystemPath; | 41 this._fileSystemPath = fileSystemPath; |
| 42 | 42 |
| 43 var contents = this.element.createChild("div", "contents"); | 43 this._eventListeners = [ |
| 44 | 44 WebInspector.fileSystemMapping.addEventListener(WebInspector.FileSystemM
apping.Events.FileMappingAdded, this._update, this), |
| 45 WebInspector.fileSystemMapping.addEventListener(WebInspector.FileSystemMappi
ng.Events.FileMappingAdded, this._fileMappingAdded, this); | 45 WebInspector.fileSystemMapping.addEventListener(WebInspector.FileSystemM
apping.Events.FileMappingRemoved, this._update, this), |
| 46 WebInspector.fileSystemMapping.addEventListener(WebInspector.FileSystemMappi
ng.Events.FileMappingRemoved, this._fileMappingRemoved, this); | 46 WebInspector.isolatedFileSystemManager.addEventListener(WebInspector.Iso
latedFileSystemManager.Events.ExcludedFolderAdded, this._update, this), |
| 47 WebInspector.isolatedFileSystemManager.addEventListener(WebInspector.Isolate
dFileSystemManager.Events.ExcludedFolderAdded, this._excludedFolderAdded, this); | 47 WebInspector.isolatedFileSystemManager.addEventListener(WebInspector.Iso
latedFileSystemManager.Events.ExcludedFolderRemoved, this._update, this) |
| 48 WebInspector.isolatedFileSystemManager.addEventListener(WebInspector.Isolate
dFileSystemManager.Events.ExcludedFolderRemoved, this._excludedFolderRemoved, th
is); | 48 ]; |
| 49 | 49 |
| 50 var blockHeader = contents.createChild("div", "block-header"); | 50 var mappingsHeader = this.contentElement.createChild("div", "file-system-hea
der"); |
| 51 blockHeader.textContent = WebInspector.UIString("Mappings"); | 51 mappingsHeader.createChild("div", "file-system-header-text").textContent = W
ebInspector.UIString("Mappings"); |
| 52 this._fileMappingsSection = contents.createChild("div", "section"); | 52 mappingsHeader.appendChild(createTextButton(WebInspector.UIString("Add"), th
is._addMappingButtonClicked.bind(this), "add-button")); |
| 53 this._fileMappingsListContainer = this._fileMappingsSection.createChild("div
", "settings-list-container"); | 53 this._mappingsList = new WebInspector.ListWidget(this); |
| 54 | 54 this._mappingsList.element.classList.add("file-system-list"); |
| 55 var urlColumn = { id: "url", placeholder: WebInspector.UIString("URL prefix"
) }; | 55 this._mappingsList.registerRequiredCSS("settings/editFileSystemView.css"); |
| 56 var pathColumn = { id: "path", placeholder: WebInspector.UIString("Folder pa
th") }; | 56 var mappingsPlaceholder = createElementWithClass("div", "file-system-list-em
pty"); |
| 57 | 57 mappingsPlaceholder.textContent = WebInspector.UIString("No mappings"); |
| 58 this._fileMappingsList = new WebInspector.EditableSettingsList([urlColumn, p
athColumn], this._fileMappingValuesProvider.bind(this), this._fileMappingValidat
e.bind(this), this._fileMappingEdit.bind(this)); | 58 this._mappingsList.setEmptyPlaceholder(mappingsPlaceholder); |
| 59 this._fileMappingsList.addEventListener(WebInspector.SettingsList.Events.Rem
oved, this._fileMappingRemovedfromList.bind(this)); | 59 this._mappingsList.show(this.contentElement); |
| 60 | 60 |
| 61 this._fileMappingsList.element.classList.add("file-mappings-list"); | 61 var excludedFoldersHeader = this.contentElement.createChild("div", "file-sys
tem-header"); |
| 62 this._fileMappingsListContainer.appendChild(this._fileMappingsList.element); | 62 excludedFoldersHeader.createChild("div", "file-system-header-text").textCont
ent = WebInspector.UIString("Excluded folders"); |
| 63 | 63 excludedFoldersHeader.appendChild(createTextButton(WebInspector.UIString("Ad
d"), this._addExcludedFolderButtonClicked.bind(this), "add-button")); |
| 64 this._entries = {}; | 64 this._excludedFoldersList = new WebInspector.ListWidget(this); |
| 65 | 65 this._excludedFoldersList.element.classList.add("file-system-list"); |
| 66 // Treat non configurable items with priority. | 66 this._excludedFoldersList.registerRequiredCSS("settings/editFileSystemView.c
ss"); |
| 67 var entries = WebInspector.fileSystemMapping.mappingEntries(this._fileSystem
Path); | 67 var excludedFoldersPlaceholder = createElementWithClass("div", "file-system-
list-empty"); |
| 68 for (var entry of entries) { | 68 excludedFoldersPlaceholder.textContent = WebInspector.UIString("No excluded
folders"); |
| 69 if (!entry.configurable) | 69 this._excludedFoldersList.setEmptyPlaceholder(excludedFoldersPlaceholder); |
| 70 this._addMappingRow(entry); | 70 this._excludedFoldersList.show(this.contentElement); |
| 71 } | 71 |
| 72 for (var entry of entries) { | 72 this.contentElement.tabIndex = 0; |
| 73 if (entry.configurable) | 73 this._update(); |
| 74 this._addMappingRow(entry); | |
| 75 } | |
| 76 | |
| 77 blockHeader = contents.createChild("div", "block-header excluded-folders-hea
der"); | |
| 78 blockHeader.textContent = WebInspector.UIString("Excluded folders"); | |
| 79 this._excludedFolderListSection = contents.createChild("div", "section exclu
ded-folders-section"); | |
| 80 this._excludedFolderListContainer = this._excludedFolderListSection.createCh
ild("div", "settings-list-container"); | |
| 81 | |
| 82 this._excludedFolderList = new WebInspector.EditableSettingsList([pathColumn
], this._excludedFolderValueProvider.bind(this), this._excludedFolderValidate.bi
nd(this), this._excludedFolderEdit.bind(this)); | |
| 83 this._excludedFolderList.addEventListener(WebInspector.SettingsList.Events.R
emoved, this._excludedFolderRemovedfromList.bind(this)); | |
| 84 this._excludedFolderList.element.classList.add("excluded-folders-list"); | |
| 85 this._excludedFolderListContainer.appendChild(this._excludedFolderList.eleme
nt); | |
| 86 /** @type {!Set<string>} */ | |
| 87 this._excludedFolderEntries = new Set(); | |
| 88 for (var folder of WebInspector.isolatedFileSystemManager.fileSystem(fileSys
temPath).nonConfigurableExcludedFolders().values()) | |
| 89 this._addExcludedFolderRow(folder, true); | |
| 90 for (var folder of WebInspector.isolatedFileSystemManager.fileSystem(fileSys
temPath).excludedFolders().values()) | |
| 91 this._addExcludedFolderRow(folder, false); | |
| 92 | |
| 93 this.element.tabIndex = 0; | |
| 94 this._hasMappingChanges = false; | |
| 95 } | 74 } |
| 96 | 75 |
| 97 WebInspector.EditFileSystemView.prototype = { | 76 WebInspector.EditFileSystemView.prototype = { |
| 98 dispose: function() | 77 dispose: function() |
| 99 { | 78 { |
| 100 WebInspector.fileSystemMapping.removeEventListener(WebInspector.FileSyst
emMapping.Events.FileMappingAdded, this._fileMappingAdded, this); | 79 WebInspector.EventTarget.removeEventListeners(this._eventListeners); |
| 101 WebInspector.fileSystemMapping.removeEventListener(WebInspector.FileSyst
emMapping.Events.FileMappingRemoved, this._fileMappingRemoved, this); | 80 }, |
| 102 WebInspector.isolatedFileSystemManager.removeEventListener(WebInspector.
IsolatedFileSystemManager.Events.ExcludedFolderAdded, this._excludedFolderAdded,
this); | 81 |
| 103 WebInspector.isolatedFileSystemManager.removeEventListener(WebInspector.
IsolatedFileSystemManager.Events.ExcludedFolderRemoved, this._excludedFolderRemo
ved, this); | 82 _update: function() |
| 104 }, | 83 { |
| 105 | 84 if (this._muteUpdate) |
| 106 _fileMappingAdded: function(event) | |
| 107 { | |
| 108 var entry = /** @type {!WebInspector.FileSystemMapping.Entry} */ (event.
data); | |
| 109 this._addMappingRow(entry); | |
| 110 }, | |
| 111 | |
| 112 _fileMappingRemoved: function(event) | |
| 113 { | |
| 114 var entry = /** @type {!WebInspector.FileSystemMapping.Entry} */ (event.
data); | |
| 115 if (this._fileSystemPath !== entry.fileSystemPath) | |
| 116 return; | 85 return; |
| 117 var key = this._entryKey(entry); | 86 |
| 118 delete this._entries[key]; | 87 this._mappingsList.clear(); |
| 119 if (this._fileMappingsList.itemForId(key)) | 88 this._mappings = WebInspector.fileSystemMapping.mappingEntries(this._fil
eSystemPath); |
| 120 this._fileMappingsList.removeItem(key); | 89 for (var entry of this._mappings) { |
| 121 }, | 90 if (entry.configurable) |
| 122 | 91 this._mappingsList.appendItem(entry, true); |
| 123 /** | 92 } |
| 124 * @param {!WebInspector.FileSystemMapping.Entry} entry | 93 for (var entry of this._mappings) { |
| 125 * @return {string} | 94 if (!entry.configurable) |
| 126 */ | 95 this._mappingsList.appendItem(entry, false); |
| 127 _entryKey: function(entry) | 96 } |
| 128 { | 97 |
| 129 return (entry.configurable ? "configurable:" : "nonconfigurable:") + ent
ry.urlPrefix; | 98 this._excludedFoldersList.clear(); |
| 130 }, | 99 this._excludedFolders = []; |
| 131 | 100 for (var folder of WebInspector.isolatedFileSystemManager.fileSystem(thi
s._fileSystemPath).excludedFolders().values()) { |
| 132 /** | 101 this._excludedFolders.push(folder); |
| 133 * @param {string} itemId | 102 this._excludedFoldersList.appendItem(folder, true); |
| 134 * @param {string} columnId | 103 } |
| 135 * @return {string} | 104 for (var folder of WebInspector.isolatedFileSystemManager.fileSystem(thi
s._fileSystemPath).nonConfigurableExcludedFolders().values()) { |
| 136 */ | 105 this._excludedFolders.push(folder); |
| 137 _fileMappingValuesProvider: function(itemId, columnId) | 106 this._excludedFoldersList.appendItem(folder, false); |
| 138 { | 107 } |
| 139 if (!itemId) | 108 }, |
| 140 return ""; | 109 |
| 141 var entry = this._entries[itemId]; | 110 _addMappingButtonClicked: function() |
| 142 switch (columnId) { | 111 { |
| 143 case "url": | 112 var entry = new WebInspector.FileSystemMapping.Entry(this._fileSystemPat
h, "", "", true); |
| 144 return entry.configurable ? entry.urlPrefix : WebInspector.UIString(
"%s (via .devtools)", entry.urlPrefix); | 113 this._mappingsList.addNewItem(0, entry); |
| 145 case "path": | 114 }, |
| 146 return entry.pathPrefix; | 115 |
| 147 default: | 116 _addExcludedFolderButtonClicked: function() |
| 148 console.assert("Should not be reached."); | 117 { |
| 149 } | 118 this._excludedFoldersList.addNewItem(0, ""); |
| 150 return ""; | 119 }, |
| 151 }, | 120 |
| 152 | 121 /** |
| 153 /** | 122 * @override |
| 154 * @param {?string} itemId | 123 * @param {*} item |
| 155 * @param {!Object} data | 124 * @param {boolean} editable |
| 156 */ | 125 * @return {!Element} |
| 157 _fileMappingValidate: function(itemId, data) | 126 */ |
| 158 { | 127 renderItem: function(item, editable) |
| 159 var oldPathPrefix = itemId ? this._entries[itemId].pathPrefix : null; | 128 { |
| 160 var oldURLPrefix = itemId ? this._entries[itemId].urlPrefix : null; | 129 var element = createElementWithClass("div", "file-system-list-item"); |
| 161 return this._validateMapping(data["url"], oldURLPrefix, data["path"], ol
dPathPrefix); | 130 if (!editable) |
| 162 }, | 131 element.classList.add("locked"); |
| 163 | 132 if (item instanceof WebInspector.FileSystemMapping.Entry) { |
| 164 /** | 133 var entry = /** @type {!WebInspector.FileSystemMapping.Entry} */ (it
em); |
| 165 * @param {?string} itemId | 134 var urlPrefix = entry.configurable ? entry.urlPrefix : WebInspector.
UIString("%s (via .devtools)", entry.urlPrefix); |
| 166 * @param {!Object} data | 135 var urlPrefixElement = element.createChild("div", "file-system-value
"); |
| 167 */ | 136 urlPrefixElement.textContent = urlPrefix; |
| 168 _fileMappingEdit: function(itemId, data) | 137 urlPrefixElement.title = urlPrefix; |
| 169 { | 138 element.createChild("div", "file-system-separator"); |
| 170 if (itemId) { | 139 var pathPrefixElement = element.createChild("div", "file-system-valu
e"); |
| 171 var urlPrefix = itemId; | 140 pathPrefixElement.textContent = entry.pathPrefix; |
| 172 var pathPrefix = this._entries[itemId].pathPrefix; | 141 pathPrefixElement.title = entry.pathPrefix; |
| 173 var fileSystemPath = this._entries[itemId].fileSystemPath; | 142 } else { |
| 174 WebInspector.fileSystemMapping.removeFileMapping(fileSystemPath, url
Prefix, pathPrefix); | 143 var pathPrefix = /** @type {string} */ (editable ? item : WebInspect
or.UIString("%s (via .devtools)", item)); |
| 175 } | 144 var pathPrefixElement = element.createChild("div", "file-system-valu
e"); |
| 176 this._addFileMapping(data["url"], data["path"]); | 145 pathPrefixElement.textContent = pathPrefix; |
| 177 }, | 146 pathPrefixElement.title = pathPrefix; |
| 178 | 147 } |
| 179 /** | 148 element.createChild("div", "file-system-locked").title = WebInspector.UI
String("From .devtools file"); |
| 180 * @param {string} urlPrefix | 149 return element; |
| 181 * @param {?string} allowedURLPrefix | 150 }, |
| 182 * @param {string} path | 151 |
| 183 * @param {?string} allowedPathPrefix | 152 /** |
| 184 */ | 153 * @override |
| 185 _validateMapping: function(urlPrefix, allowedURLPrefix, path, allowedPathPre
fix) | 154 * @param {*} item |
| 186 { | 155 * @param {number} index |
| 187 var columns = []; | 156 */ |
| 188 if (!this._checkURLPrefix(urlPrefix, allowedURLPrefix)) | 157 removeItemRequested: function(item, index) |
| 189 columns.push("url"); | 158 { |
| 190 if (!this._checkPathPrefix(path, allowedPathPrefix)) | 159 this._muteUpdate = true; |
| 191 columns.push("path"); | 160 if (item instanceof WebInspector.FileSystemMapping.Entry) { |
| 192 return columns; | 161 var entry = this._mappings[index]; |
| 193 }, | 162 WebInspector.fileSystemMapping.removeFileMapping(entry.fileSystemPat
h, entry.urlPrefix, entry.pathPrefix); |
| 194 | 163 this._mappingsList.removeItem(index); |
| 195 /** | 164 } else { |
| 196 * @param {!WebInspector.Event} event | 165 WebInspector.isolatedFileSystemManager.fileSystem(this._fileSystemPa
th).removeExcludedFolder(this._excludedFolders[index]); |
| 197 */ | 166 this._excludedFoldersList.removeItem(index); |
| 198 _fileMappingRemovedfromList: function(event) | 167 } |
| 199 { | 168 this._muteUpdate = false; |
| 200 var urlPrefix = /** @type{?string} */ (event.data); | 169 }, |
| 201 if (!urlPrefix) | 170 |
| 202 return; | 171 /** |
| 203 | 172 * @override |
| 204 var entry = this._entries[urlPrefix]; | 173 * @param {*} item |
| 205 WebInspector.fileSystemMapping.removeFileMapping(entry.fileSystemPath, e
ntry.urlPrefix, entry.pathPrefix); | 174 * @param {!WebInspector.ListWidget.Editor} editor |
| 206 this._hasMappingChanges = true; | 175 * @param {boolean} isNew |
| 207 }, | 176 */ |
| 208 | 177 commitEdit: function(item, editor, isNew) |
| 209 /** | 178 { |
| 210 * @param {string} urlPrefix | 179 this._muteUpdate = true; |
| 211 * @param {string} pathPrefix | 180 if (item instanceof WebInspector.FileSystemMapping.Entry) { |
| 212 * @return {boolean} | 181 var entry = /** @type {!WebInspector.FileSystemMapping.Entry} */ (it
em); |
| 213 */ | 182 if (!isNew) |
| 214 _addFileMapping: function(urlPrefix, pathPrefix) | 183 WebInspector.fileSystemMapping.removeFileMapping(this._fileSyste
mPath, entry.urlPrefix, entry.pathPrefix); |
| 215 { | 184 WebInspector.fileSystemMapping.addFileMapping(this._fileSystemPath,
this._normalizePrefix(editor.control("urlPrefix").value), this._normalizePrefix(
editor.control("pathPrefix").value)); |
| 216 var normalizedURLPrefix = this._normalizePrefix(urlPrefix); | 185 } else { |
| 217 var normalizedPathPrefix = this._normalizePrefix(pathPrefix); | 186 if (!isNew) |
| 218 WebInspector.fileSystemMapping.addFileMapping(this._fileSystemPath, norm
alizedURLPrefix, normalizedPathPrefix); | 187 WebInspector.isolatedFileSystemManager.fileSystem(this._fileSyst
emPath).removeExcludedFolder(/** @type {string} */ (item)); |
| 219 this._hasMappingChanges = true; | 188 WebInspector.isolatedFileSystemManager.fileSystem(this._fileSystemPa
th).addExcludedFolder(this._normalizePrefix(editor.control("pathPrefix").value))
; |
| 220 this._fileMappingsList.selectItem("configurable:" + normalizedURLPrefix)
; | 189 } |
| 221 return true; | 190 this._muteUpdate = false; |
| 222 }, | 191 this._update(); |
| 223 | 192 }, |
| 224 /** | 193 |
| 194 /** |
| 195 * @override |
| 196 * @param {*} item |
| 197 * @return {!WebInspector.ListWidget.Editor} |
| 198 */ |
| 199 beginEdit: function(item) |
| 200 { |
| 201 if (item instanceof WebInspector.FileSystemMapping.Entry) { |
| 202 var entry = /** @type {!WebInspector.FileSystemMapping.Entry} */ (it
em); |
| 203 var editor = this._createMappingEditor(); |
| 204 editor.control("urlPrefix").value = entry.urlPrefix; |
| 205 editor.control("pathPrefix").value = entry.pathPrefix; |
| 206 return editor; |
| 207 } else { |
| 208 var editor = this._createExcludedFolderEditor(); |
| 209 editor.control("pathPrefix").value = item; |
| 210 return editor; |
| 211 } |
| 212 }, |
| 213 |
| 214 /** |
| 215 * @return {!WebInspector.ListWidget.Editor} |
| 216 */ |
| 217 _createMappingEditor: function() |
| 218 { |
| 219 if (this._mappingEditor) |
| 220 return this._mappingEditor; |
| 221 |
| 222 var editor = new WebInspector.ListWidget.Editor(); |
| 223 this._mappingEditor = editor; |
| 224 var content = editor.contentElement(); |
| 225 |
| 226 var titles = content.createChild("div", "file-system-edit-row"); |
| 227 titles.createChild("div", "file-system-value").textContent = WebInspecto
r.UIString("URL prefix"); |
| 228 titles.createChild("div", "file-system-separator file-system-separator-i
nvisible"); |
| 229 titles.createChild("div", "file-system-value").textContent = WebInspecto
r.UIString("Folder path"); |
| 230 |
| 231 var fields = content.createChild("div", "file-system-edit-row"); |
| 232 fields.createChild("div", "file-system-value").appendChild(editor.create
Input("urlPrefix", "text", "localhost:8000/url", urlPrefixValidator.bind(this)))
; |
| 233 fields.createChild("div", "file-system-separator file-system-separator-i
nvisible"); |
| 234 fields.createChild("div", "file-system-value").appendChild(editor.create
Input("pathPrefix", "text", "/path/to/folder/", pathPrefixValidator.bind(this)))
; |
| 235 |
| 236 return editor; |
| 237 |
| 238 /** |
| 239 * @param {!HTMLInputElement|!HTMLSelectElement} input |
| 240 * @return {boolean} |
| 241 * @this {WebInspector.EditFileSystemView} |
| 242 */ |
| 243 function urlPrefixValidator(input) |
| 244 { |
| 245 var prefix = this._normalizePrefix(input.value); |
| 246 return !!prefix; |
| 247 } |
| 248 |
| 249 /** |
| 250 * @param {!HTMLInputElement|!HTMLSelectElement} input |
| 251 * @return {boolean} |
| 252 * @this {WebInspector.EditFileSystemView} |
| 253 */ |
| 254 function pathPrefixValidator(input) |
| 255 { |
| 256 var prefix = this._normalizePrefix(input.value); |
| 257 return !!prefix; |
| 258 } |
| 259 }, |
| 260 |
| 261 /** |
| 262 * @return {!WebInspector.ListWidget.Editor} |
| 263 */ |
| 264 _createExcludedFolderEditor: function() |
| 265 { |
| 266 if (this._excludedFolderEditor) |
| 267 return this._excludedFolderEditor; |
| 268 |
| 269 var editor = new WebInspector.ListWidget.Editor(); |
| 270 this._excludedFolderEditor = editor; |
| 271 var content = editor.contentElement(); |
| 272 |
| 273 var titles = content.createChild("div", "file-system-edit-row"); |
| 274 titles.createChild("div", "file-system-value").textContent = WebInspecto
r.UIString("Folder path"); |
| 275 |
| 276 var fields = content.createChild("div", "file-system-edit-row"); |
| 277 fields.createChild("div", "file-system-value").appendChild(editor.create
Input("pathPrefix", "text", "/path/to/folder/", pathPrefixValidator.bind(this)))
; |
| 278 |
| 279 return editor; |
| 280 |
| 281 /** |
| 282 * @param {!HTMLInputElement|!HTMLSelectElement} input |
| 283 * @return {boolean} |
| 284 * @this {WebInspector.EditFileSystemView} |
| 285 */ |
| 286 function pathPrefixValidator(input) |
| 287 { |
| 288 var prefix = this._normalizePrefix(input.value); |
| 289 return !!prefix; |
| 290 } |
| 291 }, |
| 292 |
| 293 /** |
| 225 * @param {string} prefix | 294 * @param {string} prefix |
| 226 * @return {string} | 295 * @return {string} |
| 227 */ | 296 */ |
| 228 _normalizePrefix: function(prefix) | 297 _normalizePrefix: function(prefix) |
| 229 { | 298 { |
| 230 if (!prefix) | 299 if (!prefix) |
| 231 return ""; | 300 return ""; |
| 232 return prefix + (prefix[prefix.length - 1] === "/" ? "" : "/"); | 301 return prefix + (prefix[prefix.length - 1] === "/" ? "" : "/"); |
| 233 }, | 302 }, |
| 234 | 303 |
| 235 /** | |
| 236 * @param {!WebInspector.FileSystemMapping.Entry} entry | |
| 237 */ | |
| 238 _addMappingRow: function(entry) | |
| 239 { | |
| 240 var key = this._entryKey(entry); | |
| 241 if (this._fileMappingsList.itemForId(key)) | |
| 242 return; | |
| 243 var fileSystemPath = entry.fileSystemPath; | |
| 244 if (!this._fileSystemPath || this._fileSystemPath !== fileSystemPath) | |
| 245 return; | |
| 246 | |
| 247 this._entries[key] = entry; | |
| 248 var keys = Object.keys(this._entries).sort(); | |
| 249 this._fileMappingsList.addItem(key, keys[keys.indexOf(key) + 1], !entry.
configurable); | |
| 250 }, | |
| 251 | |
| 252 /** | |
| 253 * @param {!WebInspector.Event} event | |
| 254 */ | |
| 255 _excludedFolderAdded: function(event) | |
| 256 { | |
| 257 var path = /** @type {string} */ (event.data); | |
| 258 this._addExcludedFolderRow(path, false); | |
| 259 }, | |
| 260 | |
| 261 /** | |
| 262 * @param {!WebInspector.Event} event | |
| 263 */ | |
| 264 _excludedFolderRemoved: function(event) | |
| 265 { | |
| 266 var path = /** @type {string} */ (event.data); | |
| 267 delete this._excludedFolderEntries[path]; | |
| 268 if (this._excludedFolderList.itemForId(path)) | |
| 269 this._excludedFolderList.removeItem(path); | |
| 270 }, | |
| 271 | |
| 272 /** | |
| 273 * @param {string} itemId | |
| 274 * @param {string} columnId | |
| 275 * @return {string} | |
| 276 */ | |
| 277 _excludedFolderValueProvider: function(itemId, columnId) | |
| 278 { | |
| 279 return itemId; | |
| 280 }, | |
| 281 | |
| 282 /** | |
| 283 * @param {?string} itemId | |
| 284 * @param {!Object} data | |
| 285 */ | |
| 286 _excludedFolderValidate: function(itemId, data) | |
| 287 { | |
| 288 var columns = []; | |
| 289 if (!this._validateExcludedFolder(data["path"], itemId)) | |
| 290 columns.push("path"); | |
| 291 return columns; | |
| 292 }, | |
| 293 | |
| 294 /** | |
| 295 * @param {string} path | |
| 296 * @param {?string} allowedPath | |
| 297 * @return {boolean} | |
| 298 */ | |
| 299 _validateExcludedFolder: function(path, allowedPath) | |
| 300 { | |
| 301 return !!path && (path === allowedPath || !this._excludedFolderEntries.h
as(path)); | |
| 302 }, | |
| 303 | |
| 304 /** | |
| 305 * @param {?string} itemId | |
| 306 * @param {!Object} data | |
| 307 */ | |
| 308 _excludedFolderEdit: function(itemId, data) | |
| 309 { | |
| 310 if (itemId) | |
| 311 WebInspector.isolatedFileSystemManager.fileSystem(this._fileSystemPa
th).removeExcludedFolder(itemId); | |
| 312 var excludedFolderPath = data["path"]; | |
| 313 WebInspector.isolatedFileSystemManager.fileSystem(this._fileSystemPath).
addExcludedFolder(excludedFolderPath); | |
| 314 }, | |
| 315 | |
| 316 /** | |
| 317 * @param {!WebInspector.Event} event | |
| 318 */ | |
| 319 _excludedFolderRemovedfromList: function(event) | |
| 320 { | |
| 321 var itemId = /** @type{?string} */ (event.data); | |
| 322 if (!itemId) | |
| 323 return; | |
| 324 WebInspector.isolatedFileSystemManager.fileSystem(this._fileSystemPath).
removeExcludedFolder(itemId); | |
| 325 }, | |
| 326 | |
| 327 /** | |
| 328 * @param {string} path | |
| 329 * @param {boolean} readOnly | |
| 330 */ | |
| 331 _addExcludedFolderRow: function(path, readOnly) | |
| 332 { | |
| 333 if (this._excludedFolderEntries.has(path)) | |
| 334 return; | |
| 335 this._excludedFolderEntries.add(path); | |
| 336 if (readOnly && !this._firstNonConfigurableExcludedFolder) | |
| 337 this._firstNonConfigurableExcludedFolder = WebInspector.UIString("%s
(via .devtools)", path); | |
| 338 | |
| 339 // Insert configurable entries before non-configurable. | |
| 340 var insertBefore = readOnly ? null : this._firstNonConfigurableExcludedF
older; | |
| 341 this._excludedFolderList.addItem(readOnly ? WebInspector.UIString("%s (v
ia .devtools)", path) : path, insertBefore, readOnly); | |
| 342 }, | |
| 343 | |
| 344 /** | |
| 345 * @param {string} value | |
| 346 * @param {?string} allowedPrefix | |
| 347 * @return {boolean} | |
| 348 */ | |
| 349 _checkURLPrefix: function(value, allowedPrefix) | |
| 350 { | |
| 351 var prefix = this._normalizePrefix(value); | |
| 352 return !!prefix && (prefix === allowedPrefix || !this._entries["configur
able:" + prefix]); | |
| 353 }, | |
| 354 | |
| 355 /** | |
| 356 * @param {string} value | |
| 357 * @param {?string} allowedPrefix | |
| 358 * @return {boolean} | |
| 359 */ | |
| 360 _checkPathPrefix: function(value, allowedPrefix) | |
| 361 { | |
| 362 var prefix = this._normalizePrefix(value); | |
| 363 if (!prefix) | |
| 364 return false; | |
| 365 if (prefix === allowedPrefix) | |
| 366 return true; | |
| 367 for (var key in this._entries) { | |
| 368 var entry = this._entries[key]; | |
| 369 if (entry.configurable && entry.pathPrefix === prefix) | |
| 370 return false; | |
| 371 } | |
| 372 return true; | |
| 373 }, | |
| 374 | |
| 375 __proto__: WebInspector.VBox.prototype | 304 __proto__: WebInspector.VBox.prototype |
| 376 } | 305 } |
| OLD | NEW |