|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.vaadin.ui.AbstractComponent
com.vaadin.ui.AbstractField
com.vaadin.ui.AbstractSelect
public abstract class AbstractSelect
A class representing a selection of items the user has selected in a UI. The
set of choices is presented as a set of Item
s in a
Container
.
A Select
component may be in single- or multiselect mode.
Multiselect mode means that more than one item can be selected
simultaneously.
Nested Class Summary | |
---|---|
class |
AbstractSelect.AbstractSelectTargetDetails
TargetDetails implementation for subclasses of AbstractSelect
that implement DropTarget . |
static class |
AbstractSelect.AcceptItem
This criterion accepts a only a Transferable that contains given
Item (practically its identifier) from a specific AbstractSelect. |
protected class |
AbstractSelect.CaptionChangeListener
This is a listener helper for Item and Property changes that should cause a repaint. |
class |
AbstractSelect.DefaultNewItemHandler
TODO refine doc This is a default class that handles adding new items that are typed by user to selects container. |
static interface |
AbstractSelect.Filtering
Interface for option filtering, used to filter options based on user entered value. |
static interface |
AbstractSelect.ItemDescriptionGenerator
Implement this interface and pass it to Tree.setItemDescriptionGenerator or Table.setItemDescriptionGenerator to generate mouse over descriptions ("tooltips") for the rows and cells in Table or for the items in Tree. |
static class |
AbstractSelect.MultiSelectMode
Multi select modes that controls how multi select behaves. |
static interface |
AbstractSelect.NewItemHandler
|
static class |
AbstractSelect.TargetItemIs
Criterion which accepts a drop only if the drop target is (one of) the given Item identifier(s). |
static class |
AbstractSelect.VerticalLocationIs
An accept criterion to accept drops only on a specific vertical location of an item. |
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractField |
---|
AbstractField.FocusShortcut, AbstractField.ReadOnlyStatusChangeEvent |
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent |
---|
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler |
Nested classes/interfaces inherited from interface com.vaadin.data.Container |
---|
Container.Editor, Container.Filter, Container.Filterable, Container.Hierarchical, Container.Indexed, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.SimpleFilterable, Container.Sortable, Container.Viewer |
Nested classes/interfaces inherited from interface com.vaadin.ui.Field |
---|
Field.ValueChangeEvent |
Nested classes/interfaces inherited from interface com.vaadin.data.Buffered |
---|
Buffered.SourceException |
Nested classes/interfaces inherited from interface com.vaadin.data.Property |
---|
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer |
Field Summary | |
---|---|
static int |
ITEM_CAPTION_MODE_EXPLICIT
Item caption mode: Captions must be explicitly specified. |
static int |
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. |
static int |
ITEM_CAPTION_MODE_ICON_ONLY
Item caption mode: Only icons are shown, captions are hidden. |
static int |
ITEM_CAPTION_MODE_ID
Item caption mode: Item's ID's String representation is used
as caption. |
static int |
ITEM_CAPTION_MODE_INDEX
Item caption mode: Index of the item is used as caption. |
static int |
ITEM_CAPTION_MODE_ITEM
Item caption mode: Item's String representation is used as
caption. |
static int |
ITEM_CAPTION_MODE_PROPERTY
Item caption mode: Item captions are read from property specified with setItemCaptionPropertyId . |
protected KeyMapper |
itemIdMapper
Keymapper used to map key values. |
protected Container |
items
Select options. |
Constructor Summary | |
---|---|
AbstractSelect()
Creates an empty Select. |
|
AbstractSelect(String caption)
Creates an empty Select with caption. |
|
AbstractSelect(String caption,
Collection<?> options)
Creates a new select that is filled from a collection of option values. |
|
AbstractSelect(String caption,
Container dataSource)
Creates a new select that is connected to a data-source. |
Method Summary | |
---|---|
boolean |
addContainerProperty(Object propertyId,
Class<?> type,
Object defaultValue)
Adds the new property to all items. |
Object |
addItem()
Creates a new item into container with container managed id. |
Item |
addItem(Object itemId)
Create a new item into container. |
void |
addListener(Container.ItemSetChangeListener listener)
Adds an Item set change listener for the object. |
void |
addListener(Container.PropertySetChangeListener listener)
Adds a new Property set change listener for this Container. |
void |
attach()
Notifies the component that it is connected to an application. |
void |
changeVariables(Object source,
Map<String,Object> variables)
Invoked when the value of a variable has changed. |
void |
containerItemSetChange(Container.ItemSetChangeEvent event)
Lets the listener know a Containers Item set has changed. |
void |
containerPropertySetChange(Container.PropertySetChangeEvent event)
Notifies this listener that the Containers contents has changed. |
boolean |
containsId(Object itemId)
Tests, if the collection contains an item with given id. |
void |
detach()
Detaches the component from application. |
protected void |
fireItemSetChange()
Fires the item set change event. |
protected void |
firePropertySetChange()
Fires the property set change event. |
protected AbstractSelect.CaptionChangeListener |
getCaptionChangeListener()
|
Container |
getContainerDataSource()
Gets the viewing data-source container. |
Property |
getContainerProperty(Object itemId,
Object propertyId)
Gets the Property identified by the given itemId and propertyId from the Container |
Collection<?> |
getContainerPropertyIds()
Gets the property Id collection from the container. |
Item |
getItem(Object itemId)
Gets the item from the container with given id. |
String |
getItemCaption(Object itemId)
Gets the caption of an item. |
int |
getItemCaptionMode()
Gets the item caption mode. |
Object |
getItemCaptionPropertyId()
Gets the item caption property. |
Resource |
getItemIcon(Object itemId)
Gets the item icon. |
Object |
getItemIconPropertyId()
Gets the item icon property. |
Collection<?> |
getItemIds()
Gets the item Id collection from the container. |
Collection<?> |
getListeners(Class<?> eventType)
Returns all listeners that are registered for the given event type or one of its subclasses. |
AbstractSelect.NewItemHandler |
getNewItemHandler()
TODO refine doc |
Object |
getNullSelectionItemId()
Returns the item id that represents null value of this select in single select mode. |
Class<?> |
getType()
Returns the type of the property. |
Class<?> |
getType(Object propertyId)
Gets the property type. |
Object |
getValue()
Gets the selected item id or in multiselect mode a set of selected ids. |
Collection<?> |
getVisibleItemIds()
Gets the visible item ids. |
protected boolean |
isEmpty()
For multi-selectable fields, also an empty collection of values is considered to be an empty field. |
boolean |
isMultiSelect()
Is the select in multiselect mode? In multiselect mode |
boolean |
isNewItemsAllowed()
Does the select allow adding new options by the user. |
boolean |
isNullSelectionAllowed()
Checks if null empty selection is allowed by the user. |
boolean |
isSelected(Object itemId)
Tests if an item is selected. |
void |
paintContent(PaintTarget target)
Paints the content of this component. |
protected void |
paintItem(PaintTarget target,
Object itemId)
|
boolean |
removeAllItems()
Removes all items from the container. |
boolean |
removeContainerProperty(Object propertyId)
Removes the property from all items. |
boolean |
removeItem(Object itemId)
Removes the Item identified by ItemId from the Container. |
void |
removeListener(Container.ItemSetChangeListener listener)
Removes the Item set change listener from the object. |
void |
removeListener(Container.PropertySetChangeListener listener)
Removes a previously registered Property set change listener. |
void |
sanitizeSelection()
Checks that the current selection is valid, i.e. |
void |
select(Object itemId)
Selects an item. |
void |
setContainerDataSource(Container newDataSource)
Sets the Container that serves as the data source of the viewer. |
void |
setItemCaption(Object itemId,
String caption)
Override the caption of an item. |
void |
setItemCaptionMode(int mode)
Sets the item caption mode. |
void |
setItemCaptionPropertyId(Object propertyId)
Sets the item caption property. |
void |
setItemIcon(Object itemId,
Resource icon)
Sets the icon for an item. |
void |
setItemIconPropertyId(Object propertyId)
Sets the item icon property. |
void |
setMultiSelect(boolean multiSelect)
Sets the multiselect mode. |
void |
setNewItemHandler(AbstractSelect.NewItemHandler newItemHandler)
TODO refine doc Setter for new item handler that is called when user adds new item in newItemAllowed mode. |
void |
setNewItemsAllowed(boolean allowNewOptions)
Enables or disables possibility to add new options by the user. |
void |
setNullSelectionAllowed(boolean nullSelectionAllowed)
Allow or disallow empty selection by the user. |
void |
setNullSelectionItemId(Object nullSelectionItemId)
Sets the item id that represents null value of this select. |
void |
setValue(Object newValue)
Sets the visible value of the property. |
protected void |
setValue(Object newValue,
boolean repaintIsNotNeeded)
Sets the visible value of the property. |
int |
size()
Gets the number of visible Items in the Container. |
void |
unselect(Object itemId)
Unselects an item. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.vaadin.ui.Field |
---|
getDescription, setCaption, setDescription |
Field Detail |
---|
public static final int ITEM_CAPTION_MODE_ID
String
representation is used
as caption.
public static final int ITEM_CAPTION_MODE_ITEM
String
representation is used as
caption.
public static final int ITEM_CAPTION_MODE_INDEX
Container.Indexed
interface.
public static final int ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID
String
representation is used as caption. This is
the default.
public static final int ITEM_CAPTION_MODE_EXPLICIT
public static final int ITEM_CAPTION_MODE_ICON_ONLY
public static final int ITEM_CAPTION_MODE_PROPERTY
setItemCaptionPropertyId
.
protected Container items
protected KeyMapper itemIdMapper
Constructor Detail |
---|
public AbstractSelect()
public AbstractSelect(String caption)
public AbstractSelect(String caption, Container dataSource)
caption
- the Caption of the component.dataSource
- the Container datasource to be selected from by this select.public AbstractSelect(String caption, Collection<?> options)
caption
- the Caption of this field.options
- the Collection containing the options.Method Detail |
---|
public void paintContent(PaintTarget target) throws PaintException
paintContent
in class AbstractField
target
- the Paint Event.
PaintException
- if the paint operation failed.protected void paintItem(PaintTarget target, Object itemId) throws PaintException
PaintException
public void changeVariables(Object source, Map<String,Object> variables)
changeVariables
in interface VariableOwner
changeVariables
in class AbstractField
source
- the Source of the variable change. This is the origin of the
event. For example in Web Adapter this is the request.variables
- the Mapping from variable names to new variable values.AbstractComponent.changeVariables(java.lang.Object,
java.util.Map)
public void setNewItemHandler(AbstractSelect.NewItemHandler newItemHandler)
newItemHandler
- public AbstractSelect.NewItemHandler getNewItemHandler()
public Collection<?> getVisibleItemIds()
public Class<?> getType()
getValue
and
setValue
methods 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
in interface Property
getType
in class AbstractField
public Object getValue()
getValue
in interface Property
getValue
in class AbstractField
AbstractField.getValue()
public void setValue(Object newValue) throws Property.ReadOnlyException, Property.ConversionException
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.
setValue
in interface Property
setValue
in class AbstractField
newValue
- the New selected item or collection of selected items.
Property.ReadOnlyException
- if the object is in read-only mode
Property.ConversionException
- if newValue can't be converted into the Property's native
type directly or through StringAbstractField.setValue(java.lang.Object)
protected void setValue(Object newValue, boolean repaintIsNotNeeded) throws Property.ReadOnlyException, Property.ConversionException
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.
setValue
in class AbstractField
newValue
- the New selected item or collection of selected items.repaintIsNotNeeded
- True if caller is sure that repaint is not needed.
Property.ReadOnlyException
Property.ConversionException
com.vaadin.ui.AbstractField#setValue(java.lang.Object,
java.lang.Boolean)
public Item getItem(Object itemId)
getItem
in interface Container
itemId
- the item id.
public Collection<?> getItemIds()
getItemIds
in interface Container
public Collection<?> getContainerPropertyIds()
getContainerPropertyIds
in interface Container
public Class<?> getType(Object propertyId)
getType
in interface Container
propertyId
- the Id identifying the property.
Container.getType(java.lang.Object)
public int size()
Container
size
in interface Container
public boolean containsId(Object itemId)
containsId
in interface Container
itemId
- the Id the of item to be tested.
public Property getContainerProperty(Object itemId, Object propertyId)
getContainerProperty
in interface Container
itemId
- ID of the visible Item which contains the PropertypropertyId
- ID of the Property to retrieve
null
Container.getContainerProperty(Object, Object)
public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) throws UnsupportedOperationException
addContainerProperty
in interface Container
propertyId
- ID of the Propertytype
- Data type of the new PropertydefaultValue
- The value all created Properties are initialized to
UnsupportedOperationException
- if the container does not support explicitly adding container
propertiesContainer.addContainerProperty(java.lang.Object,
java.lang.Class, java.lang.Object)
public boolean removeAllItems() throws UnsupportedOperationException
removeAllItems
in interface Container
UnsupportedOperationException
- if the container does not support removing all itemsContainer.removeAllItems()
public Object addItem() throws UnsupportedOperationException
addItem
in interface Container
UnsupportedOperationException
- if adding an item without an explicit item ID is not
supported by the containerContainer.addItem()
public Item addItem(Object itemId) throws UnsupportedOperationException
addItem
in interface Container
itemId
- the Identification of the item to be created.
UnsupportedOperationException
- if adding an item with an explicit item ID is not supported
by the containerContainer.addItem(java.lang.Object)
public boolean removeItem(Object itemId) throws UnsupportedOperationException
Container
ItemId
from the Container.
Containers that support filtering should also allow removing an item that is currently filtered out.
This functionality is optional.
removeItem
in interface Container
itemId
- ID of the Item to remove
true
if the operation succeeded, false
if not
UnsupportedOperationException
- if the container does not support removing individual itemspublic void sanitizeSelection()
public boolean removeContainerProperty(Object propertyId) throws UnsupportedOperationException
removeContainerProperty
in interface Container
propertyId
- ID of the Property to remove
UnsupportedOperationException
- if the container does not support removing container
propertiesContainer.removeContainerProperty(java.lang.Object)
public void setContainerDataSource(Container newDataSource)
setContainerDataSource
in interface Container.Viewer
newDataSource
- the new data source.Container.Viewer.setContainerDataSource(Container)
public Container getContainerDataSource()
getContainerDataSource
in interface Container.Viewer
Container.Viewer.getContainerDataSource()
public boolean isMultiSelect()
public void setMultiSelect(boolean multiSelect)
multiSelect
- the New value of property multiSelect.public boolean isNewItemsAllowed()
public void setNewItemsAllowed(boolean allowNewOptions)
allowNewOptions
- the New value of property allowNewOptions.public void setItemCaption(Object itemId, String caption)
itemId
- the id of the item to be recaptioned.caption
- the New caption.public String getItemCaption(Object itemId)
setItemCaptionMode()
for more
details.
itemId
- the id of the item to be queried.
public void setItemIcon(Object itemId, Resource icon)
itemId
- the id of the item to be assigned an icon.icon
- the icon to use or null.public Resource getItemIcon(Object itemId)
itemId
- the id of the item to be assigned an icon.
public void setItemCaptionMode(int 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
.ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID
is the default
mode.
mode
- the One of the modes listed above.public int getItemCaptionMode()
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
.ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID
is the default
mode.
public void setItemCaptionPropertyId(Object propertyId)
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
.
propertyId
- the id of the property.public Object getItemCaptionPropertyId()
public void setItemIconPropertyId(Object propertyId) throws IllegalArgumentException
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 Resource.
Note : 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
.
propertyId
- the id of the property that specifies icons for items or null
IllegalArgumentException
- If the propertyId is not in the container or is not of a
valid typepublic Object getItemIconPropertyId()
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 : 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
.
public boolean isSelected(Object itemId)
In single select mode testing selection status of the item identified by
getNullSelectionItemId()
returns true if the value of the
property is null.
itemId
- the Id the of the item to be tested.getNullSelectionItemId()
,
setNullSelectionItemId(Object)
public void select(Object itemId)
In single select mode selecting item identified by
getNullSelectionItemId()
sets the value of the property to null.
itemId
- the identifier of Item to be selected.getNullSelectionItemId()
,
setNullSelectionItemId(Object)
public void unselect(Object itemId)
itemId
- the identifier of the Item to be unselected.getNullSelectionItemId()
,
setNullSelectionItemId(Object)
public void containerPropertySetChange(Container.PropertySetChangeEvent event)
containerPropertySetChange
in interface Container.PropertySetChangeListener
event
- Change event.Container.PropertySetChangeListener.containerPropertySetChange(com.vaadin.data.Container.PropertySetChangeEvent)
public void addListener(Container.PropertySetChangeListener listener)
addListener
in interface Container.PropertySetChangeNotifier
listener
- The new Listener to be registeredContainer.PropertySetChangeNotifier.addListener(com.vaadin.data.Container.PropertySetChangeListener)
public void removeListener(Container.PropertySetChangeListener listener)
removeListener
in interface Container.PropertySetChangeNotifier
listener
- Listener to be removedContainer.PropertySetChangeNotifier.removeListener(com.vaadin.data.Container.PropertySetChangeListener)
public void addListener(Container.ItemSetChangeListener listener)
addListener
in interface Container.ItemSetChangeNotifier
listener
- listener to be addedContainer.ItemSetChangeNotifier.addListener(com.vaadin.data.Container.ItemSetChangeListener)
public void removeListener(Container.ItemSetChangeListener listener)
removeListener
in interface Container.ItemSetChangeNotifier
listener
- listener to be removedContainer.ItemSetChangeNotifier.removeListener(com.vaadin.data.Container.ItemSetChangeListener)
public Collection<?> getListeners(Class<?> eventType)
AbstractComponent
getListeners
in class AbstractComponent
eventType
- The type of event to return listeners for.
public void containerItemSetChange(Container.ItemSetChangeEvent event)
containerItemSetChange
in interface Container.ItemSetChangeListener
event
- change event textContainer.ItemSetChangeListener.containerItemSetChange(com.vaadin.data.Container.ItemSetChangeEvent)
protected void firePropertySetChange()
protected void fireItemSetChange()
protected boolean isEmpty()
isEmpty
in class AbstractField
AbstractField.isEmpty().
public void setNullSelectionAllowed(boolean nullSelectionAllowed)
setNullSelectionItemId()
. This way you can for
instance set an icon and caption for the null selection item.
nullSelectionAllowed
- whether or not to allow empty selectionsetNullSelectionItemId(Object)
,
isNullSelectionAllowed()
public boolean isNullSelectionAllowed()
setNullSelectionAllowed(boolean)
public Object getNullSelectionItemId()
Data interface does not support nulls as item ids. Selecting the item identified by this id is the same as selecting no items at all. This setting only affects the single select mode.
setNullSelectionItemId(Object)
,
isSelected(Object)
,
select(Object)
public void setNullSelectionItemId(Object nullSelectionItemId)
Data interface does not support nulls as item ids. Selecting the item identified by this id is the same as selecting no items at all. This setting only affects the single select mode.
nullSelectionItemId
- the nullSelectionItemId to set.getNullSelectionItemId()
,
isSelected(Object)
,
select(Object)
public void attach()
attach
in interface Component
attach
in class AbstractField
AbstractField.attach()
public void detach()
detach
in interface Component
detach
in class AbstractField
AbstractComponent.detach()
protected AbstractSelect.CaptionChangeListener getCaptionChangeListener()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |