OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
3 * Use of this source code is governed by a BSD-style license that can be | |
4 * found in the LICENSE file. | |
5 */ | |
6 | |
7 /** | |
8 * @unrestricted | |
9 */ | |
10 Sources.OpenResourceDialog = class extends Sources.FilteredUISourceCodeListDeleg
ate { | |
11 /** | |
12 * @param {!Sources.SourcesView} sourcesView | |
13 * @param {!Map.<!Workspace.UISourceCode, number>} defaultScores | |
14 */ | |
15 constructor(sourcesView, defaultScores) { | |
16 super(defaultScores); | |
17 this._sourcesView = sourcesView; | |
18 this.populate(); | |
19 } | |
20 | |
21 /** | |
22 * @param {!Sources.SourcesView} sourcesView | |
23 * @param {string} query | |
24 * @param {!Map.<!Workspace.UISourceCode, number>} defaultScores | |
25 * @param {!Array<string>} history | |
26 */ | |
27 static show(sourcesView, query, defaultScores, history) { | |
28 var dialog = new Sources.OpenResourceDialog(sourcesView, defaultScores); | |
29 if (InspectorFrontendHost.isUnderTest()) | |
30 Sources.OpenResourceDialog._instanceForTest = dialog; | |
31 var filteredItemSelectionDialog = new QuickOpen.FilteredListWidget(dialog, h
istory); | |
32 filteredItemSelectionDialog.showAsDialog(); | |
33 filteredItemSelectionDialog.setQuery(query); | |
34 } | |
35 | |
36 /** | |
37 * @override | |
38 * @param {?Workspace.UISourceCode} uiSourceCode | |
39 * @param {number=} lineNumber | |
40 * @param {number=} columnNumber | |
41 */ | |
42 uiSourceCodeSelected(uiSourceCode, lineNumber, columnNumber) { | |
43 if (!uiSourceCode) | |
44 uiSourceCode = this._sourcesView.currentUISourceCode(); | |
45 if (!uiSourceCode) | |
46 return; | |
47 this._sourcesView.showSourceLocation(uiSourceCode, lineNumber, columnNumber)
; | |
48 } | |
49 | |
50 /** | |
51 * @override | |
52 * @param {string} query | |
53 * @return {boolean} | |
54 */ | |
55 shouldShowMatchingItems(query) { | |
56 return !query.startsWith(':'); | |
57 } | |
58 | |
59 /** | |
60 * @override | |
61 * @param {!Workspace.Project} project | |
62 * @return {boolean} | |
63 */ | |
64 filterProject(project) { | |
65 return !project.isServiceProject(); | |
66 } | |
67 | |
68 /** | |
69 * @override | |
70 * @return {boolean} | |
71 */ | |
72 renderAsTwoRows() { | |
73 return true; | |
74 } | |
75 }; | |
76 | |
77 | |
78 /** | |
79 * @unrestricted | |
80 */ | |
81 Sources.SelectUISourceCodeForProjectTypesDialog = class extends Sources.Filtered
UISourceCodeListDelegate { | |
82 /** | |
83 * @param {!Array.<string>} types | |
84 * @param {function(?Workspace.UISourceCode)} callback | |
85 */ | |
86 constructor(types, callback) { | |
87 super(); | |
88 this._types = types; | |
89 this._callback = callback; | |
90 this.populate(); | |
91 } | |
92 | |
93 /** | |
94 * @param {string} name | |
95 * @param {!Array.<string>} types | |
96 * @param {function(?Workspace.UISourceCode)} callback | |
97 */ | |
98 static show(name, types, callback) { | |
99 var filteredItemSelectionDialog = | |
100 new QuickOpen.FilteredListWidget(new Sources.SelectUISourceCodeForProjec
tTypesDialog(types, callback)); | |
101 filteredItemSelectionDialog.showAsDialog(); | |
102 filteredItemSelectionDialog.setQuery(name); | |
103 } | |
104 | |
105 /** | |
106 * @override | |
107 * @param {?Workspace.UISourceCode} uiSourceCode | |
108 * @param {number=} lineNumber | |
109 * @param {number=} columnNumber | |
110 */ | |
111 uiSourceCodeSelected(uiSourceCode, lineNumber, columnNumber) { | |
112 this._callback(uiSourceCode); | |
113 } | |
114 | |
115 /** | |
116 * @override | |
117 * @param {!Workspace.Project} project | |
118 * @return {boolean} | |
119 */ | |
120 filterProject(project) { | |
121 return this._types.indexOf(project.type()) !== -1; | |
122 } | |
123 | |
124 /** | |
125 * @override | |
126 * @return {boolean} | |
127 */ | |
128 renderAsTwoRows() { | |
129 return true; | |
130 } | |
131 }; | |
OLD | NEW |