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 22 matching lines...) Expand all Loading... |
33 */ | 33 */ |
34 Settings.EditFileSystemView = class extends UI.VBox { | 34 Settings.EditFileSystemView = class extends UI.VBox { |
35 /** | 35 /** |
36 * @param {string} fileSystemPath | 36 * @param {string} fileSystemPath |
37 */ | 37 */ |
38 constructor(fileSystemPath) { | 38 constructor(fileSystemPath) { |
39 super(true); | 39 super(true); |
40 this.registerRequiredCSS('settings/editFileSystemView.css'); | 40 this.registerRequiredCSS('settings/editFileSystemView.css'); |
41 this._fileSystemPath = fileSystemPath; | 41 this._fileSystemPath = fileSystemPath; |
42 | 42 |
| 43 this._fileSystemMapping = Persistence.fileSystemMapping; |
43 this._eventListeners = [ | 44 this._eventListeners = [ |
44 Workspace.fileSystemMapping.addEventListener( | 45 this._fileSystemMapping.addEventListener( |
45 Workspace.FileSystemMapping.Events.FileMappingAdded, this._update, thi
s), | 46 Persistence.FileSystemMapping.Events.FileMappingAdded, this._update, t
his), |
46 Workspace.fileSystemMapping.addEventListener( | 47 this._fileSystemMapping.addEventListener( |
47 Workspace.FileSystemMapping.Events.FileMappingRemoved, this._update, t
his), | 48 Persistence.FileSystemMapping.Events.FileMappingRemoved, this._update,
this), |
48 Workspace.isolatedFileSystemManager.addEventListener( | 49 Workspace.isolatedFileSystemManager.addEventListener( |
49 Workspace.IsolatedFileSystemManager.Events.ExcludedFolderAdded, this._
update, this), | 50 Workspace.IsolatedFileSystemManager.Events.ExcludedFolderAdded, this._
update, this), |
50 Workspace.isolatedFileSystemManager.addEventListener( | 51 Workspace.isolatedFileSystemManager.addEventListener( |
51 Workspace.IsolatedFileSystemManager.Events.ExcludedFolderRemoved, this
._update, this) | 52 Workspace.IsolatedFileSystemManager.Events.ExcludedFolderRemoved, this
._update, this) |
52 ]; | 53 ]; |
53 | 54 |
54 this._mappingsList = new UI.ListWidget(this); | 55 this._mappingsList = new UI.ListWidget(this); |
55 this._mappingsList.element.classList.add('file-system-list'); | 56 this._mappingsList.element.classList.add('file-system-list'); |
56 this._mappingsList.registerRequiredCSS('settings/editFileSystemView.css'); | 57 this._mappingsList.registerRequiredCSS('settings/editFileSystemView.css'); |
57 var mappingsPlaceholder = createElementWithClass('div', 'file-system-list-em
pty'); | 58 var mappingsPlaceholder = createElementWithClass('div', 'file-system-list-em
pty'); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 96 } |
96 | 97 |
97 _update() { | 98 _update() { |
98 if (this._muteUpdate) | 99 if (this._muteUpdate) |
99 return; | 100 return; |
100 | 101 |
101 this._mappingsList.clear(); | 102 this._mappingsList.clear(); |
102 this._mappings = []; | 103 this._mappings = []; |
103 if (Runtime.experiments.isEnabled('persistence2')) | 104 if (Runtime.experiments.isEnabled('persistence2')) |
104 return; | 105 return; |
105 var mappings = Workspace.fileSystemMapping.mappingEntries(this._fileSystemPa
th); | 106 var mappings = this._fileSystemMapping.mappingEntries(this._fileSystemPath); |
106 for (var entry of mappings) { | 107 for (var entry of mappings) { |
107 if (entry.configurable) { | 108 if (entry.configurable) { |
108 this._mappingsList.appendItem(entry, true); | 109 this._mappingsList.appendItem(entry, true); |
109 this._mappings.push(entry); | 110 this._mappings.push(entry); |
110 } | 111 } |
111 } | 112 } |
112 for (var entry of mappings) { | 113 for (var entry of mappings) { |
113 if (!entry.configurable) { | 114 if (!entry.configurable) { |
114 this._mappingsList.appendItem(entry, false); | 115 this._mappingsList.appendItem(entry, false); |
115 this._mappings.push(entry); | 116 this._mappings.push(entry); |
(...skipping 10 matching lines...) Expand all Loading... |
126 } | 127 } |
127 for (var folder of Workspace.isolatedFileSystemManager.fileSystem(this._file
SystemPath) | 128 for (var folder of Workspace.isolatedFileSystemManager.fileSystem(this._file
SystemPath) |
128 .nonConfigurableExcludedFolders() | 129 .nonConfigurableExcludedFolders() |
129 .values()) { | 130 .values()) { |
130 this._excludedFolders.push(folder); | 131 this._excludedFolders.push(folder); |
131 this._excludedFoldersList.appendItem(folder, false); | 132 this._excludedFoldersList.appendItem(folder, false); |
132 } | 133 } |
133 } | 134 } |
134 | 135 |
135 _addMappingButtonClicked() { | 136 _addMappingButtonClicked() { |
136 var entry = new Workspace.FileSystemMapping.Entry(this._fileSystemPath, '',
'', true); | 137 var entry = new Persistence.FileSystemMapping.Entry(this._fileSystemPath, ''
, '', true); |
137 this._mappingsList.addNewItem(0, entry); | 138 this._mappingsList.addNewItem(0, entry); |
138 } | 139 } |
139 | 140 |
140 _addExcludedFolderButtonClicked() { | 141 _addExcludedFolderButtonClicked() { |
141 this._excludedFoldersList.addNewItem(0, ''); | 142 this._excludedFoldersList.addNewItem(0, ''); |
142 } | 143 } |
143 | 144 |
144 /** | 145 /** |
145 * @override | 146 * @override |
146 * @param {*} item | 147 * @param {*} item |
147 * @param {boolean} editable | 148 * @param {boolean} editable |
148 * @return {!Element} | 149 * @return {!Element} |
149 */ | 150 */ |
150 renderItem(item, editable) { | 151 renderItem(item, editable) { |
151 var element = createElementWithClass('div', 'file-system-list-item'); | 152 var element = createElementWithClass('div', 'file-system-list-item'); |
152 if (!editable) | 153 if (!editable) |
153 element.classList.add('locked'); | 154 element.classList.add('locked'); |
154 if (item instanceof Workspace.FileSystemMapping.Entry) { | 155 if (item instanceof Persistence.FileSystemMapping.Entry) { |
155 var entry = /** @type {!Workspace.FileSystemMapping.Entry} */ (item); | 156 var entry = /** @type {!Persistence.FileSystemMapping.Entry} */ (item); |
156 var urlPrefix = entry.configurable ? entry.urlPrefix : Common.UIString('%s
(via .devtools)', entry.urlPrefix); | 157 var urlPrefix = entry.configurable ? entry.urlPrefix : Common.UIString('%s
(via .devtools)', entry.urlPrefix); |
157 var urlPrefixElement = element.createChild('div', 'file-system-value'); | 158 var urlPrefixElement = element.createChild('div', 'file-system-value'); |
158 urlPrefixElement.textContent = urlPrefix; | 159 urlPrefixElement.textContent = urlPrefix; |
159 urlPrefixElement.title = urlPrefix; | 160 urlPrefixElement.title = urlPrefix; |
160 element.createChild('div', 'file-system-separator'); | 161 element.createChild('div', 'file-system-separator'); |
161 var pathPrefixElement = element.createChild('div', 'file-system-value'); | 162 var pathPrefixElement = element.createChild('div', 'file-system-value'); |
162 pathPrefixElement.textContent = entry.pathPrefix; | 163 pathPrefixElement.textContent = entry.pathPrefix; |
163 pathPrefixElement.title = entry.pathPrefix; | 164 pathPrefixElement.title = entry.pathPrefix; |
164 } else { | 165 } else { |
165 var pathPrefix = /** @type {string} */ (editable ? item : Common.UIString(
'%s (via .devtools)', item)); | 166 var pathPrefix = /** @type {string} */ (editable ? item : Common.UIString(
'%s (via .devtools)', item)); |
166 var pathPrefixElement = element.createChild('div', 'file-system-value'); | 167 var pathPrefixElement = element.createChild('div', 'file-system-value'); |
167 pathPrefixElement.textContent = pathPrefix; | 168 pathPrefixElement.textContent = pathPrefix; |
168 pathPrefixElement.title = pathPrefix; | 169 pathPrefixElement.title = pathPrefix; |
169 } | 170 } |
170 element.createChild('div', 'file-system-locked').title = Common.UIString('Fr
om .devtools file'); | 171 element.createChild('div', 'file-system-locked').title = Common.UIString('Fr
om .devtools file'); |
171 return element; | 172 return element; |
172 } | 173 } |
173 | 174 |
174 /** | 175 /** |
175 * @override | 176 * @override |
176 * @param {*} item | 177 * @param {*} item |
177 * @param {number} index | 178 * @param {number} index |
178 */ | 179 */ |
179 removeItemRequested(item, index) { | 180 removeItemRequested(item, index) { |
180 if (item instanceof Workspace.FileSystemMapping.Entry) { | 181 if (item instanceof Persistence.FileSystemMapping.Entry) { |
181 var entry = this._mappings[index]; | 182 var entry = this._mappings[index]; |
182 Workspace.fileSystemMapping.removeFileMapping(entry.fileSystemPath, entry.
urlPrefix, entry.pathPrefix); | 183 this._fileSystemMapping.removeFileMapping(entry.fileSystemPath, entry.urlP
refix, entry.pathPrefix); |
183 } else { | 184 } else { |
184 Workspace.isolatedFileSystemManager.fileSystem(this._fileSystemPath) | 185 Workspace.isolatedFileSystemManager.fileSystem(this._fileSystemPath) |
185 .removeExcludedFolder(this._excludedFolders[index]); | 186 .removeExcludedFolder(this._excludedFolders[index]); |
186 } | 187 } |
187 } | 188 } |
188 | 189 |
189 /** | 190 /** |
190 * @override | 191 * @override |
191 * @param {*} item | 192 * @param {*} item |
192 * @param {!UI.ListWidget.Editor} editor | 193 * @param {!UI.ListWidget.Editor} editor |
193 * @param {boolean} isNew | 194 * @param {boolean} isNew |
194 */ | 195 */ |
195 commitEdit(item, editor, isNew) { | 196 commitEdit(item, editor, isNew) { |
196 this._muteUpdate = true; | 197 this._muteUpdate = true; |
197 if (item instanceof Workspace.FileSystemMapping.Entry) { | 198 if (item instanceof Persistence.FileSystemMapping.Entry) { |
198 var entry = /** @type {!Workspace.FileSystemMapping.Entry} */ (item); | 199 var entry = /** @type {!Persistence.FileSystemMapping.Entry} */ (item); |
199 if (!isNew) | 200 if (!isNew) |
200 Workspace.fileSystemMapping.removeFileMapping(this._fileSystemPath, entr
y.urlPrefix, entry.pathPrefix); | 201 this._fileSystemMapping.removeFileMapping(this._fileSystemPath, entry.ur
lPrefix, entry.pathPrefix); |
201 Workspace.fileSystemMapping.addFileMapping( | 202 this._fileSystemMapping.addFileMapping( |
202 this._fileSystemPath, this._normalizePrefix(editor.control('urlPrefix'
).value), | 203 this._fileSystemPath, this._normalizePrefix(editor.control('urlPrefix'
).value), |
203 this._normalizePrefix(editor.control('pathPrefix').value)); | 204 this._normalizePrefix(editor.control('pathPrefix').value)); |
204 } else { | 205 } else { |
205 if (!isNew) { | 206 if (!isNew) { |
206 Workspace.isolatedFileSystemManager.fileSystem(this._fileSystemPath) | 207 Workspace.isolatedFileSystemManager.fileSystem(this._fileSystemPath) |
207 .removeExcludedFolder(/** @type {string} */ (item)); | 208 .removeExcludedFolder(/** @type {string} */ (item)); |
208 } | 209 } |
209 Workspace.isolatedFileSystemManager.fileSystem(this._fileSystemPath) | 210 Workspace.isolatedFileSystemManager.fileSystem(this._fileSystemPath) |
210 .addExcludedFolder(this._normalizePrefix(editor.control('pathPrefix').
value)); | 211 .addExcludedFolder(this._normalizePrefix(editor.control('pathPrefix').
value)); |
211 } | 212 } |
212 this._muteUpdate = false; | 213 this._muteUpdate = false; |
213 this._update(); | 214 this._update(); |
214 } | 215 } |
215 | 216 |
216 /** | 217 /** |
217 * @override | 218 * @override |
218 * @param {*} item | 219 * @param {*} item |
219 * @return {!UI.ListWidget.Editor} | 220 * @return {!UI.ListWidget.Editor} |
220 */ | 221 */ |
221 beginEdit(item) { | 222 beginEdit(item) { |
222 if (item instanceof Workspace.FileSystemMapping.Entry) { | 223 if (item instanceof Persistence.FileSystemMapping.Entry) { |
223 var entry = /** @type {!Workspace.FileSystemMapping.Entry} */ (item); | 224 var entry = /** @type {!Persistence.FileSystemMapping.Entry} */ (item); |
224 var editor = this._createMappingEditor(); | 225 var editor = this._createMappingEditor(); |
225 editor.control('urlPrefix').value = entry.urlPrefix; | 226 editor.control('urlPrefix').value = entry.urlPrefix; |
226 editor.control('pathPrefix').value = entry.pathPrefix; | 227 editor.control('pathPrefix').value = entry.pathPrefix; |
227 return editor; | 228 return editor; |
228 } else { | 229 } else { |
229 var editor = this._createExcludedFolderEditor(); | 230 var editor = this._createExcludedFolderEditor(); |
230 editor.control('pathPrefix').value = item; | 231 editor.control('pathPrefix').value = item; |
231 return editor; | 232 return editor; |
232 } | 233 } |
233 } | 234 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 /** | 334 /** |
334 * @param {string} prefix | 335 * @param {string} prefix |
335 * @return {string} | 336 * @return {string} |
336 */ | 337 */ |
337 _normalizePrefix(prefix) { | 338 _normalizePrefix(prefix) { |
338 if (!prefix) | 339 if (!prefix) |
339 return ''; | 340 return ''; |
340 return prefix + (prefix[prefix.length - 1] === '/' ? '' : '/'); | 341 return prefix + (prefix[prefix.length - 1] === '/' ? '' : '/'); |
341 } | 342 } |
342 }; | 343 }; |
OLD | NEW |