/* This file is part of "Telnet Floyd".
 *
 * (c) Radek Polak 2003-2004. All Rights Reserved.
 *
 * Please visit project homepage at http://phoenix.inf.upol.cz/~polakr
 *
 * --LICENSE NOTICE--
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 * --LICENSE NOTICE--
 *
 */

package telnet;
import javax.microedition.lcdui.*;

/**
 * Dialog, that shows all actions. User selects one which will be binded to some
 * key.
 */

public class SelectFunctionDlg extends List implements CommandListener {

  public SelectFunctionDlg() {
    super("Bind action", List.IMPLICIT);
    append("cancel",null);
    append(Action.INPUT_DIALOG,null);
    append(Action.KEY_TYPED,null);
    append(Action.CONNECT,null);
    append(Action.KEY_PRESSED,null);
    append(Action.TYPE_STRING,null);
    append(Action.ENTER_STRING,null);
    append(Action.SCROLL_UP,null);
    append(Action.SCROLL_DOWN,null);
    append(Action.SCROLL_LEFT,null);
    append(Action.SCROLL_RIGH,null);
    append(Action.SET_SCREEN_SIZE,null);
    append(Action.TRAFFIC,null);
    append(Action.BG_COLOR,null);
    append(Action.FG_COLOR,null);
    append(Action.VIEW_CONSOLE,null);
    append(Action.SET_SCOLLBACK_SIZE,null);
    append(Action.SCOLLBACK_UP,null);
    append(Action.SCOLLBACK_DOWN,null);
    append(Action.SHOW_TERMINAL_SIZE,null);
    append(Action.SHOW_HELP,null);
    append(Action.SET_SLEEP_TIME, null);
    append(Action.KEEP_CONNECTION_TIME,null);
    append(Action.EXIT_APP,null);

    setCommandListener(this);
    addCommand(new Command("Bind", Command.SCREEN, 1));
  }

  public void commandAction(Command command, Displayable displayable) {
    if( getSelectedIndex() == 0 )
      Telnet.setDisplay( Telnet.terminal );
    else
    {
      FuncParamsDlg dlg = new FuncParamsDlg();
      Telnet.setDisplay(dlg);
      dlg.setAction(getString(getSelectedIndex()));
    }
  }
}



