Class Select

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.

Synopsis

VERSION@

Since

3.0

Inheritance Path.  java.lang.Object-> com.itmill.toolkit.ui.AbstractComponent -> com.itmill.toolkit.ui.AbstractField -> com.itmill.toolkit.ui.Select

Select()

Creates an empty Select. The caption is not used.

Select(String)

Creates an empty Select with caption.

Select(String, Collection)

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.

Select(String, Container)

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_EXPLICIT

Item caption mode: Captions must be explicitly specified.

ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID

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_ICON_ONLY

Item caption mode: Only icons are shown, captions are hidden.

ITEM_CAPTION_MODE_ID

Item caption mode: Item's ID's String representation is used as caption.

ITEM_CAPTION_MODE_INDEX

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.

ITEM_CAPTION_MODE_ITEM

Item caption mode: Item's String representation is used as caption.

ITEM_CAPTION_MODE_PROPERTY

Item caption mode: Item captions are read from property specified with setItemCaptionPropertyId .

addContainerProperty(Object, Class, Object)

Parameters

return

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.

addItem()

Parameters

return

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.

addItem(Object)

Parameters

itemId

Identification of the item to be created.

return

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.

addListener(Container.ItemSetChangeListener)

Parameters

listener

listener to be added

Description copied from interface: addListener

Adds a Item set change listener for the object.

addListener(Container.PropertySetChangeListener)

Parameters

listener

The new Listener to be registered

Description copied from interface: addListener

Registers a new Property set change listener for this Container.

attach()

See Also
org.millstone.base.ui.Component#attach()

changeVariables(Object, Map)

Parameters

event

Variable change event containing the information about the changed variable.

Invoked when the value of a variable has changed.

containerItemSetChange(Container.ItemSetChangeEvent)

Parameters

event

change event text

Description copied from interface: containerItemSetChange

Lets the listener know a Containers Item set has changed.

containerPropertySetChange(Container.PropertySetChangeEvent)

Parameters

event

Change event.

Description copied from interface: containerPropertySetChange

Notifies this listener that the Containers contents has changed.

containsId(Object)

Parameters

itemId

Id the of item to be tested.

Test, if the collection contains an item with given id.

detach()

See Also
org.millstone.base.ui.Component#detach()

getContainerDataSource()

Get viewing data-source container.

getContainerProperty(Object, Object)

Parameters

itemId

ID of the Item which contains the Property

propertyId

ID of the Property to retrieve

return

Property with the given ID or null

Description copied from interface: getContainerProperty

Gets the Property identified by the given itemId and propertyId from the Container. If the Container does not contain the Property, null is returned.

getContainerPropertyIds()

Parameters

return

Collection of property ids.

Get property Id collection from the container.

getItem(Object)

Get the item from the container with given id. If the container does not contain the requested item, null is returned.

getItemCaption(Object)

Parameters

itemId

The id of the item to be queried.

return

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.

getItemCaptionMode()

Parameters

return

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.

getItemCaptionPropertyId()

Parameters

return

Id of the property used as item caption source.

Get the item caption property.

getItemIcon(Object)

Parameters

itemId

The id of the item to be assigned an icon.

return

Icon for the item or null, if not specified.

Get the item icon.

getItemIconPropertyId()

Parameters

return

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

.

getItemIds()

Parameters

return

Collection of item ids.

Get item Id collection from the container.

getNullSelectionItemId()

Parameters

return

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.

getTag()

Parameters

return

Component UIDL tag as string.

Get component UIDL tag.

getType()

Parameters

return

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().

getType(Object)

Parameters

id

Id identifying the of the property.

Get property type.

getValue()

Get the selected item id or in multiselect mode a set of selected ids.

getVisibleItemIds()

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.

isMultiSelect()

Parameters

return

Value of property multiSelect.

Is the select in multiselect mode? In multiselect mode

isNewItemsAllowed()

Parameters

return

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).

isSelected(Object)

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.

paintContent(PaintTarget)

Parameters

event

PaintEvent.

Exceptions

PaintException

The paint operation failed.

Paint the content of this component.

removeAllItems()

Parameters

return

True iff the operation succeeded.

Remove all items from the container. This functionality is optional. If the function is unsupported, it always returns false.

removeContainerProperty(Object)

Parameters

return

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.

removeItem(Object)

Parameters

return

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.

removeListener(Container.ItemSetChangeListener)

Parameters

listener

listener to be removed

Description copied from interface: removeListener

Removes a Item set change listener from the object.

removeListener(Container.PropertySetChangeListener)

Parameters

listener

Listener to be removed

Description copied from interface: removeListener

Removes a previously registered Property set change listener.

select(Object)

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.

setContainerDataSource(Container)

Set the container as data-source for viewing.

setItemCaption(Object, String)

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.

setItemCaptionMode(int)

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.

setItemCaptionPropertyId(Object)

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

.

setItemIcon(Object, Resource)

Parameters

itemId

The id of the item to be assigned an icon.

icon

New icon.

Set icon for an item.

setItemIconPropertyId(Object)

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

.

setMultiSelect(boolean)

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.

setNewItemsAllowed(boolean)

Parameters

allowNewOptions

New value of property allowNewOptions.

Enable or disable possibility to add new options by the user.

setNullSelectionItemId(Object)

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.

setValue(Object)

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.

size()

Parameters

return

Number of items in the container.

Get the number of items in the container.

unselect(Object)

Parameters

itemId

Item to be unselected.

Unselect an item.