question: boolean filterChanged ( TableLineFilter < SearchResultDataLine > filter , int depth ) { FILTER . setFilter ( depth , filter ) ; int [ ] rows = TABLE . getSelectedRows ( ) ; SearchResultDataLine [ ] lines = new SearchResultDataLine [ rows . length ] ; List < SearchResultDataLine > inView = new LinkedList < > ( ) ; for ( int i = 0 ; i < rows . length ; i ++ ) { int row = rows [ i ] ; SearchResultDataLine line = DATA_MODEL . get ( row ) ; lines [ i ] = line ; if ( TABLE . isRowVisible ( row ) ) inView . add ( line ) ; } DATA_MODEL . filtersChanged ( ) ; for ( int i = 0 ; i < rows . length ; i ++ ) { SearchResultDataLine line = lines [ i ] ; int row = DATA_MODEL . getRow ( line ) ; if ( row != - 1 ) { TABLE . addRowSelectionInterval ( row , row ) ; if ( inView != null && inView . contains ( line ) ) { TABLE . ensureRowVisible ( row ) ; inView = null ; } } } SearchMediator . setTabDisplayCount ( this ) ; return true ; }
target:  Notification that a filter on this panel has changed. Updates the data model with the new list, maintains the selection, and moves the viewport to the first still visible selected row. Note that the viewport moving cannot be done by just storing the first visible row, because after the filters change, the row might not exist anymore.  Thus, it is necessary to store all visible rows and move to the first still-visible one.