Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(371)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/SourcesView.js

Issue 2716683006: DevTools: add entry points for command menu (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 {
11 /** 11 /**
12 * @suppressGlobalPropertiesCheck 12 * @suppressGlobalPropertiesCheck
13 */ 13 */
14 constructor() { 14 constructor() {
15 super(); 15 super();
16 this.registerRequiredCSS('sources/sourcesView.css'); 16 this.registerRequiredCSS('sources/sourcesView.css');
17 this.element.id = 'sources-panel-sources-view'; 17 this.element.id = 'sources-panel-sources-view';
18 this.setMinimumAndPreferredSizes(80, 52, 150, 100); 18 this.setMinimumAndPreferredSizes(80, 52, 150, 100);
19 19
20 var workspace = Workspace.workspace; 20 var workspace = Workspace.workspace;
21 21
22 this._searchableView = new UI.SearchableView(this, 'sourcesViewSearchConfig' ); 22 this._searchableView = new UI.SearchableView(this, 'sourcesViewSearchConfig' );
23 this._searchableView.setMinimalSearchQuerySize(0); 23 this._searchableView.setMinimalSearchQuerySize(0);
24 this._searchableView.show(this.element); 24 this._searchableView.show(this.element);
25 25
26 /** @type {!Map.<!Workspace.UISourceCode, !UI.Widget>} */ 26 /** @type {!Map.<!Workspace.UISourceCode, !UI.Widget>} */
27 this._sourceViewByUISourceCode = new Map(); 27 this._sourceViewByUISourceCode = new Map();
28 28
29 var tabbedEditorPlaceholderText =
30 Host.isMac() ? Common.UIString('Hit \u2318+P to open a file') : Common.U IString('Hit Ctrl+P to open a file');
31 this._editorContainer = new Sources.TabbedEditorContainer( 29 this._editorContainer = new Sources.TabbedEditorContainer(
32 this, Common.settings.createLocalSetting('previouslyViewedFiles', []), t abbedEditorPlaceholderText); 30 this, Common.settings.createLocalSetting('previouslyViewedFiles', []), t his.placeholderElement());
33 this._editorContainer.show(this._searchableView.element); 31 this._editorContainer.show(this._searchableView.element);
34 this._editorContainer.addEventListener( 32 this._editorContainer.addEventListener(
35 Sources.TabbedEditorContainer.Events.EditorSelected, this._editorSelecte d, this); 33 Sources.TabbedEditorContainer.Events.EditorSelected, this._editorSelecte d, this);
36 this._editorContainer.addEventListener(Sources.TabbedEditorContainer.Events. EditorClosed, this._editorClosed, this); 34 this._editorContainer.addEventListener(Sources.TabbedEditorContainer.Events. EditorClosed, this._editorClosed, this);
37 35
38 this._historyManager = new Sources.EditingLocationHistoryManager(this, this. currentSourceFrame.bind(this)); 36 this._historyManager = new Sources.EditingLocationHistoryManager(this, this. currentSourceFrame.bind(this));
39 37
40 this._toolbarContainerElement = this.element.createChild('div', 'sources-too lbar'); 38 this._toolbarContainerElement = this.element.createChild('div', 'sources-too lbar');
41 this._toolbarEditorActions = new UI.Toolbar('', this._toolbarContainerElemen t); 39 this._toolbarEditorActions = new UI.Toolbar('', this._toolbarContainerElemen t);
42 40
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 Common.Revealer.reveal(unsavedSourceCodes[i]); 83 Common.Revealer.reveal(unsavedSourceCodes[i]);
86 } 84 }
87 85
88 if (!window.opener) 86 if (!window.opener)
89 window.addEventListener('beforeunload', handleBeforeUnload, true); 87 window.addEventListener('beforeunload', handleBeforeUnload, true);
90 88
91 this._shortcuts = {}; 89 this._shortcuts = {};
92 this.element.addEventListener('keydown', this._handleKeyDown.bind(this), fal se); 90 this.element.addEventListener('keydown', this._handleKeyDown.bind(this), fal se);
93 } 91 }
94 92
93 placeholderElement() {
94 var shortcuts = [
95 {
96 defaultShortcut: Common.UIString('Ctrl+P'),
97 macShortcut: Common.UIString('\u2318+P'),
98 description: Common.UIString('Open a file')
99 },
100 {
101 defaultShortcut: Common.UIString('Ctrl+Shift+P'),
102 macShortcut: Common.UIString('\u2318+Shift+P'),
103 description: Common.UIString('Run command')
104 },
105 {
106 defaultShortcut: Common.UIString('Esc'),
107 macShortcut: Common.UIString('Esc'),
108 description: Common.UIString('Toggle console drawer')
109 },
110 ];
111 var placeholderElement = createElementWithClass('span', 'sources-placeholder ');
112 for (var shortcut of shortcuts) {
113 var row = placeholderElement.createChild('div', 'sources-placeholder-row') ;
114 row.createChild('div', 'sources-placeholder-key')
115 .createTextChild(Host.isMac() ? shortcut.macShortcut : shortcut.defaul tShortcut);
116 row.createChild('div', 'sources-placeholder-value').createTextChild(shortc ut.description);
117 }
118
119 return placeholderElement;
120 }
121
95 /** 122 /**
96 * @param {function(!Array.<!UI.KeyboardShortcut.Descriptor>, function(!Event= ):boolean)} registerShortcutDelegate 123 * @param {function(!Array.<!UI.KeyboardShortcut.Descriptor>, function(!Event= ):boolean)} registerShortcutDelegate
97 */ 124 */
98 registerShortcuts(registerShortcutDelegate) { 125 registerShortcuts(registerShortcutDelegate) {
99 /** 126 /**
100 * @this {Sources.SourcesView} 127 * @this {Sources.SourcesView}
101 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} shortcuts 128 * @param {!Array.<!UI.KeyboardShortcut.Descriptor>} shortcuts
102 * @param {function(!Event=):boolean} handler 129 * @param {function(!Event=):boolean} handler
103 */ 130 */
104 function registerShortcut(shortcuts, handler) { 131 function registerShortcut(shortcuts, handler) {
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 * @return {boolean} 793 * @return {boolean}
767 */ 794 */
768 handleAction(context, actionId) { 795 handleAction(context, actionId) {
769 var sourcesView = UI.context.flavor(Sources.SourcesView); 796 var sourcesView = UI.context.flavor(Sources.SourcesView);
770 if (!sourcesView) 797 if (!sourcesView)
771 return false; 798 return false;
772 sourcesView._editorContainer.closeAllFiles(); 799 sourcesView._editorContainer.closeAllFiles();
773 return true; 800 return true;
774 } 801 }
775 }; 802 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698