org.vishia.gral.widget

## Class GralCommandSelector

- java.lang.Object
- - org.vishia.gral.widget.GralSelectList<JZtxtcmdScript.Subroutine>
  - - org.vishia.gral.widget.GralCommandSelector

- All Implemented Interfaces:
    Removeable

      public class GralCommandSelector
      extends GralSelectList<JZtxtcmdScript.Subroutine>

  This class is a widget to select commands from a table list. It can be used in any application in a window, which is opened on demand or which is open any time. The user can select a line with the command and click OK (Enter, Mouse). Then the command is send to the instance of `CmdExecuter` which is given by constructor and executed there in the thread of the `CmdExecuter`. It is possible to share the CmdQueue-instance with some other application parts. The execution is queued there. The commands are shown in a table. The appearance of the table can be controlled by the application or maybe by the user. Only one command can be selected to execute. All commands to select are contained in the public field `#cmdStore`. This storage of commands can be filled calling `CmdStore#readCmdCfg(File)` or in any other way of that class.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `GralUserAction` | `actionExecCmdWithFiles`
    `private GralUserAction` | `actionOnLineSelected`
    `JZtxtcmdScript.AddSub2List` | `addJZsub2SelectTable`
    `protected CmdExecuter` | `cmdExecuter` Execution instance in another thread.
    `protected CmdGetterArguments` | `getterArguments`
    `(package private) java.lang.Appendable` | `out`
    `protected JZtxtcmdScript.Subroutine` | `selectedCmd` The currently selected command.
    `static java.lang.String` | `version` Version, history and license.

    - ### Fields inherited from class org.vishia.gral.widget.GralSelectList

      `actions, keyLeft, keyRight, wdgdTable`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GralCommandSelector(java.lang.String name, int rows, int[] columns, char size, CmdExecuter cmdExecuter, java.lang.Appendable out, CmdGetterArguments getterArguments)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `actionLeft(java.lang.Object userData, GralTableLine_ifc line)` Action if a table line is selected and ctrl-left is pressed or the release button is pressed.
    `protected boolean` | `actionOk(java.lang.Object userData, GralTableLine_ifc<JZtxtcmdScript.Subroutine> line)` Action on click Ok at any line of table.
    `protected void` | `actionRight(java.lang.Object userData, GralTableLine_ifc line)` Action if a table line is selected and ctrl-right is pressed or the release button is pressed.
    `protected boolean` | `actionUserKey(int key, java.lang.Object userData, GralTableLine_ifc line)` Action if a table line is selected and any other key is pressed or the context menu is invoked.
    `void` | `clear()`
    `void` | `createImplWidget_Gthread()`
    `void` | `executeCurrCmdWithFiles()` Executes the command which is selected currently.
    `JZtxtcmdScript.Subroutine` | `getCurrCmd()` Returns the currently selected command.

    - ### Methods inherited from class org.vishia.gral.widget.GralSelectList

      `remove, set, setFocus, setLeftRightKeys, stop, XXXsetToPanel`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### version

          public static final java.lang.String version

      Version, history and license. This String is visible in the about info.
      - 2017-01-01 Now supports only `JZtxtcmdScript.Subroutine`, no more CmdStore. The CmdStore is the older concept before JZcmd was found. JZcmd contains more capabilities.
      - 2013-10-00 Hartmut created
      Copyright/Copyleft:
      For this source the LGPL Lesser General Public License, published by the Free Software Foundation is valid. It means:
      1. You can use this source without any restriction for any desired purpose.
      2. You can redistribute copies of this source to everybody.
      3. Every user of this source, also the user of redistribute copies with or without payment, must accept this license for further using.
      4. But the LPGL is not appropriate for a whole software product, if this source is only a part of them. It means, the user must publish this part of source, but doesn't need to publish the whole source of the own product.
      5. You can study and modify (improve) this source for own using or for redistribution, but you have to license the modified sources likewise under this LGPL Lesser General Public License. You mustn't delete this Copyright/Copyleft inscription in this source file.
      If you intent to use this source without publishing its usage, you can get a second license subscribing a special contract with the author.
      See Also:
        Constant Field Values

    - #### cmdExecuter

          protected final CmdExecuter cmdExecuter

      Execution instance in another thread.

    - #### getterArguments

          protected final CmdGetterArguments getterArguments

      Since:
        2016-12

    - #### selectedCmd

          protected JZtxtcmdScript.Subroutine selectedCmd

      The currently selected command.

    - #### out

          final java.lang.Appendable out

    - #### addJZsub2SelectTable

          public JZtxtcmdScript.AddSub2List addJZsub2SelectTable

    - #### actionOnLineSelected

          private final GralUserAction actionOnLineSelected

    - #### actionExecCmdWithFiles

          public GralUserAction actionExecCmdWithFiles

  - ### Constructor Detail

    - #### GralCommandSelector

          public GralCommandSelector(java.lang.String name,
                                     int rows,
                                     int[] columns,
                                     char size,
                                     CmdExecuter cmdExecuter,
                                     java.lang.Appendable out,
                                     CmdGetterArguments getterArguments)

  - ### Method Detail

    - #### createImplWidget_Gthread

          public void createImplWidget_Gthread()

      Overrides:
        `createImplWidget_Gthread` in class `GralSelectList<JZtxtcmdScript.Subroutine>`

    - #### clear

          public void clear()

    - #### getCurrCmd

          public JZtxtcmdScript.Subroutine getCurrCmd()

      Returns the currently selected command.

    - #### executeCurrCmdWithFiles

          public void executeCurrCmdWithFiles()

      Executes the command which is selected currently. Whether or not the selection is visible and recognized by the user, it should be defined in the application.

    - #### actionOk

          protected boolean actionOk(java.lang.Object userData,
                                     GralTableLine_ifc<JZtxtcmdScript.Subroutine> line)

      Action on click Ok at any line of table.
      Specified by:
        `actionOk` in class `GralSelectList<JZtxtcmdScript.Subroutine>`
      Parameters:
        `userData` - It is the `GralTableLine_ifc.getUserData()`, which is the `CmdStore.CmdBlock`-instance which is assigned with the line. The method casts without check.
        `line` - isn't used here. It can be null in direct invocations.
      See Also:
        `GralSelectList.actionOk(java.lang.Object, org.vishia.gral.ifc.GralTableLine_ifc)`

    - #### actionLeft

          protected void actionLeft(java.lang.Object userData,
                                    GralTableLine_ifc line)

      Description copied from class: `GralSelectList`
      Action if a table line is selected and ctrl-left is pressed or the release button is pressed.
      Specified by:
        `actionLeft` in class `GralSelectList<JZtxtcmdScript.Subroutine>`
      Parameters:
        `userData` - The user data stored in the line of table.

    - #### actionRight

          protected void actionRight(java.lang.Object userData,
                                     GralTableLine_ifc line)

      Description copied from class: `GralSelectList`
      Action if a table line is selected and ctrl-right is pressed or the release button is pressed.
      Specified by:
        `actionRight` in class `GralSelectList<JZtxtcmdScript.Subroutine>`
      Parameters:
        `userData` - The user data stored in the line of table.

    - #### actionUserKey

          protected boolean actionUserKey(int key,
                                          java.lang.Object userData,
                                          GralTableLine_ifc line)

      Description copied from class: `GralSelectList`
      Action if a table line is selected and any other key is pressed or the context menu is invoked.
      Specified by:
        `actionUserKey` in class `GralSelectList<JZtxtcmdScript.Subroutine>`
      Parameters:
        `key` - code or mouse code, one of constans from `KeyCode`.
        `userData` - The user data stored in the line of table.
        `line` - The table line.
      Returns:
        true if is was relevant for the key.