Class FxTreeTableEditContext<S>

java.lang.Object
org.tentackle.fx.table.edit.AbstractTableEditContext<S>
org.tentackle.fx.table.edit.FxTreeTableEditContext<S>
Type Parameters:
S - type of the objects contained within the treetable's items
All Implemented Interfaces:
TableEditContext<S>, TreeTableEditContext<S>

public class FxTreeTableEditContext<S> extends AbstractTableEditContext<S> implements TreeTableEditContext<S>
The edit context of an FxTreeTableView.
Rows are located among the displayed tree items, i.e. those whose parents are expanded. Tree items loading their children lazily are never forced to do so just to find a row. Rows added by this context are found even if they are not displayed yet.
Author:
harald
  • Constructor Details

    • FxTreeTableEditContext

      public FxTreeTableEditContext(FxTreeTableView<S> treeTable)
      Creates the edit context.
      Parameters:
      treeTable - the treetable view
  • Method Details

    • getTreeTable

      public FxTreeTableView<S> getTreeTable()
      Gets the treetable view.
      Returns:
      the treetable view
    • getConfiguration

      public TableConfiguration<S> getConfiguration()
      Description copied from interface: TableEditContext
      Gets the table configuration.
      Specified by:
      getConfiguration in interface TableEditContext<S>
      Returns:
      the configuration
    • getColumns

      public List<TableColumnConfiguration<S,?>> getColumns()
      Description copied from interface: TableEditContext
      Gets the visible columns in the order they are displayed.
      Specified by:
      getColumns in interface TableEditContext<S>
      Returns:
      the column configurations
    • getRowCount

      public int getRowCount()
      Description copied from interface: TableEditContext
      Gets the number of displayed rows.
      Specified by:
      getRowCount in interface TableEditContext<S>
      Returns:
      the number of rows
    • getRow

      public S getRow(int index)
      Description copied from interface: TableEditContext
      Gets a displayed row.
      Specified by:
      getRow in interface TableEditContext<S>
      Parameters:
      index - the row index
      Returns:
      the row object
    • addRow

      public void addRow(S row)
      Description copied from interface: TableEditContext
      Appends a row.
      In a sorted table, the row is displayed according to the sort order. In a treetable, the row is appended to the children of the root.
      Specified by:
      addRow in interface TableEditContext<S>
      Parameters:
      row - the row object
    • insertRowAfter

      public void insertRowAfter(S sibling, S row)
      Description copied from interface: TableEditContext
      Inserts a row after another row.
      In a sorted table, the row is displayed according to the sort order. In a treetable, the row becomes the next sibling.
      Specified by:
      insertRowAfter in interface TableEditContext<S>
      Parameters:
      sibling - the existing row
      row - the row object to insert
    • insertRowBefore

      public void insertRowBefore(S sibling, S row)
      Description copied from interface: TableEditContext
      Inserts a row before another row.
      In a sorted table, the row is displayed according to the sort order. In a treetable, the row becomes the previous sibling.
      Specified by:
      insertRowBefore in interface TableEditContext<S>
      Parameters:
      sibling - the existing row
      row - the row object to insert
    • removeRow

      public boolean removeRow(S row)
      Description copied from interface: TableEditContext
      Removes a row.
      In a treetable, the row is removed along with its children.
      Specified by:
      removeRow in interface TableEditContext<S>
      Parameters:
      row - the row object
      Returns:
      true if removed, false if there is no such row
    • getParent

      public S getParent(S row)
      Description copied from interface: TreeTableEditContext
      Gets the parent of a row.
      Specified by:
      getParent in interface TreeTableEditContext<S>
      Parameters:
      row - the row object
      Returns:
      the parent row object, null if the row is the root, a child of a hidden root, or not found
    • getChildren

      public List<S> getChildren(S row)
      Description copied from interface: TreeTableEditContext
      Gets the row's children.
      Tree items that load their children lazily will do so.
      Specified by:
      getChildren in interface TreeTableEditContext<S>
      Parameters:
      row - the row object, null for the root
      Returns:
      the row objects of the children, empty if none or the row is not found
    • addChild

      public void addChild(S parent, S row)
      Description copied from interface: TreeTableEditContext
      Appends a child to a row.
      The expansion state of the parent is not changed. However, editing a cell of the child expands its parents.
      Specified by:
      addChild in interface TreeTableEditContext<S>
      Parameters:
      parent - the row object of the parent, null for the root
      row - the row object to add
    • setExpanded

      public void setExpanded(S row, boolean expanded)
      Description copied from interface: TreeTableEditContext
      Expands or collapses a row.
      Specified by:
      setExpanded in interface TreeTableEditContext<S>
      Parameters:
      row - the row object
      expanded - true to expand, false to collapse
    • edit

      public void edit(TableCellRef<S> cell)
      Description copied from interface: TableEditContext
      Selects a cell and starts editing it.
      The row is scrolled into view if necessary. In a treetable, the parents of the row are expanded. Does nothing if the row is not displayed, for example, because it is hidden by a column filter.
      Specified by:
      edit in interface TableEditContext<S>
      Parameters:
      cell - the cell, null to do nothing
    • select

      public void select(TableCellRef<S> cell)
      Description copied from interface: TableEditContext
      Selects a cell.
      Does nothing if the row is not displayed.
      Specified by:
      select in interface TableEditContext<S>
      Parameters:
      cell - the cell, null to do nothing
    • refresh

      public void refresh()
      Description copied from interface: TableEditContext
      Refreshes the view to show the current values of the row objects.
      Invoked automatically after the methods of the TableEditHandler returned.
      Specified by:
      refresh in interface TableEditContext<S>
    • scrollTo

      protected void scrollTo(int index)
      Scrolls a row into view, unless it is already visible.
      Parameters:
      index - the row index
    • findTreeItem

      protected javafx.scene.control.TreeItem<S> findTreeItem(S row)
      Finds the tree item of a row.
      Parameters:
      row - the row object
      Returns:
      the tree item, null if not displayed and not added by this context
    • createTreeItem

      protected javafx.scene.control.TreeItem<S> createTreeItem(S row)
      Creates the tree item for a new row.
      Parameters:
      row - the row object
      Returns:
      the tree item