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 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @implements {WebInspector.TabbedEditorContainerDelegate} | 7 * @implements {WebInspector.TabbedEditorContainerDelegate} |
8 * @implements {WebInspector.Searchable} | 8 * @implements {WebInspector.Searchable} |
9 * @implements {WebInspector.Replaceable} | 9 * @implements {WebInspector.Replaceable} |
10 * @extends {WebInspector.VBox} | 10 * @extends {WebInspector.VBox} |
11 * @param {!WebInspector.Workspace} workspace | 11 * @param {!WebInspector.Workspace} workspace |
12 * @param {!WebInspector.SourcesPanel} sourcesPanel | 12 * @param {!WebInspector.SourcesPanel} sourcesPanel |
13 * @suppressGlobalPropertiesCheck | 13 * @suppressGlobalPropertiesCheck |
14 */ | 14 */ |
15 WebInspector.SourcesView = function(workspace, sourcesPanel) | 15 WebInspector.SourcesView = function(workspace, sourcesPanel) |
16 { | 16 { |
17 WebInspector.VBox.call(this); | 17 WebInspector.VBox.call(this); |
18 this.registerRequiredCSS("sources/sourcesView.css"); | 18 this.registerRequiredCSS("sources/sourcesView.css"); |
19 this.element.id = "sources-panel-sources-view"; | 19 this.element.id = "sources-panel-sources-view"; |
20 this.setMinimumAndPreferredSizes(50, 52, 150, 100); | 20 this.setMinimumAndPreferredSizes(50, 52, 150, 100); |
21 | 21 |
22 this._workspace = workspace; | 22 this._workspace = workspace; |
23 this._sourcesPanel = sourcesPanel; | 23 this._sourcesPanel = sourcesPanel; |
24 | 24 |
25 this._searchableView = new WebInspector.SearchableView(this, "sourcesViewSea
rchConfig"); | 25 this._searchableView = new WebInspector.SearchableView(this, "sourcesViewSea
rchConfig"); |
26 this._searchableView.setMinimalSearchQuerySize(0); | 26 this._searchableView.setMinimalSearchQuerySize(0); |
27 this._searchableView.show(this.element); | 27 this._searchableView.show(this.element); |
28 | 28 |
29 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.VBoxWithToolbarIt
ems>} */ | 29 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.Widget>} */ |
30 this._sourceViewByUISourceCode = new Map(); | 30 this._sourceViewByUISourceCode = new Map(); |
31 | 31 |
32 var tabbedEditorPlaceholderText = WebInspector.isMac() ? WebInspector.UIStri
ng("Hit Cmd+P to open a file") : WebInspector.UIString("Hit Ctrl+P to open a fil
e"); | 32 var tabbedEditorPlaceholderText = WebInspector.isMac() ? WebInspector.UIStri
ng("Hit Cmd+P to open a file") : WebInspector.UIString("Hit Ctrl+P to open a fil
e"); |
33 this._editorContainer = new WebInspector.TabbedEditorContainer(this, WebInsp
ector.settings.createLocalSetting("previouslyViewedFiles", []), tabbedEditorPlac
eholderText); | 33 this._editorContainer = new WebInspector.TabbedEditorContainer(this, WebInsp
ector.settings.createLocalSetting("previouslyViewedFiles", []), tabbedEditorPlac
eholderText); |
34 this._editorContainer.show(this._searchableView.element); | 34 this._editorContainer.show(this._searchableView.element); |
35 this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Ev
ents.EditorSelected, this._editorSelected, this); | 35 this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Ev
ents.EditorSelected, this._editorSelected, this); |
36 this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Ev
ents.EditorClosed, this._editorClosed, this); | 36 this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Ev
ents.EditorClosed, this._editorClosed, this); |
37 | 37 |
38 this._historyManager = new WebInspector.EditingLocationHistoryManager(this,
this.currentSourceFrame.bind(this)); | 38 this._historyManager = new WebInspector.EditingLocationHistoryManager(this,
this.currentSourceFrame.bind(this)); |
39 | 39 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 _projectRemoved: function(event) | 274 _projectRemoved: function(event) |
275 { | 275 { |
276 var project = event.data; | 276 var project = event.data; |
277 var uiSourceCodes = project.uiSourceCodes(); | 277 var uiSourceCodes = project.uiSourceCodes(); |
278 this._removeUISourceCodes(uiSourceCodes); | 278 this._removeUISourceCodes(uiSourceCodes); |
279 }, | 279 }, |
280 | 280 |
281 _updateScriptViewToolbarItems: function() | 281 _updateScriptViewToolbarItems: function() |
282 { | 282 { |
283 this._scriptViewToolbar.removeToolbarItems(); | 283 this._scriptViewToolbar.removeToolbarItems(); |
284 var view = /** @type {?WebInspector.VBoxWithToolbarItems} */(this.visibl
eView()); | 284 var view = this.visibleView() |
285 if (view) { | 285 if (view instanceof WebInspector.VBoxWithToolbarItems) { |
286 for (var item of view.toolbarItems()) | 286 for (var item of (/** @type {?WebInspector.VBoxWithToolbarItems} */(
view)).toolbarItems()) |
287 this._scriptViewToolbar.appendToolbarItem(item); | 287 this._scriptViewToolbar.appendToolbarItem(item); |
288 } | 288 } |
289 }, | 289 }, |
290 | 290 |
291 /** | 291 /** |
292 * @param {!WebInspector.UISourceCode} uiSourceCode | 292 * @param {!WebInspector.UISourceCode} uiSourceCode |
293 * @param {number=} lineNumber 0-based | 293 * @param {number=} lineNumber 0-based |
294 * @param {number=} columnNumber | 294 * @param {number=} columnNumber |
295 * @param {boolean=} omitFocus | 295 * @param {boolean=} omitFocus |
296 * @param {boolean=} omitHighlight | 296 * @param {boolean=} omitHighlight |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 sourceView = new WebInspector.ImageView(WebInspector.NetworkProject.
uiSourceCodeMimeType(uiSourceCode), uiSourceCode); | 349 sourceView = new WebInspector.ImageView(WebInspector.NetworkProject.
uiSourceCodeMimeType(uiSourceCode), uiSourceCode); |
350 else if (contentType === WebInspector.resourceTypes.Font) | 350 else if (contentType === WebInspector.resourceTypes.Font) |
351 sourceView = new WebInspector.FontView(WebInspector.NetworkProject.u
iSourceCodeMimeType(uiSourceCode), uiSourceCode); | 351 sourceView = new WebInspector.FontView(WebInspector.NetworkProject.u
iSourceCodeMimeType(uiSourceCode), uiSourceCode); |
352 else | 352 else |
353 sourceFrame = new WebInspector.UISourceCodeFrame(uiSourceCode); | 353 sourceFrame = new WebInspector.UISourceCodeFrame(uiSourceCode); |
354 | 354 |
355 if (sourceFrame) { | 355 if (sourceFrame) { |
356 sourceFrame.setHighlighterType(WebInspector.NetworkProject.uiSourceC
odeMimeType(uiSourceCode)); | 356 sourceFrame.setHighlighterType(WebInspector.NetworkProject.uiSourceC
odeMimeType(uiSourceCode)); |
357 this._historyManager.trackSourceFrameCursorJumps(sourceFrame); | 357 this._historyManager.trackSourceFrameCursorJumps(sourceFrame); |
358 } | 358 } |
359 this._sourceViewByUISourceCode.set(uiSourceCode, /** @type {!WebInspecto
r.VBoxWithToolbarItems} */(sourceFrame || sourceView)); | 359 this._sourceViewByUISourceCode.set(uiSourceCode, /** @type {!WebInspecto
r.Widget} */(sourceFrame || sourceView)); |
360 return /** @type {!WebInspector.Widget} */(sourceFrame || sourceView); | 360 return /** @type {!WebInspector.Widget} */(sourceFrame || sourceView); |
361 }, | 361 }, |
362 | 362 |
363 /** | 363 /** |
364 * @param {!WebInspector.UISourceCode} uiSourceCode | 364 * @param {!WebInspector.UISourceCode} uiSourceCode |
365 * @return {!WebInspector.Widget} | 365 * @return {!WebInspector.Widget} |
366 */ | 366 */ |
367 _getOrCreateSourceView: function(uiSourceCode) | 367 _getOrCreateSourceView: function(uiSourceCode) |
368 { | 368 { |
369 return this._sourceViewByUISourceCode.get(uiSourceCode) || this._createS
ourceView(uiSourceCode); | 369 return this._sourceViewByUISourceCode.get(uiSourceCode) || this._createS
ourceView(uiSourceCode); |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 */ | 804 */ |
805 handleAction: function(context, actionId) | 805 handleAction: function(context, actionId) |
806 { | 806 { |
807 var sourcesView = WebInspector.context.flavor(WebInspector.SourcesView); | 807 var sourcesView = WebInspector.context.flavor(WebInspector.SourcesView); |
808 if (!sourcesView) | 808 if (!sourcesView) |
809 return false; | 809 return false; |
810 sourcesView._editorContainer.closeAllFiles(); | 810 sourcesView._editorContainer.closeAllFiles(); |
811 return true; | 811 return true; |
812 } | 812 } |
813 } | 813 } |
OLD | NEW |