Discover custom ViewModels and validate Computed bindings in shared hosts
This commit is contained in:
@@ -11,6 +11,7 @@ final class BindingBrowser extends VBox {
|
||||
final ComboBox<BindingMetadata.Attribute> paths = new ComboBox<>();
|
||||
final ComboBox<String> directions = new ComboBox<>();
|
||||
final TableView<BindingMetadata.Target> targets = new TableView<>();
|
||||
final ListView<BindingMetadata.Computed> methods = new ListView<>();
|
||||
final Label status = new Label("Build and Refresh, then discover binding targets.");
|
||||
private boolean updating;
|
||||
|
||||
@@ -21,6 +22,8 @@ final class BindingBrowser extends VBox {
|
||||
directions.setId("binding-direction");
|
||||
targets.setId("binding-targets");
|
||||
status.setId("binding-status");
|
||||
methods.setId("computed-methods");
|
||||
methods.setPrefHeight(100);
|
||||
paths.setPrefWidth(320);
|
||||
directions.getItems().setAll("view", "model", "both");
|
||||
directions.setValue("both");
|
||||
@@ -62,7 +65,9 @@ final class BindingBrowser extends VBox {
|
||||
8, refresh, new Label("Model path"), paths, new Label("Direction"), directions),
|
||||
status,
|
||||
targets,
|
||||
use);
|
||||
use,
|
||||
new Label("Computed sources (public Controller methods)"),
|
||||
methods);
|
||||
}
|
||||
|
||||
private String path() {
|
||||
@@ -77,8 +82,16 @@ final class BindingBrowser extends VBox {
|
||||
}
|
||||
|
||||
void invalidate(String message) {
|
||||
targets.getItems().clear();
|
||||
status.setText(message);
|
||||
updating = true;
|
||||
try {
|
||||
paths.getItems().clear();
|
||||
paths.setValue(null);
|
||||
targets.getItems().clear();
|
||||
methods.getItems().clear();
|
||||
status.setText(message);
|
||||
} finally {
|
||||
updating = false;
|
||||
}
|
||||
}
|
||||
|
||||
void show(BindingMetadata metadata, String provenance) {
|
||||
@@ -92,9 +105,14 @@ final class BindingBrowser extends VBox {
|
||||
.orElse(null));
|
||||
directions.setValue(metadata.direction());
|
||||
targets.getItems().setAll(metadata.targets());
|
||||
methods.getItems().setAll(metadata.computed());
|
||||
status.setText(
|
||||
"Model: "
|
||||
+ metadata.model()
|
||||
+ " · ViewModel: "
|
||||
+ metadata.viewModel()
|
||||
+ " · Controller: "
|
||||
+ metadata.controller()
|
||||
+ " · "
|
||||
+ provenance
|
||||
+ "\n"
|
||||
|
||||
@@ -748,17 +748,22 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
|
||||
withDraft(
|
||||
() -> {
|
||||
long ticket = ++bindingRequest;
|
||||
validatingSource = null;
|
||||
validationPreview = false;
|
||||
|
||||
bindingBrowser.invalidate("Discovering declared types in target runtime…");
|
||||
var captured = draft;
|
||||
validatingSource = captured.text();
|
||||
bindingWorkflow
|
||||
.bindings(last, captured, path, direction)
|
||||
.whenComplete(
|
||||
(metadata, error) ->
|
||||
fx(
|
||||
() -> {
|
||||
if (closed || ticket != bindingRequest) return;
|
||||
if (closed
|
||||
|| ticket != bindingRequest
|
||||
|| draft.revision() != captured.revision()) return;
|
||||
validatingSource = null;
|
||||
boolean resumePreview = validationPreview;
|
||||
validationPreview = false;
|
||||
if (error != null) {
|
||||
bindingBrowser.invalidate(
|
||||
"Discovery unavailable: "
|
||||
@@ -766,6 +771,8 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
|
||||
+ ". Build and Refresh, then retry.");
|
||||
return;
|
||||
}
|
||||
validatedSource = captured.text();
|
||||
bindingProblems = metadata.problems();
|
||||
bindingBrowser.show(
|
||||
metadata,
|
||||
(last
|
||||
@@ -773,6 +780,11 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
|
||||
: "current successful build")
|
||||
+ " · draft revision "
|
||||
+ captured.revision());
|
||||
bindingEditor.metadata(
|
||||
metadata,
|
||||
null,
|
||||
"Discovery · draft revision " + captured.revision());
|
||||
if (resumePreview) render();
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -190,6 +190,10 @@ final class DirectBindingEditor extends VBox {
|
||||
BindingMetadata metadata, DirectBindingDocument.Values requested, String provenance) {
|
||||
status.setText(
|
||||
provenance
|
||||
+ " · ViewModel: "
|
||||
+ metadata.viewModel()
|
||||
+ " · Controller: "
|
||||
+ metadata.controller()
|
||||
+ "\n"
|
||||
+ (metadata.problems().isEmpty()
|
||||
? "No detected binding errors."
|
||||
|
||||
Reference in New Issue
Block a user