org.vishia.guiInspc

## Class InspcFieldTable

- java.lang.Object
- - org.vishia.guiInspc.InspcFieldTable

-     public class InspcFieldTable
      extends java.lang.Object

  This class presents a window with one table and some buttons to view and edit all fields in one instance in a target system.
  The InspcFieldTable shows one struct from target data or one instance, all fields of a class of Java reflection view. The fields are stored in instances of `InspcFieldOfStruct` which are referenced as data in the `GralTable` of the private composite reference `widgTable`.
  Filling the table with the fields of a reflection target:
  guiInspc_getFieldsTableOmd
  One of the methods `fillTableFromFocusedVariable()`, `actionBack()`, `getSubStruct(GralTableLine_ifc)` are invoked from operator GUI actions. They call
  `#fillTableStruct()`
  This method checks the `InspcStruct` of the variable respectively the shown struct in table whether it is known already, using `InspcStruct.isUpdated()`. It it is not updated, on selection a new variable, the
  `InspcTargetAccessor.requestFields(org.vishia.inspcPC.InspcTargetAccessData, InspcAccessExecRxOrder_ifc, Runnable)`
  is called. This routine sets only the reference to the `InspcTargetAccessData` and the 2 callbacks. This action is done especially in the graphical thread.
  If `InspcStruct.isUpdated()` returns true, then the struct was updated already. Then it can be shown in the `GralTable` with the names of its elements and the last gotten values.
  The organization thread of `InspcMng` invokes `InspcMng.procComm()` cyclically to show and request values. In this thread via calling `InspcTargetAccessor#requestStart(long)` the request for getFields is recognized. For that the `InspcTargetAccessor.cmdGetFields(String, org.vishia.inspcPC.InspcAccessExecRxOrder_ifc)` is invoked for the path of the struct. That is sent to the target.
  The target answers with some items for all fields in one or more datagram but for that request with the same sequence number. For any item respectively element of the struct the given instance to `InspcStruct.rxActionGetFields` is invoked which fills the struct.
  After the last datagram of this answer the stored reference to the `Runnable`: `actionUpdated` of this class is invoked. This action calls `#fillTableStruct()` now with received and stored fields.
  guiInspc_getFieldsTableSeq
  Show and request values for the fields
  This is simple done by getting maybe with creation of the variable for the requested field: `InspcFieldOfStruct.variable(InspcVariable, org.vishia.byteData.VariableContainer_ifc)` and request a new value with `InspcVariable.requestValue(long, Runnable)`. The callback invoked on end of the last datagram is a temporary instance `RunOnReceive#RunOnReceive(GralTableLine_ifc)` with the given line of the table which invokes `showValue(GralTableLine_ifc, boolean)`.
  guiInspc_getValueTableOmd

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `(package private) class` | `InspcFieldTable.RunOnReceive`
    `static class` | `InspcFieldTable.TxOrderSetValue` An instance of this class is used to prepare setValueByPath on a changed value in a line.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) GralUserAction` | `actionBack`
    `(package private) GralUserAction` | `actionChgTable` This action is invoked on any keyboard hits which are not handled in the GralTable.
    `(package private) GralUserAction` | `actionLineSelected`
    `(package private) GralUserAction` | `actionOpenWindow`
    `(package private) GralUserAction` | `actionRefresh`
    `(package private) GralUserAction` | `actionSetValues`
    `(package private) GralUserAction` | `actionShowAll`
    `(package private) java.lang.Runnable` | `actionUpdated`
    `private GralButton` | `btnBack`
    `private GralButton` | `btnHelp`
    `private GralButton` | `btnRefresh`
    `private GralButton` | `btnRepeat`
    `private GralButton` | `btnSetValue`
    `private GralButton` | `btnShowAll`
    `private java.util.Map<java.lang.String,java.lang.String>` | `indexSelection` This index stores the last selected file for any component which was used.
    `private InspcMng` | `inspcMng` Aggregation.
    `private java.lang.String` | `sFieldCurrent` Name and path to the current selected field.
    `private static int` | `sizeName` Sizes in table in Graphic grid units.
    `private static int` | `sizeStruct` Sizes in table in Graphic grid units.
    `private static int` | `sizeType` Sizes in table in Graphic grid units.
    `private java.lang.String` | `sPathCurrent` Name and path to the current selected field.
    `private java.lang.String` | `sPathStruct` Path in target to the struct which is shown in table.
    `private InspcVariable` | `structVar`
    `protected static java.lang.String` | `sVersion` Version, history and license.
    `private long` | `timeLineSelected`
    `private GralTextField` | `widgPath` Shows the path in target to this struct.
    `private GralTable<InspcFieldOfStruct>` | `widgTable` Table of fields, type and value.
    `private GralWindow` | `wind` The window to present.
    `protected java.util.concurrent.atomic.AtomicBoolean` | `XXXbSetValue` Set in graphic thread with `btnSetValue`, ask and reset in the InspcMng-thread.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `InspcFieldTable(InspcMng inspcMng)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `(package private) void` | `actionBack()`
    `(package private) void` | `actionSetValues()`
    `(package private) void` | `fillTableFromFocusedVariable()`
    `(package private) void` | `fillTableStruct(boolean bCanRequest)` Fills the graphic table to show the structural content of a data node (a C struct or class).
    `java.lang.String` | `getCurrentPathField()`
    `static java.lang.String` | `getDataPath(GralTable.TableLineData line)`
    `(package private) void` | `getSubStruct(GralTableLine_ifc<InspcFieldOfStruct> line)`
    `(package private) void` | `refresh()`
    `(package private) void` | `sendValueChange(GralTableLine_ifc<InspcFieldOfStruct> line)` This method is invoked if the value in the table is changed and this change should be applied to the target, key ctrl-enter.
    `(package private) void` | `setCurrentFieldInfo(GralTable.TableLineData line)`
    `void` | `setToPanel(GralMng mng)`
    `(package private) void` | `showAll()`
    `private void` | `showValue(GralTableLine_ifc<InspcFieldOfStruct> line, boolean request)` Shows the current value inside the target for the specified line.

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

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

- - ### Field Detail

    - #### sVersion

          protected static final java.lang.String sVersion

      Version, history and license.
      - 2018-09-08 Hartmut chg: because `InspcFieldOfStruct` hasSubstruct.
      - 2016-10 Hartmut chg: Regards a field which is a node of tree, not only leaf.
      - 2015-06-21 requests a new value if the older is older than 1 second, fast refresh
      - 2015-05-29 requests a new value only if the current is older than 5 seconds.
      - 2014-01-05 indexSelection
      - 2013-12-18 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 don'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 are intent to use this sources without publishing its usage, you can get a second license subscribing a special contract with the author.
      See Also:
        Constant Field Values

    - #### sizeStruct

          private static final int sizeStruct

      Sizes in table in Graphic grid units.
      See Also:
        Constant Field Values

    - #### sizeName

          private static final int sizeName

      Sizes in table in Graphic grid units.
      See Also:
        Constant Field Values

    - #### sizeType

          private static final int sizeType

      Sizes in table in Graphic grid units.
      See Also:
        Constant Field Values

    - #### wind

          private final GralWindow wind

      The window to present.

    - #### widgPath

          private final GralTextField widgPath

      Shows the path in target to this struct.

    - #### widgTable

          private final GralTable<InspcFieldOfStruct> widgTable

      Table of fields, type and value.

    - #### btnBack

          private final GralButton btnBack

    - #### btnHelp

          private final GralButton btnHelp

    - #### btnRefresh

          private final GralButton btnRefresh

    - #### btnShowAll

          private final GralButton btnShowAll

    - #### btnSetValue

          private final GralButton btnSetValue

    - #### btnRepeat

          private final GralButton btnRepeat

    - #### inspcMng

          private final InspcMng inspcMng

      Aggregation. To get variable, send requests etc.

    - #### indexSelection

          private final java.util.Map<java.lang.String,java.lang.String> indexSelection

      This index stores the last selected file for any component which was used. If the component path is reused later, the same field will be selected initially. It helps by navigation through the file tree.
      - The key is the path in canonical form with '/' as separator (in windows too!) but without terminating '/'.
      - The value is the name of the file in this directory.

    - #### structVar

          private InspcVariable structVar

    - #### sPathStruct

          private java.lang.String sPathStruct

      Path in target to the struct which is shown in table.

    - #### sFieldCurrent

          private java.lang.String sFieldCurrent

      Name and path to the current selected field.

    - #### sPathCurrent

          private java.lang.String sPathCurrent

      Name and path to the current selected field.

    - #### timeLineSelected

          private long timeLineSelected

    - #### XXXbSetValue

          protected java.util.concurrent.atomic.AtomicBoolean XXXbSetValue

      Set in graphic thread with `btnSetValue`, ask and reset in the InspcMng-thread.

    - #### actionOpenWindow

          GralUserAction actionOpenWindow

    - #### actionChgTable

          GralUserAction actionChgTable

      This action is invoked on any keyboard hits which are not handled in the GralTable.

    - #### actionLineSelected

          GralUserAction actionLineSelected

    - #### actionBack

          GralUserAction actionBack

    - #### actionRefresh

          GralUserAction actionRefresh

    - #### actionShowAll

          GralUserAction actionShowAll

    - #### actionSetValues

          GralUserAction actionSetValues

    - #### actionUpdated

          java.lang.Runnable actionUpdated

  - ### Constructor Detail

    - #### InspcFieldTable

          public InspcFieldTable(InspcMng inspcMng)

  - ### Method Detail

    - #### setToPanel

          public void setToPanel(GralMng mng)

    - #### fillTableFromFocusedVariable

          void fillTableFromFocusedVariable()

    - #### fillTableStruct

          void fillTableStruct(boolean bCanRequest)

      Fills the graphic table to show the structural content of a data node (a C struct or class).
      Parameters:
        `bCanRequest` -
      Since:
        2018-09: For array elements uses the `InspcFieldOfStruct.hasSubstruct` info from the parent (the field of the array). Note: It comes from the target: "type..." or "type[size]..." in the telegram.

    - #### showValue

          private void showValue(GralTableLine_ifc<InspcFieldOfStruct> line,
                                 boolean request)

      Shows the current value inside the target for the specified line. This routine is called both if the operator requests a refresh of content of the line: `actionChgTable` or if a new value was received: `InspcFieldTable.RunOnReceive.run()` invoked from `InspcVariable.requestValue(long, Runnable)`. The last one method requestValue() is invoked in this routine if the argument request is set to true.
      Parameters:
        `line` - The line of this table, contains the `InspcFieldOfStruct` as user data , `GralTableLine_ifc.getUserData()`. Therein the variable for this line is stored or will be created with `InspcMng#getOrCreateVariable(InspcStruct, InspcFieldOfStruct)`.
        `request` - true then a new value for the variable of this line will be requested here.

    - #### refresh

          void refresh()

    - #### showAll

          void showAll()

    - #### getCurrentPathField

          public java.lang.String getCurrentPathField()

    - #### getDataPath

          public static java.lang.String getDataPath(GralTable.TableLineData line)

    - #### setCurrentFieldInfo

          void setCurrentFieldInfo(GralTable.TableLineData line)

    - #### actionBack

          void actionBack()

    - #### getSubStruct

          void getSubStruct(GralTableLine_ifc<InspcFieldOfStruct> line)

    - #### actionSetValues

          void actionSetValues()

    - #### sendValueChange

          void sendValueChange(GralTableLine_ifc<InspcFieldOfStruct> line)

      This method is invoked if the value in the table is changed and this change should be applied to the target, key ctrl-enter.