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 16 matching lines...) Expand all Loading... |
27 */ | 27 */ |
28 /** | 28 /** |
29 * @implements {SDK.TargetManager.Observer} | 29 * @implements {SDK.TargetManager.Observer} |
30 * @unrestricted | 30 * @unrestricted |
31 */ | 31 */ |
32 Sources.NavigatorView = class extends UI.VBox { | 32 Sources.NavigatorView = class extends UI.VBox { |
33 constructor() { | 33 constructor() { |
34 super(); | 34 super(); |
35 this.registerRequiredCSS('sources/navigatorView.css'); | 35 this.registerRequiredCSS('sources/navigatorView.css'); |
36 | 36 |
37 this._scriptsTree = new TreeOutlineInShadow(); | 37 this._scriptsTree = new UI.TreeOutlineInShadow(); |
38 this._scriptsTree.registerRequiredCSS('sources/navigatorTree.css'); | 38 this._scriptsTree.registerRequiredCSS('sources/navigatorTree.css'); |
39 this._scriptsTree.setComparator(Sources.NavigatorView._treeElementsCompare); | 39 this._scriptsTree.setComparator(Sources.NavigatorView._treeElementsCompare); |
40 this.element.appendChild(this._scriptsTree.element); | 40 this.element.appendChild(this._scriptsTree.element); |
41 this.setDefaultFocusedElement(this._scriptsTree.element); | 41 this.setDefaultFocusedElement(this._scriptsTree.element); |
42 | 42 |
43 /** @type {!Map.<!Workspace.UISourceCode, !Array<!Sources.NavigatorUISourceC
odeTreeNode>>} */ | 43 /** @type {!Map.<!Workspace.UISourceCode, !Array<!Sources.NavigatorUISourceC
odeTreeNode>>} */ |
44 this._uiSourceCodeNodes = new Map(); | 44 this._uiSourceCodeNodes = new Map(); |
45 /** @type {!Map.<string, !Sources.NavigatorFolderTreeNode>} */ | 45 /** @type {!Map.<string, !Sources.NavigatorFolderTreeNode>} */ |
46 this._subfolderNodes = new Map(); | 46 this._subfolderNodes = new Map(); |
47 | 47 |
(...skipping 26 matching lines...) Expand all Loading... |
74 Persistence.Persistence.Events.BindingRemoved, this._onBindingRemoved,
this); | 74 Persistence.Persistence.Events.BindingRemoved, this._onBindingRemoved,
this); |
75 } | 75 } |
76 SDK.targetManager.addEventListener(SDK.TargetManager.Events.NameChanged, thi
s._targetNameChanged, this); | 76 SDK.targetManager.addEventListener(SDK.TargetManager.Events.NameChanged, thi
s._targetNameChanged, this); |
77 | 77 |
78 SDK.targetManager.observeTargets(this); | 78 SDK.targetManager.observeTargets(this); |
79 this._resetWorkspace(Workspace.workspace); | 79 this._resetWorkspace(Workspace.workspace); |
80 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)); | 80 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)); |
81 } | 81 } |
82 | 82 |
83 /** | 83 /** |
84 * @param {!TreeElement} treeElement | 84 * @param {!UI.TreeElement} treeElement |
85 */ | 85 */ |
86 static _treeElementOrder(treeElement) { | 86 static _treeElementOrder(treeElement) { |
87 if (treeElement._boostOrder) | 87 if (treeElement._boostOrder) |
88 return 0; | 88 return 0; |
89 | 89 |
90 if (!Sources.NavigatorView._typeOrders) { | 90 if (!Sources.NavigatorView._typeOrders) { |
91 var weights = {}; | 91 var weights = {}; |
92 var types = Sources.NavigatorView.Types; | 92 var types = Sources.NavigatorView.Types; |
93 weights[types.Root] = 1; | 93 weights[types.Root] = 1; |
94 weights[types.Domain] = 10; | 94 weights[types.Domain] = 10; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 141 |
142 var searchLabel = Common.UIString('Search in folder'); | 142 var searchLabel = Common.UIString('Search in folder'); |
143 if (!path || !path.trim()) { | 143 if (!path || !path.trim()) { |
144 path = '*'; | 144 path = '*'; |
145 searchLabel = Common.UIString('Search in all files'); | 145 searchLabel = Common.UIString('Search in all files'); |
146 } | 146 } |
147 contextMenu.appendItem(searchLabel, searchPath); | 147 contextMenu.appendItem(searchLabel, searchPath); |
148 } | 148 } |
149 | 149 |
150 /** | 150 /** |
151 * @param {!TreeElement} treeElement1 | 151 * @param {!UI.TreeElement} treeElement1 |
152 * @param {!TreeElement} treeElement2 | 152 * @param {!UI.TreeElement} treeElement2 |
153 * @return {number} | 153 * @return {number} |
154 */ | 154 */ |
155 static _treeElementsCompare(treeElement1, treeElement2) { | 155 static _treeElementsCompare(treeElement1, treeElement2) { |
156 var typeWeight1 = Sources.NavigatorView._treeElementOrder(treeElement1); | 156 var typeWeight1 = Sources.NavigatorView._treeElementOrder(treeElement1); |
157 var typeWeight2 = Sources.NavigatorView._treeElementOrder(treeElement2); | 157 var typeWeight2 = Sources.NavigatorView._treeElementOrder(treeElement2); |
158 | 158 |
159 if (typeWeight1 > typeWeight2) | 159 if (typeWeight1 > typeWeight2) |
160 return 1; | 160 return 1; |
161 if (typeWeight1 < typeWeight2) | 161 if (typeWeight1 < typeWeight2) |
162 return -1; | 162 return -1; |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 Frame: 'frame', | 828 Frame: 'frame', |
829 NetworkFolder: 'nw-folder', | 829 NetworkFolder: 'nw-folder', |
830 Root: 'root', | 830 Root: 'root', |
831 SourceMapFolder: 'sm-folder', | 831 SourceMapFolder: 'sm-folder', |
832 Worker: 'worker' | 832 Worker: 'worker' |
833 }; | 833 }; |
834 | 834 |
835 /** | 835 /** |
836 * @unrestricted | 836 * @unrestricted |
837 */ | 837 */ |
838 Sources.NavigatorFolderTreeElement = class extends TreeElement { | 838 Sources.NavigatorFolderTreeElement = class extends UI.TreeElement { |
839 /** | 839 /** |
840 * @param {!Sources.NavigatorView} navigatorView | 840 * @param {!Sources.NavigatorView} navigatorView |
841 * @param {string} type | 841 * @param {string} type |
842 * @param {string} title | 842 * @param {string} title |
843 * @param {function(boolean)=} hoverCallback | 843 * @param {function(boolean)=} hoverCallback |
844 */ | 844 */ |
845 constructor(navigatorView, type, title, hoverCallback) { | 845 constructor(navigatorView, type, title, hoverCallback) { |
846 super('', true); | 846 super('', true); |
847 this.listItemElement.classList.add('navigator-' + type + '-tree-item', 'navi
gator-folder-tree-item'); | 847 this.listItemElement.classList.add('navigator-' + type + '-tree-item', 'navi
gator-folder-tree-item'); |
848 this._nodeType = type; | 848 this._nodeType = type; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 if (!this._hoverCallback) | 919 if (!this._hoverCallback) |
920 return; | 920 return; |
921 this._hovered = false; | 921 this._hovered = false; |
922 this._hoverCallback(false); | 922 this._hoverCallback(false); |
923 } | 923 } |
924 }; | 924 }; |
925 | 925 |
926 /** | 926 /** |
927 * @unrestricted | 927 * @unrestricted |
928 */ | 928 */ |
929 Sources.NavigatorSourceTreeElement = class extends TreeElement { | 929 Sources.NavigatorSourceTreeElement = class extends UI.TreeElement { |
930 /** | 930 /** |
931 * @param {!Sources.NavigatorView} navigatorView | 931 * @param {!Sources.NavigatorView} navigatorView |
932 * @param {!Workspace.UISourceCode} uiSourceCode | 932 * @param {!Workspace.UISourceCode} uiSourceCode |
933 * @param {string} title | 933 * @param {string} title |
934 * @param {!Sources.NavigatorUISourceCodeTreeNode} node | 934 * @param {!Sources.NavigatorUISourceCodeTreeNode} node |
935 */ | 935 */ |
936 constructor(navigatorView, uiSourceCode, title, node) { | 936 constructor(navigatorView, uiSourceCode, title, node) { |
937 super('', false); | 937 super('', false); |
938 this._nodeType = Sources.NavigatorView.Types.File; | 938 this._nodeType = Sources.NavigatorView.Types.File; |
939 this._node = node; | 939 this._node = node; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 * @param {string} type | 1078 * @param {string} type |
1079 */ | 1079 */ |
1080 constructor(id, type) { | 1080 constructor(id, type) { |
1081 this.id = id; | 1081 this.id = id; |
1082 this._type = type; | 1082 this._type = type; |
1083 /** @type {!Map.<string, !Sources.NavigatorTreeNode>} */ | 1083 /** @type {!Map.<string, !Sources.NavigatorTreeNode>} */ |
1084 this._children = new Map(); | 1084 this._children = new Map(); |
1085 } | 1085 } |
1086 | 1086 |
1087 /** | 1087 /** |
1088 * @return {!TreeElement} | 1088 * @return {!UI.TreeElement} |
1089 */ | 1089 */ |
1090 treeNode() { | 1090 treeNode() { |
1091 throw 'Not implemented'; | 1091 throw 'Not implemented'; |
1092 } | 1092 } |
1093 | 1093 |
1094 dispose() { | 1094 dispose() { |
1095 } | 1095 } |
1096 | 1096 |
1097 /** | 1097 /** |
1098 * @return {boolean} | 1098 * @return {boolean} |
(...skipping 24 matching lines...) Expand all Loading... |
1123 return; | 1123 return; |
1124 if (this.parent) | 1124 if (this.parent) |
1125 this.parent.populate(); | 1125 this.parent.populate(); |
1126 this._populated = true; | 1126 this._populated = true; |
1127 this.wasPopulated(); | 1127 this.wasPopulated(); |
1128 } | 1128 } |
1129 | 1129 |
1130 wasPopulated() { | 1130 wasPopulated() { |
1131 var children = this.children(); | 1131 var children = this.children(); |
1132 for (var i = 0; i < children.length; ++i) | 1132 for (var i = 0; i < children.length; ++i) |
1133 this.treeNode().appendChild(/** @type {!TreeElement} */ (children[i].treeN
ode())); | 1133 this.treeNode().appendChild(/** @type {!UI.TreeElement} */ (children[i].tr
eeNode())); |
1134 } | 1134 } |
1135 | 1135 |
1136 /** | 1136 /** |
1137 * @param {!Sources.NavigatorTreeNode} node | 1137 * @param {!Sources.NavigatorTreeNode} node |
1138 */ | 1138 */ |
1139 didAddChild(node) { | 1139 didAddChild(node) { |
1140 if (this.isPopulated()) | 1140 if (this.isPopulated()) |
1141 this.treeNode().appendChild(/** @type {!TreeElement} */ (node.treeNode()))
; | 1141 this.treeNode().appendChild(/** @type {!UI.TreeElement} */ (node.treeNode(
))); |
1142 } | 1142 } |
1143 | 1143 |
1144 /** | 1144 /** |
1145 * @param {!Sources.NavigatorTreeNode} node | 1145 * @param {!Sources.NavigatorTreeNode} node |
1146 */ | 1146 */ |
1147 willRemoveChild(node) { | 1147 willRemoveChild(node) { |
1148 if (this.isPopulated()) | 1148 if (this.isPopulated()) |
1149 this.treeNode().removeChild(/** @type {!TreeElement} */ (node.treeNode()))
; | 1149 this.treeNode().removeChild(/** @type {!UI.TreeElement} */ (node.treeNode(
))); |
1150 } | 1150 } |
1151 | 1151 |
1152 /** | 1152 /** |
1153 * @return {boolean} | 1153 * @return {boolean} |
1154 */ | 1154 */ |
1155 isPopulated() { | 1155 isPopulated() { |
1156 return this._populated; | 1156 return this._populated; |
1157 } | 1157 } |
1158 | 1158 |
1159 /** | 1159 /** |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 /** | 1217 /** |
1218 * @override | 1218 * @override |
1219 * @return {boolean} | 1219 * @return {boolean} |
1220 */ | 1220 */ |
1221 isRoot() { | 1221 isRoot() { |
1222 return true; | 1222 return true; |
1223 } | 1223 } |
1224 | 1224 |
1225 /** | 1225 /** |
1226 * @override | 1226 * @override |
1227 * @return {!TreeElement} | 1227 * @return {!UI.TreeElement} |
1228 */ | 1228 */ |
1229 treeNode() { | 1229 treeNode() { |
1230 return this._navigatorView._scriptsTree.rootElement(); | 1230 return this._navigatorView._scriptsTree.rootElement(); |
1231 } | 1231 } |
1232 }; | 1232 }; |
1233 | 1233 |
1234 /** | 1234 /** |
1235 * @unrestricted | 1235 * @unrestricted |
1236 */ | 1236 */ |
1237 Sources.NavigatorUISourceCodeTreeNode = class extends Sources.NavigatorTreeNode
{ | 1237 Sources.NavigatorUISourceCodeTreeNode = class extends Sources.NavigatorTreeNode
{ |
(...skipping 11 matching lines...) Expand all Loading... |
1249 | 1249 |
1250 /** | 1250 /** |
1251 * @return {!Workspace.UISourceCode} | 1251 * @return {!Workspace.UISourceCode} |
1252 */ | 1252 */ |
1253 uiSourceCode() { | 1253 uiSourceCode() { |
1254 return this._uiSourceCode; | 1254 return this._uiSourceCode; |
1255 } | 1255 } |
1256 | 1256 |
1257 /** | 1257 /** |
1258 * @override | 1258 * @override |
1259 * @return {!TreeElement} | 1259 * @return {!UI.TreeElement} |
1260 */ | 1260 */ |
1261 treeNode() { | 1261 treeNode() { |
1262 if (this._treeElement) | 1262 if (this._treeElement) |
1263 return this._treeElement; | 1263 return this._treeElement; |
1264 | 1264 |
1265 this._treeElement = new Sources.NavigatorSourceTreeElement(this._navigatorVi
ew, this._uiSourceCode, '', this); | 1265 this._treeElement = new Sources.NavigatorSourceTreeElement(this._navigatorVi
ew, this._uiSourceCode, '', this); |
1266 this.updateTitle(); | 1266 this.updateTitle(); |
1267 | 1267 |
1268 var updateTitleBound = this.updateTitle.bind(this, undefined); | 1268 var updateTitleBound = this.updateTitle.bind(this, undefined); |
1269 this._eventListeners = [ | 1269 this._eventListeners = [ |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1394 constructor(navigatorView, project, id, type, folderPath, title) { | 1394 constructor(navigatorView, project, id, type, folderPath, title) { |
1395 super(id, type); | 1395 super(id, type); |
1396 this._navigatorView = navigatorView; | 1396 this._navigatorView = navigatorView; |
1397 this._project = project; | 1397 this._project = project; |
1398 this._folderPath = folderPath; | 1398 this._folderPath = folderPath; |
1399 this._title = title; | 1399 this._title = title; |
1400 } | 1400 } |
1401 | 1401 |
1402 /** | 1402 /** |
1403 * @override | 1403 * @override |
1404 * @return {!TreeElement} | 1404 * @return {!UI.TreeElement} |
1405 */ | 1405 */ |
1406 treeNode() { | 1406 treeNode() { |
1407 if (this._treeElement) | 1407 if (this._treeElement) |
1408 return this._treeElement; | 1408 return this._treeElement; |
1409 this._treeElement = this._createTreeElement(this._title, this); | 1409 this._treeElement = this._createTreeElement(this._title, this); |
1410 this.updateTitle(); | 1410 this.updateTitle(); |
1411 return this._treeElement; | 1411 return this._treeElement; |
1412 } | 1412 } |
1413 | 1413 |
1414 updateTitle() { | 1414 updateTitle() { |
1415 if (!this._treeElement || this._project.type() !== Workspace.projectTypes.Fi
leSystem) | 1415 if (!this._treeElement || this._project.type() !== Workspace.projectTypes.Fi
leSystem) |
1416 return; | 1416 return; |
1417 var absoluteFileSystemPath = | 1417 var absoluteFileSystemPath = |
1418 Persistence.FileSystemWorkspaceBinding.fileSystemPath(this._project.id()
) + '/' + this._folderPath; | 1418 Persistence.FileSystemWorkspaceBinding.fileSystemPath(this._project.id()
) + '/' + this._folderPath; |
1419 var hasMappedFiles = Runtime.experiments.isEnabled('persistence2') ? | 1419 var hasMappedFiles = Runtime.experiments.isEnabled('persistence2') ? |
1420 Persistence.persistence.filePathHasBindings(absoluteFileSystemPath) : | 1420 Persistence.persistence.filePathHasBindings(absoluteFileSystemPath) : |
1421 true; | 1421 true; |
1422 this._treeElement.listItemElement.classList.toggle('has-mapped-files', hasMa
ppedFiles); | 1422 this._treeElement.listItemElement.classList.toggle('has-mapped-files', hasMa
ppedFiles); |
1423 } | 1423 } |
1424 | 1424 |
1425 /** | 1425 /** |
1426 * @return {!TreeElement} | 1426 * @return {!UI.TreeElement} |
1427 */ | 1427 */ |
1428 _createTreeElement(title, node) { | 1428 _createTreeElement(title, node) { |
1429 if (this._project.type() !== Workspace.projectTypes.FileSystem) { | 1429 if (this._project.type() !== Workspace.projectTypes.FileSystem) { |
1430 try { | 1430 try { |
1431 title = decodeURI(title); | 1431 title = decodeURI(title); |
1432 } catch (e) { | 1432 } catch (e) { |
1433 } | 1433 } |
1434 } | 1434 } |
1435 var treeElement = new Sources.NavigatorFolderTreeElement(this._navigatorView
, this._type, title); | 1435 var treeElement = new Sources.NavigatorFolderTreeElement(this._navigatorView
, this._type, title); |
1436 treeElement.setNode(node); | 1436 treeElement.setNode(node); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1563 | 1563 |
1564 /** | 1564 /** |
1565 * @param {function(boolean)} hoverCallback | 1565 * @param {function(boolean)} hoverCallback |
1566 */ | 1566 */ |
1567 setHoverCallback(hoverCallback) { | 1567 setHoverCallback(hoverCallback) { |
1568 this._hoverCallback = hoverCallback; | 1568 this._hoverCallback = hoverCallback; |
1569 } | 1569 } |
1570 | 1570 |
1571 /** | 1571 /** |
1572 * @override | 1572 * @override |
1573 * @return {!TreeElement} | 1573 * @return {!UI.TreeElement} |
1574 */ | 1574 */ |
1575 treeNode() { | 1575 treeNode() { |
1576 if (this._treeElement) | 1576 if (this._treeElement) |
1577 return this._treeElement; | 1577 return this._treeElement; |
1578 this._treeElement = | 1578 this._treeElement = |
1579 new Sources.NavigatorFolderTreeElement(this._navigatorView, this._type,
this._title, this._hoverCallback); | 1579 new Sources.NavigatorFolderTreeElement(this._navigatorView, this._type,
this._title, this._hoverCallback); |
1580 this._treeElement.setNode(this); | 1580 this._treeElement.setNode(this); |
1581 return this._treeElement; | 1581 return this._treeElement; |
1582 } | 1582 } |
1583 | 1583 |
(...skipping 26 matching lines...) Expand all Loading... |
1610 /** | 1610 /** |
1611 * @param {string} title | 1611 * @param {string} title |
1612 * @override | 1612 * @override |
1613 */ | 1613 */ |
1614 setTitle(title) { | 1614 setTitle(title) { |
1615 this._title = title; | 1615 this._title = title; |
1616 if (this._treeElement) | 1616 if (this._treeElement) |
1617 this._treeElement.title = this._title; | 1617 this._treeElement.title = this._title; |
1618 } | 1618 } |
1619 }; | 1619 }; |
OLD | NEW |