Class EntityTablePanel

  • All Implemented Interfaces:
    ImageObserver, MenuContainer, Serializable, Accessible, DialogExceptionHandler

    public class EntityTablePanel
    extends JPanel
    implements DialogExceptionHandler
    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
      ____________________________________________________
     |                searchPanel                         |
     |____________________________________________________|
     |                                                    |
     |                                                    |
     |                                                    |
     |                                                    |
     |                entityTable (JTable)                |
     |                                                    |
     |                                                    |
     |                                                    |
     |                                                    |
     |____________________________________________________|
     |                summaryPanel                        |
     |____________________________________________________|
     |                southPanel                          |
     |____________________________________________________|
     
    The search and summary panels can be hidden Note that initializePanel() must be called to initialize this panel before displaying it.
    See Also:
    EntityTableModel, Serialized Form
    • Constructor Detail

      • EntityTablePanel

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

        public EntityTablePanel​(SwingEntityTableModel tableModel,
                                EntityTableConditionPanel conditionPanel)
        Initializes a new EntityTablePanel instance
        Parameters:
        tableModel - the EntityTableModel instance
        conditionPanel - the condition panel
      • EntityTablePanel

        public EntityTablePanel​(SwingEntityTableModel tableModel,
                                EntityComponentValues componentValues,
                                EntityTableConditionPanel conditionPanel)
        Initializes a new EntityTablePanel instance
        Parameters:
        tableModel - the EntityTableModel instance
        componentValues - the component value provider for this table panel
        conditionPanel - the condition panel
    • Method Detail

      • getTableModel

        public final SwingEntityTableModel getTableModel()
        Returns:
        the EntityTableModel used by this EntityTablePanel
      • excludeFromUpdateMenu

        public final void excludeFromUpdateMenu​(String propertyId)
        Specifies that the given property should be excluded from the update selected entities menu.
        Parameters:
        propertyId - the id of the property to exclude from the update menu
        Throws:
        IllegalStateException - in case the panel has already been initialized
      • addPopupControls

        public final void addPopupControls​(ControlSet additionalPopupControls)
        Parameters:
        additionalPopupControls - a set of controls to add to the table popup menu
        Throws:
        IllegalStateException - in case the panel has already been initialized
        See Also:
        initializePanel()
      • addToolBarControls

        public final void addToolBarControls​(ControlSet additionalToolBarControls)
        Parameters:
        additionalToolBarControls - a set of controls to add to the table toolbar menu
        Throws:
        IllegalStateException - in case the panel has already been initialized
        See Also:
        initializePanel()
      • setIncludeSouthPanel

        public final void setIncludeSouthPanel​(boolean includeSouthPanel)
        Parameters:
        includeSouthPanel - true if the south panel should be included
        Throws:
        IllegalStateException - in case the panel has already been initialized
        See Also:
        initializeSouthPanel(), initializePanel()
      • setIncludeConditionPanel

        public final void setIncludeConditionPanel​(boolean includeConditionPanel)
        Parameters:
        includeConditionPanel - true if the condition panel should be included
        Throws:
        IllegalStateException - in case the panel has already been initialized
        See Also:
        initializePanel()
      • setIncludePopupMenu

        public final void setIncludePopupMenu​(boolean includePopupMenu)
        Parameters:
        includePopupMenu - true if a popup menu should be included
        Throws:
        IllegalStateException - in case the panel has already been initialized
        See Also:
        initializePanel()
      • setConditionPanelVisible

        public final void setConditionPanelVisible​(boolean visible)
        Hides or shows the column condition panel for this EntityTablePanel
        Parameters:
        visible - if true the condition panel is shown, if false it is hidden
      • isConditionPanelVisible

        public final boolean isConditionPanelVisible()
        Returns:
        true if the condition panel is visible, false if it is hidden
      • getConditionPanel

        public final EntityTableConditionPanel getConditionPanel()
        Returns:
        the condition panel being used by this EntityTablePanel
      • toggleConditionPanel

        public final void toggleConditionPanel()
        Toggles the condition panel through the states hidden, visible and in case it is a EntityTableConditionPanel, advanced
      • setSummaryPanelVisible

        public final void setSummaryPanelVisible​(boolean visible)
        Hides or shows the column summary panel for this EntityTablePanel
        Parameters:
        visible - if true then the summary panel is shown, if false it is hidden
      • isSummaryPanelVisible

        public final boolean isSummaryPanelVisible()
        Returns:
        true if the column summary panel is visible, false if it is hidden
      • setReferentialIntegrityErrorHandling

        public final void setReferentialIntegrityErrorHandling​(EntityTablePanel.ReferentialIntegrityErrorHandling referentialIntegrityErrorHandling)
        Parameters:
        referentialIntegrityErrorHandling - the action to take on a referential integrity error on delete
      • getControl

        public final Control getControl​(String controlCode)
        Parameters:
        controlCode - the control code
        Returns:
        the control associated with controlCode
        Throws:
        IllegalArgumentException - in case no control is associated with the given control code
      • getViewDependenciesControl

        public final Control getViewDependenciesControl()
        Returns:
        a control for showing the dependencies dialog
      • getDeleteSelectedControl

        public final Control getDeleteSelectedControl()
        Returns:
        a control for deleting the selected entities
        Throws:
        IllegalStateException - in case the underlying model is read only or if deleting is not enabled
      • getPrintTableControl

        public final Control getPrintTableControl()
        Returns:
        a control for printing the table
      • getRefreshControl

        public final Control getRefreshControl()
        Returns:
        a Control for refreshing the underlying table data
      • getClearControl

        public final Control getClearControl()
        Returns:
        a Control for clearing the underlying table model, that is, removing all rows
      • viewSelectionDependencies

        public final void viewSelectionDependencies()
        Shows a dialog containing lists of entities depending on the selected entities via foreign key
      • delete

        public final void delete()
        Deletes the entities selected in the underlying table model
        See Also:
        confirmDelete()
      • onException

        public void onException​(Exception exception)
        Handles the given exception, simply displays the error message to the user by default.
        Parameters:
        exception - the exception to handle
        See Also:
        displayException(Throwable, Window)
      • displayException

        public final void displayException​(Throwable throwable,
                                           Window dialogParent)
        Handle the given exception and display it to the user.
        Specified by:
        displayException in interface DialogExceptionHandler
        Parameters:
        throwable - the exception
        dialogParent - the Window to use as parent to the exception dialog
      • getToggleConditionPanelControl

        public final Control getToggleConditionPanelControl()
        Initializes the button used to toggle the condition panel state (hidden, visible and advanced)
        Returns:
        a condition panel toggle button
      • getToggleSummaryPanelControl

        public final Control getToggleSummaryPanelControl()
        Initializes the button used to toggle the summary panel state (hidden and visible)
        Returns:
        a summary panel toggle button
      • getClearSelectionControl

        public final Control getClearSelectionControl()
        Returns:
        a control for clearing the table selection
      • getMoveSelectionDownControl

        public final Control getMoveSelectionDownControl()
        Returns:
        a control for moving the table selection down one index
      • getMoveSelectionUpControl

        public final Control getMoveSelectionUpControl()
        Returns:
        a control for moving the table selection up one index
      • addConditionPanelVisibleListener

        public final void addConditionPanelVisibleListener​(EventDataListener<Boolean> listener)
        Parameters:
        listener - a listener notified each time the condition panel visibility changes
      • removeConditionPanelVisibleListener

        public final void removeConditionPanelVisibleListener​(EventDataListener listener)
        Parameters:
        listener - the listener to remove
      • showDependenciesDialog

        public static void showDependenciesDialog​(Collection<Entity> entities,
                                                  EntityConnectionProvider connectionProvider,
                                                  JComponent dialogParent)
        Displays a dialog with the entities depending on the given entities.
        Parameters:
        entities - the entities for which to display dependencies
        connectionProvider - the connection provider
        dialogParent - the dialog parent
      • createReadOnlyEntityTablePanel

        public static EntityTablePanel createReadOnlyEntityTablePanel​(Collection<Entity> entities,
                                                                      EntityConnectionProvider connectionProvider)
        Creates a static read-only entity table panel showing the given entities
        Parameters:
        entities - the entities to show in the panel
        connectionProvider - the EntityConnectionProvider, in case the returned panel should require one
        Returns:
        a static EntityTablePanel showing the given entities
      • createEntityTablePanel

        public static EntityTablePanel createEntityTablePanel​(Collection<Entity> entities,
                                                              EntityConnectionProvider connectionProvider)
        Creates a static entity table panel showing the given entities, note that this table panel will provide a popup menu for updating and deleting the selected entities unless the underlying entities are read-only.
        Parameters:
        entities - the entities to show in the panel
        connectionProvider - the EntityConnectionProvider, in case the returned panel should require one
        Returns:
        a static EntityTablePanel showing the given entities
      • createEntityTablePanel

        public static EntityTablePanel createEntityTablePanel​(SwingEntityTableModel tableModel)
        Creates a entity table panel based on the given table model. If the table model is not read only, a popup menu for updating or deleting the selected entities is provided.
        Parameters:
        tableModel - the table model
        Returns:
        a entity table panel based on the given model
      • initializePanel

        public final EntityTablePanel initializePanel()
        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
      • initializeSouthPanel

        protected JPanel initializeSouthPanel()
        Initializes the south panel, override and return null for no south panel.
        Returns:
        the south panel, or null if no south panel should be included
      • setControl

        protected final void setControl​(String controlCode,
                                        Control control)
        Associates control with controlCode
        Parameters:
        controlCode - the control code
        control - the control to associate with controlCode
      • getPopupControls

        protected ControlSet getPopupControls​(List<ControlSet> additionalPopupControlSets)
        Constructs a ControlSet containing the controls to include in the table popup menu. Returns null or an empty ControlSet to indicate that no popup menu should be included.
        Parameters:
        additionalPopupControlSets - any additional controls to include in the popup menu
        Returns:
        the ControlSet on which to base the table popup menu, null or an empty ControlSet if no popup menu should be included
      • getPrintControls

        protected ControlSet getPrintControls()
      • getConditionPanelControl

        protected final Control getConditionPanelControl()
      • getCopyControlSet

        protected final ControlSet getCopyControlSet()
      • getCopyCellControl

        protected final Control getCopyCellControl()
      • getCopyTableWithHeaderControl

        protected final Control getCopyTableWithHeaderControl()
      • confirmDelete

        protected final boolean confirmDelete()
        Called before a delete is performed, if true is returned the delete action is performed otherwise it is canceled
        Returns:
        true if the delete action should be performed
      • getConfirmDeleteMessages

        protected String[] getConfirmDeleteMessages()
        Returns:
        Strings to display in the confirm delete dialog, index 0 = message, index 1 = title
      • initializeTableCellRenderer

        protected TableCellRenderer initializeTableCellRenderer​(Property property)
        Returns the TableCellRenderer used for the given property in this EntityTablePanel
        Parameters:
        property - the property
        Returns:
        the TableCellRenderer for the given property
      • initializeTableCellEditor

        protected TableCellEditor initializeTableCellEditor​(Property property)
        Creates a TableCellEditor for the given property, returns null if no editor is available
        Parameters:
        property - the property
        Returns:
        a TableCellEditor for the given property
      • layoutPanel

        protected void layoutPanel​(JPanel tablePanel,
                                   JPanel southPanel)
        This method simply adds the given southPanel to the BorderLayout.SOUTH location and the tablePanel at location BorderLayout.CENTER. By overriding this method you can override the default layout.
        Parameters:
        tablePanel - the panel containing the table, condition and summary panel
        southPanel - the south toolbar panel
      • initializeSouthToolBar

        protected JToolBar initializeSouthToolBar()
        Initializes the south panel toolbar, by default based on getToolBarControls()
        Returns:
        the toolbar to add to the south panel