Edit single content slots, tab and split layouts, and grid setup declarations

This commit is contained in:
2026-11-25 09:40:39 +01:00
parent 95d26eb88b
commit dc3dd6b6be
12 changed files with 970 additions and 20 deletions
+2
View File
@@ -81,6 +81,8 @@ 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.
Use **TabPane / tabs** for a Tab, **SplitPane / items** for an ordered child, or select the named content slot on a Tab, ScrollPane or BorderPane. Add `--media-layout-grid` to the Archiver host check to exercise these destinations, the document media button and the folder grid. [Form and grid editing](docs/user-guide/authoring.md)
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. 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. 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.
@@ -14,9 +14,11 @@ final class FormDocument {
static { static {
register( register(
"javafx.scene.control", "javafx.scene.control",
"Label TextField TextArea PasswordField Button CheckBox ComboBox ToolBar"); "Label TextField TextArea PasswordField Button CheckBox ComboBox ToolBar Tab TabPane"
+ " ScrollPane SplitPane");
register( register(
"javafx.scene.layout", "GridPane VBox HBox StackPane AnchorPane FlowPane TilePane Pane"); "javafx.scene.layout",
"GridPane VBox HBox StackPane AnchorPane FlowPane TilePane Pane BorderPane");
register( register(
"de.neitzel.fx.control", "de.neitzel.fx.control",
"StatusBar ToolBarPane AutoCompleteTextField TagChip NonNegativeIntegerSpinner HtmlViewer"); "StatusBar ToolBarPane AutoCompleteTextField TagChip NonNegativeIntegerSpinner HtmlViewer");
@@ -107,7 +109,10 @@ final class FormDocument {
return switch (type) { return switch (type) {
case "GridPane", "HBox", "VBox", "StackPane", "Pane", "AnchorPane", "FlowPane", "TilePane" -> case "GridPane", "HBox", "VBox", "StackPane", "Pane", "AnchorPane", "FlowPane", "TilePane" ->
List.of("children"); List.of("children");
case "ToolBarPane", "ToolBar" -> List.of("items"); case "TabPane" -> List.of("tabs");
case "Tab", "ScrollPane" -> List.of("content");
case "BorderPane" -> List.of("center", "top", "bottom", "left", "right");
case "SplitPane", "ToolBarPane", "ToolBar" -> List.of("items");
case "StatusBar" -> List.of("leftItems", "rightItems"); case "StatusBar" -> List.of("leftItems", "rightItems");
default -> List.of(); default -> List.of();
}; };
@@ -174,13 +179,57 @@ final class FormDocument {
private List<Element> members(Slot slot) { private List<Element> members(Slot slot) {
Element host = owner(slot), list = property(host, slot.property()); Element host = owner(slot), list = property(host, slot.property());
if (list == null && slot.owner().type().equals("StatusBar")) return List.of(); if (list == null
return children(list == null ? host : list).stream() && (slot.owner().type().equals("StatusBar") || slot.owner().type().equals("BorderPane")))
.filter( return List.of();
e -> return children(list == null ? host : list).stream().filter(FormDocument::instance).toList();
!BindingDocument.FX.equals(e.getNamespaceURI()) }
&& Character.isUpperCase(simple(e.getTagName()).charAt(0)))
.toList(); private static boolean instance(Element child) {
if (BindingDocument.FX.equals(child.getNamespaceURI()))
return Set.of("include", "reference", "copy").contains(child.getLocalName());
return Character.isUpperCase(simple(child.getTagName()).charAt(0));
}
private static boolean single(Slot slot) {
return slot.property().equals("content") || slot.owner().type().equals("BorderPane");
}
String destinationInfo(Slot slot) {
if (slot == null || !single(slot)) return "";
var host = owner(slot);
if (host.hasAttribute(slot.property())) return "Single place · supplied by an FXML attribute.";
var children = members(slot);
if (!children.isEmpty()) {
var child = children.getFirst();
boolean movable = items.stream().anyMatch(item -> element(item) == child);
return "Single place · occupied by "
+ child.getTagName()
+ (movable
? ". Move that child to a free destination first."
: ". Choose another destination or edit this place in Source.");
}
var wrapper = property(host, slot.property());
if (wrapper != null && (!children(wrapper).isEmpty() || !wrapper.getTextContent().isBlank()))
return "Single place · supplied by FXML content. Review this place in Source.";
return "Single place · empty";
}
private void accept(String type, Slot slot, Element moving) {
if (type.equals("Tab") != slot.property().equals("tabs"))
throw new IllegalArgumentException(
slot.property().equals("tabs")
? "TabPane.tabs accepts Tab only."
: "A Tab belongs in TabPane.tabs. This destination accepts Nodes.");
if (owner(slot).hasAttribute(slot.property()))
throw new IllegalArgumentException("This destination is supplied by an FXML attribute.");
var wrapper = property(owner(slot), slot.property());
if (single(slot)
&& (members(slot).stream().anyMatch(e -> e != moving)
|| wrapper != null
&& members(slot).isEmpty()
&& (!wrapper.getTextContent().isBlank() || !children(wrapper).isEmpty())))
throw new IllegalArgumentException("Occupied: " + slot + ". " + destinationInfo(slot));
} }
int size(Slot slot) { int size(Slot slot) {
@@ -198,7 +247,8 @@ final class FormDocument {
} }
var container = property(owner, slot.property()); var container = property(owner, slot.property());
if (container != null) return xml.append(container, snippet, ""); if (container != null) return xml.append(container, snippet, "");
if (slot.owner().type().equals("StatusBar") if ((single(slot) && members.isEmpty())
|| slot.owner().type().equals("StatusBar")
|| (slot.owner().type().equals("ToolBarPane") && members.isEmpty())) || (slot.owner().type().equals("ToolBarPane") && members.isEmpty()))
snippet = "<" + slot.property() + ">" + snippet + "</" + slot.property() + ">"; snippet = "<" + slot.property() + ">" + snippet + "</" + slot.property() + ">";
return xml.append(owner, snippet, ""); return xml.append(owner, snippet, "");
@@ -234,6 +284,7 @@ final class FormDocument {
Edit add(String type, Slot slot, int at) { Edit add(String type, Slot slot, int at) {
var host = owner(slot); var host = owner(slot);
if (!TYPES.containsKey(type)) throw new IllegalArgumentException("Choose a palette control."); if (!TYPES.containsKey(type)) throw new IllegalArgumentException("Choose a palette control.");
accept(type, slot, null);
String id = fresh(type), prefix = fxPrefix(host), qualified = TYPES.get(type); String id = fresh(type), prefix = fxPrefix(host), qualified = TYPES.get(type);
var edits = new ArrayList<Replacement>(); var edits = new ArrayList<Replacement>();
String tagName = type; String tagName = type;
@@ -245,7 +296,10 @@ final class FormDocument {
} }
} }
String extra = String extra =
type.equals("Label") || type.equals("Button") || type.equals("TagChip") type.equals("Label")
|| type.equals("Button")
|| type.equals("TagChip")
|| type.equals("Tab")
? " text=\"" + type + "\"" ? " text=\"" + type + "\""
: ""; : "";
if (slot.owner().type().equals("GridPane")) { if (slot.owner().type().equals("GridPane")) {
@@ -292,6 +346,7 @@ final class FormDocument {
throw new IllegalArgumentException("Only a child in a supported list can be moved."); throw new IllegalArgumentException("Only a child in a supported list can be moved.");
for (Node n = host; n != null; n = n.getParentNode()) for (Node n = host; n != null; n = n.getParentNode())
if (n == source) throw new IllegalArgumentException("Cannot move a control into itself."); if (n == source) throw new IllegalArgumentException("Cannot move a control into itself.");
accept(item.type(), slot, source);
var current = members(slot); var current = members(slot);
int old = current.indexOf(source); int old = current.indexOf(source);
if (old >= 0 && (at == old || at == old + 1)) return edit(List.of(), item.id()); if (old >= 0 && (at == old || at == old + 1)) return edit(List.of(), item.id());
@@ -316,6 +371,14 @@ final class FormDocument {
List<Field> fields(Item item) { List<Field> fields(Item item) {
var e = element(item); var e = element(item);
var fields = new LinkedHashMap<String, Field>(); var fields = new LinkedHashMap<String, Field>();
if (item.type().equals("Tab")) {
field(fields, "text", "String", "");
field(fields, "closable", "Boolean", "true");
field(fields, "disable", "Boolean", "false");
field(fields, "style", "CSS", "");
field(fields, "styleClass", "CSS classes", "tab");
return withSourceFields(e, fields);
}
field(fields, "accessibleText", "String", ""); field(fields, "accessibleText", "String", "");
if (Set.of("TextField", "PasswordField", "AutoCompleteTextField").contains(item.type())) if (Set.of("TextField", "PasswordField", "AutoCompleteTextField").contains(item.type()))
field(fields, "prefColumnCount", "Integer", "12"); field(fields, "prefColumnCount", "Integer", "12");
@@ -394,6 +457,10 @@ final class FormDocument {
} }
for (String name : List.of("width", "height")) for (String name : List.of("width", "height"))
fields.put(name, new Field(name, "Number", "layout", false)); fields.put(name, new Field(name, "Number", "layout", false));
return withSourceFields(e, fields);
}
private static List<Field> withSourceFields(Element e, Map<String, Field> fields) {
for (int i = 0; i < e.getAttributes().getLength(); i++) { for (int i = 0; i < e.getAttributes().getLength(); i++) {
var a = e.getAttributes().item(i); var a = e.getAttributes().item(i);
if (a.getNamespaceURI() == null) if (a.getNamespaceURI() == null)
@@ -10,6 +10,7 @@ import javafx.scene.layout.*;
final class FormEditor extends VBox { final class FormEditor extends VBox {
private final ComboBox<String> palette = combo("form-palette"); private final ComboBox<String> palette = combo("form-palette");
private final ComboBox<FormDocument.Slot> destination = combo("form-destination"); private final ComboBox<FormDocument.Slot> destination = combo("form-destination");
private final Label destinationInfo = new Label();
private final Spinner<Integer> position = new Spinner<>(0, 0, 0); private final Spinner<Integer> position = new Spinner<>(0, 0, 0);
private final ComboBox<FormDocument.Item> selected = combo("form-control"); private final ComboBox<FormDocument.Item> selected = combo("form-control");
private final ComboBox<FormDocument.Field> field = combo("form-property"); private final ComboBox<FormDocument.Field> field = combo("form-property");
@@ -75,6 +76,7 @@ final class FormEditor extends VBox {
palette.getValue(), palette.getValue(),
destination.getValue(), destination.getValue(),
position.getValue())))), position.getValue())))),
destinationInfo,
row( row(
new Label("Selected control"), new Label("Selected control"),
selected, selected,
@@ -171,6 +173,10 @@ final class FormEditor extends VBox {
private void setPosition() { private void setPosition() {
var slot = destination.getValue(); var slot = destination.getValue();
String hint = form == null ? "" : form.destinationInfo(slot);
destinationInfo.setText(hint);
destinationInfo.setVisible(!hint.isEmpty());
destinationInfo.setManaged(!hint.isEmpty());
int size = form == null || slot == null ? 0 : form.size(slot); int size = form == null || slot == null ? 0 : form.size(slot);
position.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, size, size)); position.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, size, size));
} }
@@ -13,6 +13,8 @@ final class GridDockDocument {
"DataGrid", "DataGrid",
List.of( List.of(
"keyAttribute", "keyAttribute",
"setupId",
"setupVersion",
"pageSize", "pageSize",
"maximumPageSize", "maximumPageSize",
"selectionMode", "selectionMode",
@@ -33,7 +35,9 @@ final class GridDockDocument {
"maximumWidth", "maximumWidth",
"filterable", "filterable",
"checklist", "checklist",
"groupAttribute"), "groupAttribute",
"fixedPosition",
"groupLabels"),
"DockGroupDefinition", "DockGroupDefinition",
List.of( List.of(
"destinationId", "destinationId",
@@ -177,9 +181,54 @@ final class GridDockDocument {
return id; return id;
} }
Map<String, String> groupLabels(Element column) {
var names = new TreeMap<String, String>();
var map = property(column, "groupLabels");
if (map != null)
for (int i = 0; i < map.getAttributes().getLength(); i++) {
var attr = map.getAttributes().item(i);
if (attr.getNamespaceURI() == null
&& literalKey(attr.getNodeName())
&& !reference(attr.getNodeValue()))
names.put(attr.getNodeName(), attr.getNodeValue().replaceFirst("^\\\\", ""));
}
return names;
}
private static boolean literalKey(String key) {
// FXMLLoader reads an inline, read-only Map's ordinary property attributes as keys.
return key.matches("[\\p{L}_][\\p{L}\\p{N}_-]*")
&& !key.equals("xmlns")
&& !key.startsWith("on");
}
private static boolean reference(String text) {
return !text.isEmpty() && "%@$".indexOf(text.charAt(0)) >= 0;
}
List<Replacement> groupLabel(Element column, String key, String label, boolean remove) {
if (!type(column).equals("DataGridColumn") || !literalKey(key))
throw new IllegalArgumentException(
"Use a literal FXML map key (letters, digits, underscores or hyphens).");
if (column.hasAttribute("groupLabels"))
throw new IllegalArgumentException("This groupLabels map is supplied by an attribute.");
var map = property(column, "groupLabels");
if (map != null && (property(map, key) != null || reference(map.getAttribute(key))))
throw new IllegalArgumentException("This key is supplied by a nested value or reference.");
if (remove && (map == null || !map.hasAttribute(key))) return List.of();
if (!remove && label.isBlank()) throw new IllegalArgumentException("Enter a group label.");
String encoded = (reference(label) || label.startsWith("\\")) ? "\\" + label : label;
if (map == null)
return List.of(
xml.append(
column, "<groupLabels " + key + "=\"" + XmlSource.escape(encoded, '"') + "\"/>", ""));
return xml.source.attributes(
xml.elements.indexOf(map), Collections.singletonMap(key, remove ? null : encoded));
}
List<Replacement> set(Element e, String field, String value) { List<Replacement> set(Element e, String field, String value) {
if (!SETTINGS.getOrDefault(type(e), List.of()).contains(field) if (!SETTINGS.getOrDefault(type(e), List.of()).contains(field)
|| Set.of("items", "source").contains(field)) || Set.of("items", "source", "groupLabels").contains(field))
throw new IllegalArgumentException("Use a model binding for the data input."); throw new IllegalArgumentException("Use a model binding for the data input.");
if (property(e, field) != null) if (property(e, field) != null)
throw new IllegalArgumentException( throw new IllegalArgumentException(
@@ -210,6 +259,15 @@ final class GridDockDocument {
&& Set.of("pageSize", "maximumPageSize").contains(field) && Set.of("pageSize", "maximumPageSize").contains(field)
&& Integer.parseInt(value) < 1) && Integer.parseInt(value) < 1)
throw new IllegalArgumentException("Positive page size required"); throw new IllegalArgumentException("Positive page size required");
if (field.equals("setupVersion") && !value.isEmpty() && Integer.parseInt(value) < 1)
throw new IllegalArgumentException("Setup version must be a positive integer.");
if (field.equals("fixedPosition") && !value.isEmpty()) {
int index = branches(parentOfType(e, "DataGrid")).indexOf(e);
int fixed = Integer.parseInt(value);
if (fixed != -1 && fixed != index)
throw new IllegalArgumentException(
"Use " + index + " for this column, or -1 to allow moving it.");
}
var edits = new ArrayList<Replacement>(); var edits = new ArrayList<Replacement>();
if (field.equals("destinationId") if (field.equals("destinationId")
&& destinations(e).stream().anyMatch(c -> c != e && c.getAttribute(field).equals(value))) && destinations(e).stream().anyMatch(c -> c != e && c.getAttribute(field).equals(value)))
@@ -273,13 +331,24 @@ final class GridDockDocument {
if (index < 0) throw new IllegalArgumentException("Select a column."); if (index < 0) throw new IllegalArgumentException("Select a column.");
if (index + delta < 0 || index + delta >= columns.size()) return List.of(); if (index + delta < 0 || index + delta >= columns.size()) return List.of();
var other = columns.get(index + delta); var other = columns.get(index + delta);
if (fixed(col) || fixed(other))
throw new IllegalArgumentException("Clear the fixed position before moving these columns.");
return List.of(replace(other, fragment(col)), replace(col, fragment(other))); return List.of(replace(other, fragment(col)), replace(col, fragment(other)));
} }
private boolean fixed(Element col) {
return property(col, "fixedPosition") != null
|| col.hasAttribute("fixedPosition") && !col.getAttribute("fixedPosition").equals("-1");
}
List<Replacement> removeColumn(Element col) { List<Replacement> removeColumn(Element col) {
if (!type(col).equals("DataGridColumn")) throw new IllegalArgumentException("Select a column."); if (!type(col).equals("DataGridColumn")) throw new IllegalArgumentException("Select a column.");
if (grouped(parentOfType(col, "DataGrid")).contains(col.getAttribute("id"))) if (grouped(parentOfType(col, "DataGrid")).contains(col.getAttribute("id")))
throw new IllegalArgumentException("Remove the column from groupBy first."); throw new IllegalArgumentException("Remove the column from groupBy first.");
var columns = branches(parentOfType(col, "DataGrid"));
if (columns.subList(columns.indexOf(col) + 1, columns.size()).stream().anyMatch(this::fixed))
throw new IllegalArgumentException(
"Removing this column shifts a fixed column. Clear its fixed position first.");
var span = tag(col); var span = tag(col);
int start = xml.text.lastIndexOf('\n', span.start() - 1) + 1; int start = xml.text.lastIndexOf('\n', span.start() - 1) + 1;
int end = xml.text.indexOf('\n', span.end()); int end = xml.text.indexOf('\n', span.end());
@@ -13,6 +13,13 @@ final class GridDockEditor extends VBox {
private final ComboBox<String> setting = new ComboBox<>(), private final ComboBox<String> setting = new ComboBox<>(),
value = new ComboBox<>(), value = new ComboBox<>(),
area = new ComboBox<>(); area = new ComboBox<>();
private final ComboBox<String> groupKey = new ComboBox<>();
private final TextField groupText = new TextField();
private final FlowPane groupFields = new FlowPane(6, 4);
private final Label setupHint =
new Label(
"Saved setups use the setup ID and version. Restoring an older version requires a"
+ " migration.");
private final Label message = new Label(), private final Label message = new Label(),
signals = signals =
new Label( new Label(
@@ -55,6 +62,38 @@ final class GridDockEditor extends VBox {
() -> () ->
doc.set( doc.set(
selected(), setting.getValue(), value.getEditor().getText().trim()))); selected(), setting.getValue(), value.getEditor().getText().trim())));
groupKey.setId("group-label-key");
groupKey.setEditable(true);
groupKey.setPromptText("Group key");
groupText.setId("group-label-text");
groupText.setPromptText("Displayed label");
groupKey.setOnAction(
event -> {
if (selected() != null && groupKey.getValue() != null)
groupText.setText(doc.groupLabels(selected()).getOrDefault(groupKey.getValue(), ""));
});
groupFields
.getChildren()
.addAll(
groupKey,
groupText,
button(
"Set group label",
() ->
edit(
() ->
doc.groupLabel(
selected(),
groupKey.getEditor().getText(),
groupText.getText(),
false))),
button(
"Remove group label",
() ->
edit(
() ->
doc.groupLabel(selected(), groupKey.getEditor().getText(), "", true))));
setupHint.setWrapText(true);
bind = bind =
button( button(
"Edit data binding", "Edit data binding",
@@ -82,6 +121,8 @@ final class GridDockEditor extends VBox {
tree, tree,
new FlowPane(6, 4, setting, value, apply, bind), new FlowPane(6, 4, setting, value, apply, bind),
new FlowPane(6, 4, add, earlier, later, remove, area, addArea, moveArea, split), new FlowPane(6, 4, add, earlier, later, remove, area, addArea, moveArea, split),
groupFields,
setupHint,
signals, signals,
message); message);
tree.getSelectionModel().selectedItemProperty().addListener((o, a, b) -> select()); tree.getSelectionModel().selectedItemProperty().addListener((o, a, b) -> select());
@@ -185,7 +226,17 @@ final class GridDockEditor extends VBox {
String field = setting.getValue(); String field = setting.getValue();
var e = selected(); var e = selected();
boolean input = "items".equals(field) || "source".equals(field); boolean input = "items".equals(field) || "source".equals(field);
boolean editable = e != null && field != null && !input; boolean labels = e != null && "groupLabels".equals(field);
visible(groupFields, labels);
visible(setupHint, "setupId".equals(field) || "setupVersion".equals(field));
if (labels) {
groupKey.getItems().setAll(doc.groupLabels(e).keySet());
groupKey.getSelectionModel().clearSelection();
groupKey.getEditor().clear();
groupText.clear();
groupKey.getSelectionModel().selectFirst();
}
boolean editable = e != null && field != null && !input && !labels;
visible(bind, input); visible(bind, input);
visible(apply, editable); visible(apply, editable);
visible(value, editable); visible(value, editable);
@@ -45,6 +45,28 @@ class FormDocumentTest {
apply(doc.set(item, field, value == null ? "" : value, value == null)); apply(doc.set(item, field, value == null ? "" : value, value == null));
} }
@Test
void singleSlotsRespectReferencesAndDefaultTabContent() throws Exception {
source =
"""
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<BorderPane xmlns:fx="http://javafx.com/fxml/1" bottom="$footer">
<center><TabPane fx:id="tabs"><Tab fx:id="first"><ScrollPane fx:id="scroll">
<content><fx:include source="Other.fxml"/></content>
</ScrollPane></Tab></TabPane></center>
</BorderPane>
""";
add("Tab", "tabs", "tabs");
assertThrows(IllegalArgumentException.class, () -> add("Label", "first", "content"));
assertThrows(IllegalArgumentException.class, () -> add("Label", "scroll", "content"));
assertThrows(IllegalArgumentException.class, () -> add("Label", "", "bottom"));
assertThrows(IllegalArgumentException.class, () -> add("Label", "tabs", "tabs"));
apply(doc().move(item("scroll"), slot("tab", "content"), 0));
assertTrue(source.contains("<content><fx:include source=\"Other.fxml\"/></content>"));
add("Label", "first", "content");
}
@Test @Test
void emptyGridAndNamedListsKeepReferencesAndRejectCycles() throws Exception { void emptyGridAndNamedListsKeepReferencesAndRejectCycles() throws Exception {
assertEquals( assertEquals(
@@ -5,6 +5,25 @@ import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
class GridDockDocumentTest { class GridDockDocumentTest {
@Test
void updatingOneGroupLabelRetainsReferencesCommentsAndNestedEntries() throws Exception {
String source =
"""
<?import de.neitzel.fx.view.*?>
<DataGrid><DataGridColumn id="folder" header="Folder"><groupLabels other="%localized" Post='old'>
<!-- keep --><custom><Unknown/></custom></groupLabels></DataGridColumn></DataGrid>
""";
var doc = new GridDockDocument(source);
var col = doc.branches(doc.roots().getFirst()).getFirst();
assertEquals(
source.replace("Post='old'", "Post='Post &amp; Briefe'"),
doc.xml.source.apply(doc.groupLabel(col, "Post", "Post & Briefe", false)));
assertThrows(
IllegalArgumentException.class, () -> doc.groupLabel(col, "other", "changed", false));
assertThrows(IllegalArgumentException.class, () -> doc.groupLabel(col, "custom", "", true));
assertThrows(IllegalArgumentException.class, () -> doc.set(col, "fixedPosition", "2"));
}
@Test @Test
void implicitRowAttributeAndGroupingSurviveRename() throws Exception { void implicitRowAttributeAndGroupingSurviveRename() throws Exception {
var source = var source =
+10
View File
@@ -45,3 +45,13 @@ Errors block new previews; warnings remain visible and permit preview. Stale dia
In **Form controls**, select a control and property. **Set property** writes the FXML attribute. **Reset property** removes it and restores its JavaFX default. The accessible name is inherited from Node. Text fields including AutoCompleteTextField accept a non-negative integer for `prefColumnCount`. Layout results such as `width` are read-only. In **Form controls**, select a control and property. **Set property** writes the FXML attribute. **Reset property** removes it and restores its JavaFX default. The accessible name is inherited from Node. Text fields including AutoCompleteTextField accept a non-negative integer for `prefColumnCount`. Layout results such as `width` are read-only.
After **Build and Refresh**, select `onAction` on a supported action control, `onDismiss` on ToolBarPane, or `onRemove` on TagChip. Choose a compiled controller method in the list, or enter its `#method` reference and select **Set property**. The target checks accessible no-argument methods and methods accepting ActionEvent or Event, including inherited and FXML-annotated handlers. Without current controller metadata the inspector indicates that a build is needed for method checking. Undo, Redo and Save use the same FXML document as the bindings editor. After **Build and Refresh**, select `onAction` on a supported action control, `onDismiss` on ToolBarPane, or `onRemove` on TagChip. Choose a compiled controller method in the list, or enter its `#method` reference and select **Set property**. The target checks accessible no-argument methods and methods accepting ActionEvent or Event, including inherited and FXML-annotated handlers. Without current controller metadata the inspector indicates that a build is needed for method checking. Undo, Redo and Save use the same FXML document as the bindings editor.
### Tabs, split panes and border panes
In **Form controls**, choose **Tab** from the palette and **TabPane / tabs** as the destination. Set its text under **Selected control**. Select **Tab / content** to add a layout or a ScrollPane. Each Tab, ScrollPane and named BorderPane region has one content slot. The inspector shows its occupant. To reuse an occupied slot, move its existing control to a free destination first. **Move to destination** keeps the subtree, its identifiers, event handlers and bindings together. For **SplitPane / items**, **Position** is the zero-based insertion index.
### Grid setups and group headings
Under **Bindings → DataGrid / Docking**, select the grid to edit `setupId` or `setupVersion`. Clear the field and use **Apply setting** to restore the default. Persisted settings identify the grid by its setup ID. Restoring an older definition version requires a migration for that version.
Select a column and set `fixedPosition` to its current zero-based index. Clear the field or enter `-1` to make it movable. Under `groupLabels`, select or enter a literal FXML map key and its display text, then use **Set group label** or **Remove group label**. For the Archiver folder example, group by `folder` and label `Post` as **Posteingang**. Collapsing that heading still stores the key `Post`. Keys represented by resource references or nested declarations can be reviewed in **Source**.
@@ -0,0 +1,362 @@
package qualification;
import java.lang.reflect.*;
import java.nio.file.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
import javafx.application.Platform;
import javafx.beans.value.*;
import javafx.event.ActionEvent;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.*;
import javax.imageio.ImageIO;
/** Acts on the actual controls in the interactive Archiver worker. */
public final class MediaLayoutGridTargetProbe {
public static void premain(String dir) {
if (System.getProperty("sun.java.command", "")
.startsWith("de.neitzel.fxdesigner.target.WorkerMain "))
Thread.ofPlatform().daemon().start(() -> Worker.run(Path.of(dir)));
}
private static final class Worker {
private static <T> T fx(Callable<T> action) throws Exception {
var task = new FutureTask<>(action);
Platform.runLater(task);
return task.get(10, TimeUnit.SECONDS);
}
private static void require(boolean value, String message) {
if (!value) throw new AssertionError(message);
}
private static void run(Path dir) {
try {
Stage stage = null;
while (stage == null) {
Thread.sleep(120);
try {
stage =
fx(
() ->
Window.getWindows().stream()
.filter(
w ->
w instanceof Stage s
&& s.isShowing()
&& s.getOpacity() > 0
&& s.getTitle() != null
&& s.getTitle().startsWith("Neitzel preview"))
.map(Stage.class::cast)
.findFirst()
.orElse(null));
} catch (IllegalStateException starting) {
}
}
Stage shown = stage;
var attempt = Files.readString(dir.resolve("layout-case"));
fx(
() -> {
shown.setWidth(1180);
shown.setHeight(660);
return null;
});
await(
"Resized interactive preview",
() -> shown.getScene().getWidth() >= 1100 && shown.getScene().getHeight() >= 550);
var root =
fx(
() -> {
var node = shown.getScene().getRoot();
node.applyCss();
node.layout();
return node;
});
String result =
switch (attempt) {
case "offline" -> fx(() -> offline(root));
case "details" -> fx(() -> details(root, dir));
case "trash" -> fx(() -> trash(root, dir));
case "media" -> media(root, dir);
case "grid" -> fx(() -> grid(root, dir));
default -> throw new IllegalArgumentException(attempt);
};
Files.writeString(dir.resolve("result-" + attempt), result);
} catch (Throwable failure) {
var trace = new java.io.StringWriter();
failure.printStackTrace(new java.io.PrintWriter(trace));
try {
Files.writeString(dir.resolve("target-error.txt"), trace.toString());
} catch (Exception ignored) {
}
}
}
private static String offline(Node root) {
var media = (Button) root.lookup("#external-media-load");
require(
media.isDisabled() && media.getAccessibleText().equals("Belegbilder laden"),
"Offline: " + media.getAccessibleText());
require(media.getTooltip().getText().contains("Keine auflösbaren"), "Offline tooltip");
return "Rechnung ohne Medien · gespeicherter Aktionsname, Tooltip und gesperrter Button";
}
private static String details(Parent root, Path dir) throws Exception {
var tabs = (TabPane) root;
require(
tabs.getTabs().stream()
.map(Tab::getText)
.toList()
.equals(List.of("Tags", "Datei", "Belegprüfung")),
"Tab order");
var moved = tabs.getTabs().getLast();
tabs.getSelectionModel().select(moved);
root.applyCss();
root.layout();
var scroll = (ScrollPane) moved.getContent();
var box = (HBox) scroll.getContent();
var input = (TextField) box.lookup("#tag-input");
require(input != null && tabs.getTabs().getFirst().getContent() == null, "Moved HBox");
require(
((List<?>) input.getClass().getMethod("getSuggestionsSource").invoke(input))
.contains("Beleg geprüft"),
"Bound suggestions");
input.setText("Beleg geprüft");
input.fireEvent(new ActionEvent());
require(box.lookupAll(".tag-chip").size() == 2, "Moved tag handler and Repeat");
image(root, dir.resolve("details-moved.png"));
return "Dritter Tab → ScrollPane → ursprüngliche HBox · Vorschlagsquelle, onAction und beide"
+ " TagChips wirksam";
}
private static String trash(Parent root, Path dir) throws Exception {
var split = (SplitPane) root.lookup(".split-pane");
require(
split.getItems().size() == 3
&& "trash-items".equals(split.getItems().getFirst().getId())
&& split.getItems().get(1) instanceof Label l
&& "Dateien der Auswahl".equals(l.getText())
&& "trash-files".equals(split.getItems().getLast().getId()),
"SplitPane order");
require(
((TableView<?>) split.getItems().getLast()).getItems().size() == 2,
"Selected folder files");
image(root, dir.resolve("trash-split.png"));
return "Beschriftung an Position 2 zwischen beiden Tabellen · zwei Dateien im markierten"
+ " Ordner";
}
private static void await(String name, Callable<Boolean> test) throws Exception {
long end = System.nanoTime() + TimeUnit.SECONDS.toNanos(14);
while (System.nanoTime() < end) {
if (fx(test)) return;
Thread.sleep(60);
}
throw new AssertionError(name);
}
private static Object get(Object target, String method) throws Exception {
return target.getClass().getMethod(method).invoke(target);
}
private static String media(Parent root, Path dir) throws Exception {
var group =
fx(
() ->
root.lookupAll(".tab-pane").stream()
.map(TabPane.class::cast)
.filter(
p ->
p.getTabs().stream()
.anyMatch(t -> t.getText().equals("Rechnung.html")))
.findFirst()
.orElseThrow());
fx(
() -> {
require(
root instanceof BorderPane p
&& p.getLeft() instanceof Label l
&& l.getText().equals("Medienprüfung")
&& p.getCenter().lookup("#dockPane") != null,
"BorderPane and docking");
return null;
});
var invoice = select(group, "Rechnung.html");
fx(() -> offline(invoice));
var delivery = select(group, "Lieferschein.html");
var viewer = fx(() -> delivery.lookup("#html-document"));
var button = fx(() -> (Button) delivery.lookup("#external-media-load"));
var blockedDuringLoad = new AtomicBoolean();
fx(
() -> {
require(
((Label) root.lookup("#status")).getText().equals("Lokale Bildanfragen · 0"),
"Request before grant");
require(
!button.isDisabled()
&& button.getAccessibleText().equals("Belegbilder laden")
&& button.getTooltip().getText().contains("Belegbilder laden")
&& button.getTooltip().getText().contains("Kontaktiert die Bildserver"),
"Delivery action");
var loading = (ObservableBooleanValue) get(viewer, "loadingProperty");
loading.addListener(
(obs, old, active) -> {
if (active && button.isDisabled()) blockedDuringLoad.set(true);
});
button.fire();
return null;
});
await(
"Granted image and request",
() -> {
var engine = get(viewer.lookup("WebView"), "getEngine");
var pixels =
engine
.getClass()
.getMethod("executeScript", String.class)
.invoke(engine, "document.images.length ? document.images[0].naturalWidth : 0");
return ((Label) root.lookup("#status")).getText().equals("Lokale Bildanfragen · 1")
&& !button.isDisabled()
&& ((Number) pixels).intValue() == 24;
});
fx(
() -> {
require(
blockedDuringLoad.get()
&& (boolean) get(viewer, "isExternalImagesAllowed")
&& button.getAccessibleText().equals("Externe Medien erneut laden"),
"Loading / reload states");
image(root, dir.resolve("media-granted.png"));
return null;
});
var other = select(group, "Rechnung.html");
fx(
() -> {
offline(other);
require(
!(boolean) get(other.lookup("#html-document"), "isExternalImagesAllowed"),
"Invoice inherited grant");
return null;
});
select(group, "Lieferschein.html");
fx(
() -> {
require(
!button.isDisabled() && button.getAccessibleText().contains("erneut"),
"Return to delivery");
button.fire();
return null;
});
await(
"Reload reached loopback",
() ->
((Label) root.lookup("#status")).getText().equals("Lokale Bildanfragen · 2")
&& !button.isDisabled());
return "BorderPane.left mit intaktem Docking · HTTP-Anfragen 0 → 1 → 2 · Bildbreite 24 px,"
+ " Ladesperre, erneutes Laden und tabbezogene Freigabe geprüft";
}
private static Node select(TabPane tabs, String title) throws Exception {
return fx(
() -> {
var tab =
tabs.getTabs().stream()
.filter(t -> title.equals(t.getText()))
.findFirst()
.orElseThrow();
tabs.getSelectionModel().select(tab);
tabs.applyCss();
tabs.layout();
return tab.getContent();
});
}
private static String grid(Parent root, Path dir) throws Exception {
Node grid = root.lookup("#grid");
var setup = get(grid, "snapshotSetup");
require(
get(setup, "definitionId").equals("archiver-pruefung")
&& get(setup, "definitionVersion").equals(2),
"Setup identity");
var cols = (List<?>) get(setup, "columns");
var order = new ArrayList<String>();
for (var col : cols) order.add((String) get(col, "id"));
require(order.get(1).equals("folder"), "Column position");
Collections.swap(order, 0, 1);
try {
grid.getClass().getMethod("setColumnOrder", List.class).invoke(grid, order);
throw new AssertionError("Fixed column displaced");
} catch (InvocationTargetException ex) {
require(
ex.getCause() instanceof IllegalArgumentException
&& ex.getCause().getMessage().contains("Fixed"),
"Fixed position check");
}
var heading =
grid.lookupAll(".group-heading").stream()
.map(Button.class::cast)
.filter(b -> b.getText().contains("Posteingang"))
.findFirst()
.orElseThrow();
require(
grid.lookupAll(".group-heading").stream()
.map(Button.class::cast)
.anyMatch(b -> b.getText().contains("Rechnungen")),
"Other group");
image(root, dir.resolve("grid-group.png"));
heading.fire();
var grouping = get(get(grid, "snapshotSetup"), "grouping");
var choice = ((List<?>) get(grouping, "choices")).getFirst();
var segment = ((List<?>) get(get(choice, "path"), "segments")).getFirst();
require(
get(segment, "columnId").equals("folder")
&& get(get(segment, "value"), "value").equals("Post"),
"Changed group key");
for (String id : List.of("archive-folder", "archiver-pruefung")) {
var fields = setup.getClass().getRecordComponents();
Object[] values = new Object[fields.length];
for (int i = 0; i < fields.length; i++)
values[i] =
switch (fields[i].getName()) {
case "definitionId" -> id;
case "definitionVersion" -> 1;
default -> fields[i].getAccessor().invoke(setup);
};
var old =
setup
.getClass()
.getConstructor(
Arrays.stream(fields).map(RecordComponent::getType).toArray(Class<?>[]::new))
.newInstance(values);
grid.getClass().getMethod("restoreSetup", setup.getClass()).invoke(grid, old);
var state = ((ObservableValue<?>) get(grid, "stateProperty")).getValue();
var error = (Throwable) get(state, "error");
require(
error != null
&& error
.getMessage()
.contains(
id.equals("archive-folder")
? "another grid definition"
: "Missing definition migration"),
"Wrong setup restore " + error);
}
return "Setup archiver-pruefung/2 · fremde ID und alte Version abgewiesen · folder fest an"
+ " Index 1 · Posteingang sichtbar, Gruppenschlüssel Post";
}
private static void image(Node node, Path path) throws Exception {
var img = node.snapshot(null, null);
int w = (int) img.getWidth(), h = (int) img.getHeight();
var out = new java.awt.image.BufferedImage(w, h, java.awt.image.BufferedImage.TYPE_INT_ARGB);
int[] pixels = new int[w * h];
img.getPixelReader()
.getPixels(0, 0, w, h, javafx.scene.image.PixelFormat.getIntArgbInstance(), pixels, 0, w);
out.setRGB(0, 0, w, h, pixels, 0, w);
ImageIO.write(out, "png", path.toFile());
}
}
}
@@ -0,0 +1,336 @@
package qualification;
import static qualification.WorkflowProbe.*;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.LocalFileSystem;
import de.neitzel.fxdesigner.workflow.DesignerWorkflow.Example;
import java.nio.file.*;
import java.util.*;
import javafx.embed.swing.SwingFXUtils;
import javafx.scene.control.*;
import javafx.scene.image.ImageView;
import javax.imageio.ImageIO;
import org.w3c.dom.Element;
/** Edits original Archiver forms in the registered IntelliJ designer. */
public final class MediaLayoutGridWorkflowProbe extends FormWorkflowProbe {
private Project project;
void verify(Project project) throws Exception {
this.project = project;
open("HtmlDocument");
controls(true);
choose("form-control", "HtmlViewer #article");
set("mediaLoadText", "Belegbilder laden", "mediaLoadText=\"Belegbilder laden\"");
reopen("HtmlDocument", "Belegbilder laden");
build("html-invoice");
interactive("html-invoice", "offline");
details();
trash();
window();
folder();
Files.writeString(output.resolve("SUCCESS.txt"), Files.readString(output.resolve("steps.txt")));
}
private void insert(String type, String slot, int position, String id) throws Exception {
choose("form-palette", type);
choose("form-destination", slot);
if (position >= 0)
fx(
() -> {
((Spinner<Integer>) pane.lookup("#form-position")).getValueFactory().setValue(position);
return null;
});
String before = source();
click(pane, "Insert control");
edited(before, "fx:id=\"" + id + "\"");
}
private void reject(String type, String slot, String reason) throws Exception {
choose("form-palette", type);
choose("form-destination", slot);
String before = source();
click(pane, "Insert control");
if (!before.equals(source())
|| !fx(() -> ((Label) pane.lookup("#form-message")).getText()).contains(reason))
throw new AssertionError("Expected " + reason);
}
private void history(String before, String after) throws Exception {
click(pane, "Undo");
await(() -> source().equals(before));
click(pane, "Redo");
await(() -> source().equals(after));
fx(pane::flush).toCompletableFuture().get();
}
private List<String> declarations() throws Exception {
return source()
.lines()
.map(String::trim)
.filter(
l ->
l.startsWith("<DirectBinding ")
|| l.startsWith("<CommandBinding ")
|| l.startsWith("<Repeat "))
.toList();
}
private void details() throws Exception {
open("DocumentDetails");
controls(true);
var original = declarations();
reject("Label", "TabPane [", "TabPane.tabs accepts Tab");
reject("Label", "ScrollPane [", "Occupied");
insert("Tab", "TabPane [", -1, "tab");
choose("form-control", "Tab #tab");
set("text", "Belegprüfung", "text=\"Belegprüfung\"");
insert("ScrollPane", "Tab #tab / content", 0, "scrollPane");
choose("form-control", "HBox [");
choose("form-destination", "ScrollPane #scrollPane / content");
String before = source();
click(pane, "Move to destination");
edited(before, "onAction=\"#addTag\"");
history(before, source());
reopen("DocumentDetails", "Belegprüfung");
if (!original.equals(declarations())) throw new AssertionError("Moved bindings");
build("details-invoice");
interactive("details-invoice", "details");
}
private void trash() throws Exception {
open("TrashPane");
controls(true);
insert("Label", "SplitPane [", 1, "label");
choose("form-control", "Label #label");
set("text", "Dateien der Auswahl", "text=\"Dateien der Auswahl\"");
reopen("TrashPane", "Dateien der Auswahl");
build("trash-full");
interactive("trash-full", "trash");
}
private void window() throws Exception {
open("ArchiveWindow");
controls(true);
String left =
fx(
() ->
((ComboBox<?>) pane.lookup("#form-destination"))
.getItems().stream()
.map(Object::toString)
.filter(v -> v.startsWith("BorderPane [") && v.endsWith(" / left"))
.findFirst()
.orElseThrow());
String owner = left.substring(0, left.lastIndexOf(" / "));
for (String region : List.of("center", "top", "bottom", "left", "right")) {
choose("form-destination", owner + " / " + region);
}
reject("Label", owner + " / center", "Occupied");
insert("Label", left, 0, "label");
choose("form-control", "Label #label");
set("text", "Medienprüfung", "text=\"Medienprüfung\"");
reopen("ArchiveWindow", "Medienprüfung");
build("archive-window-media");
interactive("archive-window-media", "media");
}
private void folder() throws Exception {
open("FolderTab");
inspector(true);
var original = declarations();
select("DataGrid", "grid");
gridSet("setupId", "archiver-pruefung");
gridSet("setupVersion", "2");
for (var pair :
List.of(List.of("setupId", "archiver-pruefung"), List.of("setupVersion", "2"))) {
String before = source();
combo("declaration-property", pair.getFirst());
fx(
() -> {
((ComboBox<?>) pane.lookup("#declaration-value")).getEditor().clear();
return null;
});
click(pane, "Apply setting");
await(() -> !source().contains(pair.getFirst() + "=\""));
click(pane, "Undo");
await(() -> source().equals(before));
}
gridSet("groupBy", "folder");
select("DataGridColumn", "folder");
gridSet("fixedPosition", "1");
combo("declaration-property", "groupLabels");
fx(
() -> {
((ComboBox<?>) pane.lookup("#group-label-key")).getEditor().setText("Post");
((TextField) pane.lookup("#group-label-text")).setText("Posteingang");
return null;
});
String before = source();
edit("Set group label", "Post=\"Posteingang\"");
String grouped = source();
history(before, grouped);
combo("declaration-property", "groupLabels");
choose("group-label-key", "Post");
click(pane, "Remove group label");
await(() -> !source().contains("Post=\"Posteingang\""));
click(pane, "Undo");
await(() -> source().equals(grouped));
reopen("FolderTab", "Posteingang");
if (!original.equals(declarations())) throw new AssertionError("Grid bindings");
inspector(true);
select("DataGridColumn", "folder");
combo("declaration-property", "groupLabels");
if (!fx(() -> ((TextField) pane.lookup("#group-label-text")).getText().equals("Posteingang")))
throw new AssertionError("Reopened mapping");
fx(
() -> {
ImageIO.write(
SwingFXUtils.fromFXImage(pane.snapshot(null, null), null),
"png",
output.resolve("intellij.png").toFile());
return null;
});
build("archive-folder");
interactive("archive-folder", "grid");
}
private void open(String name) throws Exception {
var path =
Path.of(project.getBasePath(), "src/main/resources/de/neitzel/archiver/ui", name + ".fxml");
file = edt(() -> LocalFileSystem.getInstance().refreshAndFindFileByNioFile(path));
pane = openDesigner(project, file);
if (!source().contains("<?neitzel-model de.neitzel.archiver.ui."))
throw new AssertionError(name);
}
private void build(String id) throws Exception {
click(pane, "Form preview");
click(pane, "Build and Refresh");
await(
() ->
fx(
() ->
((ComboBox<?>) pane.lookup("#preview-example"))
.getItems().stream().anyMatch(item -> item.toString().contains(id))));
}
private void interactive(String id, String attempt) throws Exception {
choose("preview-example", id);
await(
() ->
fx(
() -> {
var state = ((Label) pane.lookup("#preview-state")).getText();
if (state.startsWith("Preview failed")
|| state.startsWith("Preview blocked")
|| state.startsWith("Preview unavailable"))
throw new AssertionError(id + " · " + state);
var choice = (Example) ((ComboBox<?>) pane.lookup("#preview-example")).getValue();
return ((ImageView) pane.lookup("#full-preview-image")).getImage() != null
&& state.contains(choice.label());
}));
Files.writeString(output.resolve("layout-case"), attempt);
click(pane, "Interactive preview");
String name = "result-" + attempt;
awaitTarget(name);
step(id + " · " + Files.readString(output.resolve(name)));
click(pane, "Stop preview");
}
private void reopen(String form, String saved) throws Exception {
click(pane, "Save");
await(() -> Files.readString(Path.of(file.getPath())).contains(saved));
edt(
() -> {
FileEditorManager.getInstance(project).closeFile(file);
return null;
});
open(form);
if (!source().contains(saved)) throw new AssertionError("Reopened " + form);
}
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("fx:id").equals(id)
|| 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 gridSet(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 + "\"");
}
}
+4 -3
View File
@@ -26,13 +26,14 @@ p.add_argument("--archiver", type=Path, help="Qualify ArchiveWindow.fxml in a di
forms = p.add_mutually_exclusive_group() forms = p.add_mutually_exclusive_group()
forms.add_argument("--connection-form", action="store_true", help="Qualify the Archiver connection form") forms.add_argument("--connection-form", action="store_true", help="Qualify the Archiver connection form")
forms.add_argument("--grid-docking", type=Path, metavar="REFERENCE_FXML", help="Qualify the Archiver grid, dock layout and the supplied reference workspace") forms.add_argument("--grid-docking", type=Path, metavar="REFERENCE_FXML", help="Qualify the Archiver grid, dock layout and the supplied reference workspace")
forms.add_argument("--media-layout-grid", action="store_true", help="Verify media permissions, form destinations and grid setups in the Archiver")
forms.add_argument("--management-readers", action="store_true", help="Verify account and trash commands and the five reader toolbars") forms.add_argument("--management-readers", action="store_true", help="Verify account and trash commands and the five reader toolbars")
forms.add_argument("--folder-actions", action="store_true", help="Check visual event references, folder search, selection and display profiles") forms.add_argument("--folder-actions", action="store_true", help="Check visual event references, folder search, selection and display profiles")
forms.add_argument("--import-form", action="store_true", help="Check generic binding types and the Archiver import collision") forms.add_argument("--import-form", action="store_true", help="Check generic binding types and the Archiver import collision")
forms.add_argument("--document-tabs", action="store_true", help="Qualify the production Archiver HTML document tabs") forms.add_argument("--document-tabs", action="store_true", help="Qualify the production Archiver HTML document tabs")
forms.add_argument("--saved-document", action="store_true", help="Open the Archiver saved HTML and tag example") forms.add_argument("--saved-document", action="store_true", help="Open the Archiver saved HTML and tag example")
args = p.parse_args() args = p.parse_args()
if (args.connection_form or args.grid_docking or args.saved_document or args.document_tabs or args.import_form or args.folder_actions or args.management_readers) and not args.archiver: if (args.connection_form or args.grid_docking or args.saved_document or args.document_tabs or args.import_form or args.folder_actions or args.management_readers or args.media_layout_grid) and not args.archiver:
p.error("Selecting an Archiver view requires --archiver") p.error("Selecting an Archiver view requires --archiver")
if args.repeat < 1: if args.repeat < 1:
p.error("--repeat must be positive") p.error("--repeat must be positive")
@@ -44,7 +45,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", *(["--management-readers"] if args.management_readers else []), *(["--folder-actions"] if args.folder_actions else []), *(["--import-form"] if args.import_form else []), *(["--document-tabs"] if args.document_tabs else []), *(["--saved-document"] if args.saved_document else []), *(["--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, "--check", *(["--media-layout-grid"] if args.media_layout_grid else []), *(["--management-readers"] if args.management_readers else []), *(["--folder-actions"] if args.folder_actions else []), *(["--import-form"] if args.import_form else []), *(["--document-tabs"] if args.document_tabs else []), *(["--saved-document"] if args.saved_document else []), *(["--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:
@@ -88,7 +89,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 ("reader-pdf.png", "reader-epub.png", "reader-slides.png", "reader-attachment.png", "management-accounts.png", "management-trash.png", "reader-icon.png", "folder-events.png", "folder-search.png", "folder-profile.png", "result-folder-actions", "result-detail-action", "details-invoice-tags.png", "details-delivery-tags.png", "details-invoice.png", "details-delivery.png", "details-readonly.png", "details-busy.png", "html-invoice.png", "html-delivery.png", "rechnung-zwei-tags.png", "import-collision.png", "import-accepted.png", "result-import-free", "result-import-busy", "result-import-collision", "result-import-grid", "SUCCESS.txt", "FAILURE.txt", "ui-state.txt", "launcher.log", "steps.txt", "target-error.txt", "preview-restored.png", "imap.png", "jmap.png", "invoice.png", "delivery.png", "saved-document-result", "saved-bindings.fxml", "binding-article.png", "binding-dynamic.png", "tags-Pr.png", "tags-Re.png", "tags-Li.png", "document-tabs-result", "rechnung-tab.png", "lieferschein-tab.png", "rechnung-tab-tags.png", "lieferschein-tab-tags.png", "folder.png", "right.png", "bottom.png", "result-folder", "result-right", "result-bottom", "intellij.png"): for name in ("media-granted.png", "details-moved.png", "trash-split.png", "grid-group.png", "reader-pdf.png", "reader-epub.png", "reader-slides.png", "reader-attachment.png", "management-accounts.png", "management-trash.png", "reader-icon.png", "folder-events.png", "folder-search.png", "folder-profile.png", "result-folder-actions", "result-detail-action", "details-invoice-tags.png", "details-delivery-tags.png", "details-invoice.png", "details-delivery.png", "details-readonly.png", "details-busy.png", "html-invoice.png", "html-delivery.png", "rechnung-zwei-tags.png", "import-collision.png", "import-accepted.png", "result-import-free", "result-import-busy", "result-import-collision", "result-import-grid", "SUCCESS.txt", "FAILURE.txt", "ui-state.txt", "launcher.log", "steps.txt", "target-error.txt", "preview-restored.png", "imap.png", "jmap.png", "invoice.png", "delivery.png", "saved-document-result", "saved-bindings.fxml", "binding-article.png", "binding-dynamic.png", "tags-Pr.png", "tags-Re.png", "tags-Li.png", "document-tabs-result", "rechnung-tab.png", "lieferschein-tab.png", "rechnung-tab-tags.png", "lieferschein-tab-tags.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)
+7 -2
View File
@@ -22,13 +22,14 @@ p.add_argument("--archiver", type=Path, help="Use a disposable copy of the Archi
forms = p.add_mutually_exclusive_group() forms = p.add_mutually_exclusive_group()
forms.add_argument("--connection-form", action="store_true", help="Open and qualify the Archiver connection form") forms.add_argument("--connection-form", action="store_true", help="Open and qualify the Archiver connection form")
forms.add_argument("--grid-docking", type=Path, metavar="REFERENCE_FXML", help="Qualify the Archiver grid, dock layout and the supplied reference workspace") forms.add_argument("--grid-docking", type=Path, metavar="REFERENCE_FXML", help="Qualify the Archiver grid, dock layout and the supplied reference workspace")
forms.add_argument("--media-layout-grid", action="store_true", help="Verify media permissions, form destinations and grid setups in the Archiver")
forms.add_argument("--management-readers", action="store_true", help="Verify account and trash commands and the five reader toolbars") forms.add_argument("--management-readers", action="store_true", help="Verify account and trash commands and the five reader toolbars")
forms.add_argument("--folder-actions", action="store_true", help="Check visual event references, folder search, selection and display profiles") forms.add_argument("--folder-actions", action="store_true", help="Check visual event references, folder search, selection and display profiles")
forms.add_argument("--import-form", action="store_true", help="Check generic binding types and the Archiver import collision") forms.add_argument("--import-form", action="store_true", help="Check generic binding types and the Archiver import collision")
forms.add_argument("--document-tabs", action="store_true", help="Qualify the production Archiver HTML document tabs") forms.add_argument("--document-tabs", action="store_true", help="Qualify the production Archiver HTML document tabs")
forms.add_argument("--saved-document", action="store_true", help="Open the Archiver saved HTML and tag example") forms.add_argument("--saved-document", action="store_true", help="Open the Archiver saved HTML and tag example")
args = p.parse_args() args = p.parse_args()
if (args.connection_form or args.grid_docking or args.saved_document or args.document_tabs or args.import_form or args.folder_actions or args.management_readers) and not args.archiver: if (args.connection_form or args.grid_docking or args.saved_document or args.document_tabs or args.import_form or args.folder_actions or args.management_readers or args.media_layout_grid) and not args.archiver:
p.error("Selecting an Archiver view requires --archiver") p.error("Selecting an Archiver view requires --archiver")
base = Path(tempfile.mkdtemp(prefix="neitzel-designer-host-")).resolve() base = Path(tempfile.mkdtemp(prefix="neitzel-designer-host-")).resolve()
project = base / "project" project = base / "project"
@@ -39,6 +40,8 @@ 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.media_layout_grid:
view = "HtmlDocument"
if args.management_readers: if args.management_readers:
view = "MailControls" view = "MailControls"
if args.folder_actions: if args.folder_actions:
@@ -106,6 +109,8 @@ else:
suite = "Connection" suite = "Connection"
elif args.grid_docking: elif args.grid_docking:
suite = "GridDock" suite = "GridDock"
elif args.media_layout_grid:
suite = "MediaLayoutGrid"
elif args.management_readers: elif args.management_readers:
suite = "ManagementReaders" suite = "ManagementReaders"
elif args.folder_actions: elif args.folder_actions:
@@ -118,7 +123,7 @@ else:
suite = "SavedDocument" suite = "SavedDocument"
probe = f"{suite}WorkflowProbe" if args.archiver else "WorkflowProbe" probe = f"{suite}WorkflowProbe" if args.archiver else "WorkflowProbe"
files = [sources / "WorkflowProbe.java"] files = [sources / "WorkflowProbe.java"]
if args.connection_form or args.saved_document or args.document_tabs or args.import_form or args.folder_actions or args.management_readers: if args.connection_form or args.saved_document or args.document_tabs or args.import_form or args.folder_actions or args.management_readers or args.media_layout_grid:
files.append(sources / "FormWorkflowProbe.java") files.append(sources / "FormWorkflowProbe.java")
if args.archiver: if args.archiver:
files.append(sources / f"{probe}.java") files.append(sources / f"{probe}.java")