| 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 22 matching lines...) Expand all Loading... |
| 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 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, !Sources.NavigatorUISourceCodeTree
Node>} */ | 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 |
| 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 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 this._addUISourceCode(binding.network); | 181 this._addUISourceCode(binding.network); |
| 182 } | 182 } |
| 183 | 183 |
| 184 /** | 184 /** |
| 185 * @param {!Common.Event} event | 185 * @param {!Common.Event} event |
| 186 */ | 186 */ |
| 187 _onBindingChanged(event) { | 187 _onBindingChanged(event) { |
| 188 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data); | 188 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data); |
| 189 | 189 |
| 190 // Update UISourceCode titles. | 190 // Update UISourceCode titles. |
| 191 var networkNode = this._uiSourceCodeNodes.get(binding.network); | 191 var networkNodes = this._uiSourceCodeNodes.get(binding.network) || []; |
| 192 if (networkNode) | 192 for (var networkNode of networkNodes) |
| 193 networkNode.updateTitle(); | 193 networkNode.updateTitle(); |
| 194 var fileSystemNode = this._uiSourceCodeNodes.get(binding.fileSystem); | 194 var fileSystemNodes = this._uiSourceCodeNodes.get(binding.fileSystem) || []; |
| 195 if (fileSystemNode) | 195 for (var fileSystemNode of fileSystemNodes) |
| 196 fileSystemNode.updateTitle(); | 196 fileSystemNode.updateTitle(); |
| 197 | 197 |
| 198 // Update folder titles. | 198 // Update folder titles. |
| 199 var pathTokens = Persistence.FileSystemWorkspaceBinding.relativePath(binding
.fileSystem); | 199 var pathTokens = Persistence.FileSystemWorkspaceBinding.relativePath(binding
.fileSystem); |
| 200 var folderPath = ''; | 200 var folderPath = ''; |
| 201 for (var i = 0; i < pathTokens.length - 1; ++i) { | 201 for (var i = 0; i < pathTokens.length - 1; ++i) { |
| 202 folderPath += pathTokens[i]; | 202 folderPath += pathTokens[i]; |
| 203 var folderId = | 203 var folderId = |
| 204 this._folderNodeId(binding.fileSystem.project(), null, null, binding.f
ileSystem.origin(), folderPath); | 204 this._folderNodeId(binding.fileSystem.project(), null, null, binding.f
ileSystem.origin(), folderPath); |
| 205 var folderNode = this._subfolderNodes.get(folderId); | 205 var folderNode = this._subfolderNodes.get(folderId); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 225 * @param {!Workspace.Workspace} workspace | 225 * @param {!Workspace.Workspace} workspace |
| 226 */ | 226 */ |
| 227 _resetWorkspace(workspace) { | 227 _resetWorkspace(workspace) { |
| 228 this._workspace = workspace; | 228 this._workspace = workspace; |
| 229 this._workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeAdde
d, this._uiSourceCodeAdded, this); | 229 this._workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeAdde
d, this._uiSourceCodeAdded, this); |
| 230 this._workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeRemo
ved, this._uiSourceCodeRemoved, this); | 230 this._workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeRemo
ved, this._uiSourceCodeRemoved, this); |
| 231 this._workspace.addEventListener(Workspace.Workspace.Events.ProjectRemoved,
this._projectRemoved.bind(this), this); | 231 this._workspace.addEventListener(Workspace.Workspace.Events.ProjectRemoved,
this._projectRemoved.bind(this), this); |
| 232 } | 232 } |
| 233 | 233 |
| 234 /** | 234 /** |
| 235 * @return {!Workspace.Workspace} |
| 236 * @protected |
| 237 */ |
| 238 workspace() { |
| 239 return this._workspace; |
| 240 } |
| 241 |
| 242 /** |
| 235 * @param {!Workspace.UISourceCode} uiSourceCode | 243 * @param {!Workspace.UISourceCode} uiSourceCode |
| 236 * @return {boolean} | 244 * @return {boolean} |
| 237 */ | 245 */ |
| 238 accept(uiSourceCode) { | 246 accept(uiSourceCode) { |
| 239 return !uiSourceCode.project().isServiceProject(); | 247 return !uiSourceCode.project().isServiceProject(); |
| 240 } | 248 } |
| 241 | 249 |
| 242 /** | 250 /** |
| 243 * @param {!Workspace.UISourceCode} uiSourceCode | 251 * @param {!Workspace.UISourceCode} uiSourceCode |
| 244 * @return {?SDK.ResourceTreeFrame} | 252 * @return {?SDK.ResourceTreeFrame} |
| (...skipping 26 matching lines...) Expand all Loading... |
| 271 else | 279 else |
| 272 path = Common.ParsedURL.extractPath(uiSourceCode.url()).split('/').slice(1
, -1); | 280 path = Common.ParsedURL.extractPath(uiSourceCode.url()).split('/').slice(1
, -1); |
| 273 | 281 |
| 274 var project = uiSourceCode.project(); | 282 var project = uiSourceCode.project(); |
| 275 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); | 283 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); |
| 276 var frame = this._uiSourceCodeFrame(uiSourceCode); | 284 var frame = this._uiSourceCodeFrame(uiSourceCode); |
| 277 | 285 |
| 278 var folderNode = | 286 var folderNode = |
| 279 this._folderNode(uiSourceCode, project, target, frame, uiSourceCode.orig
in(), path, isFromSourceMap); | 287 this._folderNode(uiSourceCode, project, target, frame, uiSourceCode.orig
in(), path, isFromSourceMap); |
| 280 var uiSourceCodeNode = new Sources.NavigatorUISourceCodeTreeNode(this, uiSou
rceCode); | 288 var uiSourceCodeNode = new Sources.NavigatorUISourceCodeTreeNode(this, uiSou
rceCode); |
| 281 this._uiSourceCodeNodes.set(uiSourceCode, uiSourceCodeNode); | 289 this._uiSourceCodeNodes.set(uiSourceCode, [uiSourceCodeNode]); |
| 282 folderNode.appendChild(uiSourceCodeNode); | 290 folderNode.appendChild(uiSourceCodeNode); |
| 283 this.uiSourceCodeAdded(uiSourceCode); | 291 this.uiSourceCodeAdded(uiSourceCode); |
| 284 } | 292 } |
| 285 | 293 |
| 286 /** | 294 /** |
| 287 * @param {!Workspace.UISourceCode} uiSourceCode | 295 * @param {!Workspace.UISourceCode} uiSourceCode |
| 288 */ | 296 */ |
| 289 uiSourceCodeAdded(uiSourceCode) { | 297 uiSourceCodeAdded(uiSourceCode) { |
| 290 } | 298 } |
| 291 | 299 |
| 292 /** | 300 /** |
| 293 * @return {!Array<!Sources.NavigatorUISourceCodeTreeNode>} | |
| 294 */ | |
| 295 uiSourceCodeNodes() { | |
| 296 return this._uiSourceCodeNodes.valuesArray(); | |
| 297 } | |
| 298 | |
| 299 /** | |
| 300 * @param {!Common.Event} event | 301 * @param {!Common.Event} event |
| 301 */ | 302 */ |
| 302 _uiSourceCodeAdded(event) { | 303 _uiSourceCodeAdded(event) { |
| 303 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data); | 304 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data); |
| 304 this._addUISourceCode(uiSourceCode); | 305 this._addUISourceCode(uiSourceCode); |
| 305 } | 306 } |
| 306 | 307 |
| 307 /** | 308 /** |
| 308 * @param {!Common.Event} event | 309 * @param {!Common.Event} event |
| 309 */ | 310 */ |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 | 490 |
| 490 var parsedURL = new Common.ParsedURL(projectOrigin); | 491 var parsedURL = new Common.ParsedURL(projectOrigin); |
| 491 var prettyURL = parsedURL.isValid ? parsedURL.host + (parsedURL.port ? (':'
+ parsedURL.port) : '') : ''; | 492 var prettyURL = parsedURL.isValid ? parsedURL.host + (parsedURL.port ? (':'
+ parsedURL.port) : '') : ''; |
| 492 | 493 |
| 493 return (prettyURL || projectOrigin); | 494 return (prettyURL || projectOrigin); |
| 494 } | 495 } |
| 495 | 496 |
| 496 /** | 497 /** |
| 497 * @param {!Workspace.UISourceCode} uiSourceCode | 498 * @param {!Workspace.UISourceCode} uiSourceCode |
| 498 * @param {boolean=} select | 499 * @param {boolean=} select |
| 500 * @return {?Sources.NavigatorUISourceCodeTreeNode} |
| 499 */ | 501 */ |
| 500 revealUISourceCode(uiSourceCode, select) { | 502 revealUISourceCode(uiSourceCode, select) { |
| 501 var node = this._uiSourceCodeNodes.get(uiSourceCode); | 503 var nodes = this._uiSourceCodeNodes.get(uiSourceCode); |
| 502 if (!node) | 504 if (!nodes) |
| 503 return; | 505 return null; |
| 504 if (this._scriptsTree.selectedTreeElement) | 506 if (this._scriptsTree.selectedTreeElement) |
| 505 this._scriptsTree.selectedTreeElement.deselect(); | 507 this._scriptsTree.selectedTreeElement.deselect(); |
| 506 this._lastSelectedUISourceCode = uiSourceCode; | 508 this._lastSelectedUISourceCode = uiSourceCode; |
| 507 node.reveal(select); | 509 // TODO(dgozman): figure out revealing multiple. |
| 510 nodes[0].reveal(select); |
| 511 return nodes[0]; |
| 508 } | 512 } |
| 509 | 513 |
| 510 /** | 514 /** |
| 511 * @param {!Workspace.UISourceCode} uiSourceCode | 515 * @param {!Workspace.UISourceCode} uiSourceCode |
| 512 * @param {boolean} focusSource | 516 * @param {boolean} focusSource |
| 513 */ | 517 */ |
| 514 _sourceSelected(uiSourceCode, focusSource) { | 518 _sourceSelected(uiSourceCode, focusSource) { |
| 515 this._lastSelectedUISourceCode = uiSourceCode; | 519 this._lastSelectedUISourceCode = uiSourceCode; |
| 516 Common.Revealer.reveal(uiSourceCode, !focusSource); | 520 Common.Revealer.reveal(uiSourceCode, !focusSource); |
| 517 } | 521 } |
| 518 | 522 |
| 519 /** | 523 /** |
| 520 * @param {!Workspace.UISourceCode} uiSourceCode | 524 * @param {!Workspace.UISourceCode} uiSourceCode |
| 521 */ | 525 */ |
| 522 sourceDeleted(uiSourceCode) { | 526 sourceDeleted(uiSourceCode) { |
| 523 } | 527 } |
| 524 | 528 |
| 525 /** | 529 /** |
| 526 * @param {!Workspace.UISourceCode} uiSourceCode | 530 * @param {!Workspace.UISourceCode} uiSourceCode |
| 527 */ | 531 */ |
| 528 _removeUISourceCode(uiSourceCode) { | 532 _removeUISourceCode(uiSourceCode) { |
| 529 var node = this._uiSourceCodeNodes.get(uiSourceCode); | 533 var nodes = this._uiSourceCodeNodes.get(uiSourceCode) || []; |
| 530 if (!node) | 534 for (var i = 0; i < nodes.length; i++) { |
| 531 return; | 535 var node = nodes[i]; |
| 532 | 536 |
| 533 var project = uiSourceCode.project(); | 537 var project = uiSourceCode.project(); |
| 534 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); | 538 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); |
| 535 var frame = this._uiSourceCodeFrame(uiSourceCode); | 539 var frame = this._uiSourceCodeFrame(uiSourceCode); |
| 536 | 540 |
| 537 var parentNode = node.parent; | 541 var parentNode = node.parent; |
| 538 this._uiSourceCodeNodes.delete(uiSourceCode); | |
| 539 parentNode.removeChild(node); | |
| 540 node = parentNode; | |
| 541 | |
| 542 while (node) { | |
| 543 parentNode = node.parent; | |
| 544 if (!parentNode || !node.isEmpty()) | |
| 545 break; | |
| 546 if (!(node instanceof Sources.NavigatorGroupTreeNode || node instanceof So
urces.NavigatorFolderTreeNode)) | |
| 547 break; | |
| 548 if (node._type === Sources.NavigatorView.Types.Frame) | |
| 549 break; | |
| 550 | |
| 551 var folderId = this._folderNodeId(project, target, frame, uiSourceCode.ori
gin(), node._folderPath); | |
| 552 this._subfolderNodes.delete(folderId); | |
| 553 parentNode.removeChild(node); | 542 parentNode.removeChild(node); |
| 554 node = parentNode; | 543 node = parentNode; |
| 544 |
| 545 while (node) { |
| 546 parentNode = node.parent; |
| 547 if (!parentNode || !node.isEmpty()) |
| 548 break; |
| 549 if (!(node instanceof Sources.NavigatorGroupTreeNode || node instanceof
Sources.NavigatorFolderTreeNode)) |
| 550 break; |
| 551 if (node._type === Sources.NavigatorView.Types.Frame) |
| 552 break; |
| 553 |
| 554 var folderId = this._folderNodeId(project, target, frame, uiSourceCode.o
rigin(), node._folderPath); |
| 555 this._subfolderNodes.delete(folderId); |
| 556 parentNode.removeChild(node); |
| 557 node = parentNode; |
| 558 } |
| 555 } | 559 } |
| 560 this._uiSourceCodeNodes.delete(uiSourceCode); |
| 556 } | 561 } |
| 557 | 562 |
| 558 reset() { | 563 reset() { |
| 559 var nodes = this._uiSourceCodeNodes.valuesArray(); | 564 for (var entry of this._uiSourceCodeNodes) { |
| 560 for (var i = 0; i < nodes.length; ++i) | 565 var nodes = /** @type {!Array<!Sources.NavigatorUISourceCodeTreeNode>} */
(entry[1]); |
| 561 nodes[i].dispose(); | 566 for (var i = 0; i < nodes.length; i++) |
| 567 nodes[i].dispose(); |
| 568 } |
| 562 | 569 |
| 563 this._scriptsTree.removeChildren(); | 570 this._scriptsTree.removeChildren(); |
| 564 this._uiSourceCodeNodes.clear(); | 571 this._uiSourceCodeNodes.clear(); |
| 565 this._subfolderNodes.clear(); | 572 this._subfolderNodes.clear(); |
| 566 this._frameNodes.clear(); | 573 this._frameNodes.clear(); |
| 567 this._rootNode.reset(); | 574 this._rootNode.reset(); |
| 568 } | 575 } |
| 569 | 576 |
| 570 /** | 577 /** |
| 571 * @param {!Event} event | 578 * @param {!Event} event |
| 572 */ | 579 */ |
| 573 handleContextMenu(event) { | 580 handleContextMenu(event) { |
| 574 } | 581 } |
| 575 | 582 |
| 576 /** | 583 /** |
| 577 * @param {!Workspace.Project} project | 584 * @param {!Workspace.Project} project |
| 578 * @param {string} path | 585 * @param {string} path |
| 579 * @param {!Workspace.UISourceCode=} uiSourceCode | 586 * @param {!Workspace.UISourceCode=} uiSourceCode |
| 580 */ | 587 */ |
| 581 _handleContextMenuCreate(project, path, uiSourceCode) { | 588 _handleContextMenuCreate(project, path, uiSourceCode) { |
| 582 this.create(project, path, uiSourceCode); | 589 this.create(project, path, uiSourceCode); |
| 583 } | 590 } |
| 584 | 591 |
| 585 /** | 592 /** |
| 586 * @param {!Workspace.UISourceCode} uiSourceCode | 593 * @param {!Sources.NavigatorUISourceCodeTreeNode} node |
| 587 */ | 594 */ |
| 588 _handleContextMenuRename(uiSourceCode) { | 595 _handleContextMenuRename(node) { |
| 589 this.rename(uiSourceCode, false); | 596 this.rename(node, false); |
| 590 } | 597 } |
| 591 | 598 |
| 592 /** | 599 /** |
| 593 * @param {!Workspace.Project} project | 600 * @param {!Workspace.Project} project |
| 594 * @param {string} path | 601 * @param {string} path |
| 595 */ | 602 */ |
| 596 _handleContextMenuExclude(project, path) { | 603 _handleContextMenuExclude(project, path) { |
| 597 var shouldExclude = window.confirm(Common.UIString('Are you sure you want to
exclude this folder?')); | 604 var shouldExclude = window.confirm(Common.UIString('Are you sure you want to
exclude this folder?')); |
| 598 if (shouldExclude) { | 605 if (shouldExclude) { |
| 599 UI.startBatchUpdate(); | 606 UI.startBatchUpdate(); |
| 600 project.excludeFolder(Persistence.FileSystemWorkspaceBinding.completeURL(p
roject, path)); | 607 project.excludeFolder(Persistence.FileSystemWorkspaceBinding.completeURL(p
roject, path)); |
| 601 UI.endBatchUpdate(); | 608 UI.endBatchUpdate(); |
| 602 } | 609 } |
| 603 } | 610 } |
| 604 | 611 |
| 605 /** | 612 /** |
| 606 * @param {!Workspace.UISourceCode} uiSourceCode | 613 * @param {!Workspace.UISourceCode} uiSourceCode |
| 607 */ | 614 */ |
| 608 _handleContextMenuDelete(uiSourceCode) { | 615 _handleContextMenuDelete(uiSourceCode) { |
| 609 var shouldDelete = window.confirm(Common.UIString('Are you sure you want to
delete this file?')); | 616 var shouldDelete = window.confirm(Common.UIString('Are you sure you want to
delete this file?')); |
| 610 if (shouldDelete) | 617 if (shouldDelete) |
| 611 uiSourceCode.project().deleteFile(uiSourceCode.url()); | 618 uiSourceCode.project().deleteFile(uiSourceCode.url()); |
| 612 } | 619 } |
| 613 | 620 |
| 614 /** | 621 /** |
| 615 * @param {!Event} event | 622 * @param {!Event} event |
| 616 * @param {!Workspace.UISourceCode} uiSourceCode | 623 * @param {!Sources.NavigatorUISourceCodeTreeNode} node |
| 617 */ | 624 */ |
| 618 handleFileContextMenu(event, uiSourceCode) { | 625 handleFileContextMenu(event, node) { |
| 626 var uiSourceCode = node.uiSourceCode(); |
| 619 var contextMenu = new UI.ContextMenu(event); | 627 var contextMenu = new UI.ContextMenu(event); |
| 620 contextMenu.appendApplicableItems(uiSourceCode); | 628 contextMenu.appendApplicableItems(uiSourceCode); |
| 621 contextMenu.appendSeparator(); | 629 contextMenu.appendSeparator(); |
| 622 | 630 |
| 623 var project = uiSourceCode.project(); | 631 var project = uiSourceCode.project(); |
| 624 if (project.type() === Workspace.projectTypes.FileSystem) { | 632 if (project.type() === Workspace.projectTypes.FileSystem) { |
| 625 var parentURL = uiSourceCode.parentURL(); | 633 var parentURL = uiSourceCode.parentURL(); |
| 626 contextMenu.appendItem(Common.UIString('Rename\u2026'), this._handleContex
tMenuRename.bind(this, uiSourceCode)); | 634 contextMenu.appendItem(Common.UIString('Rename\u2026'), this._handleContex
tMenuRename.bind(this, node)); |
| 627 contextMenu.appendItem( | 635 contextMenu.appendItem( |
| 628 Common.UIString('Make a copy\u2026'), | 636 Common.UIString('Make a copy\u2026'), |
| 629 this._handleContextMenuCreate.bind(this, project, parentURL, uiSourceC
ode)); | 637 this._handleContextMenuCreate.bind(this, project, parentURL, uiSourceC
ode)); |
| 630 contextMenu.appendItem(Common.UIString('Delete'), this._handleContextMenuD
elete.bind(this, uiSourceCode)); | 638 contextMenu.appendItem(Common.UIString('Delete'), this._handleContextMenuD
elete.bind(this, uiSourceCode)); |
| 631 contextMenu.appendSeparator(); | 639 contextMenu.appendSeparator(); |
| 632 } | 640 } |
| 633 | 641 |
| 634 contextMenu.show(); | 642 contextMenu.show(); |
| 635 } | 643 } |
| 636 | 644 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 661 | 669 |
| 662 contextMenu.appendSeparator(); | 670 contextMenu.appendSeparator(); |
| 663 Sources.NavigatorView.appendAddFolderItem(contextMenu); | 671 Sources.NavigatorView.appendAddFolderItem(contextMenu); |
| 664 if (node instanceof Sources.NavigatorGroupTreeNode) | 672 if (node instanceof Sources.NavigatorGroupTreeNode) |
| 665 contextMenu.appendItem(Common.UIString('Remove folder from workspace'), re
moveFolder); | 673 contextMenu.appendItem(Common.UIString('Remove folder from workspace'), re
moveFolder); |
| 666 | 674 |
| 667 contextMenu.show(); | 675 contextMenu.show(); |
| 668 } | 676 } |
| 669 | 677 |
| 670 /** | 678 /** |
| 671 * @param {!Workspace.UISourceCode} uiSourceCode | 679 * @param {!Sources.NavigatorUISourceCodeTreeNode} node |
| 672 * @param {boolean} deleteIfCanceled | 680 * @param {boolean} deleteIfCanceled |
| 681 * @protected |
| 673 */ | 682 */ |
| 674 rename(uiSourceCode, deleteIfCanceled) { | 683 rename(node, deleteIfCanceled) { |
| 675 var node = this._uiSourceCodeNodes.get(uiSourceCode); | 684 var uiSourceCode = node.uiSourceCode(); |
| 676 console.assert(node); | |
| 677 node.rename(callback.bind(this)); | 685 node.rename(callback.bind(this)); |
| 678 | 686 |
| 679 /** | 687 /** |
| 680 * @this {Sources.NavigatorView} | 688 * @this {Sources.NavigatorView} |
| 681 * @param {boolean} committed | 689 * @param {boolean} committed |
| 682 */ | 690 */ |
| 683 function callback(committed) { | 691 function callback(committed) { |
| 684 if (!committed) { | 692 if (!committed) { |
| 685 if (deleteIfCanceled) | 693 if (deleteIfCanceled) |
| 686 uiSourceCode.remove(); | 694 uiSourceCode.remove(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 } | 730 } |
| 723 | 731 |
| 724 /** | 732 /** |
| 725 * @this {Sources.NavigatorView} | 733 * @this {Sources.NavigatorView} |
| 726 * @param {?Workspace.UISourceCode} uiSourceCode | 734 * @param {?Workspace.UISourceCode} uiSourceCode |
| 727 */ | 735 */ |
| 728 function fileCreated(uiSourceCode) { | 736 function fileCreated(uiSourceCode) { |
| 729 if (!uiSourceCode) | 737 if (!uiSourceCode) |
| 730 return; | 738 return; |
| 731 this._sourceSelected(uiSourceCode, false); | 739 this._sourceSelected(uiSourceCode, false); |
| 732 this.revealUISourceCode(uiSourceCode, true); | 740 var node = this.revealUISourceCode(uiSourceCode, true); |
| 733 this.rename(uiSourceCode, true); | 741 if (node) |
| 742 this.rename(node, true); |
| 734 } | 743 } |
| 735 } | 744 } |
| 736 | 745 |
| 737 _groupingChanged() { | 746 _groupingChanged() { |
| 738 this.reset(); | 747 this.reset(); |
| 739 this._initGrouping(); | 748 this._initGrouping(); |
| 740 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)); | 749 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)); |
| 741 } | 750 } |
| 742 | 751 |
| 743 _initGrouping() { | 752 _initGrouping() { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 }; | 924 }; |
| 916 | 925 |
| 917 /** | 926 /** |
| 918 * @unrestricted | 927 * @unrestricted |
| 919 */ | 928 */ |
| 920 Sources.NavigatorSourceTreeElement = class extends TreeElement { | 929 Sources.NavigatorSourceTreeElement = class extends TreeElement { |
| 921 /** | 930 /** |
| 922 * @param {!Sources.NavigatorView} navigatorView | 931 * @param {!Sources.NavigatorView} navigatorView |
| 923 * @param {!Workspace.UISourceCode} uiSourceCode | 932 * @param {!Workspace.UISourceCode} uiSourceCode |
| 924 * @param {string} title | 933 * @param {string} title |
| 934 * @param {!Sources.NavigatorUISourceCodeTreeNode} node |
| 925 */ | 935 */ |
| 926 constructor(navigatorView, uiSourceCode, title) { | 936 constructor(navigatorView, uiSourceCode, title, node) { |
| 927 super('', false); | 937 super('', false); |
| 928 this._nodeType = Sources.NavigatorView.Types.File; | 938 this._nodeType = Sources.NavigatorView.Types.File; |
| 939 this._node = node; |
| 929 this.title = title; | 940 this.title = title; |
| 930 this.listItemElement.classList.add( | 941 this.listItemElement.classList.add( |
| 931 'navigator-' + uiSourceCode.contentType().name() + '-tree-item', 'naviga
tor-file-tree-item'); | 942 'navigator-' + uiSourceCode.contentType().name() + '-tree-item', 'naviga
tor-file-tree-item'); |
| 932 this.tooltip = uiSourceCode.url(); | 943 this.tooltip = uiSourceCode.url(); |
| 933 this.createIcon(); | 944 this.createIcon(); |
| 934 | 945 |
| 935 this._navigatorView = navigatorView; | 946 this._navigatorView = navigatorView; |
| 936 this._uiSourceCode = uiSourceCode; | 947 this._uiSourceCode = uiSourceCode; |
| 937 } | 948 } |
| 938 | 949 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 super.selectOnMouseDown(event); | 992 super.selectOnMouseDown(event); |
| 982 return; | 993 return; |
| 983 } | 994 } |
| 984 setTimeout(rename.bind(this), 300); | 995 setTimeout(rename.bind(this), 300); |
| 985 | 996 |
| 986 /** | 997 /** |
| 987 * @this {Sources.NavigatorSourceTreeElement} | 998 * @this {Sources.NavigatorSourceTreeElement} |
| 988 */ | 999 */ |
| 989 function rename() { | 1000 function rename() { |
| 990 if (this._shouldRenameOnMouseDown()) | 1001 if (this._shouldRenameOnMouseDown()) |
| 991 this._navigatorView.rename(this.uiSourceCode, false); | 1002 this._navigatorView.rename(this._node, false); |
| 992 } | 1003 } |
| 993 } | 1004 } |
| 994 | 1005 |
| 995 _ondragstart(event) { | 1006 _ondragstart(event) { |
| 996 event.dataTransfer.setData('text/plain', this._warmedUpContent); | 1007 event.dataTransfer.setData('text/plain', this._warmedUpContent); |
| 997 event.dataTransfer.effectAllowed = 'copy'; | 1008 event.dataTransfer.effectAllowed = 'copy'; |
| 998 return true; | 1009 return true; |
| 999 } | 1010 } |
| 1000 | 1011 |
| 1001 /** | 1012 /** |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 ondelete() { | 1051 ondelete() { |
| 1041 this._navigatorView.sourceDeleted(this.uiSourceCode); | 1052 this._navigatorView.sourceDeleted(this.uiSourceCode); |
| 1042 return true; | 1053 return true; |
| 1043 } | 1054 } |
| 1044 | 1055 |
| 1045 /** | 1056 /** |
| 1046 * @param {!Event} event | 1057 * @param {!Event} event |
| 1047 */ | 1058 */ |
| 1048 _handleContextMenuEvent(event) { | 1059 _handleContextMenuEvent(event) { |
| 1049 this.select(); | 1060 this.select(); |
| 1050 this._navigatorView.handleFileContextMenu(event, this._uiSourceCode); | 1061 this._navigatorView.handleFileContextMenu(event, this._node); |
| 1051 } | 1062 } |
| 1052 }; | 1063 }; |
| 1053 | 1064 |
| 1054 /** | 1065 /** |
| 1055 * @unrestricted | 1066 * @unrestricted |
| 1056 */ | 1067 */ |
| 1057 Sources.NavigatorTreeNode = class { | 1068 Sources.NavigatorTreeNode = class { |
| 1058 /** | 1069 /** |
| 1059 * @param {string} id | 1070 * @param {string} id |
| 1060 * @param {string} type | 1071 * @param {string} type |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1237 } | 1248 } |
| 1238 | 1249 |
| 1239 /** | 1250 /** |
| 1240 * @override | 1251 * @override |
| 1241 * @return {!TreeElement} | 1252 * @return {!TreeElement} |
| 1242 */ | 1253 */ |
| 1243 treeNode() { | 1254 treeNode() { |
| 1244 if (this._treeElement) | 1255 if (this._treeElement) |
| 1245 return this._treeElement; | 1256 return this._treeElement; |
| 1246 | 1257 |
| 1247 this._treeElement = new Sources.NavigatorSourceTreeElement(this._navigatorVi
ew, this._uiSourceCode, ''); | 1258 this._treeElement = new Sources.NavigatorSourceTreeElement(this._navigatorVi
ew, this._uiSourceCode, '', this); |
| 1248 this.updateTitle(); | 1259 this.updateTitle(); |
| 1249 | 1260 |
| 1250 var updateTitleBound = this.updateTitle.bind(this, undefined); | 1261 var updateTitleBound = this.updateTitle.bind(this, undefined); |
| 1251 this._eventListeners = [ | 1262 this._eventListeners = [ |
| 1252 this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.TitleCha
nged, updateTitleBound), | 1263 this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.TitleCha
nged, updateTitleBound), |
| 1253 this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.WorkingC
opyChanged, updateTitleBound), | 1264 this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.WorkingC
opyChanged, updateTitleBound), |
| 1254 this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.WorkingC
opyCommitted, updateTitleBound) | 1265 this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.WorkingC
opyCommitted, updateTitleBound) |
| 1255 ]; | 1266 ]; |
| 1256 return this._treeElement; | 1267 return this._treeElement; |
| 1257 } | 1268 } |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1601 /** | 1612 /** |
| 1602 * @param {string} title | 1613 * @param {string} title |
| 1603 * @override | 1614 * @override |
| 1604 */ | 1615 */ |
| 1605 setTitle(title) { | 1616 setTitle(title) { |
| 1606 this._title = title; | 1617 this._title = title; |
| 1607 if (this._treeElement) | 1618 if (this._treeElement) |
| 1608 this._treeElement.title = this._title; | 1619 this._treeElement.title = this._title; |
| 1609 } | 1620 } |
| 1610 }; | 1621 }; |
| OLD | NEW |