| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 /** | 4 /** |
| 5 * @implements {Sources.TabbedEditorContainerDelegate} | 5 * @implements {Sources.TabbedEditorContainerDelegate} |
| 6 * @implements {UI.Searchable} | 6 * @implements {UI.Searchable} |
| 7 * @implements {UI.Replaceable} | 7 * @implements {UI.Replaceable} |
| 8 * @unrestricted | 8 * @unrestricted |
| 9 */ | 9 */ |
| 10 Sources.SourcesView = class extends UI.VBox { | 10 Sources.SourcesView = class extends UI.VBox { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 UI.viewManager.showView('sources'); | 82 UI.viewManager.showView('sources'); |
| 83 for (var i = 0; i < unsavedSourceCodes.length; ++i) | 83 for (var i = 0; i < unsavedSourceCodes.length; ++i) |
| 84 Common.Revealer.reveal(unsavedSourceCodes[i]); | 84 Common.Revealer.reveal(unsavedSourceCodes[i]); |
| 85 } | 85 } |
| 86 | 86 |
| 87 if (!window.opener) | 87 if (!window.opener) |
| 88 window.addEventListener('beforeunload', handleBeforeUnload, true); | 88 window.addEventListener('beforeunload', handleBeforeUnload, true); |
| 89 | 89 |
| 90 this._shortcuts = {}; | 90 this._shortcuts = {}; |
| 91 this.element.addEventListener('keydown', this._handleKeyDown.bind(this), fal
se); | 91 this.element.addEventListener('keydown', this._handleKeyDown.bind(this), fal
se); |
| 92 |
| 93 Persistence.persistence.addEventListener( |
| 94 Persistence.Persistence.Events.BindingCreated, this._onBindingChanged, t
his); |
| 95 Persistence.persistence.addEventListener( |
| 96 Persistence.Persistence.Events.BindingRemoved, this._onBindingChanged, t
his); |
| 92 } | 97 } |
| 93 | 98 |
| 94 /** | 99 /** |
| 95 * @param {function(!Array.<!UI.KeyboardShortcut.Descriptor>, function(!Event=
):boolean)} registerShortcutDelegate | 100 * @param {function(!Array.<!UI.KeyboardShortcut.Descriptor>, function(!Event=
):boolean)} registerShortcutDelegate |
| 96 */ | 101 */ |
| 97 registerShortcuts(registerShortcutDelegate) { | 102 registerShortcuts(registerShortcutDelegate) { |
| 98 /** | 103 /** |
| 99 * @this {Sources.SourcesView} | 104 * @this {Sources.SourcesView} |
| 100 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} shortcuts | 105 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} shortcuts |
| 101 * @param {function(!Event=):boolean} handler | 106 * @param {function(!Event=):boolean} handler |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 * @param {!Workspace.UISourceCode} uiSourceCode | 392 * @param {!Workspace.UISourceCode} uiSourceCode |
| 388 */ | 393 */ |
| 389 _removeSourceFrame(uiSourceCode) { | 394 _removeSourceFrame(uiSourceCode) { |
| 390 var sourceView = this._sourceViewByUISourceCode.get(uiSourceCode); | 395 var sourceView = this._sourceViewByUISourceCode.get(uiSourceCode); |
| 391 this._sourceViewByUISourceCode.remove(uiSourceCode); | 396 this._sourceViewByUISourceCode.remove(uiSourceCode); |
| 392 uiSourceCode.removeEventListener(Workspace.UISourceCode.Events.TitleChanged,
this._uiSourceCodeTitleChanged, this); | 397 uiSourceCode.removeEventListener(Workspace.UISourceCode.Events.TitleChanged,
this._uiSourceCodeTitleChanged, this); |
| 393 if (sourceView && sourceView instanceof Sources.UISourceCodeFrame) | 398 if (sourceView && sourceView instanceof Sources.UISourceCodeFrame) |
| 394 /** @type {!Sources.UISourceCodeFrame} */ (sourceView).dispose(); | 399 /** @type {!Sources.UISourceCodeFrame} */ (sourceView).dispose(); |
| 395 } | 400 } |
| 396 | 401 |
| 402 /** |
| 403 * @param {!Common.Event} event |
| 404 */ |
| 405 _onBindingChanged(event) { |
| 406 if (!this._executionLocation) |
| 407 return; |
| 408 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data); |
| 409 var uiSourceCode = this._executionLocation.uiSourceCode; |
| 410 if (binding.network !== uiSourceCode) |
| 411 return; |
| 412 this.setExecutionLocation(this._executionLocation); |
| 413 this.showSourceLocation( |
| 414 this._executionLocation.uiSourceCode, this._executionLocation.lineNumber
, this._executionLocation.columnNumber); |
| 415 } |
| 416 |
| 397 clearCurrentExecutionLine() { | 417 clearCurrentExecutionLine() { |
| 398 if (this._executionSourceFrame) | 418 if (this._executionSourceFrame) |
| 399 this._executionSourceFrame.clearExecutionLine(); | 419 this._executionSourceFrame.clearExecutionLine(); |
| 400 delete this._executionSourceFrame; | 420 this._executionSourceFrame = null; |
| 421 this._executionLocation = null; |
| 401 } | 422 } |
| 402 | 423 |
| 403 /** | 424 /** |
| 404 * @param {!Workspace.UILocation} uiLocation | 425 * @param {!Workspace.UILocation} uiLocation |
| 405 */ | 426 */ |
| 406 setExecutionLocation(uiLocation) { | 427 setExecutionLocation(uiLocation) { |
| 407 var sourceView = this._getOrCreateSourceView(uiLocation.uiSourceCode); | 428 this.clearCurrentExecutionLine(); |
| 429 var binding = Persistence.persistence.binding(uiLocation.uiSourceCode); |
| 430 var uiSourceCode = binding ? binding.fileSystem : uiLocation.uiSourceCode; |
| 431 var sourceView = this._getOrCreateSourceView(uiSourceCode); |
| 408 if (sourceView instanceof Sources.UISourceCodeFrame) { | 432 if (sourceView instanceof Sources.UISourceCodeFrame) { |
| 409 var sourceFrame = /** @type {!Sources.UISourceCodeFrame} */ (sourceView); | 433 var sourceFrame = /** @type {!Sources.UISourceCodeFrame} */ (sourceView); |
| 410 sourceFrame.setExecutionLocation(uiLocation); | 434 sourceFrame.setExecutionLocation( |
| 435 new Workspace.UILocation(uiSourceCode, uiLocation.lineNumber, uiLocati
on.columnNumber)); |
| 411 this._executionSourceFrame = sourceFrame; | 436 this._executionSourceFrame = sourceFrame; |
| 437 this._executionLocation = uiLocation; |
| 412 } | 438 } |
| 413 } | 439 } |
| 414 | 440 |
| 415 /** | 441 /** |
| 416 * @param {!Common.Event} event | 442 * @param {!Common.Event} event |
| 417 */ | 443 */ |
| 418 _editorClosed(event) { | 444 _editorClosed(event) { |
| 419 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data); | 445 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data); |
| 420 this._historyManager.removeHistoryForSourceCode(uiSourceCode); | 446 this._historyManager.removeHistoryForSourceCode(uiSourceCode); |
| 421 | 447 |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 * @return {boolean} | 778 * @return {boolean} |
| 753 */ | 779 */ |
| 754 handleAction(context, actionId) { | 780 handleAction(context, actionId) { |
| 755 var sourcesView = UI.context.flavor(Sources.SourcesView); | 781 var sourcesView = UI.context.flavor(Sources.SourcesView); |
| 756 if (!sourcesView) | 782 if (!sourcesView) |
| 757 return false; | 783 return false; |
| 758 sourcesView._editorContainer.closeAllFiles(); | 784 sourcesView._editorContainer.closeAllFiles(); |
| 759 return true; | 785 return true; |
| 760 } | 786 } |
| 761 }; | 787 }; |
| OLD | NEW |