protected void updateSelectedItemsFromValueModel ( ) { Object value = getValue ( ) ; Object [ ] selectedValues = EMPTY_VALUES ; if ( value != null ) { selectedValues = ( Object [ ] ) convertValue ( value , Object [ ] . class ) ; } // flag is used to avoid a round trip while we are selecting the values selectingValues = true ; try { ListSelectionModel selectionModel = getList ( ) . getSelectionModel ( ) ; selectionModel . setValueIsAdjusting ( true ) ; try { int [ ] valueIndexes = determineValueIndexes ( selectedValues ) ; int selectionMode = getSelectionMode ( ) ; if ( selectionMode == ListSelectionModel . SINGLE_SELECTION && valueIndexes . length > 1 ) { getList ( ) . setSelectedIndex ( valueIndexes [ 0 ] ) ; } else { getList ( ) . setSelectedIndices ( valueIndexes ) ; } // update value model if selectedValues contain elements which where not found in the list model // elements if ( valueIndexes . length != selectedValues . length && ! isReadOnly ( ) && isEnabled ( ) || ( selectionMode == ListSelectionModel . SINGLE_SELECTION && valueIndexes . length > 1 ) ) { updateSelectedItemsFromSelectionModel ( ) ; } } finally { selectionModel . setValueIsAdjusting ( false ) ; } } finally { selectingValues = false ; } }
Updates the selection model with the selected values from the value model .