| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 88 } |
| 89 | 89 |
| 90 if (!window.opener) | 90 if (!window.opener) |
| 91 window.addEventListener('beforeunload', handleBeforeUnload, true); | 91 window.addEventListener('beforeunload', handleBeforeUnload, true); |
| 92 | 92 |
| 93 this._shortcuts = {}; | 93 this._shortcuts = {}; |
| 94 this.element.addEventListener('keydown', this._handleKeyDown.bind(this), fal
se); | 94 this.element.addEventListener('keydown', this._handleKeyDown.bind(this), fal
se); |
| 95 } | 95 } |
| 96 | 96 |
| 97 /** | 97 /** |
| 98 * @return {!Map.<!Workspace.UISourceCode, number>} |
| 99 */ |
| 100 static defaultUISourceCodeScores() { |
| 101 /** @type {!Map.<!Workspace.UISourceCode, number>} */ |
| 102 var defaultScores = new Map(); |
| 103 var sourcesView = UI.context.flavor(Sources.SourcesView); |
| 104 if (sourcesView) { |
| 105 var uiSourceCodes = sourcesView._editorContainer.historyUISourceCodes(); |
| 106 for (var i = 1; i < uiSourceCodes.length; ++i) // Skip current element |
| 107 defaultScores.set(uiSourceCodes[i], uiSourceCodes.length - i); |
| 108 } |
| 109 return defaultScores; |
| 110 } |
| 111 |
| 112 /** |
| 98 * @param {function(!Array.<!UI.KeyboardShortcut.Descriptor>, function(!Event=
):boolean)} registerShortcutDelegate | 113 * @param {function(!Array.<!UI.KeyboardShortcut.Descriptor>, function(!Event=
):boolean)} registerShortcutDelegate |
| 99 */ | 114 */ |
| 100 registerShortcuts(registerShortcutDelegate) { | 115 registerShortcuts(registerShortcutDelegate) { |
| 101 /** | 116 /** |
| 102 * @this {Sources.SourcesView} | 117 * @this {Sources.SourcesView} |
| 103 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} shortcuts | 118 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} shortcuts |
| 104 * @param {function(!Event=):boolean} handler | 119 * @param {function(!Event=):boolean} handler |
| 105 */ | 120 */ |
| 106 function registerShortcut(shortcuts, handler) { | 121 function registerShortcut(shortcuts, handler) { |
| 107 registerShortcutDelegate(shortcuts, handler); | 122 registerShortcutDelegate(shortcuts, handler); |
| 108 this._registerShortcuts(shortcuts, handler); | 123 this._registerShortcuts(shortcuts, handler); |
| 109 } | 124 } |
| 110 | 125 |
| 111 registerShortcut.call( | 126 registerShortcut.call( |
| 112 this, UI.ShortcutsScreen.SourcesPanelShortcuts.JumpToPreviousLocation, | 127 this, UI.ShortcutsScreen.SourcesPanelShortcuts.JumpToPreviousLocation, |
| 113 this._onJumpToPreviousLocation.bind(this)); | 128 this._onJumpToPreviousLocation.bind(this)); |
| 114 registerShortcut.call( | 129 registerShortcut.call( |
| 115 this, UI.ShortcutsScreen.SourcesPanelShortcuts.JumpToNextLocation, this.
_onJumpToNextLocation.bind(this)); | 130 this, UI.ShortcutsScreen.SourcesPanelShortcuts.JumpToNextLocation, this.
_onJumpToNextLocation.bind(this)); |
| 116 registerShortcut.call( | 131 registerShortcut.call( |
| 117 this, UI.ShortcutsScreen.SourcesPanelShortcuts.CloseEditorTab, this._onC
loseEditorTab.bind(this)); | 132 this, UI.ShortcutsScreen.SourcesPanelShortcuts.CloseEditorTab, this._onC
loseEditorTab.bind(this)); |
| 118 registerShortcut.call(this, UI.ShortcutsScreen.SourcesPanelShortcuts.GoToLin
e, this._showGoToLineDialog.bind(this)); | 133 registerShortcut.call( |
| 134 this, UI.ShortcutsScreen.SourcesPanelShortcuts.GoToLine, this._showGoToL
ineQuickOpen.bind(this)); |
| 119 registerShortcut.call( | 135 registerShortcut.call( |
| 120 this, UI.ShortcutsScreen.SourcesPanelShortcuts.GoToMember, this._showOut
lineDialog.bind(this)); | 136 this, UI.ShortcutsScreen.SourcesPanelShortcuts.GoToMember, this._showOut
lineDialog.bind(this)); |
| 121 registerShortcut.call( | 137 registerShortcut.call( |
| 122 this, UI.ShortcutsScreen.SourcesPanelShortcuts.ToggleBreakpoint, this._t
oggleBreakpoint.bind(this)); | 138 this, UI.ShortcutsScreen.SourcesPanelShortcuts.ToggleBreakpoint, this._t
oggleBreakpoint.bind(this)); |
| 123 registerShortcut.call(this, UI.ShortcutsScreen.SourcesPanelShortcuts.Save, t
his._save.bind(this)); | 139 registerShortcut.call(this, UI.ShortcutsScreen.SourcesPanelShortcuts.Save, t
his._save.bind(this)); |
| 124 registerShortcut.call(this, UI.ShortcutsScreen.SourcesPanelShortcuts.SaveAll
, this._saveAll.bind(this)); | 140 registerShortcut.call(this, UI.ShortcutsScreen.SourcesPanelShortcuts.SaveAll
, this._saveAll.bind(this)); |
| 125 } | 141 } |
| 126 | 142 |
| 127 /** | 143 /** |
| 128 * @return {!UI.Toolbar} | 144 * @return {!UI.Toolbar} |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 if (uiSourceCode.contentType().isStyleSheet()) { | 613 if (uiSourceCode.contentType().isStyleSheet()) { |
| 598 Sources.StyleSheetOutlineDialog.show(uiSourceCode, this.showSourceLocation
.bind(this, uiSourceCode)); | 614 Sources.StyleSheetOutlineDialog.show(uiSourceCode, this.showSourceLocation
.bind(this, uiSourceCode)); |
| 599 return true; | 615 return true; |
| 600 } | 616 } |
| 601 | 617 |
| 602 // We don't want default browser shortcut to be executed, so pretend to hand
le this event. | 618 // We don't want default browser shortcut to be executed, so pretend to hand
le this event. |
| 603 return true; | 619 return true; |
| 604 } | 620 } |
| 605 | 621 |
| 606 /** | 622 /** |
| 607 * @param {string=} query | |
| 608 */ | |
| 609 showOpenResourceDialog(query) { | |
| 610 var uiSourceCodes = this._editorContainer.historyUISourceCodes(); | |
| 611 /** @type {!Map.<!Workspace.UISourceCode, number>} */ | |
| 612 var defaultScores = new Map(); | |
| 613 for (var i = 1; i < uiSourceCodes.length; ++i) // Skip current element | |
| 614 defaultScores.set(uiSourceCodes[i], uiSourceCodes.length - i); | |
| 615 if (!this._openResourceDialogHistory) | |
| 616 this._openResourceDialogHistory = []; | |
| 617 Sources.OpenResourceDialog.show(this, query || '', defaultScores, this._open
ResourceDialogHistory); | |
| 618 } | |
| 619 | |
| 620 /** | |
| 621 * @param {!Event=} event | 623 * @param {!Event=} event |
| 622 * @return {boolean} | 624 * @return {boolean} |
| 623 */ | 625 */ |
| 624 _showGoToLineDialog(event) { | 626 _showGoToLineQuickOpen(event) { |
| 625 if (this._editorContainer.currentFile()) | 627 if (this._editorContainer.currentFile()) |
| 626 this.showOpenResourceDialog(':'); | 628 QuickOpen.QuickOpen.show(':'); |
| 627 return true; | 629 return true; |
| 628 } | 630 } |
| 629 | 631 |
| 630 /** | 632 /** |
| 631 * @return {boolean} | 633 * @return {boolean} |
| 632 */ | 634 */ |
| 633 _save() { | 635 _save() { |
| 634 this._saveSourceFrame(this.currentSourceFrame()); | 636 this._saveSourceFrame(this.currentSourceFrame()); |
| 635 return true; | 637 return true; |
| 636 } | 638 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 * @return {boolean} | 770 * @return {boolean} |
| 769 */ | 771 */ |
| 770 handleAction(context, actionId) { | 772 handleAction(context, actionId) { |
| 771 var sourcesView = UI.context.flavor(Sources.SourcesView); | 773 var sourcesView = UI.context.flavor(Sources.SourcesView); |
| 772 if (!sourcesView) | 774 if (!sourcesView) |
| 773 return false; | 775 return false; |
| 774 sourcesView._editorContainer.closeAllFiles(); | 776 sourcesView._editorContainer.closeAllFiles(); |
| 775 return true; | 777 return true; |
| 776 } | 778 } |
| 777 }; | 779 }; |
| OLD | NEW |