Class MultiClickButton

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<com.vaadin.flow.component.button.Button>
org.vaadin.miki.superfields.buttons.MultiClickButton
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, Serializable, ComponentClickNotifier<MultiClickButton>, StateChangeNotifier<ButtonState,MultiClickButton>, Clickable, HasId, HasState<ButtonState>, WithIdMixin<MultiClickButton>

@Tag("multi-click-button") public class MultiClickButton extends com.vaadin.flow.component.Composite<com.vaadin.flow.component.button.Button> implements WithIdMixin<MultiClickButton>, ComponentClickNotifier<MultiClickButton>, Clickable, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasEnabled, HasState<ButtonState>, StateChangeNotifier<ButtonState,MultiClickButton>
A button that needs multiple clicks before a regular click listener can be invoked.
Since:
2020-07-06
Author:
miki
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a button with given listener and states.
    Creates a button with given states.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.vaadin.flow.shared.Registration
    Adds a listener.
    com.vaadin.flow.shared.Registration
    void
    Removes all associated states.
    void
    Clicks this object.
    com.vaadin.flow.component.Component
    Returns current icon.
    Returns the current state of this object.
    Returns currently displayed text.
    protected com.vaadin.flow.component.button.Button
     
    boolean
     
    void
    setEnabled(boolean enabled)
     
    void
    Sets the states of the button that need to be clicked one after another before the real click happens.
    final void
    Sets the states of the button that need to be clicked one after another before the real click happens.
    protected void
    Updates the state of the button from old to new.

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

    getChildren, getContent, getElement

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

    addListener, findAncestor, fireEvent, from, get, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, 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.DetachNotifier

    addDetachListener

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

    getElement

    Methods inherited from interface org.vaadin.miki.markers.HasId

    getId, setId

    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 org.vaadin.miki.markers.WithIdMixin

    withId
  • Constructor Details

    • MultiClickButton

      public MultiClickButton(ButtonState... states)
      Creates a button with given states.
      Parameters:
      states - An array of ButtonStates. Once button reaches last state, it fires click event.
    • MultiClickButton

      public MultiClickButton(ComponentClickListener<MultiClickButton> listener, ButtonState... states)
      Creates a button with given listener and states.
      Parameters:
      listener - Listener that will be notified once button reaches its final state and is clicked.
      states - An array of ButtonStates. Once button reaches last state, it fires click event.
  • Method Details

    • addClickListener

      public com.vaadin.flow.shared.Registration addClickListener(ComponentClickListener<MultiClickButton> listener)
      Description copied from interface: ComponentClickNotifier
      Adds a listener.
      Specified by:
      addClickListener in interface ComponentClickNotifier<MultiClickButton>
      Parameters:
      listener - Listener to be notified when event is fired.
      Returns:
      A Registration that can be used to stop listening to the event.
    • updateButtonState

      protected void updateButtonState(ButtonState newState)
      Updates the state of the button from old to new.
      Parameters:
      newState - New state.
    • setStates

      public void setStates(Collection<ButtonState> states)
      Sets the states of the button that need to be clicked one after another before the real click happens.
      Parameters:
      states - ButtonStates to use. Old states will be removed.
    • setStates

      public final void setStates(ButtonState... states)
      Sets the states of the button that need to be clicked one after another before the real click happens.
      Parameters:
      states - ButtonStates to use. Old states will be removed.
    • getText

      public String getText()
      Returns currently displayed text.
      Returns:
      Currently displayed text.
    • getIcon

      public com.vaadin.flow.component.Component getIcon()
      Returns current icon.
      Returns:
      Current icon.
    • getState

      public ButtonState getState()
      Description copied from interface: HasState
      Returns the current state of this object. The changes to the resulting object should not affect this object.
      Specified by:
      getState in interface HasState<ButtonState>
      Returns:
      Current state. May never be null.
    • clear

      public void clear()
      Removes all associated states.
    • initContent

      protected com.vaadin.flow.component.button.Button initContent()
      Overrides:
      initContent in class com.vaadin.flow.component.Composite<com.vaadin.flow.component.button.Button>
    • click

      public void click()
      Description copied from interface: Clickable
      Clicks this object. What it means is left for implementations to figure out.
      Specified by:
      click in interface Clickable
    • setEnabled

      public void setEnabled(boolean enabled)
      Specified by:
      setEnabled in interface com.vaadin.flow.component.HasEnabled
    • isEnabled

      public boolean isEnabled()
      Specified by:
      isEnabled in interface com.vaadin.flow.component.HasEnabled
    • addStateChangeListener

      public com.vaadin.flow.shared.Registration addStateChangeListener(StateChangeListener<ButtonState,MultiClickButton> listener)
      Description copied from interface: StateChangeNotifier
      Specified by:
      addStateChangeListener in interface StateChangeNotifier<ButtonState,MultiClickButton>
      Parameters:
      listener - Listener to be notified about StateChangeEvents.
      Returns:
      A Registration that can be used to stop listening to the event.