OLD | NEW |
1 /* | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 // Use of this source code is governed by a BSD-style license that can be |
3 * | 3 // found in the LICENSE file. |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions are | |
6 * met: | |
7 * | |
8 * 1. Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * | |
11 * 2. Redistributions in binary form must reproduce the above | |
12 * copyright notice, this list of conditions and the following disclaimer | |
13 * in the documentation and/or other materials provided with the | |
14 * distribution. | |
15 * | |
16 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. AND ITS CONTRIBUTORS | |
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. | |
20 * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
27 */ | |
28 | 4 |
29 /** | 5 /** |
30 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.VBox} |
31 */ | 8 */ |
32 WebInspector.AdvancedSearchController = function() | 9 WebInspector.AdvancedSearchView = function() |
33 { | 10 { |
| 11 WebInspector.VBox.call(this); |
| 12 |
34 this._searchId = 0; | 13 this._searchId = 0; |
35 | 14 |
| 15 this.element.classList.add("search-view"); |
| 16 |
| 17 this._searchPanelElement = this.element.createChild("div", "search-drawer-he
ader"); |
| 18 this._searchPanelElement.addEventListener("keydown", this._onKeyDown.bind(th
is), false); |
| 19 |
| 20 this._searchResultsElement = this.element.createChild("div"); |
| 21 this._searchResultsElement.className = "search-results"; |
| 22 |
| 23 this._search = this._searchPanelElement.createChild("input"); |
| 24 this._search.placeholder = WebInspector.UIString("Search sources"); |
| 25 this._search.setAttribute("type", "text"); |
| 26 this._search.classList.add("search-config-search"); |
| 27 this._search.setAttribute("results", "0"); |
| 28 this._search.setAttribute("size", 30); |
| 29 |
| 30 this._ignoreCaseLabel = this._searchPanelElement.createChild("label"); |
| 31 this._ignoreCaseLabel.classList.add("search-config-label"); |
| 32 this._ignoreCaseCheckbox = this._ignoreCaseLabel.createChild("input"); |
| 33 this._ignoreCaseCheckbox.setAttribute("type", "checkbox"); |
| 34 this._ignoreCaseCheckbox.classList.add("search-config-checkbox"); |
| 35 this._ignoreCaseLabel.appendChild(document.createTextNode(WebInspector.UIStr
ing("Ignore case"))); |
| 36 |
| 37 this._regexLabel = this._searchPanelElement.createChild("label"); |
| 38 this._regexLabel.classList.add("search-config-label"); |
| 39 this._regexCheckbox = this._regexLabel.createChild("input"); |
| 40 this._regexCheckbox.setAttribute("type", "checkbox"); |
| 41 this._regexCheckbox.classList.add("search-config-checkbox"); |
| 42 this._regexLabel.appendChild(document.createTextNode(WebInspector.UIString("
Regular expression"))); |
| 43 |
| 44 this._searchStatusBarElement = this.element.createChild("div", "search-statu
s-bar-summary"); |
| 45 this._searchMessageElement = this._searchStatusBarElement.createChild("span"
); |
| 46 this._searchResultsMessageElement = document.createElement("span"); |
| 47 |
36 WebInspector.settings.advancedSearchConfig = WebInspector.settings.createSet
ting("advancedSearchConfig", new WebInspector.SearchConfig("", true, false).toPl
ainObject()); | 48 WebInspector.settings.advancedSearchConfig = WebInspector.settings.createSet
ting("advancedSearchConfig", new WebInspector.SearchConfig("", true, false).toPl
ainObject()); |
| 49 this._load(); |
37 } | 50 } |
38 | 51 |
39 WebInspector.AdvancedSearchController.prototype = { | 52 WebInspector.AdvancedSearchView.prototype = { |
40 show: function() | 53 /** |
| 54 * @return {!WebInspector.SearchConfig} |
| 55 */ |
| 56 _buildSearchConfig: function() |
| 57 { |
| 58 return new WebInspector.SearchConfig(this._search.value, this._ignoreCas
eCheckbox.checked, this._regexCheckbox.checked); |
| 59 }, |
| 60 |
| 61 toggle: function() |
41 { | 62 { |
42 var selection = window.getSelection(); | 63 var selection = window.getSelection(); |
43 var queryCandidate; | 64 var queryCandidate; |
44 if (selection.rangeCount) | 65 if (selection.rangeCount) |
45 queryCandidate = selection.toString().replace(/\r?\n.*/, ""); | 66 queryCandidate = selection.toString().replace(/\r?\n.*/, ""); |
46 | 67 |
47 if (!this._searchView || !this._searchView.isShowing()) | 68 if (!this.isShowing()) |
48 WebInspector.inspectorView.showViewInDrawer("search"); | 69 WebInspector.inspectorView.showViewInDrawer("search"); |
49 if (queryCandidate) | 70 if (queryCandidate) |
50 this._searchView._search.value = queryCandidate; | 71 this._search.value = queryCandidate; |
51 this._searchView.focus(); | 72 this.focus(); |
52 | 73 |
53 this.startIndexing(); | 74 this._startIndexing(); |
54 }, | 75 }, |
55 | 76 |
56 /** | 77 /** |
57 * @param {boolean} finished | 78 * @param {boolean} finished |
58 */ | 79 */ |
59 _onIndexingFinished: function(finished) | 80 _onIndexingFinished: function(finished) |
60 { | 81 { |
61 delete this._isIndexing; | 82 delete this._isIndexing; |
62 this._searchView.indexingFinished(finished); | 83 this._indexingFinished(finished); |
63 if (!finished) | 84 if (!finished) |
64 delete this._pendingSearchConfig; | 85 delete this._pendingSearchConfig; |
65 if (!this._pendingSearchConfig) | 86 if (!this._pendingSearchConfig) |
66 return; | 87 return; |
67 var searchConfig = this._pendingSearchConfig | 88 var searchConfig = this._pendingSearchConfig |
68 delete this._pendingSearchConfig; | 89 delete this._pendingSearchConfig; |
69 this._innerStartSearch(searchConfig); | 90 this._innerStartSearch(searchConfig); |
70 }, | 91 }, |
71 | 92 |
72 startIndexing: function() | 93 _startIndexing: function() |
73 { | 94 { |
74 this._isIndexing = true; | 95 this._isIndexing = true; |
75 // FIXME: this._currentSearchScope should be initialized based on search
Config | 96 // FIXME: this._currentSearchScope should be initialized based on search
Config |
76 this._currentSearchScope = this._searchScopes()[0]; | 97 this._currentSearchScope = this._searchScopes()[0]; |
77 if (this._progressIndicator) | 98 if (this._progressIndicator) |
78 this._progressIndicator.done(); | 99 this._progressIndicator.done(); |
79 this._progressIndicator = new WebInspector.ProgressIndicator(); | 100 this._progressIndicator = new WebInspector.ProgressIndicator(); |
80 this._searchView.indexingStarted(this._progressIndicator); | 101 this._indexingStarted(this._progressIndicator); |
81 this._currentSearchScope.performIndexing(this._progressIndicator, this._
onIndexingFinished.bind(this)); | 102 this._currentSearchScope.performIndexing(this._progressIndicator, this._
onIndexingFinished.bind(this)); |
82 }, | 103 }, |
83 | 104 |
84 /** | 105 /** |
85 * @param {number} searchId | 106 * @param {number} searchId |
86 * @param {!WebInspector.FileBasedSearchResult} searchResult | 107 * @param {!WebInspector.FileBasedSearchResult} searchResult |
87 */ | 108 */ |
88 _onSearchResult: function(searchId, searchResult) | 109 _onSearchResult: function(searchId, searchResult) |
89 { | 110 { |
90 if (searchId !== this._searchId) | 111 if (searchId !== this._searchId) |
91 return; | 112 return; |
92 this._searchView.addSearchResult(searchResult); | 113 this._addSearchResult(searchResult); |
93 if (!searchResult.searchMatches.length) | 114 if (!searchResult.searchMatches.length) |
94 return; | 115 return; |
95 if (!this._searchResultsPane) | 116 if (!this._searchResultsPane) |
96 this._searchResultsPane = this._currentSearchScope.createSearchResul
tsPane(this._searchConfig); | 117 this._searchResultsPane = this._currentSearchScope.createSearchResul
tsPane(this._searchConfig); |
97 this._searchView.resultsPane = this._searchResultsPane; | 118 this._resetResults(); |
| 119 this._searchResultsElement.appendChild(this._searchResultsPane.element); |
98 this._searchResultsPane.addSearchResult(searchResult); | 120 this._searchResultsPane.addSearchResult(searchResult); |
99 }, | 121 }, |
100 | 122 |
101 /** | 123 /** |
102 * @param {number} searchId | 124 * @param {number} searchId |
103 * @param {boolean} finished | 125 * @param {boolean} finished |
104 */ | 126 */ |
105 _onSearchFinished: function(searchId, finished) | 127 _onSearchFinished: function(searchId, finished) |
106 { | 128 { |
107 if (searchId !== this._searchId) | 129 if (searchId !== this._searchId) |
108 return; | 130 return; |
109 if (!this._searchResultsPane) | 131 if (!this._searchResultsPane) |
110 this._searchView.nothingFound(); | 132 this._nothingFound(); |
111 this._searchView.searchFinished(finished); | 133 this._searchFinished(finished); |
112 delete this._searchConfig; | 134 delete this._searchConfig; |
113 }, | 135 }, |
114 | 136 |
115 /** | 137 /** |
116 * @param {!WebInspector.SearchConfig} searchConfig | 138 * @param {!WebInspector.SearchConfig} searchConfig |
117 */ | 139 */ |
118 startSearch: function(searchConfig) | 140 _startSearch: function(searchConfig) |
119 { | 141 { |
120 this.resetSearch(); | 142 this._resetSearch(); |
121 ++this._searchId; | 143 ++this._searchId; |
122 if (!this._isIndexing) | 144 if (!this._isIndexing) |
123 this.startIndexing(); | 145 this._startIndexing(); |
124 this._pendingSearchConfig = searchConfig; | 146 this._pendingSearchConfig = searchConfig; |
125 }, | 147 }, |
126 | 148 |
127 /** | 149 /** |
128 * @param {!WebInspector.SearchConfig} searchConfig | 150 * @param {!WebInspector.SearchConfig} searchConfig |
129 */ | 151 */ |
130 _innerStartSearch: function(searchConfig) | 152 _innerStartSearch: function(searchConfig) |
131 { | 153 { |
132 this._searchConfig = searchConfig; | 154 this._searchConfig = searchConfig; |
133 // FIXME: this._currentSearchScope should be initialized based on search
Config | 155 // FIXME: this._currentSearchScope should be initialized based on search
Config |
134 this._currentSearchScope = this._searchScopes()[0]; | 156 this._currentSearchScope = this._searchScopes()[0]; |
135 | 157 |
136 if (this._progressIndicator) | 158 if (this._progressIndicator) |
137 this._progressIndicator.done(); | 159 this._progressIndicator.done(); |
138 this._progressIndicator = new WebInspector.ProgressIndicator(); | 160 this._progressIndicator = new WebInspector.ProgressIndicator(); |
139 this._searchView.searchStarted(this._progressIndicator); | 161 this._searchStarted(this._progressIndicator); |
140 this._currentSearchScope.performSearch(searchConfig, this._progressIndic
ator, this._onSearchResult.bind(this, this._searchId), this._onSearchFinished.bi
nd(this, this._searchId)); | 162 this._currentSearchScope.performSearch(searchConfig, this._progressIndic
ator, this._onSearchResult.bind(this, this._searchId), this._onSearchFinished.bi
nd(this, this._searchId)); |
141 }, | 163 }, |
142 | 164 |
143 resetSearch: function() | 165 _resetSearch: function() |
144 { | 166 { |
145 this.stopSearch(); | 167 this._stopSearch(); |
146 | 168 |
147 if (this._searchResultsPane) { | 169 if (this._searchResultsPane) { |
148 this._searchView.resetResults(); | 170 this._resetResults(); |
149 delete this._searchResultsPane; | 171 delete this._searchResultsPane; |
150 } | 172 } |
151 }, | 173 }, |
152 | 174 |
153 stopSearch: function() | 175 _stopSearch: function() |
154 { | 176 { |
155 if (this._progressIndicator) | 177 if (this._progressIndicator) |
156 this._progressIndicator.cancel(); | 178 this._progressIndicator.cancel(); |
157 if (this._currentSearchScope) | 179 if (this._currentSearchScope) |
158 this._currentSearchScope.stopSearch(); | 180 this._currentSearchScope.stopSearch(); |
159 delete this._searchConfig; | 181 delete this._searchConfig; |
160 }, | 182 }, |
161 | 183 |
162 /** | 184 /** |
163 * @return {!Array.<!WebInspector.SearchScope>} | 185 * @return {!Array.<!WebInspector.SearchScope>} |
164 */ | 186 */ |
165 _searchScopes: function() | 187 _searchScopes: function() |
166 { | 188 { |
167 // FIXME: implement multiple search scopes. | 189 // FIXME: implement multiple search scopes. |
168 return /** @type {!Array.<!WebInspector.SearchScope>} */ (WebInspector.m
oduleManager.instances(WebInspector.SearchScope)); | 190 return /** @type {!Array.<!WebInspector.SearchScope>} */ (WebInspector.m
oduleManager.instances(WebInspector.SearchScope)); |
169 } | |
170 } | |
171 | |
172 /** | |
173 * @constructor | |
174 * @extends {WebInspector.VBox} | |
175 */ | |
176 WebInspector.SearchView = function() | |
177 { | |
178 WebInspector.VBox.call(this); | |
179 | |
180 this._controller = WebInspector.advancedSearchController; | |
181 WebInspector.advancedSearchController._searchView = this; | |
182 | |
183 this.element.classList.add("search-view"); | |
184 | |
185 this._searchPanelElement = this.element.createChild("div", "search-drawer-he
ader"); | |
186 this._searchPanelElement.addEventListener("keydown", this._onKeyDown.bind(th
is), false); | |
187 | |
188 this._searchResultsElement = this.element.createChild("div"); | |
189 this._searchResultsElement.className = "search-results"; | |
190 | |
191 this._search = this._searchPanelElement.createChild("input"); | |
192 this._search.placeholder = WebInspector.UIString("Search sources"); | |
193 this._search.setAttribute("type", "text"); | |
194 this._search.classList.add("search-config-search"); | |
195 this._search.setAttribute("results", "0"); | |
196 this._search.setAttribute("size", 30); | |
197 | |
198 this._ignoreCaseLabel = this._searchPanelElement.createChild("label"); | |
199 this._ignoreCaseLabel.classList.add("search-config-label"); | |
200 this._ignoreCaseCheckbox = this._ignoreCaseLabel.createChild("input"); | |
201 this._ignoreCaseCheckbox.setAttribute("type", "checkbox"); | |
202 this._ignoreCaseCheckbox.classList.add("search-config-checkbox"); | |
203 this._ignoreCaseLabel.appendChild(document.createTextNode(WebInspector.UIStr
ing("Ignore case"))); | |
204 | |
205 this._regexLabel = this._searchPanelElement.createChild("label"); | |
206 this._regexLabel.classList.add("search-config-label"); | |
207 this._regexCheckbox = this._regexLabel.createChild("input"); | |
208 this._regexCheckbox.setAttribute("type", "checkbox"); | |
209 this._regexCheckbox.classList.add("search-config-checkbox"); | |
210 this._regexLabel.appendChild(document.createTextNode(WebInspector.UIString("
Regular expression"))); | |
211 | |
212 this._searchStatusBarElement = this.element.createChild("div", "search-statu
s-bar-summary"); | |
213 this._searchMessageElement = this._searchStatusBarElement.createChild("span"
); | |
214 this._searchResultsMessageElement = document.createElement("span"); | |
215 | |
216 this._load(); | |
217 } | |
218 | |
219 WebInspector.SearchView.prototype = { | |
220 /** | |
221 * @return {!WebInspector.SearchConfig} | |
222 */ | |
223 get searchConfig() | |
224 { | |
225 return new WebInspector.SearchConfig(this._search.value, this._ignoreCas
eCheckbox.checked, this._regexCheckbox.checked); | |
226 }, | |
227 | |
228 /** | |
229 * @type {!WebInspector.SearchResultsPane} | |
230 */ | |
231 set resultsPane(resultsPane) | |
232 { | |
233 this.resetResults(); | |
234 this._searchResultsElement.appendChild(resultsPane.element); | |
235 }, | 191 }, |
236 | 192 |
237 /** | 193 /** |
238 * @param {!WebInspector.ProgressIndicator} progressIndicator | 194 * @param {!WebInspector.ProgressIndicator} progressIndicator |
239 */ | 195 */ |
240 searchStarted: function(progressIndicator) | 196 _searchStarted: function(progressIndicator) |
241 { | 197 { |
242 this.resetResults(); | 198 this._resetResults(); |
243 this._resetCounters(); | 199 this._resetCounters(); |
244 | 200 |
245 this._searchMessageElement.textContent = WebInspector.UIString("Searchin
g..."); | 201 this._searchMessageElement.textContent = WebInspector.UIString("Searchin
g..."); |
246 progressIndicator.show(this._searchStatusBarElement); | 202 progressIndicator.show(this._searchStatusBarElement); |
247 this._updateSearchResultsMessage(); | 203 this._updateSearchResultsMessage(); |
248 | 204 |
249 if (!this._searchingView) | 205 if (!this._searchingView) |
250 this._searchingView = new WebInspector.EmptyView(WebInspector.UIStri
ng("Searching...")); | 206 this._searchingView = new WebInspector.EmptyView(WebInspector.UIStri
ng("Searching...")); |
251 this._searchingView.show(this._searchResultsElement); | 207 this._searchingView.show(this._searchResultsElement); |
252 }, | 208 }, |
253 | 209 |
254 /** | 210 /** |
255 * @param {!WebInspector.ProgressIndicator} progressIndicator | 211 * @param {!WebInspector.ProgressIndicator} progressIndicator |
256 */ | 212 */ |
257 indexingStarted: function(progressIndicator) | 213 _indexingStarted: function(progressIndicator) |
258 { | 214 { |
259 this._searchMessageElement.textContent = WebInspector.UIString("Indexing
..."); | 215 this._searchMessageElement.textContent = WebInspector.UIString("Indexing
..."); |
260 progressIndicator.show(this._searchStatusBarElement); | 216 progressIndicator.show(this._searchStatusBarElement); |
261 }, | 217 }, |
262 | 218 |
263 /** | 219 /** |
264 * @param {boolean} finished | 220 * @param {boolean} finished |
265 */ | 221 */ |
266 indexingFinished: function(finished) | 222 _indexingFinished: function(finished) |
267 { | 223 { |
268 this._searchMessageElement.textContent = finished ? "" : WebInspector.UI
String("Indexing interrupted."); | 224 this._searchMessageElement.textContent = finished ? "" : WebInspector.UI
String("Indexing interrupted."); |
269 }, | 225 }, |
270 | 226 |
271 _updateSearchResultsMessage: function() | 227 _updateSearchResultsMessage: function() |
272 { | 228 { |
273 if (this._searchMatchesCount && this._searchResultsCount) | 229 if (this._searchMatchesCount && this._searchResultsCount) |
274 this._searchResultsMessageElement.textContent = WebInspector.UIStrin
g("Found %d matches in %d files.", this._searchMatchesCount, this._nonEmptySearc
hResultsCount); | 230 this._searchResultsMessageElement.textContent = WebInspector.UIStrin
g("Found %d matches in %d files.", this._searchMatchesCount, this._nonEmptySearc
hResultsCount); |
275 else | 231 else |
276 this._searchResultsMessageElement.textContent = ""; | 232 this._searchResultsMessageElement.textContent = ""; |
277 }, | 233 }, |
278 | 234 |
279 resetResults: function() | 235 _resetResults: function() |
280 { | 236 { |
281 if (this._searchingView) | 237 if (this._searchingView) |
282 this._searchingView.detach(); | 238 this._searchingView.detach(); |
283 if (this._notFoundView) | 239 if (this._notFoundView) |
284 this._notFoundView.detach(); | 240 this._notFoundView.detach(); |
285 this._searchResultsElement.removeChildren(); | 241 this._searchResultsElement.removeChildren(); |
286 }, | 242 }, |
287 | 243 |
288 _resetCounters: function() | 244 _resetCounters: function() |
289 { | 245 { |
290 this._searchMatchesCount = 0; | 246 this._searchMatchesCount = 0; |
291 this._searchResultsCount = 0; | 247 this._searchResultsCount = 0; |
292 this._nonEmptySearchResultsCount = 0; | 248 this._nonEmptySearchResultsCount = 0; |
293 }, | 249 }, |
294 | 250 |
295 nothingFound: function() | 251 _nothingFound: function() |
296 { | 252 { |
297 this.resetResults(); | 253 this._resetResults(); |
298 | 254 |
299 if (!this._notFoundView) | 255 if (!this._notFoundView) |
300 this._notFoundView = new WebInspector.EmptyView(WebInspector.UIStrin
g("No matches found.")); | 256 this._notFoundView = new WebInspector.EmptyView(WebInspector.UIStrin
g("No matches found.")); |
301 this._notFoundView.show(this._searchResultsElement); | 257 this._notFoundView.show(this._searchResultsElement); |
302 this._searchResultsMessageElement.textContent = WebInspector.UIString("N
o matches found."); | 258 this._searchResultsMessageElement.textContent = WebInspector.UIString("N
o matches found."); |
303 }, | 259 }, |
304 | 260 |
305 /** | 261 /** |
306 * @param {!WebInspector.FileBasedSearchResult} searchResult | 262 * @param {!WebInspector.FileBasedSearchResult} searchResult |
307 */ | 263 */ |
308 addSearchResult: function(searchResult) | 264 _addSearchResult: function(searchResult) |
309 { | 265 { |
310 this._searchMatchesCount += searchResult.searchMatches.length; | 266 this._searchMatchesCount += searchResult.searchMatches.length; |
311 this._searchResultsCount++; | 267 this._searchResultsCount++; |
312 if (searchResult.searchMatches.length) | 268 if (searchResult.searchMatches.length) |
313 this._nonEmptySearchResultsCount++; | 269 this._nonEmptySearchResultsCount++; |
314 this._updateSearchResultsMessage(); | 270 this._updateSearchResultsMessage(); |
315 }, | 271 }, |
316 | 272 |
317 /** | 273 /** |
318 * @param {boolean} finished | 274 * @param {boolean} finished |
319 */ | 275 */ |
320 searchFinished: function(finished) | 276 _searchFinished: function(finished) |
321 { | 277 { |
322 this._searchMessageElement.textContent = finished ? WebInspector.UIStrin
g("Search finished.") : WebInspector.UIString("Search interrupted."); | 278 this._searchMessageElement.textContent = finished ? WebInspector.UIStrin
g("Search finished.") : WebInspector.UIString("Search interrupted."); |
323 }, | 279 }, |
324 | 280 |
325 focus: function() | 281 focus: function() |
326 { | 282 { |
327 WebInspector.setCurrentFocusElement(this._search); | 283 WebInspector.setCurrentFocusElement(this._search); |
328 this._search.select(); | 284 this._search.select(); |
329 }, | 285 }, |
330 | 286 |
331 willHide: function() | 287 willHide: function() |
332 { | 288 { |
333 this._controller.stopSearch(); | 289 this._stopSearch(); |
334 }, | 290 }, |
335 | 291 |
336 /** | 292 /** |
337 * @param {?Event} event | 293 * @param {?Event} event |
338 */ | 294 */ |
339 _onKeyDown: function(event) | 295 _onKeyDown: function(event) |
340 { | 296 { |
341 switch (event.keyCode) { | 297 switch (event.keyCode) { |
342 case WebInspector.KeyboardShortcut.Keys.Enter.code: | 298 case WebInspector.KeyboardShortcut.Keys.Enter.code: |
343 this._onAction(); | 299 this._onAction(); |
344 break; | 300 break; |
345 } | 301 } |
346 }, | 302 }, |
347 | 303 |
348 _save: function() | 304 _save: function() |
349 { | 305 { |
350 WebInspector.settings.advancedSearchConfig.set(this.searchConfig.toPlain
Object()); | 306 WebInspector.settings.advancedSearchConfig.set(this._buildSearchConfig()
.toPlainObject()); |
351 }, | 307 }, |
352 | 308 |
353 _load: function() | 309 _load: function() |
354 { | 310 { |
355 var searchConfig = WebInspector.SearchConfig.fromPlainObject(WebInspecto
r.settings.advancedSearchConfig.get()); | 311 var searchConfig = WebInspector.SearchConfig.fromPlainObject(WebInspecto
r.settings.advancedSearchConfig.get()); |
356 this._search.value = searchConfig.query(); | 312 this._search.value = searchConfig.query(); |
357 this._ignoreCaseCheckbox.checked = searchConfig.ignoreCase(); | 313 this._ignoreCaseCheckbox.checked = searchConfig.ignoreCase(); |
358 this._regexCheckbox.checked = searchConfig.isRegex(); | 314 this._regexCheckbox.checked = searchConfig.isRegex(); |
359 }, | 315 }, |
360 | 316 |
361 _onAction: function() | 317 _onAction: function() |
362 { | 318 { |
363 var searchConfig = this.searchConfig; | 319 var searchConfig = this._buildSearchConfig(); |
364 if (!searchConfig.query() || !searchConfig.query().length) | 320 if (!searchConfig.query() || !searchConfig.query().length) |
365 return; | 321 return; |
366 | 322 |
367 this._save(); | 323 this._save(); |
368 this._controller.startSearch(searchConfig); | 324 this._startSearch(searchConfig); |
369 }, | 325 }, |
370 | 326 |
371 __proto__: WebInspector.VBox.prototype | 327 __proto__: WebInspector.VBox.prototype |
372 } | 328 } |
373 | 329 |
374 /** | 330 /** |
375 * @constructor | 331 * @constructor |
376 * @param {!WebInspector.ProjectSearchConfig} searchConfig | 332 * @param {!WebInspector.ProjectSearchConfig} searchConfig |
377 */ | 333 */ |
378 WebInspector.SearchResultsPane = function(searchConfig) | 334 WebInspector.SearchResultsPane = function(searchConfig) |
(...skipping 14 matching lines...) Expand all Loading... |
393 /** | 349 /** |
394 * @param {!WebInspector.FileBasedSearchResult} searchResult | 350 * @param {!WebInspector.FileBasedSearchResult} searchResult |
395 */ | 351 */ |
396 addSearchResult: function(searchResult) { } | 352 addSearchResult: function(searchResult) { } |
397 } | 353 } |
398 | 354 |
399 /** | 355 /** |
400 * @constructor | 356 * @constructor |
401 * @implements {WebInspector.ActionDelegate} | 357 * @implements {WebInspector.ActionDelegate} |
402 */ | 358 */ |
403 WebInspector.AdvancedSearchController.ToggleDrawerViewActionDelegate = function(
) | 359 WebInspector.AdvancedSearchView.ToggleDrawerViewActionDelegate = function() |
404 { | 360 { |
405 } | 361 } |
406 | 362 |
407 WebInspector.AdvancedSearchController.ToggleDrawerViewActionDelegate.prototype =
{ | 363 WebInspector.AdvancedSearchView.ToggleDrawerViewActionDelegate.prototype = { |
408 /** | 364 /** |
409 * @param {!Event} event | 365 * @param {!Event} event |
410 * @return {boolean} | 366 * @return {boolean} |
411 */ | 367 */ |
412 handleAction: function(event) | 368 handleAction: function(event) |
413 { | 369 { |
414 if (WebInspector.Dialog.currentInstance()) | 370 if (WebInspector.Dialog.currentInstance()) |
415 return false; | 371 return false; |
416 var searchView = WebInspector.advancedSearchController._searchView; | 372 var searchView = this._searchView(); |
417 if (!searchView || !searchView.isShowing() || searchView._search !== doc
ument.activeElement) { | 373 if (!searchView) |
| 374 return false; |
| 375 if (!searchView.isShowing() || searchView._search !== document.activeEle
ment) { |
418 WebInspector.inspectorView.showPanel("sources"); | 376 WebInspector.inspectorView.showPanel("sources"); |
419 WebInspector.advancedSearchController.show(); | 377 searchView.toggle(); |
420 } else { | 378 } else { |
421 WebInspector.inspectorView.closeDrawer(); | 379 WebInspector.inspectorView.closeDrawer(); |
422 } | 380 } |
423 return true; | 381 return true; |
| 382 }, |
| 383 |
| 384 /** |
| 385 * @return {?WebInspector.AdvancedSearchView} |
| 386 */ |
| 387 _searchView: function() |
| 388 { |
| 389 if (!this._view) { |
| 390 var extensions = WebInspector.moduleManager.extensions("drawer-view"
); |
| 391 for (var i = 0; i < extensions.length; ++i) { |
| 392 if (extensions[i].descriptor()["name"] === "search") { |
| 393 this._view = extensions[i].instance(); |
| 394 break; |
| 395 } |
| 396 } |
| 397 } |
| 398 return this._view; |
424 } | 399 } |
425 } | 400 } |
426 | 401 |
427 | 402 |
428 /** | 403 /** |
429 * @constructor | 404 * @constructor |
430 * @param {!WebInspector.UISourceCode} uiSourceCode | 405 * @param {!WebInspector.UISourceCode} uiSourceCode |
431 * @param {!Array.<!Object>} searchMatches | 406 * @param {!Array.<!Object>} searchMatches |
432 */ | 407 */ |
433 WebInspector.FileBasedSearchResult = function(uiSourceCode, searchMatches) { | 408 WebInspector.FileBasedSearchResult = function(uiSourceCode, searchMatches) { |
(...skipping 25 matching lines...) Expand all Loading... |
459 | 434 |
460 stopSearch: function() { }, | 435 stopSearch: function() { }, |
461 | 436 |
462 /** | 437 /** |
463 * @param {!WebInspector.ProjectSearchConfig} searchConfig | 438 * @param {!WebInspector.ProjectSearchConfig} searchConfig |
464 * @return {!WebInspector.SearchResultsPane} | 439 * @return {!WebInspector.SearchResultsPane} |
465 */ | 440 */ |
466 createSearchResultsPane: function(searchConfig) { } | 441 createSearchResultsPane: function(searchConfig) { } |
467 } | 442 } |
468 | 443 |
469 /** | |
470 * @type {!WebInspector.AdvancedSearchController} | |
471 */ | |
472 WebInspector.advancedSearchController = new WebInspector.AdvancedSearchControlle
r(); | |
473 | |
474 importScript("SearchConfig.js"); | 444 importScript("SearchConfig.js"); |
475 importScript("FileBasedSearchResultsPane.js"); | 445 importScript("FileBasedSearchResultsPane.js"); |
476 importScript("SourcesSearchScope.js"); | 446 importScript("SourcesSearchScope.js"); |
OLD | NEW |