Module com.googlecode.lanterna
Class ActionListDialogBuilder
- java.lang.Object
-
- com.googlecode.lanterna.gui2.dialogs.AbstractDialogBuilder<ActionListDialogBuilder,ActionListDialog>
-
- com.googlecode.lanterna.gui2.dialogs.ActionListDialogBuilder
-
public class ActionListDialogBuilder extends AbstractDialogBuilder<ActionListDialogBuilder,ActionListDialog>
Dialog builder for theActionListDialog
class, use this to create instances of that class and to customize them
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.Runnable>
actions
private boolean
canCancel
private boolean
closeAutomatically
private TerminalSize
listBoxSize
-
Fields inherited from class com.googlecode.lanterna.gui2.dialogs.AbstractDialogBuilder
description, extraWindowHints, title
-
-
Constructor Summary
Constructors Constructor Description ActionListDialogBuilder()
Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ActionListDialogBuilder
addAction(java.lang.Runnable action)
Adds an additional action to theActionListBox
that is to be displayed when the dialog is opened.ActionListDialogBuilder
addAction(java.lang.String label, java.lang.Runnable action)
Adds an additional action to theActionListBox
that is to be displayed when the dialog is openedActionListDialogBuilder
addActions(java.lang.Runnable... actions)
Adds additional actions to theActionListBox
that is to be displayed when the dialog is opened.protected ActionListDialog
buildDialog()
Builds the dialog according to the builder implementationjava.util.List<java.lang.Runnable>
getActions()
Returns a copy of the internal list of actions currently inside this builder that will be assigned to theActionListBox
in the dialog when builtTerminalSize
getListBoxSize()
Returns the specified size of the internalActionListBox
ornull
if there is no size and the list box will attempt to take up enough size to draw all itemsboolean
isCanCancel()
Returnstrue
if the dialog can be cancelled once it's openedprotected ActionListDialogBuilder
self()
Helper method for casting this totype
parameterB
ActionListDialogBuilder
setCanCancel(boolean canCancel)
Sets if the dialog can be cancelled or not (default:true
)ActionListDialogBuilder
setCloseAutomaticallyOnAction(boolean closeAutomatically)
Sets if clicking on an action automatically closes the dialog after the action is finished (default:true
)ActionListDialogBuilder
setListBoxSize(TerminalSize listBoxSize)
Sets the size of the internalActionListBox
in columns and rows, forcing scrollbars to appear if the space isn't big enough to contain all the items-
Methods inherited from class com.googlecode.lanterna.gui2.dialogs.AbstractDialogBuilder
build, getDescription, getExtraWindowHints, getTitle, setDescription, setExtraWindowHints, setTitle
-
-
-
-
Field Detail
-
actions
private final java.util.List<java.lang.Runnable> actions
-
listBoxSize
private TerminalSize listBoxSize
-
canCancel
private boolean canCancel
-
closeAutomatically
private boolean closeAutomatically
-
-
Method Detail
-
self
protected ActionListDialogBuilder self()
Description copied from class:AbstractDialogBuilder
Helper method for casting this totype
parameterB
- Specified by:
self
in classAbstractDialogBuilder<ActionListDialogBuilder,ActionListDialog>
- Returns:
this
asB
-
buildDialog
protected ActionListDialog buildDialog()
Description copied from class:AbstractDialogBuilder
Builds the dialog according to the builder implementation- Specified by:
buildDialog
in classAbstractDialogBuilder<ActionListDialogBuilder,ActionListDialog>
- Returns:
- New dialog object
-
setListBoxSize
public ActionListDialogBuilder setListBoxSize(TerminalSize listBoxSize)
Sets the size of the internalActionListBox
in columns and rows, forcing scrollbars to appear if the space isn't big enough to contain all the items- Parameters:
listBoxSize
- Size of theActionListBox
- Returns:
- Itself
-
getListBoxSize
public TerminalSize getListBoxSize()
Returns the specified size of the internalActionListBox
ornull
if there is no size and the list box will attempt to take up enough size to draw all items- Returns:
- Specified size of the internal
ActionListBox
ornull
if there is no size
-
setCanCancel
public ActionListDialogBuilder setCanCancel(boolean canCancel)
Sets if the dialog can be cancelled or not (default:true
)- Parameters:
canCancel
- Iftrue
, the user has the option to cancel the dialog, iffalse
there is no such button in the dialog- Returns:
- Itself
-
isCanCancel
public boolean isCanCancel()
Returnstrue
if the dialog can be cancelled once it's opened- Returns:
true
if the dialog can be cancelled once it's opened
-
addAction
public ActionListDialogBuilder addAction(java.lang.String label, java.lang.Runnable action)
Adds an additional action to theActionListBox
that is to be displayed when the dialog is opened- Parameters:
label
- Label of the new actionaction
- Action to perform if the user selects this item- Returns:
- Itself
-
addAction
public ActionListDialogBuilder addAction(java.lang.Runnable action)
Adds an additional action to theActionListBox
that is to be displayed when the dialog is opened. The label of this item will be derived by callingtoString()
on the runnable- Parameters:
action
- Action to perform if the user selects this item- Returns:
- Itself
-
addActions
public ActionListDialogBuilder addActions(java.lang.Runnable... actions)
Adds additional actions to theActionListBox
that is to be displayed when the dialog is opened. The label of the items will be derived by callingtoString()
on each runnable- Parameters:
actions
- Items to add to theActionListBox
- Returns:
- Itself
-
getActions
public java.util.List<java.lang.Runnable> getActions()
Returns a copy of the internal list of actions currently inside this builder that will be assigned to theActionListBox
in the dialog when built- Returns:
- Copy of the internal list of actions currently inside this builder
-
setCloseAutomaticallyOnAction
public ActionListDialogBuilder setCloseAutomaticallyOnAction(boolean closeAutomatically)
Sets if clicking on an action automatically closes the dialog after the action is finished (default:true
)- Parameters:
closeAutomatically
- iftrue
dialog will be automatically closed after choosing and finish any of the action- Returns:
- Itself
-
-