| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 this._subfolderNodes = new Map(); | 46 this._subfolderNodes = new Map(); |
| 47 | 47 |
| 48 this._rootNode = new Sources.NavigatorRootTreeNode(this); | 48 this._rootNode = new Sources.NavigatorRootTreeNode(this); |
| 49 this._rootNode.populate(); | 49 this._rootNode.populate(); |
| 50 | 50 |
| 51 /** @type {!Map.<!SDK.ResourceTreeFrame, !Sources.NavigatorGroupTreeNode>} *
/ | 51 /** @type {!Map.<!SDK.ResourceTreeFrame, !Sources.NavigatorGroupTreeNode>} *
/ |
| 52 this._frameNodes = new Map(); | 52 this._frameNodes = new Map(); |
| 53 | 53 |
| 54 this.element.addEventListener('contextmenu', this.handleContextMenu.bind(thi
s), false); | 54 this.element.addEventListener('contextmenu', this.handleContextMenu.bind(thi
s), false); |
| 55 | 55 |
| 56 this._dontGroup = false; |
| 56 this._navigatorGroupByFolderSetting = Common.moduleSetting('navigatorGroupBy
Folder'); | 57 this._navigatorGroupByFolderSetting = Common.moduleSetting('navigatorGroupBy
Folder'); |
| 57 this._navigatorGroupByFolderSetting.addChangeListener(this._groupingChanged.
bind(this)); | 58 this._navigatorGroupByFolderSetting.addChangeListener(this._groupingChanged.
bind(this)); |
| 58 | 59 |
| 59 this._initGrouping(); | 60 this._initGrouping(); |
| 60 SDK.targetManager.addModelListener( | 61 SDK.targetManager.addModelListener( |
| 61 SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.FrameNavigated, this
._frameNavigated, this); | 62 SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.FrameNavigated, this
._frameNavigated, this); |
| 62 SDK.targetManager.addModelListener( | 63 SDK.targetManager.addModelListener( |
| 63 SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.FrameDetached, this.
_frameDetached, this); | 64 SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.FrameDetached, this.
_frameDetached, this); |
| 64 | 65 |
| 65 if (Runtime.experiments.isEnabled('persistence2')) { | 66 if (Runtime.experiments.isEnabled('persistence2')) { |
| 66 Persistence.persistence.addEventListener( | 67 Persistence.persistence.addEventListener( |
| 67 Persistence.Persistence.Events.BindingCreated, this._onBindingChanged,
this); | 68 Persistence.Persistence.Events.BindingCreated, this._onBindingChanged,
this); |
| 68 Persistence.persistence.addEventListener( | 69 Persistence.persistence.addEventListener( |
| 69 Persistence.Persistence.Events.BindingRemoved, this._onBindingChanged,
this); | 70 Persistence.Persistence.Events.BindingRemoved, this._onBindingChanged,
this); |
| 70 } else { | 71 } else { |
| 71 Persistence.persistence.addEventListener( | 72 Persistence.persistence.addEventListener( |
| 72 Persistence.Persistence.Events.BindingCreated, this._onBindingCreated,
this); | 73 Persistence.Persistence.Events.BindingCreated, this._onBindingCreated,
this); |
| 73 Persistence.persistence.addEventListener( | 74 Persistence.persistence.addEventListener( |
| 74 Persistence.Persistence.Events.BindingRemoved, this._onBindingRemoved,
this); | 75 Persistence.Persistence.Events.BindingRemoved, this._onBindingRemoved,
this); |
| 75 } | 76 } |
| 76 SDK.targetManager.addEventListener(SDK.TargetManager.Events.NameChanged, thi
s._targetNameChanged, this); | 77 SDK.targetManager.addEventListener(SDK.TargetManager.Events.NameChanged, thi
s._targetNameChanged, this); |
| 77 | 78 |
| 78 SDK.targetManager.observeTargets(this); | 79 SDK.targetManager.observeTargets(this); |
| 79 this._resetWorkspace(Workspace.workspace); | 80 this._resetWorkspace(Workspace.workspace); |
| 80 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)); | 81 this._workspace.uiSourceCodes().forEach(this.refreshUISourceCode.bind(this))
; |
| 81 } | 82 } |
| 82 | 83 |
| 83 /** | 84 /** |
| 84 * @param {!UI.TreeElement} treeElement | 85 * @param {!UI.TreeElement} treeElement |
| 85 */ | 86 */ |
| 86 static _treeElementOrder(treeElement) { | 87 static _treeElementOrder(treeElement) { |
| 87 if (treeElement._boostOrder) | 88 if (treeElement._boostOrder) |
| 88 return 0; | 89 return 0; |
| 89 | 90 |
| 90 if (!Sources.NavigatorView._typeOrders) { | 91 if (!Sources.NavigatorView._typeOrders) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 if (typeWeight1 < typeWeight2) | 162 if (typeWeight1 < typeWeight2) |
| 162 return -1; | 163 return -1; |
| 163 return treeElement1.titleAsText().compareTo(treeElement2.titleAsText()); | 164 return treeElement1.titleAsText().compareTo(treeElement2.titleAsText()); |
| 164 } | 165 } |
| 165 | 166 |
| 166 /** | 167 /** |
| 167 * @param {!Common.Event} event | 168 * @param {!Common.Event} event |
| 168 */ | 169 */ |
| 169 _onBindingCreated(event) { | 170 _onBindingCreated(event) { |
| 170 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data); | 171 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data); |
| 171 this._removeUISourceCode(binding.network); | 172 this.refreshUISourceCode(binding.network); |
| 172 } | 173 } |
| 173 | 174 |
| 174 /** | 175 /** |
| 175 * @param {!Common.Event} event | 176 * @param {!Common.Event} event |
| 176 */ | 177 */ |
| 177 _onBindingRemoved(event) { | 178 _onBindingRemoved(event) { |
| 178 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data); | 179 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data); |
| 179 this._addUISourceCode(binding.network); | 180 this.refreshUISourceCode(binding.network); |
| 180 } | 181 } |
| 181 | 182 |
| 182 /** | 183 /** |
| 183 * @param {!Common.Event} event | 184 * @param {!Common.Event} event |
| 184 */ | 185 */ |
| 185 _onBindingChanged(event) { | 186 _onBindingChanged(event) { |
| 186 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data); | 187 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data); |
| 187 | 188 |
| 188 // Update UISourceCode titles. | 189 // Update UISourceCode titles. |
| 189 var networkNodes = this._uiSourceCodeNodes.get(binding.network) || []; | 190 var networkNodes = this._uiSourceCodeNodes.get(binding.network) || []; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 var resourceTreeModel = target && SDK.ResourceTreeModel.fromTarget(target)
; | 257 var resourceTreeModel = target && SDK.ResourceTreeModel.fromTarget(target)
; |
| 257 frame = resourceTreeModel && resourceTreeModel.mainFrame; | 258 frame = resourceTreeModel && resourceTreeModel.mainFrame; |
| 258 } | 259 } |
| 259 return frame; | 260 return frame; |
| 260 } | 261 } |
| 261 | 262 |
| 262 /** | 263 /** |
| 263 * @param {!Workspace.UISourceCode} uiSourceCode | 264 * @param {!Workspace.UISourceCode} uiSourceCode |
| 264 */ | 265 */ |
| 265 _addUISourceCode(uiSourceCode) { | 266 _addUISourceCode(uiSourceCode) { |
| 266 if (!this.accept(uiSourceCode)) | 267 if (this._uiSourceCodeNodes.has(uiSourceCode)) |
| 267 return; | 268 return; |
| 268 | 269 |
| 269 var binding = Persistence.persistence.binding(uiSourceCode); | 270 var binding = Persistence.persistence.binding(uiSourceCode); |
| 270 if (!Runtime.experiments.isEnabled('persistence2') && binding && binding.net
work === uiSourceCode) | 271 if (!Runtime.experiments.isEnabled('persistence2') && binding && binding.net
work === uiSourceCode) |
| 271 return; | 272 return; |
| 272 | 273 |
| 273 var isFromSourceMap = uiSourceCode.contentType().isFromSourceMap(); | 274 var isFromSourceMap = uiSourceCode.contentType().isFromSourceMap(); |
| 274 var path; | 275 var path; |
| 275 if (uiSourceCode.project().type() === Workspace.projectTypes.FileSystem) | 276 if (uiSourceCode.project().type() === Workspace.projectTypes.FileSystem) |
| 276 path = Persistence.FileSystemWorkspaceBinding.relativePath(uiSourceCode).s
lice(0, -1); | 277 path = Persistence.FileSystemWorkspaceBinding.relativePath(uiSourceCode).s
lice(0, -1); |
| 277 else | 278 else |
| 278 path = Common.ParsedURL.extractPath(uiSourceCode.url()).split('/').slice(1
, -1); | 279 path = Common.ParsedURL.extractPath(uiSourceCode.url()).split('/').slice(1
, -1); |
| 279 | 280 |
| 280 var project = uiSourceCode.project(); | 281 var project = uiSourceCode.project(); |
| 281 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); | 282 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); |
| 282 var frame = this._uiSourceCodeFrame(uiSourceCode); | 283 var frame = this._uiSourceCodeFrame(uiSourceCode); |
| 283 | 284 |
| 284 var folderNode = | 285 var folderNode = |
| 285 this._folderNode(uiSourceCode, project, target, frame, uiSourceCode.orig
in(), path, isFromSourceMap); | 286 this._folderNode(uiSourceCode, project, target, frame, uiSourceCode.orig
in(), path, isFromSourceMap); |
| 286 var uiSourceCodeNode = new Sources.NavigatorUISourceCodeTreeNode(this, uiSou
rceCode); | 287 var uiSourceCodeNode = new Sources.NavigatorUISourceCodeTreeNode(this, uiSou
rceCode); |
| 287 this._uiSourceCodeNodes.set(uiSourceCode, [uiSourceCodeNode]); | 288 this._uiSourceCodeNodes.set(uiSourceCode, [uiSourceCodeNode]); |
| 288 folderNode.appendChild(uiSourceCodeNode); | 289 folderNode.appendChild(uiSourceCodeNode); |
| 289 this.uiSourceCodeAdded(uiSourceCode); | 290 this.uiSourceCodeAdded(uiSourceCode); |
| 290 } | 291 } |
| 291 | 292 |
| 292 /** | 293 /** |
| 293 * @param {!Workspace.UISourceCode} uiSourceCode | 294 * @param {!Workspace.UISourceCode} uiSourceCode |
| 294 */ | 295 */ |
| 296 refreshUISourceCode(uiSourceCode) { |
| 297 if (this.accept(uiSourceCode)) |
| 298 this._addUISourceCode(uiSourceCode); |
| 299 else |
| 300 this._removeUISourceCode(uiSourceCode); |
| 301 } |
| 302 |
| 303 /** |
| 304 * @param {!Workspace.UISourceCode} uiSourceCode |
| 305 */ |
| 295 uiSourceCodeAdded(uiSourceCode) { | 306 uiSourceCodeAdded(uiSourceCode) { |
| 296 } | 307 } |
| 297 | 308 |
| 298 /** | 309 /** |
| 310 * @param {!Workspace.UISourceCode} uiSourceCode |
| 311 */ |
| 312 uiSourceCodeRemoved(uiSourceCode) { |
| 313 } |
| 314 |
| 315 /** |
| 299 * @param {!Common.Event} event | 316 * @param {!Common.Event} event |
| 300 */ | 317 */ |
| 301 _uiSourceCodeAdded(event) { | 318 _uiSourceCodeAdded(event) { |
| 302 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data); | 319 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data); |
| 303 this._addUISourceCode(uiSourceCode); | 320 this.refreshUISourceCode(uiSourceCode); |
| 304 } | 321 } |
| 305 | 322 |
| 306 /** | 323 /** |
| 307 * @param {!Common.Event} event | 324 * @param {!Common.Event} event |
| 308 */ | 325 */ |
| 309 _uiSourceCodeRemoved(event) { | 326 _uiSourceCodeRemoved(event) { |
| 310 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data); | 327 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data); |
| 311 this._removeUISourceCode(uiSourceCode); | 328 this._removeUISourceCode(uiSourceCode); |
| 312 } | 329 } |
| 313 | 330 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 return null; | 522 return null; |
| 506 if (this._scriptsTree.selectedTreeElement) | 523 if (this._scriptsTree.selectedTreeElement) |
| 507 this._scriptsTree.selectedTreeElement.deselect(); | 524 this._scriptsTree.selectedTreeElement.deselect(); |
| 508 this._lastSelectedUISourceCode = uiSourceCode; | 525 this._lastSelectedUISourceCode = uiSourceCode; |
| 509 // TODO(dgozman): figure out revealing multiple. | 526 // TODO(dgozman): figure out revealing multiple. |
| 510 nodes[0].reveal(select); | 527 nodes[0].reveal(select); |
| 511 return nodes[0]; | 528 return nodes[0]; |
| 512 } | 529 } |
| 513 | 530 |
| 514 /** | 531 /** |
| 532 * @return {?Workspace.UISourceCode} |
| 533 */ |
| 534 anyUISourceCode() { |
| 535 if (this._uiSourceCodeNodes.has(this._lastSelectedUISourceCode)) |
| 536 return this._lastSelectedUISourceCode; |
| 537 return this._uiSourceCodeNodes.keys().next().value || null; |
| 538 } |
| 539 |
| 540 /** |
| 515 * @param {!Workspace.UISourceCode} uiSourceCode | 541 * @param {!Workspace.UISourceCode} uiSourceCode |
| 516 * @param {boolean} focusSource | 542 * @param {boolean} focusSource |
| 517 */ | 543 */ |
| 518 _sourceSelected(uiSourceCode, focusSource) { | 544 _sourceSelected(uiSourceCode, focusSource) { |
| 519 this._lastSelectedUISourceCode = uiSourceCode; | 545 this._lastSelectedUISourceCode = uiSourceCode; |
| 546 this.revealSource(uiSourceCode, focusSource); |
| 547 } |
| 548 |
| 549 /** |
| 550 * @param {!Workspace.UISourceCode} uiSourceCode |
| 551 * @param {boolean} focusSource |
| 552 */ |
| 553 revealSource(uiSourceCode, focusSource) { |
| 520 Common.Revealer.reveal(uiSourceCode, !focusSource); | 554 Common.Revealer.reveal(uiSourceCode, !focusSource); |
| 521 } | 555 } |
| 522 | 556 |
| 523 /** | 557 /** |
| 524 * @param {!Workspace.UISourceCode} uiSourceCode | 558 * @param {!Workspace.UISourceCode} uiSourceCode |
| 525 */ | 559 */ |
| 526 sourceDeleted(uiSourceCode) { | 560 sourceDeleted(uiSourceCode) { |
| 527 } | 561 } |
| 528 | 562 |
| 529 /** | 563 /** |
| (...skipping 21 matching lines...) Expand all Loading... |
| 551 if (node._type === Sources.NavigatorView.Types.Frame) | 585 if (node._type === Sources.NavigatorView.Types.Frame) |
| 552 break; | 586 break; |
| 553 | 587 |
| 554 var folderId = this._folderNodeId(project, target, frame, uiSourceCode.o
rigin(), node._folderPath); | 588 var folderId = this._folderNodeId(project, target, frame, uiSourceCode.o
rigin(), node._folderPath); |
| 555 this._subfolderNodes.delete(folderId); | 589 this._subfolderNodes.delete(folderId); |
| 556 parentNode.removeChild(node); | 590 parentNode.removeChild(node); |
| 557 node = parentNode; | 591 node = parentNode; |
| 558 } | 592 } |
| 559 } | 593 } |
| 560 this._uiSourceCodeNodes.delete(uiSourceCode); | 594 this._uiSourceCodeNodes.delete(uiSourceCode); |
| 595 this.uiSourceCodeRemoved(uiSourceCode); |
| 561 } | 596 } |
| 562 | 597 |
| 563 reset() { | 598 reset() { |
| 564 for (var entry of this._uiSourceCodeNodes) { | 599 for (var entry of this._uiSourceCodeNodes) { |
| 565 var nodes = /** @type {!Array<!Sources.NavigatorUISourceCodeTreeNode>} */
(entry[1]); | 600 var nodes = /** @type {!Array<!Sources.NavigatorUISourceCodeTreeNode>} */
(entry[1]); |
| 566 for (var i = 0; i < nodes.length; i++) | 601 for (var i = 0; i < nodes.length; i++) |
| 567 nodes[i].dispose(); | 602 nodes[i].dispose(); |
| 568 } | 603 } |
| 569 | 604 |
| 570 this._scriptsTree.removeChildren(); | 605 this._scriptsTree.removeChildren(); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 function fileCreated(uiSourceCode) { | 768 function fileCreated(uiSourceCode) { |
| 734 if (!uiSourceCode) | 769 if (!uiSourceCode) |
| 735 return; | 770 return; |
| 736 this._sourceSelected(uiSourceCode, false); | 771 this._sourceSelected(uiSourceCode, false); |
| 737 var node = this.revealUISourceCode(uiSourceCode, true); | 772 var node = this.revealUISourceCode(uiSourceCode, true); |
| 738 if (node) | 773 if (node) |
| 739 this.rename(node, true); | 774 this.rename(node, true); |
| 740 } | 775 } |
| 741 } | 776 } |
| 742 | 777 |
| 778 dontGroup() { |
| 779 this._dontGroup = true; |
| 780 this._groupingChanged(); |
| 781 } |
| 782 |
| 743 _groupingChanged() { | 783 _groupingChanged() { |
| 744 this.reset(); | 784 this.reset(); |
| 745 this._initGrouping(); | 785 this._initGrouping(); |
| 746 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)); | 786 this._workspace.uiSourceCodes().forEach(this.refreshUISourceCode.bind(this))
; |
| 747 } | 787 } |
| 748 | 788 |
| 749 _initGrouping() { | 789 _initGrouping() { |
| 790 if (this._dontGroup) { |
| 791 this._groupByFrame = false; |
| 792 this._groupByDomain = false; |
| 793 this._groupByFolder = false; |
| 794 return; |
| 795 } |
| 750 this._groupByFrame = true; | 796 this._groupByFrame = true; |
| 751 this._groupByDomain = this._navigatorGroupByFolderSetting.get(); | 797 this._groupByDomain = this._navigatorGroupByFolderSetting.get(); |
| 752 this._groupByFolder = this._groupByDomain; | 798 this._groupByFolder = this._groupByDomain; |
| 753 } | 799 } |
| 754 | 800 |
| 755 _resetForTest() { | 801 _resetForTest() { |
| 756 this.reset(); | 802 this.reset(); |
| 757 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)); | 803 this._workspace.uiSourceCodes().forEach(this.refreshUISourceCode.bind(this))
; |
| 758 } | 804 } |
| 759 | 805 |
| 760 /** | 806 /** |
| 761 * @param {!Common.Event} event | 807 * @param {!Common.Event} event |
| 762 */ | 808 */ |
| 763 _frameNavigated(event) { | 809 _frameNavigated(event) { |
| 764 var frame = /** @type {!SDK.ResourceTreeFrame} */ (event.data); | 810 var frame = /** @type {!SDK.ResourceTreeFrame} */ (event.data); |
| 765 var node = this._frameNodes.get(frame); | 811 var node = this._frameNodes.get(frame); |
| 766 if (!node) | 812 if (!node) |
| 767 return; | 813 return; |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1612 /** | 1658 /** |
| 1613 * @param {string} title | 1659 * @param {string} title |
| 1614 * @override | 1660 * @override |
| 1615 */ | 1661 */ |
| 1616 setTitle(title) { | 1662 setTitle(title) { |
| 1617 this._title = title; | 1663 this._title = title; |
| 1618 if (this._treeElement) | 1664 if (this._treeElement) |
| 1619 this._treeElement.title = this._title; | 1665 this._treeElement.title = this._title; |
| 1620 } | 1666 } |
| 1621 }; | 1667 }; |
| OLD | NEW |