Class EntityTablePanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class EntityTablePanel extends JPanel
The EntityTablePanel is a UI class based on the EntityTableModel class. It consists of a JTable as well as filtering/searching and summary panels. The default layout is as follows
  ____________________________________________________
 |                conditionPanel                      |
 |____________________________________________________|
 |                                                    |
 |                                                    |
 |                                                    |
 |                                                    |
 |                entityTable (FilteredTable)         |
 |                                                    |
 |                                                    |
 |                                                    |
 |                                                    |
 |____________________________________________________|
 |                summaryPanel                        |
 |____________________________________________________|
 |                southPanel                          |
 |____________________________________________________|
 
The condition and summary panels can be hidden Note that initialize() must be called to initialize this panel before displaying it.
See Also:
  • Field Details

    • CONDITION_PANEL_VISIBLE

      public static final PropertyValue<Boolean> CONDITION_PANEL_VISIBLE
      Specifies whether table condition panels should be visible or not by default
      Value type: Boolean
      Default value: false
    • FILTER_PANEL_VISIBLE

      public static final PropertyValue<Boolean> FILTER_PANEL_VISIBLE
      Specifies whether table filter panels should be visible or not by default
      Value type: Boolean
      Default value: false
    • INCLUDE_ENTITY_MENU

      public static final PropertyValue<Boolean> INCLUDE_ENTITY_MENU
      Specifies whether to include a EntityPopupMenu on this table, triggered with CTRL-ALT-V.
      Value type: Boolean
      Default value: true
    • INCLUDE_CLEAR_CONTROL

      public static final PropertyValue<Boolean> INCLUDE_CLEAR_CONTROL
      Specifies whether to include a 'Clear' control in the popup menu.
      Value type: Boolean
      Default value: false
    • INCLUDE_CONDITION_PANEL

      public static final PropertyValue<Boolean> INCLUDE_CONDITION_PANEL
      Specifies whether to include a condition panel.
      Value type: Boolean
      Default value: true
    • INCLUDE_FILTER_PANEL

      public static final PropertyValue<Boolean> INCLUDE_FILTER_PANEL
      Specifies whether to include a filter panel.
      Value type: Boolean
      Default value: true
    • INCLUDE_LIMIT_MENU

      public static final PropertyValue<Boolean> INCLUDE_LIMIT_MENU
      Specifies whether to include a popup menu for configuring the table model limit.
      Value type: Boolean
      Default value: false
    • SHOW_REFRESH_PROGRESS_BAR

      public static final PropertyValue<Boolean> SHOW_REFRESH_PROGRESS_BAR
      Specifies whether to show an indeterminate progress bar while the model is refreshing.
      Value type: Boolean
      Default value: false
    • REFRESH_BUTTON_VISIBLE

      public static final PropertyValue<EntityTablePanel.RefreshButtonVisible> REFRESH_BUTTON_VISIBLE
      Specifies whether the refresh button should always be visible or only when the condition panel is visible
      Value type: Boolean
      Default value: EntityTablePanel.RefreshButtonVisible.WHEN_CONDITION_PANEL_IS_VISIBLE
    • COLUMN_SELECTION

      public static final PropertyValue<EntityTablePanel.ColumnSelection> COLUMN_SELECTION
      Specifies how column selection is presented to the user.
      Value type: EntityTablePanel.ColumnSelection
      Default value: EntityTablePanel.ColumnSelection.DIALOG
    • KEYBOARD_SHORTCUTS

      public static final KeyboardShortcuts<EntityTablePanel.KeyboardShortcut> KEYBOARD_SHORTCUTS
      The default keyboard shortcut keyStrokes.
  • Constructor Details

    • EntityTablePanel

      public EntityTablePanel(SwingEntityTableModel tableModel)
      Initializes a new EntityTablePanel instance
      Parameters:
      tableModel - the SwingEntityTableModel instance
    • EntityTablePanel

      public EntityTablePanel(SwingEntityTableModel tableModel, EntityConditionPanelFactory conditionPanelFactory)
      Initializes a new EntityTablePanel instance
      Parameters:
      tableModel - the SwingEntityTableModel instance
      conditionPanelFactory - the condition panel factory, if any
  • Method Details

    • table

      public final FilteredTable<Entity,Attribute<?>> table()
      Returns:
      the table
    • tableModel

      public final <T extends SwingEntityTableModel> T tableModel()
      Type Parameters:
      T - the table model type
      Returns:
      the EntityTableModel used by this EntityTablePanel
    • conditionPanel

      public final FilteredTableConditionPanel<Attribute<?>> conditionPanel()
      Returns:
      the condition panel
      Throws:
      IllegalStateException - in case no condition panel is available
    • configure

      public final EntityTablePanel.Settings configure()
      Provides a way to configure settings before the panel is initialized.
      Returns:
      the EntityTablePanel.Settings instance
      Throws:
      IllegalStateException - in case the panel has already been initialized
    • refreshButtonVisible

      public final Value<EntityTablePanel.RefreshButtonVisible> refreshButtonVisible()
      Returns:
      the Value controlling the refresh button visible setting
    • conditionPanelVisible

      public final State conditionPanelVisible()
      Returns:
      the state controlling whether the condition panel is visible
    • filterPanelVisible

      public final State filterPanelVisible()
      Returns:
      the state controlling whether the filter panel is visible
    • summaryPanelVisible

      public final State summaryPanelVisible()
      Returns:
      the state controlling whether the summary panel is visible
    • showRefreshProgressBar

      public final State showRefreshProgressBar()
      Returns:
      the state controlling whether an indeterminate progress bar should be shown while the model is refreshing
      See Also:
    • statusMessage

      public final Value<Function<SwingEntityTableModel,String>> statusMessage()
      Returns:
      the value containing the function for creating the table status message
      See Also:
    • setEditComponentFactory

      public final <T, A extends Attribute<T>, C extends JComponent> void setEditComponentFactory(A attribute, EntityComponentFactory<T,A,C> componentFactory)
      Sets the component factory for the given attribute, used when editing entities via editSelectedEntities(Attribute).
      Type Parameters:
      T - the value type
      A - the attribute type
      C - the component type
      Parameters:
      attribute - the attribute
      componentFactory - the component factory
    • setTableCellEditorFactory

      public final <T, A extends Attribute<T>, C extends JComponent> void setTableCellEditorFactory(A attribute, EntityComponentFactory<T,A,C> componentFactory)
      Sets the table cell editor component factory for the given attribute.
      Type Parameters:
      T - the value type
      A - the attribute type
      C - the component type
      Parameters:
      attribute - the attribute
      componentFactory - the component factory
    • toggleConditionPanel

      public final void toggleConditionPanel()
      Toggles the condition panel through the states hidden, visible and advanced
    • toggleFilterPanel

      public final void toggleFilterPanel()
      Toggles the filter panel through the states hidden, visible and advanced
    • selectConditionPanel

      public final void selectConditionPanel()
      Allows the user to select one of the available search condition panels
    • selectFilterPanel

      public final void selectFilterPanel()
      Allows the user to select one of the available filter condition panels
    • setReferentialIntegrityErrorHandling

      public final void setReferentialIntegrityErrorHandling(ReferentialIntegrityErrorHandling referentialIntegrityErrorHandling)
      Parameters:
      referentialIntegrityErrorHandling - the action to take on a referential integrity error during delete
    • deleteConfirmer

      public final Value<EntityEditPanel.Confirmer> deleteConfirmer()
      If set to null the default delete confirmer is used.
      Returns:
      the Value controlling the delete confirmer
    • toString

      public final String toString()
      Overrides:
      toString in class Component
    • control

      public final Value<Control> control(EntityTablePanel.TableControl tableControl)
      Returns a Value containing the control associated with controlCode, an empty Value if no such control is available. Note that standard controls are populated during initialization, so until then, these values may be empty.
      Parameters:
      tableControl - the table control code
      Returns:
      the Value containing the control associated with controlCode
    • editSelectedEntities

      public final <T> void editSelectedEntities(Attribute<T> attributeToEdit)
      Retrieves a new value via input dialog and performs an update on the selected entities assigning the value to the attribute
      Type Parameters:
      T - the attribute value type
      Parameters:
      attributeToEdit - the attribute which value to edit
      See Also:
    • viewDependencies

      public final void viewDependencies()
      Displays a dialog containing tables of entities depending on the selected entities via non-soft foreign keys
    • deleteWithConfirmation

      public final boolean deleteWithConfirmation()
      Deletes the entities selected in the underlying table model after asking for confirmation using the EntityEditPanel.Confirmer set via deleteConfirmer().
      Returns:
      true if the delete operation was successful
      See Also:
    • delete

      public final boolean delete()
      Deletes the entities selected in the underlying table model without asking for confirmation.
      Returns:
      true if the delete operation was successful
      See Also:
    • printTable

      public final void printTable() throws PrinterException
      Prints the table
      Throws:
      PrinterException - in case of a print exception
      See Also:
    • initialize

      public final EntityTablePanel initialize()
      Initializes the UI, while presenting a wait cursor to the user. Note that calling this method more than once has no effect.
      Returns:
      this EntityTablePanel instance
    • setupControls

      protected void setupControls()
      Override to setup any custom controls. This default implementation is empty. This method is called after all standard controls have been initialized.
      See Also:
    • initializeSouthPanel

      protected JPanel initializeSouthPanel()
      Initializes the south panel, override and return null for no south panel. Not called if the south panel has been disabled via EntityTablePanel.Settings.includeSouthPanel(boolean).
      Returns:
      the south panel, or null if no south panel should be included
      See Also:
    • setupKeyboardActions

      protected void setupKeyboardActions()
      Sets up the default keyboard actions.
    • createToolBarControls

      protected Controls createToolBarControls(List<Controls> additionalToolBarControls)
    • createPopupMenuControls

      protected Controls createPopupMenuControls(List<Controls> additionalPopupMenuControls)
      Creates a Controls instance containing the controls to include in the table popup menu. Returning null or an empty Controls instance indicates that no popup menu should be included.
      Parameters:
      additionalPopupMenuControls - any additional controls to include in the popup menu
      Returns:
      Controls on which to base the table popup menu, null or an empty Controls instance if no popup menu should be included
    • createPrintMenuControls

      protected Controls createPrintMenuControls()
      By default this method returns a Controls instance containing the Control associated with EntityTablePanel.TableControl.PRINT. If no Control has been assigned to that control key, an empty Controls instance is returned. Override to add print actions, which will then appear in the table popup menu.
      Returns:
      the print controls to display in the table popup menu
    • createTableCellRenderer

      protected TableCellRenderer createTableCellRenderer(Attribute<?> attribute)
      Creates a TableCellRenderer to use for the given attribute in this EntityTablePanel
      Parameters:
      attribute - the attribute
      Returns:
      the TableCellRenderer for the given attribute
    • createTableCellEditor

      protected TableCellEditor createTableCellEditor(Attribute<?> attribute)
      Creates a TableCellEditor for the given attribute, returns null if no editor is available, such as for non-updatable attributes.
      Parameters:
      attribute - the attribute
      Returns:
      a TableCellEditor for the given attribute, null in case none is available
    • layoutPanel

      protected void layoutPanel(JComponent tableComponent, JPanel southPanel)
      This method simply adds tablePanel at location BorderLayout.CENTER and, if non-null, the given southPanel to the BorderLayout.SOUTH location. By overriding this method you can override the default layout.
      Parameters:
      tableComponent - the component containing the table, condition and summary panel
      southPanel - the south toolbar panel, null if not required
      See Also:
    • createSouthToolBar

      protected JToolBar createSouthToolBar()
      Creates the south panel toolbar, by default based on createToolBarControls(List)
      Returns:
      the toolbar to add to the south panel, null if none should be included
    • beforeDelete

      protected void beforeDelete()
      Called before delete is performed on the selected entities. To cancel the delete throw a CancelException.
    • onException

      protected void onException(Throwable exception)
      Propagates the exception to onValidationException(ValidationException) or onReferentialIntegrityException(ReferentialIntegrityException) depending on type, otherwise displays the exception.
      Parameters:
      exception - the exception to handle
      See Also:
    • onReferentialIntegrityException

      protected void onReferentialIntegrityException(ReferentialIntegrityException exception)
      Called when a ReferentialIntegrityException occurs during a delete operation on the selected entities. If the referential error handling is ReferentialIntegrityErrorHandling.DISPLAY_DEPENDENCIES, the dependencies of the entities involved are displayed to the user, otherwise onException(Throwable) is called.
      Parameters:
      exception - the exception
      See Also:
    • onValidationException

      protected void onValidationException(ValidationException exception)
      Displays the exception message.
      Parameters:
      exception - the exception
    • editDialogBuilder

      protected <T> EntityDialogs.EditDialogBuilder<T> editDialogBuilder(Attribute<T> attribute)
      Override to customize the edit dialog used when multiple entities are edited.
      Type Parameters:
      T - the attribute type
      Parameters:
      attribute - the attribute to edit
      Returns:
      a edit dialog builder
    • displayException

      protected final void displayException(Throwable exception)
      Displays the exception in a dialog, with the dialog owner as the current focus owner or this panel if none is available.
      Parameters:
      exception - the exception to display
    • confirmDelete

      protected final boolean confirmDelete()
      Returns:
      true if confirmed
      See Also: