Package io.jmix.ui.component.impl
Class ValuePickerImpl<V>
java.lang.Object
io.jmix.ui.component.impl.AbstractComponent<T>
io.jmix.ui.component.impl.AbstractValueComponent<T,P,V>
io.jmix.ui.component.impl.AbstractField<JmixPickerField<V>,V,V>
io.jmix.ui.component.impl.ValuePickerImpl<V>
- All Implemented Interfaces:
ActionsHolder
,AttachNotifier
,Buffered
,Component
,Component.BelongToFrame
,Component.Editable
,Component.Focusable
,Component.HasCaption
,Component.HasDescription
,Component.HasIcon
,Component.HasXmlDescriptor
,Component.Wrapper
,HasValueSource<V>
,Field<V>
,HasContextHelp
,HasDebugId
,HasFormatter<V>
,HasHtmlCaption
,HasHtmlDescription
,HasHtmlSanitizer
,HasInputPrompt
,HasSubParts
,HasValidator<V>
,HasValue<V>
,Requirable
,SecuredActionsHolder
,SupportsUserAction<V>
,Validatable
,ValuePicker<V>
,org.springframework.beans.factory.InitializingBean
- Direct Known Subclasses:
EntityPickerImpl
,SearchFieldImpl
,ValuesPickerImpl
public class ValuePickerImpl<V>
extends AbstractField<JmixPickerField<V>,V,V>
implements ValuePicker<V>, SecuredActionsHolder, org.springframework.beans.factory.InitializingBean
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jmix.ui.component.Component
Component.Alignment, Component.BelongToFrame, Component.Disposable, Component.Editable, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.Wrapper
Nested classes/interfaces inherited from interface io.jmix.ui.component.HasContextHelp
HasContextHelp.ContextHelpIconClickEvent
Nested classes/interfaces inherited from interface io.jmix.ui.component.HasValue
HasValue.ValueChangeEvent<V>
Nested classes/interfaces inherited from interface io.jmix.ui.component.ValuePicker
ValuePicker.FieldValueChangeEvent<V>, ValuePicker.ValuePickerAction
-
Field Summary
Modifier and TypeFieldDescriptionprotected Map<Action,
JmixButton> protected ValuePickerImpl<V>.WebValuePickerActionHandler
protected Consumer<PropertyChangeEvent>
protected ActionsPermissions
protected com.vaadin.shared.Registration
protected MetadataTools
Fields inherited from class io.jmix.ui.component.impl.AbstractField
editable, parentEditableChangeListener, validators, VALIDATORS_LIST_INITIAL_CAPACITY
Fields inherited from class io.jmix.ui.component.impl.AbstractValueComponent
internalValue, uiTestIdsSupport, valueBinding
Fields inherited from class io.jmix.ui.component.impl.AbstractComponent
alignment, applicationContext, component, contextHelpIconClickHandler, contextHelpIconClickListener, descriptionAsHtml, element, frame, htmlSanitizerEnabled, icon, ICON_STYLE, id, parent
Fields inherited from interface io.jmix.ui.component.Component
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZE
Fields inherited from interface io.jmix.ui.component.ValuePicker
NAME, TYPE_STRING
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
Add an action to the componentvoid
Add an action to the component with index.Adds a listener that will be fired in case field is editable.void
protected String
applyDefaultValueFormat
(V value) void
commit()
Updates all changes since the previous commit to the data source.protected JmixPickerField<V>
void
discard()
Discards all changes since last commit.void
focus()
Sets focus to this componentprotected String
formatValue
(V value) protected com.vaadin.server.Resource
generateOptionIcon
(V item) int
Gets the tabulator index of theHasTabIndex
component.protected void
initComponent
(JmixPickerField<V> component) boolean
boolean
boolean
Tests if the value stored in the object has been modified since it was last updated from the data source.protected void
protected void
void
removeAction
(Action action) Remove the action from the componentvoid
removeAction
(String id) Remove the action by its ID.void
Remove all actions from the componentvoid
setBuffered
(boolean buffered) Sets the buffered mode.protected void
setButtonIcon
(JmixButton button, String icon) void
setDebugId
(String id) INTERNAL.protected void
setEditableToComponent
(boolean editable) void
setFieldEditable
(boolean editable) Sets whether a user can input the value manually.void
setFieldIconProvider
(Function<? super V, String> iconProvider) Sets a function that provides an icon for the field.void
setFormatter
(Formatter<? super V> formatter) void
void
setInputPrompt
(String inputPrompt) Sets the input prompt - a textual prompt that is displayed when the field would otherwise be empty, to prompt the user for input.void
setMetadataTools
(MetadataTools metadataTools) void
setTabIndex
(int tabIndex) Sets the tabulator index of theFocusable
component.protected void
setUiComponentProperties
(UiComponentProperties componentProperties) protected void
setupButtonAction
(JmixButton button, Action action) void
void
setValueFromUser
(V value) Sets the value of this component as if the user had set it.Methods inherited from class io.jmix.ui.component.impl.AbstractField
addValidator, attachValueChangeListener, getDatatypeConversionErrorMsg, getDefaultRequiredMessage, getErrorMessage, getRequiredMessage, getValidators, isEditable, isRequired, isValid, removeValidator, setEditable, setParent, setRequired, setRequiredMessage, setupComponentErrorProvider, triggerValidators, validate
Methods inherited from class io.jmix.ui.component.impl.AbstractValueComponent
addValueChangeListener, componentValueChanged, convertToModel, convertToPresentation, fieldValueEquals, getValue, getValueSource, setUiTestId, setUiTestIdsSupport, setValueSource, setValueToPresentation, valueBindingActivated, valueBindingConnected
Methods inherited from class io.jmix.ui.component.impl.AbstractComponent
addAttachListener, addDetachListener, addStyleName, assignDebugId, attached, detached, getAlignment, getCaption, getComponent, getComposition, getContextHelpIconClickHandler, getContextHelpText, getDebugId, getDescription, getEventHub, getFrame, getHeight, getHeightSizeUnit, getHtmlSanitizer, getIcon, getIconName, getIconResource, getId, getParent, getStyleName, getUiComponentProperties, getUiProperties, getWidth, getWidthSizeUnit, getXmlDescriptor, hasSubscriptions, hasValidationError, isAttached, isCaptionAsHtml, isContextHelpTextHtmlEnabled, isDescriptionAsHtml, isEnabled, isEnabledRecursive, isHtmlSanitizerEnabled, isResponsive, isVisible, isVisibleRecursive, onContextHelpIconClick, publish, removeStyleName, sanitize, setAlignment, setApplicationContext, setCaption, setCaptionAsHtml, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabled, setDescription, setDescriptionAsHtml, setEnabled, setHeight, setHtmlSanitizerEnabled, setIcon, setIconFromSet, setId, setResponsive, setStyleName, setValidationError, setVisible, setWidth, setXmlDescriptor, unsubscribe, unwrap, unwrapComposition, unwrapCompositionOrNull, unwrapOrNull, withUnwrapped, withUnwrappedComposition
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.jmix.ui.component.ActionsHolder
getActionNN, getSubPart
Methods inherited from interface io.jmix.ui.component.Component
addStyleName, getAlignment, getHeight, getHeightSizeUnit, getId, getParent, getStyleName, getWidth, getWidthSizeUnit, isEnabled, isEnabledRecursive, isResponsive, isVisible, isVisibleRecursive, removeStyleName, setAlignment, setEnabled, setHeight, setHeightAuto, setHeightFull, setId, setParent, setResponsive, setSizeAuto, setSizeFull, setStyleName, setVisible, setWidth, setWidthAuto, setWidthFull, unwrap, unwrapComposition, unwrapCompositionOrNull, unwrapOrNull, withUnwrapped, withUnwrappedComposition
Methods inherited from interface io.jmix.ui.component.Component.BelongToFrame
getFrame
Methods inherited from interface io.jmix.ui.component.Component.Editable
isEditable, isEditableWithParent, setEditable
Methods inherited from interface io.jmix.ui.component.Component.Focusable
isFocusable, setFocusable
Methods inherited from interface io.jmix.ui.component.Component.HasCaption
getCaption, setCaption
Methods inherited from interface io.jmix.ui.component.Component.HasDescription
getDescription, setDescription
Methods inherited from interface io.jmix.ui.component.Component.HasIcon
getIcon, setIcon, setIconFromSet
Methods inherited from interface io.jmix.ui.component.HasContextHelp
getContextHelpIconClickHandler, getContextHelpText, isContextHelpTextHtmlEnabled, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabled
Methods inherited from interface io.jmix.ui.component.HasHtmlCaption
isCaptionAsHtml, setCaptionAsHtml
Methods inherited from interface io.jmix.ui.component.HasHtmlDescription
isDescriptionAsHtml, setDescriptionAsHtml
Methods inherited from interface io.jmix.ui.component.HasHtmlSanitizer
isHtmlSanitizerEnabled, setHtmlSanitizerEnabled
Methods inherited from interface io.jmix.ui.component.HasValidator
addValidator, addValidators, getValidators, removeValidator
Methods inherited from interface io.jmix.ui.component.HasValue
addValueChangeListener, clear, getEmptyValue, getValue, isEmpty
Methods inherited from interface io.jmix.ui.component.data.HasValueSource
getValueSource, setValueSource
Methods inherited from interface io.jmix.ui.component.Requirable
getRequiredMessage, isRequired, setRequired, setRequiredMessage
Methods inherited from interface io.jmix.ui.component.Validatable
isValid, isValidateOnCommit, validate
-
Field Details
-
metadataTools
-
formatter
-
actions
-
actionButtons
-
actionsPermissions
-
actionHandler
-
actionPropertyChangeListener
-
fieldIconProvider
-
fieldListenerRegistration
protected com.vaadin.shared.Registration fieldListenerRegistration
-
-
Constructor Details
-
ValuePickerImpl
public ValuePickerImpl()
-
-
Method Details
-
createComponent
-
setMetadataTools
-
setUiComponentProperties
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
initComponent
-
formatValue
-
applyDefaultValueFormat
-
getFormatter
- Specified by:
getFormatter
in interfaceHasFormatter<V>
-
setFormatter
- Specified by:
setFormatter
in interfaceHasFormatter<V>
-
setValue
- Specified by:
setValue
in interfaceHasValue<V>
- Overrides:
setValue
in classAbstractValueComponent<JmixPickerField<V>,
V, V>
-
setValueFromUser
Description copied from interface:SupportsUserAction
Sets the value of this component as if the user had set it. The user originated attribute is only used for theHasValue.ValueChangeEvent
.- Specified by:
setValueFromUser
in interfaceSupportsUserAction<V>
- Parameters:
value
- the new value
-
addAction
Description copied from interface:ActionsHolder
Add an action to the component- Specified by:
addAction
in interfaceActionsHolder
-
addAction
Description copied from interface:ActionsHolder
Add an action to the component with index.- Specified by:
addAction
in interfaceActionsHolder
-
setupButtonAction
-
setButtonIcon
-
actionPropertyChanged
-
removeAction
Description copied from interface:ActionsHolder
Remove the action from the component- Specified by:
removeAction
in interfaceActionsHolder
-
removeAction
Description copied from interface:ActionsHolder
Remove the action by its ID. If there is no action with that ID, nothing happens.- Specified by:
removeAction
in interfaceActionsHolder
-
removeAllActions
public void removeAllActions()Description copied from interface:ActionsHolder
Remove all actions from the component- Specified by:
removeAllActions
in interfaceActionsHolder
-
getActions
- Specified by:
getActions
in interfaceActionsHolder
- Returns:
- unmodifiable collection of actions
-
getAction
- Specified by:
getAction
in interfaceActionsHolder
- Returns:
- an action by its ID, or null if not found
-
refreshActionsState
protected void refreshActionsState() -
focus
public void focus()Description copied from interface:Component.Focusable
Sets focus to this component- Specified by:
focus
in interfaceComponent.Focusable
-
getTabIndex
public int getTabIndex()Description copied from interface:Component.Focusable
Gets the tabulator index of theHasTabIndex
component.- Specified by:
getTabIndex
in interfaceComponent.Focusable
- Returns:
- tab index set for the
HasTabIndex
component
-
setTabIndex
public void setTabIndex(int tabIndex) Description copied from interface:Component.Focusable
Sets the tabulator index of theFocusable
component. The tab index property is used to specify the order in which the fields are focused when the user presses the Tab key. Components with a defined tab index are focused sequentially first, and then the components with no tab index.- Specified by:
setTabIndex
in interfaceComponent.Focusable
- Parameters:
tabIndex
- tab index
-
getActionsPermissions
- Specified by:
getActionsPermissions
in interfaceSecuredActionsHolder
- Returns:
- permissions container
-
getFieldIconProvider
- Specified by:
getFieldIconProvider
in interfaceValuePicker<V>
- Returns:
- an icon provider or {code null} if not set
-
setFieldIconProvider
Description copied from interface:ValuePicker
Sets a function that provides an icon for the field.- Specified by:
setFieldIconProvider
in interfaceValuePicker<V>
- Parameters:
iconProvider
- icon provider to set
-
generateOptionIcon
-
isFieldEditable
public boolean isFieldEditable()- Specified by:
isFieldEditable
in interfaceValuePicker<V>
- Returns:
- whether a user can input the value manually
-
setFieldEditable
public void setFieldEditable(boolean editable) Description copied from interface:ValuePicker
Sets whether a user can input the value manually.false
by default. Doesn't set entered value to the model. To handle user input, theValuePicker.FieldValueChangeEvent
listener must be used.- Specified by:
setFieldEditable
in interfaceValuePicker<V>
- Parameters:
editable
-true
to enable manual input,false
otherwise- See Also:
-
addFieldValueChangeListener
public Subscription addFieldValueChangeListener(Consumer<ValuePicker.FieldValueChangeEvent<V>> listener) Description copied from interface:ValuePicker
Adds a listener that will be fired in case field is editable.- Specified by:
addFieldValueChangeListener
in interfaceValuePicker<V>
- Parameters:
listener
- a listener to add- Returns:
- a
Subscription
object - See Also:
-
onFieldValueChange
-
commit
public void commit()Description copied from interface:Buffered
Updates all changes since the previous commit to the data source.- Specified by:
commit
in interfaceBuffered
- Overrides:
commit
in classAbstractValueComponent<JmixPickerField<V>,
V, V>
-
discard
public void discard()Description copied from interface:Buffered
Discards all changes since last commit. The object updates its value from the data source.- Specified by:
discard
in interfaceBuffered
- Overrides:
discard
in classAbstractValueComponent<JmixPickerField<V>,
V, V>
-
isBuffered
public boolean isBuffered()- Specified by:
isBuffered
in interfaceBuffered
- Overrides:
isBuffered
in classAbstractValueComponent<JmixPickerField<V>,
V, V> - Returns:
true
if buffered mode is on,false
otherwise
-
setBuffered
public void setBuffered(boolean buffered) Description copied from interface:Buffered
Sets the buffered mode.When in buffered mode, an internal buffer will be used to store changes until
Buffered.commit()
is called. CallingBuffered.discard()
will revert the internal buffer to the value of the data source.When in non-buffered mode both read and write operations will be done directly on the data source. In this mode the
Buffered.commit()
andBuffered.discard()
methods serve no purpose.- Specified by:
setBuffered
in interfaceBuffered
- Overrides:
setBuffered
in classAbstractValueComponent<JmixPickerField<V>,
V, V> - Parameters:
buffered
-true
if buffered mode should be turned on,false
otherwise
-
isModified
public boolean isModified()Description copied from interface:Buffered
Tests if the value stored in the object has been modified since it was last updated from the data source.- Specified by:
isModified
in interfaceBuffered
- Overrides:
isModified
in classAbstractValueComponent<JmixPickerField<V>,
V, V> - Returns:
true
if the value in the object has been modified since the last data source update,false
if not.
-
setFrame
- Specified by:
setFrame
in interfaceComponent.BelongToFrame
- Overrides:
setFrame
in classAbstractComponent<JmixPickerField<V>>
-
setEditableToComponent
protected void setEditableToComponent(boolean editable) - Overrides:
setEditableToComponent
in classAbstractField<JmixPickerField<V>,
V, V>
-
setDebugId
Description copied from interface:HasDebugId
INTERNAL. Managed by debug Id system.- Specified by:
setDebugId
in interfaceHasDebugId
- Overrides:
setDebugId
in classAbstractComponent<JmixPickerField<V>>
-
getInputPrompt
- Specified by:
getInputPrompt
in interfaceHasInputPrompt
- Returns:
- current input prompt.
-
setInputPrompt
Description copied from interface:HasInputPrompt
Sets the input prompt - a textual prompt that is displayed when the field would otherwise be empty, to prompt the user for input.- Specified by:
setInputPrompt
in interfaceHasInputPrompt
- Parameters:
inputPrompt
- input prompt
-