Class EntityPanel

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

    public class EntityPanel
    extends JPanel
    implements HierarchyPanel
    A panel representing a Entity via a EntityModel, which facilitates browsing and editing of records.
       String entityId = ...;
       EntityConnectionProvider connectionProvider = ...;
       SwingEntityModel entityModel = new SwingEntityModel(entityId, connectionProvider);
       EntityPanel entityPanel = new EntityPanel(entityModel);
       entityPanel.initializePanel();
       JFrame frame = new JFrame();
       frame.add(entityPanel);
       frame.pack();
       frame.setVisible(true);
     
    See Also:
    Serialized Form
    • Field Detail

      • USE_KEYBOARD_NAVIGATION

        public static final PropertyValue<Boolean> USE_KEYBOARD_NAVIGATION
        Indicates whether keyboard navigation will be enabled
        Value type: Boolean
        Default value: true
      • CENTER_APPLICATION_DIALOGS

        public static final PropertyValue<Boolean> CENTER_APPLICATION_DIALOGS
        Indicates whether dialogs opened by child panels in the application should be centered on their respective parent panel or the application frame/dialog. This applies to edit panels. Value type: Boolean
        Default value: false
      • DISPOSE_EDIT_DIALOG_ON_ESCAPE

        public static final PropertyValue<Boolean> DISPOSE_EDIT_DIALOG_ON_ESCAPE
        Indicates whether entity edit panel dialogs should be closed on escape
        Value type: Boolean
        Default value: true
      • SHOW_TOGGLE_EDIT_PANEL_CONTROL

        public static final PropertyValue<Boolean> SHOW_TOGGLE_EDIT_PANEL_CONTROL
        Specifies whether or not a control for toggling the edit panel is available to the user
        Value type: Boolean
        Default value: true
      • SHOW_DETAIL_PANEL_CONTROLS

        public static final PropertyValue<Boolean> SHOW_DETAIL_PANEL_CONTROLS
        Specifies whether or not actions to hide detail panels or show them in a dialog are available to the user
        Value type: Boolean
        Default value: true
      • SPLIT_PANE_DIVIDER_SIZE

        public static final PropertyValue<Integer> SPLIT_PANE_DIVIDER_SIZE
        Specifies the default size of the divider for detail panel split panes.
        Value type: Integer
        Default value: 18
      • COMPACT_ENTITY_PANEL_LAYOUT

        public static final PropertyValue<Boolean> COMPACT_ENTITY_PANEL_LAYOUT
        Indicates whether entity panels containing detail panels should by default be laid out in a compact manner
        Value type: Boolean
        Default value: true
      • TOOLBAR_BUTTONS

        public static final PropertyValue<Boolean> TOOLBAR_BUTTONS
        Specifies whether the action buttons (Save, update, delete, clear, refresh) should be on a toolbar
        Value type: Boolean
        Default value: false
    • Constructor Detail

      • EntityPanel

        public EntityPanel​(SwingEntityModel entityModel)
        Initializes a new EntityPanel instance. The Panel is not laid out and initialized until initializePanel() is called.
        Parameters:
        entityModel - the EntityModel
      • EntityPanel

        public EntityPanel​(SwingEntityModel entityModel,
                           EntityEditPanel editPanel)
        Instantiates a new EntityPanel instance. The Panel is not laid out and initialized until initializePanel() is called.
        Parameters:
        entityModel - the EntityModel
        editPanel - the edit panel
      • EntityPanel

        public EntityPanel​(SwingEntityModel entityModel,
                           EntityTablePanel tablePanel)
        Instantiates a new EntityPanel instance. The Panel is not laid out and initialized until initializePanel() is called.
        Parameters:
        entityModel - the EntityModel
        tablePanel - the table panel
      • EntityPanel

        public EntityPanel​(SwingEntityModel entityModel,
                           EntityEditPanel editPanel,
                           EntityTablePanel tablePanel)
        Instantiates a new EntityPanel instance. The Panel is not laid out and initialized until initializePanel() is called.
        Parameters:
        entityModel - the EntityModel
        editPanel - the edit panel
        tablePanel - the table panel
    • Method Detail

      • getTableModel

        public final SwingEntityTableModel getTableModel()
        Returns:
        the EntityTableModel, null if none is available
      • getControlPanelConstraints

        public final String getControlPanelConstraints()
        Returns:
        the control panel layout constraints (BorderLayout constraints)
      • setControlPanelConstraints

        public final EntityPanel setControlPanelConstraints​(String controlPanelConstraints)
        Sets the layout constraints to use for the control panel
         The default layout is as follows (BorderLayout.WEST):
         __________________________________
         |   edit panel           |control|
         |  (EntityEditPanel)     | panel | } edit control panel
         |________________________|_______|
        
         With (BorderLayout.SOUTH):
         __________________________
         |         edit           |
         |        panel           |
         |________________________| } edit control panel
         |     control panel      |
         |________________________|
        
         etc.
        
        Parameters:
        controlPanelConstraints - the control panel layout constraints (BorderLayout constraints)
        Returns:
        this entity panel
        Throws:
        IllegalStateException - if the panel has been initialized
        IllegalArgumentException - in case the given constraint is not one of BorderLayout.SOUTH, NORTH, EAST or WEST
      • isCompactDetailLayout

        public final boolean isCompactDetailLayout()
        Returns:
        true if this entity panel is using a compact detail layout
      • setCompactDetailLayout

        public final EntityPanel setCompactDetailLayout​(boolean compactDetailLayout)
        Parameters:
        compactDetailLayout - true if this panel and its detail panels should be laid out in a compact state
        Returns:
        this EntityPanel instance
      • addDetailPanels

        public final EntityPanel addDetailPanels​(EntityPanel... detailPanels)
        Parameters:
        detailPanels - the detail panels
        Returns:
        this entity panel
      • addDetailPanel

        public final EntityPanel addDetailPanel​(EntityPanel detailPanel)
        Adds the given detail panel, and adds the detail model to the underlying model if it does not contain it already, and then sets includeDetailPanelTabPane to true
        Parameters:
        detailPanel - the detail panel to add
        Returns:
        this entity panel
        Throws:
        IllegalStateException - if the panel has been initialized
      • initializePanel

        public final EntityPanel initializePanel()
        Initializes this EntityPanels UI, in case of some specific initialization code you can override the initialize() method and add your code there. This method marks this panel as initialized which prevents it from running again, whether or not an exception occurs.
        Returns:
        this EntityPanel instance
        See Also:
        initialize(), isPanelInitialized()
      • isPanelInitialized

        public final boolean isPanelInitialized()
        Returns:
        true if the method initializePanel() has been called on this EntityPanel instance
        See Also:
        initializePanel()
      • getEditPanel

        public final EntityEditPanel getEditPanel()
        Returns:
        the edit panel
      • containsEditPanel

        public final boolean containsEditPanel()
        Returns:
        true if this panel contains a edit panel.
      • getTablePanel

        public final EntityTablePanel getTablePanel()
        Returns:
        the EntityTablePanel used by this EntityPanel
      • containsTablePanel

        public final boolean containsTablePanel()
        Returns:
        true if this panel contains a table panel.
      • getEditControlPanel

        public final JPanel getEditControlPanel()
        Returns the panel containing the edit panel and the edit controls panel.
        Returns:
        the edit control panel
      • getLinkedDetailPanels

        public final Collection<EntityPanel> getLinkedDetailPanels()
        Returns:
        the currently visible/linked detail EntityPanel, if any
      • getDetailPanel

        public final EntityPanel getDetailPanel​(String entityId)
        Returns the detail panel for the given entityId, if one is available
        Parameters:
        entityId - the entity ID of the detail panel to retrieve
        Returns:
        the detail panel of the given type
        Throws:
        IllegalArgumentException - in case the panel was not found
      • containsDetailPanel

        public final boolean containsDetailPanel​(String entityId)
        Returns true if this panel contains a detail panel for the given entityId
        Parameters:
        entityId - the entityId
        Returns:
        true if a detail panel for the given entityId is found
      • setCaption

        public final void setCaption​(String caption)
        Sets the caption to use when this panel is displayed.
        Parameters:
        caption - the caption
      • getCaption

        public final String getCaption()
        Returns:
        the caption to use when presenting this entity panel
      • activatePanel

        public final void activatePanel()
        Activates this panel, showing it and preparing it for input
        Specified by:
        activatePanel in interface HierarchyPanel
      • getSelectedChildPanel

        public final EntityPanel getSelectedChildPanel()
        Specified by:
        getSelectedChildPanel in interface HierarchyPanel
        Returns:
        a child panel, if one exists, which child panel exactly is up the implementation
      • setSelectedChildPanel

        public final void setSelectedChildPanel​(HierarchyPanel childPanel)
        Activates (and shows) the given child panel
        Specified by:
        setSelectedChildPanel in interface HierarchyPanel
        Parameters:
        childPanel - the child panel to activate and show
      • getToggleEditPanelControl

        public final Control getToggleEditPanelControl()
        Returns:
        a control for toggling the edit panel
      • getToggleDetailPanelControl

        public final Control getToggleDetailPanelControl()
        Returns:
        a control for toggling the detail panel
      • displayException

        public final void displayException​(Exception exception)
        Displays the exception in a dialog
        Parameters:
        exception - the exception to handle
        See Also:
        DefaultDialogExceptionHandler
      • getDetailSplitPaneResizeWeight

        public final double getDetailSplitPaneResizeWeight()
        Returns:
        the resize weight value to use when initializing the left/right split pane, which controls the initial divider placement (0 - 1). Override to control the initial divider placement
      • setDetailSplitPanelResizeWeight

        public final EntityPanel setDetailSplitPanelResizeWeight​(double detailSplitPanelResizeWeight)
        Parameters:
        detailSplitPanelResizeWeight - the detail panel split size weight
        Returns:
        this entity panel
        Throws:
        IllegalStateException - if the panel has been initialized
      • isIncludeDetailPanelTabPane

        public final boolean isIncludeDetailPanelTabPane()
        Returns:
        true if the detail panel tab pane should be included
      • setIncludeDetailPanelTabPane

        public final EntityPanel setIncludeDetailPanelTabPane​(boolean includeDetailPanelTabPane)
        Parameters:
        includeDetailPanelTabPane - true if the detail panel tab pane should be included
        Returns:
        this entity panel
        Throws:
        IllegalStateException - if the panel has been initialized
      • isShowToggleEditPanelControl

        public final boolean isShowToggleEditPanelControl()
        Returns:
        true if the edit panel control should be shown
        See Also:
        SHOW_TOGGLE_EDIT_PANEL_CONTROL
      • setShowToggleEditPanelControl

        public final EntityPanel setShowToggleEditPanelControl​(boolean showToggleEditPanelControl)
        Parameters:
        showToggleEditPanelControl - true if a control for toggling the edit panel should be shown
        Returns:
        this EntityPane instance
        Throws:
        IllegalStateException - if the panel has been initialized
      • isShowDetailPanelControls

        public final boolean isShowDetailPanelControls()
        Returns:
        true if detail panel controls should be shown
        See Also:
        SHOW_DETAIL_PANEL_CONTROLS
      • setShowDetailPanelControls

        public final EntityPanel setShowDetailPanelControls​(boolean showDetailPanelControls)
        Parameters:
        showDetailPanelControls - true if detail panel controls should be shown
        Returns:
        this EntityPane instance
        Throws:
        IllegalStateException - if the panel has been initialized
      • isIncludeControlPanel

        public final boolean isIncludeControlPanel()
        Returns:
        true if the control panel should be included
      • setIncludeControlPanel

        public final EntityPanel setIncludeControlPanel​(boolean includeControlPanel)
        Parameters:
        includeControlPanel - true if the control panel should be included
        Returns:
        this EntityPane instance
        Throws:
        IllegalStateException - if the panel has been initialized
      • isDisposeEditDialogOnEscape

        public final boolean isDisposeEditDialogOnEscape()
        Returns:
        true if the edit dialog is disposed of on ESC
        See Also:
        DISPOSE_EDIT_DIALOG_ON_ESCAPE
      • setDisposeEditDialogOnEscape

        public final void setDisposeEditDialogOnEscape​(boolean disposeEditDialogOnEscape)
        Parameters:
        disposeEditDialogOnEscape - if true then the edit dialog is disposed of on ESC
        See Also:
        DISPOSE_EDIT_DIALOG_ON_ESCAPE
      • isUseKeyboardNavigation

        public boolean isUseKeyboardNavigation()
        Returns:
        true if keyboard navigation is enabled
      • setUseKeyboardNavigation

        public void setUseKeyboardNavigation​(boolean useKeyboardNavigation)
        Parameters:
        useKeyboardNavigation - true if keyboard navigation should be enabled
      • toggleDetailPanelState

        public final void toggleDetailPanelState()
        Toggles the detail panel state between DIALOG, HIDDEN and EMBEDDED
      • toggleEditPanelState

        public final void toggleEditPanelState()
        Toggles the edit panel state between DIALOG, HIDDEN and EMBEDDED
      • getDetailPanelState

        public final EntityPanel.PanelState getDetailPanelState()
        Returns:
        the detail panel state, either HIDDEN, EMBEDDED or DIALOG
      • getEditPanelState

        public final EntityPanel.PanelState getEditPanelState()
        Returns:
        the edit panel state, either HIDDEN, EMBEDDED or DIALOG
      • setDetailPanelState

        public final void setDetailPanelState​(EntityPanel.PanelState state)
        Parameters:
        state - the detail panel state (HIDDEN or EMBEDDED, DIALOG)
      • setEditPanelState

        public final void setEditPanelState​(EntityPanel.PanelState state)
        Parameters:
        state - the edit panel state, either HIDDEN, EMBEDDED or DIALOG
      • setFilterPanelsVisible

        public final void setFilterPanelsVisible​(boolean visible)
        Hides or shows the active filter panels for this panel and all its child panels (detail panels and their detail panels etc.)
        Parameters:
        visible - true if the active panels should be shown, false if they should be hidden
      • resizePanel

        public final void resizePanel​(org.jminor.swing.framework.ui.EntityPanel.Direction direction,
                                      int pixelAmount)
        Resizes this panel in the given direction
        Parameters:
        direction - the resize direction
        pixelAmount - the resize amount
      • requestInitialFocus

        public final void requestInitialFocus()
        Requests focus for this panel. If an edit panel is available and not hidden, the component defined as the initialFocusComponent gets the input focus. If no edit panel is available the table panel gets the focus, otherwise the first child component of this EntityPanel is used.
        See Also:
        EntityEditComponentPanel.setInitialFocusComponent(javax.swing.JComponent)
      • savePreferences

        public void savePreferences()
        Saves any user preferences for all entity panels and associated elements
      • initializeUI

        protected void initializeUI()
        Initializes this EntityPanels UI.
         The default layout is as follows:
         __________________________________
         |      edit panel        |control|
         |   (EntityEditPanel)    | panel | } edit control panel
         |________________________|_______|
         |                  |             |
         |   table panel    |   detail    |
         |(EntityTablePanel)|   panel     |
         |                  |             |
         |__________________|_____________|
        
         or in case of compact layout:
         __________________________________
         |  edit    |control|             |
         |  panel   | panel |             |
         |__________|_______|   detail    |
         |                  |   panel     |
         |   table panel    |             |
         |(EntityTablePanel)|             |
         |                  |             |
         |__________________|_____________|
         
      • initializeAssociatedPanels

        protected void initializeAssociatedPanels()
        Called during initialization, before controls have been initialized
        See Also:
        initializePanel()
      • initializeControlPanels

        protected void initializeControlPanels()
        Called during initialization, after controls have been initialized, use this method to initialize any application panels that rely on controls having been initialized
        See Also:
        initializePanel()
      • initialize

        protected void initialize()
        Override to add code that should be called during the initialization routine after the panel has been initialized
        See Also:
        initializePanel()
      • setMasterPanel

        protected final void setMasterPanel​(EntityPanel masterPanel)
        Parameters:
        masterPanel - the panel serving as master panel for this entity panel
        Throws:
        IllegalStateException - in case a master panel has already been set
      • initializeKeyboardActions

        protected final void initializeKeyboardActions()
        Initializes the keyboard navigation actions. By default CTRL-T transfers focus to the table in case one is available, CTR-E transfers focus to the edit panel in case one is available, CTR-S transfers focus to the condition panel, CTR-C opens a select control dialog and CTR-F selects the table search field
      • initializeResizing

        protected final void initializeResizing()
      • initializeNavigation

        protected final void initializeNavigation()
      • initializeEditControlPanel

        protected void initializeEditControlPanel()