Interface EntityApplication<M extends SwingEntityApplicationModel,P extends EntityApplicationPanel<M>>

Type Parameters:
M - the application model type
P - the application panel type

public interface EntityApplication<M extends SwingEntityApplicationModel,P extends EntityApplicationPanel<M>>
Builds a and starts an application.
See Also:
  • Field Details

    • USER

      static final PropertyValue<String> USER
      Specifies the user for logging into the application on the form user:password. If one is specified no login dialog is presented.

      Initialized with the value of the CODION_CLIENT_USER environment variable.

      Warning: System properties are visible in process listings. Use only for development/testing. In production, use secure credential management.

      • Value type: String
      • Default value: System.getenv("CODION_CLIENT_USER")
      See Also:
    • SAVE_DEFAULT_USERNAME

      static final PropertyValue<Boolean> SAVE_DEFAULT_USERNAME
      Specifies whether the client saves the last successful login username, which is then displayed as the default username the next time the application is started
      • Value type: Boolean
      • Default value: true
    • STARTUP_DIALOG

      static final PropertyValue<Boolean> STARTUP_DIALOG
      Specifies whether a startup dialog should be shown
      • Value type: Boolean
      • Default value: true
  • Method Details

    • domain

      EntityApplication<M,P> domain(DomainType domain)
      Parameters:
      domain - the domain type
      Returns:
      this Builder instance
    • name

      EntityApplication<M,P> name(String name)

      Sets the application name, used as frame title and client type identifier when using remote connnections.

      If no application name is set, DomainType.name() is used or applicationPanelClass.getSimpleName() in case of no domain model.

      Parameters:
      name - the application name
      Returns:
      this Builder instance
    • icon

      Parameters:
      icon - the application icon
      Returns:
      this Builder instance
    • version

      EntityApplication<M,P> version(Version version)
      Parameters:
      version - the application version
      Returns:
      this Builder instance
    • defaultLookAndFeel

      EntityApplication<M,P> defaultLookAndFeel(Class<? extends LookAndFeel> defaultLookAndFeelClass)
      Sets the default look and feel class, used in case no look and feel settings are found in user preferences.
      Parameters:
      defaultLookAndFeelClass - the default look and feel class
      Returns:
      this Builder instance
      See Also:
    • defaultLookAndFeel

      EntityApplication<M,P> defaultLookAndFeel(String defaultLookAndFeelClassName)
      Sets the default look and feel classname, used in case no look and feel settings are found in user preferences.
      Parameters:
      defaultLookAndFeelClassName - the default look and feel classname
      Returns:
      this Builder instance
      See Also:
    • lookAndFeel

      EntityApplication<M,P> lookAndFeel(Class<? extends LookAndFeel> lookAndFeelClass)
      Sets the look and feel class, overrides any look and feel settings found in user preferences.
      Parameters:
      lookAndFeelClass - the look and feel class
      Returns:
      this Builder instance
      See Also:
    • lookAndFeel

      EntityApplication<M,P> lookAndFeel(String lookAndFeelClassName)
      Sets the look and feel classname, overrides any look and feel settings found in user preferences.
      Parameters:
      lookAndFeelClassName - the look and feel classname
      Returns:
      this Builder instance
      See Also:
    • connectionProvider

      EntityApplication<M,P> connectionProvider(EntityConnectionProvider connectionProvider)
      Parameters:
      connectionProvider - the connection provider
      Returns:
      this Builder instance
    • connectionProvider

      EntityApplication<M,P> connectionProvider(Function<User,EntityConnectionProvider> connectionProvider)
      Parameters:
      connectionProvider - initializes the connection provider, receives the user provided by user(Supplier)
      Returns:
      this Builder instance
    • model

      Parameters:
      model - the application model factory
      Returns:
      this Builder instance
    • panel

      EntityApplication<M,P> panel(Function<M,P> panel)
      Parameters:
      panel - the application panel factory
      Returns:
      this Builder instance
    • user

      The User to use to connect to the database, this user is propagated to connectionProvider(Function).

      If this user is null, user(Supplier) is used to fetch a user.

      Parameters:
      user - the application user
      Returns:
      this Builder instance
      See Also:
    • user

      EntityApplication<M,P> user(Supplier<User> userSupplier)

      Supplies the User to use to connect to the database, this user is then propagated to connectionProvider(Function).

      This may be via a login dialog or simply by returning a hardcoded instance.

      Startup is silently cancelled in case the Supplier.get() throws a CancelException.

      Parameters:
      userSupplier - supplies the application user, for example via a login dialog
      Returns:
      this Builder instance
    • defaultUser

      EntityApplication<M,P> defaultUser(@Nullable User defaultUser)
      Parameters:
      defaultUser - the default user credentials to display in a login dialog
      Returns:
      this Builder instance
    • saveDefaultUsername

      EntityApplication<M,P> saveDefaultUsername(boolean saveDefaultUsername)
      Parameters:
      saveDefaultUsername - true if the username should be saved in user preferences after a successful login
      Returns:
      this Builder instance
    • loginPanelSouthComponent

      EntityApplication<M,P> loginPanelSouthComponent(Supplier<JComponent> loginPanelSouthComponentSupplier)
      Note that this does not apply when a custom user(Supplier) has been specified.
      Parameters:
      loginPanelSouthComponentSupplier - supplies the component to add to the BorderLayout.SOUTH position of the default login panel
      Returns:
      this Builder instance
    • onStarting

      EntityApplication<M,P> onStarting(@Nullable Runnable onStarting)
      Runs as the application is starting, but after Look and Feel initialization. Throw CancelException in order to cancel the application startup.
      Parameters:
      onStarting - run before the application is started
      Returns:
      this Builder instance
    • onStarted

      EntityApplication<M,P> onStarted(@Nullable Consumer<P> onStarted)
      Parameters:
      onStarted - called after a successful application start
      Returns:
      this Builder instance
    • frame

      Parameters:
      frame - the supplies the frame to use
      Returns:
      this Builder instance
    • frameTitle

      EntityApplication<M,P> frameTitle(String frameTitle)
      Parameters:
      frameTitle - the frame title
      Returns:
      this Builder instance
    • frameTitle

      EntityApplication<M,P> frameTitle(Observable<String> frameTitle)
      For a dynamic frame title.
      Parameters:
      frameTitle - the observable controlling the frame title
      Returns:
      this Builder instance
    • maximizeFrame

      EntityApplication<M,P> maximizeFrame(boolean maximizeFrame)
      Parameters:
      maximizeFrame - specifies whether the frame should be maximized or use its preferred size
      Returns:
      this Builder instance
    • displayFrame

      EntityApplication<M,P> displayFrame(boolean displayFrame)
      Parameters:
      displayFrame - specifies whether the frame should be displayed or left invisible
      Returns:
      this Builder instance
    • uncaughtExceptionHandler

      EntityApplication<M,P> uncaughtExceptionHandler(boolean uncaughtExceptionHandler)
      Specifies whether to set the default uncaught exception handler when starting the application, true by default.
      Parameters:
      uncaughtExceptionHandler - if true the default uncaught exception handler is set on application start
      Returns:
      this Builder instance
      See Also:
    • startupDialog

      EntityApplication<M,P> startupDialog(boolean startupDialog)
      Parameters:
      startupDialog - if true then a progress dialog is displayed while the application is being initialized
      Returns:
      this Builder instance
    • frameSize

      EntityApplication<M,P> frameSize(@Nullable Dimension frameSize)
      Parameters:
      frameSize - the frame size when not maximized
      Returns:
      this Builder instance
    • defaultFrameSize

      EntityApplication<M,P> defaultFrameSize(@Nullable Dimension defaultFrameSize)
      Parameters:
      defaultFrameSize - the default frame size when no previous size is available in user preferences
      Returns:
      this Builder instance
    • start

      void start()
      Starts the application on the Event Dispatch Thread.
    • start

      void start(boolean onEventDispatchThread)
      Starts the application.
      Parameters:
      onEventDispatchThread - if true then startup is performed on the Event Dispatch Thread
    • builder

      static <M extends SwingEntityApplicationModel, P extends EntityApplicationPanel<M>> EntityApplication<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 EntityApplication