Class EntityPanel

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

    public class EntityPanel
    extends JPanel
    implements HierarchyPanel
    A panel representing an Entity via a EntityModel, which facilitates browsing and editing of records.
       EntityType entityType = ...;
       EntityConnectionProvider connectionProvider = ...;
       SwingEntityModel entityModel = new SwingEntityModel(entityType, 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
      • 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 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 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
      • 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
      • USE_FRAME_PANEL_DISPLAY

        public static final PropertyValue<Boolean> USE_FRAME_PANEL_DISPLAY
        Specifies whether detail and edit panels should be displayed in a frame instead of the default dialog
        Value type: Boolean
        Default value: false
    • Constructor Detail

      • EntityPanel

        public EntityPanel​(SwingEntityModel entityModel)
        Instantiates 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

      • updateUI

        public void updateUI()
        Overrides:
        updateUI in class JPanel
      • tableModel

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

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

        public final void 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)
        Throws:
        IllegalStateException - if the panel has been initialized
        IllegalArgumentException - in case the given constraint is not one of BorderLayout.SOUTH, NORTH, EAST or WEST
      • addDetailPanels

        public final void addDetailPanels​(EntityPanel... detailPanels)
        Parameters:
        detailPanels - the detail panels
      • addDetailPanel

        public final void 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
        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 an exception occurs or not.
        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()
      • editPanel

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

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

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

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

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

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

        public final EntityPanel detailPanel​(EntityType entityType)
        Returns the detail panel for the given entityType, if one is available
        Parameters:
        entityType - the entityType of the detail panel to retrieve
        Returns:
        the detail panel of the given type
        Throws:
        IllegalArgumentException - in case the panel was not found
      • detailPanels

        public final Collection<EntityPanel> detailPanels()
        Returns all detail panels.
        Returns:
        the detail panels
      • containsDetailPanel

        public final boolean containsDetailPanel​(EntityType entityType)
        Returns true if this panel contains a detail panel for the given entityType
        Parameters:
        entityType - the entityType
        Returns:
        true if a detail panel for the given entityType 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
      • setDescription

        public void setDescription​(String description)
        Sets the description text to use in f.ex. tool tips for tabbed panes
        Parameters:
        description - the description
      • getDescription

        public String getDescription()
        Returns:
        the description
      • activatePanel

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

        public final void selectChildPanel​(HierarchyPanel childPanel)
        Description copied from interface: HierarchyPanel
        Activates (and shows) the given child panel
        Specified by:
        selectChildPanel in interface HierarchyPanel
        Parameters:
        childPanel - the child panel to activate and show
      • displayException

        public final void displayException​(Throwable exception)
        Displays the exception in a dialog
        Parameters:
        exception - the exception to display
      • 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 void setDetailSplitPanelResizeWeight​(double detailSplitPanelResizeWeight)
        Parameters:
        detailSplitPanelResizeWeight - the detail panel split size weight
        Throws:
        IllegalStateException - if the panel has been initialized
      • isIncludeDetailTabPane

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

        public final void setIncludeDetailTabPane​(boolean includeDetailTabPane)
        Parameters:
        includeDetailTabPane - true if the detail panel tab pane should be included
        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 void setShowToggleEditPanelControl​(boolean showToggleEditPanelControl)
        Parameters:
        showToggleEditPanelControl - true if a control for toggling the edit panel should be shown
        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 void setShowDetailPanelControls​(boolean showDetailPanelControls)
        Parameters:
        showDetailPanelControls - true if detail panel controls should be shown
        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 void setIncludeControlPanel​(boolean includeControlPanel)
        Parameters:
        includeControlPanel - true if the control panel should be included
        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 final boolean isUseKeyboardNavigation()
        Returns:
        true if keyboard navigation is enabled
      • setUseKeyboardNavigation

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

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

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

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

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

        public final void setDetailPanelState​(EntityPanel.PanelState state)
        Parameters:
        state - the detail panel state (HIDDEN, EMBEDDED or WINDOW)
      • 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 panel dialogs for this panel and all its child panels (detail panels and their detail panels etc.)
        Parameters:
        visible - true if the active filter panel dialogs should be shown, false if they should be hidden
      • resizePanel

        public final void resizePanel​(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
      • setFocusCycleRoot

        public final void setFocusCycleRoot​(boolean focusCycleRoot)
        Overrides:
        setFocusCycleRoot in class Container
      • builder

        public static EntityPanel.Builder builder​(EntityType entityType)
        Instantiates a new EntityPanel.Builder
        Parameters:
        entityType - the entity type to base this panel builder on
        Returns:
        a panel builder
      • builder

        public static EntityPanel.Builder builder​(SwingEntityModel.Builder modelBuilder)
        Instantiates a new EntityPanel.Builder
        Parameters:
        modelBuilder - the SwingEntityModel.Builder to base this panel builder on
        Returns:
        a panel builder
      • builder

        public static EntityPanel.Builder builder​(SwingEntityModel model)
        Instantiates a new EntityPanel.Builder
        Parameters:
        model - the SwingEntityModel to base this panel builder on
        Returns:
        a panel builder
      • initializeUI

        protected void initializeUI()
        Initializes this EntityPanels UI.
         The default layout is as follows:
         __________________________________
         |  edit    |control|             |
         |  panel   | panel |             |
         |__________|_______|   detail    |
         |                  |   panel     |
         |   table panel    |             |
         |(EntityTablePanel)|             |
         |                  |             |
         |__________________|_____________|
         
        See Also:
        editControlPanel(), editControlTablePanel()
      • 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()
      • editControlTablePanel

        protected final JPanel editControlTablePanel()
        Returns the base panel containing the edit and table panels (north, center).
        Returns:
        the edit and table base panel
      • 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
      • setupKeyboardActions

        protected final void setupKeyboardActions()
        Sets up the keyboard navigation actions. 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 opens a select search condition panel dialog, in case one is available, CTR-I opens a select input field dialog and CTR-F selects the table search field
      • setupResizing

        protected final void setupResizing()
      • setupNavigation

        protected final void setupNavigation()
      • initializeEditControlPanel

        protected final void initializeEditControlPanel()