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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 this._frameNodes = new Map(); | 53 this._frameNodes = new Map(); |
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.persistence.addEventListener(WebInspector.Persistence.Events.Bi ndingCreated, this._onBindingChanged, this); | |
64 WebInspector.persistence.addEventListener(WebInspector.Persistence.Events.Bi ndingRemoved, this._onBindingChanged, this); | |
65 | |
63 WebInspector.targetManager.observeTargets(this); | 66 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); | 67 this._resetWorkspace(WebInspector.workspace); |
67 } | 68 } |
68 | 69 |
69 WebInspector.NavigatorView.Types = { | 70 WebInspector.NavigatorView.Types = { |
70 Category: "category", | 71 Category: "category", |
71 Domain: "domain", | 72 Domain: "domain", |
72 File: "file", | 73 File: "file", |
73 FileSystem: "fs", | 74 FileSystem: "fs", |
74 FileSystemFolder: "fs-folder", | 75 FileSystemFolder: "fs-folder", |
75 Frame: "frame", | 76 Frame: "frame", |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 path = "*"; | 150 path = "*"; |
150 searchLabel = WebInspector.UIString.capitalize("Search in ^all ^files"); | 151 searchLabel = WebInspector.UIString.capitalize("Search in ^all ^files"); |
151 } | 152 } |
152 contextMenu.appendItem(searchLabel, searchPath); | 153 contextMenu.appendItem(searchLabel, searchPath); |
153 } | 154 } |
154 | 155 |
155 WebInspector.NavigatorView.prototype = { | 156 WebInspector.NavigatorView.prototype = { |
156 /** | 157 /** |
157 * @param {!WebInspector.Event} event | 158 * @param {!WebInspector.Event} event |
158 */ | 159 */ |
159 _onBindingCreated: function(event) | 160 _onBindingChanged: function(event) |
160 { | 161 { |
161 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data ); | 162 var binding = /** @type {!WebInspector.PersistenceBinding} */(event.data ); |
162 // TODO(lushnikov): show network UISourceCodes in navigator. | 163 |
163 this._removeUISourceCode(binding.network); | 164 // Update UISourceCode titles. |
165 var networkNode = this._uiSourceCodeNodes.get(binding.network); | |
166 if (networkNode) | |
167 networkNode.updateTitle(); | |
168 var fileSystemNode = this._uiSourceCodeNodes.get(binding.fileSystem); | |
169 if (fileSystemNode) | |
170 fileSystemNode.updateTitle(); | |
171 | |
172 // Update folder titles. | |
173 var pathTokens = WebInspector.FileSystemWorkspaceBinding.relativePath(bi nding.fileSystem); | |
174 var folderPath = ""; | |
175 for (var i = 0; i < pathTokens.length - 1; ++i) { | |
176 folderPath += pathTokens[i]; | |
177 var folderId = this._folderNodeId(binding.fileSystem.project(), null , null, binding.fileSystem.origin(), folderPath); | |
178 var folderNode = this._subfolderNodes.get(folderId); | |
179 if (folderNode) | |
180 folderNode.updateTitle(); | |
181 folderPath += "/"; | |
182 } | |
183 | |
184 // Update fileSystem root title. | |
185 var fileSystemRoot = this._rootNode.child(binding.fileSystem.project().i d()); | |
186 if (fileSystemRoot) | |
187 fileSystemRoot.updateTitle(); | |
164 }, | 188 }, |
165 | 189 |
166 /** | 190 /** |
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 | 191 * @override |
177 */ | 192 */ |
178 focus: function() | 193 focus: function() |
179 { | 194 { |
180 this._scriptsTree.focus(); | 195 this._scriptsTree.focus(); |
181 }, | 196 }, |
182 | 197 |
183 /** | 198 /** |
184 * @param {!WebInspector.Workspace} workspace | 199 * @param {!WebInspector.Workspace} workspace |
185 */ | 200 */ |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 }, | 239 }, |
225 | 240 |
226 /** | 241 /** |
227 * @param {!WebInspector.UISourceCode} uiSourceCode | 242 * @param {!WebInspector.UISourceCode} uiSourceCode |
228 */ | 243 */ |
229 _addUISourceCode: function(uiSourceCode) | 244 _addUISourceCode: function(uiSourceCode) |
230 { | 245 { |
231 if (!this.accept(uiSourceCode)) | 246 if (!this.accept(uiSourceCode)) |
232 return; | 247 return; |
233 | 248 |
234 var binding = WebInspector.persistence.binding(uiSourceCode); | |
235 if (binding && binding.network === uiSourceCode) | |
236 return; | |
237 | |
238 var isFromSourceMap = uiSourceCode.contentType().isFromSourceMap(); | 249 var isFromSourceMap = uiSourceCode.contentType().isFromSourceMap(); |
239 var path; | 250 var path; |
240 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSyst em) | 251 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSyst em) |
241 path = WebInspector.FileSystemWorkspaceBinding.relativePath(uiSource Code).slice(0, -1); | 252 path = WebInspector.FileSystemWorkspaceBinding.relativePath(uiSource Code).slice(0, -1); |
242 else | 253 else |
243 path = WebInspector.ParsedURL.splitURLIntoPathComponents(uiSourceCod e.url()).slice(1, -1); | 254 path = WebInspector.ParsedURL.splitURLIntoPathComponents(uiSourceCod e.url()).slice(1, -1); |
244 | 255 |
245 var project = uiSourceCode.project(); | 256 var project = uiSourceCode.project(); |
246 var target = WebInspector.NetworkProject.targetForUISourceCode(uiSourceC ode); | 257 var target = WebInspector.NetworkProject.targetForUISourceCode(uiSourceC ode); |
247 var frame = this._uiSourceCodeFrame(uiSourceCode); | 258 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) | 835 WebInspector.NavigatorView._treeElementsCompare = function compare(treeElement1, treeElement2) |
825 { | 836 { |
826 var typeWeight1 = WebInspector.NavigatorView._treeElementOrder(treeElement1) ; | 837 var typeWeight1 = WebInspector.NavigatorView._treeElementOrder(treeElement1) ; |
827 var typeWeight2 = WebInspector.NavigatorView._treeElementOrder(treeElement2) ; | 838 var typeWeight2 = WebInspector.NavigatorView._treeElementOrder(treeElement2) ; |
828 | 839 |
829 var result; | 840 var result; |
830 if (typeWeight1 > typeWeight2) | 841 if (typeWeight1 > typeWeight2) |
831 return 1; | 842 return 1; |
832 if (typeWeight1 < typeWeight2) | 843 if (typeWeight1 < typeWeight2) |
833 return -1; | 844 return -1; |
834 var title1 = /** @type {string} */(treeElement1.title); | 845 return treeElement1.titleAsText().compareTo(treeElement2.titleAsText()); |
835 var title2 = /** @type {string} */(treeElement2.title); | |
836 return title1.compareTo(title2); | |
837 } | 846 } |
838 | 847 |
839 /** | 848 /** |
840 * @constructor | 849 * @constructor |
841 * @extends {TreeElement} | 850 * @extends {TreeElement} |
842 * @param {!WebInspector.NavigatorView} navigatorView | 851 * @param {!WebInspector.NavigatorView} navigatorView |
843 * @param {string} type | 852 * @param {string} type |
844 * @param {string} title | 853 * @param {string} title |
845 * @param {function(boolean)=} hoverCallback | 854 * @param {function(boolean)=} hoverCallback |
846 */ | 855 */ |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1244 * @extends {WebInspector.NavigatorTreeNode} | 1253 * @extends {WebInspector.NavigatorTreeNode} |
1245 * @param {!WebInspector.NavigatorView} navigatorView | 1254 * @param {!WebInspector.NavigatorView} navigatorView |
1246 * @param {!WebInspector.UISourceCode} uiSourceCode | 1255 * @param {!WebInspector.UISourceCode} uiSourceCode |
1247 */ | 1256 */ |
1248 WebInspector.NavigatorUISourceCodeTreeNode = function(navigatorView, uiSourceCod e) | 1257 WebInspector.NavigatorUISourceCodeTreeNode = function(navigatorView, uiSourceCod e) |
1249 { | 1258 { |
1250 WebInspector.NavigatorTreeNode.call(this, uiSourceCode.project().id() + ":" + uiSourceCode.url(), WebInspector.NavigatorView.Types.File); | 1259 WebInspector.NavigatorTreeNode.call(this, uiSourceCode.project().id() + ":" + uiSourceCode.url(), WebInspector.NavigatorView.Types.File); |
1251 this._navigatorView = navigatorView; | 1260 this._navigatorView = navigatorView; |
1252 this._uiSourceCode = uiSourceCode; | 1261 this._uiSourceCode = uiSourceCode; |
1253 this._treeElement = null; | 1262 this._treeElement = null; |
1263 this._eventListeners = []; | |
1254 } | 1264 } |
1255 | 1265 |
1256 WebInspector.NavigatorUISourceCodeTreeNode.prototype = { | 1266 WebInspector.NavigatorUISourceCodeTreeNode.prototype = { |
1257 /** | 1267 /** |
1258 * @return {!WebInspector.UISourceCode} | 1268 * @return {!WebInspector.UISourceCode} |
1259 */ | 1269 */ |
1260 uiSourceCode: function() | 1270 uiSourceCode: function() |
1261 { | 1271 { |
1262 return this._uiSourceCode; | 1272 return this._uiSourceCode; |
1263 }, | 1273 }, |
1264 | 1274 |
1265 /** | 1275 /** |
1266 * @override | 1276 * @override |
1267 * @return {!TreeElement} | 1277 * @return {!TreeElement} |
1268 */ | 1278 */ |
1269 treeNode: function() | 1279 treeNode: function() |
1270 { | 1280 { |
1271 if (this._treeElement) | 1281 if (this._treeElement) |
1272 return this._treeElement; | 1282 return this._treeElement; |
1273 | 1283 |
1274 this._treeElement = new WebInspector.NavigatorSourceTreeElement(this._na vigatorView, this._uiSourceCode, ""); | 1284 this._treeElement = new WebInspector.NavigatorSourceTreeElement(this._na vigatorView, this._uiSourceCode, ""); |
1275 this.updateTitle(); | 1285 this.updateTitle(); |
1276 | 1286 |
1277 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Tit leChanged, this._titleChanged, this); | 1287 var updateTitleBound = this.updateTitle.bind(this, undefined); |
1278 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Wor kingCopyChanged, this._workingCopyChanged, this); | 1288 this._eventListeners = [ |
1279 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Wor kingCopyCommitted, this._workingCopyCommitted, this); | 1289 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events .TitleChanged, updateTitleBound), |
1280 | 1290 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events .WorkingCopyChanged, updateTitleBound), |
1291 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events .WorkingCopyCommitted, updateTitleBound) | |
1292 ]; | |
1281 return this._treeElement; | 1293 return this._treeElement; |
1282 }, | 1294 }, |
1283 | 1295 |
1284 /** | 1296 /** |
1285 * @param {boolean=} ignoreIsDirty | 1297 * @param {boolean=} ignoreIsDirty |
1286 */ | 1298 */ |
1287 updateTitle: function(ignoreIsDirty) | 1299 updateTitle: function(ignoreIsDirty) |
1288 { | 1300 { |
1289 if (!this._treeElement) | 1301 if (!this._treeElement) |
1290 return; | 1302 return; |
1291 | 1303 |
1292 var titleText = this._uiSourceCode.displayName(); | 1304 var titleText = this._uiSourceCode.displayName(); |
1293 if (!ignoreIsDirty && (this._uiSourceCode.isDirty() || WebInspector.pers istence.hasUnsavedCommittedChanges(this._uiSourceCode))) | 1305 if (!ignoreIsDirty && (this._uiSourceCode.isDirty() || WebInspector.pers istence.hasUnsavedCommittedChanges(this._uiSourceCode))) |
1294 titleText = "*" + titleText; | 1306 titleText = "*" + titleText; |
1295 this._treeElement.title = titleText; | 1307 |
1308 var binding = WebInspector.persistence.binding(this._uiSourceCode); | |
1309 if (binding) { | |
1310 var titleElement = createElement("span"); | |
1311 titleElement.textContent = titleText; | |
1312 var status = titleElement.createChild("span"); | |
1313 status.classList.add("mapped-file-bubble"); | |
1314 status.textContent = "\u25C9"; | |
1315 if (this._uiSourceCode === binding.network) | |
1316 status.title = WebInspector.UIString("Persisted to file system: %s", binding.fileSystem.url().trimMiddle(150)); | |
1317 else if (binding.network.contentType().isFromSourceMap()) | |
1318 status.title = WebInspector.UIString("Linked to source map: %s", binding.network.url().trimMiddle(150)); | |
1319 else | |
1320 status.title = WebInspector.UIString("Linked to %s", binding.net work.url().trimMiddle(150)); | |
1321 this._treeElement.title = titleElement; | |
1322 } else { | |
1323 this._treeElement.title = titleText; | |
1324 } | |
1296 | 1325 |
1297 var tooltip = this._uiSourceCode.url(); | 1326 var tooltip = this._uiSourceCode.url(); |
1298 if (this._uiSourceCode.contentType().isFromSourceMap()) | 1327 if (this._uiSourceCode.contentType().isFromSourceMap()) |
1299 tooltip = WebInspector.UIString("%s (from source map)", this._uiSour ceCode.displayName()); | 1328 tooltip = WebInspector.UIString("%s (from source map)", this._uiSour ceCode.displayName()); |
1300 this._treeElement.tooltip = tooltip; | 1329 this._treeElement.tooltip = tooltip; |
1301 }, | 1330 }, |
1302 | 1331 |
1303 /** | 1332 /** |
1304 * @override | 1333 * @override |
1305 * @return {boolean} | 1334 * @return {boolean} |
1306 */ | 1335 */ |
1307 hasChildren: function() | 1336 hasChildren: function() |
1308 { | 1337 { |
1309 return false; | 1338 return false; |
1310 }, | 1339 }, |
1311 | 1340 |
1341 /** | |
1342 * @override | |
1343 */ | |
1312 dispose: function() | 1344 dispose: function() |
1313 { | 1345 { |
1314 if (!this._treeElement) | 1346 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 }, | 1347 }, |
1335 | 1348 |
1336 /** | 1349 /** |
1337 * @param {boolean=} select | 1350 * @param {boolean=} select |
1338 */ | 1351 */ |
1339 reveal: function(select) | 1352 reveal: function(select) |
1340 { | 1353 { |
1341 this.parent.populate(); | 1354 this.parent.populate(); |
1342 this.parent.treeNode().expand(); | 1355 this.parent.treeNode().expand(); |
1343 this._treeElement.reveal(); | 1356 this._treeElement.reveal(); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1430 WebInspector.NavigatorFolderTreeNode.prototype = { | 1443 WebInspector.NavigatorFolderTreeNode.prototype = { |
1431 /** | 1444 /** |
1432 * @override | 1445 * @override |
1433 * @return {!TreeElement} | 1446 * @return {!TreeElement} |
1434 */ | 1447 */ |
1435 treeNode: function() | 1448 treeNode: function() |
1436 { | 1449 { |
1437 if (this._treeElement) | 1450 if (this._treeElement) |
1438 return this._treeElement; | 1451 return this._treeElement; |
1439 this._treeElement = this._createTreeElement(this._title, this); | 1452 this._treeElement = this._createTreeElement(this._title, this); |
1453 this.updateTitle(); | |
1440 return this._treeElement; | 1454 return this._treeElement; |
1441 }, | 1455 }, |
1442 | 1456 |
1457 updateTitle: function() | |
1458 { | |
1459 if (!this._treeElement || this._project.type() !== WebInspector.projectT ypes.FileSystem) | |
1460 return; | |
1461 var absoluteFileSystemPath = WebInspector.FileSystemWorkspaceBinding.fil eSystemPath(this._project.id()) + "/" + this._folderPath; | |
1462 this._treeElement.listItemElement.classList.toggle("has-mapped-files", W ebInspector.persistence.filePathHasBindings(absoluteFileSystemPath)); | |
1463 }, | |
1464 | |
1443 /** | 1465 /** |
1444 * @return {!TreeElement} | 1466 * @return {!TreeElement} |
1445 */ | 1467 */ |
1446 _createTreeElement: function(title, node) | 1468 _createTreeElement: function(title, node) |
1447 { | 1469 { |
1448 if (this._project.type() !== WebInspector.projectTypes.FileSystem) { | 1470 if (this._project.type() !== WebInspector.projectTypes.FileSystem) { |
1449 try { | 1471 try { |
1450 title = decodeURI(title); | 1472 title = decodeURI(title); |
1451 } catch (e) { | 1473 } catch (e) { |
1452 } | 1474 } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1595 */ | 1617 */ |
1596 treeNode: function() | 1618 treeNode: function() |
1597 { | 1619 { |
1598 if (this._treeElement) | 1620 if (this._treeElement) |
1599 return this._treeElement; | 1621 return this._treeElement; |
1600 this._treeElement = new WebInspector.NavigatorFolderTreeElement(this._na vigatorView, this._type, this._title, this._hoverCallback); | 1622 this._treeElement = new WebInspector.NavigatorFolderTreeElement(this._na vigatorView, this._type, this._title, this._hoverCallback); |
1601 this._treeElement.setNode(this); | 1623 this._treeElement.setNode(this); |
1602 return this._treeElement; | 1624 return this._treeElement; |
1603 }, | 1625 }, |
1604 | 1626 |
1627 /** | |
1628 * @override | |
1629 */ | |
1630 onattach: function() | |
lushnikov
2016/09/28 18:11:44
The logic in updateTitle which expands active file
| |
1631 { | |
1632 this.updateTitle(); | |
1633 }, | |
1634 | |
1635 updateTitle: function() | |
1636 { | |
1637 if (!this._treeElement || this._project.type() !== WebInspector.projectT ypes.FileSystem) | |
1638 return; | |
1639 var fileSystemPath = WebInspector.FileSystemWorkspaceBinding.fileSystemP ath(this._project.id()); | |
1640 var wasActive = this._treeElement.listItemElement.classList.contains("ha s-mapped-files"); | |
1641 var isActive = WebInspector.persistence.filePathHasBindings(fileSystemPa th); | |
1642 if (wasActive === isActive) | |
1643 return; | |
1644 this._treeElement.listItemElement.classList.toggle("has-mapped-files", i sActive); | |
1645 if (isActive) | |
1646 this._treeElement.expand(); | |
1647 else | |
1648 this._treeElement.collapse(); | |
1649 }, | |
1650 | |
1605 __proto__: WebInspector.NavigatorTreeNode.prototype | 1651 __proto__: WebInspector.NavigatorTreeNode.prototype |
1606 } | 1652 } |
OLD | NEW |