protected boolean addItem ( final Suggestion suggestion ) { SelectionEvent . fire ( MaterialAutoComplete . this , suggestion ) ; if ( getLimit ( ) > 0 ) { if ( suggestionMap . size ( ) >= getLimit ( ) ) { return false ; } } if ( suggestionMap . containsKey ( suggestion ) ) { return false ; } final ListItem displayItem = new ListItem ( ) ; displayItem . setStyleName ( AddinsCssName . MULTIVALUESUGGESTBOX_TOKEN ) ; if ( getType ( ) == AutocompleteType . TEXT ) { suggestionMap . clear ( ) ; itemBox . setText ( suggestion . getReplacementString ( ) ) ; } else { final MaterialChip chip = chipProvider . getChip ( suggestion ) ; if ( chip == null ) { return false ; } registerHandler ( chip . addClickHandler ( event -> { if ( chipProvider . isChipSelectable ( suggestion ) ) { if ( itemsHighlighted . contains ( displayItem ) ) { chip . removeStyleName ( selectedChipStyle ) ; itemsHighlighted . remove ( displayItem ) ; } else { chip . addStyleName ( selectedChipStyle ) ; itemsHighlighted . add ( displayItem ) ; } } } ) ) ; if ( chip . getIcon ( ) != null ) { registerHandler ( chip . getIcon ( ) . addClickHandler ( event -> { if ( chipProvider . isChipRemovable ( suggestion ) ) { suggestionMap . remove ( suggestion ) ; list . remove ( displayItem ) ; itemsHighlighted . remove ( displayItem ) ; ValueChangeEvent . fire ( MaterialAutoComplete . this , getValue ( ) ) ; suggestBox . showSuggestionList ( ) ; } } ) ) ; } suggestionMap . put ( suggestion , chip ) ; displayItem . add ( chip ) ; list . insert ( displayItem , list . getWidgetCount ( ) - 1 ) ; } return true ; }
Adding the item value using Material Chips added on auto complete box