Edit DataGrid columns and dock layout declarations in the designer

This commit is contained in:
2026-11-24 15:59:08 +01:00
parent 43267824d7
commit b04bd9d7ef
14 changed files with 1148 additions and 17 deletions
+4
View File
@@ -81,6 +81,10 @@ Add `--connection-form` to open or qualify `ConnectionForm.fxml`. After **Build
In **Form controls**, select the palette type, destination child list and insertion position, then **Insert control**. Select a control on the canvas or in **Selected control**. **Set property** and **Reset property** edit its FXML, and **Bind property** opens the direct-binding form. For **suggestions**, enter one string per line. To reorder or move a child, choose its destination and position, then **Move to destination**. Each change participates in IntelliJ Undo and Redo. In **Form controls**, select the palette type, destination child list and insertion position, then **Insert control**. Select a control on the canvas or in **Selected control**. **Set property** and **Reset property** edit its FXML, and **Bind property** opens the direct-binding form. For **suggestions**, enter one string per line. To reorder or move a child, choose its destination and position, then **Move to destination**. Each change participates in IntelliJ Undo and Redo.
Open **Bindings → DataGrid / Docking** in `FolderTab.fxml` to select the grid or one of its columns. **Apply setting** writes the selected property. Clear an optional value to restore its FXML default. **Edit data binding** opens the direct binding for `items` or `source`. The **Archivordner · Beispieldateien** example loads two local files using the grid's declared columns and grouping.
In `ArchiveWindow.fxml`, select a layout branch to split it or an outer side area to move it. **Add area with group** creates a destination in an unused area. The **Beispielarchiv** example opens a document and its details in the declared destinations. Both the embedded image and the interactive window use this layout. To repeat both acceptance scenarios, add `--grid-docking ../NeitzelLib/fx-example/src/main/resources/de/neitzel/fx/example/docking/workspace/ReferenceWorkspace.fxml` to the Archiver host check.
For an existing Archiver checkout, install the built plugin ZIP and create the ignored local JDK and worker mappings once with `python3 scripts/configure-library-example.py --project ../Archiver --target-java-home "$JAVA_HOME"`. Launch the IDE with access to the Maven repository containing the qualified snapshots. For an existing Archiver checkout, install the built plugin ZIP and create the ignored local JDK and worker mappings once with `python3 scripts/configure-library-example.py --project ../Archiver --target-java-home "$JAVA_HOME"`. Launch the IDE with access to the Maven repository containing the qualified snapshots.
The [save/startup reliability follow-up](docs/ide-host-reliability.md) covers queued IntelliJ VFS writes and host-revision/validation races, including repeated registered module-path qualification. Add `--mode modulepath --repeat 3` to the IDE runner to repeat that gate. The [save/startup reliability follow-up](docs/ide-host-reliability.md) covers queued IntelliJ VFS writes and host-revision/validation races, including repeated registered module-path qualification. Add `--mode modulepath --repeat 3` to the IDE runner to repeat that gate.
@@ -106,11 +106,14 @@ final class BindingDocument {
} }
boolean named(Element e, String type) { boolean named(Element e, String type) {
if (e.getTagName().equals(PACKAGE + type)) return true; return named(e, PACKAGE, type);
}
boolean named(Element e, String pkg, String type) {
if (e.getTagName().equals(pkg + type)) return true;
if (!e.getTagName().equals(type)) return false; if (!e.getTagName().equals(type)) return false;
boolean own = imports.contains(PACKAGE + type) || imports.contains(PACKAGE + "*"); boolean own = imports.contains(pkg + type) || imports.contains(pkg + "*");
boolean other = boolean other = imports.stream().anyMatch(i -> i.endsWith("." + type) && !i.equals(pkg + type));
imports.stream().anyMatch(i -> i.endsWith("." + type) && !i.equals(PACKAGE + type));
return own && !other; return own && !other;
} }
@@ -239,6 +239,18 @@ final class BindingEditor extends VBox {
collection.setText(v.collection()); collection.setText(v.collection());
} }
void editProperty(BindingDocument.Values v) {
var existing =
bindings.getItems().stream()
.filter(
e ->
e.values().control().equals(v.control())
&& e.values().property().equals(v.property()))
.findFirst();
if (existing.isPresent()) bindings.getSelectionModel().select(existing.get());
else newBinding(v);
}
void newBinding(BindingDocument.Values v) { void newBinding(BindingDocument.Values v) {
loading = true; loading = true;
bindings.getSelectionModel().clearSelection(); bindings.getSelectionModel().clearSelection();
@@ -35,6 +35,7 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
return content; return content;
} }
private GridDockEditor gridDockEditor;
private FormEditor formEditor; private FormEditor formEditor;
private final ImageView wholeImage = new ImageView(); private final ImageView wholeImage = new ImageView();
private final Spinner<Integer> previewWidth = new Spinner<>(120, 1600, 760, 40); private final Spinner<Integer> previewWidth = new Spinner<>(120, 1600, 760, 40);
@@ -423,6 +424,15 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
repeatTab.setClosable(false); repeatTab.setClosable(false);
var tableTab = new Tab("Table / Columns", tableEditor); var tableTab = new Tab("Table / Columns", tableEditor);
tableTab.setClosable(false); tableTab.setClosable(false);
gridDockEditor =
new GridDockEditor(
this::editForm,
values -> {
directBindingTab.getTabPane().getSelectionModel().select(directBindingTab);
bindingEditor.editProperty(values);
});
var gridDockTab = new Tab("DataGrid / Docking", gridDockEditor);
gridDockTab.setClosable(false);
var problemsTab = new Tab("Problems", diagnosticsPane); var problemsTab = new Tab("Problems", diagnosticsPane);
problemsTab.setClosable(false); problemsTab.setClosable(false);
var structureTab = new Tab("Structure", referenceEditor); var structureTab = new Tab("Structure", referenceEditor);
@@ -439,6 +449,7 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
commandTab, commandTab,
repeatTab, repeatTab,
tableTab, tableTab,
gridDockTab,
structureTab, structureTab,
problemsTab, problemsTab,
discoveryTab, discoveryTab,
@@ -627,6 +638,7 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
repeatEditor.load(value.text(), value.writable()); repeatEditor.load(value.text(), value.writable());
commandEditor.load(value.text(), value.writable()); commandEditor.load(value.text(), value.writable());
tableEditor.load(value.text(), value.writable()); tableEditor.load(value.text(), value.writable());
gridDockEditor.load(value.text(), value.writable());
referenceEditor.load(value.text(), value.writable()); referenceEditor.load(value.text(), value.writable());
submittedSource = null; submittedSource = null;
commitSource(); commitSource();
@@ -663,6 +675,7 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
repeatEditor.load(value.text(), value.writable()); repeatEditor.load(value.text(), value.writable());
commandEditor.load(value.text(), value.writable()); commandEditor.load(value.text(), value.writable());
tableEditor.load(value.text(), value.writable()); tableEditor.load(value.text(), value.writable());
gridDockEditor.load(value.text(), value.writable());
referenceEditor.load(value.text(), value.writable()); referenceEditor.load(value.text(), value.writable());
if (!source.getText().equals(value.text())) { if (!source.getText().equals(value.text())) {
int anchor = source.getAnchor(), caret = source.getCaretPosition(); int anchor = source.getAnchor(), caret = source.getCaretPosition();
@@ -725,6 +738,7 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
} catch (Throwable error) { } catch (Throwable error) {
design.setDisable(true); design.setDisable(true);
componentInspector.setDisable(true); componentInspector.setDisable(true);
gridDockEditor.setDisable(true);
projection = null; projection = null;
report(error); report(error);
} finally { } finally {
@@ -171,16 +171,38 @@ public final class FxmlProjection {
} }
var imports = new HashMap<String, String>(); var imports = new HashMap<String, String>();
var remove = new ArrayList<Node>(); var remove = new ArrayList<Node>();
var explicit = new HashMap<String, String>();
var conflicts = new HashSet<String>();
var unknownPackages = new ArrayList<String>();
boolean docking = false;
for (Node n = d.getFirstChild(); n != null; n = n.getNextSibling()) for (Node n = d.getFirstChild(); n != null; n = n.getNextSibling())
if (n instanceof ProcessingInstruction pi && pi.getTarget().equals("import")) { if (n instanceof ProcessingInstruction pi && pi.getTarget().equals("import")) {
String type = pi.getData().trim(); String type = pi.getData().trim();
if (!type.startsWith("javafx.")) { String simple = type.substring(type.lastIndexOf('.') + 1);
if (type.endsWith(".*")) if (!simple.equals("*")) {
throw new IOException("Application wildcard imports need an explicit Component import"); var previous = explicit.putIfAbsent(simple, type);
imports.put(type.substring(type.lastIndexOf('.') + 1), type); if (previous != null && !previous.equals(type)) conflicts.add(simple);
remove.add(n);
} }
if (type.startsWith("javafx.")) continue;
if (type.equals("de.neitzel.fx.docking.*")) docking = true;
else if (simple.equals("*")) unknownPackages.add(type);
else imports.put(simple, type);
remove.add(n);
} }
for (int i = 0; i < originals.getLength(); i++) {
var element = (Element) originals.item(i);
String tag = element.getTagName();
if (!isObject(element) || tag.contains(".")) continue;
if (conflicts.contains(tag)) throw importError(i, tag, "Conflicting explicit imports");
if (explicit.containsKey(tag)) continue;
if (!unknownPackages.isEmpty()) {
throw importError(
i, tag, "Unresolved wildcard import (" + String.join(", ", unknownPackages) + ")");
}
if (docking
&& Set.of("DockPane", "DockLayout", "DockGroupDefinition", "DockSplitDefinition")
.contains(tag)) imports.put(tag, "de.neitzel.fx.docking." + tag);
}
remove.forEach(d::removeChild); remove.forEach(d::removeChild);
d.insertBefore( d.insertBefore(
d.createProcessingInstruction("import", SnapshotRegion.class.getName()), d.createProcessingInstruction("import", SnapshotRegion.class.getName()),
@@ -240,6 +262,21 @@ public final class FxmlProjection {
return xml(d); return xml(d);
} }
private IOException importError(int index, String tag, String message) {
int offset = source.tags.get(index).start();
int line = 1 + (int) source.text.substring(0, offset).chars().filter(c -> c == '\n').count();
int column = offset - source.text.lastIndexOf('\n', offset);
return new IOException(
message
+ " for <"
+ tag
+ "> at line "
+ line
+ ", column "
+ column
+ ". Use one explicit import for this type.");
}
private static Map<String, Element> indexed(Document d) throws IOException { private static Map<String, Element> indexed(Document d) throws IOException {
var result = new LinkedHashMap<String, Element>(); var result = new LinkedHashMap<String, Element>();
@@ -0,0 +1,373 @@
package de.neitzel.fxdesigner.kit;
import de.neitzel.fxdesigner.contracts.EditBatch.Replacement;
import java.util.*;
import org.w3c.dom.*;
/** Address declarations by their source elements. Replacing a branch retains its complete XML. */
final class GridDockDocument {
static final String DOCK = "de.neitzel.fx.docking.";
static final List<String> AREAS = List.of("center", "left", "right", "top", "bottom");
static final Map<String, List<String>> SETTINGS =
Map.of(
"DataGrid",
List.of(
"keyAttribute",
"pageSize",
"maximumPageSize",
"selectionMode",
"groupingEnabled",
"groupBy",
"groupsCollapsed",
"items",
"source"),
"DataGridColumn",
List.of(
"id",
"attribute",
"header",
"type",
"kind",
"width",
"minimumWidth",
"maximumWidth",
"filterable",
"checklist",
"groupAttribute"),
"DockGroupDefinition",
List.of(
"destinationId",
"tabSide",
"mode",
"visibleWhenEmpty",
"releaseSpaceWhenEmpty",
"collapsible",
"preferredWidth",
"preferredHeight"),
"DockSplitDefinition", List.of("destinationId", "orientation", "position"));
static List<String> options(String field) {
return switch (field) {
case "filterable",
"groupingEnabled",
"groupsCollapsed",
"visibleWhenEmpty",
"releaseSpaceWhenEmpty",
"collapsible" ->
List.of("true", "false");
case "checklist" -> List.of("DISABLED", "INHERIT", "CURRENT_PAGE", "SOURCE_WIDE");
case "selectionMode" -> List.of("NONE", "SINGLE", "MULTIPLE");
case "tabSide" -> List.of("TOP", "RIGHT", "BOTTOM", "LEFT");
case "mode" -> List.of("DOCKED", "OVERLAY");
case "orientation" -> List.of("HORIZONTAL", "VERTICAL");
case "kind" -> List.of("TEXT", "INTEGER", "DECIMAL", "BOOLEAN");
default -> List.of();
};
}
final BindingDocument xml;
GridDockDocument(String text) throws Exception {
xml = new BindingDocument(text);
}
String type(Element e) {
String tag = e.getTagName(), name = tag.substring(tag.lastIndexOf('.') + 1);
if ((name.equals("DataGrid") || name.equals("DataGridColumn")) && xml.named(e, name))
return name;
if (Set.of("DockPane", "DockLayout", "DockGroupDefinition", "DockSplitDefinition")
.contains(name)
&& xml.named(e, DOCK, name)) return name;
return "";
}
List<Element> roots() {
return xml.elements.stream()
.filter(e -> Set.of("DataGrid", "DockPane").contains(type(e)))
.toList();
}
static List<Element> children(Element e) {
var result = new ArrayList<Element>();
for (Node n = e.getFirstChild(); n != null; n = n.getNextSibling())
if (n instanceof Element c) result.add(c);
return result;
}
private Element property(Element e, String name) {
var list = children(e).stream().filter(c -> c.getTagName().equals(name)).toList();
if (list.size() > 1) throw new IllegalArgumentException("Multiple declarations of " + name);
return list.isEmpty() ? null : list.getFirst();
}
Element parentOfType(Element e, String type) {
for (Node n = e; n instanceof Element p; n = n.getParentNode())
if (type(p).equals(type)) return p;
throw new IllegalArgumentException("Missing " + type);
}
private Element columnsOwner(Element grid) {
var wrapper = property(grid, "columns");
if (wrapper != null && children(grid).stream().anyMatch(c -> type(c).equals("DataGridColumn")))
throw new IllegalArgumentException(
"Mixed column containers. Edit the declaration in Source.");
return wrapper == null ? grid : wrapper;
}
List<Element> branches(Element e) {
if (type(e).equals("DataGrid"))
return children(columnsOwner(e)).stream()
.filter(c -> type(c).equals("DataGridColumn"))
.toList();
if (type(e).equals("DataGridColumn") || type(e).equals("DockGroupDefinition")) return List.of();
return children(e).stream()
.filter(
c ->
!type(c).isEmpty()
|| AREAS.contains(c.getTagName())
|| Set.of("initialLayout", "first", "second").contains(c.getTagName()))
.toList();
}
String label(Element e) {
String label = type(e);
if (label.isEmpty()) return e.getTagName();
String id =
e.hasAttribute("destinationId") ? e.getAttribute("destinationId") : e.getAttribute("id");
if (id.isEmpty()) id = e.getAttributeNS(BindingDocument.FX, "id");
return id.isEmpty() ? label : label + " · " + id;
}
private XmlSource.Tag tag(Element e) {
return xml.source.tags.get(xml.elements.indexOf(e));
}
private String fragment(Element e) {
var t = tag(e);
return xml.text.substring(t.start(), t.end());
}
private Replacement replace(Element e, String snippet) {
var t = tag(e);
return new Replacement(t.start(), t.end(), snippet);
}
private List<String> grouped(Element grid) {
return Arrays.stream(grid.getAttribute("groupBy").split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.toList();
}
private List<Element> destinations(Element e) {
var pane = parentOfType(e, "DockPane");
return xml.elements.stream()
.filter(
c ->
(pane.compareDocumentPosition(c) & Node.DOCUMENT_POSITION_CONTAINED_BY) != 0
&& Set.of("DockGroupDefinition", "DockSplitDefinition").contains(type(c)))
.toList();
}
private String fresh(List<Element> elements, String attr, String base) {
var used = new HashSet<String>();
elements.forEach(e -> used.add(e.getAttribute(attr)));
String id = base;
for (int i = 2; used.contains(id); i++) id = base + i;
return id;
}
List<Replacement> set(Element e, String field, String value) {
if (!SETTINGS.getOrDefault(type(e), List.of()).contains(field)
|| Set.of("items", "source").contains(field))
throw new IllegalArgumentException("Use a model binding for the data input.");
if (property(e, field) != null)
throw new IllegalArgumentException(
"The property has a nested declaration. Edit it in Source.");
if (e.getAttribute(field).matches("^[%$#].*"))
throw new IllegalArgumentException("This property is a reference. Edit it in Source.");
boolean required =
field.equals("id") || field.equals("destinationId") || field.equals("header");
if (required && value.isBlank())
throw new IllegalArgumentException("A value is required for " + field);
var opts = options(field);
if (!value.isEmpty() && !opts.isEmpty() && !opts.contains(value))
throw new IllegalArgumentException("Choose one of " + opts);
if (!value.isEmpty()
&& Set.of(
"width",
"minimumWidth",
"maximumWidth",
"preferredWidth",
"preferredHeight",
"position")
.contains(field)) {
double n = Double.parseDouble(value);
if (!Double.isFinite(n) || n <= 0 || field.equals("position") && n >= 1)
throw new IllegalArgumentException("Invalid " + field);
}
if (!value.isEmpty()
&& Set.of("pageSize", "maximumPageSize").contains(field)
&& Integer.parseInt(value) < 1)
throw new IllegalArgumentException("Positive page size required");
var edits = new ArrayList<Replacement>();
if (field.equals("destinationId")
&& destinations(e).stream().anyMatch(c -> c != e && c.getAttribute(field).equals(value)))
throw new IllegalArgumentException("Destination already exists: " + value);
if (field.equals("id")) {
var grid = parentOfType(e, "DataGrid");
if (branches(grid).stream().anyMatch(c -> c != e && c.getAttribute("id").equals(value)))
throw new IllegalArgumentException("Column already exists: " + value);
var groups = new ArrayList<>(grouped(grid));
if (Collections.replaceAll(groups, e.getAttribute("id"), value))
edits.addAll(
xml.source.attributes(
xml.elements.indexOf(grid), Map.of("groupBy", String.join(", ", groups))));
// The library defaults the row attribute to the column id.
if (!e.hasAttribute("attribute")
&& !e.getAttribute("id").equals(value)
&& !e.getAttribute("id").isEmpty()) {
edits.addAll(
xml.source.attributes(
xml.elements.indexOf(e), Map.of("id", value, "attribute", e.getAttribute("id"))));
return edits;
}
}
if (field.equals("groupBy") && !value.isBlank()) {
var ids = branches(e).stream().map(c -> c.getAttribute("id")).toList();
var seen = new HashSet<String>();
for (String token : value.split(",", -1))
if (!ids.contains(token.trim()) || !seen.add(token.trim()))
throw new IllegalArgumentException("Unknown or repeated grouping column: " + token);
}
edits.addAll(
xml.source.attributes(
xml.elements.indexOf(e),
Collections.singletonMap(field, value.isEmpty() ? null : value)));
return edits;
}
List<Replacement> addColumn(Element e) {
var grid = parentOfType(e, "DataGrid");
var cols = branches(grid);
String id = fresh(cols, "id", "column");
// Start with an existing row attribute so the new column can render immediately.
String attribute = cols.isEmpty() ? "value" : cols.getFirst().getAttribute("attribute");
if (attribute.isEmpty() && !cols.isEmpty()) attribute = cols.getFirst().getAttribute("id");
return List.of(
xml.append(
columnsOwner(grid),
"<de.neitzel.fx.view.DataGridColumn id=\""
+ id
+ "\" attribute=\""
+ XmlSource.escape(attribute, '"')
+ "\" header=\""
+ id
+ "\"/>",
""));
}
List<Replacement> move(Element col, int delta) {
var columns = branches(parentOfType(col, "DataGrid"));
int index = columns.indexOf(col);
if (index < 0) throw new IllegalArgumentException("Select a column.");
if (index + delta < 0 || index + delta >= columns.size()) return List.of();
var other = columns.get(index + delta);
return List.of(replace(other, fragment(col)), replace(col, fragment(other)));
}
List<Replacement> removeColumn(Element col) {
if (!type(col).equals("DataGridColumn")) throw new IllegalArgumentException("Select a column.");
if (grouped(parentOfType(col, "DataGrid")).contains(col.getAttribute("id")))
throw new IllegalArgumentException("Remove the column from groupBy first.");
var span = tag(col);
int start = xml.text.lastIndexOf('\n', span.start() - 1) + 1;
int end = xml.text.indexOf('\n', span.end());
if (end >= 0
&& xml.text.substring(start, span.start()).isBlank()
&& xml.text.substring(span.end(), end).isBlank())
return List.of(new Replacement(start, end + 1, ""));
return List.of(replace(col, ""));
}
private String group(String id) {
return "<" + DOCK + "DockGroupDefinition destinationId=\"" + id + "\"/>";
}
List<Replacement> addArea(Element e, String area) {
if (!AREAS.contains(area)) throw new IllegalArgumentException("Choose a dock area.");
var pane = parentOfType(e, "DockPane");
var initial = property(pane, "initialLayout");
var child =
"<"
+ area
+ ">"
+ group(fresh(destinations(pane), "destinationId", area))
+ "</"
+ area
+ ">";
if (initial == null) {
if (pane.hasAttribute("initialLayout"))
throw new IllegalArgumentException("The layout is supplied by reference.");
if (!area.equals("center"))
throw new IllegalArgumentException("Create the center area first.");
return List.of(
xml.append(
pane,
"<initialLayout><"
+ DOCK
+ "DockLayout>"
+ child
+ "</"
+ DOCK
+ "DockLayout></initialLayout>",
""));
}
var layout =
children(initial).stream()
.filter(c -> type(c).equals("DockLayout"))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("An inline DockLayout is required."));
if (property(layout, area) != null || layout.hasAttribute(area))
throw new IllegalArgumentException("Area already exists: " + area);
return List.of(xml.append(layout, child, ""));
}
List<Replacement> moveArea(Element origin, String target) {
if (!AREAS.contains(origin.getTagName())
|| !AREAS.contains(target)
|| origin.getTagName().equals("center"))
throw new IllegalArgumentException("Select a side area to move.");
var layout = parentOfType(origin, "DockLayout");
if (property(layout, target) != null || layout.hasAttribute(target))
throw new IllegalArgumentException("Area already exists: " + target);
var t = tag(origin);
String name = origin.getTagName();
if (t.selfClosing())
return List.of(new Replacement(t.start() + 1, t.start() + 1 + name.length(), target));
return List.of(
new Replacement(t.start() + 1, t.start() + 1 + name.length(), target),
new Replacement(t.closeStart() + 2, t.closeStart() + 2 + name.length(), target));
}
List<Replacement> split(Element e) {
if (!Set.of("DockGroupDefinition", "DockSplitDefinition").contains(type(e)))
throw new IllegalArgumentException("Select a dock group or split.");
var destinations = destinations(e);
String id = fresh(destinations, "destinationId", "split");
return List.of(
replace(
e,
"<"
+ DOCK
+ "DockSplitDefinition destinationId=\""
+ id
+ "\" orientation=\"HORIZONTAL\"><first>"
+ fragment(e)
+ "</first><second>"
+ group(fresh(destinations, "destinationId", "group"))
+ "</second></"
+ DOCK
+ "DockSplitDefinition>"));
}
}
@@ -0,0 +1,197 @@
package de.neitzel.fxdesigner.kit;
import de.neitzel.fxdesigner.contracts.EditBatch.Replacement;
import java.util.*;
import java.util.function.*;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import org.w3c.dom.Element;
/** Source-backed inspector for the two declarative structures hidden inside Kit proxies. */
final class GridDockEditor extends VBox {
private final TreeView<Element> tree = new TreeView<>();
private final ComboBox<String> setting = new ComboBox<>(),
value = new ComboBox<>(),
area = new ComboBox<>();
private final Label message = new Label(),
signals =
new Label(
"Selection outputs (read-only): selectedKey, selectedKeys, selectedElement,"
+ " selectedElements");
private GridDockDocument doc;
private final Consumer<FormDocument.Edit> submit;
private final Consumer<BindingDocument.Values> binding;
private final Button apply, bind, add, remove, earlier, later, addArea, moveArea, split;
GridDockEditor(Consumer<FormDocument.Edit> submit, Consumer<BindingDocument.Values> binding) {
super(4);
this.submit = submit;
this.binding = binding;
tree.setId("declaration-tree");
tree.setShowRoot(false);
tree.setPrefHeight(155);
tree.setMinHeight(88);
tree.setCellFactory(
v ->
new TreeCell<>() {
protected void updateItem(Element e, boolean empty) {
super.updateItem(e, empty);
setText(empty || e == null ? null : doc.label(e));
}
});
setting.setId("declaration-property");
value.setId("declaration-value");
message.setId("declaration-message");
value.setEditable(true);
value.setPrefWidth(180);
area.setId("dock-area");
area.getItems().addAll(GridDockDocument.AREAS);
area.setValue("center");
apply =
button(
"Apply setting",
() ->
edit(
() ->
doc.set(
selected(), setting.getValue(), value.getEditor().getText().trim())));
bind =
button(
"Edit data binding",
() -> {
String id = selected().getAttributeNS(BindingDocument.FX, "id");
if (id.isEmpty()) {
message.setText("Give the grid an fx:id under Structure first.");
return;
}
String field = setting.getValue();
binding.accept(new BindingDocument.Values(id, field, "", "view", ""));
});
add = button("Add column", () -> edit(() -> doc.addColumn(selected())));
remove = button("Delete column", () -> edit(() -> doc.removeColumn(selected())));
earlier = button("Earlier", () -> edit(() -> doc.move(selected(), -1)));
later = button("Later", () -> edit(() -> doc.move(selected(), 1)));
addArea =
button("Add area with group", () -> edit(() -> doc.addArea(selected(), area.getValue())));
moveArea = button("Move area", () -> edit(() -> doc.moveArea(selected(), area.getValue())));
split = button("Split branch", () -> edit(() -> doc.split(selected())));
signals.setWrapText(true);
message.setWrapText(true);
getChildren()
.addAll(
tree,
new FlowPane(6, 4, setting, value, apply, bind),
new FlowPane(6, 4, add, earlier, later, remove, area, addArea, moveArea, split),
signals,
message);
tree.getSelectionModel().selectedItemProperty().addListener((o, a, b) -> select());
setting.valueProperty().addListener((o, a, b) -> showValue());
}
private static Button button(String text, Runnable action) {
var button = new Button(text);
button.setOnAction(e -> action.run());
return button;
}
private Element selected() {
var item = tree.getSelectionModel().getSelectedItem();
return item == null ? null : item.getValue();
}
private void edit(Supplier<List<Replacement>> action) {
try {
var edits = action.get();
message.setText("");
if (!edits.isEmpty()) submit.accept(new FormDocument.Edit(doc.xml.text, edits, ""));
} catch (RuntimeException ex) {
message.setText(ex.getMessage());
}
}
private TreeItem<Element> item(Element e) {
var node = new TreeItem<>(e);
node.setExpanded(true);
for (var c : doc.branches(e)) node.getChildren().add(item(c));
return node;
}
void load(String text, boolean writable) {
var previous = selected();
String label = previous == null ? "" : doc.label(previous);
var oldItem = tree.getSelectionModel().getSelectedItem();
var path = new LinkedList<Integer>();
for (var n = oldItem; n != null && n.getParent() != null; n = n.getParent())
path.addFirst(n.getParent().getChildren().indexOf(n));
String field = setting.getValue();
try {
doc = new GridDockDocument(text);
var root = new TreeItem<Element>();
root.setExpanded(true);
for (var e : doc.roots()) root.getChildren().add(item(e));
tree.setRoot(root);
setDisable(!writable);
var match = root;
for (int i : path) {
if (i >= match.getChildren().size()) break;
match = match.getChildren().get(i);
}
if (match == root && !root.getChildren().isEmpty()) match = root.getChildren().getFirst();
if (match.getValue() != null
&& !doc.label(match.getValue()).equals(label)
&& match.getParent() != null)
match =
match.getParent().getChildren().stream()
.filter(n -> doc.label(n.getValue()).equals(label))
.findFirst()
.orElse(match);
tree.getSelectionModel().select(match);
select();
if (setting.getItems().contains(field)) setting.setValue(field);
message.setText(root.getChildren().isEmpty() ? "No DataGrid or DockPane in this view." : "");
} catch (Exception ex) {
tree.setRoot(null);
setDisable(true);
message.setText(ex.getMessage());
}
}
private static void visible(javafx.scene.Node node, boolean flag) {
node.setVisible(flag);
node.setManaged(flag);
}
private void select() {
var e = selected();
String type = e == null ? "" : doc.type(e);
boolean grid = type.equals("DataGrid"), column = type.equals("DataGridColumn");
setting.getItems().setAll(GridDockDocument.SETTINGS.getOrDefault(type, List.of()));
setting.getSelectionModel().selectFirst();
for (var node : List.of(add, signals)) visible(node, grid || column);
for (var node : List.of(earlier, later, remove)) visible(node, column);
for (var node : List.of(area, addArea)) visible(node, e != null && !grid && !column);
visible(
moveArea,
e != null
&& GridDockDocument.AREAS.contains(e.getTagName())
&& !e.getTagName().equals("center"));
visible(split, type.equals("DockGroupDefinition") || type.equals("DockSplitDefinition"));
visible(setting, !setting.getItems().isEmpty());
message.setText("");
showValue();
}
private void showValue() {
String field = setting.getValue();
var e = selected();
boolean input = "items".equals(field) || "source".equals(field);
boolean editable = e != null && field != null && !input;
visible(bind, input);
visible(apply, editable);
visible(value, editable);
if (!editable) return;
value.getItems().setAll(GridDockDocument.options(field));
value.setValue(e.getAttribute(field));
value.getEditor().setText(e.getAttribute(field));
}
}
@@ -0,0 +1,44 @@
package de.neitzel.fxdesigner.kit;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class GridDockDocumentTest {
@Test
void implicitRowAttributeAndGroupingSurviveRename() throws Exception {
var source =
"""
<?import de.neitzel.fx.view.DataGrid?>
<?import de.neitzel.fx.view.DataGridColumn?>
<DataGrid groupBy="name"><columns>
<DataGridColumn id="name" header="Name"/>
<DataGridColumn id="age"/>
</columns></DataGrid>
""";
var doc = new GridDockDocument(source);
var grid = doc.roots().getFirst();
var col = doc.branches(grid).getFirst();
assertThrows(IllegalArgumentException.class, () -> doc.removeColumn(col));
assertThrows(IllegalArgumentException.class, () -> doc.set(col, "id", "age"));
var renamed = doc.xml.source.apply(doc.set(col, "id", "title"));
assertTrue(renamed.contains("groupBy=\"title\""));
assertTrue(renamed.contains("attribute=\"name\""));
var removed = doc.xml.source.apply(doc.removeColumn(doc.branches(grid).getLast()));
assertEquals(source.replace(" <DataGridColumn id=\"age\"/>\n", ""), removed);
}
@Test
void rootDockProjectionAndAmbiguousImportPreserveOriginal() throws Exception {
String source =
"""
<?import de.neitzel.fx.docking.*?>
<DockPane><initialLayout><DockLayout><center><DockGroupDefinition destinationId='main'/></center></DockLayout></initialLayout></DockPane>
""";
var projection = new FxmlProjection(source);
assertEquals(source, projection.restore(projection.project()));
String conflict = source.replace("<DockPane>", "<?import my.docks.*?>\n<DockPane>");
var ex = assertThrows(java.io.IOException.class, () -> new FxmlProjection(conflict).project());
assertTrue(ex.getMessage().contains("<DockPane> at line 3, column 1"), ex::getMessage);
}
}
@@ -131,6 +131,8 @@ public final class TargetPreview implements AutoCloseable {
view = ViewLoader.loadComponent(componentType, session.model(), context, models); view = ViewLoader.loadComponent(componentType, session.model(), context, models);
} else view = ViewLoader.load(resource, session.model(), context, models); } else view = ViewLoader.load(resource, session.model(), context, models);
scene = new Scene(view.getRoot(), 420, 240); scene = new Scene(view.getRoot(), 420, 240);
interactive = new javafx.stage.Stage();
interactive.setScene(scene);
layout(420, 240); layout(420, 240);
var wait = session.ready(); var wait = session.ready();
if (wait == null) if (wait == null)
@@ -262,11 +264,7 @@ public final class TargetPreview implements AutoCloseable {
public void showInteractive(String title, Runnable onClosed) { public void showInteractive(String title, Runnable onClosed) {
fx(); fx();
if (interactive == null) { interactive.setOnHidden(e -> onClosed.run());
interactive = new javafx.stage.Stage();
interactive.setScene(scene);
interactive.setOnHidden(e -> onClosed.run());
}
interactive.setTitle(title); interactive.setTitle(title);
interactive.show(); interactive.show();
interactive.toFront(); interactive.toFront();
+1 -1
View File
@@ -67,7 +67,7 @@ The user subsequently passed the physical corner retest for both Components in b
## Remaining boundaries ## Remaining boundaries
This stage preserves arbitrary source, but does not make arbitrary structure visually editable. Binding-aware renames and subtree copy/paste/delete are now available through the [Structure editor](reference-safe-structure.md). Arbitrary insertion/reparenting still requires Source editing. Application wildcard imports, `fx:include`, scripts and unrepresentable roots retain source fallback. Arbitrary target properties use declared FXML text editing until shared discovery supplies typed metadata. Anonymous identities are local to a projection revision, not the persistent occurrence identities needed for repeated/Table Components. Target node lookup still uses the initial CSS-ID route; separate CSS IDs and repeated/internal scopes need stage 3's occurrence identity work. This stage preserves arbitrary source, but does not make arbitrary structure visually editable. Binding-aware renames and subtree copy/paste/delete are now available through the [Structure editor](reference-safe-structure.md). Arbitrary insertion/reparenting still requires Source editing. Unresolved application wildcard imports, `fx:include`, scripts and unrepresentable roots retain source fallback. The four declarative docking types in `de.neitzel.fx.docking.*` are recognized by the projection and editable in the DataGrid / Docking inspector. Arbitrary target properties use declared FXML text editing until shared discovery supplies typed metadata. Anonymous identities are local to a projection revision, not the persistent occurrence identities needed for repeated/Table Components. Target node lookup still uses the initial CSS-ID route; separate CSS IDs and repeated/internal scopes need stage 3's occurrence identity work.
Qualification remains scoped to the recorded macOS arm64 / IntelliJ 263.7307.200 / JavaFX and Kit 26 host baseline and Java 21 / JavaFX 21.0.7 application fixtures. Product packaging, a broader platform matrix, lossless structural editing and wider input qualification are not implied. The stage-2 physical input gate is closed on the tested baseline. The following [target-runtime stage](target-runtime-sessions.md) implements retained sessions, sizing and navigation; its new actions have a separate human review. Qualification remains scoped to the recorded macOS arm64 / IntelliJ 263.7307.200 / JavaFX and Kit 26 host baseline and Java 21 / JavaFX 21.0.7 application fixtures. Product packaging, a broader platform matrix, lossless structural editing and wider input qualification are not implied. The stage-2 physical input gate is closed on the tested baseline. The following [target-runtime stage](target-runtime-sessions.md) implements retained sessions, sizing and navigation; its new actions have a separate human review.
@@ -0,0 +1,119 @@
package qualification;
import java.nio.file.*;
import java.util.*;
import java.util.concurrent.*;
import javafx.application.Platform;
import javafx.beans.value.ObservableValue;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.stage.Window;
/**
* Measures the real Archiver controls in the interactive worker launched by the registered editor.
*/
public final class GridDockTargetProbe {
public static void premain(String dir) {
if (!System.getProperty("sun.java.command", "")
.startsWith("de.neitzel.fxdesigner.target.WorkerMain ")) return;
Thread.ofPlatform().daemon().start(() -> Probe.observe(Path.of(dir)));
}
private static final class Probe {
private static void observe(Path dir) {
try {
while (true) {
Thread.sleep(200);
var check = new FutureTask<>(() -> inspect(dir));
try {
Platform.runLater(check);
} catch (IllegalStateException starting) {
continue;
}
if (check.get(10, TimeUnit.SECONDS)) return;
}
} catch (Throwable e) {
try {
Files.writeString(dir.resolve("target-error.txt"), e + " " + e.getCause());
} catch (Exception ignored) {
e.printStackTrace();
}
}
}
private static boolean inspect(Path dir) throws Exception {
var windows = Window.getWindows().stream().filter(Window::isShowing).toList();
if (windows.isEmpty() || !Files.exists(dir.resolve("attempt"))) return false;
var root = windows.getFirst().getScene().getRoot();
String attempt = Files.readString(dir.resolve("attempt"));
if (attempt.equals("folder")) {
var grid = root.lookup("#grid");
if (grid == null) return false;
var grouping = (ChoiceBox<?>) root.lookup("#grouping");
if (!"Nach Ordner".equals(String.valueOf(grouping.getValue())))
throw new AssertionError("Wrong grouping choice: " + grouping.getValue());
var type = grid.getClass();
var cols = (List<?>) type.getMethod("getColumns").invoke(grid);
var first = cols.getFirst();
if (!"Archivdatei".equals(first.getClass().getMethod("getHeader").invoke(first)))
throw new AssertionError("Unexpected first column");
var texts =
root.lookupAll("*").stream()
.filter(Labeled.class::isInstance)
.map(n -> ((Labeled) n).getText())
.filter(Objects::nonNull)
.toList();
for (String expected : List.of("Archivdatei", "Musterrechnung.pdf", "Lieferbrief.txt"))
if (!texts.contains(expected))
throw new AssertionError("Missing " + expected + " in " + texts);
type.getMethod("select", Object.class).invoke(grid, "Musterrechnung.pdf");
Object key =
((ObservableValue<?>) type.getMethod("selectedKeyProperty").invoke(grid)).getValue();
Object row =
((ObservableValue<?>) type.getMethod("selectedElementProperty").invoke(grid))
.getValue();
if (!"Musterrechnung.pdf".equals(key)
|| !key.equals(row.getClass().getMethod("path").invoke(row)))
throw new AssertionError("Unstable selection " + key);
Files.writeString(
dir.resolve("result-folder"),
"Archivdatei · Musterrechnung.pdf · Lieferbrief.txt · selectedKey=" + key);
} else {
Node doc = null, details = null;
for (var n : root.lookupAll(".label"))
if (n instanceof Label label) {
if ("Dokument im Beispielarchiv".equals(label.getText())) doc = n;
if ("Belegnummer RE-2026-042".equals(label.getText())) details = n;
}
if (doc == null || details == null)
throw new AssertionError("Missing visible example content");
if (attempt.equals("bottom")) {
var pane = root.lookup("#dockPane");
var layout = pane.getClass().getMethod("getInitialLayout").invoke(pane);
var center = layout.getClass().getMethod("getCenter").invoke(layout);
var bottom = layout.getClass().getMethod("getBottom").invoke(layout);
if (!"VERTICAL"
.equals(center.getClass().getMethod("getOrientation").invoke(center).toString())
|| !"beleg".equals(bottom.getClass().getMethod("getDestinationId").invoke(bottom)))
throw new AssertionError("Target did not load the edited split and destination");
}
var a = doc.localToScene(doc.getBoundsInLocal());
var b = details.localToScene(details.getBoundsInLocal());
if (attempt.equals("right") ? b.getMinX() <= a.getMaxX() : b.getMinY() <= a.getMaxY())
throw new AssertionError("Wrong " + attempt + " arrangement: " + a + " / " + b);
Files.writeString(
dir.resolve("result-" + attempt),
"Dokument ("
+ (int) a.getMinX()
+ ","
+ (int) a.getMinY()
+ "), Belegnummer ("
+ (int) b.getMinX()
+ ","
+ (int) b.getMinY()
+ ")");
}
return true;
}
}
}
@@ -0,0 +1,317 @@
package qualification;
import static qualification.WorkflowProbe.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileEditor.*;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupActivity;
import com.intellij.openapi.vfs.*;
import de.neitzel.fxdesigner.kit.DesignerPane;
import java.nio.file.*;
import java.util.*;
import javafx.embed.swing.SwingFXUtils;
import javafx.scene.control.*;
import javafx.scene.image.*;
import javax.imageio.ImageIO;
import org.w3c.dom.Element;
/** Drives the inspector, native document and target preview in a disposable Archiver checkout. */
public final class GridDockWorkflowProbe implements StartupActivity.DumbAware {
private DesignerPane pane;
private VirtualFile file;
private Project project;
public void runActivity(Project project) {
if (!started.compareAndSet(false, true)) return;
this.project = project;
ApplicationManager.getApplication()
.executeOnPooledThread(
() -> {
try {
verify();
} catch (Throwable ex) {
try {
var trace = new java.io.StringWriter();
ex.printStackTrace(new java.io.PrintWriter(trace));
if (pane != null)
trace.append(
fx(
() ->
pane.lookupAll(".label").stream()
.filter(Label.class::isInstance)
.map(n -> ((Label) n).getText())
.filter(Objects::nonNull)
.toList()
.toString()));
Files.writeString(output.resolve("FAILURE.txt"), trace.toString());
} catch (Exception e) {
ex.printStackTrace();
}
}
});
}
private void step(String text) throws Exception {
Files.writeString(
output.resolve("steps.txt"),
text + "\n",
StandardOpenOption.CREATE,
StandardOpenOption.APPEND);
}
private String source() throws Exception {
return edt(() -> FileDocumentManager.getInstance().getDocument(file).getText());
}
private void open(Path path) throws Exception {
file = edt(() -> LocalFileSystem.getInstance().refreshAndFindFileByNioFile(path));
pane = openDesigner(project, file);
step("Opened " + file.getName());
}
private void inspector(boolean expanded) throws Exception {
fx(
() -> {
var panel =
(TitledPane)
pane.lookupAll(".titled-pane").stream()
.filter(n -> n instanceof TitledPane t && t.getText().equals("Bindings"))
.findFirst()
.orElseThrow();
panel.setAnimated(false);
panel.setExpanded(expanded);
var tabs = (TabPane) panel.getContent();
tabs.getSelectionModel()
.select(
tabs.getTabs().stream()
.filter(t -> t.getText().equals("DataGrid / Docking"))
.findFirst()
.orElseThrow());
pane.applyCss();
pane.layout();
return null;
});
}
private void select(String name, String id) throws Exception {
fx(
() -> {
var tree = (TreeView<Element>) pane.lookup("#declaration-tree");
for (int i = 0; i < tree.getExpandedItemCount(); i++) {
var item = tree.getTreeItem(i);
var e = item.getValue();
String tag = e.getTagName();
if ((tag.equals(name) || tag.endsWith("." + name))
&& (id.isEmpty()
|| e.getAttribute("id").equals(id)
|| e.getAttribute("destinationId").equals(id))) {
tree.getSelectionModel().select(item);
return null;
}
}
throw new AssertionError("Missing " + name + " " + id);
});
}
private void combo(String name, String text) throws Exception {
fx(
() -> {
var box = (ComboBox<String>) pane.lookup("#" + name);
box.setValue(text);
return null;
});
}
private void edit(String button, String expected) throws Exception {
String before = source();
click(pane, button);
await(
() -> {
String now = source();
var msg = fx(() -> ((Label) pane.lookup("#declaration-message")).getText());
if (!msg.isEmpty()) throw new AssertionError(msg);
return !now.equals(before)
&& now.contains(expected)
&& fx(
() ->
((TextArea) pane.lookup("#fxml-source")) == null
|| ((TextArea) pane.lookup("#fxml-source")).getText().equals(now));
});
fx(pane::flush).toCompletableFuture().get();
step(button + " · " + expected);
}
private void set(String field, String value) throws Exception {
combo("declaration-property", field);
fx(
() -> {
((ComboBox<?>) pane.lookup("#declaration-value")).getEditor().setText(value);
return null;
});
edit("Apply setting", field + "=\"" + value + "\"");
}
private void roundtrip(String previous) throws Exception {
String now = source();
click(pane, "Undo");
await(() -> source().equals(previous));
click(pane, "Redo");
await(() -> source().equals(now));
Path path = Path.of(file.getPath());
click(pane, "Save");
await(() -> Files.readString(path).equals(now));
edt(
() -> {
FileEditorManager.getInstance(project).closeFile(file);
return null;
});
open(path);
if (!source().equals(now)) throw new AssertionError("Reopened source differs");
}
private void checkPreviewState() {
var state = (Label) pane.lookup("#preview-state");
if (state != null
&& (state.getText().startsWith("Preview failed")
|| state.getText().startsWith("Preview unavailable")
|| state.getText().startsWith("Preview blocked")))
throw new AssertionError(state.getText());
}
private void preview(String id, boolean build) throws Exception {
step("Preview " + id);
click(pane, "Form preview");
click(pane, build ? "Build and Refresh" : "Preview last successful");
await(
() ->
fx(
() -> {
checkPreviewState();
return !((ComboBox<?>) pane.lookup("#preview-example")).getItems().isEmpty();
}));
fx(
() -> {
((ComboBox<?>) pane.lookup("#preview-example")).getSelectionModel().selectFirst();
((Spinner<?>) pane.lookup("#preview-height")).increment(5);
return null;
});
await(
() ->
fx(
() -> {
checkPreviewState();
var image = (ImageView) pane.lookup("#full-preview-image");
return image != null
&& image.getImage() != null
&& image.getImage().getHeight() == 720;
}));
fx(
() -> {
var image = ((ImageView) pane.lookup("#full-preview-image")).getImage();
ImageIO.write(
SwingFXUtils.fromFXImage(image, null), "png", output.resolve(id + ".png").toFile());
return null;
});
Files.writeString(output.resolve("attempt"), id);
click(pane, "Interactive preview");
await(
() -> {
if (Files.exists(output.resolve("target-error.txt")))
throw new AssertionError(Files.readString(output.resolve("target-error.txt")));
return Files.exists(output.resolve("result-" + id));
});
click(pane, "Stop preview");
step(Files.readString(output.resolve("result-" + id)));
}
private void verify() throws Exception {
Path root = Path.of(project.getBasePath()),
views = root.resolve("src/main/resources/de/neitzel/archiver/ui");
open(root.resolve("src/main/resources/ReferenceWorkspace.fxml"));
inspector(true);
select("DockGroupDefinition", "editors");
select("DockGroupDefinition", "changes");
open(views.resolve("FolderTab.fxml"));
inspector(true);
select("DataGrid", "");
combo("declaration-property", "items");
click(pane, "Edit data binding");
fx(
() -> {
if (!((TextField) pane.lookup("#direct-path")).getText().equals("rows"))
throw new AssertionError("Missing grid.items binding");
return null;
});
inspector(true);
select("DataGrid", "");
combo("declaration-property", "source");
click(pane, "Edit data binding");
fx(
() -> {
if (!((TextField) pane.lookup("#direct-property")).getText().equals("source"))
throw new AssertionError("Missing source binding input");
return null;
});
inspector(true);
select("DataGrid", "");
set("keyAttribute", "path");
set("selectionMode", "SINGLE");
set("pageSize", "25");
set("groupBy", "folder");
select("DataGridColumn", "path");
set("id", "document");
set("header", "Archivdatei");
set("width", "245");
set("kind", "TEXT");
set("filterable", "false");
edit("Later", "Archivdatei");
select("DataGridColumn", "document");
edit("Earlier", "Archivdatei");
edit("Add column", "id=\"column\"");
select("DataGridColumn", "column");
set("attribute", "folder");
set("checklist", "CURRENT_PAGE");
String before = source();
edit("Delete column", "Archivdatei");
roundtrip(before);
preview("folder", true);
open(views.resolve("ArchiveWindow.fxml"));
preview("right", false);
inspector(true);
select("right", "");
combo("dock-area", "bottom");
edit("Move area", "<bottom><DockGroupDefinition");
select("DockGroupDefinition", "details");
set("destinationId", "beleg");
set("visibleWhenEmpty", "true");
select("DockPane", "");
combo("dock-area", "left");
edit("Add area with group", "destinationId=\"left\"");
select("DockGroupDefinition", "messages");
edit("Split branch", "destinationId=\"split\"");
select("DockSplitDefinition", "split");
String horizontal = source();
set("orientation", "VERTICAL");
roundtrip(horizontal);
inspector(true);
select("DockSplitDefinition", "split");
select("DockGroupDefinition", "messages");
select("DockGroupDefinition", "beleg");
inspector(false);
preview("bottom", false);
fx(
() -> {
ImageIO.write(
SwingFXUtils.fromFXImage(pane.snapshot(null, null), null),
"png",
output.resolve("intellij.png").toFile());
return null;
});
Files.writeString(
output.resolve("SUCCESS.txt"),
"PASS registered IntelliJ DataGrid and Docking inspectors, reference workspace, native"
+ " edits/undo/redo/save/reopen, loaded Archiver rows and stable selection, two sample"
+ " contents moved from right to bottom.\n");
}
}
+5 -2
View File
@@ -24,7 +24,10 @@ p.add_argument("--mode", choices=["all", "classpath", "modulepath"], default="al
p.add_argument("--repeat", type=int, default=1, help="Consecutive independent runs per mode") p.add_argument("--repeat", type=int, default=1, help="Consecutive independent runs per mode")
p.add_argument("--archiver", type=Path, help="Qualify ArchiveWindow.fxml in a disposable project copy") p.add_argument("--archiver", type=Path, help="Qualify ArchiveWindow.fxml in a disposable project copy")
p.add_argument("--connection-form", action="store_true", help="Qualify the Archiver connection form") p.add_argument("--connection-form", action="store_true", help="Qualify the Archiver connection form")
p.add_argument("--grid-docking", type=Path, metavar="REFERENCE_FXML", help="Qualify the Archiver grid, dock layout and the supplied reference workspace")
args = p.parse_args() args = p.parse_args()
if args.grid_docking and (not args.archiver or args.connection_form):
p.error("--grid-docking requires --archiver and a separate run from --connection-form")
if args.connection_form and not args.archiver: if args.connection_form and not args.archiver:
p.error("--connection-form requires --archiver") p.error("--connection-form requires --archiver")
if args.repeat < 1: if args.repeat < 1:
@@ -37,7 +40,7 @@ modes = ("classpath",) if args.archiver else (("classpath", "modulepath") if arg
for run_number, mode in ((n, mode) for n in range(1, args.repeat + 1) for mode in modes): for run_number, mode in ((n, mode) for n in range(1, args.repeat + 1) for mode in modes):
crashes = NativeCrashGuard(ROOT) crashes = NativeCrashGuard(ROOT)
launch = subprocess.run([sys.executable, ROOT / "scripts/run-fixture-host.py", "intellij", launch = subprocess.run([sys.executable, ROOT / "scripts/run-fixture-host.py", "intellij",
"--check", *(["--connection-form"] if args.connection_form else []), *(["--archiver", str(args.archiver.resolve())] if args.archiver else []), "--mode", mode, "--java-home", args.java_home, "--check", *(["--grid-docking", str(args.grid_docking.resolve())] if args.grid_docking else []), *(["--connection-form"] if args.connection_form else []), *(["--archiver", str(args.archiver.resolve())] if args.archiver else []), "--mode", mode, "--java-home", args.java_home,
"--target-java-home", args.target_java_home, "--idea-home", args.idea_home], "--target-java-home", args.target_java_home, "--idea-home", args.idea_home],
cwd=ROOT, text=True, capture_output=True, timeout=60) cwd=ROOT, text=True, capture_output=True, timeout=60)
if launch.returncode: if launch.returncode:
@@ -81,7 +84,7 @@ for run_number, mode in ((n, mode) for n in range(1, args.repeat + 1) for mode i
shutil.copyfile(base / "intellij.png", output / (mode + ".png")) shutil.copyfile(base / "intellij.png", output / (mode + ".png"))
(evidence / "proof.json").write_text(json.dumps(proof, indent=2) + "\n") (evidence / "proof.json").write_text(json.dumps(proof, indent=2) + "\n")
finally: finally:
for name in ("SUCCESS.txt", "FAILURE.txt", "ui-state.txt", "launcher.log", "steps.txt", "target-error.txt", "preview-restored.png", "imap.png", "jmap.png", "intellij.png"): for name in ("SUCCESS.txt", "FAILURE.txt", "ui-state.txt", "launcher.log", "steps.txt", "target-error.txt", "preview-restored.png", "imap.png", "jmap.png", "folder.png", "right.png", "bottom.png", "result-folder", "result-right", "result-bottom", "intellij.png"):
if (base / name).exists(): if (base / name).exists():
shutil.copyfile(base / name, evidence / name) shutil.copyfile(base / name, evidence / name)
workers = descendant_workers(pid) workers = descendant_workers(pid)
+10
View File
@@ -20,7 +20,10 @@ p.add_argument("--check", action="store_true", help="Install the disposable IDE
p.add_argument("--mode", choices=["classpath","modulepath"], default="classpath") p.add_argument("--mode", choices=["classpath","modulepath"], default="classpath")
p.add_argument("--archiver", type=Path, help="Use a disposable copy of the Archiver project") p.add_argument("--archiver", type=Path, help="Use a disposable copy of the Archiver project")
p.add_argument("--connection-form", action="store_true", help="Open and qualify the Archiver connection form") p.add_argument("--connection-form", action="store_true", help="Open and qualify the Archiver connection form")
p.add_argument("--grid-docking", type=Path, metavar="REFERENCE_FXML", help="Qualify the Archiver grid, dock layout and the supplied reference workspace")
args = p.parse_args() args = p.parse_args()
if args.grid_docking and (not args.archiver or args.connection_form):
p.error("--grid-docking requires --archiver and a separate run from --connection-form")
if args.connection_form and not args.archiver: if args.connection_form and not args.archiver:
p.error("--connection-form requires --archiver") p.error("--connection-form requires --archiver")
base = Path(tempfile.mkdtemp(prefix="neitzel-designer-host-")).resolve() base = Path(tempfile.mkdtemp(prefix="neitzel-designer-host-")).resolve()
@@ -32,6 +35,9 @@ if args.archiver:
subprocess.run([sys.executable, ROOT / "scripts/configure-library-example.py", "--project", project, subprocess.run([sys.executable, ROOT / "scripts/configure-library-example.py", "--project", project,
"--target-java-home", args.target_java_home], check=True) "--target-java-home", args.target_java_home], check=True)
view = "ConnectionForm" if args.connection_form else "ArchiveWindow" view = "ConnectionForm" if args.connection_form else "ArchiveWindow"
if args.grid_docking:
view = "FolderTab"
shutil.copyfile(args.grid_docking, project / "src/main/resources/ReferenceWorkspace.fxml")
file = project / f"src/main/resources/de/neitzel/archiver/ui/{view}.fxml" file = project / f"src/main/resources/de/neitzel/archiver/ui/{view}.fxml"
else: else:
subprocess.run([sys.executable, ROOT / "scripts/prepare-fixture-host.py", "--destination", project, subprocess.run([sys.executable, ROOT / "scripts/prepare-fixture-host.py", "--destination", project,
@@ -61,10 +67,14 @@ else:
probe = "ArchiveWorkflowProbe" if args.archiver else "WorkflowProbe" probe = "ArchiveWorkflowProbe" if args.archiver else "WorkflowProbe"
if args.connection_form: if args.connection_form:
probe = "ConnectionWorkflowProbe" probe = "ConnectionWorkflowProbe"
if args.grid_docking:
probe = "GridDockWorkflowProbe"
files = [sources / "WorkflowProbe.java"] files = [sources / "WorkflowProbe.java"]
if args.archiver: if args.archiver:
files.append(sources / f"{probe}.java") files.append(sources / f"{probe}.java")
target_probe = "ConnectionTargetProbe" if args.connection_form else "ArchiveTargetProbe" target_probe = "ConnectionTargetProbe" if args.connection_form else "ArchiveTargetProbe"
if args.grid_docking:
target_probe = "GridDockTargetProbe"
agent_classes = base / "agent-classes" agent_classes = base / "agent-classes"
agent_classes.mkdir() agent_classes.mkdir()
subprocess.run([args.java_home / "bin/javac", "-cp", os.pathsep.join(map(str,jars)), "-d", agent_classes, subprocess.run([args.java_home / "bin/javac", "-cp", os.pathsep.join(map(str,jars)), "-d", agent_classes,