Discover Table compatibility and declared Row alignment
This commit is contained in:
@@ -213,7 +213,9 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
|
||||
if (target != null) kit.editor().getSelection().select(target);
|
||||
},
|
||||
values -> validateBindings(values, false));
|
||||
tableEditor = new TableEditor(this::editTable, this::navigateComponent);
|
||||
tableEditor =
|
||||
new TableEditor(
|
||||
this::editTable, this::navigateComponent, values -> validateBindings(values, false));
|
||||
bindingBrowser =
|
||||
new BindingBrowser(
|
||||
this::discoverBindings,
|
||||
@@ -691,6 +693,7 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
|
||||
bindingWorkflow.cancel();
|
||||
bindingBrowser.invalidate(message);
|
||||
repeatEditor.invalidateDiscovery();
|
||||
tableEditor.invalidateDiscovery();
|
||||
}
|
||||
|
||||
private void editTable(TableEditor.Intent intent) {
|
||||
@@ -817,6 +820,14 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
|
||||
: "Current successful build")
|
||||
+ " · draft revision "
|
||||
+ captured.revision());
|
||||
tableEditor.metadata(
|
||||
metadata,
|
||||
values,
|
||||
(last
|
||||
? "Explicit retained build (outdated)"
|
||||
: "Current successful build")
|
||||
+ " · draft revision "
|
||||
+ captured.revision());
|
||||
status.setText(
|
||||
"Binding validation complete: "
|
||||
+ metadata.problems().size()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.neitzel.fxdesigner.kit;
|
||||
|
||||
import de.neitzel.fxdesigner.contracts.EditBatch.Replacement;
|
||||
import de.neitzel.fxdesigner.protocol.BindingMetadata;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import javafx.scene.control.*;
|
||||
@@ -21,12 +22,47 @@ final class TableEditor extends VBox {
|
||||
private final Consumer<Intent> edit;
|
||||
private String source = "";
|
||||
private TableDocument document;
|
||||
private boolean loading;
|
||||
private boolean loading, updatingChoices;
|
||||
private final ComboBox<BindingMetadata.RepeatOption> collectionChoices = new ComboBox<>(),
|
||||
rowChoices = new ComboBox<>(),
|
||||
columnChoices = new ComboBox<>();
|
||||
private final Consumer<BindingDocument.Values> discover;
|
||||
|
||||
private BindingDocument.Values values() {
|
||||
return BindingDocument.Values.repeat("@table:" + table, row.getText(), collection.getText());
|
||||
}
|
||||
|
||||
private Integer table, column;
|
||||
|
||||
TableEditor(Consumer<Intent> edit, Consumer<String> navigate) {
|
||||
TableEditor(
|
||||
Consumer<Intent> edit, Consumer<String> navigate, Consumer<BindingDocument.Values> discover) {
|
||||
super(5);
|
||||
this.edit = edit;
|
||||
this.discover = discover;
|
||||
collectionChoices.setId("table-collections");
|
||||
rowChoices.setId("table-rows");
|
||||
columnChoices.setId("table-attributes");
|
||||
for (var c : List.of(collectionChoices, rowChoices, columnChoices)) c.setPrefWidth(360);
|
||||
collectionChoices.setOnAction(
|
||||
e -> {
|
||||
var v = collectionChoices.getValue();
|
||||
if (v != null && !updatingChoices) {
|
||||
collection.setText(v.name());
|
||||
discover.accept(values());
|
||||
}
|
||||
});
|
||||
rowChoices.setOnAction(
|
||||
e -> {
|
||||
var v = rowChoices.getValue();
|
||||
if (v != null && !updatingChoices) row.setText(v.name());
|
||||
});
|
||||
columnChoices.setOnAction(
|
||||
e -> {
|
||||
var v = columnChoices.getValue();
|
||||
if (v != null && !updatingChoices) attribute.setText(v.name());
|
||||
});
|
||||
collection.textProperty().addListener((o, a, b) -> invalidateDiscovery());
|
||||
|
||||
setId("table-editor");
|
||||
tables.setId("table-bindings");
|
||||
columns.setId("table-columns");
|
||||
@@ -68,6 +104,11 @@ final class TableEditor extends VBox {
|
||||
.addAll(
|
||||
tables,
|
||||
tableFields,
|
||||
new HBox(
|
||||
6,
|
||||
button("Discover / Validate Table", () -> discover.accept(values())),
|
||||
collectionChoices,
|
||||
rowChoices),
|
||||
new HBox(
|
||||
6,
|
||||
button(
|
||||
@@ -100,6 +141,7 @@ final class TableEditor extends VBox {
|
||||
})),
|
||||
columns,
|
||||
columnFields,
|
||||
columnChoices,
|
||||
new HBox(
|
||||
6,
|
||||
button(
|
||||
@@ -203,6 +245,7 @@ final class TableEditor extends VBox {
|
||||
setDisable(!writable);
|
||||
if (source.equals(text)) return;
|
||||
source = text;
|
||||
invalidateDiscovery();
|
||||
loading = true;
|
||||
try {
|
||||
document = new TableDocument(text);
|
||||
@@ -243,6 +286,49 @@ final class TableEditor extends VBox {
|
||||
}
|
||||
}
|
||||
|
||||
void invalidateDiscovery() {
|
||||
updatingChoices = true;
|
||||
try {
|
||||
collectionChoices.getItems().clear();
|
||||
rowChoices.getItems().clear();
|
||||
columnChoices.getItems().clear();
|
||||
} finally {
|
||||
updatingChoices = false;
|
||||
}
|
||||
status.setText(
|
||||
"Document/build or collection changed; Discover / Validate Table again. Row alignment"
|
||||
+ " unverified.");
|
||||
}
|
||||
|
||||
void metadata(BindingMetadata metadata, BindingDocument.Values requested, String provenance) {
|
||||
var messages = new java.util.ArrayList<String>();
|
||||
if (document != null) messages.addAll(document.errors());
|
||||
for (var p : metadata.problems())
|
||||
if (java.util.Set.of("collection", "row", "columns", "alignment", "Table")
|
||||
.contains(p.property()))
|
||||
messages.add(p.severity() + " " + p.control() + ": " + p.message());
|
||||
status.setText(
|
||||
provenance
|
||||
+ "\n"
|
||||
+ (messages.isEmpty()
|
||||
? "No Table compatibility errors found."
|
||||
: String.join("\n", messages))
|
||||
+ "\n"
|
||||
+ "Diagnostics describe the current document. Choices compare the requested collection."
|
||||
+ " Open Row Component to resolve alignment warnings; its layout is never changed"
|
||||
+ " automatically.");
|
||||
if (requested != null && requested.equals(values())) {
|
||||
updatingChoices = true;
|
||||
try {
|
||||
collectionChoices.getItems().setAll(metadata.tableCollections());
|
||||
rowChoices.getItems().setAll(metadata.tableRows());
|
||||
columnChoices.getItems().setAll(metadata.tableColumns());
|
||||
} finally {
|
||||
updatingChoices = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void error(String message) {
|
||||
status.setText(message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user