Offer grid row attributes and qualify Archiver folder profile editing

This commit is contained in:
2026-11-25 13:17:24 +01:00
parent ff6ba0a745
commit 9c63b2dd0f
10 changed files with 560 additions and 78 deletions
@@ -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> T fx(Callable<T> action) throws Exception {
static final class Worker {
static <T> T fx(Callable<T> action) throws Exception {
var task = new FutureTask<>(action);
Platform.runLater(task);
return task.get(10, TimeUnit.SECONDS);
}
private static void await(String description, Callable<Boolean> test) throws Exception {
static void await(String description, Callable<Boolean> 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);
@@ -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<String>) 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<Window> 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<String>) 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<DialogPane> 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<Label> row(Node grid, String file) {
return cell(grid, file).getParent().getChildrenUnmodifiable().stream()
.filter(Label.class::isInstance)
.map(Label.class::cast)
.toList();
}
private static String date(String day) {
return DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
.withZone(ZoneId.systemDefault())
.format(Instant.parse(day + "T11:00:00Z"));
}
private static void cells(Node grid, String file, String... expected) {
var labels = row(grid, file);
var actual = labels.stream().limit(10).map(Label::getText).toList();
var values = new ArrayList<>(List.of(file));
values.addAll(List.of(expected));
require(actual.equals(values), file + " rendered " + actual + " expected " + values);
require(
labels.get(4).getPrefWidth() == 182 && labels.get(5).getPrefWidth() == 168,
"Profile widths: " + labels.get(4).getPrefWidth() + ", " + labels.get(5).getPrefWidth());
}
private static String metadata(Parent root, String attempt, Path dir) throws Exception {
var grid = fx(() -> root.lookup("#grid"));
var profiles = fx(() -> (ComboBox<String>) root.lookup("#folder-view-profile"));
boolean renamed = !attempt.equals("metadata");
String sent = renamed ? "versand" : "mailSent";
await(
"Loaded saved metadata profile",
() -> visible(grid, sent) && visible(grid, "bookTitle") && !profiles.isDisabled());
fx(
() -> {
require(
"Metadaten".equals(profiles.getValue()), "Initial profile " + profiles.getValue());
String january = "Z-Anfrage.eml", december = "A-Zusage.eml";
cells(
grid,
january,
"Anfrage",
"ada@example.org",
"archiv@example.org",
"kopie@example.org",
date("2026-01-01"),
"",
"",
"",
"");
cells(
grid,
december,
"Zusage",
"ada@example.org",
"archiv@example.org",
"kopie@example.org",
date("2026-12-01"),
"",
"",
"",
"");
cells(
grid,
"Lesebuch.epub",
"",
"",
"",
"",
"",
renamed ? "Nordverlag" : "Das Lesebuch",
"Ada Berg, Eva Tal",
"Nordverlag",
"de");
cells(grid, "Notiz.txt", "", "", "", "", "", "", "", "", "");
require(
cell(grid, january).localToScene(0, 0).getY()
< cell(grid, december).localToScene(0, 0).getY(),
"Mail date sort order");
var setup = grid.getClass().getMethod("snapshotSetup").invoke(grid);
require(
setup
.getClass()
.getMethod("sort")
.invoke(setup)
.toString()
.contains(sent + ", direction=ASCENDING"),
"Sort after restoration: " + setup);
if (renamed) {
cell(grid, "Buchverlag");
require(
root.lookupAll(".label").stream()
.anyMatch(
n -> n instanceof Label l && l.getText().contains("mailSent → versand")),
"Missing profile mapping");
image(root, dir.resolve("folder-metadata.png"));
}
profiles.getSelectionModel().select("\0STANDARD");
return null;
});
await(
"Standard hides metadata",
() -> !visible(grid, sent) && !visible(grid, "mailCc") && !profiles.isDisabled());
fx(
() -> {
profiles.getSelectionModel().select("\0EMAIL");
return null;
});
await(
"Email shows date and CC",
() ->
visible(grid, sent)
&& visible(grid, "mailCc")
&& !visible(grid, "bookTitle")
&& !profiles.isDisabled());
fx(
() -> {
profiles.getSelectionModel().select("Metadaten");
return null;
});
await("Return to saved profile", () -> visible(grid, "bookTitle") && !profiles.isDisabled());
return "Rendered two mails, EPUB and plain text. Nine metadata cells per row; sort "
+ sent
+ " ascending, CC 182 px, date 168 px. Standard → Email → Metadaten."
+ (renamed ? " Retained date source and bookPublisher in Buchverlag." : "");
}
}
}
@@ -0,0 +1,109 @@
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;
/** Saves profile bindings and column declarations in the registered FolderTab editor. */
public final class FolderProfilesWorkflowProbe extends DeclarationWorkflowProbe {
@Override
void verify(Project project) throws Exception {
this.project = project;
open("FolderTab");
build("folder-actions");
interactive("folder-actions", "profiles");
interactive("folder-readonly", "readonly");
interactive("folder-metadata", "metadata");
for (var id : List.of("saveProfile", "clearLayout", "manageProfiles")) commands(id, id, 4);
commands("saveProfile", "saveProfile", 4);
click(pane, "Discover / Validate Commands");
await(
() ->
fx(
() ->
((Label) pane.lookup("#command-status"))
.getText()
.contains("No detected binding errors.")));
fx(
() -> {
var choices =
pane.lookup("#command-path").getParent().getChildrenUnmodifiable().stream()
.filter(
n -> Integer.valueOf(1).equals(javafx.scene.layout.GridPane.getRowIndex(n)))
.filter(ComboBox.class::isInstance)
.map(ComboBox.class::cast)
.filter(
box ->
box.getItems()
.containsAll(List.of("manageProfiles", "saveProfile", "clearLayout")))
.findFirst()
.orElseThrow();
choices.getSelectionModel().select("manageProfiles");
return null;
});
click(pane, "Apply Command binding");
String bound = "control=\"saveProfile\" path=\"manageProfiles\"";
await(() -> source().contains(bound));
inspector(true);
select("DataGridColumn", "mailSent");
applySetting("id", "versand");
select("DataGridColumn", "bookTitle");
combo("declaration-property", "attribute");
choose("declaration-value", "bookPublisher");
edit("Apply setting", "attribute=\"bookPublisher\"");
applySetting("header", "Buchverlag");
reopen("FolderTab", "header=\"Buchverlag\"");
if (!source().contains(bound) || !source().contains("attribute=\"mailSent\""))
throw new AssertionError(source());
build("folder-actions");
choose("preview-example", "folder-actions");
await(
() ->
fx(
() ->
((Label) pane.lookup("#preview-state"))
.getText()
.contains("Suche und Anzeigeprofile")
&& ((javafx.scene.image.ImageView) pane.lookup("#full-preview-image"))
.getImage()
!= null));
commands("saveProfile", "manageProfiles", 4);
fx(
() -> {
ImageIO.write(
SwingFXUtils.fromFXImage(pane.snapshot(null, null), null),
"png",
output.resolve("intellij.png").toFile());
return null;
});
interactive("folder-actions", "rebound");
interactive("folder-metadata", "renamed");
for (String invalid : List.of("keinFeld", "bookPublisher")) {
inspector(true);
select("DataGridColumn", "versand");
applySetting("attribute", invalid);
click(pane, "Form preview");
click(pane, "Render drafts");
await(
() ->
fx(
() -> {
var message = ((Label) pane.lookup("#preview-state")).getText();
return message.contains("versand")
&& message.contains(invalid)
&& message.contains(
invalid.equals("keinFeld") ? "unbekanntes Zeilenattribut" : "INTEGER");
}));
step("Preview diagnosed " + invalid + " on INTEGER column versand");
click(pane, "Undo");
await(() -> source().contains("attribute=\"mailSent\""));
}
interactive("folder-metadata", "recovered");
Files.writeString(output.resolve("SUCCESS.txt"), Files.readString(output.resolve("steps.txt")));
}
}
@@ -140,5 +140,38 @@ abstract class FormWorkflowProbe implements StartupActivity.DumbAware {
});
}
void commands(String control, String path, int count) throws Exception {
fx(
() -> {
var group =
(TitledPane)
pane.lookupAll(".titled-pane").stream()
.filter(n -> n instanceof TitledPane t && "Bindings".equals(t.getText()))
.findFirst()
.orElseThrow();
group.setAnimated(false);
group.setExpanded(true);
var tabs = (TabPane) group.getContent();
tabs.getSelectionModel()
.select(
tabs.getTabs().stream()
.filter(t -> t.getText().equals("Command bindings"))
.findFirst()
.orElseThrow());
pane.applyCss();
pane.layout();
var list = (ListView<?>) pane.lookup("#command-bindings");
if (list.getItems().size() != count) throw new AssertionError(list.getItems());
for (int i = 0; i < count; i++) {
if (list.getItems().get(i).toString().startsWith(control + " ←"))
list.getSelectionModel().select(i);
}
if (!control.equals(((TextField) pane.lookup("#command-control")).getText())
|| !path.equals(((TextField) pane.lookup("#command-path")).getText()))
throw new AssertionError(control + " → " + path);
return null;
});
}
abstract void verify(Project project) throws Exception;
}
+26 -10
View File
@@ -16,13 +16,13 @@ import javax.imageio.ImageIO;
public final class ImportWorkflowProbe extends FormWorkflowProbe {
@Override
void verify(Project project) throws Exception {
open(project, "ConnectionForm", 2);
open(project, "ConnectionForm");
discover();
target("securityChoices", "view", "security", "items", "COMPATIBLE");
target("protocol", "both", "protocol", "value", "COMPATIBLE");
target("security", "both", "security", "value", "COMPATIBLE");
open(project, "FolderTab", 2);
open(project, "FolderTab");
discover();
target("view", "both", "view", "value", "COMPATIBLE");
target("grouping", "both", "grouping", "value", "COMPATIBLE");
@@ -31,20 +31,20 @@ public final class ImportWorkflowProbe extends FormWorkflowProbe {
target("rows", "view", "clearLayout", "accessibleHelp", "INCOMPATIBLE");
target("view", "both", "untypedPick", "value", "UNRESOLVED");
target("rows", "view", "grid", "items", "COMPATIBLE");
applyAndReopen(project, "FolderTab", 2, "grid", "items", "rows", "view");
applyAndReopen(project, "FolderTab", "grid", "items", "rows", "view");
preview("archive-folder", "import-grid");
open(project, "ImportForm", 3);
open(project, "ImportForm");
discover();
target("folder", "both", "folders", "value", "COMPATIBLE");
applyAndReopen(project, "ImportForm", 3, "folders", "value", "folder", "both");
applyAndReopen(project, "ImportForm", "folders", "value", "folder", "both");
preview("import-free", "import-free");
preview("import-collision", "import-collision");
preview("import-busy", "import-busy");
Files.writeString(output.resolve("SUCCESS.txt"), Files.readString(output.resolve("steps.txt")));
}
private void open(Project project, String form, int count) throws Exception {
private void open(Project project, String form) throws Exception {
var path =
Path.of(project.getBasePath(), "src/main/resources/de/neitzel/archiver/ui", form + ".fxml");
file = edt(() -> LocalFileSystem.getInstance().refreshAndFindFileByNioFile(path));
@@ -52,8 +52,24 @@ public final class ImportWorkflowProbe extends FormWorkflowProbe {
fx(pane::flush).toCompletableFuture().get(10, java.util.concurrent.TimeUnit.SECONDS);
click(pane, "Form preview");
click(pane, "Build and Refresh");
var required =
switch (form) {
case "FolderTab" -> java.util.List.of("archive-folder", "folder-actions");
case "ConnectionForm" -> java.util.List.of("connection-imap", "connection-jmap");
case "ImportForm" -> java.util.List.of("import-free", "import-collision", "import-busy");
default -> throw new IllegalArgumentException(form);
};
await(
() -> fx(() -> ((ComboBox<?>) pane.lookup("#preview-example")).getItems().size() == count));
() ->
fx(
() ->
((ComboBox<?>) pane.lookup("#preview-example"))
.getItems().stream()
.map(
de.neitzel.fxdesigner.workflow.DesignerWorkflow.Example.class::cast)
.map(de.neitzel.fxdesigner.workflow.DesignerWorkflow.Example::id)
.toList()
.containsAll(required)));
// The initial native document sync invalidates discovery while the first preview is loading.
// Wait for the displayed revision before selecting a source in the inspector.
await(
@@ -73,7 +89,7 @@ public final class ImportWorkflowProbe extends FormWorkflowProbe {
return ((ImageView) pane.lookup("#full-preview-image")).getImage() != null
&& state.contains("revision");
}));
step("Opened " + form + " with " + count + " examples");
step("Opened " + form + " with " + required);
}
private void discover() throws Exception {
@@ -161,7 +177,7 @@ public final class ImportWorkflowProbe extends FormWorkflowProbe {
}
private void applyAndReopen(
Project project, String form, int count, String id, String prop, String path, String dir)
Project project, String form, String id, String prop, String path, String dir)
throws Exception {
click(pane, "Use selected target");
if (!fx(
@@ -188,7 +204,7 @@ public final class ImportWorkflowProbe extends FormWorkflowProbe {
FileEditorManager.getInstance(project).closeFile(file);
return null;
});
open(project, form, count);
open(project, form);
if (!source().contains(declaration)) throw new AssertionError("Binding was lost on reopen");
step("Applied, saved and reopened " + declaration);
}
@@ -106,38 +106,6 @@ public final class ManagementReadersWorkflowProbe extends FormWorkflowProbe {
if (!source().contains(saved)) throw new AssertionError("Reopened " + form);
}
private void commands(String control, String path, int count) throws Exception {
fx(
() -> {
var group =
(TitledPane)
pane.lookupAll(".titled-pane").stream()
.filter(n -> n instanceof TitledPane t && "Bindings".equals(t.getText()))
.findFirst()
.orElseThrow();
group.setExpanded(true);
var tabs = (TabPane) group.getContent();
tabs.getSelectionModel()
.select(
tabs.getTabs().stream()
.filter(t -> t.getText().equals("Command bindings"))
.findFirst()
.orElseThrow());
pane.applyCss();
pane.layout();
var list = (ListView<?>) pane.lookup("#command-bindings");
if (list.getItems().size() != count) throw new AssertionError(list.getItems());
for (int i = 0; i < count; i++) {
if (list.getItems().get(i).toString().startsWith(control + " ←"))
list.getSelectionModel().select(i);
}
if (!control.equals(((TextField) pane.lookup("#command-control")).getText())
|| !path.equals(((TextField) pane.lookup("#command-path")).getText()))
throw new AssertionError(control + " → " + path);
return null;
});
}
private void management(
String form,
String data,