Class EntityApplicationPanel<M extends SwingEntityApplicationModel>

    • Field Detail

      • 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.displayEntityPanelDialog method should be persisted, or kept in memory, when the dialog is closed, instead of being created each time.
        Value type: Boolean
        Default value: false
        See Also:
        displayEntityPanelDialog(EntityPanelBuilder)
      • TAB_PLACEMENT

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

      • EntityApplicationPanel

        public EntityApplicationPanel()
        A default constructor
      • EntityApplicationPanel

        public EntityApplicationPanel​(Supplier<JFrame> frameProvider)
    • Method Detail

      • displayException

        public final void displayException​(Throwable exception,
                                           Window dialogParent)
        Handle the given exception and display it to the user.
        Specified by:
        displayException in interface DialogExceptionHandler
        Parameters:
        exception - the exception
        dialogParent - the Window to use as parent to the exception dialog
      • getModel

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

        public final EntityApplicationPanel<M> addEntityPanelBuilders​(EntityPanelBuilder... panelBuilders)
        Adds main application panels, displayed on application start
        Parameters:
        panelBuilders - the main application panel providers
        Returns:
        this application panel instance
      • addEntityPanelBuilder

        public final EntityApplicationPanel<M> addEntityPanelBuilder​(EntityPanelBuilder panelBuilder)
        Adds a main application panel, displayed on application start
        Parameters:
        panelBuilder - the main application panel provider
        Returns:
        this application panel instance
      • addSupportPanelBuilders

        public final EntityApplicationPanel<M> addSupportPanelBuilders​(EntityPanelBuilder... panelBuilders)
        Adds support application panels, available via a support panel menu
        Parameters:
        panelBuilders - the support application panel providers
        Returns:
        this application panel instance
      • addSupportPanelBuilder

        public final EntityApplicationPanel<M> addSupportPanelBuilder​(EntityPanelBuilder panelBuilder)
        Adds a support application panel, available via a support panel menu
        Parameters:
        panelBuilder - the support application panel provider
        Returns:
        this application panel instance
      • getEntityPanel

        public final EntityPanel getEntityPanel​(String entityId)
        Parameters:
        entityId - the entity ID
        Returns:
        the first entity panel found based on the given entity type, null if none is found
      • getEntityPanels

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

        public final Window getParentWindow()
        Returns:
        the parent window of this panel, if one exists, null otherwise
      • isAlwaysOnTop

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

        public final void logout()
        Performs a logout
      • 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
      • selectLookAndFeel

        public final void selectLookAndFeel()
        Allows the user the select between the system and cross platform Look and Feel, activated on next appliation start
      • selectFontSize

        public final void selectFontSize()
        Display a dialog for selecting the application font size
      • startApplication

        public final JFrame startApplication​(String frameCaption,
                                             String iconName,
                                             boolean maximize,
                                             Dimension frameSize)
        Starts this application.
        Parameters:
        frameCaption - the caption to display on the frame
        iconName - the name of the icon to use
        maximize - if true the application frame is maximized on startup
        frameSize - the frame size when not maximized
        Returns:
        the JFrame instance containing this application panel
      • startApplication

        public final JFrame startApplication​(String frameCaption,
                                             String iconName,
                                             boolean maximize,
                                             Dimension frameSize,
                                             User defaultUser)
        Starts this application.
        Parameters:
        frameCaption - the caption to display on the frame
        iconName - the name of the icon to use
        maximize - if true the application frame is maximized on startup
        frameSize - the frame size when not maximized
        defaultUser - the default user to display in the login dialog
        Returns:
        the JFrame instance containing this application panel
      • startApplication

        public final JFrame startApplication​(String frameCaption,
                                             String iconName,
                                             boolean maximize,
                                             Dimension frameSize,
                                             User defaultUser,
                                             boolean showFrame)
        Starts this application.
        Parameters:
        frameCaption - the caption to display on the frame
        iconName - the name of the icon to use
        maximize - if true the application frame is maximized on startup
        frameSize - the frame size when not maximized
        defaultUser - the default user to display in the login dialog
        showFrame - if true the frame is set visible
        Returns:
        the JFrame instance containing this application panel
      • startApplication

        public final JFrame startApplication​(String frameCaption,
                                             String iconName,
                                             boolean maximize,
                                             Dimension frameSize,
                                             User defaultUser,
                                             boolean showFrame,
                                             User silentLoginUser)
        Starts this application.
        Parameters:
        frameCaption - the caption to display on the frame
        iconName - the name of the icon to use
        maximize - if true the application frame is maximized on startup
        frameSize - the frame size when not maximized
        defaultUser - the default user to display in the login dialog
        showFrame - if true the frame is set visible
        silentLoginUser - if specified the application is started silently with that user, displaying no login or progress dialog
        Returns:
        the JFrame instance containing this application panel
      • getSelectedChildPanel

        public final EntityPanel getSelectedChildPanel()
        Specified by:
        getSelectedChildPanel in interface HierarchyPanel
        Returns:
        a child panel, if one exists, which child panel exactly is up the implementation
      • setSelectedChildPanel

        public final void setSelectedChildPanel​(HierarchyPanel childPanel)
        Activates (and shows) the given child panel
        Specified by:
        setSelectedChildPanel in interface HierarchyPanel
        Parameters:
        childPanel - the child panel to activate and show
      • activatePanel

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

        public final void displayHelp()
        Shows a help dialog
        See Also:
        getHelpPanel()
      • displayAbout

        public final void displayAbout()
        Shows an about dialog
        See Also:
        getAboutPanel()
      • 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​(EventListener listener)
        Parameters:
        listener - a listener notified when to application has been successfully started
      • removeApplicationStartedListener

        public final void removeApplicationStartedListener​(EventListener listener)
        Parameters:
        listener - the listener to remove
      • getDependencyTreeModel

        public final TreeModel getDependencyTreeModel()
        Returns:
        a tree model showing the dependencies between entities via foreign keys
      • getApplicationTabPane

        protected final JTabbedPane getApplicationTabPane()
        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
      • getFileControlSet

        protected ControlSet getFileControlSet()
        Returns:
        the ControlSet specifying the items in the 'File' menu
      • getSettingsControlSet

        protected ControlSet getSettingsControlSet()
        Returns:
        the ControlSet specifying the items in the 'Settings' menu
      • getToolsControlSet

        protected ControlSet getToolsControlSet()
        Returns:
        the ControlSet specifying the items in the 'Tools' menu
      • getViewControlSet

        protected ControlSet getViewControlSet()
        Returns:
        the ControlSet specifying the items in the 'View' menu
      • getHelpControlSet

        protected ControlSet getHelpControlSet()
        Returns:
        the ControlSet 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
      • createSelectLookAndFeelControl

        protected final Control createSelectLookAndFeelControl()
        Returns:
        a Control for selecting the application look and feel
      • 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
      • getHelpPanel

        protected JPanel getHelpPanel()
        Returns:
        the panel shown when Help -> Help is selected
      • getHelpText

        protected String getHelpText()
                              throws IOException
        Returns:
        the text to show in the help panel
        Throws:
        IOException - in case of an IO exception
      • getAboutPanel

        protected JPanel getAboutPanel()
        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
      • getClientVersion

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

        protected final void initialize​(M applicationModel)
        Initializes this application panel
        Parameters:
        applicationModel - the application model
        Throws:
        IllegalStateException - if the application model has not been set
        CancelException - in case the initialization is cancelled
      • bindEvents

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

        protected List<ControlSet> getAdditionalMenuControlSet()
        Returns:
        a List of ControlSet objects which are to be added to the main menu bar
      • getSupportTableControlSet

        protected ControlSet getSupportTableControlSet()
        Returns:
        the ControlSet on which the Support Tables menu item is based on
      • displayEntityPanelDialog

        protected final void displayEntityPanelDialog​(EntityPanelBuilder panelProvider)
        Shows a dialog containing the entity panel provided by the given panel provider
        Parameters:
        panelProvider - the entity panel provider
      • displayEntityPanelDialog

        protected final void displayEntityPanelDialog​(EntityPanelBuilder panelProvider,
                                                      boolean modalDialog)
        Shows a dialog containing the entity panel provided by the given panel provider
        Parameters:
        panelProvider - the entity panel provider
        modalDialog - if true the dialog is made modal
      • initializeUI

        protected void initializeUI()
        Initializes this EntityApplicationPanel
      • isLoginRequired

        protected final boolean isLoginRequired()
        Returns:
        true if a login dialog is required for this application, false if the user is supplied differently
      • setLoginRequired

        protected final void setLoginRequired​(boolean loginRequired)
        Sets whether or not this application requires a login dialog, setting this value after the application has been started has no effect
        Parameters:
        loginRequired - the login required status
      • isShowStartupDialog

        protected final boolean isShowStartupDialog()
        Returns:
        true if a startup dialog should be shown
      • setShowStartupDialog

        protected final void setShowStartupDialog​(boolean startupDialog)
        Parameters:
        startupDialog - true if a startup dialog should be shown
      • getDefaultFontSize

        protected Integer getDefaultFontSize()
        Returns:
        the default font size multiplier
        See Also:
        selectFontSize()
      • initializeNorthPanel

        protected JPanel initializeNorthPanel()
        Initializes 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
      • initializeSouthPanel

        protected JPanel initializeSouthPanel()
        Initializes 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
      • initializeStartupProgressPanel

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

        protected String getFrameTitle​(String frameCaption,
                                       EntityConnectionProvider connectionProvider)
        Parameters:
        frameCaption - the caption for the frame
        connectionProvider - the EntityConnectionProvider this application is using
        Returns:
        a frame title based on the logged in user
      • prepareFrame

        protected final JFrame prepareFrame​(String title,
                                            boolean maximize,
                                            boolean showMenuBar,
                                            Dimension size,
                                            ImageIcon applicationIcon,
                                            boolean setVisible)
        Initializes a JFrame according to the given parameters, containing this EntityApplicationPanel
        Parameters:
        title - the title string for the JFrame
        maximize - if true then the JFrame is maximized, overrides the prefSeizeAsRatioOfScreen parameter
        showMenuBar - true if a menubar should be created
        size - if the JFrame is not maximized then its preferredSize is set to this value
        applicationIcon - the application icon
        setVisible - if true then the JFrame is set visible
        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
      • initializeMenuBar

        protected JMenuBar initializeMenuBar()
        Initializes the JMenuBar to use on the application Frame
        Returns:
        by default a JMenuBar based on the main menu control set
        See Also:
        getMainMenuControlSet()
      • initializeApplicationModel

        protected abstract M initializeApplicationModel​(EntityConnectionProvider connectionProvider)
        Initializes the application model
        Parameters:
        connectionProvider - the db provider
        Returns:
        an initialized application model
        Throws:
        CancelException - in case the initialization is cancelled
      • getUser

        protected User getUser​(String frameCaption,
                               User defaultUser,
                               ImageIcon applicationIcon)
        Returns the user, either via a login dialog or via override, called during startup
        Parameters:
        frameCaption - the application frame caption
        defaultUser - the default user
        applicationIcon - the application icon
        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
      • getDefaultUsername

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

        protected String getApplicationIdentifier()
        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://jminor.org/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