Add reference-safe FXML rename, subtree copy and delete

This commit is contained in:
2026-11-13 16:13:03 +01:00
parent 5462f480a4
commit 910a8b0e85
13 changed files with 1191 additions and 7 deletions
@@ -46,6 +46,7 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
if (computedEditor != null) computedEditor.selectControl(id);
if (repeatEditor != null) repeatEditor.selectControl(id);
if (tableEditor != null) tableEditor.selectControl(id);
if (referenceEditor != null) referenceEditor.selectIndex(projection.sourceIndex(id));
if (id == null || !projection.components().containsKey(id)) return;
componentInspector.getChildren().add(new Label(projection.components().get(id) + " · " + id));
componentInspector
@@ -119,6 +120,8 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
private BindingBrowser bindingBrowser;
private BindingEditor bindingEditor, computedEditor, repeatEditor;
private TableEditor tableEditor;
private ReferenceEditor referenceEditor;
private String pendingReferenceValidation;
private String validatedSource, validatingSource;
private boolean validationPreview;
private java.util.List<de.neitzel.fxdesigner.protocol.BindingMetadata.Problem> bindingProblems =
@@ -216,6 +219,7 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
tableEditor =
new TableEditor(
this::editTable, this::navigateComponent, values -> validateBindings(values, false));
referenceEditor = new ReferenceEditor(file.toUri().toString(), this::editStructure);
bindingBrowser =
new BindingBrowser(
this::discoverBindings,
@@ -368,10 +372,13 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
repeatTab.setClosable(false);
var tableTab = new Tab("Table / Columns", tableEditor);
tableTab.setClosable(false);
var structureTab = new Tab("Structure", referenceEditor);
structureTab.setClosable(false);
var bindings =
new TitledPane(
"Bindings",
new TabPane(directBindingTab, computedTab, repeatTab, tableTab, discoveryTab));
new TabPane(
directBindingTab, computedTab, repeatTab, tableTab, structureTab, discoveryTab));
bindings.setExpanded(false);
center.setBottom(new VBox(properties, bindings));
output.setEditable(false);
@@ -515,6 +522,7 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
computedEditor.load(value.text(), value.writable());
repeatEditor.load(value.text(), value.writable());
tableEditor.load(value.text(), value.writable());
referenceEditor.load(value.text(), value.writable());
submittedSource = null;
commitSource();
return;
@@ -540,6 +548,7 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
computedEditor.load(value.text(), value.writable());
repeatEditor.load(value.text(), value.writable());
tableEditor.load(value.text(), value.writable());
referenceEditor.load(value.text(), value.writable());
if (!source.getText().equals(value.text())) {
int anchor = source.getAnchor(), caret = source.getCaretPosition();
var edits =
@@ -605,6 +614,10 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
report(error);
} finally {
loading = false;
if (value.text().equals(pendingReferenceValidation)) {
pendingReferenceValidation = null;
Platform.runLater(() -> validateBindings(null, false));
}
}
}
@@ -696,6 +709,22 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
tableEditor.invalidateDiscovery();
}
private void editStructure(ReferenceEditor.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 source object again");
if (intent.validate())
pendingReferenceValidation = apply(draft.text(), intent.change().edits());
submit(intent.change().edits(), intent.label());
} catch (Exception e) {
referenceEditor.error(e.getMessage());
}
});
}
private void editTable(TableEditor.Intent intent) {
withDraft(
() -> {
@@ -742,6 +771,7 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
try {
var errors = new ArrayList<>(new BindingDocument(draft.text()).errors());
errors.addAll(new TableDocument(draft.text()).errors());
errors.addAll(new ReferenceDocument(draft.text()).referenceErrors());
if (errors.isEmpty()) return true;
status.setText("Preview blocked: " + String.join("; ", errors));
if (projection != null)