Module de.seggebaeing.sqlanalyzer
Class WorkerWindow
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
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
FieldsModifier and TypeFieldDescriptionprotected 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 -
Method Summary
Modifier and TypeMethodDescriptionprotected 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 aDualProgressBar
bound to started/finished progress and, optionally, aCountdownLabel
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
-
Field Details
-
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
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 benull
)resources
- localization bundle (may benull
)- 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 viaPlatform.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 aDualProgressBar
bound to started/finished progress and, optionally, aCountdownLabel
that counts down until the next retry.- Parameters:
title
- label shown beneath the progress barstartedProgress
- observable in[0,1]
driving the grey “started” fillfinishedProgress
- observable in[0,1]
driving the red “finished” fillretryInTarget
- 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
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 callsignalDone()
on success.- Returns:
- a new, not-yet-started
Thread
to be started by the framework - Implementation Note:
- Perform UI updates via
Platform.runLater(Runnable)
.
-