| 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 */ | 13 */ |
| 14 WebInspector.SourcesView = function(workspace, sourcesPanel) | 14 WebInspector.SourcesView = function(workspace, sourcesPanel) |
| 15 { | 15 { |
| 16 WebInspector.VBox.call(this); | 16 WebInspector.VBox.call(this); |
| 17 this.registerRequiredCSS("sourcesView.css"); | 17 this.registerRequiredCSS("sourcesView.css"); |
| 18 this.element.id = "sources-panel-sources-view"; | 18 this.element.id = "sources-panel-sources-view"; |
| 19 this.setMinimumAndPreferredSizes(50, 25, 150, 100); | 19 this.setMinimumAndPreferredSizes(50, 25, 150, 100); |
| 20 | 20 |
| 21 this._workspace = workspace; | 21 this._workspace = workspace; |
| 22 this._sourcesPanel = sourcesPanel; | 22 this._sourcesPanel = sourcesPanel; |
| 23 | 23 |
| 24 this._searchableView = new WebInspector.SearchableView(this); | 24 this._searchableView = new WebInspector.SearchableView(this, "sourcesViewSea
rchConfig"); |
| 25 this._searchableView.setMinimalSearchQuerySize(0); | 25 this._searchableView.setMinimalSearchQuerySize(0); |
| 26 this._searchableView.show(this.element); | 26 this._searchableView.show(this.element); |
| 27 | 27 |
| 28 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.UISourceCodeFrame
>} */ | 28 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.UISourceCodeFrame
>} */ |
| 29 this._sourceFramesByUISourceCode = new Map(); | 29 this._sourceFramesByUISourceCode = new Map(); |
| 30 | 30 |
| 31 var tabbedEditorPlaceholderText = WebInspector.isMac() ? WebInspector.UIStri
ng("Hit Cmd+P to open a file") : WebInspector.UIString("Hit Ctrl+P to open a fil
e"); | 31 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 this._editorContainer = new WebInspector.TabbedEditorContainer(this, "previo
uslyViewedFiles", tabbedEditorPlaceholderText); | 32 this._editorContainer = new WebInspector.TabbedEditorContainer(this, "previo
uslyViewedFiles", tabbedEditorPlaceholderText); |
| 33 this._editorContainer.show(this._searchableView.element); | 33 this._editorContainer.show(this._searchableView.element); |
| 34 this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Ev
ents.EditorSelected, this._editorSelected, this); | 34 this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Ev
ents.EditorSelected, this._editorSelected, this); |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 { | 490 { |
| 491 this._recreateSourceFrameIfNeeded(uiSourceCode); | 491 this._recreateSourceFrameIfNeeded(uiSourceCode); |
| 492 }, | 492 }, |
| 493 | 493 |
| 494 searchCanceled: function() | 494 searchCanceled: function() |
| 495 { | 495 { |
| 496 if (this._searchView) | 496 if (this._searchView) |
| 497 this._searchView.searchCanceled(); | 497 this._searchView.searchCanceled(); |
| 498 | 498 |
| 499 delete this._searchView; | 499 delete this._searchView; |
| 500 delete this._searchQuery; | 500 delete this._searchConfig; |
| 501 }, | 501 }, |
| 502 | 502 |
| 503 /** | 503 /** |
| 504 * @param {string} query | 504 * @param {!WebInspector.SearchableView.SearchConfig} searchConfig |
| 505 * @param {boolean} shouldJump | 505 * @param {boolean} shouldJump |
| 506 * @param {boolean=} jumpBackwards | 506 * @param {boolean=} jumpBackwards |
| 507 */ | 507 */ |
| 508 performSearch: function(query, shouldJump, jumpBackwards) | 508 performSearch: function(searchConfig, shouldJump, jumpBackwards) |
| 509 { | 509 { |
| 510 this._searchableView.updateSearchMatchesCount(0); | 510 this._searchableView.updateSearchMatchesCount(0); |
| 511 | 511 |
| 512 var sourceFrame = this.currentSourceFrame(); | 512 var sourceFrame = this.currentSourceFrame(); |
| 513 if (!sourceFrame) | 513 if (!sourceFrame) |
| 514 return; | 514 return; |
| 515 | 515 |
| 516 this._searchView = sourceFrame; | 516 this._searchView = sourceFrame; |
| 517 this._searchQuery = query; | 517 this._searchConfig = searchConfig; |
| 518 | 518 |
| 519 /** | 519 /** |
| 520 * @param {!WebInspector.View} view | 520 * @param {!WebInspector.View} view |
| 521 * @param {number} searchMatches | 521 * @param {number} searchMatches |
| 522 * @this {WebInspector.SourcesView} | 522 * @this {WebInspector.SourcesView} |
| 523 */ | 523 */ |
| 524 function finishedCallback(view, searchMatches) | 524 function finishedCallback(view, searchMatches) |
| 525 { | 525 { |
| 526 if (!searchMatches) | 526 if (!searchMatches) |
| 527 return; | 527 return; |
| 528 | 528 |
| 529 this._searchableView.updateSearchMatchesCount(searchMatches); | 529 this._searchableView.updateSearchMatchesCount(searchMatches); |
| 530 } | 530 } |
| 531 | 531 |
| 532 /** | 532 /** |
| 533 * @param {number} currentMatchIndex | 533 * @param {number} currentMatchIndex |
| 534 * @this {WebInspector.SourcesView} | 534 * @this {WebInspector.SourcesView} |
| 535 */ | 535 */ |
| 536 function currentMatchChanged(currentMatchIndex) | 536 function currentMatchChanged(currentMatchIndex) |
| 537 { | 537 { |
| 538 this._searchableView.updateCurrentMatchIndex(currentMatchIndex); | 538 this._searchableView.updateCurrentMatchIndex(currentMatchIndex); |
| 539 } | 539 } |
| 540 | 540 |
| 541 /** | 541 /** |
| 542 * @this {WebInspector.SourcesView} | 542 * @this {WebInspector.SourcesView} |
| 543 */ | 543 */ |
| 544 function searchResultsChanged() | 544 function searchResultsChanged() |
| 545 { | 545 { |
| 546 this.performSearch(query, false, false); | 546 this.performSearch(this._searchConfig, false, false); |
| 547 } | 547 } |
| 548 | 548 |
| 549 this._searchView.performSearch(query, shouldJump, !!jumpBackwards, finis
hedCallback.bind(this), currentMatchChanged.bind(this), searchResultsChanged.bin
d(this)); | 549 this._searchView.performSearch(this._searchConfig, shouldJump, !!jumpBac
kwards, finishedCallback.bind(this), currentMatchChanged.bind(this), searchResul
tsChanged.bind(this)); |
| 550 }, | 550 }, |
| 551 | 551 |
| 552 jumpToNextSearchResult: function() | 552 jumpToNextSearchResult: function() |
| 553 { | 553 { |
| 554 if (!this._searchView) | 554 if (!this._searchView) |
| 555 return; | 555 return; |
| 556 | 556 |
| 557 if (this._searchView !== this.currentSourceFrame()) { | 557 if (this._searchView !== this.currentSourceFrame()) { |
| 558 this.performSearch(this._searchQuery, true); | 558 this.performSearch(this._searchConfig, true); |
| 559 return; | 559 return; |
| 560 } | 560 } |
| 561 | 561 |
| 562 this._searchView.jumpToNextSearchResult(); | 562 this._searchView.jumpToNextSearchResult(); |
| 563 }, | 563 }, |
| 564 | 564 |
| 565 jumpToPreviousSearchResult: function() | 565 jumpToPreviousSearchResult: function() |
| 566 { | 566 { |
| 567 if (!this._searchView) | 567 if (!this._searchView) |
| 568 return; | 568 return; |
| 569 | 569 |
| 570 if (this._searchView !== this.currentSourceFrame()) { | 570 if (this._searchView !== this.currentSourceFrame()) { |
| 571 this.performSearch(this._searchQuery, true); | 571 this.performSearch(this._searchConfig, true); |
| 572 if (this._searchView) | 572 if (this._searchView) |
| 573 this._searchView.jumpToLastSearchResult(); | 573 this._searchView.jumpToLastSearchResult(); |
| 574 return; | 574 return; |
| 575 } | 575 } |
| 576 | 576 |
| 577 this._searchView.jumpToPreviousSearchResult(); | 577 this._searchView.jumpToPreviousSearchResult(); |
| 578 }, | 578 }, |
| 579 | 579 |
| 580 /** | 580 /** |
| 581 * @param {string} text | 581 * @return {boolean} |
| 582 */ | 582 */ |
| 583 replaceSelectionWith: function(text) | 583 supportsCaseSensitiveSearch: function() |
| 584 { |
| 585 return true; |
| 586 }, |
| 587 |
| 588 /** |
| 589 * @return {boolean} |
| 590 */ |
| 591 supportsRegexSearch: function() |
| 592 { |
| 593 return true; |
| 594 }, |
| 595 |
| 596 /** |
| 597 * @param {string} replacement |
| 598 */ |
| 599 replaceSelectionWith: function(replacement) |
| 584 { | 600 { |
| 585 var sourceFrame = this.currentSourceFrame(); | 601 var sourceFrame = this.currentSourceFrame(); |
| 586 if (!sourceFrame) { | 602 if (!sourceFrame) { |
| 587 console.assert(sourceFrame); | 603 console.assert(sourceFrame); |
| 588 return; | 604 return; |
| 589 } | 605 } |
| 590 sourceFrame.replaceSelectionWith(text); | 606 sourceFrame.replaceSelectionWith(replacement); |
| 591 }, | 607 }, |
| 592 | 608 |
| 593 /** | 609 /** |
| 594 * @param {string} query | 610 * @param {!WebInspector.SearchableView.SearchConfig} searchConfig |
| 595 * @param {string} text | 611 * @param {string} replacement |
| 596 */ | 612 */ |
| 597 replaceAllWith: function(query, text) | 613 replaceAllWith: function(searchConfig, replacement) |
| 598 { | 614 { |
| 599 var sourceFrame = this.currentSourceFrame(); | 615 var sourceFrame = this.currentSourceFrame(); |
| 600 if (!sourceFrame) { | 616 if (!sourceFrame) { |
| 601 console.assert(sourceFrame); | 617 console.assert(sourceFrame); |
| 602 return; | 618 return; |
| 603 } | 619 } |
| 604 sourceFrame.replaceAllWith(query, text); | 620 sourceFrame.replaceAllWith(searchConfig, replacement); |
| 605 }, | 621 }, |
| 606 | 622 |
| 607 /** | 623 /** |
| 608 * @param {!Event=} event | 624 * @param {!Event=} event |
| 609 * @return {boolean} | 625 * @return {boolean} |
| 610 */ | 626 */ |
| 611 _showOutlineDialog: function(event) | 627 _showOutlineDialog: function(event) |
| 612 { | 628 { |
| 613 var uiSourceCode = this._editorContainer.currentFile(); | 629 var uiSourceCode = this._editorContainer.currentFile(); |
| 614 if (!uiSourceCode) | 630 if (!uiSourceCode) |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 var currentUISourceCode = sourcesView.currentUISourceCode(); | 799 var currentUISourceCode = sourcesView.currentUISourceCode(); |
| 784 if (!currentUISourceCode) | 800 if (!currentUISourceCode) |
| 785 return true; | 801 return true; |
| 786 var nextUISourceCode = WebInspector.SourcesView.SwitchFileActionDelegate
._nextFile(currentUISourceCode); | 802 var nextUISourceCode = WebInspector.SourcesView.SwitchFileActionDelegate
._nextFile(currentUISourceCode); |
| 787 if (!nextUISourceCode) | 803 if (!nextUISourceCode) |
| 788 return true; | 804 return true; |
| 789 sourcesView.showSourceLocation(nextUISourceCode); | 805 sourcesView.showSourceLocation(nextUISourceCode); |
| 790 return true; | 806 return true; |
| 791 } | 807 } |
| 792 } | 808 } |
| OLD | NEW |