mirror of
https://github.com/praktimarc/kst4contest.git
synced 2026-11-19 01:52:29 +01:00
Run the setup wizard before an unconfigured profile's runtime is built
Written-by: Gemini 4 Hydrogen (Antigravity) Written-by: Claude Fable 5.2
This commit is contained in:
3 files changed
+66
No files matched your search
@@ -24,6 +24,13 @@ public final class ApplicationRuntimeLauncher {
|
||||
|
||||
private static Kst4ContestApplication currentRuntime;
|
||||
|
||||
/**
|
||||
* Whether the next runtime start shows the setup wizard although the profile is set up.
|
||||
* Set by the menu entry and cleared by the start that honours it.
|
||||
*/
|
||||
private static final java.util.concurrent.atomic.AtomicBoolean SETUP_WIZARD_REQUESTED =
|
||||
new java.util.concurrent.atomic.AtomicBoolean(false);
|
||||
|
||||
private ApplicationRuntimeLauncher() {
|
||||
// Utility class.
|
||||
}
|
||||
@@ -61,6 +68,20 @@ public final class ApplicationRuntimeLauncher {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
/** Asks the next runtime start to show the setup wizard. */
|
||||
static void requestSetupWizard() {
|
||||
SETUP_WIZARD_REQUESTED.set(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells a starting runtime whether the wizard was asked for, and forgets the request.
|
||||
*
|
||||
* @return true exactly once per request
|
||||
*/
|
||||
static boolean consumeSetupWizardRequest() {
|
||||
return SETUP_WIZARD_REQUESTED.getAndSet(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the running runtime with one bound to another operator profile.
|
||||
*
|
||||
|
||||
@@ -42,6 +42,8 @@ import kst4contest.view.compose.SettingsWindow;
|
||||
import kst4contest.controller.ScoreService;
|
||||
import kst4contest.view.compose.SettingsWindow;
|
||||
import kst4contest.controller.On4KstConnectionState;
|
||||
import kst4contest.view.compose.wizard.SetupWizardLauncher;
|
||||
import kst4contest.view.compose.wizard.SetupWizardOutcome;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -2177,6 +2179,17 @@ public class Kst4ContestApplication implements StatusUpdateListener, SettingsHos
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* The setup wizard, before anything of this profile's runtime exists. It writes
|
||||
* preferences.xml and the ChatController built below reads it like any stored
|
||||
* setting, so there is no running session to bring up to date and no reload.
|
||||
* Blocks until the wizard is closed; see SetupWizardWindow for why that is safe on
|
||||
* either thread this method is called from.
|
||||
*/
|
||||
SetupWizardOutcome setupWizardOutcome = SetupWizardLauncher.runIfNeeded(
|
||||
ActiveOperatorProfile.get().getPreferencesRelativeFileName(),
|
||||
ApplicationRuntimeLauncher.consumeSetupWizardRequest());
|
||||
|
||||
ApplicationRuntimeLauncher.setCurrent(this);
|
||||
|
||||
ApplicationFileUtils.copyResourceIfRequired(ApplicationConstants.APPLICATION_NAME, STYLE_DEFAULTCSSDAY_RESOURCE, STYLE_DEFAULTCSSDAY_FILE);
|
||||
@@ -2297,6 +2310,15 @@ public class Kst4ContestApplication implements StatusUpdateListener, SettingsHos
|
||||
//initialize the timeline
|
||||
uiDispatcher.runOnUi(this::updateTimelineVisuals);
|
||||
|
||||
/*
|
||||
* "Save and connect" in the setup wizard. Here and not earlier: connecting needs the
|
||||
* runtime this method has just finished building. The same path as File -> Connect,
|
||||
* so a refused or failed connection is reported the way it is there.
|
||||
*/
|
||||
if (setupWizardOutcome == SetupWizardOutcome.SAVED_AND_CONNECT) {
|
||||
uiDispatcher.runOnUi(this::menuActionConnect);
|
||||
}
|
||||
|
||||
/*
|
||||
* Replaces Application.stop(), which only JavaFX ever called. This covers a SIGTERM
|
||||
* and a closing terminal; the ordinary exit still goes through
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package kst4contest.view;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* The request to show the setup wizard on the next runtime start is honoured exactly once.
|
||||
* A request that stuck would open the wizard on every later profile switch.
|
||||
*/
|
||||
class ApplicationRuntimeLauncherSetupWizardTest {
|
||||
|
||||
@Test
|
||||
void aRequestIsHonouredOnce() {
|
||||
assertFalse(ApplicationRuntimeLauncher.consumeSetupWizardRequest(), "nothing was requested");
|
||||
|
||||
ApplicationRuntimeLauncher.requestSetupWizard();
|
||||
|
||||
assertTrue(ApplicationRuntimeLauncher.consumeSetupWizardRequest());
|
||||
assertFalse(ApplicationRuntimeLauncher.consumeSetupWizardRequest(), "the request must not stick");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user