From ff6ba0a745373ea13878a1a04ecae678442654c8 Mon Sep 17 00:00:00 2001 From: Konrad Neitzel Date: Wed, 25 Nov 2026 12:08:18 +0100 Subject: [PATCH 1/7] Validate grid width bounds and qualify Archiver window and document states in IntelliJ --- README.md | 2 +- .../neitzel/fxdesigner/build/SourceWatch.java | 39 ++++-- .../fxdesigner/build/SourceWatchTest.java | 29 +++++ .../fxdesigner/kit/GridDockDocument.java | 61 ++++++++- .../fxdesigner/kit/GridDockEditor.java | 9 ++ .../fxdesigner/kit/GridDockDocumentTest.java | 27 ++++ docs/user-guide/authoring.md | 2 + .../idea/ArchiveTargetProbe.java | 98 ++++++++++++++- .../idea/DocumentTabsTargetProbe.java | 27 ++-- .../idea/DocumentTabsWorkflowProbe.java | 118 +++++++++++++----- .../idea/MediaLayoutGridTargetProbe.java | 25 +++- .../idea/MediaLayoutGridWorkflowProbe.java | 57 +++++++++ 12 files changed, 429 insertions(+), 65 deletions(-) create mode 100644 designer-core/src/test/java/de/neitzel/fxdesigner/build/SourceWatchTest.java diff --git a/README.md b/README.md index d59d71f..e4d24f0 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ python3 scripts/run-fixture-host.py intellij --archiver ../Archiver \ --idea-home "$IDEA_HOME" --java-home "$JAVA_HOME" --target-java-home "$JAVA_HOME" ``` -Open `ArchiveWindow.fxml` in **Neitzel Designer**, choose **Build and Refresh** and start **Interactive preview** with **Beispielarchiv**. The open menu command enables the trash button. Under **Bindings → Command bindings** select `open`, change its path to `openReadOnly`, apply and restart the preview. The status bar identifies the read-only example. **Discover / Validate Commands** lists public getters returning a NeitzelLib `Command`, including the Command exposed by an `AsyncCommand`. The Problems view navigates to an invalid declaration. To repeat the automated acceptance, use the same arguments with `python3 scripts/check-ide-host.py --archiver ../Archiver` (omit the `intellij` positional argument). +Open `ArchiveWindow.fxml` in **Neitzel Designer**, choose **Build and Refresh** and start **Interactive preview** with **Beispielarchiv**. Open the sample archive and select an entry in the example document. The entry, selected folder and scan state control the same 22 command permissions as the application. Opening read-only disables import and account management. The trash button opens the populated session-local trash, and closing the archive disables it. Under **Bindings → Command bindings** select `open`, change its path to `openReadOnly`, apply and restart the preview. The status bar identifies the read-only example. **Discover / Validate Commands** lists public getters returning a NeitzelLib `Command`, including the Command exposed by an `AsyncCommand`. The Problems view navigates to an invalid declaration. To repeat the automated acceptance, use the same arguments with `python3 scripts/check-ide-host.py --archiver ../Archiver` (omit the `intellij` positional argument). Add `--connection-form` to open or qualify `ConnectionForm.fxml`. After **Build and Refresh**, choose **Form preview** and select **IMAP · Beispielkonto** or **JMAP · Beispielkonto**. The full image comes from the target application at the selected width and height. **Interactive preview** opens a separate, editable instance of the selected example. diff --git a/designer-core/src/main/java/de/neitzel/fxdesigner/build/SourceWatch.java b/designer-core/src/main/java/de/neitzel/fxdesigner/build/SourceWatch.java index 4cce2bb..bb65d16 100644 --- a/designer-core/src/main/java/de/neitzel/fxdesigner/build/SourceWatch.java +++ b/designer-core/src/main/java/de/neitzel/fxdesigner/build/SourceWatch.java @@ -2,6 +2,7 @@ package de.neitzel.fxdesigner.build; import java.io.*; import java.nio.file.*; +import java.nio.file.attribute.BasicFileAttributes; import java.util.*; /** Detects transient changes and overflow in addition to pre/post hashes and file attributes. */ @@ -13,18 +14,32 @@ final class SourceWatch implements AutoCloseable { SourceWatch(Path root) throws IOException { this.root = root; watch = root.getFileSystem().newWatchService(); - try (var dirs = Files.walk(root)) { - for (Path dir : - dirs.filter(Files::isDirectory) - .filter(p -> InputTree.included(root, root.relativize(p))) - .toList()) - keys.put( - dir.register( - watch, - StandardWatchEventKinds.ENTRY_CREATE, - StandardWatchEventKinds.ENTRY_DELETE, - StandardWatchEventKinds.ENTRY_MODIFY), - dir); + try { + Files.walkFileTree( + root, + new SimpleFileVisitor<>() { + @Override + public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) + throws IOException { + if (!InputTree.included(root, root.relativize(dir))) + return FileVisitResult.SKIP_SUBTREE; + keys.put( + dir.register( + watch, + StandardWatchEventKinds.ENTRY_CREATE, + StandardWatchEventKinds.ENTRY_DELETE, + StandardWatchEventKinds.ENTRY_MODIFY), + dir); + return FileVisitResult.CONTINUE; + } + }); + } catch (IOException | RuntimeException failure) { + try { + watch.close(); + } catch (IOException cleanup) { + failure.addSuppressed(cleanup); + } + throw failure; } } diff --git a/designer-core/src/test/java/de/neitzel/fxdesigner/build/SourceWatchTest.java b/designer-core/src/test/java/de/neitzel/fxdesigner/build/SourceWatchTest.java new file mode 100644 index 0000000..d39c83a --- /dev/null +++ b/designer-core/src/test/java/de/neitzel/fxdesigner/build/SourceWatchTest.java @@ -0,0 +1,29 @@ +package de.neitzel.fxdesigner.build; + +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +import java.nio.file.*; +import java.nio.file.attribute.PosixFilePermissions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +class SourceWatchTest { + @Test + void registeringBuildInputsNeverTraversesSnapshotContents(@TempDir Path project) + throws Exception { + assumeTrue(project.getFileSystem().supportedFileAttributeViews().contains("posix")); + var snapshot = Files.createDirectories(project.resolve(".neitzel-fx-designer/snapshots")); + Files.createFile(snapshot.resolve("state.tmp")); + var permissions = Files.getPosixFilePermissions(snapshot); + try { + Files.setPosixFilePermissions(snapshot, PosixFilePermissions.fromString("---------")); + assumeTrue(!Files.isReadable(snapshot)); + try (var watch = new SourceWatch(project)) { + assertFalse(watch.changed()); + } + } finally { + Files.setPosixFilePermissions(snapshot, permissions); + } + } +} 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 5008e9f..bdf15c4 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 @@ -104,7 +104,7 @@ final class GridDockDocument { return result; } - private Element property(Element e, String name) { + static Element property(Element e, String name) { var list = children(e).stream().filter(c -> c.getTagName().equals(name)).toList(); if (list.size() > 1) throw new IllegalArgumentException("Multiple declarations of " + name); return list.isEmpty() ? null : list.getFirst(); @@ -232,6 +232,59 @@ final class GridDockDocument { xml.elements.indexOf(map), Collections.singletonMap(key, remove ? null : encoded)); } + // DataGridColumn defaults in the target library. The Kit does not load target classes. + static final Map COLUMN_WIDTHS = + Map.of("minimumWidth", "80", "width", "150", "maximumWidth", "1200"); + + private record ColumnWidth(String description, Double literal) { + static ColumnWidth read(Element column, String name, String edited, String proposed) { + String text = column.getAttribute(name); + if (name.equals(edited)) text = proposed; + else { + var nested = property(column, name); + if (nested != null) { + if (!children(nested).isEmpty()) return new ColumnWidth(name + "=", null); + text = nested.getTextContent().strip(); + } + } + boolean useDefault = text.isEmpty(); + if (useDefault) text = COLUMN_WIDTHS.get(name); + String label = name + "=" + text; + if (reference(text) || text.startsWith("#")) { + if (name.equals(edited)) + throw new IllegalArgumentException("Enter a literal pixel width for " + name); + return new ColumnWidth(label + " (resolved at runtime)", null); + } + double pixels; + try { + pixels = Double.parseDouble(text); + } catch (NumberFormatException ex) { + throw new IllegalArgumentException("Expected a pixel width for " + label); + } + if (!Double.isFinite(pixels) || pixels <= 0) + throw new IllegalArgumentException("Expected a finite, positive pixel width for " + label); + return new ColumnWidth(label + (useDefault ? " (default)" : ""), pixels); + } + + boolean exceeds(ColumnWidth other) { + return literal != null && other.literal != null && literal > other.literal; + } + } + + private static void validateColumnWidths(Element column, String edited, String proposed) { + var minimum = ColumnWidth.read(column, "minimumWidth", edited, proposed); + var width = ColumnWidth.read(column, "width", edited, proposed); + var maximum = ColumnWidth.read(column, "maximumWidth", edited, proposed); + if (minimum.exceeds(width) || width.exceeds(maximum) || minimum.exceeds(maximum)) + throw new IllegalArgumentException( + "Expected minimumWidth ≤ width ≤ maximumWidth: " + + minimum.description() + + ", " + + width.description() + + ", " + + maximum.description()); + } + List set(Element e, String field, String value) { if (!SETTINGS.getOrDefault(type(e), List.of()).contains(field) || Set.of("items", "source", "groupLabels").contains(field)) @@ -239,7 +292,7 @@ final class GridDockDocument { if (property(e, field) != null) throw new IllegalArgumentException( "The property has a nested declaration. Edit it in Source."); - if (e.getAttribute(field).matches("^[%$#].*")) + if (reference(e.getAttribute(field)) || e.getAttribute(field).startsWith("#")) throw new IllegalArgumentException("This property is a reference. Edit it in Source."); boolean required = field.equals("id") || field.equals("destinationId") || field.equals("header"); @@ -248,7 +301,9 @@ final class GridDockDocument { var opts = options(field); if (!value.isEmpty() && !opts.isEmpty() && !opts.contains(value)) throw new IllegalArgumentException("Choose one of " + opts); - if (!value.isEmpty() + if (type(e).equals("DataGridColumn") && COLUMN_WIDTHS.containsKey(field)) { + validateColumnWidths(e, field, value); + } else if (!value.isEmpty() && Set.of( "width", "minimumWidth", 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 6cf953a..a87e4d7 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 @@ -250,6 +250,15 @@ final class GridDockEditor extends VBox { default -> ""; } : ""; + if (doc.type(e).equals("DataGridColumn") && GridDockDocument.COLUMN_WIDTHS.containsKey(field)) { + hint = + GridDockDocument.property(e, field) == null + ? "Default: " + GridDockDocument.COLUMN_WIDTHS.get(field) + " px" + : "Nested FXML value"; + value.setTooltip( + new Tooltip( + "minimumWidth ≤ width ≤ maximumWidth. FXML references are resolved at runtime.")); + } else value.setTooltip(null); value.setPromptText(hint); value.getItems().setAll(GridDockDocument.options(field)); value.setValue(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 0ea792c..eca4a07 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,33 @@ import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; class GridDockDocumentTest { + @Test + void columnBoundsIncludeDefaultsResetsAndKnownPartsOfDynamicWidths() throws Exception { + var doc = + new GridDockDocument( + ""); + var col = doc.xml.elements.getFirst(); + assertThrows(IllegalArgumentException.class, () -> doc.set(col, "width", "")); + assertThrows(IllegalArgumentException.class, () -> doc.set(col, "minimumWidth", "300")); + assertThrows(IllegalArgumentException.class, () -> doc.set(col, "maximumWidth", "100")); + assertThrows(IllegalArgumentException.class, () -> doc.set(col, "width", "%size")); + assertDoesNotThrow(() -> doc.set(col, "maximumWidth", "230")); + assertDoesNotThrow(() -> doc.set(col, "minimumWidth", "")); + var dynamic = + new GridDockDocument( + ""); + var bound = dynamic.xml.elements.getFirst(); + assertTrue( + assertThrows( + IllegalArgumentException.class, () -> dynamic.set(bound, "minimumWidth", "201")) + .getMessage() + .contains("%start (resolved at runtime)")); + assertEquals( + dynamic.xml.text.replace("200", "210"), + dynamic.xml.source.apply(dynamic.set(bound, "maximumWidth", "210"))); + assertThrows(IllegalArgumentException.class, () -> dynamic.set(bound, "width", "")); + } + @Test void dockMinimaAllowZeroWithoutChangingGridColumnRules() throws Exception { var source = diff --git a/docs/user-guide/authoring.md b/docs/user-guide/authoring.md index a0cdfff..7b93e5c 100644 --- a/docs/user-guide/authoring.md +++ b/docs/user-guide/authoring.md @@ -54,6 +54,8 @@ 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. +Set the column widths so that `minimumWidth ≤ width ≤ maximumWidth`. Clearing a field restores its default (80, 150 and 1200 pixels respectively). The inspector checks the remaining literal bounds when a sibling value is supplied by an FXML reference. + 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 diff --git a/integration-tests/idea/ArchiveTargetProbe.java b/integration-tests/idea/ArchiveTargetProbe.java index 2986dd7..43919ff 100644 --- a/integration-tests/idea/ArchiveTargetProbe.java +++ b/integration-tests/idea/ArchiveTargetProbe.java @@ -1,6 +1,7 @@ package qualification; import java.nio.file.*; +import java.util.*; import java.util.concurrent.*; import javafx.application.Platform; import javafx.scene.control.*; @@ -42,10 +43,32 @@ public final class ArchiveTargetProbe { } } + static void verify( + String state, + String expected, + Map commands, + Button trash, + StringBuilder evidence) { + var active = new TreeSet(); + commands.forEach( + (name, item) -> { + if (!item.isDisable()) active.add(name); + }); + if (!trash.isDisabled()) active.add("trash"); + if (commands.size() != 21 || !active.equals(Set.of(expected.trim().split(" +")))) + throw new AssertionError(state + " expected [" + expected + "] actual " + active); + evidence.append(state).append(" · enabled ").append(active).append("\n"); + } + static boolean inspect(Path directory) throws Exception { var stage = Window.getWindows().stream() - .filter(Window::isShowing) + .filter( + w -> + w.isShowing() + && w.getOpacity() > 0 + && w instanceof javafx.stage.Stage s + && Objects.toString(s.getTitle(), "").startsWith("Neitzel preview")) .filter(w -> w.getScene().lookup("#trash-button") instanceof Button) .findFirst(); if (stage.isEmpty()) return false; @@ -73,11 +96,23 @@ public final class ArchiveTargetProbe { trash.fire(); if (!status.getText().equals("Vorschau · Bereit")) throw new AssertionError("Disabled command ran"); - if (((TreeView) root.lookup("#folders")).getRoot() == null - || root.lookup("#dockPane").lookupAll(".label").stream() - .noneMatch( - n -> n instanceof Label l && l.getText().equals("Dokument im Beispielarchiv"))) + if (root.lookup("#dockPane").lookupAll(".label").stream() + .noneMatch(n -> n instanceof Label l && l.getText().equals("Dokument im Beispielarchiv"))) return false; + var commands = new LinkedHashMap(); + for (var group : ((MenuBar) root.lookup(".menu-bar")).getMenus()) { + for (var item : group.getItems()) { + if (!(item instanceof Menu) && item.getOnAction() != null) + commands.put(item == open ? "open" : item.getId(), item); + } + } + var evidence = new StringBuilder(); + String idle = "open openReadOnly overview preferences"; + String ready = idle + " closeArchive refresh rebuild trash find slideshow"; + String write = " importFile singleFile naming pending manageMail"; + String readEntry = " showFile showPlace openFile"; + String editEntry = " tags move duplicate"; + verify("closed", idle, commands, trash, evidence); open.fire(); String afterOpen = status.getText(); if (trash.isDisabled() || !afterOpen.endsWith(" · 1")) throw new AssertionError(afterOpen); @@ -85,6 +120,57 @@ public final class ArchiveTargetProbe { String afterTrash = status.getText(); if (!afterTrash.equals("Vorschau · Beispielpapierkorb geöffnet · 2")) throw new AssertionError(afterTrash); + var dialog = + Window.getWindows().stream() + .filter(w -> w.isShowing() && w.getScene().lookup("#archive-trash") != null) + .findFirst() + .orElseThrow(); + var content = dialog.getScene().getRoot(); + var items = (TableView) content.lookup("#trash-items"); + String summary = ((Label) content.lookup("#summary")).getText(); + boolean writable = afterOpen.equals("Vorschau · Beispielarchiv geöffnet · 1"); + if (items.getItems().size() != 2 + || !summary.contains("3 Dateien") + || ((Button) content.lookup("#trash-delete")).isDisabled() == writable) + throw new AssertionError(summary); + ((Button) ((DialogPane) content).lookupButton(ButtonType.CLOSE)).fire(); + if (dialog.isShowing()) throw new AssertionError("Trash dialog did not close"); + evidence.append(summary).append("\n"); + var folders = (TreeView) root.lookup("#folders"); + var entries = (ChoiceBox) root.lookup("#example-entry"); + var phase = (ChoiceBox) root.lookup("#example-activity"); + String mode = writable ? "writable" : "read-only"; + String opened = writable ? ready + write : ready; + verify(mode, opened, commands, trash, evidence); + folders.getSelectionModel().select(0); + entries.getSelectionModel().select(0); + String selected = opened + " rules" + readEntry + (writable ? editEntry : ""); + verify(mode + ", invoice selected", selected, commands, trash, evidence); + entries.getSelectionModel().select(1); + verify("server-bound mail", selected.replace(" move", ""), commands, trash, evidence); + entries.getSelectionModel().select(0); + phase.getSelectionModel().select(1); + verify("initial scan", "slideshow" + readEntry, commands, trash, evidence); + phase.getSelectionModel().select(2); + verify("background scan", "find slideshow" + readEntry, commands, trash, evidence); + phase.getSelectionModel().select(3); + verify("busy", "find", commands, trash, evidence); + commands.get("importFile").fire(); + if (!status.getText().equals(afterTrash)) throw new AssertionError("Blocked import executed"); + phase.getSelectionModel().select(4); + verify("foreground read", selected.replace(" closeArchive", ""), commands, trash, evidence); + phase.getSelectionModel().select(0); + entries.getSelectionModel().clearSelection(); + folders.getSelectionModel().clearSelection(); + verify("selection cleared", opened, commands, trash, evidence); + commands.get("closeArchive").fire(); + verify("archive closed", idle, commands, trash, evidence); + String closedStatus = status.getText(); + trash.fire(); + if (!status.getText().equals(closedStatus) || folders.getRoot() != null) + throw new AssertionError(closedStatus); + commands.get("openReadOnly").fire(); + verify("read-only reopened", ready, commands, trash, evidence); String run = Files.readString(directory.resolve("attempt")).trim(); var image = root.snapshot(null, null); int width = (int) image.getWidth(), height = (int) image.getHeight(); @@ -108,7 +194,7 @@ public final class ArchiveTargetProbe { screenshot, "png", directory.resolve("preview-" + run + ".png").toFile()); Files.writeString( directory.resolve("result-" + run), - afterOpen + "\n" + afterTrash + "\n" + ProcessHandle.current().pid()); + afterOpen + "\n" + afterTrash + "\n" + evidence + ProcessHandle.current().pid()); return true; } } diff --git a/integration-tests/idea/DocumentTabsTargetProbe.java b/integration-tests/idea/DocumentTabsTargetProbe.java index 1d0e295..63c2c75 100644 --- a/integration-tests/idea/DocumentTabsTargetProbe.java +++ b/integration-tests/idea/DocumentTabsTargetProbe.java @@ -80,7 +80,8 @@ public final class DocumentTabsTargetProbe { } else { result = checkDetails(dir, root, id); } - Files.writeString(dir.resolve("result-" + id), result); + var completed = Files.writeString(dir.resolve("result-" + id + ".tmp"), result); + Files.move(completed, dir.resolve("result-" + id), StandardCopyOption.ATOMIC_MOVE); } catch (Throwable error) { var trace = new java.io.StringWriter(); error.printStackTrace(new java.io.PrintWriter(trace)); @@ -260,29 +261,25 @@ public final class DocumentTabsTargetProbe { long activateAfter = 0; while (System.nanoTime() < deadline) { if (System.nanoTime() >= activateAfter - && !fx(field::isFocused) + && !fx(() -> field.isFocused() && field.getScene().getWindow().isFocused()) && System.getProperty("os.name").startsWith("Mac")) { - String activate = - "ObjC.import('AppKit');" - + " $.NSRunningApplication.runningApplicationWithProcessIdentifier(" - + ProcessHandle.current().pid() - + ").activateWithOptions(2)"; - new ProcessBuilder("/usr/bin/osascript", "-l", "JavaScript", "-e", activate) - .redirectErrorStream(true) - .start() - .waitFor(5, TimeUnit.SECONDS); + var desktop = java.awt.Desktop.getDesktop(); + if (desktop.isSupported(java.awt.Desktop.Action.APP_REQUEST_FOREGROUND)) { + // Request activation from the preview process itself, which owns the FX stage. + desktop.requestForeground(true); + } activateAfter = System.nanoTime() + TimeUnit.SECONDS.toNanos(3); } boolean matched = fx( () -> { var stage = (Stage) field.getScene().getWindow(); - if (!field.isFocused()) { + if (!stage.isFocused() || !field.isFocused()) { stage.toFront(); stage.requestFocus(); field.requestFocus(); } - if (!field.isFocused()) return false; + if (!stage.isFocused() || !field.isFocused()) return false; if (!suggestions(field).contains(suggestion)) throw new AssertionError( "Missing " + suggestion + " in catalogue " + suggestions(field)); @@ -315,6 +312,10 @@ public final class DocumentTabsTargetProbe { + field.isFocused() + ", stage focused=" + field.getScene().getWindow().isFocused() + + ", focus owner=" + + field.getScene().getFocusOwner() + + ", field bounds=" + + field.localToScreen(field.getBoundsInLocal()) + ", catalogue=" + suggestions(field) + ", windows=" diff --git a/integration-tests/idea/DocumentTabsWorkflowProbe.java b/integration-tests/idea/DocumentTabsWorkflowProbe.java index 8ced1cd..1c1fa66 100644 --- a/integration-tests/idea/DocumentTabsWorkflowProbe.java +++ b/integration-tests/idea/DocumentTabsWorkflowProbe.java @@ -7,6 +7,7 @@ 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.List; import java.util.concurrent.TimeUnit; import javafx.embed.swing.SwingFXUtils; import javafx.scene.control.*; @@ -24,17 +25,24 @@ public final class DocumentTabsWorkflowProbe extends FormWorkflowProbe { "AutoCompleteTextField #input", "promptText", "Belegtag wählen"); - build(4); - for (String id : - new String[] {"details-invoice", "details-delivery", "details-readonly", "details-busy"}) - preview(id); + qualify("details-invoice", "details-delivery", "details-readonly", "details-busy"); open(project, "HtmlDocument"); - build(2); - preview("html-invoice"); - preview("html-delivery"); + qualify("html-invoice", "html-delivery"); open(project, "ArchiveWindow"); - build(2); - preview("archive-window-documents"); + qualify("archive-window-documents"); + var ids = fx(this::available); + if (!ids.contains("archive-window-media")) + throw new AssertionError("Missing media example: " + ids); + try { + awaitExamples(List.of("missing-required-example")); + throw new AssertionError("Missing descriptor was accepted"); + } catch (IllegalStateException expected) { + String diagnostic = expected.getMessage(); + if (!diagnostic.contains( + "ArchiveWindow.fxml · required [missing-required-example] · available " + ids)) + throw expected; + step(diagnostic); + } Files.writeString(output.resolve("SUCCESS.txt"), Files.readString(output.resolve("steps.txt"))); } @@ -65,32 +73,84 @@ public final class DocumentTabsWorkflowProbe extends FormWorkflowProbe { step("Saved and reopened " + control + "." + property + " = " + value); } - private void build(int examples) throws Exception { + private List available() { + return ((ComboBox) pane.lookup("#preview-example")) + .getItems().stream().map(Example.class::cast).map(Example::id).toList(); + } + + private String state() { + return ((Label) pane.lookup("#preview-state")).getText(); + } + + private boolean failed() { + String state = state(); + return state.startsWith("Preview failed") + || state.startsWith("Preview blocked") + || state.startsWith("Preview unavailable") + || state.contains("correct the build"); + } + + private String diagnostic(List required) { + return file.getName() + + " · required " + + required + + " · available " + + available() + + " · " + + state(); + } + + private void awaitExamples(List required) throws Exception { + try { + // Discovery publishes the complete list at once. Additional providers may extend it. + await( + () -> + fx( + () -> + failed() + || state().contains("register an example") + || !state().startsWith("Building") && !available().isEmpty())); + } catch (AssertionError timeout) { + throw new AssertionError(fx(() -> diagnostic(required)), timeout); + } + if (!fx(() -> !failed() && available().containsAll(required))) + throw new IllegalStateException(fx(() -> diagnostic(required))); + } + + private void qualify(String... examples) throws Exception { + var required = List.of(examples); click(pane, "Form preview"); click(pane, "Build and Refresh"); - await( - () -> - fx( - () -> - ((ComboBox) pane.lookup("#preview-example")).getItems().size() == examples)); + awaitExamples(required); + step(file.getName() + " · available " + fx(this::available)); + for (String id : required) preview(id); } private void preview(String id) throws Exception { - choose("preview-example", id); String label = - fx(() -> ((Example) ((ComboBox) pane.lookup("#preview-example")).getValue()).label()); - await( - () -> - fx( - () -> { - String 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); - return ((ImageView) pane.lookup("#full-preview-image")).getImage() != null - && state.contains(label); - })); + fx( + () -> { + var choices = (ComboBox) pane.lookup("#preview-example"); + var selected = + choices.getItems().stream() + .filter(example -> example.id().equals(id)) + .findFirst() + .orElseThrow(() -> new IllegalStateException(diagnostic(List.of(id)))); + choices.getSelectionModel().select(selected); + return selected.label(); + }); + try { + await( + () -> + fx( + () -> + failed() + || ((ImageView) pane.lookup("#full-preview-image")).getImage() != null + && state().contains(label))); + } catch (AssertionError timeout) { + throw new AssertionError(fx(() -> diagnostic(List.of(id))), timeout); + } + if (fx(this::failed)) throw new AssertionError(fx(() -> diagnostic(List.of(id)))); fx( () -> { var frame = ((ImageView) pane.lookup("#full-preview-image")).getImage(); diff --git a/integration-tests/idea/MediaLayoutGridTargetProbe.java b/integration-tests/idea/MediaLayoutGridTargetProbe.java index 2351bcb..373e6b7 100644 --- a/integration-tests/idea/MediaLayoutGridTargetProbe.java +++ b/integration-tests/idea/MediaLayoutGridTargetProbe.java @@ -284,6 +284,28 @@ public final class MediaLayoutGridTargetProbe { var cols = (List) get(setup, "columns"); var order = new ArrayList(); for (var col : cols) order.add((String) get(col, "id")); + var labels = + grid.lookupAll(".label").stream().map(Label.class::cast).map(Label::getText).toList(); + require( + labels.containsAll(List.of("Musterrechnung.pdf", "Lieferbrief.txt")), + "Example rows: " + labels); + var widthType = + Class.forName("de.neitzel.grid.ColumnWidth", true, grid.getClass().getClassLoader()); + var resize = grid.getClass().getMethod("setColumnWidth", String.class, widthType); + var explicit = + Class.forName(widthType.getName() + "$Explicit", true, widthType.getClassLoader()) + .getConstructor(double.class); + var defaultWidth = get(cols.getFirst(), "width"); + require( + order.getFirst().equals("path") + && defaultWidth.getClass().getSimpleName().equals("Default"), + "Initial path column"); + require( + resize.invoke(grid, "path", defaultWidth).equals(230d) + && resize.invoke(grid, "path", explicit.newInstance(50d)).equals(150d) + && resize.invoke(grid, "path", explicit.newInstance(600d)).equals(300d) + && resize.invoke(grid, "path", defaultWidth).equals(230d), + "Rendered path column width limits"); require(order.get(1).equals("folder"), "Column position"); Collections.swap(order, 0, 1); try { @@ -344,7 +366,8 @@ public final class MediaLayoutGridTargetProbe { : "Missing definition migration"), "Wrong setup restore " + error); } - return "Setup archiver-pruefung/2 · fremde ID und alte Version abgewiesen · folder fest an" + return "path start 230 px, resize to 50/600 clamped to 150/300 px, reset 230 px · Setup" + + " archiver-pruefung/2 · fremde ID und alte Version abgewiesen · folder fest an" + " Index 1 · Posteingang sichtbar, Gruppenschlüssel Post"; } diff --git a/integration-tests/idea/MediaLayoutGridWorkflowProbe.java b/integration-tests/idea/MediaLayoutGridWorkflowProbe.java index 411a669..4127cc9 100644 --- a/integration-tests/idea/MediaLayoutGridWorkflowProbe.java +++ b/integration-tests/idea/MediaLayoutGridWorkflowProbe.java @@ -130,10 +130,67 @@ public final class MediaLayoutGridWorkflowProbe extends DeclarationWorkflowProbe interactive("archive-window-media", "media"); } + private void columnWidths() throws Exception { + select("DataGridColumn", "path"); + for (var pair : List.of(List.of("minimumWidth", "300"), List.of("maximumWidth", "100"))) { + String before = source(); + combo("declaration-property", pair.getFirst()); + fx( + () -> { + ((ComboBox) pane.lookup("#declaration-value")).getEditor().setText(pair.getLast()); + return null; + }); + click(pane, "Apply setting"); + var message = fx(() -> ((Label) pane.lookup("#declaration-message")).getText()); + if (!source().equals(before) + || !message.contains(pair.getFirst() + "=" + pair.getLast()) + || !message.contains("width=230")) + throw new AssertionError("Invalid width edit: " + message); + if (!fx( + () -> + ((javafx.scene.image.ImageView) pane.lookup("#full-preview-image")).getImage() != null + && ((Label) pane.lookup("#preview-state")).getText().contains("Beispieldateien"))) + throw new AssertionError("Lost the valid example preview"); + step("Rejected · valid FXML and example preview retained · " + message); + } + applySetting("minimumWidth", "150"); + applySetting("maximumWidth", "300"); + applySetting("width", "240"); + for (String field : List.of("width", "minimumWidth", "maximumWidth")) { + String before = source(); + combo("declaration-property", field); + fx( + () -> { + ((ComboBox) pane.lookup("#declaration-value")).getEditor().clear(); + return null; + }); + click(pane, "Apply setting"); + await(() -> !source().equals(before)); + String reset = source(); + history(before, reset); + click(pane, "Undo"); + await(() -> source().equals(before)); + fx(pane::flush).toCompletableFuture().get(); + } + applySetting("width", "230"); + } + private void folder() throws Exception { open("FolderTab"); + build("archive-folder"); + choose("preview-example", "archive-folder"); + await( + () -> + fx( + () -> + ((javafx.scene.image.ImageView) pane.lookup("#full-preview-image")).getImage() + != null + && ((Label) pane.lookup("#preview-state")) + .getText() + .contains("Beispieldateien"))); inspector(true); var original = declarations(); + columnWidths(); select("DataGrid", "grid"); applySetting("setupId", "archiver-pruefung"); applySetting("setupVersion", "2"); From 9c63b2dd0f85f93245dedd578e15fce552fcd542 Mon Sep 17 00:00:00 2001 From: Konrad Neitzel Date: Wed, 25 Nov 2026 13:17:24 +0100 Subject: [PATCH 2/7] Offer grid row attributes and qualify Archiver folder profile editing --- README.md | 2 + .../fxdesigner/kit/GridDockEditor.java | 18 +- .../idea/FolderActionsTargetProbe.java | 60 ++-- .../idea/FolderProfilesTargetProbe.java | 328 ++++++++++++++++++ .../idea/FolderProfilesWorkflowProbe.java | 109 ++++++ integration-tests/idea/FormWorkflowProbe.java | 33 ++ .../idea/ImportWorkflowProbe.java | 36 +- .../idea/ManagementReadersWorkflowProbe.java | 32 -- scripts/check-ide-host.py | 7 +- scripts/run-fixture-host.py | 13 +- 10 files changed, 560 insertions(+), 78 deletions(-) create mode 100644 integration-tests/idea/FolderProfilesTargetProbe.java create mode 100644 integration-tests/idea/FolderProfilesWorkflowProbe.java diff --git a/README.md b/README.md index e4d24f0..f45ad25 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,8 @@ Use `--import-form` with `scripts/check-ide-host.py --archiver ../Archiver` and Use `--management-readers` with the Archiver host check to exercise the two account states, the empty and populated trash, and all five reader toolbars. The check saves and reopens CommandBinding changes in both management forms and an icon and accessible text change in the picture toolbar. +Use `--folder-profiles` with the Archiver host check to rebind the profile buttons and edit mail and book columns against indexed EML and EPUB files. The editable attribute list offers the row attributes used by the current grid. + Use `--folder-actions` with the Archiver host check to edit a text field’s column count, accessible name and controller action, then exercise the folder toolbar’s dismiss handler, full-text search, multiple selection and saved display profiles. Use `--document-tabs` with the Archiver host check to open the production archive window and select **Archiver · HTML-Dokumenttabs**. The check also opens the production HTML and details FXML files directly, edits the assigned-tag Component and the input prompt through the visual inspector, and reopens the saved files. In the archive window it adds a second tag to the invoice, switches to the delivery note and back, removes the selected tag, and checks each WebView and suggestion popup. Direct examples cover read-only and busy states. 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 a87e4d7..a162381 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 @@ -260,7 +260,23 @@ final class GridDockEditor extends VBox { "minimumWidth ≤ width ≤ maximumWidth. FXML references are resolved at runtime.")); } else value.setTooltip(null); value.setPromptText(hint); - value.getItems().setAll(GridDockDocument.options(field)); + if ("attribute".equals(field) || "groupAttribute".equals(field)) { + var columns = doc.branches(doc.parentOfType(e, "DataGrid")); + value + .getItems() + .setAll( + columns.stream() + .map( + column -> + column.getAttribute( + column.hasAttribute("attribute") ? "attribute" : "id")) + .filter(name -> !name.isBlank()) + .distinct() + .toList()); + value.setTooltip( + new Tooltip( + "Row attributes used by this grid. You can also enter another row attribute.")); + } else value.getItems().setAll(GridDockDocument.options(field)); value.setValue(e.getAttribute(field)); value.getEditor().setText(e.getAttribute(field)); } diff --git a/integration-tests/idea/FolderActionsTargetProbe.java b/integration-tests/idea/FolderActionsTargetProbe.java index f2d8865..c28a134 100644 --- a/integration-tests/idea/FolderActionsTargetProbe.java +++ b/integration-tests/idea/FolderActionsTargetProbe.java @@ -19,14 +19,14 @@ public final class FolderActionsTargetProbe { Thread.ofPlatform().daemon().start(() -> Worker.run(Path.of(dir))); } - private static final class Worker { - private static T fx(Callable action) throws Exception { + static final class Worker { + static T fx(Callable action) throws Exception { var task = new FutureTask<>(action); Platform.runLater(task); return task.get(10, TimeUnit.SECONDS); } - private static void await(String description, Callable test) throws Exception { + static void await(String description, Callable test) throws Exception { long end = System.nanoTime() + TimeUnit.SECONDS.toNanos(22); while (System.nanoTime() < end) { if (fx(test)) return; @@ -35,34 +35,38 @@ public final class FolderActionsTargetProbe { throw new AssertionError(description); } - private static void require(boolean value, String message) { + static void require(boolean value, String message) { if (!value) throw new AssertionError(message); } + static Stage previewStage() throws Exception { + 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) { + } + } + return stage; + } + 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; + Stage shown = previewStage(); var root = fx( () -> { @@ -140,7 +144,7 @@ public final class FolderActionsTargetProbe { .orElseThrow(); } - private static boolean visible(Node grid, String column) throws Exception { + static boolean visible(Node grid, String column) throws Exception { return (boolean) grid.getClass().getMethod("isColumnVisible", String.class).invoke(grid, column); } @@ -283,7 +287,7 @@ public final class FolderActionsTargetProbe { + " Dateityp; Kurzansicht restored hidden Dateityp."); } - private static void image(Node node, Path path) throws Exception { + 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); diff --git a/integration-tests/idea/FolderProfilesTargetProbe.java b/integration-tests/idea/FolderProfilesTargetProbe.java new file mode 100644 index 0000000..78ff3fc --- /dev/null +++ b/integration-tests/idea/FolderProfilesTargetProbe.java @@ -0,0 +1,328 @@ +package qualification; + +import static qualification.FolderActionsTargetProbe.Worker.*; + +import java.nio.file.*; +import java.time.*; +import java.time.format.*; +import java.util.*; +import java.util.concurrent.Callable; +import java.util.concurrent.atomic.AtomicInteger; +import javafx.application.Platform; +import javafx.collections.ListChangeListener; +import javafx.scene.*; +import javafx.scene.control.*; +import javafx.stage.Window; + +/** Checks rendered folder rows and the ordinary modal profile dialogs in the preview worker. */ +public final class FolderProfilesTargetProbe { + public static void premain(String directory) { + if (System.getProperty("sun.java.command", "") + .startsWith("de.neitzel.fxdesigner.target.WorkerMain ")) + Thread.ofPlatform().daemon().start(() -> Checks.run(Path.of(directory))); + } + + private static final class Checks { + private static void run(Path dir) { + try { + var stage = previewStage(); + var root = + fx( + () -> { + stage.setWidth(1360); + stage.setHeight(700); + var r = stage.getScene().getRoot(); + r.applyCss(); + r.layout(); + return r; + }); + var attempt = Files.readString(dir.resolve("layout-case")); + var result = + switch (attempt) { + case "profiles", "readonly", "rebound" -> profiles(root, attempt); + case "metadata", "renamed", "recovered" -> metadata(root, attempt, dir); + default -> throw new AssertionError(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 error) { + error.printStackTrace(); + } + } + } + + private static DialogPane dialog(String title) { + return Window.getWindows().stream() + .filter(javafx.stage.Stage.class::isInstance) + .map(javafx.stage.Stage.class::cast) + .filter(s -> s.isShowing() && title.equals(s.getTitle())) + .map(s -> (DialogPane) s.getScene().getRoot()) + .findFirst() + .orElse(null); + } + + private static Button change(DialogPane d) { + return (Button) + d.lookupButton( + d.getButtonTypes().stream() + .filter(t -> t.getButtonData() == ButtonBar.ButtonData.OTHER) + .findFirst() + .orElseThrow()); + } + + private static void toggle(Node grid, String header) { + var menu = (MenuButton) grid.lookup(".data-grid-column-menu"); + menu.show(); + var item = + (CheckMenuItem) + menu.getItems().stream() + .filter(i -> header.equals(i.getText())) + .findFirst() + .orElseThrow(); + item.setSelected(!item.isSelected()); + item.fire(); + menu.hide(); + } + + private static String profiles(Parent root, String attempt) throws Exception { + var grid = fx(() -> root.lookup("#grid")); + var profiles = fx(() -> (ComboBox) root.lookup("#folder-view-profile")); + var save = fx(() -> (Button) root.lookup("#save-folder-view-profile")); + var clear = fx(() -> (Button) root.lookup("#clear-folder-view-layout")); + var manage = fx(() -> (Button) root.lookup("#manage-folder-view-profiles")); + boolean readonly = attempt.equals("readonly"), rebound = attempt.equals("rebound"); + await( + "Initial profile", + () -> !manage.isDisabled() && profiles.isDisabled() == readonly && clear.isDisabled()); + String name = readonly ? "Metadaten" : "Prüfprofil"; + fx( + () -> { + require( + !profiles.getItems().contains("Prüfprofil"), + "New session inherited previous profile"); + if (!readonly) profiles.getEditor().setText(name); + require(readonly == save.isDisabled(), "Save availability"); + if (!readonly && !rebound) { + save.fire(); + require(profiles.getItems().contains(name), "Profile not saved"); + } + toggle(grid, "Dateityp"); + return null; + }); + await("Changed local layout", () -> !clear.isDisabled() && !visible(grid, "type")); + fx( + () -> { + clear.fire(); + return null; + }); + await("Restored local layout", () -> clear.isDisabled() && visible(grid, "type")); + var openings = new AtomicInteger(); + String title = "Anzeigeprofile verwalten"; + ListChangeListener shown = + changes -> { + while (changes.next()) + for (Window w : changes.getAddedSubList()) + if (w instanceof javafx.stage.Stage s && title.equals(s.getTitle())) + openings.incrementAndGet(); + }; + fx( + () -> { + Window.getWindows().addListener(shown); + Platform.runLater((rebound ? save : manage)::fire); + return null; + }); + await("Profile manager opened", () -> dialog(title) != null); + fx( + () -> { + var d = dialog(title); + var list = (ListView) d.lookup("#archive-display-profiles"); + if (rebound) require(!list.getItems().contains(name), "Old save handler also ran"); + else { + list.getSelectionModel().select(name); + var action = change(d); + require(action.isDisabled() == readonly, "Profile deletion availability"); + if (!readonly) Platform.runLater(action::fire); + } + return null; + }); + if (!readonly && !rebound) { + Callable confirm = + () -> + Window.getWindows().stream() + .filter(Window::isShowing) + .map(w -> w.getScene().getRoot()) + .filter(DialogPane.class::isInstance) + .map(DialogPane.class::cast) + .filter(d -> d.getButtonTypes().contains(ButtonType.OK)) + .findFirst() + .orElse(null); + await("Delete confirmation", () -> confirm.call() != null); + fx( + () -> { + ((Button) confirm.call().lookupButton(ButtonType.OK)).fire(); + return null; + }); + await("Deleted own profile", () -> !profiles.getItems().contains(name)); + } + fx( + () -> { + ((Button) dialog(title).lookupButton(ButtonType.CLOSE)).fire(); + return null; + }); + fx( + () -> { + Window.getWindows().removeListener(shown); + require( + openings.get() == 1 && dialog(title) == null, + "Expected exactly one profile dialog: " + openings); + return null; + }); + if (rebound) + return "Fresh session. Rebound Save opened exactly one management dialog, without saving a" + + " profile."; + if (readonly) + return "Read-only: archive save, selection and deletion disabled. Management and local" + + " layout change/reset succeeded."; + return "Saved Prüfprofil, hid and restored Dateityp, deleted own profile after confirmation."; + } + + private static Label cell(Node grid, String text) { + return grid.lookupAll(".label").stream() + .filter(Label.class::isInstance) + .map(Label.class::cast) + .filter(l -> text.equals(l.getText())) + .findFirst() + .orElseThrow(() -> new AssertionError(text)); + } + + private static List