| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 * EventsView displays a filtered list of all events sharing a source, and | 6 * EventsView displays a filtered list of all events sharing a source, and |
| 7 * a details pane for the selected sources. | 7 * a details pane for the selected sources. |
| 8 * | 8 * |
| 9 * +----------------------++----------------+ | 9 * +----------------------++----------------+ |
| 10 * | filter box || | | 10 * | filter box || | |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 | 521 |
| 522 unselectAll_: function() { | 522 unselectAll_: function() { |
| 523 var entries = this.currentSelectedRows_.slice(0); | 523 var entries = this.currentSelectedRows_.slice(0); |
| 524 for (var i = 0; i < entries.length; ++i) { | 524 for (var i = 0; i < entries.length; ++i) { |
| 525 entries[i].setSelected(false); | 525 entries[i].setSelected(false); |
| 526 } | 526 } |
| 527 }, | 527 }, |
| 528 | 528 |
| 529 /** | 529 /** |
| 530 * If |params| includes a query, replaces the current filter and unselects. | 530 * If |params| includes a query, replaces the current filter and unselects. |
| 531 * all items. | 531 * all items. If it includes a selection, tries to select the relevant |
| 532 * item. |
| 532 */ | 533 */ |
| 533 setParameters: function(params) { | 534 setParameters: function(params) { |
| 534 if (params.q) { | 535 if (params.q) { |
| 535 this.unselectAll_(); | 536 this.unselectAll_(); |
| 536 this.setFilterText_(params.q); | 537 this.setFilterText_(params.q); |
| 537 } | 538 } |
| 539 |
| 540 if (params.s) { |
| 541 var sourceRow = this.sourceIdToRowMap_[params.s]; |
| 542 if (sourceRow) |
| 543 sourceRow.setSelected(true); |
| 544 } |
| 538 }, | 545 }, |
| 539 | 546 |
| 540 /** | 547 /** |
| 541 * If already using the specified sort method, flips direction. Otherwise, | 548 * If already using the specified sort method, flips direction. Otherwise, |
| 542 * removes pre-existing sort parameter before adding the new one. | 549 * removes pre-existing sort parameter before adding the new one. |
| 543 */ | 550 */ |
| 544 toggleSortMethod_: function(sortMethod) { | 551 toggleSortMethod_: function(sortMethod) { |
| 545 // Remove old sort directives, if any. | 552 // Remove old sort directives, if any. |
| 546 var filterText = this.parseSortDirectives_(this.getFilterText_()); | 553 var filterText = this.parseSortDirectives_(this.getFilterText_()); |
| 547 | 554 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 559 }, | 566 }, |
| 560 | 567 |
| 561 sortBySourceType_: function(event) { | 568 sortBySourceType_: function(event) { |
| 562 this.toggleSortMethod_('source'); | 569 this.toggleSortMethod_('source'); |
| 563 }, | 570 }, |
| 564 | 571 |
| 565 sortByDescription_: function(event) { | 572 sortByDescription_: function(event) { |
| 566 this.toggleSortMethod_('desc'); | 573 this.toggleSortMethod_('desc'); |
| 567 }, | 574 }, |
| 568 | 575 |
| 569 modifySelectionArray: function(sourceRow, addToSelection) { | 576 /** |
| 577 * Modifies the map of selected rows to include/exclude the one with |
| 578 * |sourceId|, if present. Does not modify checkboxes or the LogView. |
| 579 * Should only be called by a SourceRow in response to its selection |
| 580 * state changing. |
| 581 */ |
| 582 modifySelectionArray: function(sourceId, addToSelection) { |
| 583 var sourceRow = this.sourceIdToRowMap_[sourceId]; |
| 584 if (!sourceRow) |
| 585 return; |
| 570 // Find the index for |sourceEntry| in the current selection list. | 586 // Find the index for |sourceEntry| in the current selection list. |
| 571 var index = -1; | 587 var index = -1; |
| 572 for (var i = 0; i < this.currentSelectedRows_.length; ++i) { | 588 for (var i = 0; i < this.currentSelectedRows_.length; ++i) { |
| 573 if (this.currentSelectedRows_[i] == sourceRow) { | 589 if (this.currentSelectedRows_[i] == sourceRow) { |
| 574 index = i; | 590 index = i; |
| 575 break; | 591 break; |
| 576 } | 592 } |
| 577 } | 593 } |
| 578 | 594 |
| 579 if (index != -1 && !addToSelection) { | 595 if (index != -1 && !addToSelection) { |
| 580 // Remove from the selection. | 596 // Remove from the selection. |
| 581 this.currentSelectedRows_.splice(index, 1); | 597 this.currentSelectedRows_.splice(index, 1); |
| 582 } | 598 } |
| 583 | 599 |
| 584 if (index == -1 && addToSelection) { | 600 if (index == -1 && addToSelection) { |
| 585 this.currentSelectedRows_.push(sourceRow); | 601 this.currentSelectedRows_.push(sourceRow); |
| 586 } | 602 } |
| 587 }, | 603 }, |
| 588 | 604 |
| 589 getSelectedSourceEntries_: function() { | 605 getSelectedSourceEntries_: function() { |
| 590 var sourceEntries = []; | 606 var sourceEntries = []; |
| 591 for (var id in this.currentSelectedRows_) { | 607 for (var i = 0; i < this.currentSelectedRows_.length; ++i) { |
| 592 sourceEntries.push(this.currentSelectedRows_[id].getSourceEntry()); | 608 sourceEntries.push(this.currentSelectedRows_[i].getSourceEntry()); |
| 593 } | 609 } |
| 594 return sourceEntries; | 610 return sourceEntries; |
| 595 }, | 611 }, |
| 596 | 612 |
| 597 invalidateDetailsView_: function() { | 613 invalidateDetailsView_: function() { |
| 598 this.detailsView_.setData(this.getSelectedSourceEntries_()); | 614 this.detailsView_.setData(this.getSelectedSourceEntries_()); |
| 599 }, | 615 }, |
| 600 | 616 |
| 601 invalidateFilterCounter_: function() { | 617 invalidateFilterCounter_: function() { |
| 602 if (!this.outstandingRepaintFilterCounter_) { | 618 if (!this.outstandingRepaintFilterCounter_) { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 var source1Text = source1.getSourceTypeString(); | 714 var source1Text = source1.getSourceTypeString(); |
| 699 var source2Text = source2.getSourceTypeString(); | 715 var source2Text = source2.getSourceTypeString(); |
| 700 var compareResult = source1Text.localeCompare(source2Text); | 716 var compareResult = source1Text.localeCompare(source2Text); |
| 701 if (compareResult != 0) | 717 if (compareResult != 0) |
| 702 return compareResult; | 718 return compareResult; |
| 703 return compareSourceId(source1, source2); | 719 return compareSourceId(source1, source2); |
| 704 } | 720 } |
| 705 | 721 |
| 706 return EventsView; | 722 return EventsView; |
| 707 })(); | 723 })(); |
| OLD | NEW |