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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MultiClickButton(ComponentClickListener<MultiClickButton> listener, ButtonState... states)Creates a button with given listener and states.MultiClickButton(ButtonState... states)Creates a button with given states.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.vaadin.flow.shared.RegistrationaddClickListener(ComponentClickListener<MultiClickButton> listener)Adds a listener.com.vaadin.flow.shared.RegistrationaddStateChangeListener(StateChangeListener<ButtonState,MultiClickButton> listener)Adds givenStateChangeListener.voidclear()Removes all associated states.voidclick()Clicks this object.com.vaadin.flow.component.ComponentgetIcon()Returns current icon.ButtonStategetState()Returns the current state of this object.StringgetText()Returns currently displayed text.protected com.vaadin.flow.component.button.ButtoninitContent()booleanisEnabled()voidsetEnabled(boolean enabled)voidsetStates(Collection<ButtonState> states)Sets the states of the button that need to be clicked one after another before the real click happens.voidsetStates(ButtonState... states)Sets the states of the button that need to be clicked one after another before the real click happens.protected voidupdateButtonState(ButtonState newState)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, 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.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 Detail
-
MultiClickButton
public MultiClickButton(ButtonState... states)
Creates a button with given states.- Parameters:
states- An array ofButtonStates. 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 ofButtonStates. Once button reaches last state, it fires click event.
-
-
Method Detail
-
addClickListener
public com.vaadin.flow.shared.Registration addClickListener(ComponentClickListener<MultiClickButton> listener)
Description copied from interface:ComponentClickNotifierAdds a listener.- Specified by:
addClickListenerin interfaceComponentClickNotifier<MultiClickButton>- Parameters:
listener- Listener to be notified when event is fired.- Returns:
- A
Registrationthat 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:HasStateReturns the current state of this object. The changes to the resulting object should not affect this object.- Specified by:
getStatein interfaceHasState<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:
initContentin classcom.vaadin.flow.component.Composite<com.vaadin.flow.component.button.Button>
-
click
public void click()
Description copied from interface:ClickableClicks this object. What it means is left for implementations to figure out.
-
setEnabled
public void setEnabled(boolean enabled)
- Specified by:
setEnabledin interfacecom.vaadin.flow.component.HasEnabled
-
isEnabled
public boolean isEnabled()
- Specified by:
isEnabledin interfacecom.vaadin.flow.component.HasEnabled
-
addStateChangeListener
public com.vaadin.flow.shared.Registration addStateChangeListener(StateChangeListener<ButtonState,MultiClickButton> listener)
Description copied from interface:StateChangeNotifierAdds givenStateChangeListener.- Specified by:
addStateChangeListenerin interfaceStateChangeNotifier<ButtonState,MultiClickButton>- Parameters:
listener- Listener to be notified aboutStateChangeEvents.- Returns:
- A
Registrationthat can be used to stop listening to the event.
-
-