java.lang.Object
de.seggebaeing.sqlanalyzer.presentation.uielements.window.TitledInitializableWindow
de.seggebaeing.sqlanalyzer.presentation.uielements.window.WorkerWindow
All Implemented Interfaces:
javafx.fxml.Initializable
Direct Known Subclasses:
EvaluationController, GenerationController

public abstract class WorkerWindow extends TitledInitializableWindow
Abstract base controller for long-running worker windows. Provides common wiring for Settings/Start/Cancel/Save actions, manages a Thread via workerProperty, and offers helpers to display progress (dual progress bars with optional retry countdown). Handles start validation, cancellation/cleanup, and enabling Save on completion. Intended for FXML controllers on the JavaFX Application Thread.
Since:
1.0
Author:
Felix Seggebäing
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final javafx.beans.property.ObjectProperty<Thread>
    Holds the currently running worker thread; null means idle.

    Fields inherited from class de.seggebaeing.sqlanalyzer.presentation.uielements.window.TitledInitializableWindow

    root
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addDualProgressBar(String title, javafx.beans.value.ObservableValue<Number> startedProgress, javafx.beans.value.ObservableValue<Number> finishedProgress, javafx.beans.value.ObservableValue<Instant> retryInTarget)
    Adds a progress row consisting of a DualProgressBar bound to started/finished progress and, optionally, a CountdownLabel that counts down until the next retry.
    protected abstract Thread
    Creates the background worker thread for the long-running task.
    void
    initialize(URL location, ResourceBundle resources)
    Initializes header and button handlers, and wires UI enablement to the worker state: Start is disabled while a worker runs; Cancel is enabled only when a worker exists.
    protected abstract void
    Handles the Save action once the worker has completed.
    protected abstract void
    Opens the settings UI for configuring the worker before start.
    void
    Marks the worker as completed by enabling the Save button.
    protected abstract boolean
    Validates whether the worker can be started (e.g., required settings provided).

    Methods inherited from class de.seggebaeing.sqlanalyzer.presentation.uielements.window.TitledInitializableWindow

    closeWindow, enableHelp, getRoot, getStage, getTitle

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • workerProperty

      protected final javafx.beans.property.ObjectProperty<Thread> workerProperty
      Holds the currently running worker thread; null means idle. UI buttons bind to this to enable/disable Start/Cancel appropriately.
  • Constructor Details

    • WorkerWindow

      public WorkerWindow()
  • Method Details

    • initialize

      public void initialize(URL location, ResourceBundle resources)
      Initializes header and button handlers, and wires UI enablement to the worker state: Start is disabled while a worker runs; Cancel is enabled only when a worker exists.
      Parameters:
      location - FXML location (may be null)
      resources - localization bundle (may be null)
      Implementation Note:
      Invoked by the FXML loader on the JavaFX Application Thread.
    • signalDone

      public void signalDone()
      Marks the worker as completed by enabling the Save button. Safe to invoke from a background thread; delegates to the JavaFX Application Thread via Platform.runLater(Runnable).
      Implementation Note:
      Keep aligned with worker lifecycle callbacks.
    • addDualProgressBar

      protected void addDualProgressBar(String title, javafx.beans.value.ObservableValue<Number> startedProgress, javafx.beans.value.ObservableValue<Number> finishedProgress, javafx.beans.value.ObservableValue<Instant> retryInTarget)
      Adds a progress row consisting of a DualProgressBar bound to started/finished progress and, optionally, a CountdownLabel that counts down until the next retry.
      Parameters:
      title - label shown beneath the progress bar
      startedProgress - observable in [0,1] driving the grey “started” fill
      finishedProgress - observable in [0,1] driving the red “finished” fill
      retryInTarget - optional observable target instant for the retry countdown; null to omit
      Implementation Note:
      Binds to the provided observables and appends the row to content. Invoke on the JavaFX Application Thread.
    • startValid

      protected abstract boolean startValid()
      Validates whether the worker can be started (e.g., required settings provided).
      Returns:
      true if preconditions are satisfied; false otherwise
      Implementation Note:
      Called before creating the worker thread.
    • saveBtnClick

      protected abstract void saveBtnClick()
      Handles the Save action once the worker has completed. Implementations should persist/export results and update the UI as needed.
      Implementation Note:
      Invoked by the Save button; run on the JavaFX Application Thread.
    • showSettingsPopup

      protected abstract void showSettingsPopup()
      Opens the settings UI for configuring the worker before start.
    • createWorkerThread

      protected abstract Thread createWorkerThread()
      Creates the background worker thread for the long-running task. The returned thread should do work off the FX thread, respect interruption, publish progress via bound observables, and call signalDone() on success.
      Returns:
      a new, not-yet-started Thread to be started by the framework
      Implementation Note:
      Perform UI updates via Platform.runLater(Runnable).