com.vaadin.ui
Class AbstractSelect

java.lang.Object
  extended by com.vaadin.terminal.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
          extended by com.vaadin.ui.AbstractField<Object>
              extended by com.vaadin.ui.AbstractSelect
All Implemented Interfaces:
Buffered, BufferedValidatable, Container, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.Viewer, Property<Object>, Property.Editor, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer, Validatable, Action.ShortcutNotifier, MethodEventSource, Connector, ClientConnector, RpcTarget, Sizeable, Vaadin6Component, VariableOwner, Component, Component.Focusable, Field<Object>, Serializable, EventListener
Direct Known Subclasses:
ListSelect, NativeSelect, OptionGroup, Select, Table, Tree, TwinColSelect

public abstract class AbstractSelect
extends AbstractField<Object>
implements Container, Container.Viewer, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.ItemSetChangeNotifier, Container.ItemSetChangeListener, Vaadin6Component

A class representing a selection of items the user has selected in a UI. The set of choices is presented as a set of Items 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.

Since:
5.0
Version:
7.0.0.alpha3
Author:
Vaadin Ltd.
See Also:
Serialized Form

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 class AbstractSelect.ItemCaptionMode
           
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.terminal.VariableOwner
VariableOwner.ErrorEvent
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener
 
Nested classes/interfaces inherited from interface com.vaadin.terminal.Sizeable
Sizeable.Unit
 
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.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.Transactional<T>, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer
 
Field Summary
static AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_EXPLICIT
          Deprecated. from 7.0, use ItemCaptionMode.ID instead
static AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID
          Deprecated. from 7.0, use ItemCaptionMode.ID instead
static AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_ICON_ONLY
          Deprecated. from 7.0, use ItemCaptionMode.ID instead
static AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_ID
          Deprecated. from 7.0, use ItemCaptionMode.ID instead
static AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_INDEX
          Deprecated. from 7.0, use ItemCaptionMode.ID instead
static AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_ITEM
          Deprecated. from 7.0, use ItemCaptionMode.ID instead
static AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_PROPERTY
          Deprecated. from 7.0, use ItemCaptionMode.ID instead
protected  KeyMapper<Object> itemIdMapper
          Keymapper used to map key values.
protected  Container items
          Select options.
 
Fields inherited from interface com.vaadin.terminal.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
 
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.
 AbstractSelect.ItemCaptionMode 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 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(AbstractSelect.ItemCaptionMode mode)
          Sets the item caption mode.
 void setItemCaptionPropertyId(Object propertyId)
          Sets the item caption property.
 void setItemIcon(Object itemId, Resource icon)
          Sets tqhe 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 com.vaadin.ui.AbstractField
addListener, addListener, addValidator, commit, discard, fireReadOnlyStatusChange, fireValueChange, focus, getConversionError, getConversionError, getConvertedValue, getConverter, getCurrentBufferedSourceException, getErrorMessage, getInternalValue, getPropertyDataSource, getRequiredError, getState, getTabIndex, getValidators, isBuffered, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isReadThrough, isRequired, isValid, isValidationVisible, isWriteThrough, readOnlyStatusChange, removeAllValidators, removeListener, removeListener, removeValidator, setBuffered, setConversionError, setConvertedValue, setConverter, setConverter, setCurrentBufferedSourceException, setInternalValue, setInvalidAllowed, setInvalidCommitted, setPropertyDataSource, setReadOnly, setReadThrough, setRequired, setRequiredError, setTabIndex, setValidationVisible, setWriteThrough, shouldHideErrors, toString, updateState, validate, validate, valueChange
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addListener, addListener, addListener, addListener, addShortcutListener, addStyleName, findAncestor, fireComponentErrorEvent, fireComponentEvent, fireEvent, getActionManager, getApplication, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getHeight, getHeightUnits, getIcon, getLocale, getParent, getRoot, getStyle, getStyleName, getWidth, getWidthUnits, handleError, hasListeners, isConnectorEnabled, isEnabled, isImmediate, isVisible, removeListener, removeListener, removeListener, removeListener, removeListener, removeShortcutListener, removeStyleName, requestRepaint, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setErrorHandler, setHeight, setHeight, setIcon, setImmediate, setLocale, setParent, setSizeFull, setSizeUndefined, setStyle, setStyleName, setVisible, setWidth, setWidth
 
Methods inherited from class com.vaadin.terminal.AbstractClientConnector
addExtension, addMethodInvocationToQueue, createState, getAllChildrenIterable, getConnectorId, getExtensions, getRpcManager, getRpcProxy, getStateType, registerRpc, registerRpc, removeExtension, requestRepaintAll, retrievePendingRpcCalls
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.vaadin.terminal.VariableOwner
isEnabled, isImmediate
 
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, getApplication, getCaption, getDebugId, getIcon, getLocale, getParent, getRoot, getState, getStyleName, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setDebugId, setEnabled, setIcon, setReadOnly, setStyleName, setVisible, updateState
 
Methods inherited from interface com.vaadin.terminal.gwt.server.ClientConnector
getExtensions, getStateType, isConnectorEnabled, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setParent
 
Methods inherited from interface com.vaadin.terminal.gwt.client.Connector
getConnectorId
 
Methods inherited from interface com.vaadin.terminal.gwt.server.RpcTarget
getRpcManager
 
Methods inherited from interface com.vaadin.terminal.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setSizeFull, setSizeUndefined, setWidth, setWidth
 
Methods inherited from interface com.vaadin.event.Action.ShortcutNotifier
addShortcutListener, removeShortcutListener
 

Field Detail

ITEM_CAPTION_MODE_ID

@Deprecated
public static final AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_ID
Deprecated. from 7.0, use ItemCaptionMode.ID instead

ITEM_CAPTION_MODE_ITEM

@Deprecated
public static final AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_ITEM
Deprecated. from 7.0, use ItemCaptionMode.ID instead

ITEM_CAPTION_MODE_INDEX

@Deprecated
public static final AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_INDEX
Deprecated. from 7.0, use ItemCaptionMode.ID instead

ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID

@Deprecated
public static final AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID
Deprecated. from 7.0, use ItemCaptionMode.ID instead

ITEM_CAPTION_MODE_EXPLICIT

@Deprecated
public static final AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_EXPLICIT
Deprecated. from 7.0, use ItemCaptionMode.ID instead

ITEM_CAPTION_MODE_ICON_ONLY

@Deprecated
public static final AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_ICON_ONLY
Deprecated. from 7.0, use ItemCaptionMode.ID instead

ITEM_CAPTION_MODE_PROPERTY

@Deprecated
public static final AbstractSelect.ItemCaptionMode ITEM_CAPTION_MODE_PROPERTY
Deprecated. from 7.0, use ItemCaptionMode.ID instead

items

protected Container items
Select options.


itemIdMapper

protected KeyMapper<Object> itemIdMapper
Keymapper used to map key values.

Constructor Detail

AbstractSelect

public AbstractSelect()
Creates an empty Select. The caption is not used.


AbstractSelect

public AbstractSelect(String caption)
Creates an empty Select with caption.


AbstractSelect

public AbstractSelect(String caption,
                      Container dataSource)
Creates a new select that is connected to a data-source.

Parameters:
caption - the Caption of the component.
dataSource - the Container datasource to be selected from by this select.

AbstractSelect

public AbstractSelect(String caption,
                      Collection<?> options)
Creates a new select that is filled from a collection of option values.

Parameters:
caption - the Caption of this field.
options - the Collection containing the options.
Method Detail

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException
Paints the content of this component.

Specified by:
paintContent in interface Vaadin6Component
Parameters:
target - the Paint Event.
Throws:
PaintException - if the paint operation failed.

paintItem

protected void paintItem(PaintTarget target,
                         Object itemId)
                  throws PaintException
Throws:
PaintException

changeVariables

public void changeVariables(Object source,
                            Map<String,Object> variables)
Invoked when the value of a variable has changed.

Specified by:
changeVariables in interface VariableOwner
Parameters:
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.
See Also:
com.vaadin.ui.AbstractComponent#changeVariables(java.lang.Object, java.util.Map)

setNewItemHandler

public void setNewItemHandler(AbstractSelect.NewItemHandler newItemHandler)
TODO refine doc Setter for new item handler that is called when user adds new item in newItemAllowed mode.

Parameters:
newItemHandler -

getNewItemHandler

public AbstractSelect.NewItemHandler getNewItemHandler()
TODO refine doc

Returns:

getVisibleItemIds

public Collection<?> getVisibleItemIds()
Gets 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.


getType

public Class<?> getType()
Returns the type of the property. 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.

Specified by:
getType in interface Property<Object>
Specified by:
getType in class AbstractField<Object>
Returns:
the Type of the property.

getValue

public Object getValue()
Gets the selected item id or in multiselect mode a set of selected ids.

Specified by:
getValue in interface Property<Object>
Overrides:
getValue in class AbstractField<Object>
Returns:
the current value of the field.
See Also:
AbstractField.getValue()

setValue

public void setValue(Object newValue)
              throws Property.ReadOnlyException
Sets 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.

Specified by:
setValue in interface Property<Object>
Overrides:
setValue in class AbstractField<Object>
Parameters:
newValue - the New selected item or collection of selected items.
Throws:
Property.ReadOnlyException - if the object is in read-only mode
See Also:
AbstractField.setValue(java.lang.Object)

setValue

protected void setValue(Object newValue,
                        boolean repaintIsNotNeeded)
                 throws Property.ReadOnlyException
Sets 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.

Overrides:
setValue in class AbstractField<Object>
Parameters:
newValue - the New selected item or collection of selected items.
repaintIsNotNeeded - True if caller is sure that repaint is not needed.
Throws:
Property.ReadOnlyException
See Also:
com.vaadin.ui.AbstractField#setValue(java.lang.Object, java.lang.Boolean)

getItem

public Item getItem(Object itemId)
Gets the item from the container with given id. If the container does not contain the requested item, null is returned.

Specified by:
getItem in interface Container
Parameters:
itemId - the item id.
Returns:
the item from the container.

getItemIds

public Collection<?> getItemIds()
Gets the item Id collection from the container.

Specified by:
getItemIds in interface Container
Returns:
the Collection of item ids.

getContainerPropertyIds

public Collection<?> getContainerPropertyIds()
Gets the property Id collection from the container.

Specified by:
getContainerPropertyIds in interface Container
Returns:
the Collection of property ids.

getType

public Class<?> getType(Object propertyId)
Gets the property type.

Specified by:
getType in interface Container
Parameters:
propertyId - the Id identifying the property.
Returns:
data type of the Properties
See Also:
Container.getType(java.lang.Object)

size

public int size()
Description copied from interface: Container
Gets the number of visible Items in the Container. Filtering can hide items so that they will not be visible through the container API.

Specified by:
size in interface Container
Returns:
number of Items in the Container

containsId

public boolean containsId(Object itemId)
Tests, if the collection contains an item with given id.

Specified by:
containsId in interface Container
Parameters:
itemId - the Id the of item to be tested.
Returns:
boolean indicating if the Container holds the specified Item

getContainerProperty

public Property<?> getContainerProperty(Object itemId,
                                        Object propertyId)
Gets the Property identified by the given itemId and propertyId from the Container

Specified by:
getContainerProperty in interface Container
Parameters:
itemId - ID of the visible Item which contains the Property
propertyId - ID of the Property to retrieve
Returns:
Property with the given ID or null
See Also:
Container.getContainerProperty(Object, Object)

addContainerProperty

public boolean addContainerProperty(Object propertyId,
                                    Class<?> type,
                                    Object defaultValue)
                             throws UnsupportedOperationException
Adds the 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.

Specified by:
addContainerProperty in interface Container
Parameters:
propertyId - ID of the Property
type - Data type of the new Property
defaultValue - The value all created Properties are initialized to
Returns:
True if the operation succeeded.
Throws:
UnsupportedOperationException - if the container does not support explicitly adding container properties
See Also:
Container.addContainerProperty(java.lang.Object, java.lang.Class, java.lang.Object)

removeAllItems

public boolean removeAllItems()
                       throws UnsupportedOperationException
Removes all items from the container. This functionality is optional. If the function is unsupported, it always returns false.

Specified by:
removeAllItems in interface Container
Returns:
True if the operation succeeded.
Throws:
UnsupportedOperationException - if the container does not support removing all items
See Also:
Container.removeAllItems()

addItem

public Object addItem()
               throws UnsupportedOperationException
Creates 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.

Specified by:
addItem in interface Container
Returns:
the Id of the created item or null in case of failure.
Throws:
UnsupportedOperationException - if adding an item without an explicit item ID is not supported by the container
See Also:
Container.addItem()

addItem

public Item addItem(Object itemId)
             throws UnsupportedOperationException
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.

Specified by:
addItem in interface Container
Parameters:
itemId - the Identification of the item to be created.
Returns:
the Created item with the given id, or null in case of failure.
Throws:
UnsupportedOperationException - if adding an item with an explicit item ID is not supported by the container
See Also:
Container.addItem(java.lang.Object)

removeItem

public boolean removeItem(Object itemId)
                   throws UnsupportedOperationException
Description copied from interface: Container
Removes the Item identified by ItemId from the Container.

Containers that support filtering should also allow removing an item that is currently filtered out.

This functionality is optional.

Specified by:
removeItem in interface Container
Parameters:
itemId - ID of the Item to remove
Returns:
true if the operation succeeded, false if not
Throws:
UnsupportedOperationException - if the container does not support removing individual items

removeContainerProperty

public boolean removeContainerProperty(Object propertyId)
                                throws UnsupportedOperationException
Removes the 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.

Specified by:
removeContainerProperty in interface Container
Parameters:
propertyId - ID of the Property to remove
Returns:
True if the operation succeeded.
Throws:
UnsupportedOperationException - if the container does not support removing container properties
See Also:
Container.removeContainerProperty(java.lang.Object)

setContainerDataSource

public void setContainerDataSource(Container newDataSource)
Sets the Container that serves as the data source of the viewer. As a side-effect the fields value (selection) is set to null due old selection not necessary exists in new Container.

Specified by:
setContainerDataSource in interface Container.Viewer
Parameters:
newDataSource - the new data source.
See Also:
Container.Viewer.setContainerDataSource(Container)

getContainerDataSource

public Container getContainerDataSource()
Gets the viewing data-source container.

Specified by:
getContainerDataSource in interface Container.Viewer
Returns:
data source Container
See Also:
Container.Viewer.getContainerDataSource()

isMultiSelect

public boolean isMultiSelect()
Is the select in multiselect mode? In multiselect mode

Returns:
the Value of property multiSelect.

setMultiSelect

public void setMultiSelect(boolean multiSelect)
Sets the multiselect mode. Setting multiselect mode false may lose selection information: if selected items set contains one or more selected items, only one of the selected items is kept as selected. Subclasses of AbstractSelect can choose not to support changing the multiselect mode, and may throw UnsupportedOperationException.

Parameters:
multiSelect - the New value of property multiSelect.

isNewItemsAllowed

public boolean isNewItemsAllowed()
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. Note that data-source must allow adding new items.

Returns:
True if additions are allowed.

setNewItemsAllowed

public void setNewItemsAllowed(boolean allowNewOptions)
Enables or disables possibility to add new options by the user.

Parameters:
allowNewOptions - the New value of property allowNewOptions.

setItemCaption

public void setItemCaption(Object itemId,
                           String caption)
Override the caption of an item. Setting caption explicitly overrides id, item and index captions.

Parameters:
itemId - the id of the item to be recaptioned.
caption - the New caption.

getItemCaption

public String getItemCaption(Object itemId)
Gets the caption of an item. The caption is generated as specified by the item caption mode. See setItemCaptionMode() for more details.

Parameters:
itemId - the id of the item to be queried.
Returns:
the caption for specified item.

setItemIcon

public void setItemIcon(Object itemId,
                        Resource icon)
Sets tqhe icon for an item.

Parameters:
itemId - the id of the item to be assigned an icon.
icon - the icon to use or null.

getItemIcon

public Resource getItemIcon(Object itemId)
Gets the item icon.

Parameters:
itemId - the id of the item to be assigned an icon.
Returns:
the icon for the item or null, if not specified.

setItemCaptionMode

public void setItemCaptionMode(AbstractSelect.ItemCaptionMode mode)
Sets the item caption mode.

The mode can be one of the following ones:

The ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID is the default mode.

Parameters:
mode - the One of the modes listed above.

getItemCaptionMode

public AbstractSelect.ItemCaptionMode getItemCaptionMode()
Gets the item caption mode.

The mode can be one of the following ones:

The ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID is the default mode.

Returns:
the One of the modes listed above.

setItemCaptionPropertyId

public void setItemCaptionPropertyId(Object propertyId)
Sets 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.

Note that the type of the property used for caption must be String

Setting the property id to null disables this feature. The id is null by default

.

Parameters:
propertyId - the id of the property.

getItemCaptionPropertyId

public Object getItemCaptionPropertyId()
Gets the item caption property.

Returns:
the Id of the property used as item caption source.

setItemIconPropertyId

public void setItemIconPropertyId(Object propertyId)
                           throws IllegalArgumentException
Sets 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 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

.

Parameters:
propertyId - the id of the property that specifies icons for items or null
Throws:
IllegalArgumentException - If the propertyId is not in the container or is not of a valid type

getItemIconPropertyId

public Object getItemIconPropertyId()
Gets 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 : 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

.

Returns:
the Id of the property containing the item icons.

isSelected

public boolean isSelected(Object itemId)
Tests 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:
itemId - the Id the of the item to be tested.
See Also:
getNullSelectionItemId(), setNullSelectionItemId(Object)

select

public void select(Object itemId)
Selects an item.

In single select mode selecting item identified by getNullSelectionItemId() sets the value of the property to null.

Parameters:
itemId - the identifier of Item to be selected.
See Also:
getNullSelectionItemId(), setNullSelectionItemId(Object)

unselect

public void unselect(Object itemId)
Unselects an item.

Parameters:
itemId - the identifier of the Item to be unselected.
See Also:
getNullSelectionItemId(), setNullSelectionItemId(Object)

containerPropertySetChange

public void containerPropertySetChange(Container.PropertySetChangeEvent event)
Notifies this listener that the Containers contents has changed.

Specified by:
containerPropertySetChange in interface Container.PropertySetChangeListener
Parameters:
event - Change event.
See Also:
Container.PropertySetChangeListener.containerPropertySetChange(com.vaadin.data.Container.PropertySetChangeEvent)

addListener

public void addListener(Container.PropertySetChangeListener listener)
Adds a new Property set change listener for this Container.

Specified by:
addListener in interface Container.PropertySetChangeNotifier
Parameters:
listener - The new Listener to be registered
See Also:
Container.PropertySetChangeNotifier.addListener(com.vaadin.data.Container.PropertySetChangeListener)

removeListener

public void removeListener(Container.PropertySetChangeListener listener)
Removes a previously registered Property set change listener.

Specified by:
removeListener in interface Container.PropertySetChangeNotifier
Parameters:
listener - Listener to be removed
See Also:
Container.PropertySetChangeNotifier.removeListener(com.vaadin.data.Container.PropertySetChangeListener)

addListener

public void addListener(Container.ItemSetChangeListener listener)
Adds an Item set change listener for the object.

Specified by:
addListener in interface Container.ItemSetChangeNotifier
Parameters:
listener - listener to be added
See Also:
Container.ItemSetChangeNotifier.addListener(com.vaadin.data.Container.ItemSetChangeListener)

removeListener

public void removeListener(Container.ItemSetChangeListener listener)
Removes the Item set change listener from the object.

Specified by:
removeListener in interface Container.ItemSetChangeNotifier
Parameters:
listener - listener to be removed
See Also:
Container.ItemSetChangeNotifier.removeListener(com.vaadin.data.Container.ItemSetChangeListener)

getListeners

public Collection<?> getListeners(Class<?> eventType)
Description copied from class: AbstractComponent
Returns all listeners that are registered for the given event type or one of its subclasses.

Overrides:
getListeners in class AbstractComponent
Parameters:
eventType - The type of event to return listeners for.
Returns:
A collection with all registered listeners. Empty if no listeners are found.

containerItemSetChange

public void containerItemSetChange(Container.ItemSetChangeEvent event)
Lets the listener know a Containers Item set has changed.

Specified by:
containerItemSetChange in interface Container.ItemSetChangeListener
Parameters:
event - change event text
See Also:
Container.ItemSetChangeListener.containerItemSetChange(com.vaadin.data.Container.ItemSetChangeEvent)

firePropertySetChange

protected void firePropertySetChange()
Fires the property set change event.


fireItemSetChange

protected void fireItemSetChange()
Fires the item set change event.


isEmpty

protected boolean isEmpty()
For multi-selectable fields, also an empty collection of values is considered to be an empty field.

Overrides:
isEmpty in class AbstractField<Object>
See Also:
AbstractField.isEmpty().

setNullSelectionAllowed

public void setNullSelectionAllowed(boolean nullSelectionAllowed)
Allow or disallow empty selection by the user. If the select is in single-select mode, you can make an item represent the empty selection by calling setNullSelectionItemId(). This way you can for instance set an icon and caption for the null selection item.

Parameters:
nullSelectionAllowed - whether or not to allow empty selection
See Also:
setNullSelectionItemId(Object), isNullSelectionAllowed()

isNullSelectionAllowed

public boolean isNullSelectionAllowed()
Checks if null empty selection is allowed by the user.

Returns:
whether or not empty selection is allowed
See Also:
setNullSelectionAllowed(boolean)

getNullSelectionItemId

public Object getNullSelectionItemId()
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 identified by this id is the same as selecting no items at all. This setting only affects the single select mode.

Returns:
the Object Null value item id.
See Also:
setNullSelectionItemId(Object), isSelected(Object), select(Object)

setNullSelectionItemId

public void setNullSelectionItemId(Object nullSelectionItemId)
Sets the item id that represents null value of this select.

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.

Parameters:
nullSelectionItemId - the nullSelectionItemId to set.
See Also:
getNullSelectionItemId(), isSelected(Object), select(Object)

attach

public void attach()
Notifies the component that it is connected to an application.

Specified by:
attach in interface ClientConnector
Specified by:
attach in interface Component
Overrides:
attach in class AbstractField<Object>
See Also:
AbstractField.attach()

detach

public void detach()
Detaches the component from application.

Specified by:
detach in interface ClientConnector
Overrides:
detach in class AbstractField<Object>
See Also:
AbstractComponent.detach()

getCaptionChangeListener

protected AbstractSelect.CaptionChangeListener getCaptionChangeListener()


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.