false
, only {@link Suggestion}s from the
* SuggestionOracle are accepted. Direct input create by the user is
* ignored. By default, direct input is allowed.
*/
public void setDirectInputAllowed(boolean directInputAllowed) {
this.directInputAllowed = directInputAllowed;
}
/**
* @return if {@link Suggestion}s created by direct input from the user
* should be allowed. By default directInputAllowed is
* true
.
*/
public boolean isDirectInputAllowed() {
return directInputAllowed;
}
/**
* Sets the style class applied to chips when they are selected.
* * Defaults to "blue white-text". *
* * @param selectedChipStyle The class or classes to be applied to selected chips */ public void setSelectedChipStyle(String selectedChipStyle) { this.selectedChipStyle = selectedChipStyle; } /** * Returns the style class applied to chips when they are selected. ** Defaults to "blue white-text". *
*/ public String getSelectedChipStyle() { return selectedChipStyle; } @Override public void showProgress(ProgressType type) { progressMixin.showProgress(ProgressType.INDETERMINATE); } @Override public void setPercent(double percent) { progressMixin.setPercent(percent); } @Override public void hideProgress() { progressMixin.hideProgress(); } @Override public HandlerRegistration addKeyUpHandler(final KeyUpHandler handler) { return itemBox.addKeyUpHandler(event -> { if (isEnabled()) { handler.onKeyUp(event); } }); } @Override public void setType(AutocompleteType type) { typeMixin.setType(type); } @Override public AutocompleteType getType() { return typeMixin.getType(); } @Override public HandlerRegistration addSelectionHandler(final SelectionHandlernull
if the
* suggestion should be ignored.
*/
MaterialChip getChip(Suggestion suggestion);
/**
* Returns whether the chip defined by the suggestion should be selected when the user clicks on it.
* *
* Selecion of chips is used to batch remove suggestions, for example. *
* * @param suggestion the selected {@link Suggestion} * @see MaterialAutoComplete#setSelectedChipStyle(String) */ boolean isChipSelectable(Suggestion suggestion); /** * Returns whether the chip defined by the suggestion should be removed from the autocomplete when clicked on its icon. **
* Override this method returning false
to implement your own logic when the user clicks on the chip icon.
*
*
* By default all chips are selectable and removable. The default {@link IconType} used by the chips provided is the {@link IconType#CLOSE}. *
* * @see MaterialAutoComplete#setChipProvider(MaterialChipProvider) */ public static class DefaultMaterialChipProvider implements MaterialChipProvider { @Override public MaterialChip getChip(Suggestion suggestion) { final MaterialChip chip = new MaterialChip(); String imageChip = suggestion.getDisplayString(); String textChip = imageChip; String s = "]*[>]", ""); } chip.setText(textChip); chip.setIconType(IconType.CLOSE); return chip; } @Override public boolean isChipRemovable(Suggestion suggestion) { return true; } @Override public boolean isChipSelectable(Suggestion suggestion) { return true; } } @Override public HandlerRegistration addValueChangeHandler(final ValueChangeHandlernull
).
*/
@Override
public List extends Suggestion> getValue() {
return new ArrayList<>(suggestionMap.keySet());
}
@Override
public void setValue(List extends Suggestion> value, boolean fireEvents) {
clear();
if (value != null) {
placeholderLabel.addStyleName(CssName.ACTIVE);
for (Suggestion suggestion : value) {
addItem(suggestion);
}
}
super.setValue(value, fireEvents);
}
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
itemBox.setEnabled(enabled);
}
@Override
public ErrorMixin