public class Switcher extends com.vaadin.v7.ui.CustomField<Object> implements com.vaadin.v7.data.Container.Viewer
CustomField
which wraps a ComboBox
and additionally provides 2 arrows to "navigate" -
actually to select the previous or the next item from the available set.
Additionally, the Switcher can display a description of the currently selected item.
Its Layout looks likecom.vaadin.v7.ui.AbstractField.FocusShortcut, com.vaadin.v7.ui.AbstractField.ReadOnlyStatusChangeEvent
com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier, com.vaadin.ui.HasComponents.ComponentAttachEvent, com.vaadin.ui.HasComponents.ComponentAttachListener, com.vaadin.ui.HasComponents.ComponentDetachEvent, com.vaadin.ui.HasComponents.ComponentDetachListener
com.vaadin.ui.Component.ErrorEvent, com.vaadin.ui.Component.Event, com.vaadin.ui.Component.Focusable, com.vaadin.ui.Component.Listener
com.vaadin.server.ClientConnector.AttachEvent, com.vaadin.server.ClientConnector.AttachListener, com.vaadin.server.ClientConnector.ConnectorErrorEvent, com.vaadin.server.ClientConnector.DetachEvent, com.vaadin.server.ClientConnector.DetachListener
com.vaadin.server.Sizeable.Unit
com.vaadin.v7.ui.Field.ValueChangeEvent
com.vaadin.v7.data.Buffered.SourceException
com.vaadin.v7.data.Property.Editor, com.vaadin.v7.data.Property.ReadOnlyException, com.vaadin.v7.data.Property.ReadOnlyStatusChangeListener, com.vaadin.v7.data.Property.ReadOnlyStatusChangeNotifier, com.vaadin.v7.data.Property.Transactional<T>, com.vaadin.v7.data.Property.ValueChangeListener, com.vaadin.v7.data.Property.ValueChangeNotifier, com.vaadin.v7.data.Property.Viewer
Modifier and Type | Field and Description |
---|---|
static String |
VARIATION_BLACK
The constant for the color-variation "black".
|
static String |
VARIATION_GREEN
The constant for the color-variation "green" (which is default).
|
Constructor and Description |
---|
Switcher(Collection<?> options)
Constructs a Switcher by a given collection.
|
Switcher(Collection<?> options,
String colorVariation)
Constructs a Switcher by a given
Collection and a given color-variant. |
Switcher(com.vaadin.v7.data.Container container)
Constructs a Switcher by a given
Container using the default color-variation (VARIATION_GREEN). |
Switcher(com.vaadin.v7.data.Container container,
String colorVariation)
Constructs a Switcher by a given
Container and colorVariant ("green" or "black", "green" is default). |
Modifier and Type | Method and Description |
---|---|
void |
addValueChangeListener(com.vaadin.v7.data.Property.ValueChangeListener valueChangeListener)
This method adds a
Property.ValueChangeListener to the underlying ComboBox.Such a ValueChangeListener would be notified not only when a user is changing the value directly with the wrapped ComboBox ,
but also fired when the arrows (back, forward) are used. |
com.vaadin.v7.data.Container.Ordered |
getContainerDataSource()
Returns the
Container . |
protected Object |
getInternalValue()
Returns the selected item id.
|
com.vaadin.v7.data.Property |
getPropertyDataSource()
Gets the current data source of the field, if any (actually from its underlying
ComboBox ). |
Class<?> |
getType() |
void |
goBack()
Sets the previous value - if the current value is not the first available in the set.
|
void |
goForward()
Sets the next value - if the current value is not the last available in the set.
|
protected com.vaadin.ui.Component |
initContent() |
void |
setContainerDataSource(com.vaadin.v7.data.Container newDataSource)
Sets the
Container that serves as the data source of the viewer (on the underlying ComboBox ). |
void |
setConverter(com.vaadin.v7.data.util.converter.Converter<Object,?> converter)
Sets the
Converter used to convert the field value to property data
source type. |
void |
setDescriptionPropertyName(String descriptionPropertyName)
Sets the name of the property which is used as the value of the description of an item.
If it's not set, a description cannot be showed. When set, the passed Container should have set the property name descriptionPropertyName. |
void |
setItemCaptionPropertyId(String propertyId)
Sets the item caption property of the underlying
ComboBox . |
void |
setNullSelectionAllowed(boolean nullSelectionAllowed)
Allow or disallow empty selection by the user; it applies #setNullSelectionAllowed on underlying
ComboBox . |
void |
setNullSelectionItemId(Object item)
Sets the item id that represents null value of this select;
it applies #setNullSelectionItemId on underlying
ComboBox . |
void |
setPropertyDataSource(com.vaadin.v7.data.Property newDataSource)
Sets the specified Property as the data source for the field on the underlying
ComboBox .For more details see the javadoc of AbstractField.setPropertyDataSource(com.vaadin.v7.data.Property) . |
void |
setValue(Object newValue)
Sets the visible value of the property.
|
void |
withBorder(boolean withBorder)
Adds the css style which ensures that the switcher comes with border on top and on bottom, if set true.
|
attach, focus, getContent, getTabIndex, iterator, setFocusDelegate, setHeight, setTabIndex, setWidth
addListener, addListener, addReadOnlyStatusChangeListener, addValidator, beforeClientResponse, clear, commit, detach, discard, fireReadOnlyStatusChange, fireValueChange, getConversionError, getConversionError, getConvertedValue, getConverter, getCurrentBufferedSourceException, getCustomAttributes, getErrorMessage, getModelType, getRequiredError, getState, getState, getValidators, getValue, isBuffered, isEmpty, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isRequired, isValid, isValidationVisible, readDesign, readOnlyStatusChange, removeAllValidators, removeListener, removeListener, removeReadOnlyStatusChangeListener, removeValidator, removeValueChangeListener, setBuffered, setConversionError, setConvertedValue, setConverter, setCurrentBufferedSourceException, setInternalValue, setInvalidAllowed, setInvalidCommitted, setLocale, setReadOnly, setRequired, setRequiredError, setValidationVisible, setValue, setValue, shouldHideErrors, validate, validate, valueChange, writeDesign
getExplicitImmediateValue, isImmediate, setImmediate
addContextClickListener, addListener, addShortcutListener, addStyleName, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isRequiredIndicatorVisible, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeightUndefined, setIcon, setId, setParent, setPrimaryStyleName, setRequiredIndicatorVisible, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidthUndefined
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
addListener, addStyleName, addStyleNames, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, readDesign, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible, writeDesign
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidthUndefined
forEach, spliterator
public static final String VARIATION_GREEN
public static final String VARIATION_BLACK
public Switcher(Collection<?> options)
options
- public Switcher(Collection<?> options, String colorVariation)
Collection
and a given color-variant.
The collection is converted into a container during instantiation.options
- colorVariation
- public Switcher(com.vaadin.v7.data.Container container)
Container
using the default color-variation (VARIATION_GREEN).container
- public Switcher(com.vaadin.v7.data.Container container, String colorVariation)
Container
and colorVariant ("green" or "black", "green" is default).container
- colorVariation
- public void setDescriptionPropertyName(String descriptionPropertyName)
Container
should have set the property name descriptionPropertyName.descriptionPropertyName
- public void withBorder(boolean withBorder)
withBorder
- protected com.vaadin.ui.Component initContent()
initContent
in class com.vaadin.v7.ui.CustomField<Object>
public void setNullSelectionAllowed(boolean nullSelectionAllowed)
ComboBox
.nullSelectionAllowed
- public void setNullSelectionItemId(Object item)
ComboBox
.item
- public void setItemCaptionPropertyId(String propertyId)
ComboBox
.propertyId
- the id of the property.public void setValue(Object newValue)
The value of the select is the selected item id.
Sets the value to the underlyingComboBox
.public void goForward()
public void goBack()
public void addValueChangeListener(com.vaadin.v7.data.Property.ValueChangeListener valueChangeListener)
Property.ValueChangeListener
to the underlying ComboBox.ComboBox
,
but also fired when the arrows (back, forward) are used.addValueChangeListener
in interface com.vaadin.v7.data.Property.ValueChangeNotifier
addValueChangeListener
in class com.vaadin.v7.ui.AbstractField<Object>
public com.vaadin.v7.data.Property getPropertyDataSource()
ComboBox
).getPropertyDataSource
in interface com.vaadin.v7.data.Property.Viewer
getPropertyDataSource
in class com.vaadin.v7.ui.AbstractField<Object>
public void setPropertyDataSource(com.vaadin.v7.data.Property newDataSource)
ComboBox
.AbstractField.setPropertyDataSource(com.vaadin.v7.data.Property)
.setPropertyDataSource
in interface com.vaadin.v7.data.Property.Viewer
setPropertyDataSource
in class com.vaadin.v7.ui.AbstractField<Object>
newDataSource
- public void setConverter(com.vaadin.v7.data.util.converter.Converter<Object,?> converter)
Converter
used to convert the field value to property data
source type. The converter must have a presentation type that matches the
field type.setConverter
in class com.vaadin.v7.ui.AbstractField<Object>
converter
- protected Object getInternalValue()
getInternalValue
in class com.vaadin.v7.ui.AbstractField<Object>
public Class<?> getType()
public void setContainerDataSource(com.vaadin.v7.data.Container newDataSource)
Container
that serves as the data source of the viewer (on the underlying ComboBox
).setContainerDataSource
in interface com.vaadin.v7.data.Container.Viewer
newDataSource
- public com.vaadin.v7.data.Container.Ordered getContainerDataSource()
Container
.getContainerDataSource
in interface com.vaadin.v7.data.Container.Viewer
Copyright © 2020 Magnolia International Ltd.. All rights reserved.