OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * | 10 * |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 | 54 |
55 this.element.addEventListener("contextmenu", this.handleContextMenu.bind(thi s), false); | 55 this.element.addEventListener("contextmenu", this.handleContextMenu.bind(thi s), false); |
56 | 56 |
57 this._navigatorGroupByFolderSetting = WebInspector.moduleSetting("navigatorG roupByFolder"); | 57 this._navigatorGroupByFolderSetting = WebInspector.moduleSetting("navigatorG roupByFolder"); |
58 this._navigatorGroupByFolderSetting.addChangeListener(this._groupingChanged. bind(this)); | 58 this._navigatorGroupByFolderSetting.addChangeListener(this._groupingChanged. bind(this)); |
59 | 59 |
60 this._initGrouping(); | 60 this._initGrouping(); |
61 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.Events.FrameNavigated, this._frameNavigated, this ); | 61 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.Events.FrameNavigated, this._frameNavigated, this ); |
62 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.Events.FrameDetached, this._frameDetached, this); | 62 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.Events.FrameDetached, this._frameDetached, this); |
63 WebInspector.targetManager.observeTargets(this); | 63 WebInspector.targetManager.observeTargets(this); |
64 WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.Bi ndingCreated, this._onBindingCreated, this); | |
65 WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.Bi ndingRemoved, this._onBindingRemoved, this); | |
66 this._resetWorkspace(WebInspector.workspace); | 64 this._resetWorkspace(WebInspector.workspace); |
67 } | 65 } |
68 | 66 |
69 WebInspector.NavigatorView.Types = { | 67 WebInspector.NavigatorView.Types = { |
70 Category: "category", | 68 Category: "category", |
71 Domain: "domain", | 69 Domain: "domain", |
72 File: "file", | 70 File: "file", |
73 FileSystem: "fs", | 71 FileSystem: "fs", |
74 FileSystemFolder: "fs-folder", | 72 FileSystemFolder: "fs-folder", |
75 Frame: "frame", | 73 Frame: "frame", |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 var searchLabel = WebInspector.UIString.capitalize("Search in ^folder"); | 145 var searchLabel = WebInspector.UIString.capitalize("Search in ^folder"); |
148 if (!path || !path.trim()) { | 146 if (!path || !path.trim()) { |
149 path = "*"; | 147 path = "*"; |
150 searchLabel = WebInspector.UIString.capitalize("Search in ^all ^files"); | 148 searchLabel = WebInspector.UIString.capitalize("Search in ^all ^files"); |
151 } | 149 } |
152 contextMenu.appendItem(searchLabel, searchPath); | 150 contextMenu.appendItem(searchLabel, searchPath); |
153 } | 151 } |
154 | 152 |
155 WebInspector.NavigatorView.prototype = { | 153 WebInspector.NavigatorView.prototype = { |
156 /** | 154 /** |
157 * @param {!WebInspector.Event} event | |
158 */ | |
159 _onBindingCreated: function(event) | |
160 { | |
161 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data ); | |
162 // TODO(lushnikov): show network UISourceCodes in navigator. | |
163 this._removeUISourceCode(binding.network); | |
164 }, | |
165 | |
166 /** | |
167 * @param {!WebInspector.Event} event | |
168 */ | |
169 _onBindingRemoved: function(event) | |
170 { | |
171 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data ); | |
172 this._addUISourceCode(binding.network); | |
173 }, | |
174 | |
175 /** | |
176 * @override | 155 * @override |
177 */ | 156 */ |
178 focus: function() | 157 focus: function() |
179 { | 158 { |
180 this._scriptsTree.focus(); | 159 this._scriptsTree.focus(); |
181 }, | 160 }, |
182 | 161 |
183 /** | 162 /** |
184 * @param {!WebInspector.Workspace} workspace | 163 * @param {!WebInspector.Workspace} workspace |
185 */ | 164 */ |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 }, | 203 }, |
225 | 204 |
226 /** | 205 /** |
227 * @param {!WebInspector.UISourceCode} uiSourceCode | 206 * @param {!WebInspector.UISourceCode} uiSourceCode |
228 */ | 207 */ |
229 _addUISourceCode: function(uiSourceCode) | 208 _addUISourceCode: function(uiSourceCode) |
230 { | 209 { |
231 if (!this.accept(uiSourceCode)) | 210 if (!this.accept(uiSourceCode)) |
232 return; | 211 return; |
233 | 212 |
234 var binding = WebInspector.persistence.binding(uiSourceCode); | |
235 if (binding && binding.network === uiSourceCode) | |
236 return; | |
237 | |
238 var isFromSourceMap = uiSourceCode.contentType().isFromSourceMap(); | 213 var isFromSourceMap = uiSourceCode.contentType().isFromSourceMap(); |
239 var path; | 214 var path; |
240 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSyst em) | 215 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSyst em) |
241 path = WebInspector.FileSystemWorkspaceBinding.relativePath(uiSource Code).slice(0, -1); | 216 path = WebInspector.FileSystemWorkspaceBinding.relativePath(uiSource Code).slice(0, -1); |
242 else | 217 else |
243 path = WebInspector.ParsedURL.splitURLIntoPathComponents(uiSourceCod e.url()).slice(1, -1); | 218 path = WebInspector.ParsedURL.splitURLIntoPathComponents(uiSourceCod e.url()).slice(1, -1); |
244 | 219 |
245 var project = uiSourceCode.project(); | 220 var project = uiSourceCode.project(); |
246 var target = WebInspector.NetworkProject.targetForUISourceCode(uiSourceC ode); | 221 var target = WebInspector.NetworkProject.targetForUISourceCode(uiSourceC ode); |
247 var frame = this._uiSourceCodeFrame(uiSourceCode); | 222 var frame = this._uiSourceCodeFrame(uiSourceCode); |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
824 WebInspector.NavigatorView._treeElementsCompare = function compare(treeElement1, treeElement2) | 799 WebInspector.NavigatorView._treeElementsCompare = function compare(treeElement1, treeElement2) |
825 { | 800 { |
826 var typeWeight1 = WebInspector.NavigatorView._treeElementOrder(treeElement1) ; | 801 var typeWeight1 = WebInspector.NavigatorView._treeElementOrder(treeElement1) ; |
827 var typeWeight2 = WebInspector.NavigatorView._treeElementOrder(treeElement2) ; | 802 var typeWeight2 = WebInspector.NavigatorView._treeElementOrder(treeElement2) ; |
828 | 803 |
829 var result; | 804 var result; |
830 if (typeWeight1 > typeWeight2) | 805 if (typeWeight1 > typeWeight2) |
831 return 1; | 806 return 1; |
832 if (typeWeight1 < typeWeight2) | 807 if (typeWeight1 < typeWeight2) |
833 return -1; | 808 return -1; |
834 var title1 = /** @type {string} */(treeElement1.title); | 809 var title1 = /** @type {string} */(treeElement1.title instanceof Element ? t reeElement1.title.textContent : treeElement1.title); |
dgozman
2016/09/27 17:08:47
titleAsText
lushnikov
2016/09/27 21:29:12
Done.
| |
835 var title2 = /** @type {string} */(treeElement2.title); | 810 var title2 = /** @type {string} */(treeElement2.title instanceof Element ? t reeElement2.title.textContent : treeElement2.title); |
836 return title1.compareTo(title2); | 811 return title1.compareTo(title2); |
837 } | 812 } |
838 | 813 |
839 /** | 814 /** |
840 * @constructor | 815 * @constructor |
841 * @extends {TreeElement} | 816 * @extends {TreeElement} |
842 * @param {!WebInspector.NavigatorView} navigatorView | 817 * @param {!WebInspector.NavigatorView} navigatorView |
843 * @param {string} type | 818 * @param {string} type |
844 * @param {string} title | 819 * @param {string} title |
845 * @param {function(boolean)=} hoverCallback | 820 * @param {function(boolean)=} hoverCallback |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1244 * @extends {WebInspector.NavigatorTreeNode} | 1219 * @extends {WebInspector.NavigatorTreeNode} |
1245 * @param {!WebInspector.NavigatorView} navigatorView | 1220 * @param {!WebInspector.NavigatorView} navigatorView |
1246 * @param {!WebInspector.UISourceCode} uiSourceCode | 1221 * @param {!WebInspector.UISourceCode} uiSourceCode |
1247 */ | 1222 */ |
1248 WebInspector.NavigatorUISourceCodeTreeNode = function(navigatorView, uiSourceCod e) | 1223 WebInspector.NavigatorUISourceCodeTreeNode = function(navigatorView, uiSourceCod e) |
1249 { | 1224 { |
1250 WebInspector.NavigatorTreeNode.call(this, uiSourceCode.project().id() + ":" + uiSourceCode.url(), WebInspector.NavigatorView.Types.File); | 1225 WebInspector.NavigatorTreeNode.call(this, uiSourceCode.project().id() + ":" + uiSourceCode.url(), WebInspector.NavigatorView.Types.File); |
1251 this._navigatorView = navigatorView; | 1226 this._navigatorView = navigatorView; |
1252 this._uiSourceCode = uiSourceCode; | 1227 this._uiSourceCode = uiSourceCode; |
1253 this._treeElement = null; | 1228 this._treeElement = null; |
1229 this._eventListeners = []; | |
1254 } | 1230 } |
1255 | 1231 |
1256 WebInspector.NavigatorUISourceCodeTreeNode.prototype = { | 1232 WebInspector.NavigatorUISourceCodeTreeNode.prototype = { |
1257 /** | 1233 /** |
1258 * @return {!WebInspector.UISourceCode} | 1234 * @return {!WebInspector.UISourceCode} |
1259 */ | 1235 */ |
1260 uiSourceCode: function() | 1236 uiSourceCode: function() |
1261 { | 1237 { |
1262 return this._uiSourceCode; | 1238 return this._uiSourceCode; |
1263 }, | 1239 }, |
1264 | 1240 |
1265 /** | 1241 /** |
1266 * @override | 1242 * @override |
1267 * @return {!TreeElement} | 1243 * @return {!TreeElement} |
1268 */ | 1244 */ |
1269 treeNode: function() | 1245 treeNode: function() |
1270 { | 1246 { |
1271 if (this._treeElement) | 1247 if (this._treeElement) |
1272 return this._treeElement; | 1248 return this._treeElement; |
1273 | 1249 |
1274 this._treeElement = new WebInspector.NavigatorSourceTreeElement(this._na vigatorView, this._uiSourceCode, ""); | 1250 this._treeElement = new WebInspector.NavigatorSourceTreeElement(this._na vigatorView, this._uiSourceCode, ""); |
1275 this.updateTitle(); | 1251 this.updateTitle(); |
1276 | 1252 |
1277 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Tit leChanged, this._titleChanged, this); | 1253 var updateTitleBound = this.updateTitle.bind(this, undefined); |
1278 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Wor kingCopyChanged, this._workingCopyChanged, this); | 1254 this._eventListeners = [ |
1279 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Wor kingCopyCommitted, this._workingCopyCommitted, this); | 1255 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events .TitleChanged, updateTitleBound), |
1280 | 1256 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events .WorkingCopyChanged, updateTitleBound), |
1257 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events .WorkingCopyCommitted, updateTitleBound), | |
1258 WebInspector.persistence.addEventListener(WebInspector.Persistence.E vents.BindingCreated, updateTitleBound), | |
dgozman
2016/09/27 17:08:47
Should not listen for this on every tree node.
lushnikov
2016/09/27 21:29:12
Done.
| |
1259 WebInspector.persistence.addEventListener(WebInspector.Persistence.E vents.BindingRemoved, updateTitleBound) | |
1260 ]; | |
1281 return this._treeElement; | 1261 return this._treeElement; |
1282 }, | 1262 }, |
1283 | 1263 |
1284 /** | 1264 /** |
1285 * @param {boolean=} ignoreIsDirty | 1265 * @param {boolean=} ignoreIsDirty |
1286 */ | 1266 */ |
1287 updateTitle: function(ignoreIsDirty) | 1267 updateTitle: function(ignoreIsDirty) |
1288 { | 1268 { |
1289 if (!this._treeElement) | 1269 if (!this._treeElement) |
1290 return; | 1270 return; |
1291 | 1271 |
1292 var titleText = this._uiSourceCode.displayName(); | 1272 var titleText = this._uiSourceCode.displayName(); |
1293 if (!ignoreIsDirty && (this._uiSourceCode.isDirty() || WebInspector.pers istence.hasUnsavedCommittedChanges(this._uiSourceCode))) | 1273 if (!ignoreIsDirty && (this._uiSourceCode.isDirty() || WebInspector.pers istence.hasUnsavedCommittedChanges(this._uiSourceCode))) |
1294 titleText = "*" + titleText; | 1274 titleText = "*" + titleText; |
1295 this._treeElement.title = titleText; | 1275 |
1276 var binding = WebInspector.persistence.binding(this._uiSourceCode); | |
1277 if (binding) { | |
1278 var titleElement = createElement("span"); | |
1279 titleElement.textContent = titleText; | |
1280 var status = titleElement.createChild("span"); | |
1281 status.classList.add("mapped-file-bubble"); | |
1282 status.textContent = "â—‰"; | |
dgozman
2016/09/27 17:08:47
\uxxxx
lushnikov
2016/09/27 21:29:12
Done.
| |
1283 if (this._uiSourceCode === binding.network) | |
dgozman
2016/09/27 17:08:47
Let's trim urls.
lushnikov
2016/09/27 21:29:12
Done.
| |
1284 status.title = WebInspector.UIString("Mapped to fileSystem: %s", binding.fileSystem.url()); | |
dgozman
2016/09/27 17:08:47
Persisted to file system: %s
lushnikov
2016/09/27 21:29:13
Done.
| |
1285 else if (binding.network.contentType().isFromSourceMap()) | |
1286 status.title = WebInspector.UIString("Mapped to source map: %s", binding.network.url()); | |
dgozman
2016/09/27 17:08:47
Linked to source map: %s
lushnikov
2016/09/27 21:29:12
Done.
| |
1287 else | |
1288 status.title = WebInspector.UIString("Mapped to network: %s", bi nding.network.url()); | |
dgozman
2016/09/27 17:08:47
Linked to %s
lushnikov
2016/09/27 21:29:12
Done.
| |
1289 this._treeElement.title = titleElement; | |
1290 } else { | |
1291 this._treeElement.title = titleText; | |
1292 } | |
1296 | 1293 |
1297 var tooltip = this._uiSourceCode.url(); | 1294 var tooltip = this._uiSourceCode.url(); |
1298 if (this._uiSourceCode.contentType().isFromSourceMap()) | 1295 if (this._uiSourceCode.contentType().isFromSourceMap()) |
1299 tooltip = WebInspector.UIString("%s (from source map)", this._uiSour ceCode.displayName()); | 1296 tooltip = WebInspector.UIString("%s (from source map)", this._uiSour ceCode.displayName()); |
1300 this._treeElement.tooltip = tooltip; | 1297 this._treeElement.tooltip = tooltip; |
1301 }, | 1298 }, |
1302 | 1299 |
1303 /** | 1300 /** |
1304 * @override | 1301 * @override |
1305 * @return {boolean} | 1302 * @return {boolean} |
1306 */ | 1303 */ |
1307 hasChildren: function() | 1304 hasChildren: function() |
1308 { | 1305 { |
1309 return false; | 1306 return false; |
1310 }, | 1307 }, |
1311 | 1308 |
1312 dispose: function() | 1309 dispose: function() |
1313 { | 1310 { |
1314 if (!this._treeElement) | 1311 WebInspector.EventTarget.removeEventListeners(this._eventListeners); |
1315 return; | |
1316 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. TitleChanged, this._titleChanged, this); | |
1317 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyChanged, this._workingCopyChanged, this); | |
1318 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyCommitted, this._workingCopyCommitted, this); | |
1319 }, | |
1320 | |
1321 _titleChanged: function(event) | |
1322 { | |
1323 this.updateTitle(); | |
1324 }, | |
1325 | |
1326 _workingCopyChanged: function(event) | |
1327 { | |
1328 this.updateTitle(); | |
1329 }, | |
1330 | |
1331 _workingCopyCommitted: function(event) | |
1332 { | |
1333 this.updateTitle(); | |
1334 }, | 1312 }, |
1335 | 1313 |
1336 /** | 1314 /** |
1337 * @param {boolean=} select | 1315 * @param {boolean=} select |
1338 */ | 1316 */ |
1339 reveal: function(select) | 1317 reveal: function(select) |
1340 { | 1318 { |
1341 this.parent.populate(); | 1319 this.parent.populate(); |
1342 this.parent.treeNode().expand(); | 1320 this.parent.treeNode().expand(); |
1343 this._treeElement.reveal(); | 1321 this._treeElement.reveal(); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1417 * @param {string} type | 1395 * @param {string} type |
1418 * @param {string} folderPath | 1396 * @param {string} folderPath |
1419 * @param {string} title | 1397 * @param {string} title |
1420 */ | 1398 */ |
1421 WebInspector.NavigatorFolderTreeNode = function(navigatorView, project, id, type , folderPath, title) | 1399 WebInspector.NavigatorFolderTreeNode = function(navigatorView, project, id, type , folderPath, title) |
1422 { | 1400 { |
1423 WebInspector.NavigatorTreeNode.call(this, id, type); | 1401 WebInspector.NavigatorTreeNode.call(this, id, type); |
1424 this._navigatorView = navigatorView; | 1402 this._navigatorView = navigatorView; |
1425 this._project = project; | 1403 this._project = project; |
1426 this._folderPath = folderPath; | 1404 this._folderPath = folderPath; |
1405 this._absoluteFileSystemPath = ""; | |
1406 if (this._project.type() === WebInspector.projectTypes.FileSystem) | |
1407 this._absoluteFileSystemPath = WebInspector.FileSystemWorkspaceBinding.f ileSystemPath(this._project.id()) + "/" + this._folderPath; | |
1427 this._title = title; | 1408 this._title = title; |
1409 this._eventListeners = []; | |
1428 } | 1410 } |
1429 | 1411 |
1430 WebInspector.NavigatorFolderTreeNode.prototype = { | 1412 WebInspector.NavigatorFolderTreeNode.prototype = { |
1431 /** | 1413 /** |
1432 * @override | 1414 * @override |
1433 * @return {!TreeElement} | 1415 * @return {!TreeElement} |
1434 */ | 1416 */ |
1435 treeNode: function() | 1417 treeNode: function() |
1436 { | 1418 { |
1437 if (this._treeElement) | 1419 if (this._treeElement) |
1438 return this._treeElement; | 1420 return this._treeElement; |
1439 this._treeElement = this._createTreeElement(this._title, this); | 1421 this._treeElement = this._createTreeElement(this._title, this); |
1422 if (this._project.type() === WebInspector.projectTypes.FileSystem) { | |
1423 this._eventListeners = [ | |
1424 WebInspector.persistence.addEventListener(WebInspector.Persisten ce.Events.BindingCreated, this._updateHasMappedFiles, this), | |
dgozman
2016/09/27 17:08:47
Make it global.
lushnikov
2016/09/27 21:29:12
Done.
| |
1425 WebInspector.persistence.addEventListener(WebInspector.Persisten ce.Events.BindingRemoved, this._updateHasMappedFiles, this) | |
1426 ]; | |
1427 this._updateHasMappedFiles(); | |
1428 } | |
1440 return this._treeElement; | 1429 return this._treeElement; |
1441 }, | 1430 }, |
1442 | 1431 |
1432 _updateHasMappedFiles: function() | |
1433 { | |
1434 this._treeElement.listItemElement.classList.toggle("has-mapped-files", W ebInspector.persistence.filePathHasBindings(this._absoluteFileSystemPath)); | |
1435 }, | |
1436 | |
1443 /** | 1437 /** |
1444 * @return {!TreeElement} | 1438 * @return {!TreeElement} |
1445 */ | 1439 */ |
1446 _createTreeElement: function(title, node) | 1440 _createTreeElement: function(title, node) |
1447 { | 1441 { |
1448 if (this._project.type() !== WebInspector.projectTypes.FileSystem) { | 1442 if (this._project.type() !== WebInspector.projectTypes.FileSystem) { |
1449 try { | 1443 try { |
1450 title = decodeURI(title); | 1444 title = decodeURI(title); |
1451 } catch (e) { | 1445 } catch (e) { |
1452 } | 1446 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1552 * @override | 1546 * @override |
1553 * @param {!WebInspector.NavigatorTreeNode} node | 1547 * @param {!WebInspector.NavigatorTreeNode} node |
1554 */ | 1548 */ |
1555 willRemoveChild: function(node) | 1549 willRemoveChild: function(node) |
1556 { | 1550 { |
1557 if (node._isMerged || !this.isPopulated()) | 1551 if (node._isMerged || !this.isPopulated()) |
1558 return; | 1552 return; |
1559 this._treeElement.removeChild(node._treeElement); | 1553 this._treeElement.removeChild(node._treeElement); |
1560 }, | 1554 }, |
1561 | 1555 |
1556 dispose: function() | |
1557 { | |
1558 WebInspector.EventTarget.removeEventListeners(this._eventListeners); | |
1559 }, | |
1560 | |
1562 __proto__: WebInspector.NavigatorTreeNode.prototype | 1561 __proto__: WebInspector.NavigatorTreeNode.prototype |
1563 } | 1562 } |
1564 | 1563 |
1565 /** | 1564 /** |
1566 * @constructor | 1565 * @constructor |
1567 * @extends {WebInspector.NavigatorTreeNode} | 1566 * @extends {WebInspector.NavigatorTreeNode} |
1568 * @param {!WebInspector.NavigatorView} navigatorView | 1567 * @param {!WebInspector.NavigatorView} navigatorView |
1569 * @param {!WebInspector.Project} project | 1568 * @param {!WebInspector.Project} project |
1570 * @param {string} id | 1569 * @param {string} id |
1571 * @param {string} type | 1570 * @param {string} type |
1572 * @param {string} title | 1571 * @param {string} title |
1573 */ | 1572 */ |
1574 WebInspector.NavigatorGroupTreeNode = function(navigatorView, project, id, type, title) | 1573 WebInspector.NavigatorGroupTreeNode = function(navigatorView, project, id, type, title) |
1575 { | 1574 { |
1576 WebInspector.NavigatorTreeNode.call(this, id, type); | 1575 WebInspector.NavigatorTreeNode.call(this, id, type); |
1577 this._project = project; | 1576 this._project = project; |
1578 this._navigatorView = navigatorView; | 1577 this._navigatorView = navigatorView; |
1579 this._title = title; | 1578 this._title = title; |
1579 this._eventListeners = []; | |
1580 this.populate(); | 1580 this.populate(); |
1581 } | 1581 } |
1582 | 1582 |
1583 WebInspector.NavigatorGroupTreeNode.prototype = { | 1583 WebInspector.NavigatorGroupTreeNode.prototype = { |
1584 /** | 1584 /** |
1585 * @param {function(boolean)} hoverCallback | 1585 * @param {function(boolean)} hoverCallback |
1586 */ | 1586 */ |
1587 setHoverCallback: function(hoverCallback) | 1587 setHoverCallback: function(hoverCallback) |
1588 { | 1588 { |
1589 this._hoverCallback = hoverCallback; | 1589 this._hoverCallback = hoverCallback; |
1590 }, | 1590 }, |
1591 | 1591 |
1592 /** | 1592 /** |
1593 * @override | 1593 * @override |
1594 * @return {!TreeElement} | 1594 * @return {!TreeElement} |
1595 */ | 1595 */ |
1596 treeNode: function() | 1596 treeNode: function() |
1597 { | 1597 { |
1598 if (this._treeElement) | 1598 if (this._treeElement) |
1599 return this._treeElement; | 1599 return this._treeElement; |
1600 this._treeElement = new WebInspector.NavigatorFolderTreeElement(this._na vigatorView, this._type, this._title, this._hoverCallback); | 1600 this._treeElement = new WebInspector.NavigatorFolderTreeElement(this._na vigatorView, this._type, this._title, this._hoverCallback); |
1601 this._treeElement.setNode(this); | 1601 this._treeElement.setNode(this); |
1602 if (this._project.type() === WebInspector.projectTypes.FileSystem) { | |
1603 this._eventListeners = [ | |
1604 WebInspector.persistence.addEventListener(WebInspector.Persisten ce.Events.BindingCreated, this._updateHasMappedFiles, this), | |
dgozman
2016/09/27 17:08:47
ditto
lushnikov
2016/09/27 21:29:12
Done.
| |
1605 WebInspector.persistence.addEventListener(WebInspector.Persisten ce.Events.BindingRemoved, this._updateHasMappedFiles, this) | |
1606 ]; | |
1607 this._updateHasMappedFiles(); | |
1608 } | |
1602 return this._treeElement; | 1609 return this._treeElement; |
1603 }, | 1610 }, |
1604 | 1611 |
1612 _updateHasMappedFiles: function() | |
1613 { | |
1614 var fileSystemPath = WebInspector.FileSystemWorkspaceBinding.fileSystemP ath(this._project.id()); | |
1615 var wasActive = this._treeElement.listItemElement.classList.contains("ha s-mapped-files"); | |
1616 var isActive = WebInspector.persistence.filePathHasBindings(fileSystemPa th); | |
1617 if (wasActive === isActive) | |
1618 return; | |
1619 this._treeElement.listItemElement.classList.toggle("has-mapped-files", i sActive); | |
1620 if (isActive) | |
1621 this._treeElement.expand(); | |
1622 else | |
1623 this._treeElement.collapse(); | |
1624 }, | |
1625 | |
1626 dispose: function() | |
dgozman
2016/09/27 17:08:47
@override ?
lushnikov
2016/09/27 21:29:12
Done.
| |
1627 { | |
1628 WebInspector.EventTarget.removeEventListeners(this._eventListeners); | |
1629 }, | |
1630 | |
1605 __proto__: WebInspector.NavigatorTreeNode.prototype | 1631 __proto__: WebInspector.NavigatorTreeNode.prototype |
1606 } | 1632 } |
OLD | NEW |