|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.itmill.toolkit.terminal.Identifiable
com.itmill.toolkit.ui.AbstractComponent
com.itmill.toolkit.ui.AbstractField
com.itmill.toolkit.ui.Select
public 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 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 |
Select.OptionsStream
|
| Nested classes/interfaces inherited from class com.itmill.toolkit.ui.AbstractField |
|---|
AbstractField.ReadOnlyStatusChangeEvent |
| Nested classes/interfaces inherited from interface com.itmill.toolkit.data.Container |
|---|
Container.Editor, 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.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 |
| 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 |
| 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.data.Container |
|---|
NULL_ITEM_ID |
| Constructor Summary | |
|---|---|
Select()
Creates an empty Select. |
|
Select(String caption)
Creates an empty Select with caption. |
|
Select(String caption,
Collection options)
Creates a new select that is filled from a collection of option values. |
|
Select(String caption,
Container dataSource)
Creates a new select wthat 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. |
static String |
escapeJSON(String s)
|
protected void |
fireItemSetChange()
Fires the item set change event. |
protected void |
firePropertySetChange()
Fires the property set change event. |
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. |
Object |
getNullSelectionItemId()
Returns the item id that represents null value of this select in single select mode. |
OptionFilter |
getOptionFilter()
|
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 |
isLazyLoading()
|
boolean |
isMultiSelect()
Is the select in multiselect mode? |
boolean |
isNewItemsAllowed()
Does the select allow adding new options by the user. |
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 |
setLazyLoading(boolean useLazyLoading)
|
void |
setLazyLoading(boolean useLazyLoading,
Application app,
Select.OptionsStream optionsStream)
|
void |
setMultiSelect(boolean multiSelect)
Sets the multiselect mode. |
void |
setNewItemsAllowed(boolean allowNewOptions)
Enables or disables possibility to add new options by the user. |
void |
setNullSelectionItemId(Object nullSelectionItemId)
Sets the item id that represents null value of this select. |
void |
setOptionFilter(OptionFilter of)
|
void |
setValue(Object newValue)
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 com.itmill.toolkit.ui.AbstractField |
|---|
addListener, addListener, addValidator, commit, constructField, discard, finalize, fireReadOnlyStatusChange, fireValueChange, focus, getErrorMessage, getFocusableId, getPropertyDataSource, getTabIndex, getValidators, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isReadThrough, isRequired, isValid, isWriteThrough, removeListener, removeListener, removeValidator, setInternalValue, setInvalidAllowed, setInvalidCommitted, setPropertyDataSource, setReadOnly, setReadThrough, setRequired, setTabIndex, setWriteThrough, toString, validate, valueChange |
| Methods inherited from class com.itmill.toolkit.ui.AbstractComponent |
|---|
addListener, addListener, addListener, addListener, childRequestedRepaint, dependsOn, fireComponentErrorEvent, fireComponentEvent, fireEvent, getApplication, getCaption, getComponentError, getData, getDescription, getDirectDependencies, getIcon, getLocale, getParent, getStyle, getWindow, isEnabled, isImmediate, isVisible, paint, removeDirectDependency, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setData, setDescription, setEnabled, setIcon, setImmediate, setLocale, setParent, setStyle, setVisible |
| Methods inherited from class com.itmill.toolkit.terminal.Identifiable |
|---|
getDebugId, getUIID, setDebugId, setUIID |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, 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, childRequestedRepaint, getApplication, getCaption, getIcon, getLocale, getParent, getStyle, getWindow, isEnabled, isVisible, removeListener, setEnabled, setParent, setStyle, setVisible |
| Methods inherited from interface com.itmill.toolkit.terminal.Paintable |
|---|
addListener, paint, removeListener, requestRepaint, requestRepaintRequests |
| Methods inherited from interface com.itmill.toolkit.terminal.VariableOwner |
|---|
dependsOn, getDirectDependencies, isImmediate, removeDirectDependency |
| 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 Select()
public Select(String caption)
public Select(String caption,
Container dataSource)
caption - the Caption of the component.dataSource - the Container datasource to be selected from by this select.
public Select(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 AbstractComponentsource - 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 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)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.
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 tem to be selected.getNullSelectionItemId(),
setNullSelectionItemId(Object)public void unselect(Object itemId)
itemId - the Item to be unselected.getNullSelectionItemId(),
setNullSelectionItemId(Object)public void containerPropertySetChange(Container.PropertySetChangeEvent event)
containerPropertySetChange in interface Container.PropertySetChangeListenerevent - Change event.Container.PropertySetChangeListener.containerPropertySetChange(com.itmill.toolkit.data.Container.PropertySetChangeEvent)public void addListener(Container.PropertySetChangeListener listener)
addListener in interface Container.PropertySetChangeNotifierlistener - The new Listener to be registeredContainer.PropertySetChangeNotifier.addListener(com.itmill.toolkit.data.Container.PropertySetChangeListener)public void removeListener(Container.PropertySetChangeListener listener)
removeListener in interface Container.PropertySetChangeNotifierlistener - Listener to be removedContainer.PropertySetChangeNotifier.removeListener(com.itmill.toolkit.data.Container.PropertySetChangeListener)public void addListener(Container.ItemSetChangeListener listener)
addListener in interface Container.ItemSetChangeNotifierlistener - listener to be addedContainer.ItemSetChangeNotifier.addListener(com.itmill.toolkit.data.Container.ItemSetChangeListener)public void removeListener(Container.ItemSetChangeListener listener)
removeListener in interface Container.ItemSetChangeNotifierlistener - listener to be removedContainer.ItemSetChangeNotifier.removeListener(com.itmill.toolkit.data.Container.ItemSetChangeListener)public void containerItemSetChange(Container.ItemSetChangeEvent event)
containerItemSetChange in interface Container.ItemSetChangeListenerevent - change event textContainer.ItemSetChangeListener.containerItemSetChange(com.itmill.toolkit.data.Container.ItemSetChangeEvent)protected void firePropertySetChange()
protected void fireItemSetChange()
public final Object getNullSelectionItemId()
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.
setNullSelectionItemId(Object),
isSelected(Object),
select(Object)public void setNullSelectionItemId(Object nullSelectionItemId)
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.
nullSelectionItemId - the nullSelectionItemId to set.getNullSelectionItemId(),
isSelected(Object),
select(Object)public boolean isLazyLoading()
public void setLazyLoading(boolean useLazyLoading)
public void setLazyLoading(boolean useLazyLoading,
Application app,
Select.OptionsStream optionsStream)
public void attach()
attach in interface Componentattach in class AbstractFieldAbstractField.attach()public void detach()
detach in interface Componentdetach in class AbstractComponentAbstractComponent.detach()public void setOptionFilter(OptionFilter of)
public OptionFilter getOptionFilter()
public static String escapeJSON(String s)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||