Package snap.view

Class TableView<T>

All Implemented Interfaces:
PropChange.DoChange, Selectable<T>, XMLArchiver.Archivable

public class TableView<T> extends ParentView implements Selectable<T>
A View subclass to show a table of items.
  • Field Details

  • Constructor Details

    • TableView

      public TableView()
      Creates a new TableView.
  • Method Details

    • getScrollGroup

      public ScrollGroup getScrollGroup()
      Returns the ScrollGroup.
    • getScrollView

      public ScrollView getScrollView()
      Returns the ScrollView.
    • getItemsList

      public List<T> getItemsList()
      Returns the items.
      Specified by:
      getItemsList in interface Selectable<T>
    • setItemsList

      public void setItemsList(List<T> theItems)
      Sets the items.
      Specified by:
      setItemsList in interface Selectable<T>
    • setItems

      public void setItems(T[] theItems)
      Sets the items.
      Specified by:
      setItems in interface Selectable<T>
    • isMultiSel

      public boolean isMultiSel()
      Returns whether list allows multiple selections.
    • setMultiSel

      public void setMultiSel(boolean aValue)
      Sets whether list allows multiple selections.
    • getSel

      public ListSel getSel()
      Returns the selection.
    • setSel

      public void setSel(ListSel aSel)
      Sets the table selection.
    • getSel2D

      public ListSel2D getSel2D()
      Returns the selection.
    • setSel2D

      public void setSel2D(ListSel2D aSel)
      Sets the table selection.
    • getSelIndex

      public int getSelIndex()
      Returns the selected index.
      Specified by:
      getSelIndex in interface Selectable<T>
    • setSelIndex

      public void setSelIndex(int anIndex)
      Sets the selected index.
      Specified by:
      setSelIndex in interface Selectable<T>
    • getSelRowIndex

      public int getSelRowIndex()
      Returns the selected row.
    • getSelColIndex

      public int getSelColIndex()
      Returns the selected column.
    • setSelRowColIndex

      public void setSelRowColIndex(int aRow, int aCol)
      Returns the selected cell.
    • getSelCell

      public ListCell<T> getSelCell()
      Returns the selected cell.
    • getSelItem

      public T getSelItem()
      Returns the selected item.
      Specified by:
      getSelItem in interface Selectable<T>
    • setSelItem

      public void setSelItem(T anItem)
      Sets the selected index.
      Specified by:
      setSelItem in interface Selectable<T>
    • selectUp

      public void selectUp()
      Selects up in the table.
    • selectDown

      public void selectDown()
      Selects down in the table.
    • selectRight

      public void selectRight()
      Selects right in the table.
    • selectLeft

      public void selectLeft()
      Selects right in the table.
    • pickListPropChange

      protected void pickListPropChange(PropChange aPC)
      Called when PickList changes selection.
    • updateItem

      public void updateItem(T anItem)
      Tell table to update given item.
    • updateItems

      public void updateItems()
      Tell table to update visible items.
    • updateItems

      public void updateItems(T[] theItems)
      Tell table to update given items.
    • getColCount

      public int getColCount()
      Returns the number of columns.
    • getCol

      public TableCol<T> getCol(int anIndex)
      Returns the column at given index.
    • getCols

      public TableCol<T>[] getCols()
      Returns the column at given index.
    • addCol

      public void addCol(TableCol<T> aCol)
      Adds a TableCol.
    • removeCol

      public TableCol<T> removeCol(int anIndex)
      Remove's the TableCol at the given index from this Table's children list.
    • removeCol

      public int removeCol(TableCol<T> aCol)
      Removes the given TableCol from this table's children list.
    • getRowCount

      public int getRowCount()
      Returns the number of rows.
    • isShowHeader

      public boolean isShowHeader()
      Returns whether to show header.
    • setShowHeader

      public void setShowHeader(boolean aValue)
      Sets whether to show header.
    • getHeaderView

      public SplitView getHeaderView()
      Returns the HeaderView.
    • isShowHeaderCol

      public boolean isShowHeaderCol()
      Returns whether to show header.
    • setShowHeaderCol

      public void setShowHeaderCol(boolean aValue)
      Sets whether to show header.
    • getHeaderCol

      public TableCol<T> getHeaderCol()
      Returns the header col.
    • isShowGridX

      public boolean isShowGridX()
      Returns whether to show horizontal grid lines.
    • setShowGridX

      public void setShowGridX(boolean aValue)
      Sets whether to show horizontal grid lines.
    • isShowGridY

      public boolean isShowGridY()
      Returns whether to show vertical grid lines.
    • setShowGridY

      public void setShowGridY(boolean aValue)
      Sets whether to show vertical grid lines.
    • getGridColor

      public Color getGridColor()
      Returns grid color.
    • setGridColor

      public void setGridColor(Color aValue)
      Sets grid color.
    • isRowHeightSet

      public boolean isRowHeightSet()
      Returns whether row height has been explicitly set.
    • getRowHeight

      public double getRowHeight()
      Returns the row height.
    • setRowHeight

      public void setRowHeight(double aValue)
      Sets the row height.
    • getCellPadding

      public Insets getCellPadding()
      Returns the cell padding.
    • setCellPadding

      public void setCellPadding(Insets aPad)
      Sets the cell padding.
    • getCellConfigure

      public Consumer<ListCell<T>> getCellConfigure()
      Called to set method to configure cell for rendering.
    • setCellConfigure

      public void setCellConfigure(Consumer<ListCell<T>> aCC)
      Called to set method to configure cell for rendering.
    • getCell

      public ListCell<T> getCell(int aRow, int aCol)
      Returns the cell at given row and col.
    • getColIndexForX

      public int getColIndexForX(double aX)
      Returns the col index for given X.
    • getRowIndexForY

      public int getRowIndexForY(double aY)
      Returns the row index for given Y.
    • getColForX

      public TableCol<T> getColForX(double aX)
      Returns the column at given X coord.
    • getCellForXY

      public ListCell<T> getCellForXY(double aX, double aY)
      Returns the cell at given Y coord.
    • getPrefWidthImpl

      protected double getPrefWidthImpl(double aH)
      Returns the preferred width.
      Overrides:
      getPrefWidthImpl in class View
    • getPrefHeightImpl

      protected double getPrefHeightImpl(double aW)
      Returns the preferred height.
      Overrides:
      getPrefHeightImpl in class View
    • layoutImpl

      protected void layoutImpl()
      Override to layout children with VBox layout.
      Overrides:
      layoutImpl in class ParentView
    • processEvent

      protected void processEvent(ViewEvent anEvent)
      Handle events.
      Overrides:
      processEvent in class View
    • processEventFilters

      protected void processEventFilters(ViewEvent anEvent)
      Override to catch KeyPress (tab or enter) for TableView or cells (when editing).
      Overrides:
      processEventFilters in class View
    • paintAbove

      protected void paintAbove(Painter aPntr)
      Override to paint highlight for selected cell.
      Overrides:
      paintAbove in class ParentView
    • getSelRectImage

      protected ImageBox getSelRectImage(Rect aRect)
      A fuzzy cell border image to highlight cell.
    • isEditable

      public boolean isEditable()
      Returns whether table cells are editable.
    • setEditable

      public void setEditable(boolean aValue)
      Sets whether table cells are editable.
    • getEditingCell

      public ListCell<T> getEditingCell()
      Returns the cell currently editing.
    • setEditingCell

      protected void setEditingCell(ListCell<T> aCell)
      Sets the cell currently editing.
    • editCell

      public void editCell(ListCell aCell)
      Called to edit given cell.
    • editCellStop

      public void editCellStop()
      Called to stop editing a cell.
    • cellEditingChanged

      protected void cellEditingChanged(ListCell<T> aCell)
      Called when cell editing starts.
    • setHeight

      public void setHeight(double aValue)
      Override to reset cells.
      Overrides:
      setHeight in class View
    • getFocusNext

      public View getFocusNext()
      Override to forward to table.
      Overrides:
      getFocusNext in class View
    • getFocusPrev

      public View getFocusPrev()
      Override to forward to table.
      Overrides:
      getFocusPrev in class View
    • setFocused

      protected void setFocused(boolean aValue)
      Override to clear focus image.
      Overrides:
      setFocused in class View
    • getValuePropName

      public String getValuePropName()
      Returns a mapped property name.
      Overrides:
      getValuePropName in class View
    • getDefaultBorder

      public Border getDefaultBorder()
      Returns the default border.
      Overrides:
      getDefaultBorder in class View
    • toXMLView

      public XMLElement toXMLView(XMLArchiver anArchiver)
      XML archival.
      Overrides:
      toXMLView in class ParentView
    • fromXMLView

      public void fromXMLView(XMLArchiver anArchiver, XMLElement anElement)
      XML unarchival.
      Overrides:
      fromXMLView in class ParentView
    • toXMLChildren

      protected void toXMLChildren(XMLArchiver anArchiver, XMLElement anElement)
      XML archival of children.
      Overrides:
      toXMLChildren in class ParentView
    • fromXMLChildren

      protected void fromXMLChildren(XMLArchiver anArchiver, XMLElement anElement)
      XML unarchival for shape children.
      Overrides:
      fromXMLChildren in class ParentView