Class EntityApplicationPanel<M extends SwingEntityApplicationModel>

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

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

  • Constructor Details

  • Method Details

    • displayException

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

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

      public final EntityApplicationPanel.ApplicationLayout applicationLayout()
      Returns:
      the application layout
    • entityPanel

      public final EntityPanel entityPanel(EntityType entityType)
      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
    • panels

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

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

      public final Observer<EntityApplicationPanel<M>> 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 SYSTEM_EXIT is true.

      Disposes all windows in the JVM so that it can end naturally when SYSTEM_EXIT is false, note that this closes the windows of any other Codion application sharing the JVM.

      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 EntityApplicationPanel<M> initialize()
      Initializes this panel and marks it as initialized, subsequent calls have no effect, nor has a call made while the initialization is in progress.
      Returns:
      this application panel
    • restore

      public void restore(Preferences preferences)
      Restores preferences for this application panel and its sub-panels. Override to apply any custom preferences.

      Remember to call super.restore(preferences) when overriding.

      Parameters:
      preferences - the preferences instance from which to restore
    • store

      public void store(Preferences preferences)
      Stores application preferences. Override to store custom preferences.

      Remember to call super.store(preferences) when overriding.

      The keys application and version are stored in the given node, along with the child nodes entities and auxiliary, so custom preferences need other names, preferably a child node of their own.

      Parameters:
      preferences - the Preferences instance to write to
    • 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 panels().

    • 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
    • createLookupMenuControls

      protected Optional<Controls> createLookupMenuControls()
      Returns:
      the Controls on which to base the Lookup 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
    • createSelectLookAndFeelControl

      protected final Control createSelectLookAndFeelControl()
      Allows the user the select between the available Look and Feels.
      Returns:
      a Control for selecting the application look and feel
      See Also:
    • createSelectScalingControl

      protected final Control createSelectScalingControl()
      Returns:
      a Control for selecting the scaling
    • 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
    • createLogControls

      protected final Controls createLogControls()
      Returns:
      Controls for log handling
    • 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
    • exiting

      protected final Observer<EntityApplicationPanel<M>> exiting()
      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: