Class Toaster
- java.lang.Object
-
- org.pepstock.charba.client.utils.toast.Toaster
-
public final class Toaster extends Object
Utility for displaying toast notifications with progress bars on the page.- Author:
- Andrea "Stock" Stocchero
-
-
Field Summary
Fields Modifier and Type Field Description static intMAXIMUM_OPEN_ITEMSMaximum amount of open and shown toasts.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Toasterget()Singleton object to get the toaster instanceDefaultToastOptionsgetDefaults()Returns the defaults of toast.List<ToastItem>getHistoryItems()Returns the list of toast items in the history.intgetMaxHistoryItems()Returns the maximum amount of toast items you want to maintain in the history.intgetMaxOpenItems()Returns the maximum amount of open toast items you want to maintain on DOM.MaximumOpenItemsPolicygetMaxOpenItemsPolicy()Returns the policy to apply when the maximum amount of open items is reached.voidhideOpenItems()Closes all items which are opened and not closed yet.
All toast items in queued will be removed.voidhideOpenItems(boolean clearQueue)Closes all items which are opened and not closed yet.
If the passed argument istrue, it clears also the queue, without showing the items.voidsetMaxHistoryItems(int maxHistoryItems)Sets the maximum amount of toast items you want to maintain in the history.voidsetMaxOpenItems(int maxOpenItems)Sets the maximum amount of open toast items you want to maintain on DOM.
Maximum value is 100.voidsetMaxOpenItemsPolicy(MaximumOpenItemsPolicy policy)Sets the policy to apply when the maximum amount of open items is reached.Statusshow(String... label)Creates and shows a toast configured by the passed options.Statusshow(String title, String label)Creates and shows a toast with title and label.Statusshow(String title, List<String> label)Creates and shows a toast with title and label.Statusshow(List<String> label)Creates and shows a toast configured by the passed options.Statusshow(Map<String,Object> context, String... label)Creates and shows a toast configured by the passed options.Statusshow(Map<String,Object> context, String title, String label)Creates and shows a toast with title and label.Statusshow(Map<String,Object> context, String title, List<String> label)Creates and shows a toast with title and label.Statusshow(Map<String,Object> context, List<String> label)Creates and shows a toast configured by the passed options.Statusshow(Map<String,Object> context, IsToastType type, String... label)Creates and shows a toast configured by the passed options.Statusshow(Map<String,Object> context, IsToastType type, String title, String label)Creates and shows a toast with title and label.Statusshow(Map<String,Object> context, IsToastType type, String title, List<String> label)Creates and shows a toast with title and label.Statusshow(Map<String,Object> context, IsToastType type, List<String> label)Creates and shows a toast configured by the passed options.Statusshow(Map<String,Object> context, ToastOptions options, String... label)Creates and shows a toast configured by the passed options.Statusshow(Map<String,Object> context, ToastOptions options, String title, String label)Creates and shows a toast configured by the passed options.Statusshow(Map<String,Object> context, ToastOptions options, String title, List<String> label)Creates and shows a toast configured by the passed options.Statusshow(Map<String,Object> context, ToastOptions options, List<String> label)Creates and shows a toast configured by the passed options.Statusshow(IsToastType type, String... label)Creates and shows a toast configured by the passed options.Statusshow(IsToastType type, String title, String label)Creates and shows a toast with title and label.Statusshow(IsToastType type, String title, List<String> label)Creates and shows a toast with title and label.Statusshow(IsToastType type, List<String> label)Creates and shows a toast configured by the passed options.Statusshow(ToastOptions options, String... label)Creates and shows a toast configured by the passed options.Statusshow(ToastOptions options, String title, String label)Creates and shows a toast configured by the passed options.Statusshow(ToastOptions options, String title, List<String> label)Creates and shows a toast configured by the passed options.Statusshow(ToastOptions options, List<String> label)Creates and shows a toast configured by the passed options.
-
-
-
Field Detail
-
MAXIMUM_OPEN_ITEMS
public static final int MAXIMUM_OPEN_ITEMS
Maximum amount of open and shown toasts.- See Also:
- Constant Field Values
-
-
Method Detail
-
get
public static Toaster get()
Singleton object to get the toaster instance- Returns:
- toaster instance.
-
getDefaults
public DefaultToastOptions getDefaults()
Returns the defaults of toast.- Returns:
- the defaults of toast
-
show
public Status show(String... label)
Creates and shows a toast configured by the passed options.- Parameters:
label- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(List<String> label)
Creates and shows a toast configured by the passed options.- Parameters:
label- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(IsToastType type, String... label)
Creates and shows a toast configured by the passed options.- Parameters:
type- type of the toastlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(IsToastType type, List<String> label)
Creates and shows a toast configured by the passed options.- Parameters:
type- type of the toastlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(ToastOptions options, String... label)
Creates and shows a toast configured by the passed options.- Parameters:
options- configuration of the toast to showlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(ToastOptions options, List<String> label)
Creates and shows a toast configured by the passed options.- Parameters:
options- configuration of the toast to showlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(String title, String label)
Creates and shows a toast with title and label.- Parameters:
title- title of the toastlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(String title, List<String> label)
Creates and shows a toast with title and label.- Parameters:
title- title of the toastlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(IsToastType type, String title, String label)
Creates and shows a toast with title and label.- Parameters:
type- type of the toasttitle- title of the toastlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(IsToastType type, String title, List<String> label)
Creates and shows a toast with title and label.- Parameters:
type- type of the toasttitle- title of the toastlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(ToastOptions options, String title, String label)
Creates and shows a toast configured by the passed options.- Parameters:
options- configuration of the toast to showtitle- title of the toastlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(ToastOptions options, String title, List<String> label)
Creates and shows a toast configured by the passed options.- Parameters:
options- configuration of the toast to showtitle- title of the toastlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(Map<String,Object> context, String... label)
Creates and shows a toast configured by the passed options.- Parameters:
context- context of toast executionlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(Map<String,Object> context, List<String> label)
Creates and shows a toast configured by the passed options.- Parameters:
context- context of toast executionlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(Map<String,Object> context, IsToastType type, String... label)
Creates and shows a toast configured by the passed options.- Parameters:
context- context of toast executiontype- type of the toastlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(Map<String,Object> context, IsToastType type, List<String> label)
Creates and shows a toast configured by the passed options.- Parameters:
context- context of toast executiontype- type of the toastlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(Map<String,Object> context, ToastOptions options, String... label)
Creates and shows a toast configured by the passed options.- Parameters:
context- context of toast executionoptions- configuration of the toast to showlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(Map<String,Object> context, ToastOptions options, List<String> label)
Creates and shows a toast configured by the passed options.- Parameters:
context- context of toast executionoptions- configuration of the toast to showlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(Map<String,Object> context, String title, String label)
Creates and shows a toast with title and label.- Parameters:
context- context of toast executiontitle- title of the toastlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(Map<String,Object> context, String title, List<String> label)
Creates and shows a toast with title and label.- Parameters:
context- context of toast executiontitle- title of the toastlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(Map<String,Object> context, IsToastType type, String title, String label)
Creates and shows a toast with title and label.- Parameters:
context- context of toast executiontype- type of the toasttitle- title of the toastlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(Map<String,Object> context, IsToastType type, String title, List<String> label)
Creates and shows a toast with title and label.- Parameters:
context- context of toast executiontype- type of the toasttitle- title of the toastlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(Map<String,Object> context, ToastOptions options, String title, String label)
Creates and shows a toast configured by the passed options.- Parameters:
context- context of toast executionoptions- configuration of the toast to showtitle- title of the toastlabel- label of the toast- Returns:
- the status if the toast has been shown
-
show
public Status show(Map<String,Object> context, ToastOptions options, String title, List<String> label)
Creates and shows a toast configured by the passed options.- Parameters:
context- context of toast executionoptions- configuration of the toast to showtitle- title of the toastlabel- label of the toast- Returns:
- the status if the toast has been shown
-
getMaxHistoryItems
public int getMaxHistoryItems()
Returns the maximum amount of toast items you want to maintain in the history.- Returns:
- the maximum amount of toast items you want to maintain in the history
-
setMaxHistoryItems
public void setMaxHistoryItems(int maxHistoryItems)
Sets the maximum amount of toast items you want to maintain in the history.- Parameters:
maxHistoryItems- the maximum amount of toast items you want to maintain in the history
-
getHistoryItems
public List<ToastItem> getHistoryItems()
Returns the list of toast items in the history.- Returns:
- the list of toast items in the history
-
getMaxOpenItemsPolicy
public MaximumOpenItemsPolicy getMaxOpenItemsPolicy()
Returns the policy to apply when the maximum amount of open items is reached.- Returns:
- the policy to apply when the maximum amount of open items is reached
-
setMaxOpenItemsPolicy
public void setMaxOpenItemsPolicy(MaximumOpenItemsPolicy policy)
Sets the policy to apply when the maximum amount of open items is reached.- Parameters:
policy- the policy to apply when the maximum amount of open items is reached
-
getMaxOpenItems
public int getMaxOpenItems()
Returns the maximum amount of open toast items you want to maintain on DOM.- Returns:
- the maximum amount of open toast items you want to maintain on DOM
-
setMaxOpenItems
public void setMaxOpenItems(int maxOpenItems)
Sets the maximum amount of open toast items you want to maintain on DOM.
Maximum value is 100.- Parameters:
maxOpenItems- the maximum amount of open toast items you want to maintain on DOM
-
hideOpenItems
public void hideOpenItems()
Closes all items which are opened and not closed yet.
All toast items in queued will be removed.
-
hideOpenItems
public void hideOpenItems(boolean clearQueue)
Closes all items which are opened and not closed yet.
If the passed argument istrue, it clears also the queue, without showing the items.- Parameters:
clearQueue- iftrue, it clears also the queue, without showing the items.
-
-