java.lang.Object
de.seggebaeing.sqlanalyzer.presentation.util.WindowManager

public class WindowManager extends Object
Centralized window and navigation manager for the JavaFX de.seggebaeing.sqlanalyzer.presentation layer. This class bootstraps the primary (Home) stage, opens typed windows (general workflow, BDO overviews, BDO details, and Help), wires FXML to custom controllers, and coordinates lifecycle and refresh behavior across stages.

Threading: All public methods must be called on the JavaFX Application Thread. This class is not thread-safe.

Since:
1.0
Author:
Felix Seggebäing
  • Constructor Details

    • WindowManager

      public WindowManager()
  • Method Details

    • start

      public static void start(javafx.stage.Stage primaryStage)
      Bootstraps the primary (Home) stage and hands control to the WindowManager.

      Loads the Home FXML with a HomeController, sets standardized title & icon (via loadFxmlInto(Stage, String, TitledInitializableWindow)), shows the stage, and enforces a minimum size based on the root node’s preferred size. The Home stage cannot be closed; its close request is consumed and the stage is hidden instead. If it is closed while no other non-help stages are visible, the application terminates via System.exit(0).

      Threading: Must be called on the JavaFX Application Thread.

      Parameters:
      primaryStage - the primary JavaFX stage provided by the runtime
      Throws:
      IllegalStateException - if the WindowManager has already been initialized
    • openWindow

      public static void openWindow(GeneralWindowType windowType)
      Opens a general-purpose window (e.g., Generation/Evaluation worker or Settings) based on the given GeneralWindowType.

      Resolves the FXML name via GeneralWindowType.getFxmlName(), creates the corresponding controller via ControllerFactory.createGeneralController(GeneralWindowType), and delegates to initializeAndShow(TitledInitializableWindow, String, boolean) with resizable=true. Title, icon, and scene are applied during initialization. Failures during FXML/controller loading are logged and the window will not be shown.

      Threading: Must be called on the JavaFX Application Thread.

      Parameters:
      windowType - the type of general window to open; must not be null
    • openOverview

      public static void openOverview(BdoWindowType bdoWindowType, Predicate<? extends BusinessDomainObject> filter)
      Opens an Overview window for the given BdoWindowType and registers it for centralized refresh.

      Uses the shared overview.fxml and a type-specific controller created via ControllerFactory.createOverviewController(BdoWindowType, java.util.function.Predicate). The controller is tracked internally so refreshOverviewsFor(BdoWindowType) can update all open overviews of the same type. The controller is automatically untracked when its window hides, preventing leaks. The window is shown resizable.

      External filter: An optional predicate may be provided to pre-filter items in the UI; it may be null to omit external filtering.

      Threading: Must be called on the JavaFX Application Thread.

      Parameters:
      bdoWindowType - the kind of BDO overview to open; must not be null
      filter - optional external filter applied by the overview; may be null
    • openDetails

      public static void openDetails(BusinessDomainObject bdo)
      Opens a Details window for the specified BusinessDomainObject.

      Determines the FXML via BdoWindowType.getForType(Class) and creates the appropriate controller using ControllerFactory.createDetailsController(BusinessDomainObject). Delegates to initializeAndShow(TitledInitializableWindow, String, boolean) with resizable=true; title, icon, and scene are applied during initialization.

      Threading: Must be called on the JavaFX Application Thread.

      Parameters:
      bdo - the domain object to view or edit; must not be null
      Throws:
      NullPointerException - if bdo is null
      IllegalArgumentException - if no BdoWindowType is registered for the object’s class
    • showHelpWindow

      public static void showHelpWindow(String htmlFileName)
      Opens a non-resizable Help window and loads the specified help HTML.

      Shows help.fxml with a new HelpWindow controller, then resolves the HTML via ResourceLoader.getHelpHtmlUrl(String) and calls HelpWindow.loadHtml(String) with the URL’s external form. If the resource cannot be found, an error is logged and the window remains in its default state.

      Threading: Must be called on the JavaFX Application Thread.

      Parameters:
      htmlFileName - help key or file name (typically without .html); if no resource is found, content is not loaded and an error is logged
    • refreshOverviewsFor

      public static void refreshOverviewsFor(BdoWindowType windowType)
      Triggers a UI refresh on all currently open Overview windows of the given type.

      Looks up tracked controllers in the internal registry and invokes OverviewWindow.refresh() on each. If no overview windows are registered for the type, this method is a no-op.

      Threading: Must be called on the JavaFX Application Thread.

      Parameters:
      windowType - the overview category to refresh; must not be null