Class TablePopup<S>

java.lang.Object
org.tentackle.fx.rdc.table.TablePopup<S>
Type Parameters:
S - the table element type

public class TablePopup<S> extends Object
Table popup.
Provides a context menu with several handy features: a column chooser, auto-adjusting the column widths, printing, exporting all or the selected rows to a spreadsheet or XML file, and saving or loading the table preferences. For tree tables, the menu also provides items to expand and collapse the tree.
The popup can be used for tables and tree tables. It installs its menu as the context menu of the table and all its columns.
Author:
harald
  • Constructor Details

    • TablePopup

      public TablePopup(FxTableView<S> table, String preferencesSuffix, String title)
      Creates a table popup.
      Parameters:
      table - the table
      preferencesSuffix - the preferences suffix to load/save table preferences, null if from table config
      title - the title of the printed table, null if from table config
    • TablePopup

      public TablePopup(FxTreeTableView<S> treeTable, String preferencesSuffix, String title)
      Creates a table popup.
      Parameters:
      treeTable - the tree table
      preferencesSuffix - the preferences suffix to load/save table preferences, null if from table config
      title - the title of the printed table, null if from table config
  • Method Details

    • getTable

      public FxTableView<S> getTable()
      Gets the table.
      Returns:
      the table, null if tree table popup
    • getTreeTable

      public FxTreeTableView<S> getTreeTable()
      Gets the tree table.
      Returns:
      the tree table, null if table popup
    • getTitle

      public String getTitle()
      Gets the printed title.
      Returns:
      the title
    • setTitle

      public void setTitle(String title)
      Sets the printed title.
      Parameters:
      title - the title for printing
    • getPreferencesSuffix

      public String getPreferencesSuffix()
      Gets the table preferences suffix.
      Returns:
      the suffix, null if none
    • setPreferencesSuffix

      public void setPreferencesSuffix(String preferencesSuffix)
      Sets the table preferences suffix.
      Parameters:
      preferencesSuffix - the suffix
    • isColumnMenuEnabled

      public boolean isColumnMenuEnabled()
      Returns whether the column menu is enabled.
      Returns:
      true if column menu is enabled
    • setColumnMenuEnabled

      public void setColumnMenuEnabled(boolean columnMenuEnabled)
      Enables or disables the column menu.
      The column menu allows the user to show or hide columns.
      Parameters:
      columnMenuEnabled - true to enable column menu (default)
    • expandTreeTable

      public void expandTreeTable(javafx.scene.control.TreeItem<S> selectedItem)
      Recursively expands the items of the tree table.
      Parameters:
      selectedItem - the selected item to start, null for the whole tree table
    • collapseTreeTable

      public void collapseTreeTable(javafx.scene.control.TreeItem<S> selectedItem)
      Recursively collapses the items of the tree table.
      Parameters:
      selectedItem - the selected item to start, null for the whole tree table
    • createContextMenu

      public javafx.scene.control.ContextMenu createContextMenu()
      Creates the context menu.
      Returns:
      the context menu
    • autoWidth

      public void autoWidth()
      Resizes all columns to fit their content.
    • print

      public void print()
      Prints the table.
    • toSpreadsheet

      public void toSpreadsheet(boolean onlySelected)
      Opens a dialog to export the table to a spreadsheet file.
      The file is opened in the associated application afterward.
      Parameters:
      onlySelected - true if export only selected rows
    • toXml

      public void toXml(boolean onlySelected)
      Opens a dialog to export the table to an XML file.
      The file is opened in the associated application afterward.
      Parameters:
      onlySelected - true if export only selected rows
    • savePreferences

      public void savePreferences(boolean system)
      Saves the table preferences.
      Parameters:
      system - true if system scope, else user
    • savePreferences

      public void savePreferences()
      Saves the table preferences.
      System or user scope is determined from PersistedPreferencesFactory.
    • loadPreferences

      public void loadPreferences(boolean system)
      Loads the table preferences.
      Parameters:
      system - true if from system scope only, else try user first
    • loadPreferences

      public void loadPreferences()
      Loads the table preferences.
      System or user scope is determined from PersistedPreferencesFactory.