| 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); | |
| 97 } | 92 } |
| 98 | 93 |
| 99 /** | 94 /** |
| 100 * @param {function(!Array.<!UI.KeyboardShortcut.Descriptor>, function(!Event=
):boolean)} registerShortcutDelegate | 95 * @param {function(!Array.<!UI.KeyboardShortcut.Descriptor>, function(!Event=
):boolean)} registerShortcutDelegate |
| 101 */ | 96 */ |
| 102 registerShortcuts(registerShortcutDelegate) { | 97 registerShortcuts(registerShortcutDelegate) { |
| 103 /** | 98 /** |
| 104 * @this {Sources.SourcesView} | 99 * @this {Sources.SourcesView} |
| 105 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} shortcuts | 100 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} shortcuts |
| 106 * @param {function(!Event=):boolean} handler | 101 * @param {function(!Event=):boolean} handler |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 * @param {!Workspace.UISourceCode} uiSourceCode | 387 * @param {!Workspace.UISourceCode} uiSourceCode |
| 393 */ | 388 */ |
| 394 _removeSourceFrame(uiSourceCode) { | 389 _removeSourceFrame(uiSourceCode) { |
| 395 var sourceView = this._sourceViewByUISourceCode.get(uiSourceCode); | 390 var sourceView = this._sourceViewByUISourceCode.get(uiSourceCode); |
| 396 this._sourceViewByUISourceCode.remove(uiSourceCode); | 391 this._sourceViewByUISourceCode.remove(uiSourceCode); |
| 397 uiSourceCode.removeEventListener(Workspace.UISourceCode.Events.TitleChanged,
this._uiSourceCodeTitleChanged, this); | 392 uiSourceCode.removeEventListener(Workspace.UISourceCode.Events.TitleChanged,
this._uiSourceCodeTitleChanged, this); |
| 398 if (sourceView && sourceView instanceof Sources.UISourceCodeFrame) | 393 if (sourceView && sourceView instanceof Sources.UISourceCodeFrame) |
| 399 /** @type {!Sources.UISourceCodeFrame} */ (sourceView).dispose(); | 394 /** @type {!Sources.UISourceCodeFrame} */ (sourceView).dispose(); |
| 400 } | 395 } |
| 401 | 396 |
| 402 /** | 397 _onBindingChanged() { |
| 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); | 398 this.setExecutionLocation(this._executionLocation); |
| 413 this.showSourceLocation( | 399 this.showSourceLocation( |
| 414 this._executionLocation.uiSourceCode, this._executionLocation.lineNumber
, this._executionLocation.columnNumber); | 400 this._executionLocation.uiSourceCode, this._executionLocation.lineNumber
, this._executionLocation.columnNumber); |
| 415 } | 401 } |
| 416 | 402 |
| 417 clearCurrentExecutionLine() { | 403 clearCurrentExecutionLine() { |
| 418 if (this._executionSourceFrame) | 404 if (!this._executionLocation) |
| 419 this._executionSourceFrame.clearExecutionLine(); | 405 return; |
| 406 Persistence.persistence.unsubscribeFromBindingEvent( |
| 407 this._executionLocation.uiSourceCode, this._onBindingChanged); |
| 408 this._executionSourceFrame.clearExecutionLine(); |
| 420 this._executionSourceFrame = null; | 409 this._executionSourceFrame = null; |
| 421 this._executionLocation = null; | 410 this._executionLocation = null; |
| 422 } | 411 } |
| 423 | 412 |
| 424 /** | 413 /** |
| 425 * @param {!Workspace.UILocation} uiLocation | 414 * @param {!Workspace.UILocation} uiLocation |
| 426 */ | 415 */ |
| 427 setExecutionLocation(uiLocation) { | 416 setExecutionLocation(uiLocation) { |
| 428 this.clearCurrentExecutionLine(); | 417 this.clearCurrentExecutionLine(); |
| 429 var binding = Persistence.persistence.binding(uiLocation.uiSourceCode); | 418 var binding = Persistence.persistence.binding(uiLocation.uiSourceCode); |
| 430 var uiSourceCode = binding ? binding.fileSystem : uiLocation.uiSourceCode; | 419 var uiSourceCode = binding ? binding.fileSystem : uiLocation.uiSourceCode; |
| 431 var sourceView = this._getOrCreateSourceView(uiSourceCode); | 420 var sourceView = this._getOrCreateSourceView(uiSourceCode); |
| 432 if (sourceView instanceof Sources.UISourceCodeFrame) { | 421 if (!(sourceView instanceof Sources.UISourceCodeFrame)) |
| 433 var sourceFrame = /** @type {!Sources.UISourceCodeFrame} */ (sourceView); | 422 return; |
| 434 sourceFrame.setExecutionLocation( | 423 Persistence.persistence.subscribeForBindingEvent(uiLocation.uiSourceCode, th
is._onBindingChanged, this); |
| 435 new Workspace.UILocation(uiSourceCode, uiLocation.lineNumber, uiLocati
on.columnNumber)); | 424 var sourceFrame = /** @type {!Sources.UISourceCodeFrame} */ (sourceView); |
| 436 this._executionSourceFrame = sourceFrame; | 425 sourceFrame.setExecutionLocation( |
| 437 this._executionLocation = uiLocation; | 426 new Workspace.UILocation(uiSourceCode, uiLocation.lineNumber, uiLocation
.columnNumber)); |
| 438 } | 427 this._executionSourceFrame = sourceFrame; |
| 428 this._executionLocation = uiLocation; |
| 439 } | 429 } |
| 440 | 430 |
| 441 /** | 431 /** |
| 442 * @param {!Common.Event} event | 432 * @param {!Common.Event} event |
| 443 */ | 433 */ |
| 444 _editorClosed(event) { | 434 _editorClosed(event) { |
| 445 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data); | 435 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data); |
| 446 this._historyManager.removeHistoryForSourceCode(uiSourceCode); | 436 this._historyManager.removeHistoryForSourceCode(uiSourceCode); |
| 447 | 437 |
| 448 var wasSelected = false; | 438 var wasSelected = false; |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 * @return {boolean} | 768 * @return {boolean} |
| 779 */ | 769 */ |
| 780 handleAction(context, actionId) { | 770 handleAction(context, actionId) { |
| 781 var sourcesView = UI.context.flavor(Sources.SourcesView); | 771 var sourcesView = UI.context.flavor(Sources.SourcesView); |
| 782 if (!sourcesView) | 772 if (!sourcesView) |
| 783 return false; | 773 return false; |
| 784 sourcesView._editorContainer.closeAllFiles(); | 774 sourcesView._editorContainer.closeAllFiles(); |
| 785 return true; | 775 return true; |
| 786 } | 776 } |
| 787 }; | 777 }; |
| OLD | NEW |