X-Git-Url: http://git.nikiroo.be/?p=jvcard.git;a=blobdiff_plain;f=src%2Fcom%2Fgooglecode%2Flanterna%2Fgui2%2Fdialogs%2FActionListDialogBuilder.java;fp=src%2Fcom%2Fgooglecode%2Flanterna%2Fgui2%2Fdialogs%2FActionListDialogBuilder.java;h=0000000000000000000000000000000000000000;hp=311f752bc5056389a92efadd18d97e392ede6ba7;hb=f06c81000632cfb5f525ca458f719338f55f9f66;hpb=a73a906356c971b080c36368e71a15d87e8b8d31 diff --git a/src/com/googlecode/lanterna/gui2/dialogs/ActionListDialogBuilder.java b/src/com/googlecode/lanterna/gui2/dialogs/ActionListDialogBuilder.java deleted file mode 100644 index 311f752..0000000 --- a/src/com/googlecode/lanterna/gui2/dialogs/ActionListDialogBuilder.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.googlecode.lanterna.gui2.dialogs; - -import com.googlecode.lanterna.TerminalSize; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * Dialog builder for the {@code ActionListDialog} class, use this to create instances of that class and to customize - * them - * @author Martin - */ -public class ActionListDialogBuilder extends AbstractDialogBuilder { - private TerminalSize listBoxSize; - private boolean canCancel; - private List actions; - - /** - * Default constructor - */ - public ActionListDialogBuilder() { - super("ActionListDialogBuilder"); - this.listBoxSize = null; - this.canCancel = true; - this.actions = new ArrayList(); - } - - @Override - protected ActionListDialogBuilder self() { - return this; - } - - @Override - protected ActionListDialog buildDialog() { - return new ActionListDialog( - title, - description, - listBoxSize, - canCancel, - actions); - } - - /** - * Sets the size of the internal {@code ActionListBox} in columns and rows, forcing scrollbars to appear if the - * space isn't big enough to contain all the items - * @param listBoxSize Size of the {@code ActionListBox} - * @return Itself - */ - public ActionListDialogBuilder setListBoxSize(TerminalSize listBoxSize) { - this.listBoxSize = listBoxSize; - return this; - } - - /** - * Returns the specified size of the internal {@code ActionListBox} or {@code null} if there is no size and the list - * box will attempt to take up enough size to draw all items - * @return Specified size of the internal {@code ActionListBox} or {@code null} if there is no size - */ - public TerminalSize getListBoxSize() { - return listBoxSize; - } - - /** - * Sets if the dialog can be cancelled or not (default: {@code true}) - * @param canCancel If {@code true}, the user has the option to cancel the dialog, if {@code false} there is no such - * button in the dialog - * @return Itself - */ - public ActionListDialogBuilder setCanCancel(boolean canCancel) { - this.canCancel = canCancel; - return this; - } - - /** - * Returns {@code true} if the dialog can be cancelled once it's opened - * @return {@code true} if the dialog can be cancelled once it's opened - */ - public boolean isCanCancel() { - return canCancel; - } - - /** - * Adds an additional action to the {@code ActionListBox} that is to be displayed when the dialog is opened - * @param label Label of the new action - * @param action Action to perform if the user selects this item - * @return Itself - */ - public ActionListDialogBuilder addAction(final String label, final Runnable action) { - return addAction(new Runnable() { - @Override - public String toString() { - return label; - } - - @Override - public void run() { - action.run(); - } - }); - } - - /** - * Adds an additional action to the {@code ActionListBox} that is to be displayed when the dialog is opened. The - * label of this item will be derived by calling {@code toString()} on the runnable - * @param action Action to perform if the user selects this item - * @return Itself - */ - public ActionListDialogBuilder addAction(Runnable action) { - this.actions.add(action); - return this; - } - - /** - * Adds additional actions to the {@code ActionListBox} that is to be displayed when the dialog is opened. The - * label of the items will be derived by calling {@code toString()} on each runnable - * @param actions Items to add to the {@code ActionListBox} - * @return Itself - */ - public ActionListDialogBuilder addActions(Runnable... actions) { - this.actions.addAll(Arrays.asList(actions)); - return this; - } - - /** - * Returns a copy of the internal list of actions currently inside this builder that will be assigned to the - * {@code ActionListBox} in the dialog when built - * @return Copy of the internal list of actions currently inside this builder - */ - public List getActions() { - return new ArrayList(actions); - } -}