| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 24 matching lines...) Expand all Loading... |
| 35 /* | 35 /* |
| 36 * @constructor | 36 * @constructor |
| 37 */ | 37 */ |
| 38 function EventsView() { | 38 function EventsView() { |
| 39 assertFirstConstructorCall(EventsView); | 39 assertFirstConstructorCall(EventsView); |
| 40 | 40 |
| 41 // Call superclass's constructor. | 41 // Call superclass's constructor. |
| 42 superClass.call(this); | 42 superClass.call(this); |
| 43 | 43 |
| 44 // Initialize the sub-views. | 44 // Initialize the sub-views. |
| 45 var leftPane = new VerticalSplitView(new DivView(EventsView.TOPBAR_ID), | 45 var leftPane = new VerticalSplitView( |
| 46 new DivView(EventsView.LIST_BOX_ID)); | 46 new DivView(EventsView.TOPBAR_ID), new DivView(EventsView.LIST_BOX_ID)); |
| 47 | 47 |
| 48 this.detailsView_ = new DetailsView(EventsView.DETAILS_LOG_BOX_ID); | 48 this.detailsView_ = new DetailsView(EventsView.DETAILS_LOG_BOX_ID); |
| 49 | 49 |
| 50 this.splitterView_ = new ResizableVerticalSplitView( | 50 this.splitterView_ = new ResizableVerticalSplitView( |
| 51 leftPane, this.detailsView_, new DivView(EventsView.SIZER_ID)); | 51 leftPane, this.detailsView_, new DivView(EventsView.SIZER_ID)); |
| 52 | 52 |
| 53 SourceTracker.getInstance().addSourceEntryObserver(this); | 53 SourceTracker.getInstance().addSourceEntryObserver(this); |
| 54 | 54 |
| 55 this.tableBody_ = $(EventsView.TBODY_ID); | 55 this.tableBody_ = $(EventsView.TBODY_ID); |
| 56 | 56 |
| 57 this.filterInput_ = $(EventsView.FILTER_INPUT_ID); | 57 this.filterInput_ = $(EventsView.FILTER_INPUT_ID); |
| 58 this.filterCount_ = $(EventsView.FILTER_COUNT_ID); | 58 this.filterCount_ = $(EventsView.FILTER_COUNT_ID); |
| 59 | 59 |
| 60 this.filterInput_.addEventListener('search', | 60 this.filterInput_.addEventListener( |
| 61 this.onFilterTextChanged_.bind(this), true); | 61 'search', this.onFilterTextChanged_.bind(this), true); |
| 62 | 62 |
| 63 $(EventsView.SELECT_ALL_ID).addEventListener( | 63 $(EventsView.SELECT_ALL_ID) |
| 64 'click', this.selectAll_.bind(this), true); | 64 .addEventListener('click', this.selectAll_.bind(this), true); |
| 65 | 65 |
| 66 $(EventsView.SORT_BY_ID_ID).addEventListener( | 66 $(EventsView.SORT_BY_ID_ID) |
| 67 'click', this.sortById_.bind(this), true); | 67 .addEventListener('click', this.sortById_.bind(this), true); |
| 68 | 68 |
| 69 $(EventsView.SORT_BY_SOURCE_TYPE_ID).addEventListener( | 69 $(EventsView.SORT_BY_SOURCE_TYPE_ID) |
| 70 'click', this.sortBySourceType_.bind(this), true); | 70 .addEventListener('click', this.sortBySourceType_.bind(this), true); |
| 71 | 71 |
| 72 $(EventsView.SORT_BY_DESCRIPTION_ID).addEventListener( | 72 $(EventsView.SORT_BY_DESCRIPTION_ID) |
| 73 'click', this.sortByDescription_.bind(this), true); | 73 .addEventListener('click', this.sortByDescription_.bind(this), true); |
| 74 | 74 |
| 75 new MouseOverHelp(EventsView.FILTER_HELP_ID, | 75 new MouseOverHelp( |
| 76 EventsView.FILTER_HELP_HOVER_ID); | 76 EventsView.FILTER_HELP_ID, EventsView.FILTER_HELP_HOVER_ID); |
| 77 | 77 |
| 78 // Sets sort order and filter. | 78 // Sets sort order and filter. |
| 79 this.setFilter_(''); | 79 this.setFilter_(''); |
| 80 | 80 |
| 81 this.initializeSourceList_(); | 81 this.initializeSourceList_(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 EventsView.TAB_ID = 'tab-handle-events'; | 84 EventsView.TAB_ID = 'tab-handle-events'; |
| 85 EventsView.TAB_NAME = 'Events'; | 85 EventsView.TAB_NAME = 'Events'; |
| 86 EventsView.TAB_HASH = '#events'; | 86 EventsView.TAB_HASH = '#events'; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 insertionSort_: function(sourceRow) { | 225 insertionSort_: function(sourceRow) { |
| 226 // SourceRow that should be after |sourceRow|, if it needs | 226 // SourceRow that should be after |sourceRow|, if it needs |
| 227 // to be moved earlier in the list. | 227 // to be moved earlier in the list. |
| 228 var sourceRowAfter = sourceRow; | 228 var sourceRowAfter = sourceRow; |
| 229 while (true) { | 229 while (true) { |
| 230 var prevSourceId = sourceRowAfter.getPreviousNodeSourceId(); | 230 var prevSourceId = sourceRowAfter.getPreviousNodeSourceId(); |
| 231 if (prevSourceId == null) | 231 if (prevSourceId == null) |
| 232 break; | 232 break; |
| 233 var prevSourceRow = this.sourceIdToRowMap_[prevSourceId]; | 233 var prevSourceRow = this.sourceIdToRowMap_[prevSourceId]; |
| 234 if (this.comparisonFuncWithReversing_( | 234 if (this.comparisonFuncWithReversing_( |
| 235 sourceRow.getSourceEntry(), | 235 sourceRow.getSourceEntry(), prevSourceRow.getSourceEntry()) >= |
| 236 prevSourceRow.getSourceEntry()) >= 0) { | 236 0) { |
| 237 break; | 237 break; |
| 238 } | 238 } |
| 239 sourceRowAfter = prevSourceRow; | 239 sourceRowAfter = prevSourceRow; |
| 240 } | 240 } |
| 241 if (sourceRowAfter != sourceRow) { | 241 if (sourceRowAfter != sourceRow) { |
| 242 sourceRow.moveBefore(sourceRowAfter); | 242 sourceRow.moveBefore(sourceRowAfter); |
| 243 return; | 243 return; |
| 244 } | 244 } |
| 245 | 245 |
| 246 var sourceRowBefore = sourceRow; | 246 var sourceRowBefore = sourceRow; |
| 247 while (true) { | 247 while (true) { |
| 248 var nextSourceId = sourceRowBefore.getNextNodeSourceId(); | 248 var nextSourceId = sourceRowBefore.getNextNodeSourceId(); |
| 249 if (nextSourceId == null) | 249 if (nextSourceId == null) |
| 250 break; | 250 break; |
| 251 var nextSourceRow = this.sourceIdToRowMap_[nextSourceId]; | 251 var nextSourceRow = this.sourceIdToRowMap_[nextSourceId]; |
| 252 if (this.comparisonFuncWithReversing_( | 252 if (this.comparisonFuncWithReversing_( |
| 253 sourceRow.getSourceEntry(), | 253 sourceRow.getSourceEntry(), nextSourceRow.getSourceEntry()) <= |
| 254 nextSourceRow.getSourceEntry()) <= 0) { | 254 0) { |
| 255 break; | 255 break; |
| 256 } | 256 } |
| 257 sourceRowBefore = nextSourceRow; | 257 sourceRowBefore = nextSourceRow; |
| 258 } | 258 } |
| 259 if (sourceRowBefore != sourceRow) | 259 if (sourceRowBefore != sourceRow) |
| 260 sourceRow.moveAfter(sourceRowBefore); | 260 sourceRow.moveAfter(sourceRowBefore); |
| 261 }, | 261 }, |
| 262 | 262 |
| 263 /** | 263 /** |
| 264 * Called whenever SourceEntries are updated with new log entries. Updates | 264 * Called whenever SourceEntries are updated with new log entries. Updates |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 return sourceEntries; | 465 return sourceEntries; |
| 466 }, | 466 }, |
| 467 | 467 |
| 468 invalidateDetailsView_: function() { | 468 invalidateDetailsView_: function() { |
| 469 this.detailsView_.setData(this.getSelectedSourceEntries_()); | 469 this.detailsView_.setData(this.getSelectedSourceEntries_()); |
| 470 }, | 470 }, |
| 471 | 471 |
| 472 invalidateFilterCounter_: function() { | 472 invalidateFilterCounter_: function() { |
| 473 if (!this.outstandingRepaintFilterCounter_) { | 473 if (!this.outstandingRepaintFilterCounter_) { |
| 474 this.outstandingRepaintFilterCounter_ = true; | 474 this.outstandingRepaintFilterCounter_ = true; |
| 475 window.setTimeout(this.repaintFilterCounter_.bind(this), | 475 window.setTimeout( |
| 476 REPAINT_FILTER_COUNTER_TIMEOUT_MS); | 476 this.repaintFilterCounter_.bind(this), |
| 477 REPAINT_FILTER_COUNTER_TIMEOUT_MS); |
| 477 } | 478 } |
| 478 }, | 479 }, |
| 479 | 480 |
| 480 repaintFilterCounter_: function() { | 481 repaintFilterCounter_: function() { |
| 481 this.outstandingRepaintFilterCounter_ = false; | 482 this.outstandingRepaintFilterCounter_ = false; |
| 482 this.filterCount_.innerHTML = ''; | 483 this.filterCount_.innerHTML = ''; |
| 483 addTextNode(this.filterCount_, | 484 addTextNode( |
| 484 this.numPostfilter_ + ' of ' + this.numPrefilter_); | 485 this.filterCount_, this.numPostfilter_ + ' of ' + this.numPrefilter_); |
| 485 } | 486 } |
| 486 }; // end of prototype. | 487 }; // end of prototype. |
| 487 | 488 |
| 488 // ------------------------------------------------------------------------ | 489 // ------------------------------------------------------------------------ |
| 489 // Helper code for comparisons | 490 // Helper code for comparisons |
| 490 // ------------------------------------------------------------------------ | 491 // ------------------------------------------------------------------------ |
| 491 | 492 |
| 492 var COMPARISON_FUNCTION_TABLE = { | 493 var COMPARISON_FUNCTION_TABLE = { |
| 493 // sort: and sort:- are allowed | 494 // sort: and sort:- are allowed |
| 494 '': compareSourceId_, | 495 '': compareSourceId_, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 var source1Text = source1.getSourceTypeString(); | 570 var source1Text = source1.getSourceTypeString(); |
| 570 var source2Text = source2.getSourceTypeString(); | 571 var source2Text = source2.getSourceTypeString(); |
| 571 var compareResult = source1Text.localeCompare(source2Text); | 572 var compareResult = source1Text.localeCompare(source2Text); |
| 572 if (compareResult != 0) | 573 if (compareResult != 0) |
| 573 return compareResult; | 574 return compareResult; |
| 574 return compareSourceId_(source1, source2); | 575 return compareSourceId_(source1, source2); |
| 575 } | 576 } |
| 576 | 577 |
| 577 return EventsView; | 578 return EventsView; |
| 578 })(); | 579 })(); |
| OLD | NEW |