Add shared source-preserving Table and Column authoring

This commit is contained in:
2026-11-13 15:07:38 +01:00
parent 0d14ac14e0
commit 3417788194
9 changed files with 796 additions and 5 deletions
@@ -45,6 +45,7 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
if (bindingEditor != null) bindingEditor.selectControl(id);
if (computedEditor != null) computedEditor.selectControl(id);
if (repeatEditor != null) repeatEditor.selectControl(id);
if (tableEditor != null) tableEditor.selectControl(id);
if (id == null || !projection.components().containsKey(id)) return;
componentInspector.getChildren().add(new Label(projection.components().get(id) + " · " + id));
componentInspector
@@ -117,6 +118,7 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
private DesignerWorkflow bindingWorkflow;
private BindingBrowser bindingBrowser;
private BindingEditor bindingEditor, computedEditor, repeatEditor;
private TableEditor tableEditor;
private String validatedSource, validatingSource;
private boolean validationPreview;
private java.util.List<de.neitzel.fxdesigner.protocol.BindingMetadata.Problem> bindingProblems =
@@ -211,6 +213,7 @@ 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);
bindingBrowser =
new BindingBrowser(
this::discoverBindings,
@@ -361,9 +364,12 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
computedTab.setClosable(false);
var repeatTab = new Tab("Repeat bindings", repeatEditor);
repeatTab.setClosable(false);
var tableTab = new Tab("Table / Columns", tableEditor);
tableTab.setClosable(false);
var bindings =
new TitledPane(
"Bindings", new TabPane(directBindingTab, computedTab, repeatTab, discoveryTab));
"Bindings",
new TabPane(directBindingTab, computedTab, repeatTab, tableTab, discoveryTab));
bindings.setExpanded(false);
center.setBottom(new VBox(properties, bindings));
output.setEditable(false);
@@ -506,6 +512,7 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
bindingEditor.load(value.text(), value.writable());
computedEditor.load(value.text(), value.writable());
repeatEditor.load(value.text(), value.writable());
tableEditor.load(value.text(), value.writable());
submittedSource = null;
commitSource();
return;
@@ -530,6 +537,7 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
bindingEditor.load(value.text(), value.writable());
computedEditor.load(value.text(), value.writable());
repeatEditor.load(value.text(), value.writable());
tableEditor.load(value.text(), value.writable());
if (!source.getText().equals(value.text())) {
int anchor = source.getAnchor(), caret = source.getCaretPosition();
var edits =
@@ -685,6 +693,20 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
repeatEditor.invalidateDiscovery();
}
private void editTable(TableEditor.Intent intent) {
withDraft(
() -> {
try {
if (!draft.writable()) throw new IllegalStateException("Document is read-only");
if (!draft.text().equals(intent.source()))
throw new IllegalStateException("Document changed; select the Table again");
submit(intent.edits(), intent.label());
} catch (Exception error) {
tableEditor.error(error.getMessage());
}
});
}
private void editBinding(BindingEditor.Intent intent) {
withDraft(
() -> {
@@ -715,7 +737,8 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
private boolean bindingPreviewAllowed() {
try {
var errors = new BindingDocument(draft.text()).errors();
var errors = new ArrayList<>(new BindingDocument(draft.text()).errors());
errors.addAll(new TableDocument(draft.text()).errors());
if (errors.isEmpty()) return true;
status.setText("Preview blocked: " + String.join("; ", errors));
if (projection != null)