A class representing a selection of items the user has selected in a UI. The
set of choices is presented as a set of
com.itmill.toolkit.data.Item
s
in a
com.itmill.toolkit.data.Container
.
A
Select
component may be in single- or multiselect mode.
Multiselect mode means that more than one item can be selected
simultaneously.
3.0
Inheritance Path. java.lang.Object-> com.itmill.toolkit.ui.AbstractComponent -> com.itmill.toolkit.ui.AbstractField -> com.itmill.toolkit.ui.Select
Parameters
caption
Caption of this field.
options
Collection containing the options.
selected
Selected option or null, if none selected.
Creates a new select that is filled from a collection of option values.
Parameters
dataSource
Container datasource to be selected from by this select.
caption
Caption of the component.
selected
Selected item id or null, if none selected.
Creates a new select wthat is connected to a data-source.
Item caption mode: If an Item has a caption it's used, if not, Item's
ID's
String
representation is used as caption.
This is
the default
.
Item caption mode: Index of the item is used as caption. The index mode
can only be used with the containers implementing the
com.itmill.toolkit.data.Container.Indexed
interface.
Parameters
True iff the operation succeeded.
Add new property to all items. Adds a property with given id, type and default value to all items in the container. This functionality is optional. If the function is unsupported, it always returns false.
Parameters
Id of the created item or null in case of failure.
Create a new item into container with container managed id. The id of the created new item is returned. The item can be fetched with getItem() method. if the creation fails, null is returned.
Parameters
itemId
Identification of the item to be created.
Created item with the given id, or null in case of failure.
Create a new item into container. The created new item is returned and ready for setting property values. if the creation fails, null is returned. In case the container already contains the item, null is returned. This functionality is optional. If the function is unsupported, it always returns null.
Parameters
listener
listener to be added
Adds a Item set change listener for the object.
Parameters
listener
The new Listener to be registered
Registers a new Property set change listener for this Container.
Parameters
event
Variable change event containing the information about the changed variable.
Invoked when the value of a variable has changed.
Parameters
event
change event text
Lets the listener know a Containers Item set has changed.
Parameters
event
Change event.
Notifies this listener that the Containers contents has changed.
Parameters
itemId
Id the of item to be tested.
Test, if the collection contains an item with given id.
Parameters
itemId
ID of the Item which contains the Property
propertyId
ID of the Property to retrieve
Property with the given ID or
null
Gets the Property identified by the given itemId and propertyId from the
Container. If the Container does not contain the Property,
null
is returned.
Parameters
Collection of property ids.
Get property Id collection from the container.
Get the item from the container with given id. If the container does not contain the requested item, null is returned.
Parameters
itemId
The id of the item to be queried.
caption for specified item.
Get the caption of an item. The caption is generated as specified by the
item caption mode. See
setItemCaptionMode()
for more
details.
Parameters
One of the modes listed above.
Get the item caption mode.
The mode can be one of the following ones:
ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID
: Items
Id-objects
toString()
is used as item caption. If caption
is explicitly specified, it overrides the id-caption.
ITEM_CAPTION_MODE_ID
: Items Id-objects
toString()
is used as item caption.
ITEM_CAPTION_MODE_ITEM
: Item-objects
toString()
is used as item caption.
ITEM_CAPTION_MODE_INDEX
: The index of the item is
used as item caption. The index mode can only be used with the containers
implementing
Container.Indexed
interface.
ITEM_CAPTION_MODE_EXPLICIT
: The item captions must
be explicitly specified.
ITEM_CAPTION_MODE_PROPERTY
: The item captions are
read from property, that must be specified with
setItemCaptionPropertyId()
.
The
ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID
is the default
mode.
Parameters
Id of the property used as item caption source.
Get the item caption property.
Parameters
itemId
The id of the item to be assigned an icon.
Icon for the item or null, if not specified.
Get the item icon.
Parameters
Id of the property containing the item icons.
Get the item icon property.
If the property id is set to a valid value, each item is given an icon got from the given property of the items. The type of the property must be assignable to Icon.
Note that the icons set with
setItemIcon
function override
the icons from the property.
Setting the property id to null disables this feature. The id is null by default
.
Parameters
Object Null value item id.
Returns the item id that represents null value of this select in single select mode.
Data interface does not support nulls as item ids. Selecting the item idetified by this id is the same as selecting no items at all. This setting only affects the single select mode.
Parameters
type Type of the property.
Return the type of the property. getValue and setValue functions must be compatible with this type: one can safely cast getValue() to given type and pass any variable assignable to this type as a parameter to setValue().
Get the visible item ids. In Select, this returns list of all item ids, but can be overriden in subclasses if they paint only part of the items to the terminal or null if no items is visible.
Parameters
Value of property multiSelect.
Is the select in multiselect mode? In multiselect mode
Parameters
True iff additions are allowed.
Does the select allow adding new options by the user. If true, the new options can be added to the Container. The text entered by the user is used as id. No that data-source must allow adding new items (it must implement Container.Managed).
Parameters
itemId
Id the of the item to be tested
Test if an item is selected
In single select mode testing selection status of the item identified by
getNullSelectionItemId()
returns true if the value of the
property is null.
Parameters
event
PaintEvent.
Exceptions
PaintException
The paint operation failed.
Paint the content of this component.
Parameters
True iff the operation succeeded.
Remove all items from the container. This functionality is optional. If the function is unsupported, it always returns false.
Parameters
True iff the operation succeeded.
Remove property from all items. Removes a property with given id from all the items in the container. This functionality is optional. If the function is unsupported, it always returns false.
Parameters
True iff the operation succeeded.
Remove item identified by Id from the container. This functionality is optional. If the function is not implemented, the functions allways returns false.
Parameters
listener
listener to be removed
Removes a Item set change listener from the object.
Parameters
listener
Listener to be removed
Removes a previously registered Property set change listener.
Parameters
itemId
Item to be selected.
Select an item.
In single select mode selecting item identified by
getNullSelectionItemId()
sets the value of the property to null.
Parameters
itemId
The id of the item to be recaptioned.
caption
New caption.
Override the caption of an item. Setting caption explicitly overrides id, item and index captions.
Parameters
mode
One of the modes listed above.
Set the item caption mode.
The mode can be one of the following ones:
ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID
: Items
Id-objects
toString()
is used as item caption. If caption
is explicitly specified, it overrides the id-caption.
ITEM_CAPTION_MODE_ID
: Items Id-objects
toString()
is used as item caption.
ITEM_CAPTION_MODE_ITEM
: Item-objects
toString()
is used as item caption.
ITEM_CAPTION_MODE_INDEX
: The index of the item is
used as item caption. The index mode can only be used with the containers
implementing
Container.Indexed
interface.
ITEM_CAPTION_MODE_EXPLICIT
: The item captions must
be explicitly specified.
ITEM_CAPTION_MODE_PROPERTY
: The item captions are
read from property, that must be specified with
setItemCaptionPropertyId()
.
The
ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID
is the default
mode.
Set the item caption property.
Setting the id to a existing property implicitly sets the item caption
mode to
ITEM_CAPTION_MODE_PROPERTY
. If the object is in
ITEM_CAPTION_MODE_PROPERTY
mode, setting caption property
id null resets the item caption mode to
ITEM_CAPTION_EXPLICIT_DEFAULTS_ID
.
Setting the property id to null disables this feature. The id is null by default
.
Parameters
itemId
The id of the item to be assigned an icon.
icon
New icon.
Set icon for an item.
Parameters
propertyId
Id of the property that specifies icons for items.
Set the item icon property.
If the property id is set to a valid value, each item is given an icon got from the given property of the items. The type of the property must be assignable to Icon.
Note that the icons set with
setItemIcon
function override
the icons from the property.
Setting the property id to null disables this feature. The id is null by default
.
Parameters
multiSelect
New value of property multiSelect.
Set the multiselect mode. Setting multiselect mode false may loose selection information: if selected items set contains one or more selected items, only one of the selected items is kept as selected.
Parameters
allowNewOptions
New value of property allowNewOptions.
Enable or disable possibility to add new options by the user.
Parameters
nullPropertyValueContainerItemId
The nullPropertyValueContainerItemId to set
Sets the item id that represents null value of this select.
Data interface does not support nulls as item ids. Selecting the item idetified by this id is the same as selecting no items at all. This setting only affects the single select mode.
Parameters
newValue
New selected item or collection of selected items.
Set the visible value of the property.
The value of the select is the selected item id. If the select is in multiselect-mode, the value is a set of selected item keys. In multiselect mode all collections of id:s can be assigned.
Parameters
Number of items in the container.
Get the number of items in the container.
Parameters
itemId
Item to be unselected.
Unselect an item.