Usage:
// Create a concrete class extending AbstractSelect
public class MySelect extends AbstractSelect< MyType, String, MyElement, MyOption, MySelect> {
// implementation details...
}
MySelect select = new MySelect();
T
The type of the model.
V
The type of the value to be selected.
E
The type of the element.
O
The type of the option.
C
The type of the concrete class extending this abstract class.
Usage example:
Select< String> fruitSelect = Select.create("Choose a fruit");
fruitSelect.withOption(new SelectOption<> ("Apple"), false);
fruitSelect.withOption(new SelectOption<> ("Banana"), false);
V
The type of value associated with each select option.
See also :
Usage example:
MultiSelect< String> multiSelect = MultiSelect.create("Select Items");
multiSelect.withValue("Option1", "Option2");
V
the type of the value represented by each selectable option
See also :
public void AbstractSelect()
public C appendChild(O option)
option
The option to be added to the select.
an instance of the concrete class.
public C insertChild(int index, O option)
index
The desired location index.
option
The option to be added to the select.
an instance of the concrete class.
public C appendOptions(Collection<O> options)
options
The collection of options to be added to the select.
an instance of the concrete class.
public C insertOptions(int index, Collection<O> options)
index
The insert starting index
options
The collection of options to be added to the select.
an instance of the concrete class.
public C appendOptions(O[] options)
options
The options to be added to the select.
an instance of the concrete class.
public C insertOptions(int index, O[] options)
index
The starting insert index.
options
The options to be added to the select.
an instance of the concrete class.
public C appendItem(Function<I, O> mapper, I item)
mapper
The function to map the item to an option.
item
The item to be mapped and added as an option to the select.
an instance of the concrete class.
public C insertItem(int index, Function<I, O> mapper, I item)
index
The index
mapper
The function to map the item to an option.
item
The item to be mapped and added as an option to the select.
an instance of the concrete class.
public C appendItems(Function<I, O> mapper, Collection<I> items)
mapper
The function to map each item to an option.
items
The collection of items to be mapped and added as options to the select.
an instance of the concrete class.
public C insertItems(int index, Function<I, O> mapper, Collection<I> items)
index
The starting insert index.
mapper
The function to map each item to an option.
items
The collection of items to be mapped and added as options to the select.
an instance of the concrete class.
public C appendItems(Function<I, O> mapper, I[] items)
mapper
The function to map each item to an option.
items
The items to be mapped and added as options to the select.
an instance of the concrete class.
public C insertItems(int index, Function<I, O> mapper, I[] items)
index
insert starting index.
mapper
The function to map each item to an option.
items
The items to be mapped and added as options to the select.
an instance of the concrete class.
public C appendChild(Separator separator)
separator
The separator to be added between options in the select.
an instance of the concrete class.
public C insertChild(int index, Separator separator)
index
the insert index.
separator
The separator to be added between options in the select.
an instance of the concrete class.
public String getPlaceholder()
The placeholder text.
public C setPlaceholder(String placeholder)
placeholder
The text to be used as a placeholder.
an instance of the concrete class.
public DominoElement<HTMLInputElement> getInputElement()
The input element.
public String getStringValue()
The string representation of the selected value(s).
public C focus()
an instance of the concrete class.
public C unfocus()
an instance of the concrete class.
public boolean isFocused()
true if the element is focused, false otherwise.
public boolean isEmpty()
true if the select is empty, false otherwise.
public boolean isEmptyIgnoreSpaces()
Note: This method currently has the same implementation as isEmpty .
Returns:
true if the select is empty, false otherwise.
public boolean isEnabled()
true if the select is enabled, false otherwise.
public C clear()
an instance of the concrete class.
public C clear(boolean silent)
silent
if true , listeners will not be notified of the change.
an instance of the concrete class.
public AutoValidator createAutoValidator(ApplyFunction autoValidate)
autoValidate
The function to be applied for auto-validation.
an instance of AutoValidator .
public C triggerChangeListeners(V oldValue, V newValue)
oldValue
The old value.
newValue
The new value.
an instance of the concrete class.
public C triggerClearListeners(V oldValue)
oldValue
The old value.
an instance of the concrete class.
public String getName()
The name attribute of the input element.
public C setName(String name)
name
The name to set.
an instance of the concrete class.
public String getType()
The string "text".
public C withValue(V value)
value
The new value to set.
an instance of the concrete class.
public C addOptionsGroup(Collection<O> options, MenuItemsGroupHandler<T, AbstractMenuItem<T>> groupHandler)
options
The collection of options to add to the group.
groupHandler
The handler for the options group.
an instance of the concrete class.
public C group(MenuItemsGroupHandler<T, AbstractMenuItem<T>> groupHandler, Collection<O> options)
groupHandler
The handler for the options group.
options
The collection of options to group.
an instance of the concrete class.
public C withValue(V value, boolean silent)
value
The new value to set.
silent
If true, change listeners will not be notified.
an instance of the concrete class.
public C withOption(O option)
option
The option to add.
an instance of the concrete class.
public void setValue(V value)
value
The new value to set.
public C selectOption(O option)
option
The option to select.
an instance of the concrete class.
public int getSelectedIndex()
The index of the selected option, or -1 if no option is selected.
public Optional<O> findOption(O option)
option
The option to search for.
An Optional containing the matched option or empty if not found.
public Optional<O> findOptionByKey(String key)
key
The key of the option to search for.
An Optional containing the matched option or empty if not found.
public Optional<O> findOptionByValue(T value)
value
The value of the option to search for.
An Optional containing the matched option or empty if not found.
public Optional<O> findOptionByIndex(int index)
index
The index of the option to search for.
An Optional containing the matched option or empty if the index is out of bounds or not found.
public C selectAt(int index)
index
The index of the option to select.
an instance of the concrete class.
public C selectAt(int[] indices)
indices
The Indices of the options to select.
an instance of the concrete class.
public C selectAt(int index, boolean silent)
index
The index of the option to select.
silent
If true, change listeners will not be notified.
an instance of the concrete class.
public C selectAt(boolean silent, int[] indices)
indices
The Indices of the option to select.
silent
If true, change listeners will not be notified.
an instance of the concrete class.
public C selectByKey(String key)
key
The key of the option to select.
an instance of the concrete class.
public C selectByKey(String key, boolean silent)
key
The key of the option to select.
silent
If true, change listeners will not be notified.
an instance of the concrete class.
public C selectByValue(T value)
value
The value of the option to select.
an instance of the concrete class.
public C selectByValue(T value, boolean silent)
value
The value of the option to select.
silent
If true, change listeners will not be notified.
an instance of the concrete class.
public C deselectAt(int index)
index
The index of the option to deselect.
an instance of the concrete class.
public C deselectAt(int index, boolean silent)
index
The index of the option to deselect.
silent
If true, change listeners will not be notified.
an instance of the concrete class.
public C deselectByKey(String key)
key
The key of the option to deselect.
an instance of the concrete class.
public C deselectByKey(String key, boolean silent)
key
The key of the option to deselect.
silent
If true, change listeners will not be notified.
an instance of the concrete class.
public C deselectByValue(T value)
value
The value of the option to deselect.
an instance of the concrete class.
public C deselectByValue(T value, boolean silent)
value
The value of the option to deselect.
silent
If true, change listeners will not be notified.
an instance of the concrete class.
public boolean containsKey(String key)
key
The key to search for.
true if the option is found, otherwise false .
public boolean containsValue(T value)
value
The value to search for.
true if the option is found, otherwise false .
public C setClearable(boolean clearable)
clearable
true if the select should be clearable, otherwise false .
an instance of the concrete class.
public boolean isClearable()
true if the select is clearable, otherwise false .
public C setAutoCloseOnSelect(boolean autoClose)
autoClose
true if the select should automatically close after selection, otherwise false .
an instance of the concrete class.
public boolean isAutoCloseOnSelect()
true if the select auto-closes on select, otherwise false .
public C setSearchable(boolean searchable)
searchable
true if the select should provide search functionality, otherwise false .
an instance of the concrete class.
public boolean isSearchable()
true if the select is searchable, otherwise false .
public boolean isAllowCreateMissing()
true if the select allows creating missing options, otherwise false .
public Menu<T> getOptionsMenu()
The options menu.
public C withOptionsMenu(ChildHandler<C, Menu<T>> handler)
handler
The handler to apply.
an instance of the concrete class.
public C setMissingItemHandler(MissingOptionHandler<C, E, T, O> missingOptionHandler)
missingOptionHandler
The handler for missing options.
an instance of the concrete class.
public C removeOption(O option)
option
The option to remove.
an instance of the concrete class.
public C removeOptionAt(int index)
index
the index of the option to be removed.
an instance of the concrete class.
public C removeOptions(Collection<O> options)
options
The collection of options to remove.
an instance of the concrete class.
public C removeOptions(O[] options)
options
The array of options to remove.
an instance of the concrete class.
public C removeAllOptions()
an instance of the concrete class.
public C hide()
an instance of the concrete class.
public boolean isTypeToSelect()
true if the select component is selectable when start typing
public C setTypeToSelect(boolean typeToSelect)
typeToSelect
true if the select component should be selectable when start typing
public List<O> getOptions()
a list of options collected from the menu items
public C withOptions(ChildHandler<C, List<O>> handler)
handler
the handler responsible for applying additional options to the current instance and its associated list of options
the current instance with the applied options
public C withFieldInput(ChildHandler<C, DivElement> handler)
handler
a ChildHandler that performs actions using the current instance and the fieldInput element
the current instance after the handler is applied
public void Select()
public void Select(String label)
label
The label to be set for the select control.
public static Select<V> create()
public Select<V> withOption(SelectOption<V> option, boolean silent)
public V getValue()
the value of the currently selected option or null if no option is selected.
public void MultiSelect()
public void MultiSelect(String label)
label
the label for the MultiSelect
public static MultiSelect<V> create()
V
the type of the value
a new instance of MultiSelect
public static MultiSelect<V> create(String label)
label
the label for the MultiSelect
V
the type of the value
a new instance of MultiSelect
public MultiSelect<V> withValue(V[] value)
value
the values to set
the current MultiSelect instance for chaining
public MultiSelect<V> withValue(boolean silent, V[] value)
This method allows specifying multiple values and whether the change should notify listeners or not.
Usage example:
MultiSelect< String> multiSelect = MultiSelect.create("Select Items");
multiSelect.withValue(true, "Option1", "Option2"); // silent set
multiSelect.withValue(false, "Option3", "Option4"); // non-silent set
silent
if true , change listeners will not be triggered; if false , they will be triggered
value
the array of values to set
the current MultiSelect instance for chaining
See also :
public MultiSelect<V> withOption(SelectOption<V> option, boolean silent)
option
the option to add
silent
if true, change listeners will not be triggered
the current MultiSelect instance for chaining
public List<V> getValue()
a list of selected values
See also :
public MultiSelect<V> setWrapSelection(boolean wrapSelection)
If wrapSelection is true , the selection will wrap. Otherwise, it will be forced to stay on a single line using a no-wrap CSS class.
wrapSelection
true to allow wrapping, false to prevent wrapping
this MultiSelect instance for method chaining
public MultiSelect<V> setShowSelectionCount(boolean showSelectionCount)
If showSelectionCount is true , the selection count badge will be shown. Otherwise, it will be hidden using the appropriate CSS class.
showSelectionCount
true to display the selection count badge, false to hide it
this MultiSelect instance for method chaining