Class EntityApplicationPanel<M extends SwingEntityApplicationModel>

Type Parameters:
M - the application model type
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public abstract class EntityApplicationPanel<M extends SwingEntityApplicationModel> extends JPanel
A central application panel class.
See Also:
  • Field Details

  • Constructor Details

    • EntityApplicationPanel

      public EntityApplicationPanel(M applicationModel)
    • EntityApplicationPanel

      public EntityApplicationPanel(M applicationModel, EntityApplicationPanel.ApplicationLayout applicationLayout)
  • Method Details

    • displayException

      public final void displayException(Throwable exception)
      Displays the exception in a dialog
      Parameters:
      exception - the exception to display
    • applicationModel

      public final M applicationModel()
      Returns:
      the application model this application panel is based on
    • applicationLayout

      public final <T extends EntityApplicationPanel.ApplicationLayout> T applicationLayout()
      Type Parameters:
      T - the layout type
      Returns:
      the application layout
    • entityPanel

      public final <T extends EntityPanel> T entityPanel(EntityType entityType)
      Type Parameters:
      T - the entity panel type
      Parameters:
      entityType - the entityType
      Returns:
      the first entity panel found based on the given entity type
      Throws:
      IllegalArgumentException - in case this application panel does not contain a panel for the given entity type
    • entityPanels

      public final List<EntityPanel> entityPanels()
      Returns:
      an unmodifiable view of the main application panels
    • parentWindow

      public final Optional<Window> parentWindow()
      Returns:
      the parent window of this panel, if one exists, an empty Optional otherwise
    • alwaysOnTop

      public final State alwaysOnTop()
      Returns:
      a State controlling the alwaysOnTop state of this panels parent window
    • viewApplicationTree

      public final void viewApplicationTree()
      Displays in a dialog a tree describing the application layout
    • viewDependencyTree

      public final void viewDependencyTree()
      Shows a dialog containing a dependency tree view of all defined entities
    • addInitializationListener

      public final void addInitializationListener(Consumer<EntityApplicationPanel<?>> listener)
      Parameters:
      listener - notified when this application panel has been initialized
      See Also:
    • exit

      public final void exit()
      Exits this application
      Throws:
      CancelException - if the exit is cancelled
      See Also:
    • displayHelp

      public void displayHelp() throws Exception
      Displays the help.
      Throws:
      Exception - in case of an exception, for example a malformed URL
      See Also:
    • displayKeyboardShortcuts

      public final void displayKeyboardShortcuts()
      Displays a keyboard shortcut overview panel.
    • displayAbout

      public final void displayAbout()
      Shows an about dialog
      See Also:
    • initialize

      public final void initialize()
      Initializes this panel and marks is as initialized, subsequent calls have no effect.
    • createDependencyTreeModel

      public static TreeModel createDependencyTreeModel(Entities entities)
      Parameters:
      entities - the entities
      Returns:
      a tree model showing the dependencies between entities via foreign keys
    • builder

      public static <M extends SwingEntityApplicationModel, P extends EntityApplicationPanel<M>> EntityApplicationPanel.Builder<M,P> builder(Class<M> applicationModelClass, Class<P> applicationPanelClass)
      Type Parameters:
      M - the application model type
      P - the application panel type
      Parameters:
      applicationModelClass - the application model class
      applicationPanelClass - the application panel class
      Returns:
      a EntityApplicationPanel.Builder
    • createMainMenuControls

      protected Controls createMainMenuControls()
      Returns:
      the controls on which to base the main menu
      See Also:
    • createFileMenuControls

      protected Controls createFileMenuControls()
      Returns:
      the Controls specifying the items in the 'File' menu
    • createToolsMenuControls

      protected Controls createToolsMenuControls()
      Returns:
      the Controls specifying the items in the 'Tools' menu
    • createViewMenuControls

      protected Controls createViewMenuControls()
      Returns:
      the Controls specifying the items in the 'View' menu
    • createHelpMenuControls

      protected Controls createHelpMenuControls()
      Returns:
      the Controls specifying the items in the 'Help' menu
    • createSupportTableMenuControls

      protected Controls createSupportTableMenuControls()
      Returns:
      the Controls on which to base the Support Tables menu
    • createExitControl

      protected final Control createExitControl()
      Returns:
      a Control for exiting the application
    • createLogLevelControl

      protected final Control createLogLevelControl()
      Returns:
      a Control for setting the log level
    • createViewApplicationTreeControl

      protected final Control createViewApplicationTreeControl()
      Returns:
      a Control for viewing the application structure tree
    • createViewDependencyTree

      protected final Control createViewDependencyTree()
      Returns:
      a Control for viewing the application dependency tree
    • createSelectLookAndFeelControl

      protected final Control createSelectLookAndFeelControl()
      Allows the user the select between the available Look and Feels, saves the selection as a user preference.
      Returns:
      a Control for selecting the application look and feel
      See Also:
    • createSelectFontSizeControl

      protected final Control createSelectFontSizeControl()
      Returns:
      a Control for selecting the font size
    • createAlwaysOnTopControl

      protected final ToggleControl createAlwaysOnTopControl()
      Returns:
      a Control controlling the always on top status
    • createAboutControl

      protected final Control createAboutControl()
      Returns:
      a Control for viewing information about the application
    • createHelpControl

      protected final Control createHelpControl()
      Returns:
      a Control for displaying the help
    • createViewKeyboardShortcutsControl

      protected final Control createViewKeyboardShortcutsControl()
      Returns:
      a Control for displaying the keyboard shortcuts overview
    • createAboutPanel

      protected JPanel createAboutPanel()
      Returns:
      the panel shown when Help -> About is selected
    • bindEvents

      protected void bindEvents()
      Override to add event bindings after initialization
    • displayEntityPanel

      protected final void displayEntityPanel(EntityPanel.Builder panelBuilder)
      Displays the panel provided by the given builder in a frame or dialog, depending on EntityPanel.USE_FRAME_PANEL_DISPLAY.
      Parameters:
      panelBuilder - the entity panel builder
    • displayEntityPanel

      protected final void displayEntityPanel(EntityPanel entityPanel)
      Displays the given panel in a frame or dialog, depending on EntityPanel.USE_FRAME_PANEL_DISPLAY.
      Parameters:
      entityPanel - the entity panel
    • displayEntityPanelFrame

      protected final void displayEntityPanelFrame(EntityPanel entityPanel)
      Shows a frame containing the given entity panel
      Parameters:
      entityPanel - the entity panel
    • displayEntityPanelDialog

      protected final void displayEntityPanelDialog(EntityPanel entityPanel)
      Shows a non-modal dialog containing the given entity panel
      Parameters:
      entityPanel - the entity panel
    • displayEntityPanelDialog

      protected final void displayEntityPanelDialog(EntityPanel entityPanel, boolean modalDialog)
      Shows a dialog containing the given entity panel
      Parameters:
      entityPanel - the entity panel
      modalDialog - if true the dialog is made modal
    • createEntityPanels

      protected abstract List<EntityPanel> createEntityPanels()
      Creates the EntityPanels to include in this application panel. Returns an empty list in case this panel contains no entity panels or has a custom UI.
      Returns:
      a List containing the EntityPanels to include in this application panel or an empty list in case of no entity panels.
    • createSupportEntityPanelBuilders

      protected Collection<EntityPanel.Builder> createSupportEntityPanelBuilders()
      Returns a Collection of EntityPanel.Builder instances to use to populate the Support Table menu. Returns an empty Collection in case of no support table panels.
      Returns:
      a Collection of EntityPanel.Builder instances to use to populate the Support Table menu.
    • addOnExitListener

      protected final void addOnExitListener(Runnable listener)
      Adds a listener notified when the application is about to exit. To cancel the exit throw a CancelException.
      Parameters:
      listener - a listener notified when the application is about to exit
    • createMenuBar

      protected JMenuBar createMenuBar()
      Creates the JMenuBar to use on the application Frame
      Returns:
      by default a JMenuBar based on the main menu controls
      See Also:
    • defaultUsername

      protected final String defaultUsername()
      Returns:
      the default username, that is, the username of the last successful login from user preferences, or the operating system username, if no username is found in user preferences.
    • savePreferences

      protected void savePreferences()
      Called during the exit() method, override to save user preferences on program exit, remember to call super.savePreferences() when overriding
      See Also: