Class JmixSwitch

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<C,T>
com.vaadin.flow.component.AbstractSinglePropertyField<JmixSwitch,Boolean>
io.jmix.flowui.kit.component.checkbox.JmixSwitch
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<JmixSwitch>, com.vaadin.flow.component.ClickNotifier<JmixSwitch>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<JmixSwitch>, com.vaadin.flow.component.FocusNotifier<JmixSwitch>, com.vaadin.flow.component.HasAriaLabel, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasHelper, com.vaadin.flow.component.HasLabel, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasValidation, com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<JmixSwitch,Boolean>,Boolean>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<JmixSwitch,Boolean>,Boolean>, com.vaadin.flow.component.shared.HasTooltip, com.vaadin.flow.component.shared.HasValidationProperties, com.vaadin.flow.component.shared.InputField<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<JmixSwitch,Boolean>,Boolean>, com.vaadin.flow.data.binder.HasValidator<Boolean>, Serializable
Direct Known Subclasses:
Switch

@Tag("jmix-switch") @JsModule("./src/checkbox/jmix-switch.js") public class JmixSwitch extends com.vaadin.flow.component.AbstractSinglePropertyField<JmixSwitch,Boolean> implements com.vaadin.flow.component.ClickNotifier<JmixSwitch>, com.vaadin.flow.component.Focusable<JmixSwitch>, com.vaadin.flow.component.HasAriaLabel, com.vaadin.flow.component.shared.HasValidationProperties, com.vaadin.flow.data.binder.HasValidator<Boolean>, com.vaadin.flow.component.shared.InputField<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<JmixSwitch,Boolean>,Boolean>
JmixSwitch is an input field representing a binary choice.
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField

    com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V extends Object>

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier

    com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier

    com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component>

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue

    com.vaadin.flow.component.HasValue.ValueChangeEvent<V extends Object>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected com.vaadin.flow.component.html.NativeLabel
     
    protected com.vaadin.flow.component.shared.internal.ValidationController<JmixSwitch,Boolean>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
     
    com.vaadin.flow.data.binder.Validator<Boolean>
     
    Get the current label text.
    boolean
    Get the state for the auto-focus property of the switch.
    boolean
    Gets whether the user is required to select the switch.
    protected void
    onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
     
    void
    setAriaLabel(String ariaLabel)
     
    void
    setAriaLabelledBy(String ariaLabelledBy)
     
    void
    setAutofocus(boolean autofocus)
    Set the switch to be input focused when the page loads.
    void
    Set the current label text of this switch.
    void
    setLabelComponent(com.vaadin.flow.component.Component component)
    Replaces the label content with the given label component.
    void
    setManualValidation(boolean enabled)
     
    void
    setRequiredIndicatorVisible(boolean required)
    Sets whether the user is required to select the switch.
    protected void
     

    Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField

    getSynchronizationRegistration, hasValidValue, setPresentationValue, setSynchronizedEvent

    Methods inherited from class com.vaadin.flow.component.AbstractField

    addValueChangeListener, getEmptyValue, getValue, isEmpty, setModelValue, setValue, valueEquals

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.BlurNotifier

    addBlurListener

    Methods inherited from interface com.vaadin.flow.component.ClickNotifier

    addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.Focusable

    addFocusShortcut, blur, focus, getTabIndex, setTabIndex

    Methods inherited from interface com.vaadin.flow.component.FocusNotifier

    addFocusListener

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasEnabled

    isEnabled, setEnabled

    Methods inherited from interface com.vaadin.flow.component.HasHelper

    getHelperComponent, getHelperText, setHelperComponent, setHelperText

    Methods inherited from interface com.vaadin.flow.component.HasSize

    getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName

    Methods inherited from interface com.vaadin.flow.component.shared.HasTooltip

    getTooltip, setTooltipText

    Methods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties

    getErrorMessage, isInvalid, setErrorMessage, setInvalid

    Methods inherited from interface com.vaadin.flow.data.binder.HasValidator

    addValidationStatusChangeListener

    Methods inherited from interface com.vaadin.flow.component.HasValue

    addValueChangeListener, clear, getEmptyValue, getOptionalValue, getValue, isEmpty, setValue

    Methods inherited from interface com.vaadin.flow.component.HasValueAndElement

    isReadOnly, setReadOnly
  • Field Details

    • labelElement

      protected com.vaadin.flow.component.html.NativeLabel labelElement
    • validationController

      protected com.vaadin.flow.component.shared.internal.ValidationController<JmixSwitch,Boolean> validationController
  • Constructor Details

    • JmixSwitch

      public JmixSwitch()
  • Method Details

    • onAttach

      protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
      Overrides:
      onAttach in class com.vaadin.flow.component.Component
    • setRequiredIndicatorVisible

      public void setRequiredIndicatorVisible(boolean required)
      Sets whether the user is required to select the switch. When required, an indicator appears next to the label and the field invalidates if the switch is first selected and then deselected.

      NOTE: The required indicator is only visible when the field has a label, see setLabel(String).

      Specified by:
      setRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<JmixSwitch,Boolean>,Boolean>
      Specified by:
      setRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<JmixSwitch,Boolean>,Boolean>
      Parameters:
      required - true to make the field required, false otherwise
    • isRequiredIndicatorVisible

      public boolean isRequiredIndicatorVisible()
      Gets whether the user is required to select the switch.
      Specified by:
      isRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<JmixSwitch,Boolean>,Boolean>
      Specified by:
      isRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<JmixSwitch,Boolean>,Boolean>
      Returns:
      true if the field is required, false otherwise
      See Also:
    • getLabel

      public String getLabel()
      Get the current label text.
      Specified by:
      getLabel in interface com.vaadin.flow.component.HasLabel
      Returns:
      the current label text
    • setLabel

      public void setLabel(String label)
      Set the current label text of this switch.
      Specified by:
      setLabel in interface com.vaadin.flow.component.HasLabel
      Parameters:
      label - the label text to set
    • setLabelComponent

      public void setLabelComponent(com.vaadin.flow.component.Component component)
      Replaces the label content with the given label component.
      Parameters:
      component - the component to be added to the label.
      Since:
      23.1
    • setAriaLabel

      public void setAriaLabel(String ariaLabel)
      Specified by:
      setAriaLabel in interface com.vaadin.flow.component.HasAriaLabel
    • getAriaLabel

      public Optional<String> getAriaLabel()
      Specified by:
      getAriaLabel in interface com.vaadin.flow.component.HasAriaLabel
    • setAriaLabelledBy

      public void setAriaLabelledBy(String ariaLabelledBy)
      Specified by:
      setAriaLabelledBy in interface com.vaadin.flow.component.HasAriaLabel
    • getAriaLabelledBy

      public Optional<String> getAriaLabelledBy()
      Specified by:
      getAriaLabelledBy in interface com.vaadin.flow.component.HasAriaLabel
    • setAutofocus

      public void setAutofocus(boolean autofocus)
      Set the switch to be input focused when the page loads.
      Parameters:
      autofocus - the boolean value to set
    • isAutofocus

      public boolean isAutofocus()
      Get the state for the auto-focus property of the switch.

      This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.

      Returns:
      the autofocus property from the switch
    • setManualValidation

      public void setManualValidation(boolean enabled)
      Specified by:
      setManualValidation in interface com.vaadin.flow.component.HasValidation
    • getDefaultValidator

      public com.vaadin.flow.data.binder.Validator<Boolean> getDefaultValidator()
      Specified by:
      getDefaultValidator in interface com.vaadin.flow.data.binder.HasValidator<Boolean>
    • validate

      protected void validate()