Class EntityApplicationPanel<M extends SwingEntityApplicationModel>

    • Field Detail

      • 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}/{jdk}/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
      • PERSIST_ENTITY_PANELS

        public static final PropertyValue<Boolean> PERSIST_ENTITY_PANELS
        Specifies if EntityPanels opened via the EntityApplicationPanel.displayEntityPanel method should be persisted, or kept in memory, when the dialog/frame is closed, instead of being created each time.
        Value type: Boolean
        Default value: false
        See Also:
        displayEntityPanelDialog(EntityPanel.Builder)
      • TAB_PLACEMENT

        public static final PropertyValue<Integer> TAB_PLACEMENT
        Specifies the tab placement
        Value type: Integer (SwingConstants.TOP, SwingConstants.BOTTOM, SwingConstants.LEFT, SwingConstants.RIGHT)
        Default value: SwingConstants.TOP
    • Constructor Detail

      • EntityApplicationPanel

        public EntityApplicationPanel​(String applicationName)
        Parameters:
        applicationName - the application name
      • EntityApplicationPanel

        public EntityApplicationPanel​(String applicationName,
                                      ImageIcon applicationIcon)
        Parameters:
        applicationName - the application name
        applicationIcon - the application icon
      • EntityApplicationPanel

        public EntityApplicationPanel​(String applicationName,
                                      ImageIcon applicationIcon,
                                      Supplier<JFrame> frameProvider)
        Parameters:
        applicationName - the application name
        applicationIcon - the application icon
        frameProvider - the JFrame provider
    • Method Detail

      • displayException

        public final void displayException​(Throwable 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
      • entityPanel

        public final EntityPanel entityPanel​(EntityType entityType)
        Parameters:
        entityType - the entityType
        Returns:
        the first entity panel found based on the given entity type, null if none is found
      • 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
      • applicationName

        public final String applicationName()
        Returns:
        the application name
      • applicationIcon

        public final ImageIcon applicationIcon()
        Returns:
        the application icon, the default logo icon if none has been specified
        See Also:
        FrameworkIcons.logo(int)
      • isAlwaysOnTop

        public final boolean isAlwaysOnTop()
        Returns:
        true if the frame this application panel is shown in should be 'alwaysOnTop'
      • alwaysOnTopState

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

        public final void setLogLevel()
        Shows a dialog for setting the log level
      • 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
      • selectFontSize

        public final void selectFontSize()
        Display a dialog for selecting the application font size multiplier
      • 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
      • 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
      • displayHelp

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

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

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

        public final void addAlwaysOnTopListener​(EventDataListener<Boolean> listener)
        Parameters:
        listener - a listener notified each time the always on top status changes
      • removeAlwaysOnTopListener

        public final void removeAlwaysOnTopListener​(EventListener listener)
        Parameters:
        listener - the listener to remove
      • addApplicationStartedListener

        public final void addApplicationStartedListener​(EventDataListener<JFrame> listener)
        Parameters:
        listener - a listener notified when to application has been successfully started
      • removeApplicationStartedListener

        public final void removeApplicationStartedListener​(EventDataListener<JFrame> listener)
        Parameters:
        listener - the listener to remove
      • createDependencyTreeModel

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

        protected final JTabbedPane applicationTabPane()
        Returns the JTabbedPane used by the default UI, note that this can be null if the default UI initialization has been overridden. Returns null until initializeUI() has been called
        Returns:
        the default application tab pane
      • createFileControls

        protected Controls createFileControls()
        Returns:
        the Controls specifying the items in the 'File' menu
      • createSettingsControls

        protected Controls createSettingsControls()
        Returns:
        the Controls specifying the items in the 'Settings' menu
      • createToolsControls

        protected Controls createToolsControls()
        Returns:
        the Controls specifying the items in the 'Tools' menu
      • createViewControls

        protected Controls createViewControls()
        Returns:
        the Controls specifying the items in the 'View' menu
      • createHelpControls

        protected Controls createHelpControls()
        Returns:
        the Controls specifying the items in the 'Help' 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
      • createRefreshAllControl

        protected final Control createRefreshAllControl()
        Returns:
        a Control for refreshing the application model
      • 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
      • 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
      • initializeConnectionProvider

        protected EntityConnectionProvider initializeConnectionProvider​(User user,
                                                                        String clientTypeId)
        Initializes the entity connection provider
        Parameters:
        user - the user
        clientTypeId - a string specifying the client type
        Returns:
        an initialized EntityConnectionProvider
        Throws:
        CancelException - in case the initialization is cancelled
      • clientVersion

        protected Version clientVersion()
        Returns:
        the client version if specified, null by default
      • bindEvents

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

        protected List<Controls> createAdditionalMenuControls()
        Returns:
        a List of Controls instances which should be added to the main menu bar
      • createSupportTableControls

        protected Controls createSupportTableControls()
        Returns:
        the Controls on which to base the Support Tables menu
      • displayEntityPanel

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

        protected final void displayEntityPanelFrame​(EntityPanel.Builder panelBuilder)
        Shows a frame containing the entity panel provided by the given panel builder
        Parameters:
        panelBuilder - the entity panel builder
      • displayEntityPanelDialog

        protected final void displayEntityPanelDialog​(EntityPanel.Builder panelBuilder)
        Shows a dialog containing the entity panel provided by the given panel builder
        Parameters:
        panelBuilder - the entity panel builder
      • displayEntityPanelDialog

        protected final void displayEntityPanelDialog​(EntityPanel.Builder panelBuilder,
                                                      boolean modalDialog)
        Shows a dialog containing the entity panel provided by the given panel builder
        Parameters:
        panelBuilder - the entity panel builder
        modalDialog - if true the dialog is made modal
      • initializeUI

        protected void initializeUI()
        Initializes this EntityApplicationPanel
      • createEntityPanels

        protected abstract List<EntityPanel> createEntityPanels​(M applicationModel)
        Creates the EntityPanels to include in this application panel.
        Parameters:
        applicationModel - the application model responsible for providing EntityModels for the panels
        Returns:
        a List containing the EntityPanels to include in this application panel
      • createSupportEntityPanelBuilders

        protected List<EntityPanel.Builder> createSupportEntityPanelBuilders​(M applicationModel)
      • lookAndFeelName

        protected String lookAndFeelName()
        Returns the name of the look and feel to use, this default implementation fetches it from user preferences, if no preference is available the default system look and feel is used.
        Returns:
        the look and feel name to use
        See Also:
        defaultLookAndFeelName()
      • fontSizeMultiplier

        protected int fontSizeMultiplier()
        Returns the font size multiplier to use, from user preferences, in percentages, e.g:
        85 = decrease the default font size by 15%
        100 = use the default font size
        125 = increase the default font size by 25%
        Returns:
        the font size multiplier to use
        See Also:
        selectFontSize()
      • createNorthPanel

        protected JPanel createNorthPanel()
        Creates a panel to display in the NORTH position of this application panel. override to provide a north panel.
        Returns:
        a panel for the NORTH position
      • createSouthPanel

        protected JPanel createSouthPanel()
        Creates a panel to display in the SOUTH position of this application frame, override to provide a south panel.
        Returns:
        a panel for the SOUTH position
      • createStartupIconPanel

        protected JPanel createStartupIconPanel​(Icon icon)
        Initializes the icon panel to show in the startup dialog
        Parameters:
        icon - the icon
        Returns:
        an initialized startup icon panel
      • frameTitle

        protected String frameTitle()
        Returns:
        a frame title based on the application name, version and the logged-in user
      • prepareFrame

        protected final JFrame prepareFrame​(boolean displayFrame,
                                            boolean maximizeFrame,
                                            Dimension frameSize,
                                            boolean mainMenu)
        Initializes a JFrame according to the given parameters, containing this EntityApplicationPanel
        Parameters:
        displayFrame - specifies whether the frame should be displayed or left invisible
        maximizeFrame - specifies whether the frame should be maximized or use it's preferred size
        frameSize - if the JFrame is not maximized then its preferredSize is set to this value
        mainMenu - yes if the main menu should be included
        Returns:
        an initialized, but non-visible JFrame
      • addOnExitListener

        protected final void addOnExitListener​(EventListener 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:
        createMainMenuControls()
      • createApplicationModel

        protected abstract M createApplicationModel​(EntityConnectionProvider connectionProvider)
        Creates the application model
        Parameters:
        connectionProvider - the connection provider
        Returns:
        an initialized application model
        Throws:
        CancelException - in case the initialization is cancelled
      • loginUser

        protected User loginUser​(User defaultUser,
                                 LoginDialogBuilder.LoginValidator loginValidator)
        Returns the user, either via a login dialog or via override, called during startup if login is required
        Parameters:
        defaultUser - the default user to display in the login dialog
        loginValidator - the user login validator
        Returns:
        the application user
        Throws:
        CancelException - in case a login dialog is cancelled
      • saveDefaultUsername

        protected void saveDefaultUsername​(String username)
        Saves the username so that it can be used as default the next time this application is started.
        Parameters:
        username - the username
      • defaultUsername

        protected String defaultUsername()
        Returns:
        a default username previously saved to user preferences or the OS username
      • applicationIdentifier

        protected String applicationIdentifier()
        Returns a String identifying the application this EntityApplicationPanel represents, by default the full class name is returned.
        Returns:
        a String identifying the application type this panel represents
      • 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:
        EntityApplicationModel.savePreferences()
      • getUser

        protected static User getUser​(String[] args)
        Looks up user credentials via a CredentialsProvider service using an authentication token found in the program arguments list. Useful for single sign on application launch.
        javaws -open authenticationToken:123-123-123 http://codion.is/demo/demo.jnlp
        java -jar application/getdown-1.7.1.jar app_dir app_id authenticationToken:123-123-123
        Parameters:
        args - the program arguments
        Returns:
        the User credentials associated with the authentication token, null if no authentication token is found, the user credentials have expired or if no authentication server is running