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
ConstructorsConstructorDescriptionMultiClickButton(ComponentClickListener<MultiClickButton> listener, ButtonState... states) Creates a button with given listener and states.MultiClickButton(ButtonState... states) Creates a button with given states. -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.RegistrationAdds a listener.com.vaadin.flow.shared.RegistrationAdds givenStateChangeListener.voidclear()Removes all associated states.voidclick()Clicks this object.com.vaadin.flow.component.ComponentgetIcon()Returns current icon.getState()Returns the current state of this object.getText()Returns currently displayed text.protected com.vaadin.flow.component.button.ButtonbooleanvoidsetEnabled(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.final 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, getElementMethods 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, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods 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, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface org.vaadin.miki.markers.WithIdMixin
withId
-
Constructor Details
-
MultiClickButton
Creates a button with given states.- Parameters:
states- An array ofButtonStates. Once button reaches last state, it fires click event.
-
MultiClickButton
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 Details
-
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
Updates the state of the button from old to new.- Parameters:
newState- New state.
-
setStates
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
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
Returns currently displayed text.- Returns:
- Currently displayed text.
-
getIcon
public com.vaadin.flow.component.Component getIcon()Returns current icon.- Returns:
- Current icon.
-
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.
-