Discover Converter capabilities and validate shared binding drafts

This commit is contained in:
2026-11-13 12:58:08 +01:00
parent 17b1bce704
commit 5a208d2336
35 changed files with 1096 additions and 34 deletions
@@ -115,6 +115,10 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
private DesignerWorkflow bindingWorkflow;
private BindingBrowser bindingBrowser;
private DirectBindingEditor bindingEditor;
private String validatedSource, validatingSource;
private boolean validationPreview;
private java.util.List<de.neitzel.fxdesigner.protocol.BindingMetadata.Problem> bindingProblems =
java.util.List.of();
private Tab directBindingTab;
private long bindingRequest;
private boolean interactiveRequested, interactiveRestart;
@@ -182,7 +186,8 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
if (kit.editor().getFxomDocument() == null) return;
var target = new FXOMFxIdIndex(kit.editor().getFxomDocument()).lookup(id);
if (target != null) kit.editor().getSelection().select(target);
});
},
values -> validateBindings(values, false));
bindingBrowser =
new BindingBrowser(
this::discoverBindings,
@@ -639,6 +644,9 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
private void invalidateBindings(String message) {
bindingRequest++;
validatedSource = null;
validatingSource = null;
validationPreview = false;
bindingWorkflow.cancel();
bindingBrowser.invalidate(message);
}
@@ -682,10 +690,66 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
return false;
}
private void validateBindings(DirectBindingDocument.Values values, boolean preview) {
withDraft(
() -> {
if (preview && draft.text().equals(validatingSource)) {
validationPreview = true;
return;
}
long ticket = ++bindingRequest;
var captured = draft;
validatingSource = captured.text();
validationPreview |= preview;
status.setText("Validating binding types in target runtime…");
bindingWorkflow
.bindingDetails(
last,
captured,
values == null ? "" : values.path(),
values == null ? "both" : values.direction(),
values == null ? "" : values.control(),
values == null ? "" : values.property())
.whenComplete(
(metadata, error) ->
fx(
() -> {
if (closed
|| ticket != bindingRequest
|| draft.revision() != captured.revision()) return;
validatingSource = null;
boolean resumePreview = validationPreview;
validationPreview = false;
if (error != null) {
status.setText(
"Binding validation unavailable: " + error.getMessage());
return;
}
validatedSource = captured.text();
bindingProblems = metadata.problems();
bindingEditor.metadata(
metadata,
values,
(last
? "Explicit retained build (outdated)"
: "Current successful build")
+ " · draft revision "
+ captured.revision());
status.setText(
"Binding validation complete: "
+ metadata.problems().size()
+ " diagnostics");
if (resumePreview) render();
}));
});
}
private void discoverBindings(String path, String direction) {
withDraft(
() -> {
long ticket = ++bindingRequest;
validatingSource = null;
validationPreview = false;
bindingBrowser.invalidate("Discovering declared types in target runtime…");
var captured = draft;
bindingWorkflow
@@ -803,6 +867,19 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
withDraft(
() -> {
if (!bindingPreviewAllowed()) return;
if (!draft.text().equals(validatedSource)) {
validateBindings(null, true);
return;
}
if (bindingProblems.stream().anyMatch(p -> p.severity().equals("ERROR"))) {
status.setText(
"Preview blocked: "
+ bindingProblems.stream()
.filter(p -> p.severity().equals("ERROR"))
.map(p -> p.message())
.collect(java.util.stream.Collectors.joining("; ")));
return;
}
var selected = examples.getValue();
if (selected == null || projection == null) return;
long ticket = renderSequence.incrementAndGet();