org.vishia.gral.ifc

## Interface GralTable_ifc<UserData>

- Type Parameters:
    `UserData` - Type of the data which is associated with a table line.
  All Superinterfaces:
    GralWidget_ifc, Removeable
  All Known Implementing Classes:
    GralTable

      public interface GralTable_ifc<UserData>
      extends GralWidget_ifc

  Interface to a table widget.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.vishia.gral.ifc.GralWidget_ifc

      `GralWidget_ifc.ActionChange, GralWidget_ifc.ActionChangeWhen`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `kAllLines` Identify number for some methods which have a line number parameter.
    `static int` | `kEmptyArea` Identify number for some methods which have a line number parameter.
    `static int` | `version` Version, history and license.

    - ### Fields inherited from interface org.vishia.gral.ifc.GralWidget_ifc

      `sVersion`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `GralTableLine_ifc<UserData>` | `addLine(java.lang.String key, java.lang.String[] cellTexts, UserData userData)` Inserts a line in the table with given content.
    `void` | `clearTable()`
    `void` | `deleteLine(GralTableLine_ifc<UserData> line)` Deletes a line in the table.
    `TreeNode_ifc<?,UserData>` | `getAllLines()` Returns all lines.
    `GralColor` | `getBackColor(int ix)` Gets the background color for the widget.
    `GralTableLine_ifc<UserData>` | `getCurrentLine()` Returns the currently selected line or null if nothing is selected.
    `GralTableLine_ifc<UserData>` | `getFirstMarkedLine(int mask)` Returns the first line from top of the table which is marked or null if no line is marked.
    `GralTableLine_ifc<UserData>` | `getLine(java.lang.String key)` Get the line which is designated with the requested key.
    `java.util.List<UserData>` | `getListContent()` Returns all content of lines.
    `java.util.List<GralTableLine_ifc<UserData>>` | `getMarkedLines(int mask)` Returns all marked lines.
    `GralTableLine_ifc<UserData>` | `insertLine(java.lang.String key, int row, java.lang.String[] cellTexts, UserData userData)` Inserts a line in the table with given content.
    `void` | `setBackColor(GralColor color, int ix)` Sets the background color of the table or one line.
    `void` | `setCurrentLine(GralTableLine_ifc<UserData> line, int ixline, int ixcolumn)` Sets the cell which is the current one in the given line.
    `boolean` | `setCurrentLine(java.lang.String key)` Sets the line which is the current one.
    `int` | `size()` Returns the number of active lines of the table.

    - ### Methods inherited from interface org.vishia.gral.ifc.GralWidget_ifc

      `createImplWidget_Gthread, getActionChange, getCmd, getContentIdent, getContentInfo, getData, getDataPath, getName, gralMng, isChanged, isEditable, isGraphicDisposed, isInFocus, isNotEditableOrShouldInitialize, isVisible, refreshFromVariable, refreshFromVariable, repaint, repaint, setBackgroundColor, setBoundsPixel, setCmd, setContentIdent, setData, setDataPath, setEditable, setFocus, setFocus, setForegroundColor, setHtmlHelp, setLineColor, setText, setTextColor, setToPanel, setVisible`

    - ### Methods inherited from interface org.vishia.util.Removeable

      `remove`

- - ### Field Detail

    - #### version

          static final int version

      Version, history and license.
      - 2013-09-15 Hartmut new: Definition of `setBackColor(GralColor, int)` parallel to the `GralWidget_ifc.getBackColor(int)` with special comments for usage of the int parameter. See `kAllLines`, `kEmptyArea`. Adequate `getBackColor(int)`.
      - 2013-09-05 Hartmut chg: `getMarkedLines(int)` now has that 1 argument for mark mask.
      - 2013-06-11 Hartmut new Now the `GralTable`, the `GralTable.TableLineData` and this interface are marked with the generic type UserData.
      - 2012-08-22 Hartmut new `#setCurrentLine(int)` with int, it isn't new because it was able to set with `#setCurrentCell(int, int)` with -1 as second parameter.
        2011-11-20 Hartmut new `#getMarkedLines()`
        - 2011-10-01 Hartmut new: `clearTable()`
        - 2011-09-03 Hartmut chg: method `#insertLine(String, int)` returns now the instance of `GralTableLine_ifc` The user doesn't create a line instance, an extra factory isn't necessary. The implementing instance can be determined by the implementer of this interface.
        - 2011-05-11 Hartmut new: creation. Tables are a relevant medium to present GUIs. The implementation of tables in SWT or swing are strong different. It needs a simple interface to work with tables.
        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

    - #### kAllLines

          static final int kAllLines

      Identify number for some methods which have a line number parameter. Execute for all lines and the empty area.
      See Also:
        Constant Field Values

    - #### kEmptyArea

          static final int kEmptyArea

      Identify number for some methods which have a line number parameter. Execute only for the empty area (not existing lines)
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### setBackColor

          void setBackColor(GralColor color,
                            int ix)

      Sets the background color of the table or one line.
      Specified by:
        `setBackColor` in interface `GralWidget_ifc`
      Parameters:
        `ix` - >=0 sets for one line only, `kAllLines`: Sets for all lines and the table background, `kEmptyArea`: Only for table background.
        `color` - Any color
      See Also:
        `GralWidget_ifc.setBackColor(org.vishia.gral.ifc.GralColor, int)`

    - #### getBackColor

          GralColor getBackColor(int ix)

      Description copied from interface: `GralWidget_ifc`
      Gets the background color for the widget.
      Specified by:
        `getBackColor` in interface `GralWidget_ifc`
      Parameters:
        `ix` - 0 if only one color is supported, 1, ... if the widget has more as one background.
      Returns:
        color Any color

    - #### getCurrentLine

          GralTableLine_ifc<UserData> getCurrentLine()

      Returns the currently selected line or null if nothing is selected.

    - #### setCurrentLine

          boolean setCurrentLine(java.lang.String key)

      Sets the line which is the current one. The current row is unchanged.
      Parameters:
        `key` - The key of the line, given by `insertLine(String, int, String[], Object)`.
      Returns:
        true if found.

    - #### setCurrentLine

          void setCurrentLine(GralTableLine_ifc<UserData> line,
                              int ixline,
                              int ixcolumn)

      Sets the cell which is the current one in the given line.
      Parameters:
        `line` - The line which should be selected.
        `ixline` - the index in the visible are of table where the line should be present. If the index is negative, it is the index from end of visible area. -1 means the last line. if the index is outside of the area, it will be set inside.
        `ixcolumn` - from 0 for the left column, if -1 then let the current row of table unchanged.

    - #### getLine

          GralTableLine_ifc<UserData> getLine(java.lang.String key)

      Get the line which is designated with the requested key. Background: The lines of a table can be sorted in view. To get a line which is sorted in another row a originally set a key is necessary. The table data model contains a sorted map with keys and the associated lines. The keys can, but may not shown as user visible data.
      Parameters:
        `key` - The key to find out the row.
      Returns:
        null if such line isn't found.

    - #### insertLine

          GralTableLine_ifc<UserData> insertLine(java.lang.String key,
                                                 int row,
                                                 java.lang.String[] cellTexts,
                                                 UserData userData)

      Inserts a line in the table with given content.
      Parameters:
        `key` - The key to get it.
        `row` - The row where the line should be inserted before. 0 - insert on top. negative or Integer.MAXINT or number greater as number of rows: append on end.
        `cellTexts` - texts of the cells. May be null.
        `userData` - data assigned to the line, able to get with `GralTableLine_ifc.getUserData()`.
      Returns:
        instance to add info.
      See Also:
        `GralTableLine_ifc} to add content.`

    - #### addLine

          GralTableLine_ifc<UserData> addLine(java.lang.String key,
                                              java.lang.String[] cellTexts,
                                              UserData userData)

      Inserts a line in the table with given content.
      Parameters:
        `key` - The key to get it.
        `cellTexts` - texts of the cells. May be null.
        `userData` - data assigned to the line, maybe null, able to get with `GralTableLine_ifc.getUserData()`.
      Returns:
        instance to add info.
      See Also:
        `GralTableLine_ifc} to add content.`

    - #### deleteLine

          void deleteLine(GralTableLine_ifc<UserData> line)

      Deletes a line in the table.

    - #### size

          int size()

      Returns the number of active lines of the table.
      Returns:

    - #### clearTable

          void clearTable()

    - #### getMarkedLines

          java.util.List<GralTableLine_ifc<UserData>> getMarkedLines(int mask)

      Returns all marked lines. It returns an empty list if no line is marked.

    - #### getAllLines

          TreeNode_ifc<?,UserData> getAllLines()

      Returns all lines. Note: This returns the original container of lines without backup. It means the list will be changed if any `insertLine(String, int, String[], Object)` or `deleteLine(GralTableLine_ifc)` will be called. Do not call any modification of this list for example `List.add(Object)` or `List.remove(int)`, use the methods of this interface to change the content of the table. Elsewhere the graphical presentation of the data may be corrupted. See `getListContent()`.

    - #### getListContent

          java.util.List<UserData> getListContent()

      Returns all content of lines. This makes a snapshot of the lines in calling time. If the table will be changed in another thread while this routine runs, a `ConcurrentModificationException` will be thrown. But after them the list is able to use independently.

    - #### getFirstMarkedLine

          GralTableLine_ifc<UserData> getFirstMarkedLine(int mask)

      Returns the first line from top of the table which is marked or null if no line is marked.