|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.millstone.base.ui.AbstractComponent | +--org.millstone.base.ui.AbstractField | +--org.millstone.base.ui.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
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 |
Nested classes inherited from class org.millstone.base.ui.AbstractField |
AbstractField.ReadOnlyStatusChangeEvent, AbstractField.ValueChangeEvent |
Nested classes inherited from class org.millstone.base.data.Container |
Container.Editor, Container.Hierarchical, Container.Indexed, Container.ItemSetChangeEvent, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeEvent, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.Viewer |
Nested classes inherited from class org.millstone.base.data.Buffered |
Buffered.SourceException |
Nested classes inherited from class org.millstone.base.data.Property |
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeEvent, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeEvent, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer |
Nested classes inherited from class org.millstone.base.ui.Component |
Component.Event, Component.Listener |
Nested classes inherited from class org.millstone.base.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 org.millstone.base.data.Container |
NULL_ITEM_ID |
Constructor Summary | |
Select()
Creates an empty Select. |
|
Select(java.lang.String caption)
Creates an empty Select with caption. |
|
Select(java.lang.String caption,
java.util.Collection options)
Creates a new select that is filled from a collection of option values. |
|
Select(java.lang.String caption,
Container dataSource)
Creates a new select wthat is connected to a data-source. |
Method Summary | |
boolean |
addContainerProperty(java.lang.Object propertyId,
java.lang.Class type,
java.lang.Object defaultValue)
Add new property to all items. |
java.lang.Object |
addItem()
Create a new item into container with container managed id. |
Item |
addItem(java.lang.Object itemId)
Create a new item into container. |
void |
addListener(Container.ItemSetChangeListener listener)
Adds a Item set change listener for the object. |
void |
addListener(Container.PropertySetChangeListener listener)
Registers a new Property set change listener for this Container. |
void |
changeVariables(java.lang.Object source,
java.util.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(java.lang.Object itemId)
Test, if the collection contains an item with given id. |
protected void |
fireItemSetChange()
Fire item set change event |
protected void |
firePropertySetChange()
Fire property set change event |
Container |
getContainerDataSource()
Get viewing data-source container. |
Property |
getContainerProperty(java.lang.Object itemId,
java.lang.Object propertyId)
Gets the Property identified by the given itemId and propertyId from the Container. |
java.util.Collection |
getContainerPropertyIds()
Get property Id collection from the container. |
Item |
getItem(java.lang.Object itemId)
Get the item from the container with given id. |
java.lang.String |
getItemCaption(java.lang.Object itemId)
Get the caption of an item. |
int |
getItemCaptionMode()
Get the item caption mode. |
java.lang.Object |
getItemCaptionPropertyId()
Get the item caption property. |
Resource |
getItemIcon(java.lang.Object itemId)
Get the item icon. |
java.lang.Object |
getItemIconPropertyId()
Get the item icon property. |
java.util.Collection |
getItemIds()
Get item Id collection from the container. |
java.lang.Object |
getNullSelectionItemId()
Returns the item id that represents null value of this select in single select mode. |
java.lang.String |
getTag()
Get component UIDL tag. |
java.lang.Class |
getType()
Return the type of the property. |
java.lang.Class |
getType(java.lang.Object propertyId)
Get property type. |
java.lang.Object |
getValue()
Get the selected item id or in multiselect mode a set of selected ids. |
java.util.Collection |
getVisibleItemIds()
Get 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 |
isSelected(java.lang.Object itemId)
Test if an item is selected In single select mode testing selection status of the item identified by getNullSelectionItemId() returns true if the value of the
property is null. |
void |
paintContent(PaintTarget target)
Paint the content of this component. |
boolean |
removeAllItems()
Remove all items from the container. |
boolean |
removeContainerProperty(java.lang.Object propertyId)
Remove property from all items. |
boolean |
removeItem(java.lang.Object itemId)
Remove item identified by Id from the container. |
void |
removeListener(Container.ItemSetChangeListener listener)
Removes a Item set change listener from the object. |
void |
removeListener(Container.PropertySetChangeListener listener)
Removes a previously registered Property set change listener. |
void |
select(java.lang.Object itemId)
Select an item. |
void |
setContainerDataSource(Container newDataSource)
Set the container as data-source for viewing. |
void |
setItemCaption(java.lang.Object itemId,
java.lang.String caption)
Override the caption of an item. |
void |
setItemCaptionMode(int mode)
Set the item caption mode. |
void |
setItemCaptionPropertyId(java.lang.Object propertyId)
Set the item caption property. |
void |
setItemIcon(java.lang.Object itemId,
Resource icon)
Set icon for an item. |
void |
setItemIconPropertyId(java.lang.Object propertyId)
Set the item icon property. |
void |
setMultiSelect(boolean multiSelect)
Set the multiselect mode. |
void |
setNewItemsAllowed(boolean allowNewOptions)
Enable or disable possibility to add new options by the user. |
void |
setNullSelectionItemId(java.lang.Object nullSelectionItemId)
Sets the item id that represents null value of this select. |
void |
setValue(java.lang.Object newValue)
Set the visible value of the property. |
int |
size()
Get the number of items in the container. |
void |
unselect(java.lang.Object itemId)
Unselect an item. |
Methods inherited from class org.millstone.base.ui.AbstractField |
addListener, addListener, addValidator, commit, constructField, discard, fireReadOnlyStatusChange, fireValueChange, focus, getErrorMessage, getPropertyDataSource, getValidators, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isReadThrough, isValid, isWriteThrough, removeListener, removeListener, removeValidator, setInvalidAllowed, setInvalidCommitted, setPropertyDataSource, setReadOnly, setReadThrough, setWriteThrough, toString, validate, valueChange |
Methods inherited from class org.millstone.base.ui.AbstractComponent |
addListener, addListener, addListener, addListener, attach, childRequestedRepaint, dependsOn, detach, fireComponentEvent, fireEvent, getApplication, getCaption, getComponentError, getDescription, getDirectDependencies, getIcon, getLocale, getParent, getStyle, getWindow, isEnabled, isImmediate, isVisible, paint, removeDirectDependency, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setDescription, setEnabled, setIcon, setImmediate, setLocale, setParent, setStyle, setVisible |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
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(java.lang.String caption)
public Select(java.lang.String caption, Container dataSource)
dataSource
- Container datasource to be selected from by this select.caption
- Caption of the component.public Select(java.lang.String caption, java.util.Collection options)
caption
- Caption of this field.options
- Collection containing the options.Method Detail |
public void paintContent(PaintTarget target) throws PaintException
paintContent
in class AbstractField
target
- target UIDL stream where the component should paint
itself to
PaintException
- The paint operation failed.public void changeVariables(java.lang.Object source, java.util.Map variables)
changeVariables
in interface VariableOwner
changeVariables
in class AbstractComponent
source
- Source of the variable change. This is the origin of the
event. For example in Web Adapter this is the request.variables
- Mapping from variable names to new variable valuespublic java.lang.String getTag()
getTag
in class AbstractComponent
public java.util.Collection getVisibleItemIds()
public java.lang.Class getType()
getType
in interface Property
getType
in class AbstractField
public java.lang.Object getValue()
getValue
in interface Property
getValue
in class AbstractField
public void setValue(java.lang.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
- New selected item or collection of selected items.
Property.ReadOnlyException
Property.ConversionException
public Item getItem(java.lang.Object itemId)
getItem
in interface Container
itemId
- ID of the Item to retrieve
null
if the Item
is not found in the Containerpublic java.util.Collection getItemIds()
getItemIds
in interface Container
public java.util.Collection getContainerPropertyIds()
getContainerPropertyIds
in interface Container
public java.lang.Class getType(java.lang.Object propertyId)
getType
in interface Container
propertyId
- ID identifying the Properties
public int size()
size
in interface Container
public boolean containsId(java.lang.Object itemId)
containsId
in interface Container
itemId
- Id the of item to be tested.
public Property getContainerProperty(java.lang.Object itemId, java.lang.Object propertyId)
Container
null
is returned.
getContainerProperty
in interface Container
itemId
- ID of the Item which contains the PropertypropertyId
- ID of the Property to retrieve
null
Container.getContainerProperty(Object, Object)
public boolean addContainerProperty(java.lang.Object propertyId, java.lang.Class type, java.lang.Object defaultValue) throws java.lang.UnsupportedOperationException
addContainerProperty
in interface Container
propertyId
- ID of the Propertytype
- Data type of the new PropertydefaultValue
- The value all created Properties are
initialized to
java.lang.UnsupportedOperationException
public boolean removeAllItems() throws java.lang.UnsupportedOperationException
removeAllItems
in interface Container
java.lang.UnsupportedOperationException
public java.lang.Object addItem() throws java.lang.UnsupportedOperationException
addItem
in interface Container
java.lang.UnsupportedOperationException
public Item addItem(java.lang.Object itemId) throws java.lang.UnsupportedOperationException
addItem
in interface Container
itemId
- Identification of the item to be created.
java.lang.UnsupportedOperationException
public boolean removeItem(java.lang.Object itemId) throws java.lang.UnsupportedOperationException
removeItem
in interface Container
itemId
- ID of the Item to remove
java.lang.UnsupportedOperationException
public boolean removeContainerProperty(java.lang.Object propertyId) throws java.lang.UnsupportedOperationException
removeContainerProperty
in interface Container
propertyId
- ID of the Property to remove
java.lang.UnsupportedOperationException
public void setContainerDataSource(Container newDataSource)
setContainerDataSource
in interface Container.Viewer
newDataSource
- The new data source Itempublic Container getContainerDataSource()
getContainerDataSource
in interface Container.Viewer
public boolean isMultiSelect()
public void setMultiSelect(boolean multiSelect)
multiSelect
- New value of property multiSelect.public boolean isNewItemsAllowed()
public void setNewItemsAllowed(boolean allowNewOptions)
allowNewOptions
- New value of property allowNewOptions.public void setItemCaption(java.lang.Object itemId, java.lang.String caption)
itemId
- The id of the item to be recaptioned.caption
- New caption.public java.lang.String getItemCaption(java.lang.Object itemId)
setItemCaptionMode()
for more details.
itemId
- The id of the item to be queried.
public void setItemIcon(java.lang.Object itemId, Resource icon)
itemId
- The id of the item to be assigned an icon.icon
- New icon.public Resource getItemIcon(java.lang.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
- 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(java.lang.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
.
public java.lang.Object getItemCaptionPropertyId()
public void setItemIconPropertyId(java.lang.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 that the icons set with setItemIcon
function override the icons from the property.
Setting the property id to null disables this feature. The id is null by default
.
propertyId
- Id of the property that specifies icons for
items.public java.lang.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 that the icons set with setItemIcon
function override the icons from the property.
Setting the property id to null disables this feature. The id is null by default
.
public boolean isSelected(java.lang.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
- Id the of the item to be testedgetNullSelectionItemId()
,
setNullSelectionItemId(Object)
public void select(java.lang.Object itemId)
In single select mode selecting item identified
by getNullSelectionItemId()
sets the value of the
property to null.
itemId
- Item to be selected.getNullSelectionItemId()
,
setNullSelectionItemId(Object)
public void unselect(java.lang.Object itemId)
itemId
- Item to be unselected.getNullSelectionItemId()
,
setNullSelectionItemId(Object)
public void containerPropertySetChange(Container.PropertySetChangeEvent event)
Container.PropertySetChangeListener
containerPropertySetChange
in interface Container.PropertySetChangeListener
event
- Change event.Container.PropertySetChangeListener.containerPropertySetChange(org.millstone.base.data.Container.PropertySetChangeEvent)
public void addListener(Container.PropertySetChangeListener listener)
Container.PropertySetChangeNotifier
addListener
in interface Container.PropertySetChangeNotifier
listener
- The new Listener to be registeredContainer.PropertySetChangeNotifier.addListener(org.millstone.base.data.Container.PropertySetChangeListener)
public void removeListener(Container.PropertySetChangeListener listener)
Container.PropertySetChangeNotifier
removeListener
in interface Container.PropertySetChangeNotifier
listener
- Listener to be removedContainer.PropertySetChangeNotifier.removeListener(org.millstone.base.data.Container.PropertySetChangeListener)
public void addListener(Container.ItemSetChangeListener listener)
Container.ItemSetChangeNotifier
addListener
in interface Container.ItemSetChangeNotifier
listener
- listener to be addedContainer.ItemSetChangeNotifier.addListener(org.millstone.base.data.Container.ItemSetChangeListener)
public void removeListener(Container.ItemSetChangeListener listener)
Container.ItemSetChangeNotifier
removeListener
in interface Container.ItemSetChangeNotifier
listener
- listener to be removedContainer.ItemSetChangeNotifier.removeListener(org.millstone.base.data.Container.ItemSetChangeListener)
public void containerItemSetChange(Container.ItemSetChangeEvent event)
Container.ItemSetChangeListener
containerItemSetChange
in interface Container.ItemSetChangeListener
event
- change event textContainer.ItemSetChangeListener.containerItemSetChange(org.millstone.base.data.Container.ItemSetChangeEvent)
protected void firePropertySetChange()
protected void fireItemSetChange()
public final java.lang.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(java.lang.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.
getNullSelectionItemId()
,
isSelected(Object)
,
select(Object)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |