public void addItems ( final List < SuggestTokenDto > suggestions , final VTextField textFieldWidget , final PopupPanel popupPanel , final TextFieldSuggestionBoxServerRpc suggestionServerRpc ) { for ( int index = 0 ; index < suggestions . size ( ) ; index ++ ) { final SuggestTokenDto suggestToken = suggestions . get ( index ) ; final MenuItem mi = new MenuItem ( suggestToken . getSuggestion ( ) , true , new ScheduledCommand ( ) { @ Override public void execute ( ) { final String tmpSuggestion = suggestToken . getSuggestion ( ) ; final TokenStartEnd tokenStartEnd = tokenMap . get ( tmpSuggestion ) ; final String text = textFieldWidget . getValue ( ) ; final StringBuilder builder = new StringBuilder ( text ) ; builder . replace ( tokenStartEnd . getStart ( ) , tokenStartEnd . getEnd ( ) + 1 , tmpSuggestion ) ; textFieldWidget . setValue ( builder . toString ( ) , true ) ; popupPanel . hide ( ) ; textFieldWidget . setFocus ( true ) ; suggestionServerRpc . suggest ( builder . toString ( ) , textFieldWidget . getCursorPos ( ) ) ; } } ) ; tokenMap . put ( suggestToken . getSuggestion ( ) , new TokenStartEnd ( suggestToken . getStart ( ) , suggestToken . getEnd ( ) ) ) ; Roles . getListitemRole ( ) . set ( mi . getElement ( ) ) ; WidgetUtil . sinkOnloadForImages ( mi . getElement ( ) ) ; addItem ( mi ) ; } }
Adds suggestions to the suggestion menu bar .