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:
  • Constructor Details

    • EntityTablePanel

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

      public EntityTablePanel(SwingEntityTableModel tableModel, Consumer<EntityTablePanel.Config> configuration)
      Initializes a new EntityTablePanel instance
      Parameters:
      tableModel - the SwingEntityTableModel instance
      configuration - provides access to the table panel configuration
    • EntityTablePanel

      public EntityTablePanel(SwingEntityTableModel tableModel, EntityEditPanel editPanel)
      Initializes a new EntityTablePanel instance
      Parameters:
      tableModel - the SwingEntityTableModel instance
      editPanel - the edit panel
    • EntityTablePanel

      public EntityTablePanel(SwingEntityTableModel tableModel, EntityEditPanel editPanel, Consumer<EntityTablePanel.Config> configuration)
      Initializes a new EntityTablePanel instance
      Parameters:
      tableModel - the SwingEntityTableModel instance
      editPanel - the edit panel
      configuration - provides access to the table panel configuration
  • 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
    • 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
    • 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
    • addPopupMenuControls

      public void addPopupMenuControls(Controls additionalPopupMenuControls)
      Parameters:
      additionalPopupMenuControls - a set of controls to add to the table popup menu
      Throws:
      IllegalStateException - in case this panel has already been initialized
    • addToolBarControls

      public void addToolBarControls(Controls additionalToolBarControls)
      Parameters:
      additionalToolBarControls - a set of controls to add to the table toolbar menu
      Throws:
      IllegalStateException - in case this panel has already been initialized
    • 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
    • editSelected

      public final void editSelected()
      Displays a selection dialog for selecting an attribute to edit and retrieves a new value via input dialog and performs an update on the selected entities assigning the value to the attribute
      See Also:
    • editSelected

      public final void editSelected(Attribute<?> attributeToEdit)
      Retrieves a new value via input dialog and performs an update on the selected entities assigning the value to the attribute
      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
    • deleteSelectedWithConfirmation

      public final boolean deleteSelectedWithConfirmation()
      Deletes the entities selected in the underlying table model after asking for confirmation using the confirmer specified via EntityTablePanel.Config.deleteConfirmer(Confirmer)
      Returns:
      true if the delete operation was successful
      See Also:
    • deleteSelected

      public final boolean deleteSelected()
      Deletes the entities selected in the underlying table model without asking for confirmation.
      Returns:
      true if the delete operation was successful
    • 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
    • configureControls

      protected void configureControls()
      Override to configure 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.Config.includeSouthPanel(boolean).
      Returns:
      the south panel, or null if no south panel should be included
      See Also:
    • setupKeyboardActions

      protected void setupKeyboardActions()
    • configureToolBar

      protected final void configureToolBar(Consumer<EntityTablePanel.ToolBarConfig> toolBarConfig)
      Configures the toolbar controls.
      Note that the EntityTablePanel.ToolBarConfig instance has pre-configured defaults, which must be cleared in order to start with an empty configuration.
         configureToolBar(config -> config.clear()
                 .standard(TableControl.REFRESH)
                 .separator()
                 .control(createCustomControl())
                 .separator()
                 .defaults())
       
      Parameters:
      toolBarConfig - provides access to the toolbar configuration
      See Also:
    • configurePopupMenu

      protected final void configurePopupMenu(Consumer<EntityTablePanel.PopupMenuConfig> popupMenuConfig)
      Configures the popup menu controls.
      Note that the EntityTablePanel.PopupMenuConfig instance has pre-configured defaults, which must be cleared in order to start with an empty configuration.
         configurePopupMenu(config -> config.clear()
                 .standard(TableControl.REFRESH)
                 .separator()
                 .control(createCustomControl())
                 .separator()
                 .defaults())
       
      Parameters:
      popupMenuConfig - provides access to the popup menu configuration
      See Also:
    • 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-editable attributes.
      Parameters:
      attribute - the attribute
      Returns:
      a TableCellEditor for the given attribute, null in case none is available
      See Also:
    • 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:
    • onException

      protected void onException(Exception 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(Exception) 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.EditAttributeDialogBuilder<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(Exception 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: