| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 /** | 236 /** |
| 237 * @param {!Workspace.UISourceCode} uiSourceCode | 237 * @param {!Workspace.UISourceCode} uiSourceCode |
| 238 * @return {boolean} | 238 * @return {boolean} |
| 239 */ | 239 */ |
| 240 accept(uiSourceCode) { | 240 accept(uiSourceCode) { |
| 241 return !uiSourceCode.project().isServiceProject(); | 241 return !uiSourceCode.project().isServiceProject(); |
| 242 } | 242 } |
| 243 | 243 |
| 244 /** | 244 /** |
| 245 * @param {!Workspace.UISourceCode} uiSourceCode | 245 * @param {!Workspace.UISourceCode} uiSourceCode |
| 246 * @return {?SDK.ResourceTreeFrame} | |
| 247 */ | |
| 248 _uiSourceCodeFrame(uiSourceCode) { | |
| 249 var frame = Bindings.NetworkProject.frameForProject(uiSourceCode.project()); | |
| 250 if (!frame) { | |
| 251 var target = Bindings.NetworkProject.targetForProject(uiSourceCode.project
()); | |
| 252 var resourceTreeModel = target && target.model(SDK.ResourceTreeModel); | |
| 253 frame = resourceTreeModel && resourceTreeModel.mainFrame; | |
| 254 } | |
| 255 return frame; | |
| 256 } | |
| 257 | |
| 258 /** | |
| 259 * @param {!Workspace.UISourceCode} uiSourceCode | |
| 260 */ | 246 */ |
| 261 _addUISourceCode(uiSourceCode) { | 247 _addUISourceCode(uiSourceCode) { |
| 262 if (!this.accept(uiSourceCode)) | 248 if (!this.accept(uiSourceCode)) |
| 263 return; | 249 return; |
| 264 | 250 |
| 265 var binding = Persistence.persistence.binding(uiSourceCode); | 251 var binding = Persistence.persistence.binding(uiSourceCode); |
| 266 if (!Runtime.experiments.isEnabled('persistence2') && binding && binding.net
work === uiSourceCode) | 252 if (!Runtime.experiments.isEnabled('persistence2') && binding && binding.net
work === uiSourceCode) |
| 267 return; | 253 return; |
| 268 | 254 |
| 269 var isFromSourceMap = uiSourceCode.contentType().isFromSourceMap(); | 255 var isFromSourceMap = uiSourceCode.contentType().isFromSourceMap(); |
| 270 var path; | 256 var path; |
| 271 if (uiSourceCode.project().type() === Workspace.projectTypes.FileSystem) | 257 if (uiSourceCode.project().type() === Workspace.projectTypes.FileSystem) |
| 272 path = Persistence.FileSystemWorkspaceBinding.relativePath(uiSourceCode).s
lice(0, -1); | 258 path = Persistence.FileSystemWorkspaceBinding.relativePath(uiSourceCode).s
lice(0, -1); |
| 273 else | 259 else |
| 274 path = Common.ParsedURL.extractPath(uiSourceCode.url()).split('/').slice(1
, -1); | 260 path = Common.ParsedURL.extractPath(uiSourceCode.url()).split('/').slice(1
, -1); |
| 275 | 261 |
| 276 var project = uiSourceCode.project(); | 262 var project = uiSourceCode.project(); |
| 277 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); | 263 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); |
| 278 var frame = this._uiSourceCodeFrame(uiSourceCode); | 264 var frames = Bindings.NetworkProject.framesForUISourceCode(uiSourceCode); |
| 279 | 265 var uiSourceCodeNodes = []; |
| 280 var folderNode = | 266 if (frames.length) { |
| 281 this._folderNode(uiSourceCode, project, target, frame, uiSourceCode.orig
in(), path, isFromSourceMap); | 267 for (var frame of frames) { |
| 282 var uiSourceCodeNode = new Sources.NavigatorUISourceCodeTreeNode(this, uiSou
rceCode); | 268 var folderNode = |
| 283 this._uiSourceCodeNodes.set(uiSourceCode, [uiSourceCodeNode]); | 269 this._folderNode(uiSourceCode, project, target, frame, uiSourceCode.
origin(), path, isFromSourceMap); |
| 284 folderNode.appendChild(uiSourceCodeNode); | 270 var uiSourceCodeNode = new Sources.NavigatorUISourceCodeTreeNode(this, u
iSourceCode, frame); |
| 271 folderNode.appendChild(uiSourceCodeNode); |
| 272 uiSourceCodeNodes.push(uiSourceCodeNode); |
| 273 } |
| 274 } else { |
| 275 var folderNode = |
| 276 this._folderNode(uiSourceCode, project, target, null, uiSourceCode.ori
gin(), path, isFromSourceMap); |
| 277 var uiSourceCodeNode = new Sources.NavigatorUISourceCodeTreeNode(this, uiS
ourceCode, null); |
| 278 folderNode.appendChild(uiSourceCodeNode); |
| 279 uiSourceCodeNodes.push(uiSourceCodeNode); |
| 280 } |
| 281 this._uiSourceCodeNodes.set(uiSourceCode, uiSourceCodeNodes); |
| 285 this.uiSourceCodeAdded(uiSourceCode); | 282 this.uiSourceCodeAdded(uiSourceCode); |
| 286 } | 283 } |
| 287 | 284 |
| 288 /** | 285 /** |
| 289 * @param {!Workspace.UISourceCode} uiSourceCode | 286 * @param {!Workspace.UISourceCode} uiSourceCode |
| 290 */ | 287 */ |
| 291 uiSourceCodeAdded(uiSourceCode) { | 288 uiSourceCodeAdded(uiSourceCode) { |
| 292 } | 289 } |
| 293 | 290 |
| 294 /** | 291 /** |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 /** | 520 /** |
| 524 * @param {!Workspace.UISourceCode} uiSourceCode | 521 * @param {!Workspace.UISourceCode} uiSourceCode |
| 525 */ | 522 */ |
| 526 _removeUISourceCode(uiSourceCode) { | 523 _removeUISourceCode(uiSourceCode) { |
| 527 var nodes = this._uiSourceCodeNodes.get(uiSourceCode) || []; | 524 var nodes = this._uiSourceCodeNodes.get(uiSourceCode) || []; |
| 528 for (var i = 0; i < nodes.length; i++) { | 525 for (var i = 0; i < nodes.length; i++) { |
| 529 var node = nodes[i]; | 526 var node = nodes[i]; |
| 530 | 527 |
| 531 var project = uiSourceCode.project(); | 528 var project = uiSourceCode.project(); |
| 532 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); | 529 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); |
| 533 var frame = this._uiSourceCodeFrame(uiSourceCode); | 530 var frame = node.frame(); |
| 534 | 531 |
| 535 var parentNode = node.parent; | 532 var parentNode = node.parent; |
| 536 parentNode.removeChild(node); | 533 parentNode.removeChild(node); |
| 537 node = parentNode; | 534 node = parentNode; |
| 538 | 535 |
| 539 while (node) { | 536 while (node) { |
| 540 parentNode = node.parent; | 537 parentNode = node.parent; |
| 541 if (!parentNode || !node.isEmpty()) | 538 if (!parentNode || !node.isEmpty()) |
| 542 break; | 539 break; |
| 543 if (!(node instanceof Sources.NavigatorGroupTreeNode || node instanceof
Sources.NavigatorFolderTreeNode)) | 540 if (!(node instanceof Sources.NavigatorGroupTreeNode || node instanceof
Sources.NavigatorFolderTreeNode)) |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 } | 1204 } |
| 1208 }; | 1205 }; |
| 1209 | 1206 |
| 1210 /** | 1207 /** |
| 1211 * @unrestricted | 1208 * @unrestricted |
| 1212 */ | 1209 */ |
| 1213 Sources.NavigatorUISourceCodeTreeNode = class extends Sources.NavigatorTreeNode
{ | 1210 Sources.NavigatorUISourceCodeTreeNode = class extends Sources.NavigatorTreeNode
{ |
| 1214 /** | 1211 /** |
| 1215 * @param {!Sources.NavigatorView} navigatorView | 1212 * @param {!Sources.NavigatorView} navigatorView |
| 1216 * @param {!Workspace.UISourceCode} uiSourceCode | 1213 * @param {!Workspace.UISourceCode} uiSourceCode |
| 1214 * @param {?SDK.ResourceTreeFrame} frame |
| 1217 */ | 1215 */ |
| 1218 constructor(navigatorView, uiSourceCode) { | 1216 constructor(navigatorView, uiSourceCode, frame) { |
| 1219 super(uiSourceCode.project().id() + ':' + uiSourceCode.url(), Sources.Naviga
torView.Types.File); | 1217 super(uiSourceCode.project().id() + ':' + uiSourceCode.url(), Sources.Naviga
torView.Types.File); |
| 1220 this._navigatorView = navigatorView; | 1218 this._navigatorView = navigatorView; |
| 1221 this._uiSourceCode = uiSourceCode; | 1219 this._uiSourceCode = uiSourceCode; |
| 1222 this._treeElement = null; | 1220 this._treeElement = null; |
| 1223 this._eventListeners = []; | 1221 this._eventListeners = []; |
| 1222 this._frame = frame; |
| 1224 } | 1223 } |
| 1225 | 1224 |
| 1226 /** | 1225 /** |
| 1226 * @return {?SDK.ResourceTreeFrame} |
| 1227 */ |
| 1228 frame() { |
| 1229 return this._frame; |
| 1230 } |
| 1231 |
| 1232 /** |
| 1227 * @return {!Workspace.UISourceCode} | 1233 * @return {!Workspace.UISourceCode} |
| 1228 */ | 1234 */ |
| 1229 uiSourceCode() { | 1235 uiSourceCode() { |
| 1230 return this._uiSourceCode; | 1236 return this._uiSourceCode; |
| 1231 } | 1237 } |
| 1232 | 1238 |
| 1233 /** | 1239 /** |
| 1234 * @override | 1240 * @override |
| 1235 * @return {!UI.TreeElement} | 1241 * @return {!UI.TreeElement} |
| 1236 */ | 1242 */ |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1586 /** | 1592 /** |
| 1587 * @param {string} title | 1593 * @param {string} title |
| 1588 * @override | 1594 * @override |
| 1589 */ | 1595 */ |
| 1590 setTitle(title) { | 1596 setTitle(title) { |
| 1591 this._title = title; | 1597 this._title = title; |
| 1592 if (this._treeElement) | 1598 if (this._treeElement) |
| 1593 this._treeElement.title = this._title; | 1599 this._treeElement.title = this._title; |
| 1594 } | 1600 } |
| 1595 }; | 1601 }; |
| OLD | NEW |