From 92e852e936593ad7b61c986b7a7b36ca0293f60a Mon Sep 17 00:00:00 2001 From: Konrad Neitzel Date: Wed, 25 Nov 2026 09:55:35 +0100 Subject: [PATCH] Edit docking group constraints and qualify document tab behavior in IntelliJ --- README.md | 2 + .../fxdesigner/kit/GridDockDocument.java | 18 +- .../fxdesigner/kit/GridDockEditor.java | 10 + .../fxdesigner/kit/GridDockDocumentTest.java | 25 ++ docs/user-guide/authoring.md | 12 + .../idea/DeclarationWorkflowProbe.java | 155 ++++++++ .../idea/DockRulesTargetProbe.java | 331 ++++++++++++++++++ .../idea/DockRulesWorkflowProbe.java | 104 ++++++ .../idea/MediaLayoutGridWorkflowProbe.java | 154 +------- scripts/check-ide-host.py | 7 +- scripts/run-fixture-host.py | 9 +- 11 files changed, 671 insertions(+), 156 deletions(-) create mode 100644 integration-tests/idea/DeclarationWorkflowProbe.java create mode 100644 integration-tests/idea/DockRulesTargetProbe.java create mode 100644 integration-tests/idea/DockRulesWorkflowProbe.java diff --git a/README.md b/README.md index 7b5ba13..d59d71f 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,8 @@ In **Form controls**, select the palette type, destination child list and insert 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) +In `ArchiveWindow.fxml`, select a named DockGroupDefinition to edit minimum dimensions, allowed split directions and persistence. The Archiver host check accepts `--dock-rules` to exercise the document tab context menus at two window sizes and compare the destinations after closing the last tab. [Dock group settings and example](docs/user-guide/authoring.md#dock-group-size-splitting-and-persistence) + 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. diff --git a/designer-kit-ui/src/main/java/de/neitzel/fxdesigner/kit/GridDockDocument.java b/designer-kit-ui/src/main/java/de/neitzel/fxdesigner/kit/GridDockDocument.java index abe605a..5008e9f 100644 --- a/designer-kit-ui/src/main/java/de/neitzel/fxdesigner/kit/GridDockDocument.java +++ b/designer-kit-ui/src/main/java/de/neitzel/fxdesigner/kit/GridDockDocument.java @@ -47,7 +47,11 @@ final class GridDockDocument { "releaseSpaceWhenEmpty", "collapsible", "preferredWidth", - "preferredHeight"), + "preferredHeight", + "minimumWidth", + "minimumHeight", + "persistent", + "splitDirections"), "DockSplitDefinition", List.of("destinationId", "orientation", "position")); static List options(String field) { @@ -56,6 +60,7 @@ final class GridDockDocument { "groupingEnabled", "groupsCollapsed", "visibleWhenEmpty", + "persistent", "releaseSpaceWhenEmpty", "collapsible" -> List.of("true", "false"); @@ -63,6 +68,7 @@ final class GridDockDocument { case "selectionMode" -> List.of("NONE", "SINGLE", "MULTIPLE"); case "tabSide" -> List.of("TOP", "RIGHT", "BOTTOM", "LEFT"); case "mode" -> List.of("DOCKED", "OVERLAY"); + case "splitDirections" -> List.of("ALL", "NONE", "HORIZONTAL", "VERTICAL"); case "orientation" -> List.of("HORIZONTAL", "VERTICAL"); case "kind" -> List.of("TEXT", "INTEGER", "DECIMAL", "BOOLEAN"); default -> List.of(); @@ -246,14 +252,22 @@ final class GridDockDocument { && Set.of( "width", "minimumWidth", + "minimumHeight", "maximumWidth", "preferredWidth", "preferredHeight", "position") .contains(field)) { double n = Double.parseDouble(value); - if (!Double.isFinite(n) || n <= 0 || field.equals("position") && n >= 1) + boolean groupMinimum = + type(e).equals("DockGroupDefinition") + && (field.equals("minimumWidth") || field.equals("minimumHeight")); + if (groupMinimum) { + if (!Double.isFinite(n) || n < 0) + throw new IllegalArgumentException("Enter a finite group minimum of 0 or more pixels."); + } else 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) diff --git a/designer-kit-ui/src/main/java/de/neitzel/fxdesigner/kit/GridDockEditor.java b/designer-kit-ui/src/main/java/de/neitzel/fxdesigner/kit/GridDockEditor.java index f407447..6cf953a 100644 --- a/designer-kit-ui/src/main/java/de/neitzel/fxdesigner/kit/GridDockEditor.java +++ b/designer-kit-ui/src/main/java/de/neitzel/fxdesigner/kit/GridDockEditor.java @@ -241,6 +241,16 @@ final class GridDockEditor extends VBox { visible(apply, editable); visible(value, editable); if (!editable) return; + String hint = + doc.type(e).equals("DockGroupDefinition") + ? switch (field) { + case "minimumWidth", "minimumHeight" -> "Default: 80 px"; + case "persistent" -> "Default: true"; + case "splitDirections" -> "Default: ALL"; + default -> ""; + } + : ""; + value.setPromptText(hint); value.getItems().setAll(GridDockDocument.options(field)); value.setValue(e.getAttribute(field)); value.getEditor().setText(e.getAttribute(field)); diff --git a/designer-kit-ui/src/test/java/de/neitzel/fxdesigner/kit/GridDockDocumentTest.java b/designer-kit-ui/src/test/java/de/neitzel/fxdesigner/kit/GridDockDocumentTest.java index c63c875..0ea792c 100644 --- a/designer-kit-ui/src/test/java/de/neitzel/fxdesigner/kit/GridDockDocumentTest.java +++ b/designer-kit-ui/src/test/java/de/neitzel/fxdesigner/kit/GridDockDocumentTest.java @@ -5,6 +5,31 @@ import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; class GridDockDocumentTest { + @Test + void dockMinimaAllowZeroWithoutChangingGridColumnRules() throws Exception { + var source = + ""; + var doc = new GridDockDocument(source); + var group = doc.xml.elements.getFirst(); + for (String field : java.util.List.of("minimumWidth", "minimumHeight")) { + for (String invalid : java.util.List.of("-1", "NaN", "Infinity", "wide")) + assertThrows(IllegalArgumentException.class, () -> doc.set(group, field, invalid)); + var changed = new GridDockDocument(doc.xml.source.apply(doc.set(group, field, "0"))); + var reset = + new GridDockDocument( + changed.xml.source.apply(changed.set(changed.xml.elements.getFirst(), field, ""))); + var result = reset.xml.elements.getFirst(); + assertFalse(result.hasAttribute(field)); + assertEquals("messages", result.getAttribute("destinationId")); + } + assertThrows(IllegalArgumentException.class, () -> doc.set(group, "persistent", "yes")); + assertThrows(IllegalArgumentException.class, () -> doc.set(group, "splitDirections", "RIGHT")); + var grid = new GridDockDocument(""); + assertThrows( + IllegalArgumentException.class, + () -> grid.set(grid.xml.elements.getFirst(), "minimumWidth", "0")); + } + @Test void updatingOneGroupLabelRetainsReferencesCommentsAndNestedEntries() throws Exception { String source = diff --git a/docs/user-guide/authoring.md b/docs/user-guide/authoring.md index 8dcad44..a0cdfff 100644 --- a/docs/user-guide/authoring.md +++ b/docs/user-guide/authoring.md @@ -55,3 +55,15 @@ In **Form controls**, choose **Tab** from the palette and **TabPane / tabs** as 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**. + +### Dock group size, splitting and persistence + +Open `ArchiveWindow.fxml` and select **Bindings → DataGrid / Docking → DockGroupDefinition · messages**. Select a property and use **Apply setting**. Clearing the value restores its FXML default. + +| Group property | Values and effect | +| --- | --- | +| `minimumWidth`, `minimumHeight` | Finite pixel values from 0 upwards, default 80 each. Both groups and their divider must fit before a split is available. | +| `splitDirections` | `HORIZONTAL` allows left and right, `VERTICAL` allows above and below, `NONE` disables splitting and `ALL` is the default. | +| `persistent` | The default `true` keeps an empty root group available as a destination. With `false`, closing its last tab removes the group. Inside a split, the surviving sibling fills the vacated branch. | + +After saving, choose **Form preview → Build and Refresh → Archiver · HTML-Dokumenttabs → Interactive preview**. Open the context menu of **Lieferschein.html** and use **Split**. Unavailable directions show the reason in the menu. Resize the window to test the minimum dimensions. To inspect persistence, move the delivery tab to `details` and close the invoice. Open **Move to** on the remaining delivery tab to see whether `messages` is still available. diff --git a/integration-tests/idea/DeclarationWorkflowProbe.java b/integration-tests/idea/DeclarationWorkflowProbe.java new file mode 100644 index 0000000..d44b6a4 --- /dev/null +++ b/integration-tests/idea/DeclarationWorkflowProbe.java @@ -0,0 +1,155 @@ +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 javafx.scene.control.*; +import javafx.scene.image.ImageView; +import org.w3c.dom.Element; + +/** Shared actions for editing declarations and opening the resulting Archiver preview. */ +abstract class DeclarationWorkflowProbe extends FormWorkflowProbe { + Project project; + + 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(" + fx( + () -> + ((ComboBox) pane.lookup("#preview-example")) + .getItems().stream().anyMatch(item -> item.toString().contains(id)))); + } + + 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"); + } + + 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); + } + + 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; + }); + } + + void select(String name, String id) throws Exception { + fx( + () -> { + var tree = (TreeView) 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); + }); + } + + void combo(String name, String text) throws Exception { + fx( + () -> { + var box = (ComboBox) pane.lookup("#" + name); + box.setValue(text); + return null; + }); + } + + 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); + } + + void applySetting(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 + "\""); + } +} diff --git a/integration-tests/idea/DockRulesTargetProbe.java b/integration-tests/idea/DockRulesTargetProbe.java new file mode 100644 index 0000000..c6f3dde --- /dev/null +++ b/integration-tests/idea/DockRulesTargetProbe.java @@ -0,0 +1,331 @@ +package qualification; + +import java.nio.file.*; +import java.util.*; +import java.util.concurrent.*; +import javafx.application.Platform; +import javafx.geometry.Side; +import javafx.scene.Parent; +import javafx.scene.control.*; +import javafx.stage.*; + +/** Operates the document tabs' ordinary context menus in the interactive Archiver worker. */ +public final class DockRulesTargetProbe { + public static void premain(String directory) { + if (System.getProperty("sun.java.command", "") + .startsWith("de.neitzel.fxdesigner.target.WorkerMain ")) + Thread.ofPlatform().daemon().start(() -> Worker.run(Path.of(directory))); + } + + private static final class Worker { + private static final String INVOICE = "Rechnung.html", DELIVERY = "Lieferschein.html"; + + static T fx(Callable action) throws Exception { + var task = new FutureTask<>(action); + Platform.runLater(task); + return task.get(10, TimeUnit.SECONDS); + } + + static void run(Path dir) { + try { + Stage stage = null; + while (stage == null) { + Thread.sleep(100); + try { + stage = + fx( + () -> + Window.getWindows().stream() + .filter(Stage.class::isInstance) + .map(Stage.class::cast) + .filter( + s -> + s.isShowing() + && s.getOpacity() > 0 + && Objects.toString(s.getTitle(), "") + .startsWith("Neitzel preview")) + .findFirst() + .orElse(null)); + } catch (IllegalStateException starting) { + /* Await JavaFX startup. */ + } + } + Stage preview = stage; + String attempt = Files.readString(dir.resolve("layout-case")); + Parent root = fx(() -> preview.getScene().getRoot()); + String result; + if (attempt.equals("defaults")) { + result = fx(() -> defaults(root)); + } else { + boolean horizontal = attempt.equals("horizontal"); + require(horizontal || attempt.equals("vertical"), attempt); + resize(preview, 640, 440); + String small = fx(() -> checkRules(root, horizontal, false)); + resize(preview, 1340, 760); + String large = fx(() -> checkRules(root, horizontal, true)); + await(() -> tab(root, INVOICE).getTabPane() != tab(root, DELIVERY).getTabPane()); + String split = fx(() -> inspectSplit(root, horizontal, dir)); + fx( + () -> { + move(root, DELIVERY, "details"); + return null; + }); + await(() -> tab(root, INVOICE).getTabPane().getTabs().size() == 1); + fx( + () -> { + var invoice = tab(root, INVOICE); + var menu = menu(invoice); + item(menu.getItems(), "Close", "Schließen").fire(); + return null; + }); + await(() -> tabs(root).stream().noneMatch(t -> t.getText().equals(INVOICE))); + String empty = fx(() -> verifyEmpty(root, !horizontal, dir)); + result = small + "\n" + large + "\n" + split + "\n" + empty; + } + 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 ex) { + ex.printStackTrace(); + } + } + } + + static void await(Callable test) throws Exception { + long end = System.nanoTime() + TimeUnit.SECONDS.toNanos(10); + while (System.nanoTime() < end) { + if (fx(test)) return; + Thread.sleep(50); + } + throw new AssertionError("Preview state did not settle"); + } + + static void resize(Stage stage, int width, int height) throws Exception { + fx( + () -> { + stage.setWidth(width); + stage.setHeight(height); + return null; + }); + await( + () -> + Math.abs(stage.getScene().getWidth() - width) < 12 + && stage.getScene().getHeight() > height - 60 + && stage.getScene().getHeight() <= height); + fx( + () -> { + layout(stage.getScene().getRoot()); + return null; + }); + } + + static void layout(Parent root) { + root.applyCss(); + root.layout(); + } + + static void require(boolean ok, String reason) { + if (!ok) throw new AssertionError(reason); + } + + static List tabs(Parent root) { + return root.lookupAll(".dock-group").stream() + .map(TabPane.class::cast) + .flatMap(p -> p.getTabs().stream()) + .toList(); + } + + static Tab tab(Parent root, String name) { + return tabs(root).stream().filter(t -> name.equals(t.getText())).findFirst().orElseThrow(); + } + + static ContextMenu menu(Tab tab) { + var m = tab.getContextMenu(); + m.show(tab.getTabPane(), Side.TOP, 0, 0); + return m; + } + + static MenuItem item(List items, String... labels) { + return items.stream() + .filter( + i -> + Arrays.stream(labels) + .anyMatch( + l -> + l.equals(i.getText()) + || i.getText().startsWith(l + " (") + || i.getText().startsWith(l + " —"))) + .findFirst() + .orElseThrow( + () -> + new AssertionError( + "Missing " + + Arrays.toString(labels) + + " in " + + items.stream().map(MenuItem::getText).toList())); + } + + static String checkRules(Parent root, boolean horizontal, boolean large) { + var delivery = tab(root, DELIVERY); + var group = delivery.getTabPane(); + require(tab(root, INVOICE).getTabPane() == group, "Initial document group"); + require(group.minWidth(-1) == 300 && group.minHeight(-1) == 225, "Effective minima"); + var m = menu(delivery); + var choices = ((Menu) item(m.getItems(), "Split", "Teilen")).getItems(); + var right = item(choices, "Right", "Rechts"); + var below = item(choices, "Below", "Unten"); + var blocked = horizontal ? below : right; + var allowed = horizontal ? right : below; + require( + blocked.isDisable() + && (blocked.getText().contains("direction") + || blocked.getText().contains("Richtung")), + blocked.getText()); + // Exercise the checked operation as well as its disabled presentation. + blocked.fire(); + require( + tab(root, INVOICE).getTabPane() == tab(root, DELIVERY).getTabPane(), + "Forbidden split changed layout"); + String size = Math.round(group.getWidth()) + " × " + Math.round(group.getHeight()); + if (!large) { + require( + allowed.isDisable() + && (horizontal + ? group.getWidth() < 2 * group.minWidth(-1) + 8 + : group.getHeight() < 2 * group.minHeight(-1) + 8) + && !allowed.getText().equals(blocked.getText()), + size + " · " + allowed.getText()); + allowed.fire(); + require( + tab(root, INVOICE).getTabPane() == tab(root, DELIVERY).getTabPane(), + "Small split changed layout"); + } else { + require(!allowed.isDisable(), size + " · " + allowed.getText()); + allowed.fire(); + } + m.hide(); + return (large ? "1340 × 760" : "640 × 440") + + " · Gruppe " + + size + + " · " + + blocked.getText() + + " · " + + allowed.getText(); + } + + static String inspectSplit(Parent root, boolean horizontal, Path dir) throws Exception { + layout(root); + var first = tab(root, INVOICE).getTabPane(); + var second = tab(root, DELIVERY).getTabPane(); + for (var group : List.of(first, second)) { + require(group.getWidth() >= 300 && group.getHeight() >= 225, "Split child below minimum"); + require( + group.minWidth(-1) == 300 && group.minHeight(-1) == 225, + "Split did not inherit minima"); + } + var a = first.localToScene(first.getLayoutBounds()); + var b = second.localToScene(second.getLayoutBounds()); + require( + horizontal ? b.getMinX() >= a.getMaxX() - 1 : b.getMinY() >= a.getMaxY() - 1, + "Geometric split direction"); + require( + first.lookup("#html-document") != null && second.lookup("#html-document") != null, + "Document viewers"); + image(root, dir.resolve(horizontal ? "dock-horizontal.png" : "dock-vertical.png")); + return "Rechnung / Lieferschein · " + + Math.round(a.getWidth()) + + " × " + + Math.round(a.getHeight()) + + " und " + + Math.round(b.getWidth()) + + " × " + + Math.round(b.getHeight()); + } + + static void move(Parent root, String document, String destination) { + var m = menu(tab(root, document)); + var targets = ((Menu) item(m.getItems(), "Move to", "Verschieben nach")).getItems(); + var action = item(targets, destination); + require(!action.isDisable(), action.getText()); + action.fire(); + m.hide(); + } + + static String verifyEmpty(Parent root, boolean persistent, Path dir) throws Exception { + layout(root); + var m = menu(tab(root, DELIVERY)); + var targets = ((Menu) item(m.getItems(), "Move to", "Verschieben nach")).getItems(); + require( + targets.stream().anyMatch(i -> i.getText().startsWith("details")), + "details destination gone"); + var messages = targets.stream().filter(i -> i.getText().equals("messages")).findFirst(); + require( + messages.isPresent() == persistent, + "messages target after close: " + targets.stream().map(MenuItem::getText).toList()); + m.hide(); + var empty = + root.lookupAll(".dock-group").stream() + .map(TabPane.class::cast) + .filter(t -> t.getTabs().isEmpty() && t.isVisible() && t.isManaged()) + .toList(); + require(empty.size() == (persistent ? 1 : 0), "Empty groups: " + empty.size()); + image(root, dir.resolve(persistent ? "dock-empty-kept.png" : "dock-empty-removed.png")); + if (persistent) { + move(root, DELIVERY, "messages"); + require(tab(root, DELIVERY).getTabPane() == empty.getFirst(), "Return to persistent group"); + } + return persistent + ? "persistent=true · messages bleibt leer sichtbar und nimmt den Lieferschein wieder auf" + : "persistent=false · messages nach dem letzten Tab aus Layout und Zielmenü entfernt"; + } + + static String defaults(Parent root) throws Exception { + var pane = root.lookup("#dockPane"); + var layout = pane.getClass().getMethod("getInitialLayout").invoke(pane); + var group = layout.getClass().getMethod("getCenter").invoke(layout); + var type = group.getClass(); + require( + Objects.equals(type.getMethod("getMinimumWidth").invoke(group), 80.0) + && Objects.equals(type.getMethod("getMinimumHeight").invoke(group), 80.0) + && (boolean) type.getMethod("isPersistent").invoke(group) + && type.getMethod("getSplitDirections").invoke(group).toString().equals("ALL"), + "Effective defaults"); + var texts = + root.lookupAll(".label").stream() + .filter(Label.class::isInstance) + .map(Label.class::cast) + .map(Label::getText) + .toList(); + require( + texts.contains("Rechnungen / Musterrechnung.pdf") + && texts.contains("Belegnummer RE-2026-042"), + "Original sample content"); + return "Defaults 80 × 80, true, ALL · Musterrechnung.pdf und Belegnummer RE-2026-042"; + } + + static void image(Parent root, Path file) throws Exception { + var image = root.snapshot(null, null); + var pixels = + new java.awt.image.BufferedImage( + (int) image.getWidth(), + (int) image.getHeight(), + java.awt.image.BufferedImage.TYPE_INT_ARGB); + var buffer = ((java.awt.image.DataBufferInt) pixels.getRaster().getDataBuffer()).getData(); + image + .getPixelReader() + .getPixels( + 0, + 0, + pixels.getWidth(), + pixels.getHeight(), + javafx.scene.image.PixelFormat.getIntArgbInstance(), + buffer, + 0, + pixels.getWidth()); + javax.imageio.ImageIO.write(pixels, "png", file.toFile()); + } + } +} diff --git a/integration-tests/idea/DockRulesWorkflowProbe.java b/integration-tests/idea/DockRulesWorkflowProbe.java new file mode 100644 index 0000000..20ba153 --- /dev/null +++ b/integration-tests/idea/DockRulesWorkflowProbe.java @@ -0,0 +1,104 @@ +package qualification; + +import static qualification.WorkflowProbe.*; + +import com.intellij.openapi.project.Project; +import java.nio.file.Files; +import java.util.List; +import javafx.embed.swing.SwingFXUtils; +import javafx.scene.control.*; +import javax.imageio.ImageIO; + +/** Configures the same central group in three independently loaded preview sessions. */ +public final class DockRulesWorkflowProbe extends DeclarationWorkflowProbe { + private static final String FORM = "ArchiveWindow"; + private static final String DOCUMENTS = "archive-window-documents"; + private static final List FIELDS = + List.of("minimumWidth", "minimumHeight", "persistent", "splitDirections"); + + @Override + void verify(Project project) throws Exception { + this.project = project; + open(FORM); + group(); + reject("minimumWidth", "-0.5"); + reject("minimumHeight", "Infinity"); + reject("splitDirections", "RIGHT"); + reject("persistent", "yes"); + applySetting("minimumWidth", "300"); + applySetting("minimumHeight", "225"); + applySetting("persistent", "false"); + applySetting("splitDirections", "HORIZONTAL"); + savedGroup("HORIZONTAL"); + fx( + () -> { + ImageIO.write( + SwingFXUtils.fromFXImage(pane.snapshot(null, null), null), + "png", + output.resolve("intellij.png").toFile()); + return null; + }); + build(DOCUMENTS); + interactive(DOCUMENTS, "horizontal"); + + group(); + applySetting("persistent", "true"); + applySetting("splitDirections", "VERTICAL"); + savedGroup("VERTICAL"); + build(DOCUMENTS); + interactive(DOCUMENTS, "vertical"); + + group(); + for (var field : FIELDS) { + enter(field, ""); + click(pane, "Apply setting"); + await(() -> !source().contains(field + "=\"")); + fx(pane::flush).toCompletableFuture().get(); + } + savedGroup("destinationId=\"messages\""); + for (var field : FIELDS) { + choose("declaration-property", field); + if (!fx( + () -> ((ComboBox) pane.lookup("#declaration-value")).getEditor().getText().isEmpty())) + throw new AssertionError("Reset " + field); + } + build("archive-window"); + interactive("archive-window", "defaults"); + Files.writeString(output.resolve("SUCCESS.txt"), Files.readString(output.resolve("steps.txt"))); + } + + private void group() throws Exception { + inspector(true); + select("DockGroupDefinition", "messages"); + } + + private void savedGroup(String value) throws Exception { + String expected = source(); + reopen(FORM, expected); + if (!source().equals(expected)) throw new AssertionError("Reopened FXML differs"); + group(); + select("DockGroupDefinition", "details"); + select("DockGroupDefinition", "messages"); + choose("declaration-property", "splitDirections"); + step("Save / reopen · messages, details · " + value); + } + + private void enter(String field, String value) throws Exception { + choose("declaration-property", field); + fx( + () -> { + ((ComboBox) pane.lookup("#declaration-value")).getEditor().setText(value); + return null; + }); + } + + private void reject(String field, String value) throws Exception { + String before = source(); + enter(field, value); + click(pane, "Apply setting"); + if (!before.equals(source()) + || fx(() -> ((Label) pane.lookup("#declaration-message")).getText().isBlank())) + throw new AssertionError("Accepted " + field + "=" + value); + step("Rejected · " + field + "=" + value); + } +} diff --git a/integration-tests/idea/MediaLayoutGridWorkflowProbe.java b/integration-tests/idea/MediaLayoutGridWorkflowProbe.java index 08672bc..411a669 100644 --- a/integration-tests/idea/MediaLayoutGridWorkflowProbe.java +++ b/integration-tests/idea/MediaLayoutGridWorkflowProbe.java @@ -2,21 +2,15 @@ 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; +public final class MediaLayoutGridWorkflowProbe extends DeclarationWorkflowProbe { void verify(Project project) throws Exception { this.project = project; @@ -141,8 +135,8 @@ public final class MediaLayoutGridWorkflowProbe extends FormWorkflowProbe { inspector(true); var original = declarations(); select("DataGrid", "grid"); - gridSet("setupId", "archiver-pruefung"); - gridSet("setupVersion", "2"); + applySetting("setupId", "archiver-pruefung"); + applySetting("setupVersion", "2"); for (var pair : List.of(List.of("setupId", "archiver-pruefung"), List.of("setupVersion", "2"))) { String before = source(); @@ -157,9 +151,9 @@ public final class MediaLayoutGridWorkflowProbe extends FormWorkflowProbe { click(pane, "Undo"); await(() -> source().equals(before)); } - gridSet("groupBy", "folder"); + applySetting("groupBy", "folder"); select("DataGridColumn", "folder"); - gridSet("fixedPosition", "1"); + applySetting("fixedPosition", "1"); combo("declaration-property", "groupLabels"); fx( () -> { @@ -195,142 +189,4 @@ public final class MediaLayoutGridWorkflowProbe extends FormWorkflowProbe { 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(" - 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) 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) 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 + "\""); - } } diff --git a/scripts/check-ide-host.py b/scripts/check-ide-host.py index 65a5401..6e5a8aa 100644 --- a/scripts/check-ide-host.py +++ b/scripts/check-ide-host.py @@ -26,6 +26,7 @@ p.add_argument("--archiver", type=Path, help="Qualify ArchiveWindow.fxml in a di forms = p.add_mutually_exclusive_group() 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("--dock-rules", action="store_true", help="Verify group minima, split directions and persistence in the Archiver") 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("--folder-actions", action="store_true", help="Check visual event references, folder search, selection and display profiles") @@ -33,7 +34,7 @@ forms.add_argument("--import-form", action="store_true", help="Check generic bin 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") 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 or args.media_layout_grid) 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 or args.dock_rules) and not args.archiver: p.error("Selecting an Archiver view requires --archiver") if args.repeat < 1: p.error("--repeat must be positive") @@ -45,7 +46,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): crashes = NativeCrashGuard(ROOT) launch = subprocess.run([sys.executable, ROOT / "scripts/run-fixture-host.py", "intellij", - "--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, + "--check", *(["--dock-rules"] if args.dock_rules else []), *(["--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], cwd=ROOT, text=True, capture_output=True, timeout=60) if launch.returncode: @@ -89,7 +90,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")) (evidence / "proof.json").write_text(json.dumps(proof, indent=2) + "\n") finally: - 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"): + for name in ("dock-horizontal.png", "dock-vertical.png", "dock-empty-kept.png", "dock-empty-removed.png", "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(): shutil.copyfile(base / name, evidence / name) workers = descendant_workers(pid) diff --git a/scripts/run-fixture-host.py b/scripts/run-fixture-host.py index c568ffb..2c684a2 100644 --- a/scripts/run-fixture-host.py +++ b/scripts/run-fixture-host.py @@ -22,6 +22,7 @@ p.add_argument("--archiver", type=Path, help="Use a disposable copy of the Archi 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("--grid-docking", type=Path, metavar="REFERENCE_FXML", help="Qualify the Archiver grid, dock layout and the supplied reference workspace") +forms.add_argument("--dock-rules", action="store_true", help="Verify group minima, split directions and persistence in the Archiver") 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("--folder-actions", action="store_true", help="Check visual event references, folder search, selection and display profiles") @@ -29,7 +30,7 @@ forms.add_argument("--import-form", action="store_true", help="Check generic bin 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") 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 or args.media_layout_grid) 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 or args.dock_rules) and not args.archiver: p.error("Selecting an Archiver view requires --archiver") base = Path(tempfile.mkdtemp(prefix="neitzel-designer-host-")).resolve() project = base / "project" @@ -109,6 +110,8 @@ else: suite = "Connection" elif args.grid_docking: suite = "GridDock" + elif args.dock_rules: + suite = "DockRules" elif args.media_layout_grid: suite = "MediaLayoutGrid" elif args.management_readers: @@ -123,8 +126,10 @@ else: suite = "SavedDocument" probe = f"{suite}WorkflowProbe" if args.archiver else "WorkflowProbe" 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 or args.media_layout_grid: + 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 or args.dock_rules: files.append(sources / "FormWorkflowProbe.java") + if args.media_layout_grid or args.dock_rules: + files.append(sources / "DeclarationWorkflowProbe.java") if args.archiver: files.append(sources / f"{probe}.java") target_probe = f"{suite}TargetProbe"