public class WTokenField extends WInputComponentWithValue<Set<Object>>
ComponentWithValue.ValueChangeListenerImpl, ComponentWithValue.ValueProperty<T>
Modifier and Type | Field and Description |
---|---|
protected IVaadinContainerDataSourceAdapter |
options
Data source which provides the options objects.
|
protected boolean |
widgetConfigured |
refreshing
form, INTERNAL_STATE_RECORD_PROPERTY
Constructor and Description |
---|
WTokenField() |
Modifier and Type | Method and Description |
---|---|
protected void |
configure() |
protected IVaadinContainerDataSourceAdapter |
createDataSource(RecordHolder dataSource,
RecordHolder captionValueProvider)
Called to obtain a data source which will provide available options (row objects) to the select component.
|
protected org.vaadin.tokenfield.TokenField |
createWidget()
Called once, to create the actual Vaadin component.
|
com.whitestein.lsps.vaadin.forms.WTokenField.TokenFieldWidget |
getWidget()
Gets the Vaadin representation of this component.
|
boolean |
isExcludeSelectedTokens() |
void |
preventGC(Set<ValueHolder> set)
Override for all components which are actively using some record holders, not directly linked to the model.
|
void |
refresh()
Refreshes the component (binding, datasource, children).
|
protected void |
restoreInternalState(Map<String,Object> state)
Restores the UI state of this component which was previously written
by
FormComponent.writeInternalState(Map) . |
void |
setExcludeSelectedTokens(boolean excludeSelectedTokens)
Configures whether token field should show selected tokens from the user.
|
void |
setFieldStyle(EnumerationImpl fieldStyle)
Set how token field looks like - as combo box or as text field.
|
void |
setOptions(CollectionHolder selectItems)
Sets the options given as a collection of
uicommon::SelectItem s. |
void |
setOptions(RecordHolder dataSource,
RecordHolder captionValueProvider)
Configures the
AbstractSelect provided by getWidget() :
creates a data source via createDataSource(RecordHolder, RecordHolder) and calls AbstractSelect.setContainerDataSource(Container)
directs it to use the property caption model
Registers WAbstractSelect.VariantConverter
;
creates a data source and calls AbstractSelect.setContainerDataSource(Container) ; |
protected void |
writeInternalState(Map<String,Object> state)
Writes the UI state of this component to the provided map.
|
addValidator, fireValueChanged, focus, getOnChange, getValidationErrors, inferValidator, isConvertible, isImmediate, isRequired, isValid, removeAllValidators, setImmediate, setOnChange, setRequired
getBinding, getProperty, isFullyInitialized, onPropertyValueSet, refreshBinding, setProperty
addDataErrorMessage, addStyleName, attach, call, clearDataErrorMessages, createEvent, equals, getCaption, getComponentAlignment, getContextClickHandler, getCustomErrorMessage, getDataErrorMessages, getDescription, getExpandRatio, getHasChildrenAdapter, getHeight, getIcon, getModelingId, getNamespace, getStyleName, getTabIndex, getWidth, hashCode, isEnabled, isReadOnly, isVisible, localize, markAsDirty, removeStyleName, restoreState, saveState, setCaption, setComponentAlignment, setContextClickHandler, setContextMenuItems, setCustomErrorMessage, setDescription, setEnabled, setExpandRatio, setHeight, setIcon, setReadOnly, setStyleName, setTabIndex, setVisible, setWidth, toString
protected IVaadinContainerDataSourceAdapter options
protected boolean widgetConfigured
protected org.vaadin.tokenfield.TokenField createWidget()
FormComponent
createWidget
in class WInputComponentWithValue<Set<Object>>
public com.whitestein.lsps.vaadin.forms.WTokenField.TokenFieldWidget getWidget()
FormComponent
getWidget
in class WInputComponentWithValue<Set<Object>>
public void setFieldStyle(EnumerationImpl fieldStyle)
fieldStyle
- the style of token fieldprotected IVaadinContainerDataSourceAdapter createDataSource(RecordHolder dataSource, RecordHolder captionValueProvider)
captionValueProvider
to provide captions for particular option row objects.dataSource
- forms::DataSource instance, may be null - in such case just return EmptyVaadinContainerDataSourceAdapter
.captionValueProvider
- provides captions for options from the data source.protected void configure()
public void setOptions(RecordHolder dataSource, RecordHolder captionValueProvider)
AbstractSelect
provided by getWidget()
:
createDataSource(RecordHolder, RecordHolder)
and calls AbstractSelect.setContainerDataSource(Container)
property
caption modelWAbstractSelect.VariantConverter
AbstractSelect.setContainerDataSource(Container)
;dataSource
- forms::DataSource instancecaptionValueProvider
- forms::ValueProvider instance.public void setOptions(CollectionHolder selectItems)
uicommon::SelectItem
s.selectItems
- select items representing the optionspublic void setExcludeSelectedTokens(boolean excludeSelectedTokens)
excludeSelectedTokens
- - if it is true
, token field will NOT show selected tokens among suggestions. If it is
false
, selected token fields will be suggested.public boolean isExcludeSelectedTokens()
true
if the field shows selected tokens among its suggestions, false
otherwise.public void preventGC(Set<ValueHolder> set)
FormComponent
WTabSheet
maintains a set of opened tabs. These tab records are not referenced
directly from forms::TabSheet and will therefore be garbage-collected. We however need those records to not to be GCed as the user
may ask for them simply by calling getTab(Integer).
Please note that the component definition records (e.g. forms::Button) are already GC-protected and they do not need to be added to this set.
Also, any child components currently attached to the UI are automatically protected and are not required to be registered in the set.preventGC
in class WInputComponentWithValue<Set<Object>>
set
- a set of records which are to be GC-prevented, never null. The component should add any records here.
Default implementation does nothing.protected void writeInternalState(Map<String,Object> state)
FormComponent
Many UI attributes such as size, caption, etc. are not held in the records but are stored exclusively in the Vaadin components. In the records the getter/setter methods of such attributes directly delegate to the underlying component. For the purposes of the Save Document/Todo use case the state of such attributes has to be preserved.
Subclasses should override this method. The overriding method should call
super.writeInternalState(state)
to store the state form the super
class as well. The attributes should be written to the provided state
parameter. The type of the values written to the state
can only by
Java representation of LSPS types. That is java.util.Date
,
java.lang.String
, Decimal
, RecordHolder
,
ListHolder
, ... The name of the attributes stored in the map
should be unique and should not collide with the names used by any
of the superclass. It is the responsibility of the overridden method to ensure
that.
Subclasses overriding this method should also override
FormComponent.restoreInternalState(Map)
and restore the state written
by this method.
writeInternalState
in class WInputComponentWithValue<Set<Object>>
state
- a map to which this method should write the component's UI state.FormComponent.restoreInternalState(Map)
,
FormComponent.saveState()
protected void restoreInternalState(Map<String,Object> state)
FormComponent
FormComponent.writeInternalState(Map)
.
Subclasses should override and call super.restoreInternalState(state);
restoreInternalState
in class WInputComponentWithValue<Set<Object>>
state
- a map of attributes and their valuesFormComponent.writeInternalState(Map)
public void refresh()
ComponentWithValue
refresh
in class ComponentWithValue<Set<Object>>
Copyright © 2007-2018 Whitestein Technologies. All Rights Reserved.