| 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 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 WebInspector.AdvancedSearchView = class extends WebInspector.VBox { | 7 Sources.AdvancedSearchView = class extends UI.VBox { |
| 8 constructor() { | 8 constructor() { |
| 9 super(true); | 9 super(true); |
| 10 this.setMinimumSize(0, 40); | 10 this.setMinimumSize(0, 40); |
| 11 this.registerRequiredCSS('sources/sourcesSearch.css'); | 11 this.registerRequiredCSS('sources/sourcesSearch.css'); |
| 12 | 12 |
| 13 this._searchId = 0; | 13 this._searchId = 0; |
| 14 | 14 |
| 15 this.contentElement.classList.add('search-view'); | 15 this.contentElement.classList.add('search-view'); |
| 16 | 16 |
| 17 this._searchPanelElement = this.contentElement.createChild('div', 'search-dr
awer-header'); | 17 this._searchPanelElement = this.contentElement.createChild('div', 'search-dr
awer-header'); |
| 18 this._searchPanelElement.addEventListener('keydown', this._onKeyDown.bind(th
is), false); | 18 this._searchPanelElement.addEventListener('keydown', this._onKeyDown.bind(th
is), false); |
| 19 this._searchPanelElement.addEventListener('input', this._onInput.bind(this),
false); | 19 this._searchPanelElement.addEventListener('input', this._onInput.bind(this),
false); |
| 20 | 20 |
| 21 this._searchResultsElement = this.contentElement.createChild('div'); | 21 this._searchResultsElement = this.contentElement.createChild('div'); |
| 22 this._searchResultsElement.className = 'search-results'; | 22 this._searchResultsElement.className = 'search-results'; |
| 23 | 23 |
| 24 this._search = WebInspector.HistoryInput.create(); | 24 this._search = UI.HistoryInput.create(); |
| 25 this._searchPanelElement.appendChild(this._search); | 25 this._searchPanelElement.appendChild(this._search); |
| 26 this._search.placeholder = WebInspector.UIString('Search all sources (use "f
ile:" to filter by path)\u200e'); | 26 this._search.placeholder = Common.UIString('Search all sources (use "file:"
to filter by path)\u200e'); |
| 27 this._search.setAttribute('type', 'text'); | 27 this._search.setAttribute('type', 'text'); |
| 28 this._search.classList.add('search-config-search'); | 28 this._search.classList.add('search-config-search'); |
| 29 this._search.setAttribute('results', '0'); | 29 this._search.setAttribute('results', '0'); |
| 30 this._search.setAttribute('size', 42); | 30 this._search.setAttribute('size', 42); |
| 31 | 31 |
| 32 this._searchPanelElement.createChild('div', 'search-icon'); | 32 this._searchPanelElement.createChild('div', 'search-icon'); |
| 33 this._searchInputClearElement = this._searchPanelElement.createChild('div',
'search-cancel-button'); | 33 this._searchInputClearElement = this._searchPanelElement.createChild('div',
'search-cancel-button'); |
| 34 this._searchInputClearElement.hidden = true; | 34 this._searchInputClearElement.hidden = true; |
| 35 this._searchInputClearElement.addEventListener('click', this._onSearchInputC
lear.bind(this), false); | 35 this._searchInputClearElement.addEventListener('click', this._onSearchInputC
lear.bind(this), false); |
| 36 | 36 |
| 37 this._ignoreCaseLabel = createCheckboxLabel(WebInspector.UIString('Ignore ca
se')); | 37 this._ignoreCaseLabel = createCheckboxLabel(Common.UIString('Ignore case')); |
| 38 this._ignoreCaseLabel.classList.add('search-config-label'); | 38 this._ignoreCaseLabel.classList.add('search-config-label'); |
| 39 this._searchPanelElement.appendChild(this._ignoreCaseLabel); | 39 this._searchPanelElement.appendChild(this._ignoreCaseLabel); |
| 40 this._ignoreCaseCheckbox = this._ignoreCaseLabel.checkboxElement; | 40 this._ignoreCaseCheckbox = this._ignoreCaseLabel.checkboxElement; |
| 41 this._ignoreCaseCheckbox.classList.add('search-config-checkbox'); | 41 this._ignoreCaseCheckbox.classList.add('search-config-checkbox'); |
| 42 | 42 |
| 43 this._regexLabel = createCheckboxLabel(WebInspector.UIString('Regular expres
sion')); | 43 this._regexLabel = createCheckboxLabel(Common.UIString('Regular expression')
); |
| 44 this._regexLabel.classList.add('search-config-label'); | 44 this._regexLabel.classList.add('search-config-label'); |
| 45 this._searchPanelElement.appendChild(this._regexLabel); | 45 this._searchPanelElement.appendChild(this._regexLabel); |
| 46 this._regexCheckbox = this._regexLabel.checkboxElement; | 46 this._regexCheckbox = this._regexLabel.checkboxElement; |
| 47 this._regexCheckbox.classList.add('search-config-checkbox'); | 47 this._regexCheckbox.classList.add('search-config-checkbox'); |
| 48 | 48 |
| 49 this._searchToolbarElement = this.contentElement.createChild('div', 'search-
toolbar-summary'); | 49 this._searchToolbarElement = this.contentElement.createChild('div', 'search-
toolbar-summary'); |
| 50 this._searchMessageElement = this._searchToolbarElement.createChild('div', '
search-message'); | 50 this._searchMessageElement = this._searchToolbarElement.createChild('div', '
search-message'); |
| 51 this._searchProgressPlaceholderElement = this._searchToolbarElement.createCh
ild('div', 'flex-centered'); | 51 this._searchProgressPlaceholderElement = this._searchToolbarElement.createCh
ild('div', 'flex-centered'); |
| 52 this._searchResultsMessageElement = this._searchToolbarElement.createChild('
div', 'search-message'); | 52 this._searchResultsMessageElement = this._searchToolbarElement.createChild('
div', 'search-message'); |
| 53 | 53 |
| 54 this._advancedSearchConfig = WebInspector.settings.createLocalSetting( | 54 this._advancedSearchConfig = Common.settings.createLocalSetting( |
| 55 'advancedSearchConfig', new WebInspector.SearchConfig('', true, false).t
oPlainObject()); | 55 'advancedSearchConfig', new Workspace.SearchConfig('', true, false).toPl
ainObject()); |
| 56 this._load(); | 56 this._load(); |
| 57 /** @type {!WebInspector.SearchScope} */ | 57 /** @type {!Sources.SearchScope} */ |
| 58 this._searchScope = new WebInspector.SourcesSearchScope(); | 58 this._searchScope = new Sources.SourcesSearchScope(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 /** | 61 /** |
| 62 * @param {string} query | 62 * @param {string} query |
| 63 * @param {string=} filePath | 63 * @param {string=} filePath |
| 64 */ | 64 */ |
| 65 static openSearch(query, filePath) { | 65 static openSearch(query, filePath) { |
| 66 WebInspector.viewManager.showView('sources.search'); | 66 UI.viewManager.showView('sources.search'); |
| 67 var searchView = | 67 var searchView = |
| 68 /** @type {!WebInspector.AdvancedSearchView} */ (self.runtime.sharedInst
ance(WebInspector.AdvancedSearchView)); | 68 /** @type {!Sources.AdvancedSearchView} */ (self.runtime.sharedInstance(
Sources.AdvancedSearchView)); |
| 69 var fileMask = filePath ? ' file:' + filePath : ''; | 69 var fileMask = filePath ? ' file:' + filePath : ''; |
| 70 searchView._toggle(query + fileMask); | 70 searchView._toggle(query + fileMask); |
| 71 } | 71 } |
| 72 | 72 |
| 73 /** | 73 /** |
| 74 * @return {!WebInspector.SearchConfig} | 74 * @return {!Workspace.SearchConfig} |
| 75 */ | 75 */ |
| 76 _buildSearchConfig() { | 76 _buildSearchConfig() { |
| 77 return new WebInspector.SearchConfig( | 77 return new Workspace.SearchConfig( |
| 78 this._search.value, this._ignoreCaseCheckbox.checked, this._regexCheckbo
x.checked); | 78 this._search.value, this._ignoreCaseCheckbox.checked, this._regexCheckbo
x.checked); |
| 79 } | 79 } |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * @param {string} queryCandidate | 82 * @param {string} queryCandidate |
| 83 */ | 83 */ |
| 84 _toggle(queryCandidate) { | 84 _toggle(queryCandidate) { |
| 85 if (queryCandidate) | 85 if (queryCandidate) |
| 86 this._search.value = queryCandidate; | 86 this._search.value = queryCandidate; |
| 87 | 87 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 115 return; | 115 return; |
| 116 var searchConfig = this._pendingSearchConfig; | 116 var searchConfig = this._pendingSearchConfig; |
| 117 delete this._pendingSearchConfig; | 117 delete this._pendingSearchConfig; |
| 118 this._innerStartSearch(searchConfig); | 118 this._innerStartSearch(searchConfig); |
| 119 } | 119 } |
| 120 | 120 |
| 121 _startIndexing() { | 121 _startIndexing() { |
| 122 this._isIndexing = true; | 122 this._isIndexing = true; |
| 123 if (this._progressIndicator) | 123 if (this._progressIndicator) |
| 124 this._progressIndicator.done(); | 124 this._progressIndicator.done(); |
| 125 this._progressIndicator = new WebInspector.ProgressIndicator(); | 125 this._progressIndicator = new UI.ProgressIndicator(); |
| 126 this._searchMessageElement.textContent = WebInspector.UIString('Indexing\u20
26'); | 126 this._searchMessageElement.textContent = Common.UIString('Indexing\u2026'); |
| 127 this._progressIndicator.show(this._searchProgressPlaceholderElement); | 127 this._progressIndicator.show(this._searchProgressPlaceholderElement); |
| 128 this._searchScope.performIndexing( | 128 this._searchScope.performIndexing( |
| 129 new WebInspector.ProgressProxy(this._progressIndicator, this._onIndexing
Finished.bind(this))); | 129 new Common.ProgressProxy(this._progressIndicator, this._onIndexingFinish
ed.bind(this))); |
| 130 } | 130 } |
| 131 | 131 |
| 132 _onSearchInputClear() { | 132 _onSearchInputClear() { |
| 133 this._search.value = ''; | 133 this._search.value = ''; |
| 134 this.focus(); | 134 this.focus(); |
| 135 this._searchInputClearElement.hidden = true; | 135 this._searchInputClearElement.hidden = true; |
| 136 } | 136 } |
| 137 | 137 |
| 138 /** | 138 /** |
| 139 * @param {number} searchId | 139 * @param {number} searchId |
| 140 * @param {!WebInspector.FileBasedSearchResult} searchResult | 140 * @param {!Sources.FileBasedSearchResult} searchResult |
| 141 */ | 141 */ |
| 142 _onSearchResult(searchId, searchResult) { | 142 _onSearchResult(searchId, searchResult) { |
| 143 if (searchId !== this._searchId || !this._progressIndicator) | 143 if (searchId !== this._searchId || !this._progressIndicator) |
| 144 return; | 144 return; |
| 145 if (this._progressIndicator && this._progressIndicator.isCanceled()) { | 145 if (this._progressIndicator && this._progressIndicator.isCanceled()) { |
| 146 this._onIndexingFinished(); | 146 this._onIndexingFinished(); |
| 147 return; | 147 return; |
| 148 } | 148 } |
| 149 this._addSearchResult(searchResult); | 149 this._addSearchResult(searchResult); |
| 150 if (!searchResult.searchMatches.length) | 150 if (!searchResult.searchMatches.length) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 163 _onSearchFinished(searchId, finished) { | 163 _onSearchFinished(searchId, finished) { |
| 164 if (searchId !== this._searchId || !this._progressIndicator) | 164 if (searchId !== this._searchId || !this._progressIndicator) |
| 165 return; | 165 return; |
| 166 if (!this._searchResultsPane) | 166 if (!this._searchResultsPane) |
| 167 this._nothingFound(); | 167 this._nothingFound(); |
| 168 this._searchFinished(finished); | 168 this._searchFinished(finished); |
| 169 delete this._searchConfig; | 169 delete this._searchConfig; |
| 170 } | 170 } |
| 171 | 171 |
| 172 /** | 172 /** |
| 173 * @param {!WebInspector.SearchConfig} searchConfig | 173 * @param {!Workspace.SearchConfig} searchConfig |
| 174 */ | 174 */ |
| 175 _startSearch(searchConfig) { | 175 _startSearch(searchConfig) { |
| 176 this._resetSearch(); | 176 this._resetSearch(); |
| 177 ++this._searchId; | 177 ++this._searchId; |
| 178 if (!this._isIndexing) | 178 if (!this._isIndexing) |
| 179 this._startIndexing(); | 179 this._startIndexing(); |
| 180 this._pendingSearchConfig = searchConfig; | 180 this._pendingSearchConfig = searchConfig; |
| 181 } | 181 } |
| 182 | 182 |
| 183 /** | 183 /** |
| 184 * @param {!WebInspector.SearchConfig} searchConfig | 184 * @param {!Workspace.SearchConfig} searchConfig |
| 185 */ | 185 */ |
| 186 _innerStartSearch(searchConfig) { | 186 _innerStartSearch(searchConfig) { |
| 187 this._searchConfig = searchConfig; | 187 this._searchConfig = searchConfig; |
| 188 if (this._progressIndicator) | 188 if (this._progressIndicator) |
| 189 this._progressIndicator.done(); | 189 this._progressIndicator.done(); |
| 190 this._progressIndicator = new WebInspector.ProgressIndicator(); | 190 this._progressIndicator = new UI.ProgressIndicator(); |
| 191 this._searchStarted(this._progressIndicator); | 191 this._searchStarted(this._progressIndicator); |
| 192 this._searchScope.performSearch( | 192 this._searchScope.performSearch( |
| 193 searchConfig, this._progressIndicator, this._onSearchResult.bind(this, t
his._searchId), | 193 searchConfig, this._progressIndicator, this._onSearchResult.bind(this, t
his._searchId), |
| 194 this._onSearchFinished.bind(this, this._searchId)); | 194 this._onSearchFinished.bind(this, this._searchId)); |
| 195 } | 195 } |
| 196 | 196 |
| 197 _resetSearch() { | 197 _resetSearch() { |
| 198 this._stopSearch(); | 198 this._stopSearch(); |
| 199 | 199 |
| 200 if (this._searchResultsPane) { | 200 if (this._searchResultsPane) { |
| 201 this._resetResults(); | 201 this._resetResults(); |
| 202 delete this._searchResultsPane; | 202 delete this._searchResultsPane; |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 _stopSearch() { | 206 _stopSearch() { |
| 207 if (this._progressIndicator && !this._isIndexing) | 207 if (this._progressIndicator && !this._isIndexing) |
| 208 this._progressIndicator.cancel(); | 208 this._progressIndicator.cancel(); |
| 209 if (this._searchScope) | 209 if (this._searchScope) |
| 210 this._searchScope.stopSearch(); | 210 this._searchScope.stopSearch(); |
| 211 delete this._searchConfig; | 211 delete this._searchConfig; |
| 212 } | 212 } |
| 213 | 213 |
| 214 /** | 214 /** |
| 215 * @param {!WebInspector.ProgressIndicator} progressIndicator | 215 * @param {!UI.ProgressIndicator} progressIndicator |
| 216 */ | 216 */ |
| 217 _searchStarted(progressIndicator) { | 217 _searchStarted(progressIndicator) { |
| 218 this._resetResults(); | 218 this._resetResults(); |
| 219 this._resetCounters(); | 219 this._resetCounters(); |
| 220 | 220 |
| 221 this._searchMessageElement.textContent = WebInspector.UIString('Searching\u2
026'); | 221 this._searchMessageElement.textContent = Common.UIString('Searching\u2026'); |
| 222 progressIndicator.show(this._searchProgressPlaceholderElement); | 222 progressIndicator.show(this._searchProgressPlaceholderElement); |
| 223 this._updateSearchResultsMessage(); | 223 this._updateSearchResultsMessage(); |
| 224 | 224 |
| 225 if (!this._searchingView) | 225 if (!this._searchingView) |
| 226 this._searchingView = new WebInspector.EmptyWidget(WebInspector.UIString('
Searching\u2026')); | 226 this._searchingView = new UI.EmptyWidget(Common.UIString('Searching\u2026'
)); |
| 227 this._searchingView.show(this._searchResultsElement); | 227 this._searchingView.show(this._searchResultsElement); |
| 228 } | 228 } |
| 229 | 229 |
| 230 /** | 230 /** |
| 231 * @param {boolean} finished | 231 * @param {boolean} finished |
| 232 */ | 232 */ |
| 233 _indexingFinished(finished) { | 233 _indexingFinished(finished) { |
| 234 this._searchMessageElement.textContent = finished ? '' : WebInspector.UIStri
ng('Indexing interrupted.'); | 234 this._searchMessageElement.textContent = finished ? '' : Common.UIString('In
dexing interrupted.'); |
| 235 } | 235 } |
| 236 | 236 |
| 237 _updateSearchResultsMessage() { | 237 _updateSearchResultsMessage() { |
| 238 if (this._searchMatchesCount && this._searchResultsCount) | 238 if (this._searchMatchesCount && this._searchResultsCount) |
| 239 this._searchResultsMessageElement.textContent = WebInspector.UIString( | 239 this._searchResultsMessageElement.textContent = Common.UIString( |
| 240 'Found %d matches in %d files.', this._searchMatchesCount, this._nonEm
ptySearchResultsCount); | 240 'Found %d matches in %d files.', this._searchMatchesCount, this._nonEm
ptySearchResultsCount); |
| 241 else | 241 else |
| 242 this._searchResultsMessageElement.textContent = ''; | 242 this._searchResultsMessageElement.textContent = ''; |
| 243 } | 243 } |
| 244 | 244 |
| 245 _resetResults() { | 245 _resetResults() { |
| 246 if (this._searchingView) | 246 if (this._searchingView) |
| 247 this._searchingView.detach(); | 247 this._searchingView.detach(); |
| 248 if (this._notFoundView) | 248 if (this._notFoundView) |
| 249 this._notFoundView.detach(); | 249 this._notFoundView.detach(); |
| 250 this._searchResultsElement.removeChildren(); | 250 this._searchResultsElement.removeChildren(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 _resetCounters() { | 253 _resetCounters() { |
| 254 this._searchMatchesCount = 0; | 254 this._searchMatchesCount = 0; |
| 255 this._searchResultsCount = 0; | 255 this._searchResultsCount = 0; |
| 256 this._nonEmptySearchResultsCount = 0; | 256 this._nonEmptySearchResultsCount = 0; |
| 257 } | 257 } |
| 258 | 258 |
| 259 _nothingFound() { | 259 _nothingFound() { |
| 260 this._resetResults(); | 260 this._resetResults(); |
| 261 | 261 |
| 262 if (!this._notFoundView) | 262 if (!this._notFoundView) |
| 263 this._notFoundView = new WebInspector.EmptyWidget(WebInspector.UIString('N
o matches found.')); | 263 this._notFoundView = new UI.EmptyWidget(Common.UIString('No matches found.
')); |
| 264 this._notFoundView.show(this._searchResultsElement); | 264 this._notFoundView.show(this._searchResultsElement); |
| 265 this._searchResultsMessageElement.textContent = WebInspector.UIString('No ma
tches found.'); | 265 this._searchResultsMessageElement.textContent = Common.UIString('No matches
found.'); |
| 266 } | 266 } |
| 267 | 267 |
| 268 /** | 268 /** |
| 269 * @param {!WebInspector.FileBasedSearchResult} searchResult | 269 * @param {!Sources.FileBasedSearchResult} searchResult |
| 270 */ | 270 */ |
| 271 _addSearchResult(searchResult) { | 271 _addSearchResult(searchResult) { |
| 272 this._searchMatchesCount += searchResult.searchMatches.length; | 272 this._searchMatchesCount += searchResult.searchMatches.length; |
| 273 this._searchResultsCount++; | 273 this._searchResultsCount++; |
| 274 if (searchResult.searchMatches.length) | 274 if (searchResult.searchMatches.length) |
| 275 this._nonEmptySearchResultsCount++; | 275 this._nonEmptySearchResultsCount++; |
| 276 this._updateSearchResultsMessage(); | 276 this._updateSearchResultsMessage(); |
| 277 } | 277 } |
| 278 | 278 |
| 279 /** | 279 /** |
| 280 * @param {boolean} finished | 280 * @param {boolean} finished |
| 281 */ | 281 */ |
| 282 _searchFinished(finished) { | 282 _searchFinished(finished) { |
| 283 this._searchMessageElement.textContent = | 283 this._searchMessageElement.textContent = |
| 284 finished ? WebInspector.UIString('Search finished.') : WebInspector.UISt
ring('Search interrupted.'); | 284 finished ? Common.UIString('Search finished.') : Common.UIString('Search
interrupted.'); |
| 285 } | 285 } |
| 286 | 286 |
| 287 /** | 287 /** |
| 288 * @override | 288 * @override |
| 289 */ | 289 */ |
| 290 focus() { | 290 focus() { |
| 291 this._search.focus(); | 291 this._search.focus(); |
| 292 this._search.select(); | 292 this._search.select(); |
| 293 } | 293 } |
| 294 | 294 |
| 295 /** | 295 /** |
| 296 * @override | 296 * @override |
| 297 */ | 297 */ |
| 298 willHide() { | 298 willHide() { |
| 299 this._stopSearch(); | 299 this._stopSearch(); |
| 300 } | 300 } |
| 301 | 301 |
| 302 /** | 302 /** |
| 303 * @param {!Event} event | 303 * @param {!Event} event |
| 304 */ | 304 */ |
| 305 _onKeyDown(event) { | 305 _onKeyDown(event) { |
| 306 switch (event.keyCode) { | 306 switch (event.keyCode) { |
| 307 case WebInspector.KeyboardShortcut.Keys.Enter.code: | 307 case UI.KeyboardShortcut.Keys.Enter.code: |
| 308 this._onAction(); | 308 this._onAction(); |
| 309 break; | 309 break; |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 | 312 |
| 313 _onInput() { | 313 _onInput() { |
| 314 if (this._search.value && this._search.value.length) | 314 if (this._search.value && this._search.value.length) |
| 315 this._searchInputClearElement.hidden = false; | 315 this._searchInputClearElement.hidden = false; |
| 316 else | 316 else |
| 317 this._searchInputClearElement.hidden = true; | 317 this._searchInputClearElement.hidden = true; |
| 318 } | 318 } |
| 319 | 319 |
| 320 _save() { | 320 _save() { |
| 321 this._advancedSearchConfig.set(this._buildSearchConfig().toPlainObject()); | 321 this._advancedSearchConfig.set(this._buildSearchConfig().toPlainObject()); |
| 322 } | 322 } |
| 323 | 323 |
| 324 _load() { | 324 _load() { |
| 325 var searchConfig = WebInspector.SearchConfig.fromPlainObject(this._advancedS
earchConfig.get()); | 325 var searchConfig = Workspace.SearchConfig.fromPlainObject(this._advancedSear
chConfig.get()); |
| 326 this._search.value = searchConfig.query(); | 326 this._search.value = searchConfig.query(); |
| 327 this._ignoreCaseCheckbox.checked = searchConfig.ignoreCase(); | 327 this._ignoreCaseCheckbox.checked = searchConfig.ignoreCase(); |
| 328 this._regexCheckbox.checked = searchConfig.isRegex(); | 328 this._regexCheckbox.checked = searchConfig.isRegex(); |
| 329 if (this._search.value && this._search.value.length) | 329 if (this._search.value && this._search.value.length) |
| 330 this._searchInputClearElement.hidden = false; | 330 this._searchInputClearElement.hidden = false; |
| 331 } | 331 } |
| 332 | 332 |
| 333 _onAction() { | 333 _onAction() { |
| 334 var searchConfig = this._buildSearchConfig(); | 334 var searchConfig = this._buildSearchConfig(); |
| 335 if (!searchConfig.query() || !searchConfig.query().length) | 335 if (!searchConfig.query() || !searchConfig.query().length) |
| 336 return; | 336 return; |
| 337 | 337 |
| 338 this._save(); | 338 this._save(); |
| 339 this._startSearch(searchConfig); | 339 this._startSearch(searchConfig); |
| 340 } | 340 } |
| 341 }; | 341 }; |
| 342 | 342 |
| 343 | 343 |
| 344 /** | 344 /** |
| 345 * @unrestricted | 345 * @unrestricted |
| 346 */ | 346 */ |
| 347 WebInspector.SearchResultsPane = class { | 347 Sources.SearchResultsPane = class { |
| 348 /** | 348 /** |
| 349 * @param {!WebInspector.ProjectSearchConfig} searchConfig | 349 * @param {!Workspace.ProjectSearchConfig} searchConfig |
| 350 */ | 350 */ |
| 351 constructor(searchConfig) { | 351 constructor(searchConfig) { |
| 352 this._searchConfig = searchConfig; | 352 this._searchConfig = searchConfig; |
| 353 this.element = createElement('div'); | 353 this.element = createElement('div'); |
| 354 } | 354 } |
| 355 | 355 |
| 356 /** | 356 /** |
| 357 * @return {!WebInspector.ProjectSearchConfig} | 357 * @return {!Workspace.ProjectSearchConfig} |
| 358 */ | 358 */ |
| 359 get searchConfig() { | 359 get searchConfig() { |
| 360 return this._searchConfig; | 360 return this._searchConfig; |
| 361 } | 361 } |
| 362 | 362 |
| 363 /** | 363 /** |
| 364 * @param {!WebInspector.FileBasedSearchResult} searchResult | 364 * @param {!Sources.FileBasedSearchResult} searchResult |
| 365 */ | 365 */ |
| 366 addSearchResult(searchResult) { | 366 addSearchResult(searchResult) { |
| 367 } | 367 } |
| 368 }; | 368 }; |
| 369 | 369 |
| 370 /** | 370 /** |
| 371 * @implements {WebInspector.ActionDelegate} | 371 * @implements {UI.ActionDelegate} |
| 372 * @unrestricted | 372 * @unrestricted |
| 373 */ | 373 */ |
| 374 WebInspector.AdvancedSearchView.ActionDelegate = class { | 374 Sources.AdvancedSearchView.ActionDelegate = class { |
| 375 /** | 375 /** |
| 376 * @override | 376 * @override |
| 377 * @param {!WebInspector.Context} context | 377 * @param {!UI.Context} context |
| 378 * @param {string} actionId | 378 * @param {string} actionId |
| 379 * @return {boolean} | 379 * @return {boolean} |
| 380 */ | 380 */ |
| 381 handleAction(context, actionId) { | 381 handleAction(context, actionId) { |
| 382 this._showSearch(); | 382 this._showSearch(); |
| 383 return true; | 383 return true; |
| 384 } | 384 } |
| 385 | 385 |
| 386 _showSearch() { | 386 _showSearch() { |
| 387 var selection = WebInspector.inspectorView.element.getDeepSelection(); | 387 var selection = UI.inspectorView.element.getDeepSelection(); |
| 388 var queryCandidate = ''; | 388 var queryCandidate = ''; |
| 389 if (selection.rangeCount) | 389 if (selection.rangeCount) |
| 390 queryCandidate = selection.toString().replace(/\r?\n.*/, ''); | 390 queryCandidate = selection.toString().replace(/\r?\n.*/, ''); |
| 391 WebInspector.AdvancedSearchView.openSearch(queryCandidate); | 391 Sources.AdvancedSearchView.openSearch(queryCandidate); |
| 392 } | 392 } |
| 393 }; | 393 }; |
| 394 | 394 |
| 395 /** | 395 /** |
| 396 * @unrestricted | 396 * @unrestricted |
| 397 */ | 397 */ |
| 398 WebInspector.FileBasedSearchResult = class { | 398 Sources.FileBasedSearchResult = class { |
| 399 /** | 399 /** |
| 400 * @param {!WebInspector.UISourceCode} uiSourceCode | 400 * @param {!Workspace.UISourceCode} uiSourceCode |
| 401 * @param {!Array.<!Object>} searchMatches | 401 * @param {!Array.<!Object>} searchMatches |
| 402 */ | 402 */ |
| 403 constructor(uiSourceCode, searchMatches) { | 403 constructor(uiSourceCode, searchMatches) { |
| 404 this.uiSourceCode = uiSourceCode; | 404 this.uiSourceCode = uiSourceCode; |
| 405 this.searchMatches = searchMatches; | 405 this.searchMatches = searchMatches; |
| 406 } | 406 } |
| 407 }; | 407 }; |
| 408 | 408 |
| 409 /** | 409 /** |
| 410 * @interface | 410 * @interface |
| 411 */ | 411 */ |
| 412 WebInspector.SearchScope = function() {}; | 412 Sources.SearchScope = function() {}; |
| 413 | 413 |
| 414 WebInspector.SearchScope.prototype = { | 414 Sources.SearchScope.prototype = { |
| 415 /** | 415 /** |
| 416 * @param {!WebInspector.SearchConfig} searchConfig | 416 * @param {!Workspace.SearchConfig} searchConfig |
| 417 * @param {!WebInspector.Progress} progress | 417 * @param {!Common.Progress} progress |
| 418 * @param {function(!WebInspector.FileBasedSearchResult)} searchResultCallback | 418 * @param {function(!Sources.FileBasedSearchResult)} searchResultCallback |
| 419 * @param {function(boolean)} searchFinishedCallback | 419 * @param {function(boolean)} searchFinishedCallback |
| 420 */ | 420 */ |
| 421 performSearch: function(searchConfig, progress, searchResultCallback, searchFi
nishedCallback) {}, | 421 performSearch: function(searchConfig, progress, searchResultCallback, searchFi
nishedCallback) {}, |
| 422 | 422 |
| 423 /** | 423 /** |
| 424 * @param {!WebInspector.Progress} progress | 424 * @param {!Common.Progress} progress |
| 425 */ | 425 */ |
| 426 performIndexing: function(progress) {}, | 426 performIndexing: function(progress) {}, |
| 427 | 427 |
| 428 stopSearch: function() {}, | 428 stopSearch: function() {}, |
| 429 | 429 |
| 430 /** | 430 /** |
| 431 * @param {!WebInspector.ProjectSearchConfig} searchConfig | 431 * @param {!Workspace.ProjectSearchConfig} searchConfig |
| 432 * @return {!WebInspector.SearchResultsPane} | 432 * @return {!Sources.SearchResultsPane} |
| 433 */ | 433 */ |
| 434 createSearchResultsPane: function(searchConfig) {} | 434 createSearchResultsPane: function(searchConfig) {} |
| 435 }; | 435 }; |
| OLD | NEW |