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