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

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: ac Created 3 years, 7 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 if (Runtime.experiments.isEnabled('persistence2'))
32 tabbedEditorPlaceholderText += '\n\n' + Common.UIString('Drop in a folder to add to workspace');
33 this._editorContainer = new Sources.TabbedEditorContainer( 29 this._editorContainer = new Sources.TabbedEditorContainer(
34 this, Common.settings.createLocalSetting('previouslyViewedFiles', []), t abbedEditorPlaceholderText); 30 this, Common.settings.createLocalSetting('previouslyViewedFiles', []), t his._placeholderElement());
35 this._editorContainer.show(this._searchableView.element); 31 this._editorContainer.show(this._searchableView.element);
36 this._editorContainer.addEventListener( 32 this._editorContainer.addEventListener(
37 Sources.TabbedEditorContainer.Events.EditorSelected, this._editorSelecte d, this); 33 Sources.TabbedEditorContainer.Events.EditorSelected, this._editorSelecte d, this);
38 this._editorContainer.addEventListener(Sources.TabbedEditorContainer.Events. EditorClosed, this._editorClosed, this); 34 this._editorContainer.addEventListener(Sources.TabbedEditorContainer.Events. EditorClosed, this._editorClosed, this);
39 35
40 this._historyManager = new Sources.EditingLocationHistoryManager(this, this. currentSourceFrame.bind(this)); 36 this._historyManager = new Sources.EditingLocationHistoryManager(this, this. currentSourceFrame.bind(this));
41 37
42 this._toolbarContainerElement = this.element.createChild('div', 'sources-too lbar'); 38 this._toolbarContainerElement = this.element.createChild('div', 'sources-too lbar');
43 this._toolbarEditorActions = new UI.Toolbar('', this._toolbarContainerElemen t); 39 this._toolbarEditorActions = new UI.Toolbar('', this._toolbarContainerElemen t);
44 40
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 84 }
89 85
90 if (!window.opener) 86 if (!window.opener)
91 window.addEventListener('beforeunload', handleBeforeUnload, true); 87 window.addEventListener('beforeunload', handleBeforeUnload, true);
92 88
93 this._shortcuts = {}; 89 this._shortcuts = {};
94 this.element.addEventListener('keydown', this._handleKeyDown.bind(this), fal se); 90 this.element.addEventListener('keydown', this._handleKeyDown.bind(this), fal se);
95 } 91 }
96 92
97 /** 93 /**
94 * @return {!Element}
95 */
96 _placeholderElement() {
97 var shortcuts = [
98 {actionId: 'quickOpen.show', description: Common.UIString('Open file')},
99 {actionId: 'commandMenu.show', description: Common.UIString('Run command') }
100 ];
101
102 var element = createElementWithClass('span', 'tabbed-pane-placeholder');
103 for (var shortcut of shortcuts) {
104 var shortcutKeyText = UI.shortcutRegistry.shortcutTitleForAction(shortcut. actionId);
105 var row = element.createChild('div', 'tabbed-pane-placeholder-row');
106 row.createChild('div', 'tabbed-pane-placeholder-key').textContent = shortc utKeyText;
107 row.createChild('div', 'tabbed-pane-placeholder-value').textContent = shor tcut.description;
108 }
109 if (Runtime.experiments.isEnabled('persistence2'))
110 element.createChild('div').textContent = Common.UIString('Drop in a folder to add to workspace');
111
112 return element;
113 }
114
115 /**
98 * @return {!Map.<!Workspace.UISourceCode, number>} 116 * @return {!Map.<!Workspace.UISourceCode, number>}
99 */ 117 */
100 static defaultUISourceCodeScores() { 118 static defaultUISourceCodeScores() {
101 /** @type {!Map.<!Workspace.UISourceCode, number>} */ 119 /** @type {!Map.<!Workspace.UISourceCode, number>} */
102 var defaultScores = new Map(); 120 var defaultScores = new Map();
103 var sourcesView = UI.context.flavor(Sources.SourcesView); 121 var sourcesView = UI.context.flavor(Sources.SourcesView);
104 if (sourcesView) { 122 if (sourcesView) {
105 var uiSourceCodes = sourcesView._editorContainer.historyUISourceCodes(); 123 var uiSourceCodes = sourcesView._editorContainer.historyUISourceCodes();
106 for (var i = 1; i < uiSourceCodes.length; ++i) // Skip current element 124 for (var i = 1; i < uiSourceCodes.length; ++i) // Skip current element
107 defaultScores.set(uiSourceCodes[i], uiSourceCodes.length - i); 125 defaultScores.set(uiSourceCodes[i], uiSourceCodes.length - i);
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 * @return {boolean} 773 * @return {boolean}
756 */ 774 */
757 handleAction(context, actionId) { 775 handleAction(context, actionId) {
758 var sourcesView = UI.context.flavor(Sources.SourcesView); 776 var sourcesView = UI.context.flavor(Sources.SourcesView);
759 if (!sourcesView) 777 if (!sourcesView)
760 return false; 778 return false;
761 sourcesView._editorContainer.closeAllFiles(); 779 sourcesView._editorContainer.closeAllFiles();
762 return true; 780 return true;
763 } 781 }
764 }; 782 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698