Validate grid width bounds and qualify Archiver window and document states in IntelliJ

This commit is contained in:
2026-11-25 12:08:18 +01:00
parent 2df25985ce
commit ff6ba0a745
12 changed files with 429 additions and 65 deletions
+1 -1
View File
@@ -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.
@@ -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;
}
}
@@ -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);
}
}
}
@@ -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<String, String> 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 + "=<nested FXML>", 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<Replacement> 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",
@@ -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));
@@ -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(
"<?import de.neitzel.fx.view.*?><DataGridColumn width='230' minimumWidth='200'/>");
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(
"<?import de.neitzel.fx.view.*?><DataGridColumn width='%start' maximumWidth='200'/>");
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 =
+2
View File
@@ -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
+92 -6
View File
@@ -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<String, MenuItem> commands,
Button trash,
StringBuilder evidence) {
var active = new TreeSet<String>();
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<String, MenuItem>();
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;
}
}
@@ -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="
@@ -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<String> 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<String> required) {
return file.getName()
+ " · required "
+ required
+ " · available "
+ available()
+ " · "
+ state();
}
private void awaitExamples(List<String> 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<Example>) 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();
@@ -284,6 +284,28 @@ public final class MediaLayoutGridTargetProbe {
var cols = (List<?>) get(setup, "columns");
var order = new ArrayList<String>();
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";
}
@@ -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");