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

    • USER_PREFERENCES_ENABLED

      public static final PropertyValue<Boolean> USER_PREFERENCES_ENABLED
      Specifies whether the client should apply and save user preferences
      • Value type: Boolean
      • Default value: true
      See Also:
    • RESTORE_DEFAULT_PREFERENCES

      public static final PropertyValue<Boolean> RESTORE_DEFAULT_PREFERENCES
      Specifies whether the application should restore default preferences, that is, not load any saved user preferences.
      • Value type: Boolean
      • Default value: false
      See Also:
    • CALL_SYSTEM_EXIT

      public static final PropertyValue<Boolean> CALL_SYSTEM_EXIT
      Specifies whether the application should call System.exit(int) when exiting.
      • Value type: Boolean
      • Default value: false
      See Also:
    • DISPLAY_SYSTEM_PROPERTIES

      public static final PropertyValue<Boolean> DISPLAY_SYSTEM_PROPERTIES
      Specifies whether a button for displaying system properties is included on the about panel.
      • Value type: Boolean
      • Default value: true
      See Also:
    • HELP_URL

      public static final PropertyValue<String> HELP_URL
      Specifies the URL to the application help
      • Value type: String
      • Default value: https://codion.is/doc/{version}/help/client.html
    • CONFIRM_EXIT

      public static final PropertyValue<Boolean> CONFIRM_EXIT
      Indicates whether the application should ask for confirmation when exiting
      • Value type: Boolean
      • Default value: false
    • SHOW_STARTUP_DIALOG

      public static final PropertyValue<Boolean> SHOW_STARTUP_DIALOG
      Specifies whether a startup dialog should be shown
      • Value type: Boolean
      • Default value: true
    • CACHE_ENTITY_PANELS

      public static final PropertyValue<Boolean> CACHE_ENTITY_PANELS
      Specifies whether EntityPanels displayed via displayEntityPanelDialog(EntityPanel) or displayEntityPanelFrame(EntityPanel) should be cached, instead of being created each time the dialog/frame is shown.
      • Value type: Boolean
      • Default value: false
      See Also:
  • Constructor Details

  • Method Details

    • displayException

      public final void displayException(Exception 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
      See Also:
    • 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
    • initialized

      public final Observer<EntityApplicationPanel<?>> initialized()
      Returns:
      an observer notified when this application panel is initialized
      See Also:
    • exit

      public final void exit()
      Exits this application. Calls System.exit(int) in case CALL_SYSTEM_EXIT is true.
      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.
    • requestInitialFocus

      public void requestInitialFocus()

      Requests the initial application focus by calling EntityPanel.requestInitialFocus() on the main entity panel.

      By default, the main entity panel is the first one returned by entityPanels().

    • 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 Optional<Controls> createMainMenuControls()
      Returns:
      the controls on which to base the main menu or an empty Optional if the menu should be excluded
      See Also:
    • createFileMenuControls

      protected Optional<Controls> createFileMenuControls()
      Returns:
      the Controls specifying the items in the 'File' menu or an empty Optional to skip the menu
    • createToolsMenuControls

      protected Optional<Controls> createToolsMenuControls()
      Returns:
      the Controls specifying the items in the 'Tools' menu or an empty Optional to skip the menu
    • createViewMenuControls

      protected Optional<Controls> createViewMenuControls()
      Returns:
      the Controls specifying the items in the 'View' menu or an empty Optional to skip the menu
    • createHelpMenuControls

      protected Optional<Controls> createHelpMenuControls()
      Returns:
      the Controls specifying the items in the 'Help' menu or an empty Optional to skip the menu
    • createSupportTableMenuControls

      protected Optional<Controls> createSupportTableMenuControls()
      Returns:
      the Controls on which to base the Support Tables menu or an empty Optional to skip the menu
    • createExitControl

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

      protected final Controls createLogLevelControl()
      Returns:
      Controls 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
    • displayEntityPanelWindow

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

      protected final void displayEntityPanelWindow(EntityPanel entityPanel)
      Displays the given panel in a frame or dialog, depending on EntityPanel.Config.WINDOW_TYPE.
      Parameters:
      entityPanel - the entity panel
      See Also:
    • displayEntityPanelFrame

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

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

      protected final void displayEntityPanelDialog(EntityPanel entityPanel, boolean modal)
      Shows a dialog containing the given entity panel
      Parameters:
      entityPanel - the entity panel
      modal - if true the dialog should be 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.
    • exitObserver

      protected final Observer<?> exitObserver()
      To cancel the exit add a listener throwing a CancelException.
      Returns:
      an observer notified when the application is about to exit.
    • createMenuBar

      protected Optional<JMenuBar> createMenuBar()
      Creates the JMenuBar to use on the application Frame
      Returns:
      by default a JMenuBar based on the main menu controls or an empty Optional in case of no menu bar
      See Also:
    • savePreferences

      protected void savePreferences()
      Called during the exit() method, override to save user preferences on program exit, remember to call super.savePreferences() when overriding. Only called if USER_PREFERENCES_ENABLED is set to true.
      See Also: