X-Git-Url: http://git.nikiroo.be/?p=jvcard.git;a=blobdiff_plain;f=src%2Fcom%2Fgooglecode%2Flanterna%2Fgui2%2FActionListBox.java;fp=src%2Fcom%2Fgooglecode%2Flanterna%2Fgui2%2FActionListBox.java;h=0000000000000000000000000000000000000000;hp=a805b6ea2dc1bb4e2108d86c497026fb2d0921ad;hb=f06c81000632cfb5f525ca458f719338f55f9f66;hpb=a73a906356c971b080c36368e71a15d87e8b8d31
diff --git a/src/com/googlecode/lanterna/gui2/ActionListBox.java b/src/com/googlecode/lanterna/gui2/ActionListBox.java
deleted file mode 100644
index a805b6e..0000000
--- a/src/com/googlecode/lanterna/gui2/ActionListBox.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * This file is part of lanterna (http://code.google.com/p/lanterna/).
- *
- * lanterna is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
- *
- * Copyright (C) 2010-2015 Martin
- */
-package com.googlecode.lanterna.gui2;
-
-import com.googlecode.lanterna.TerminalPosition;
-import com.googlecode.lanterna.TerminalSize;
-import com.googlecode.lanterna.input.KeyStroke;
-import com.googlecode.lanterna.input.KeyType;
-
-/**
- * This class is a list box implementation that displays a number of items that has actions associated with them. You
- * can activate this action by pressing the Enter or Space keys on the keyboard and the action associated with the
- * currently selected item will fire.
- * @author Martin
- */
-public class ActionListBox extends AbstractListBox {
-
- /**
- * Default constructor, creates an {@code ActionListBox} with no pre-defined size that will request to be big enough
- * to display all items
- */
- public ActionListBox() {
- this(null);
- }
-
- /**
- * Creates a new {@code ActionListBox} with a pre-set size. If the items don't fit in within this size, scrollbars
- * will be used to accommodate. Calling {@code new ActionListBox(null)} has the same effect as calling
- * {@code new ActionListBox()}.
- * @param preferredSize
- */
- public ActionListBox(TerminalSize preferredSize) {
- super(preferredSize);
- }
-
- /**
- * {@inheritDoc}
- *
- * The label of the item in the list box will be the result of calling {@code .toString()} on the runnable, which
- * might not be what you want to have unless you explicitly declare it. Consider using
- * {@code addItem(String label, Runnable action} instead, if you want to just set the label easily without having
- * to override {@code .toString()}.
- *
- * @param object Runnable to execute when the action was selected and fired in the list
- * @return Itself
- */
- @Override
- public ActionListBox addItem(Runnable object) {
- return super.addItem(object);
- }
-
- /**
- * Adds a new item to the list, which is displayed in the list using a supplied label.
- * @param label Label to use in the list for the new item
- * @param action Runnable to invoke when this action is selected and then triggered
- * @return Itself
- */
- public ActionListBox addItem(final String label, final Runnable action) {
- return addItem(new Runnable() {
- @Override
- public void run() {
- action.run();
- }
-
- @Override
- public String toString() {
- return label;
- }
- });
- }
-
- @Override
- public TerminalPosition getCursorLocation() {
- return null;
- }
-
- @Override
- public Result handleKeyStroke(KeyStroke keyStroke) {
- Object selectedItem = getSelectedItem();
- if(selectedItem != null &&
- (keyStroke.getKeyType() == KeyType.Enter ||
- (keyStroke.getKeyType() == KeyType.Character && keyStroke.getCharacter() == ' '))) {
-
- ((Runnable)selectedItem).run();
- return Result.HANDLED;
- }
- return super.handleKeyStroke(keyStroke);
- }
-}