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 the on with |sourceId|, if |
| 578 * present. Does not modify checkboxes or the LogView. Should only be |
| 579 * called by a SourceRow in response to its selection state changing. |
| 580 */ |
| 581 modifySelectionArray: function(sourceId, addToSelection) { |
| 582 var sourceRow = this.sourceIdToRowMap_[sourceId]; |
| 583 if (!sourceRow) |
| 584 return; |
570 // Find the index for |sourceEntry| in the current selection list. | 585 // Find the index for |sourceEntry| in the current selection list. |
571 var index = -1; | 586 var index = -1; |
572 for (var i = 0; i < this.currentSelectedRows_.length; ++i) { | 587 for (var i = 0; i < this.currentSelectedRows_.length; ++i) { |
573 if (this.currentSelectedRows_[i] == sourceRow) { | 588 if (this.currentSelectedRows_[i] == sourceRow) { |
574 index = i; | 589 index = i; |
575 break; | 590 break; |
576 } | 591 } |
577 } | 592 } |
578 | 593 |
579 if (index != -1 && !addToSelection) { | 594 if (index != -1 && !addToSelection) { |
580 // Remove from the selection. | 595 // Remove from the selection. |
581 this.currentSelectedRows_.splice(index, 1); | 596 this.currentSelectedRows_.splice(index, 1); |
582 } | 597 } |
583 | 598 |
584 if (index == -1 && addToSelection) { | 599 if (index == -1 && addToSelection) { |
585 this.currentSelectedRows_.push(sourceRow); | 600 this.currentSelectedRows_.push(sourceRow); |
586 } | 601 } |
587 }, | 602 }, |
588 | 603 |
589 getSelectedSourceEntries_: function() { | 604 getSelectedSourceEntries_: function() { |
590 var sourceEntries = []; | 605 var sourceEntries = []; |
591 for (var id in this.currentSelectedRows_) { | 606 for (var i = 0; i < this.currentSelectedRows_.length; ++i) { |
592 sourceEntries.push(this.currentSelectedRows_[id].getSourceEntry()); | 607 sourceEntries.push(this.currentSelectedRows_[i].getSourceEntry()); |
593 } | 608 } |
594 return sourceEntries; | 609 return sourceEntries; |
595 }, | 610 }, |
596 | 611 |
597 invalidateDetailsView_: function() { | 612 invalidateDetailsView_: function() { |
598 this.detailsView_.setData(this.getSelectedSourceEntries_()); | 613 this.detailsView_.setData(this.getSelectedSourceEntries_()); |
599 }, | 614 }, |
600 | 615 |
601 invalidateFilterCounter_: function() { | 616 invalidateFilterCounter_: function() { |
602 if (!this.outstandingRepaintFilterCounter_) { | 617 if (!this.outstandingRepaintFilterCounter_) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 var source1Text = source1.getSourceTypeString(); | 713 var source1Text = source1.getSourceTypeString(); |
699 var source2Text = source2.getSourceTypeString(); | 714 var source2Text = source2.getSourceTypeString(); |
700 var compareResult = source1Text.localeCompare(source2Text); | 715 var compareResult = source1Text.localeCompare(source2Text); |
701 if (compareResult != 0) | 716 if (compareResult != 0) |
702 return compareResult; | 717 return compareResult; |
703 return compareSourceId(source1, source2); | 718 return compareSourceId(source1, source2); |
704 } | 719 } |
705 | 720 |
706 return EventsView; | 721 return EventsView; |
707 })(); | 722 })(); |
OLD | NEW |