Class DBTableModel

All Implemented Interfaces:
DBTableFetcher, DBViewportFetcher, LayoutHintingModel, TableFormatProvider, AutoFilterModel, ConditionalFormattingModel, CsvExportable, ExtendableTableInterface, FilteredModel, ConditionalFormattingStrategy.ConditionalFormattingChangeListener, MultiModelTable, QuickFilterable, ReversibleModel, SortableModel, ToolTipGeneratingTableModel, UpdateListener, Workspace, Serializable, TableModel

Table model for displaying views of layered Deephaven tables.
See Also:
  • Field Details

    • LOG_REMOTE_OPERATOR_APPLY_LENGTH_PROPERTY

      public static final String LOG_REMOTE_OPERATOR_APPLY_LENGTH_PROPERTY
      Defines the name of the property that controls how long the RemoteOperatorApply toString value is allowed to be.
      See Also:
    • LOG_REMOTE_OPERATOR_APPLY_LENGTH

      public static final int LOG_REMOTE_OPERATOR_APPLY_LENGTH
      Indicates how long an output the RemoteOperatorApply toString function can produce. When set to a negative value, no length limit will be applied, though the QueryOperationPerformanceLog has a length limit of its own. When set to 0, the internal details of the RemoteOperatorApply will be omitted. When set to any positive value, the output will be capped at that length.
      ImplNote:
      This should not normally be needed, but in some cases (such as a client with a table with thousands of columns, allowing users to use the 'search' function to apply a filter to all the text columns at once), the RemoteOperatorApply full-detail value might become so long as to impact a client. Therefore, this mechanism is included to allow the full-detail value to be reduced or entirely excluded as needed.
    • PREFETCH_ATTRS

      public static final Collection<String> PREFETCH_ATTRS
  • Constructor Details

    • DBTableModel

      public DBTableModel(@NotNull com.fishlib.io.logger.Logger log, @NotNull String name, @NotNull Table baselineTable)
      Construct a new model.
      Parameters:
      log - The log
      name - The name
      baselineTable - The baseline table
    • DBTableModel

      public DBTableModel(@NotNull com.fishlib.io.logger.Logger log, @NotNull String name, @NotNull Table baselineTable, @NotNull Function<DBTableModel,FilterStrategyImpl> filterStrategyFactory)
      Construct a new model.
      Parameters:
      log - The log
      name - The name
      baselineTable - The baseline table
      filterStrategyFactory - A factory to create the filter strategy
  • Method Details

    • updateMaxTableRows

      public static void updateMaxTableRows()
      Update the maximum number of tables rows that can be displayed. Should be called after changing font or look-and-feel.
    • setColumnTypeEditable

      public static void setColumnTypeEditable(@NotNull Class columnType)
      When rendering a column of columnType; indicate that it is editable to the JTable.
      Parameters:
      columnType - the Class to make column's editable for
    • updateTelemetryInfo

      public DBTableModel updateTelemetryInfo(@Nullable TelemetryLogger.TelemetryInfo telemetryInfo)
    • updateTelemetryInfo

      public DBTableModel updateTelemetryInfo(@Nullable String tableName, long pqSerial, @Nullable QueryProcessorConnection qpc)
    • getTelemetryInfo

      @Nullable public TelemetryLogger.TelemetryInfo getTelemetryInfo()
    • isRemote

      public boolean isRemote()
      Indicates if the underlying Table for this model is remote.
      Returns:
      true if the Table is remote, false otherwise
    • addTableChangeListener

      public void addTableChangeListener(@NotNull DBTableModel.TableChangeListener listener)
      Adds a listener for changes to the underlying Table. Note that this will call listener immediately upon being added.
      Parameters:
      listener - the listener to add
    • removeTableChangeListener

      public void removeTableChangeListener(@NotNull DBTableModel.TableChangeListener listener)
      Removes a table change listener.
      Parameters:
      listener - the listener to remove
    • getBaselineTable

      public Table getBaselineTable()
      Gets the baseline table. This is the unmodified table prior to any apply operations.
      Returns:
      the baseline table.
    • getUnfilteredDataTable

      public Table getUnfilteredDataTable()
      Gets the unfiltered data table. This is the table for getting data prior to any filtering.
      Returns:
      the unfiltered data table
    • getDataTable

      public Table getDataTable()
      Gets the data table. This is the table for getting data after any filtering.
      Returns:
      the data table
    • getDisplayedTable

      public Table getDisplayedTable()
      Gets the displayed table. This is the table that will be displayed.
      Returns:
      the displayed table
    • getViewportTable

      public Table getViewportTable()
      Gets the viewport table. This is the table for viewport.
      Returns:
      the viewport table.
    • setClosed

      public void setClosed()
      Closes the table model and releases all table handles.
    • isClosed

      public boolean isClosed()
    • getWorkspaceInfo

      public org.jdom2.Element getWorkspaceInfo()
      Description copied from interface: Workspace
      Serialize the class into an element to be stored in the workspace
      Specified by:
      getWorkspaceInfo in interface Workspace
      Overrides:
      getWorkspaceInfo in class IrisTableModel
      Returns:
      An Element containing the data to persist.
    • setWorkspaceInfo

      public void setWorkspaceInfo(@NotNull org.jdom2.Element workspaceInfo)
      Description copied from interface: Workspace
      Restore the class to the state defined by the data persisted in workspaceInfo
      Specified by:
      setWorkspaceInfo in interface Workspace
      Overrides:
      setWorkspaceInfo in class IrisTableModel
      Parameters:
      workspaceInfo - An Element containing the persisted state.
    • getRowCount

      public int getRowCount()
      Specified by:
      getRowCount in interface TableModel
    • getRawSize

      public long getRawSize()
      Gets the raw size of the viewport table
      Returns:
      the raw size
    • isCellEditable

      public boolean isCellEditable(int rowIndex, int columnIndex)
      Specified by:
      isCellEditable in interface TableModel
      Overrides:
      isCellEditable in class AbstractTableModel
    • getValueAt

      public Object getValueAt(int rowIndex, int columnIndex)
      Specified by:
      getValueAt in interface TableModel
    • convertRowIndexToTableIndex

      public long convertRowIndexToTableIndex(Table table, int row)
      Convert an index in Swing space, to Deephaven Table space. While the indices passed to the DBTableModel may appear to be flat the underlying table may not be.
      Parameters:
      row - The row in Swing-model space.
      Returns:
      the equivalent index into the Deephaven viewport table
    • isStale

      public boolean isStale(int rowIndex, int columnIndex)
      Check if the specified cell is stale. Note that the indices are in SWING model space, and will be automatically converted to Deephaven table space.
      Overrides:
      isStale in class IrisTableModel
      Parameters:
      rowIndex - the row index
      columnIndex - the column index
      Returns:
      true if the cell is stale.
    • generateToolTip

      public ToolTipGeneratingTableModel.GeneratedToolTip generateToolTip(int columnIndex, @NotNull GuiColumn column)
      Specified by:
      generateToolTip in interface ToolTipGeneratingTableModel
    • hasShowStatistics

      public boolean hasShowStatistics()
      Specified by:
      hasShowStatistics in interface ToolTipGeneratingTableModel
    • showStatistics

      public void showStatistics(@NotNull JTable table, int columnIndex, @NotNull GuiColumn column)
      Specified by:
      showStatistics in interface ToolTipGeneratingTableModel
    • setToolTipDialog

      public void setToolTipDialog(int col, @NotNull GuiColumn column, @NotNull JDialog dialog, @NotNull JLabel label)
      Specified by:
      setToolTipDialog in interface ToolTipGeneratingTableModel
    • getModel

      public <MODEL_TYPE extends TableModel> MODEL_TYPE getModel(@NotNull Class<MODEL_TYPE> modelTypeClass)
      Description copied from interface: MultiModelTable
      return a model of type modelType, or null if none
      Specified by:
      getModel in interface MultiModelTable
    • getModel

      public TableModel getModel()
      Description copied from interface: MultiModelTable
      return the single child model, or null if none
      Specified by:
      getModel in interface MultiModelTable
    • getOriginalRowIndices

      public int[] getOriginalRowIndices(@NotNull int[] selectedRows)
      Specified by:
      getOriginalRowIndices in interface MultiModelTable
    • getOriginalRowIndices

      public int[] getOriginalRowIndices(@NotNull int[] selectedRows, boolean sorted)
      Specified by:
      getOriginalRowIndices in interface MultiModelTable
    • getOriginalModel

      public TableModel getOriginalModel()
      Specified by:
      getOriginalModel in interface MultiModelTable
    • getTable

      @Deprecated public Table getTable()
      Deprecated.
      Specified by:
      getTable in interface DBTableFetcher
    • getDbViewportTable

      @Deprecated public Table getDbViewportTable()
      Deprecated.
      Specified by:
      getDbViewportTable in interface DBViewportFetcher
    • exportToCsv

      public void exportToCsv(Container ref, File f, com.fishlib.base.Procedure.Unary<File> openOrCopyFile) throws IOException
      Specified by:
      exportToCsv in interface CsvExportable
      Throws:
      IOException
    • getTableForSelection

      public Table getTableForSelection(@NotNull JTable jTable)
      Get a table containing only selected values as determined by the selection model.
      Parameters:
      jTable - The table to find selected items in
      Returns:
      A table containing only the rows selected by the model.
    • getTableForSelection

      public Table getTableForSelection(@NotNull JTable jTable, boolean stripPreview)
      Get a table containing only selected values as determined by the selection model.
      Parameters:
      jTable - The table to find selected items in
      stripPreview - Remove preview application, so that the raw data from the table is returned (e.g., double[] not the preview of the double[]).
      Returns:
      A table containing only the rows selected by the model.
    • getTableForSelection

      public Table getTableForSelection(@NotNull JTable jTable, @NotNull BitSet includedColumnIndexes)
      Get a table containing only selected values as determined by the selection model. The resultant table will only contain the columns defined by columns
      Parameters:
      jTable - The table to find selected items in
      includedColumnIndexes - The columns to include in the new table.
      Returns:
      A table containing only the rows selected by the model.
    • getTableForSelection

      public Table getTableForSelection(@NotNull int[] selectedRowIndexes, @NotNull BitSet includedColumnIndexes)
      Get a table containing only values as determined by the identified array of selected rows. The resultant table will only contain the columns defined by columns
      Parameters:
      selectedRowIndexes - The properly indexed rows from the original to include in the new table
      includedColumnIndexes - The columns to include in the new table.
      Returns:
      A table containing only the rows selected by the model.
    • getTableForSelection

      public Table getTableForSelection(@NotNull JTable jTable, @NotNull BitSet includedColumnIndexes, boolean stripPreview)
      Get a table containing only selected values as determined by the selection model. The resultant table will only contain the columns defined by columns
      Parameters:
      jTable - The table to find selected items in
      includedColumnIndexes - The columns to include in the new table.
      stripPreview - Remove preview application, so that the raw data from the table is returned (e.g., double[] not the preview of the double[]).
      Returns:
      A table containing only the rows selected by the model.
    • getTableForSelection

      public Table getTableForSelection(@NotNull int[] selectedRowIndexes, @NotNull BitSet includedColumnIndexes, boolean stripPreview)
      Get a table containing only values as determined by the identified array of selected rows. The resultant table will only contain the columns defined by columns
      Parameters:
      selectedRowIndexes - The properly indexed rows from the original to include in the new table
      includedColumnIndexes - The columns to include in the new table.
      stripPreview - Remove preview application, so that the raw data from the table is returned (e.g., double[] not the preview of the double[]).
      Returns:
      A table containing only the rows selected by the model.
    • getEstimatedSelectedItemCount

      public int getEstimatedSelectedItemCount(@NotNull JTable jTable)
      Get the estimated number of selected rows for this table.
    • getColumnColor

      public long getColumnColor(@NotNull String columnName, int row)
      Specified by:
      getColumnColor in interface TableFormatProvider
    • getRowColor

      public long getRowColor(int row)
      Specified by:
      getRowColor in interface TableFormatProvider
    • getCellFormat

      public String getCellFormat(@NotNull String columnName, int row, @NotNull TableFormatProvider.FormatType type)
      Specified by:
      getCellFormat in interface TableFormatProvider
    • hasColumnColor

      public boolean hasColumnColor(@NotNull String columnName)
      Specified by:
      hasColumnColor in interface TableFormatProvider
    • hasRowColor

      public boolean hasRowColor(@NotNull String columnName)
      Specified by:
      hasRowColor in interface TableFormatProvider
    • hasCellFormat

      public boolean hasCellFormat(@NotNull String columnName, @NotNull TableFormatProvider.FormatType type)
      Specified by:
      hasCellFormat in interface TableFormatProvider
    • wasColumnColorChanged

      public boolean wasColumnColorChanged(String columnName)
      Specified by:
      wasColumnColorChanged in interface TableFormatProvider
    • markColumnColorUnchanged

      public void markColumnColorUnchanged(String columnName)
      Specified by:
      markColumnColorUnchanged in interface TableFormatProvider
    • getLayoutHints

      public LayoutHintBuilder getLayoutHints()
      Specified by:
      getLayoutHints in interface LayoutHintingModel
      Returns:
      A LayoutHintBuilder defining the layout hints for this model, or null if none were present.
    • setSavedRollup

      public void setSavedRollup(SavedRollup rollup)
      Sets the rollup info created by a UI rollup.
      Parameters:
      rollup - the info for rolling up this model
    • getSavedRollup

      public SavedRollup getSavedRollup()
      Gets the info for performing a rollup on this model. This will be null if the model has never been rollup up.
      Returns:
      the rollup model, null if there is none
    • isBaselineSubsetOfOtherBaseline

      public boolean isBaselineSubsetOfOtherBaseline(@NotNull DBTableModel other)
      Figure out whether the baseline table columns in this DBTableModel are all present in another DBTableModel's baseline table.
      Parameters:
      other - The other DBTableModel
      Returns:
      true if all columns in this model's baseline table are present in the other model's data table with the same data type
    • supportsColumnChange

      public boolean supportsColumnChange()
      Description copied from interface: ExtendableTableInterface
      Determine whether this instance supports column change. Some subclasses support this in all cases, others only sometimes.
      Specified by:
      supportsColumnChange in interface ExtendableTableInterface
      Returns:
      true if it is valid to call addColumns
    • beginAddColumns

      public ExtendableTableInterface.PartialResult beginAddColumns(@NotNull List<ExtendableTableInterface.Entry> columnDefinitions)
      Description copied from interface: ExtendableTableInterface
      Begin the process of setting extended columns. This will create and return a new DBTable via updateView, with new columns. Implementations must not touch Swing components, and callers must not invoke this on the Swing event thread.
      Specified by:
      beginAddColumns in interface ExtendableTableInterface
      Parameters:
      columnDefinitions - list of column name/definition entries to add
      Returns:
      PartialResult containing intermediate results to be passed to finishAddColumns
    • setFinishedCallback

      public void setFinishedCallback(Runnable finishedCallback)
      Description copied from interface: ExtendableTableInterface
      set a callback to be called on the swing thread sometime after finishAddColumns
      Specified by:
      setFinishedCallback in interface ExtendableTableInterface
      Parameters:
      finishedCallback - Runnable to be called after finishAddColumns
    • popFinishedCallback

      public Runnable popFinishedCallback()
      Description copied from interface: ExtendableTableInterface
      get the current callback value. set the callback to null
      Specified by:
      popFinishedCallback in interface ExtendableTableInterface
      Returns:
      current callback, if any
    • finishAddColumns

      public void finishAddColumns(@NotNull ExtendableTableInterface.PartialResult partialResult)
      Description copied from interface: ExtendableTableInterface
      Incorporate the new DBTable and columns into tables and models. This must not be called on the Swing event thread.
      Specified by:
      finishAddColumns in interface ExtendableTableInterface
      Parameters:
      partialResult - intermediate results from beginAddColumns
    • getExtendedColumns

      public List<ExtendableTableInterface.Entry> getExtendedColumns()
      Description copied from interface: ExtendableTableInterface
      get all extended columns and definitions
      Specified by:
      getExtendedColumns in interface ExtendableTableInterface
      Returns:
      list of name/definition pairs.
    • filterChanged

      public void filterChanged()
      Description copied from interface: FilteredModel
      Notify the implementation that the set of underlying filters have changed.
      Specified by:
      filterChanged in interface FilteredModel
    • getFilterStrategy

      @NotNull public FilterStrategyImpl getFilterStrategy()
      Description copied from interface: FilteredModel
      Get the FilterStrategyImpl in use.
      Specified by:
      getFilterStrategy in interface AutoFilterModel
      Specified by:
      getFilterStrategy in interface FilteredModel
      Returns:
      the FilterStrategy
    • saveStrategy

      public void saveStrategy(@NotNull String name)
      Description copied from interface: FilteredModel
      Save the current set of filters to the global set of filters by name.
      Specified by:
      saveStrategy in interface FilteredModel
      Parameters:
      name - the name of the filter
    • getSavedStrategies

      @NotNull public org.jdom2.Element[] getSavedStrategies()
      Description copied from interface: FilteredModel
      Get all of the saved strategy workspace Elements
      Specified by:
      getSavedStrategies in interface FilteredModel
      Returns:
      an array of saved filter strategy elements.
    • removeStrategy

      public void removeStrategy(@NotNull String name)
      Description copied from interface: FilteredModel
      Remove the globally saved filter of the specified name.
      Specified by:
      removeStrategy in interface FilteredModel
      Parameters:
      name - the name of the filter to remove
    • isFilteringOn

      public boolean isFilteringOn()
      Description copied from interface: FilteredModel
      Check if the model is currently being filtered.
      Specified by:
      isFilteringOn in interface FilteredModel
      Returns:
      true if filters are currently applied
    • isFilterable

      public boolean isFilterable(String column)
      Description copied from interface: FilteredModel
      Check if the specified column is filterable.
      Specified by:
      isFilterable in interface AutoFilterModel
      Specified by:
      isFilterable in interface FilteredModel
      Parameters:
      column - the column name.
      Returns:
      true if the column is filterable.
    • setQuickFilter

      public void setQuickFilter(String filter, QuickFilterMode mode)
      Description copied from interface: QuickFilterable
      Set the quick filter to apply.
      Specified by:
      setQuickFilter in interface QuickFilterable
      Parameters:
      filter - the filter text
      mode - the QuickFilterMode to apply with
    • getQuickFilter

      public String getQuickFilter()
      Description copied from interface: QuickFilterable
      Get the current quick filter string
      Specified by:
      getQuickFilter in interface QuickFilterable
      Returns:
      the current filter
    • getQuickFilterMode

      public QuickFilterMode getQuickFilterMode()
      Description copied from interface: QuickFilterable
      Get the current quick filter mode.
      Specified by:
      getQuickFilterMode in interface QuickFilterable
      Returns:
      the quickfilter mode
    • requestAutoFilterData

      public AutoFilterModel.AutoFilterRequestHandler requestAutoFilterData(@NotNull String columnName, int maxUniqueValues, @NotNull AutoFilterModel.AutoFilterListener listener)
      Description copied from interface: AutoFilterModel
      Requests auto filter data for a given column name.
      Specified by:
      requestAutoFilterData in interface AutoFilterModel
      Parameters:
      columnName - the name of the column
      maxUniqueValues - the maximum number of unique values to return
      listener - a listener for the data
      Returns:
      a handler for the request
    • requestMoreAutoFilterData

      public AutoFilterModel.AutoFilterRequestHandler requestMoreAutoFilterData(@NotNull String columnName, @NotNull AutoFilterModel.AutoFilterListener listener)
      Description copied from interface: AutoFilterModel
      Requests more data for the given column.
      Specified by:
      requestMoreAutoFilterData in interface AutoFilterModel
      Parameters:
      columnName - the name of the column
      listener - a listener for the data
      Returns:
      a handler for the request
    • getInitialFetchSize

      public int getInitialFetchSize(String column)
      Description copied from interface: AutoFilterModel
      Get the number of unique values to initially fetch for the specified column.
      Specified by:
      getInitialFetchSize in interface AutoFilterModel
      Parameters:
      column - The column to get the fetch size for
      Returns:
      The number of unique values to fetch
    • reverse

      public void reverse(ReversibleModel.ReverseType type)
      Description copied from interface: ReversibleModel

      Set the type of reversal operation to perform.

      Specified by:
      reverse in interface ReversibleModel
    • getReverseType

      public ReversibleModel.ReverseType getReverseType()
      Specified by:
      getReverseType in interface ReversibleModel
      Returns:
      The current table reversal mode.
    • headerClicked

      public void headerClicked(MouseEvent e)
      Description copied from interface: SortableModel
      Called when sorting should be changed based on a header click.
      Specified by:
      headerClicked in interface SortableModel
      Parameters:
      e - the driving MouseEvent
    • getHeaderRendererIcon

      public Icon getHeaderRendererIcon(int columnIndex, int size)
      Description copied from interface: SortableModel
      Get the sort icon for the specified column and size. May return null, for no icon.
      Specified by:
      getHeaderRendererIcon in interface SortableModel
      Parameters:
      columnIndex - the column
      size - the icon size
      Returns:
      an icon to render for sorting.
    • cancelSorting

      public void cancelSorting()
      Description copied from interface: SortableModel
      Clear sorting on all columns.
      Specified by:
      cancelSorting in interface SortableModel
    • setSortingStatus

      public void setSortingStatus(int columnIndex, int status, boolean isAbsolute, boolean clearSorting)
      Description copied from interface: SortableModel
      Set the sorting status of a single column. Adds to existing sort definition.
      Specified by:
      setSortingStatus in interface SortableModel
    • getSortingDirective

      @NotNull public SortableModel.SortingDirective getSortingDirective(int columnIndex)
      Description copied from interface: SortableModel
      Get the sorting status of a single column.
      Specified by:
      getSortingDirective in interface SortableModel
    • isSorting

      public boolean isSorting()
      Description copied from interface: SortableModel
      determine whether there are any sorting directives - similar to empty()
      Specified by:
      isSorting in interface SortableModel
    • getSortableColumns

      @NotNull public Set<String> getSortableColumns()
      Description copied from interface: SortableModel
      Get the set of sortable columns.
      Specified by:
      getSortableColumns in interface SortableModel
      Overrides:
      getSortableColumns in class IrisTableModel
      Returns:
      the set of sortable columns
    • saveConditionalFormattingStrategy

      public void saveConditionalFormattingStrategy(String name)
      Specified by:
      saveConditionalFormattingStrategy in interface ConditionalFormattingModel
    • getSavedConditionalFormattingStrategies

      public org.jdom2.Element[] getSavedConditionalFormattingStrategies()
      Specified by:
      getSavedConditionalFormattingStrategies in interface ConditionalFormattingModel
    • removeConditionalFormattingStrategy

      public void removeConditionalFormattingStrategy(String name)
      Specified by:
      removeConditionalFormattingStrategy in interface ConditionalFormattingModel
    • getConditionalFormattingStrategy

      public ConditionalFormattingStrategy getConditionalFormattingStrategy()
      Specified by:
      getConditionalFormattingStrategy in interface ConditionalFormattingModel
    • onFormattingChanged

      public void onFormattingChanged()
      Specified by:
      onFormattingChanged in interface ConditionalFormattingStrategy.ConditionalFormattingChangeListener
    • onFormattingChanged

      public void onFormattingChanged(String columnName)
      Specified by:
      onFormattingChanged in interface ConditionalFormattingStrategy.ConditionalFormattingChangeListener
    • setBaselineTable

      public void setBaselineTable(@NotNull Table baselineTable)
      Change the baseline table for this model, and recompute accordingly. It is expected that the new baseline table has the same structure as the original.
      Parameters:
      baselineTable - The new baseline table
    • clearBaselineTable

      public void clearBaselineTable()
      Change the baseline table for this model to an empty table with the same schema, and recompute accordingly.
    • doneProcessing

      protected void doneProcessing()
      Overrides:
      doneProcessing in class BaseDBTableModel
    • saveRollup

      public void saveRollup(com.illumon.iris.treetable.RollupDefinition def, org.jdom2.Element workspaceInfo)
      Save the specified rollup to the workspace.
      Parameters:
      def - the rollup to save
      workspaceInfo -
    • deleteRollup

      public void deleteRollup(String name)
      Delete the saved rollup.
      Parameters:
      name - the workspace to delete.
    • getSavedRollups

      public List<SavedRollup> getSavedRollups()
      Get list of all saved rollups for this model.
      Returns:
      an list of saved rollups