|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.itmill.toolkit.ui.AbstractComponent
com.itmill.toolkit.ui.AbstractField
com.itmill.toolkit.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 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.
| Nested Class Summary | |
|---|---|
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.NewItemHandler
|
| Nested classes/interfaces inherited from class com.itmill.toolkit.ui.AbstractField |
|---|
AbstractField.ReadOnlyStatusChangeEvent |
| Nested classes/interfaces inherited from class com.itmill.toolkit.ui.AbstractComponent |
|---|
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.data.Container |
|---|
Container.Editor, Container.Filterable, Container.Hierarchical, Container.Indexed, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.Sortable, Container.Viewer |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.ui.Field |
|---|
Field.ValueChangeEvent |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.data.Buffered |
|---|
Buffered.SourceException |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.data.Property |
|---|
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.ui.Component |
|---|
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.terminal.Paintable |
|---|
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener |
| 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. |
| Fields inherited from interface com.itmill.toolkit.terminal.Sizeable |
|---|
SIZE_UNDEFINED, UNIT_SYMBOLS, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS, UNITS_ROWS |
| 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 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. |
AbstractSelect.NewItemHandler |
getNewItemHandler()
TODO refine doc |
Object |
getNullSelectionItemId()
Returns the item id that represents null value of this select in single select mode. |
String |
getTag()
Gets the component UIDL tag. |
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. |
boolean |
isMultiSelect()
Is the select in multiselect mode? |
boolean |
isNewItemsAllowed()
Does the select allow adding new options by the user. |
boolean |
isNullSelectionAllowed()
Checks if null empty selection is allowed. |
boolean |
isSelected(Object itemId)
Tests if an item is selected. |
void |
paintContent(PaintTarget target)
Paints the content of this component. |
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 Id 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 as data-source for viewing. |
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 of disallow empty selection. |
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 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.itmill.toolkit.ui.Field |
|---|
getDescription, setCaption, setDescription |
| Methods inherited from interface com.itmill.toolkit.ui.Component |
|---|
addListener, addStyleName, childRequestedRepaint, getApplication, getCaption, getIcon, getLocale, getParent, getStyleName, getWindow, isEnabled, isVisible, removeListener, removeStyleName, setEnabled, setIcon, setParent, setStyleName, setVisible |
| Methods inherited from interface com.itmill.toolkit.terminal.Paintable |
|---|
addListener, getDebugId, paint, removeListener, requestRepaint, requestRepaintRequests, setDebugId |
| Methods inherited from interface com.itmill.toolkit.terminal.VariableOwner |
|---|
isImmediate |
| Methods inherited from interface com.itmill.toolkit.terminal.Sizeable |
|---|
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUnits, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUnits |
| 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 AbstractFieldtarget - the Paint Event.
PaintException - if the paint operation failed.
public void changeVariables(Object source,
Map variables)
changeVariables in interface VariableOwnerchangeVariables in class AbstractFieldsource - 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 String getTag()
getTag in class AbstractComponentpublic 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 PropertygetType in class AbstractFieldpublic Object getValue()
getValue in interface PropertygetValue in class AbstractFieldAbstractField.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 PropertysetValue in class AbstractFieldnewValue - 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 AbstractFieldnewValue - the New selected item or collection of selected items.repaintIsNotNeeded - True if caller is sure that repaint is not needed.
Property.ReadOnlyException
Property.ConversionExceptioncom.itmill.toolkit.ui.AbstractField#setValue(java.lang.Object,
java.lang.Boolean)public Item getItem(Object itemId)
getItem in interface ContaineritemId - the item id.
public Collection getItemIds()
getItemIds in interface Containerpublic Collection getContainerPropertyIds()
getContainerPropertyIds in interface Containerpublic Class getType(Object propertyId)
getType in interface ContainerpropertyId - the Id identifying the property.
Container.getType(java.lang.Object)public int size()
Container
size in interface Containerpublic boolean containsId(Object itemId)
containsId in interface ContaineritemId - the Id the of item to be tested.
public Property getContainerProperty(Object itemId,
Object propertyId)
getContainerProperty in interface ContaineritemId - ID of the Item which contains the PropertypropertyId - ID of the Property to retrieve
nullContainer.getContainerProperty(Object,
Object)
public boolean addContainerProperty(Object propertyId,
Class type,
Object defaultValue)
throws UnsupportedOperationException
addContainerProperty in interface ContainerpropertyId - ID of the Propertytype - Data type of the new PropertydefaultValue - The value all created Properties are initialized to
UnsupportedOperationExceptionContainer.addContainerProperty(java.lang.Object,
java.lang.Class, java.lang.Object)
public boolean removeAllItems()
throws UnsupportedOperationException
removeAllItems in interface ContainerUnsupportedOperationExceptionContainer.removeAllItems()
public Object addItem()
throws UnsupportedOperationException
addItem in interface ContainerUnsupportedOperationExceptionContainer.addItem()
public Item addItem(Object itemId)
throws UnsupportedOperationException
addItem in interface ContaineritemId - the Identification of the item to be created.
UnsupportedOperationExceptionContainer.addItem(java.lang.Object)
public boolean removeItem(Object itemId)
throws UnsupportedOperationException
removeItem in interface ContaineritemId - ID of the Item to remove
UnsupportedOperationExceptionContainer.removeItem(java.lang.Object)
public boolean removeContainerProperty(Object propertyId)
throws UnsupportedOperationException
removeContainerProperty in interface ContainerpropertyId - ID of the Property to remove
UnsupportedOperationExceptionContainer.removeContainerProperty(java.lang.Object)public void setContainerDataSource(Container newDataSource)
setContainerDataSource in interface Container.ViewernewDataSource - the new data source.public Container getContainerDataSource()
getContainerDataSource in interface Container.ViewerContainer.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 New icon.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)
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
.
propertyId - the Id of the property that specifies icons for items.public 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.