Run Designer previews with application-owned DI adapters
This commit is contained in:
+52
@@ -0,0 +1,52 @@
|
||||
package de.neitzel.fxdesigner.standalone;
|
||||
|
||||
import de.neitzel.fxdesigner.kit.DesignerPane;
|
||||
import de.neitzel.fxdesigner.workflow.HostLaunch;
|
||||
import de.neitzel.fxdesigner.kit.SpringPreviewHostChecks;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import static de.neitzel.fxdesigner.kit.SpringPreviewHostChecks.fx;
|
||||
|
||||
public final class SpringPreviewHostSmoke {
|
||||
public static void main(String[] args) throws Exception {
|
||||
var launch = HostLaunch.load(Path.of(args[0]));
|
||||
Platform.startup(() -> Platform.setImplicitExit(false));
|
||||
var book = Path.of(args[1]);
|
||||
var output = Path.of(args[2]);
|
||||
try (var host = new StandaloneHost(launch.runtimes(),
|
||||
location -> CompletableFuture.completedFuture(null),
|
||||
diagnostic -> System.out.println(diagnostic.message()))) {
|
||||
verify(host, launch, book, "Spring contact book", true, output);
|
||||
verify(host, launch, book.resolveSibling("EntryCard.fxml"), "Spring entry", false, output);
|
||||
Files.writeString(output.resolve("SUCCESS.txt"),
|
||||
"PASS Spring canvas, form and interactive previews in standalone");
|
||||
} finally {
|
||||
Platform.exit();
|
||||
}
|
||||
}
|
||||
|
||||
private static void verify(StandaloneHost host, HostLaunch launch, Path file, String label, boolean book, Path output)
|
||||
throws Exception {
|
||||
var stage = fx(Stage::new);
|
||||
var pane = fx(() -> {
|
||||
var editor = new DesignerPane(host.services(), launch, file);
|
||||
stage.setScene(new Scene(editor, 1300, 850));
|
||||
stage.show();
|
||||
return editor;
|
||||
});
|
||||
try {
|
||||
SpringPreviewHostChecks.verify(pane, label, book, output);
|
||||
} finally {
|
||||
fx(() -> {
|
||||
pane.close();
|
||||
stage.close();
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user