Edit control properties and verify controller event handlers in IntelliJ

This commit is contained in:
2026-11-25 08:23:40 +01:00
parent ceb32166ff
commit 22ff06ea75
14 changed files with 699 additions and 16 deletions
+2
View File
@@ -89,6 +89,8 @@ Add `--saved-document` to the Archiver launcher or host check to open the design
Use `--import-form` with `scripts/check-ide-host.py --archiver ../Archiver` and the same JDK and IDEA options to verify seven generic binding targets. The check saves and reopens bindings on the folder grid and import selector, then exercises the free, conflicting and busy import examples in the registered editor. Use `--import-form` with `scripts/check-ide-host.py --archiver ../Archiver` and the same JDK and IDEA options to verify seven generic binding targets. The check saves and reopens bindings on the folder grid and import selector, then exercises the free, conflicting and busy import examples in the registered editor.
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. 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.
For an existing Archiver checkout, install the built plugin ZIP and create the ignored local JDK and worker mappings once with `python3 scripts/configure-library-example.py --project ../Archiver --target-java-home "$JAVA_HOME"`. Launch the IDE with access to the Maven repository containing the qualified snapshots. For an existing Archiver checkout, install the built plugin ZIP and create the ignored local JDK and worker mappings once with `python3 scripts/configure-library-example.py --project ../Archiver --target-java-home "$JAVA_HOME"`. Launch the IDE with access to the Maven repository containing the qualified snapshots.
@@ -22,7 +22,51 @@ public record BindingMetadata(
List<RepeatOption> tableRows, List<RepeatOption> tableRows,
List<RepeatOption> tableColumns, List<RepeatOption> tableColumns,
List<String> commandPaths, List<String> commandPaths,
List<String> commandTargets) { List<String> commandTargets,
Optional<List<String>> actionEventHandlers) {
public BindingMetadata(
String model,
String path,
String direction,
List<Attribute> attributes,
List<Target> targets,
List<String> diagnostics,
List<Converter> converters,
List<Problem> problems,
String controller,
String viewModel,
List<Computed> computed,
List<RepeatOption> collections,
List<RepeatOption> components,
List<RepeatOption> panes,
List<RepeatOption> tableCollections,
List<RepeatOption> tableRows,
List<RepeatOption> tableColumns,
List<String> commandPaths,
List<String> commandTargets) {
this(
model,
path,
direction,
attributes,
targets,
diagnostics,
converters,
problems,
controller,
viewModel,
computed,
collections,
components,
panes,
tableCollections,
tableRows,
tableColumns,
commandPaths,
commandTargets,
Optional.empty());
}
public BindingMetadata( public BindingMetadata(
String model, String model,
String path, String path,
@@ -204,6 +248,7 @@ public record BindingMetadata(
tableColumns = List.copyOf(tableColumns); tableColumns = List.copyOf(tableColumns);
commandPaths = List.copyOf(commandPaths); commandPaths = List.copyOf(commandPaths);
commandTargets = List.copyOf(commandTargets); commandTargets = List.copyOf(commandTargets);
actionEventHandlers = actionEventHandlers.map(List::copyOf);
if (!Set.of("view", "model", "both").contains(direction)) if (!Set.of("view", "model", "both").contains(direction))
throw new IllegalArgumentException("Invalid direction"); throw new IllegalArgumentException("Invalid direction");
} }
@@ -211,6 +256,7 @@ public record BindingMetadata(
public Map<String, String> encode() { public Map<String, String> encode() {
var m = new TreeMap<String, String>(); var m = new TreeMap<String, String>();
m.put("format", "5"); m.put("format", "5");
actionEventHandlers.ifPresent(names -> encodeStrings(m, "actionEvents", names));
encodeStrings(m, "commands", commandPaths); encodeStrings(m, "commands", commandPaths);
encodeStrings(m, "commandTargets", commandTargets); encodeStrings(m, "commandTargets", commandTargets);
encodeOptions(m, "rc", collections); encodeOptions(m, "rc", collections);
@@ -393,6 +439,9 @@ public record BindingMetadata(
decodeOptions(m, "tr"), decodeOptions(m, "tr"),
decodeOptions(m, "ta"), decodeOptions(m, "ta"),
commands ? decodeStrings(m, "commands") : List.of(), commands ? decodeStrings(m, "commands") : List.of(),
commands ? decodeStrings(m, "commandTargets") : List.of()); commands ? decodeStrings(m, "commandTargets") : List.of(),
m.containsKey("actionEvents")
? Optional.of(decodeStrings(m, "actionEvents"))
: Optional.empty());
} }
} }
@@ -876,6 +876,7 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
validatingSource = null; validatingSource = null;
validationPreview = false; validationPreview = false;
bindingWorkflow.cancel(); bindingWorkflow.cancel();
formEditor.eventHandlers(Optional.empty());
bindingBrowser.invalidate(message); bindingBrowser.invalidate(message);
repeatEditor.invalidateDiscovery(); repeatEditor.invalidateDiscovery();
commandEditor.invalidateDiscovery(); commandEditor.invalidateDiscovery();
@@ -1163,6 +1164,7 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
} }
validatedSource = captured.text(); validatedSource = captured.text();
bindingProblems = metadata.problems(); bindingProblems = metadata.problems();
formEditor.eventHandlers(metadata.actionEventHandlers());
publishDiagnostics( publishDiagnostics(
last last
? "Explicit retained build (outdated)" ? "Explicit retained build (outdated)"
@@ -1243,6 +1245,7 @@ public final class DesignerPane extends BorderPane implements AutoCloseable {
} }
validatedSource = captured.text(); validatedSource = captured.text();
bindingProblems = metadata.problems(); bindingProblems = metadata.problems();
formEditor.eventHandlers(metadata.actionEventHandlers());
publishDiagnostics( publishDiagnostics(
last last
? "Explicit retained build (outdated)" ? "Explicit retained build (outdated)"
@@ -316,6 +316,12 @@ final class FormDocument {
List<Field> fields(Item item) { List<Field> fields(Item item) {
var e = element(item); var e = element(item);
var fields = new LinkedHashMap<String, Field>(); var fields = new LinkedHashMap<String, Field>();
field(fields, "accessibleText", "String", "");
if (Set.of("TextField", "PasswordField", "AutoCompleteTextField").contains(item.type()))
field(fields, "prefColumnCount", "Integer", "12");
if (Set.of(
"TextField", "PasswordField", "AutoCompleteTextField", "Button", "CheckBox", "ComboBox")
.contains(item.type())) field(fields, "onAction", "Event handler", "");
field(fields, "styleClass", "CSS classes", "control default"); field(fields, "styleClass", "CSS classes", "control default");
field(fields, "padding", "Insets", item.type().equals("StatusBar") ? "4 8 4 8" : "0"); field(fields, "padding", "Insets", item.type().equals("StatusBar") ? "4 8 4 8" : "0");
field(fields, "style", "CSS", ""); field(fields, "style", "CSS", "");
@@ -13,6 +13,8 @@ final class FormEditor extends VBox {
private final Spinner<Integer> position = new Spinner<>(0, 0, 0); private final Spinner<Integer> position = new Spinner<>(0, 0, 0);
private final ComboBox<FormDocument.Item> selected = combo("form-control"); private final ComboBox<FormDocument.Item> selected = combo("form-control");
private final ComboBox<FormDocument.Field> field = combo("form-property"); private final ComboBox<FormDocument.Field> field = combo("form-property");
private final ComboBox<String> handlers = combo("form-event-handlers");
private Optional<List<String>> verifiedHandlers = Optional.empty();
private final TextArea value = new TextArea(); private final TextArea value = new TextArea();
private final Label details = new Label(), message = new Label(); private final Label details = new Label(), message = new Label();
private final Consumer<FormDocument.Edit> submit; private final Consumer<FormDocument.Edit> submit;
@@ -30,6 +32,13 @@ final class FormEditor extends VBox {
palette.setValue("Label"); palette.setValue("Label");
position.setId("form-position"); position.setId("form-position");
position.setPrefWidth(74); position.setPrefWidth(74);
handlers.setPromptText("Choose controller method");
handlers.managedProperty().bind(handlers.visibleProperty());
handlers.setVisible(false);
handlers.setOnAction(
e -> {
if (handlers.getValue() != null) value.setText(handlers.getValue());
});
value.setId("form-value"); value.setId("form-value");
value.setPrefRowCount(2); value.setPrefRowCount(2);
details.setId("form-field-type"); details.setId("form-field-type");
@@ -79,18 +88,25 @@ final class FormEditor extends VBox {
destination.getValue(), destination.getValue(),
position.getValue())))), position.getValue())))),
row(new Label("Property"), field, details), row(new Label("Property"), field, details),
handlers,
value, value,
row( row(
button( button(
"Set property", "Set property",
() -> () ->
perform( perform(
() -> () -> {
form.set( if (eventSelected()
selected.getValue(), && verifiedHandlers.isPresent()
field.getValue(), && !verifiedHandlers.get().contains(value.getText()))
value.getText(), throw new IllegalArgumentException(
false))), "No accessible controller method "
+ value.getText()
+ " for ActionEvent. Choose a listed method with no"
+ " argument or a compatible event argument.");
return form.set(
selected.getValue(), field.getValue(), value.getText(), false);
})),
button( button(
"Reset property", "Reset property",
() -> perform(() -> form.set(selected.getValue(), field.getValue(), "", true))), () -> perform(() -> form.set(selected.getValue(), field.getValue(), "", true))),
@@ -168,7 +184,27 @@ final class FormEditor extends VBox {
showValue(); showValue();
} }
void eventHandlers(Optional<List<String>> names) {
verifiedHandlers = names;
handlers.getItems().setAll(names.orElse(List.of()));
handlers.setDisable(names.isEmpty());
if (eventSelected()) showHandlerStatus();
}
private boolean eventSelected() {
return field.getValue() != null && field.getValue().type().equals("Event handler");
}
private void showHandlerStatus() {
details.setText(
verifiedHandlers.isEmpty()
? "ActionEvent · Build and Refresh to check controller methods"
: "ActionEvent · methods from the compiled controller");
}
private void showValue() { private void showValue() {
handlers.setVisible(eventSelected());
handlers.getSelectionModel().clearSelection();
var f = field.getValue(); var f = field.getValue();
var item = selected.getValue(); var item = selected.getValue();
if (form == null || item == null || f == null) { if (form == null || item == null || f == null) {
@@ -184,6 +220,7 @@ final class FormEditor extends VBox {
+ (f.type().equals("ObservableList<String>") + (f.type().equals("ObservableList<String>")
? "bind to a model list" ? "bind to a model list"
: f.editable() ? "editable" : "read only")); : f.editable() ? "editable" : "read only"));
if (eventSelected()) showHandlerStatus();
value.setEditable(f.editable()); value.setEditable(f.editable());
value.setText(form.value(item, f)); value.setText(form.value(item, f));
} }
@@ -483,7 +483,8 @@ public final class BindingDiscovery {
.filter(e -> commandTarget(e.getValue())) .filter(e -> commandTarget(e.getValue()))
.map(Map.Entry::getKey) .map(Map.Entry::getKey)
.sorted() .sorted()
.toList()); .toList(),
owner.actionEventHandlers());
} }
private List<String> commandPaths() { private List<String> commandPaths() {
@@ -117,6 +117,50 @@ final class ControllerMetadata {
} }
} }
/** FXMLLoader gives an event-taking overload precedence over a parameterless handler. */
Optional<List<String>> actionEventHandlers() {
if (unknownController && controller == null) return Optional.empty();
var names = new TreeSet<String>();
var effectiveEvents = new HashMap<String, Boolean>();
for (Class<?> type = controller;
type != null
&& !type.getPackageName().startsWith("java.")
&& !type.getPackageName().startsWith("javafx.");
type = type.getSuperclass()) {
var declaredEvents = new HashMap<String, Boolean>();
for (var method : type.getDeclaredMethods()) {
int modifiers = method.getModifiers();
boolean publicAccess =
Modifier.isPublic(modifiers) && Modifier.isPublic(type.getModifiers());
if (Modifier.isStatic(modifiers)
|| Modifier.isNative(modifiers)
|| method.isSynthetic()
|| method.isBridge()
|| (!publicAccess && !method.isAnnotationPresent(javafx.fxml.FXML.class))
|| method.getName().equals("initialize")) continue;
Module module = type.getModule(), fxml = javafx.fxml.FXMLLoader.class.getModule();
if (!module.isOpen(type.getPackageName(), fxml)
&& !(publicAccess && module.isExported(type.getPackageName(), fxml))) continue;
var parameters = method.getParameterTypes();
if (parameters.length == 0) names.add("#" + method.getName());
if (parameters.length == 1 && javafx.event.Event.class.isAssignableFrom(parameters[0])) {
declaredEvents.merge(
"#" + method.getName(),
parameters[0].isAssignableFrom(javafx.event.ActionEvent.class),
Boolean::logicalAnd);
}
}
// FXMLLoader indexes EVENT methods by name, with the subclass taking precedence.
declaredEvents.forEach(effectiveEvents::putIfAbsent);
}
effectiveEvents.forEach(
(name, acceptsAction) -> {
if (acceptsAction) names.add(name);
else names.remove(name);
});
return Optional.of(List.copyOf(names));
}
List<Computed> methods(Class<?> target) { List<Computed> methods(Class<?> target) {
if (controller == null) return List.of(); if (controller == null) return List.of();
var result = new TreeMap<String, Computed>(); var result = new TreeMap<String, Computed>();
@@ -0,0 +1,61 @@
package de.neitzel.fxdesigner.target;
import static org.junit.jupiter.api.Assertions.*;
import de.neitzel.fxdesigner.protocol.BindingMetadata;
import java.util.List;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.scene.input.KeyEvent;
import org.junit.jupiter.api.Test;
class ActionEventHandlersTest {
public static class Parent {
@FXML
private void inherited(Event event) {}
public void replaced(KeyEvent event) {}
private void hidden() {}
}
public static class Controller extends Parent {
@FXML
private void submit(ActionEvent event) {}
public void replaced(ActionEvent event) {}
public void clear() {}
public void mixed() {}
public void mixed(KeyEvent event) {}
public void keys(KeyEvent event) {}
public static void helper() {}
public void initialize() {}
Controller() {
throw new AssertionError("Discovery constructed a controller");
}
}
@Test
void reportsOnlyAccessibleSignaturesCallableForActionEvents() throws Exception {
var xml =
"<?import javafx.scene.control.TextField?><TextField xmlns:fx=\"http://javafx.com/fxml/1\""
+ " fx:controller=\""
+ Controller.class.getName()
+ "\"/>";
var result = BindingDiscovery.inspect(xml, "", "view", getClass().getClassLoader());
var wire = result.encode();
assertEquals(
List.of("#clear", "#inherited", "#replaced", "#submit"),
BindingMetadata.decode(wire).actionEventHandlers().orElseThrow());
wire.remove("actionEvents");
assertTrue(BindingMetadata.decode(wire).actionEventHandlers().isEmpty());
}
}
+6
View File
@@ -39,3 +39,9 @@ Paste targets supported standard Pane children (VBox, HBox, Pane, AnchorPane, St
Problems are scoped to open designer documents and current build/draft evidence. Selecting a problem navigates to the affected FXML location. Source underlines follow the same ranges. IntelliJ also exposes Problems entries, native XML annotations and **Alt+Enter** actions. This is not a whole-project background inspection or precise Java-source navigation service. Problems are scoped to open designer documents and current build/draft evidence. Selecting a problem navigates to the affected FXML location. Source underlines follow the same ranges. IntelliJ also exposes Problems entries, native XML annotations and **Alt+Enter** actions. This is not a whole-project background inspection or precise Java-source navigation service.
Errors block new previews; warnings remain visible and permit preview. Stale diagnostic actions are withdrawn after edits or build changes. Available fixes are deliberately narrow: explicit DirectBinding direction choices, removing a later duplicate Direct/Computed target, and removal of eligible simple invalid Direct/Computed/Repeat declarations. Tables, unknown/nested payloads, warnings and declarations with `fx:id` do not get speculative deletion fixes. No action is auto-selected. Fixes preserve unrelated source and use normal Undo/Redo; see [supported fixes](../source-highlighting-fixes.md). Errors block new previews; warnings remain visible and permit preview. Stale diagnostic actions are withdrawn after edits or build changes. Available fixes are deliberately narrow: explicit DirectBinding direction choices, removing a later duplicate Direct/Computed target, and removal of eligible simple invalid Direct/Computed/Repeat declarations. Tables, unknown/nested payloads, warnings and declarations with `fx:id` do not get speculative deletion fixes. No action is auto-selected. Fixes preserve unrelated source and use normal Undo/Redo; see [supported fixes](../source-highlighting-fixes.md).
### Form properties and controller events
In **Form controls**, select a control and property. **Set property** writes the FXML attribute. **Reset property** removes it and restores its JavaFX default. The accessible name is inherited from Node. Text fields including AutoCompleteTextField accept a non-negative integer for `prefColumnCount`. Layout results such as `width` are read-only.
After **Build and Refresh**, select `onAction` on a supported action control, `onDismiss` on ToolBarPane, or `onRemove` on TagChip. Choose a compiled controller method in the list, or enter its `#method` reference and select **Set property**. The target checks accessible no-argument methods and methods accepting ActionEvent or Event, including inherited and FXML-annotated handlers. Without current controller metadata the inspector indicates that a build is needed for method checking. Undo, Redo and Save use the same FXML document as the bindings editor.
@@ -0,0 +1,297 @@
package qualification;
import java.nio.file.*;
import java.util.*;
import java.util.concurrent.*;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.input.ContextMenuEvent;
import javafx.stage.*;
import javax.imageio.ImageIO;
/** Acts on the actual controls in the interactive Archiver worker. */
public final class FolderActionsTargetProbe {
public static void premain(String dir) {
if (System.getProperty("sun.java.command", "")
.startsWith("de.neitzel.fxdesigner.target.WorkerMain "))
Thread.ofPlatform().daemon().start(() -> Worker.run(Path.of(dir)));
}
private static final class Worker {
private static <T> T fx(Callable<T> action) throws Exception {
var task = new FutureTask<>(action);
Platform.runLater(task);
return task.get(10, TimeUnit.SECONDS);
}
private static void await(String description, Callable<Boolean> test) throws Exception {
long end = System.nanoTime() + TimeUnit.SECONDS.toNanos(22);
while (System.nanoTime() < end) {
if (fx(test)) return;
Thread.sleep(90);
}
throw new AssertionError(description);
}
private static void require(boolean value, String message) {
if (!value) throw new AssertionError(message);
}
private static void run(Path dir) {
try {
Stage stage = null;
while (stage == null) {
Thread.sleep(120);
try {
stage =
fx(
() ->
Window.getWindows().stream()
.filter(
w ->
w instanceof Stage s
&& s.isShowing()
&& s.getOpacity() > 0
&& s.getTitle() != null
&& s.getTitle().startsWith("Neitzel preview"))
.map(Stage.class::cast)
.findFirst()
.orElse(null));
} catch (IllegalStateException starting) {
}
}
Stage shown = stage;
var root =
fx(
() -> {
shown.setWidth(1250);
shown.setHeight(640);
var r = shown.getScene().getRoot();
r.applyCss();
r.layout();
return r;
});
if (fx(() -> root.lookup("#tag-input") != null)) {
fx(
() -> {
var input = (TextField) root.lookup("#tag-input");
require(
input.getPrefColumnCount() == 23
&& "Belege verschlagworten".equals(input.getAccessibleText()),
"Saved text field properties");
input.setText("Inspektorprobe");
input.fireEvent(new ActionEvent());
require(
root.lookupAll(".tag-chip").stream()
.anyMatch(
chip ->
chip.lookup(".label") instanceof Label l
&& l.getText().equals("Inspektorprobe")),
"onAction did not add tag");
return null;
});
Files.writeString(
dir.resolve("result-detail-action"),
"23 columns and accessible name restored; #addTag added Inspektorprobe");
} else checkFolder(dir, root);
} catch (Throwable failure) {
var trace = new java.io.StringWriter();
failure.printStackTrace(new java.io.PrintWriter(trace));
try {
Files.writeString(dir.resolve("target-error.txt"), trace.toString());
} catch (Exception ignored) {
}
}
}
private static List<?> rows(Node grid) throws Exception {
return (List<?>) grid.getClass().getMethod("getItems").invoke(grid);
}
private static String attr(Object row, String name) throws Exception {
return (String) row.getClass().getMethod(name).invoke(row);
}
private static void select(Node grid, List<String> keys) throws Exception {
grid.getClass().getMethod("selectKeys", Collection.class).invoke(grid, keys);
}
private static MenuItem move(Node grid, String file) {
Node anchor =
grid.lookupAll(".label").stream()
.filter(n -> n instanceof Label l && l.getText().equals(file))
.findFirst()
.orElseThrow();
while (anchor != null && anchor.getOnContextMenuRequested() == null)
anchor = anchor.getParent();
Objects.requireNonNull(anchor, "Product row context menu");
var p = anchor.localToScreen(0, 0);
anchor.fireEvent(
new ContextMenuEvent(
ContextMenuEvent.CONTEXT_MENU_REQUESTED, 0, 0, p.getX(), p.getY(), false, null));
return Window.getWindows().stream()
.filter(w -> w instanceof ContextMenu m && m.isShowing())
.map(ContextMenu.class::cast)
.flatMap(m -> m.getItems().stream())
.filter(i -> "Verschieben …".equals(i.getText()))
.findFirst()
.orElseThrow();
}
private static boolean visible(Node grid, String column) throws Exception {
return (boolean)
grid.getClass().getMethod("isColumnVisible", String.class).invoke(grid, column);
}
@SuppressWarnings("unchecked")
private static void checkFolder(Path dir, Parent root) throws Exception {
Node grid = fx(() -> root.lookup("#grid"));
var search = fx(() -> (TextField) root.lookup("#search"));
var feedback = fx(() -> (Label) root.lookup("#example-folder-result"));
var places = fx(() -> (Button) root.lookup("#places"));
var profiles = fx(() -> (ComboBox<String>) root.lookup("#folder-view-profile"));
var save = fx(() -> (Button) root.lookup("#save-folder-view-profile"));
fx(
() -> {
search.setText("Archivbeleg");
search.fireEvent(new ActionEvent());
return null;
});
await(
"Two distinguishable full-text hits for Archivbeleg",
() -> {
if (rows(grid).size() != 2) return false;
for (var row : rows(grid))
if (!attr(row, "snippet").toLowerCase(Locale.ROOT).contains("archivbeleg"))
return false;
return grid.lookupAll(".label").stream()
.anyMatch(n -> n instanceof Label l && l.getText().equals("Lieferbrief.md"));
});
var keys =
fx(
() -> {
var result = new TreeMap<String, String>();
for (var row : rows(grid)) result.put(attr(row, "path"), attr(row, "key"));
return result;
});
var invoice = keys.get("Musterrechnung.pdf");
var letter = keys.get("Lieferbrief.md");
require(
invoice != null && letter != null && !invoice.equals(letter),
"Distinct archive entry keys: " + keys);
fx(
() -> {
var action = move(grid, "Lieferbrief.md");
select(grid, List.of());
require(action.isDisable() && places.isDisabled(), "Empty selection enabled actions");
select(grid, List.of(letter));
require(!action.isDisable() && !places.isDisabled(), "Single selection blocked");
places.fire();
require(
feedback.getText().contains("Lieferbrief.md")
&& feedback.getText().contains("Wareneingang"),
"Wrong place: " + feedback.getText());
action.fire();
require(feedback.getText().equals("Verschieben · " + letter), "Wrong single key");
select(grid, List.of(invoice, letter));
require(!action.isDisable() && places.isDisabled(), "Multiple selection availability");
action.fire();
String message = feedback.getText();
require(
message.startsWith("Verschieben · ")
&& Set.copyOf(
Arrays.asList(message.substring("Verschieben · ".length()).split(", ")))
.equals(Set.of(invoice, letter)),
"Wrong affected keys: " + message);
image(root, dir.resolve("folder-search.png"));
search.setText("Wareneingang");
search.fireEvent(new ActionEvent());
String before = feedback.getText();
action.fire();
require(
places.isDisabled() && before.equals(feedback.getText()),
"Stale action during new search");
return null;
});
await(
"Only Lieferbrief matches Wareneingang",
() -> rows(grid).size() == 1 && attr(rows(grid).getFirst(), "key").equals(letter));
fx(
() -> {
((Button) root.lookup(".tool-bar-dismiss")).fire();
Node bar = root.lookup("#search-toolbar");
require(
!bar.isVisible() && !bar.isManaged() && search.getText().isEmpty(),
"onDismiss did not close/reset the search");
return null;
});
await(
"Normal folder rows and profiles ready",
() -> rows(grid).size() == 2 && !profiles.isDisabled());
fx(
() -> {
var menu = (MenuButton) grid.lookup(".data-grid-column-menu");
menu.show();
var type =
(CheckMenuItem)
menu.getItems().stream()
.filter(it -> "Dateityp".equals(it.getText()))
.findFirst()
.orElseThrow();
require(type.isSelected(), "Initially hidden type");
type.setSelected(false);
type.fire();
menu.hide();
profiles.getEditor().setText("Kurzansicht");
require(!save.isDisabled(), "Save unavailable");
save.fire();
require(profiles.getItems().contains("Kurzansicht"), "Profile not saved");
String standard =
profiles.getItems().stream()
.filter(it -> it.endsWith("STANDARD"))
.findFirst()
.orElseThrow();
profiles.getSelectionModel().select(standard);
return null;
});
await(
"Standard restores visible type", () -> visible(grid, "type") && !profiles.isDisabled());
fx(
() -> {
profiles.getSelectionModel().select("Kurzansicht");
return null;
});
await(
"Reapplied profile hides type",
() ->
!visible(grid, "type")
&& !profiles.isDisabled()
&& "Kurzansicht".equals(profiles.getEditor().getText()));
fx(
() -> {
image(root, dir.resolve("folder-profile.png"));
return null;
});
Files.writeString(
dir.resolve("result-folder-actions"),
"Archivbeleg → two hits; Wareneingang → Lieferbrief. Fundstelle and move verified for"
+ " zero, one, both keys "
+ keys
+ "; new search invalidated actions. Dismiss cleared search. Standard showed"
+ " Dateityp; Kurzansicht restored hidden Dateityp.");
}
private static void image(Node node, Path path) throws Exception {
var img = node.snapshot(null, null);
int w = (int) img.getWidth(), h = (int) img.getHeight();
var out = new java.awt.image.BufferedImage(w, h, java.awt.image.BufferedImage.TYPE_INT_ARGB);
int[] pixels = new int[w * h];
img.getPixelReader()
.getPixels(0, 0, w, h, javafx.scene.image.PixelFormat.getIntArgbInstance(), pixels, 0, w);
out.setRGB(0, 0, w, h, pixels, 0, w);
ImageIO.write(out, "png", path.toFile());
}
}
}
@@ -0,0 +1,171 @@
package qualification;
import static qualification.WorkflowProbe.*;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.LocalFileSystem;
import java.nio.file.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javafx.embed.swing.SwingFXUtils;
import javafx.scene.control.*;
import javafx.scene.image.ImageView;
import javax.imageio.ImageIO;
public final class FolderActionsWorkflowProbe extends FormWorkflowProbe {
@Override
void verify(Project project) throws Exception {
checkForm(project, true);
checkForm(project, false);
Files.writeString(output.resolve("SUCCESS.txt"), Files.readString(output.resolve("steps.txt")));
}
private void open(Project project, String name) throws Exception {
var path =
Path.of(project.getBasePath(), "src/main/resources/de/neitzel/archiver/ui", name + ".fxml");
file = edt(() -> LocalFileSystem.getInstance().refreshAndFindFileByNioFile(path));
pane = openDesigner(project, file);
fx(pane::flush).toCompletableFuture().get(10, TimeUnit.SECONDS);
}
private void save() throws Exception {
var text = source();
click(pane, "Save");
await(
() ->
Files.readString(Path.of(file.getPath()))
.lines()
.map(String::stripTrailing)
.toList()
.equals(text.lines().map(String::stripTrailing).toList()));
}
private void build(String id, String label) throws Exception {
click(pane, "Form preview");
click(pane, "Build and Refresh");
await(
() ->
fx(
() ->
((ComboBox<?>) pane.lookup("#preview-example"))
.getItems().stream().anyMatch(e -> e.toString().contains(id))));
choose("preview-example", id);
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(state);
return ((ImageView) pane.lookup("#full-preview-image")).getImage() != null
&& state.contains(label);
}));
}
private void reset(String prop, String attribute) throws Exception {
choose("form-property", prop);
click(pane, "Reset property");
await(() -> !source().contains(attribute));
}
private void checkForm(Project project, boolean details) throws Exception {
String name = details ? "DocumentDetails" : "FolderTab";
String control = details ? "AutoCompleteTextField #input" : "ToolBarPane #find";
String prop = details ? "onAction" : "onDismiss";
String handler = details ? "#addTag" : "#closeFind";
String id = details ? "details-invoice" : "folder-actions";
String label = details ? "Dokumentdetails · Rechnung" : "Archivordner · Suche und Anzeigeprofile";
open(project, name);
List<String> bindings =
source()
.lines()
.filter(s -> s.contains("<DirectBinding ") || s.contains("<CommandBinding "))
.toList();
controls(true);
choose("form-control", control);
if (details) {
reset("accessibleText", "accessibleText=\"Neuen Tag eingeben\"");
reset("prefColumnCount", "prefColumnCount=\"12\"");
set("accessibleText", "Belege verschlagworten", "accessibleText=\"Belege verschlagworten\"");
set("prefColumnCount", "23", "prefColumnCount=\"23\"");
String edited = source();
click(pane, "Undo");
await(() -> !source().contains("prefColumnCount=\"23\""));
click(pane, "Redo");
await(() -> source().equals(edited));
choose("form-property", "width");
if (fx(() -> ((TextArea) pane.lookup("#form-value")).isEditable()))
throw new AssertionError("Writable width");
}
reset(prop, prop + "=\"" + handler + "\"");
save();
step(name + " · reset " + prop + " and saved");
build(id, label);
controls(true);
choose("form-control", control);
choose("form-property", prop);
await(
() ->
fx(
() ->
((ComboBox<?>) pane.lookup("#form-event-handlers"))
.getItems()
.contains(handler)));
String before = source();
fx(
() -> {
((TextArea) pane.lookup("#form-value")).setText("#falscherHandler");
return null;
});
click(pane, "Set property");
var msg = fx(() -> ((Label) pane.lookup("#form-message")).getText());
if (!msg.contains("#falscherHandler")
|| !msg.contains("ActionEvent")
|| !before.equals(source())) throw new AssertionError(msg);
if (!details) screenshot("folder-events.png");
choose("form-event-handlers", handler);
click(pane, "Set property");
edited(before, prop + "=\"" + handler + "\"");
save();
edt(
() -> {
FileEditorManager.getInstance(project).closeFile(file);
return null;
});
open(project, name);
String saved = source();
if (!saved.contains(prop + "=\"" + handler + "\"")
|| !bindings.equals(
saved
.lines()
.filter(s -> s.contains("<DirectBinding ") || s.contains("<CommandBinding "))
.toList())) throw new AssertionError("Reopened declarations differ");
step(
name
+ " · rejected #falscherHandler, saved and reopened "
+ handler
+ " with "
+ bindings.size()
+ " unchanged bindings");
build(id, label);
if (!details) screenshot("intellij.png");
click(pane, "Interactive preview");
var result = details ? "result-detail-action" : "result-folder-actions";
awaitTarget(result);
step(Files.readString(output.resolve(result)));
click(pane, "Stop preview");
}
private void screenshot(String name) throws Exception {
fx(
() -> {
ImageIO.write(
SwingFXUtils.fromFXImage(pane.snapshot(null, null), null),
"png",
output.resolve(name).toFile());
return null;
});
}
}
@@ -22,7 +22,7 @@ public final class ImportWorkflowProbe extends FormWorkflowProbe {
target("protocol", "both", "protocol", "value", "COMPATIBLE"); target("protocol", "both", "protocol", "value", "COMPATIBLE");
target("security", "both", "security", "value", "COMPATIBLE"); target("security", "both", "security", "value", "COMPATIBLE");
open(project, "FolderTab", 1); open(project, "FolderTab", 2);
discover(); discover();
target("view", "both", "view", "value", "COMPATIBLE"); target("view", "both", "view", "value", "COMPATIBLE");
target("grouping", "both", "grouping", "value", "COMPATIBLE"); target("grouping", "both", "grouping", "value", "COMPATIBLE");
@@ -31,7 +31,7 @@ public final class ImportWorkflowProbe extends FormWorkflowProbe {
target("rows", "view", "clearLayout", "accessibleHelp", "INCOMPATIBLE"); target("rows", "view", "clearLayout", "accessibleHelp", "INCOMPATIBLE");
target("view", "both", "untypedPick", "value", "UNRESOLVED"); target("view", "both", "untypedPick", "value", "UNRESOLVED");
target("rows", "view", "grid", "items", "COMPATIBLE"); target("rows", "view", "grid", "items", "COMPATIBLE");
applyAndReopen(project, "FolderTab", 1, "grid", "items", "rows", "view"); applyAndReopen(project, "FolderTab", 2, "grid", "items", "rows", "view");
preview("archive-folder", "import-grid"); preview("archive-folder", "import-grid");
open(project, "ImportForm", 3); open(project, "ImportForm", 3);
+4 -3
View File
@@ -26,11 +26,12 @@ p.add_argument("--archiver", type=Path, help="Qualify ArchiveWindow.fxml in a di
forms = p.add_mutually_exclusive_group() forms = p.add_mutually_exclusive_group()
forms.add_argument("--connection-form", action="store_true", help="Qualify the Archiver connection form") forms.add_argument("--connection-form", action="store_true", help="Qualify the Archiver connection form")
forms.add_argument("--grid-docking", type=Path, metavar="REFERENCE_FXML", help="Qualify the Archiver grid, dock layout and the supplied reference workspace") forms.add_argument("--grid-docking", type=Path, metavar="REFERENCE_FXML", help="Qualify the Archiver grid, dock layout and the supplied reference workspace")
forms.add_argument("--folder-actions", action="store_true", help="Check visual event references, folder search, selection and display profiles")
forms.add_argument("--import-form", action="store_true", help="Check generic binding types and the Archiver import collision") forms.add_argument("--import-form", action="store_true", help="Check generic binding types and the Archiver import collision")
forms.add_argument("--document-tabs", action="store_true", help="Qualify the production Archiver HTML document tabs") forms.add_argument("--document-tabs", action="store_true", help="Qualify the production Archiver HTML document tabs")
forms.add_argument("--saved-document", action="store_true", help="Open the Archiver saved HTML and tag example") forms.add_argument("--saved-document", action="store_true", help="Open the Archiver saved HTML and tag example")
args = p.parse_args() args = p.parse_args()
if (args.connection_form or args.grid_docking or args.saved_document or args.document_tabs or args.import_form) and not args.archiver: if (args.connection_form or args.grid_docking or args.saved_document or args.document_tabs or args.import_form or args.folder_actions) and not args.archiver:
p.error("Selecting an Archiver view requires --archiver") p.error("Selecting an Archiver view requires --archiver")
if args.repeat < 1: if args.repeat < 1:
p.error("--repeat must be positive") p.error("--repeat must be positive")
@@ -42,7 +43,7 @@ modes = ("classpath",) if args.archiver else (("classpath", "modulepath") if arg
for run_number, mode in ((n, mode) for n in range(1, args.repeat + 1) for mode in modes): for run_number, mode in ((n, mode) for n in range(1, args.repeat + 1) for mode in modes):
crashes = NativeCrashGuard(ROOT) crashes = NativeCrashGuard(ROOT)
launch = subprocess.run([sys.executable, ROOT / "scripts/run-fixture-host.py", "intellij", launch = subprocess.run([sys.executable, ROOT / "scripts/run-fixture-host.py", "intellij",
"--check", *(["--import-form"] if args.import_form else []), *(["--document-tabs"] if args.document_tabs else []), *(["--saved-document"] if args.saved_document else []), *(["--grid-docking", str(args.grid_docking.resolve())] if args.grid_docking else []), *(["--connection-form"] if args.connection_form else []), *(["--archiver", str(args.archiver.resolve())] if args.archiver else []), "--mode", mode, "--java-home", args.java_home, "--check", *(["--folder-actions"] if args.folder_actions else []), *(["--import-form"] if args.import_form else []), *(["--document-tabs"] if args.document_tabs else []), *(["--saved-document"] if args.saved_document else []), *(["--grid-docking", str(args.grid_docking.resolve())] if args.grid_docking else []), *(["--connection-form"] if args.connection_form else []), *(["--archiver", str(args.archiver.resolve())] if args.archiver else []), "--mode", mode, "--java-home", args.java_home,
"--target-java-home", args.target_java_home, "--idea-home", args.idea_home], "--target-java-home", args.target_java_home, "--idea-home", args.idea_home],
cwd=ROOT, text=True, capture_output=True, timeout=60) cwd=ROOT, text=True, capture_output=True, timeout=60)
if launch.returncode: if launch.returncode:
@@ -86,7 +87,7 @@ for run_number, mode in ((n, mode) for n in range(1, args.repeat + 1) for mode i
shutil.copyfile(base / "intellij.png", output / (mode + ".png")) shutil.copyfile(base / "intellij.png", output / (mode + ".png"))
(evidence / "proof.json").write_text(json.dumps(proof, indent=2) + "\n") (evidence / "proof.json").write_text(json.dumps(proof, indent=2) + "\n")
finally: finally:
for name in ("details-invoice-tags.png", "details-delivery-tags.png", "details-invoice.png", "details-delivery.png", "details-readonly.png", "details-busy.png", "html-invoice.png", "html-delivery.png", "rechnung-zwei-tags.png", "import-collision.png", "import-accepted.png", "result-import-free", "result-import-busy", "result-import-collision", "result-import-grid", "SUCCESS.txt", "FAILURE.txt", "ui-state.txt", "launcher.log", "steps.txt", "target-error.txt", "preview-restored.png", "imap.png", "jmap.png", "invoice.png", "delivery.png", "saved-document-result", "saved-bindings.fxml", "binding-article.png", "binding-dynamic.png", "tags-Pr.png", "tags-Re.png", "tags-Li.png", "document-tabs-result", "rechnung-tab.png", "lieferschein-tab.png", "rechnung-tab-tags.png", "lieferschein-tab-tags.png", "folder.png", "right.png", "bottom.png", "result-folder", "result-right", "result-bottom", "intellij.png"): for name in ("folder-events.png", "folder-search.png", "folder-profile.png", "result-folder-actions", "result-detail-action", "details-invoice-tags.png", "details-delivery-tags.png", "details-invoice.png", "details-delivery.png", "details-readonly.png", "details-busy.png", "html-invoice.png", "html-delivery.png", "rechnung-zwei-tags.png", "import-collision.png", "import-accepted.png", "result-import-free", "result-import-busy", "result-import-collision", "result-import-grid", "SUCCESS.txt", "FAILURE.txt", "ui-state.txt", "launcher.log", "steps.txt", "target-error.txt", "preview-restored.png", "imap.png", "jmap.png", "invoice.png", "delivery.png", "saved-document-result", "saved-bindings.fxml", "binding-article.png", "binding-dynamic.png", "tags-Pr.png", "tags-Re.png", "tags-Li.png", "document-tabs-result", "rechnung-tab.png", "lieferschein-tab.png", "rechnung-tab-tags.png", "lieferschein-tab-tags.png", "folder.png", "right.png", "bottom.png", "result-folder", "result-right", "result-bottom", "intellij.png"):
if (base / name).exists(): if (base / name).exists():
shutil.copyfile(base / name, evidence / name) shutil.copyfile(base / name, evidence / name)
workers = descendant_workers(pid) workers = descendant_workers(pid)
+7 -2
View File
@@ -22,11 +22,12 @@ p.add_argument("--archiver", type=Path, help="Use a disposable copy of the Archi
forms = p.add_mutually_exclusive_group() forms = p.add_mutually_exclusive_group()
forms.add_argument("--connection-form", action="store_true", help="Open and qualify the Archiver connection form") forms.add_argument("--connection-form", action="store_true", help="Open and qualify the Archiver connection form")
forms.add_argument("--grid-docking", type=Path, metavar="REFERENCE_FXML", help="Qualify the Archiver grid, dock layout and the supplied reference workspace") forms.add_argument("--grid-docking", type=Path, metavar="REFERENCE_FXML", help="Qualify the Archiver grid, dock layout and the supplied reference workspace")
forms.add_argument("--folder-actions", action="store_true", help="Check visual event references, folder search, selection and display profiles")
forms.add_argument("--import-form", action="store_true", help="Check generic binding types and the Archiver import collision") forms.add_argument("--import-form", action="store_true", help="Check generic binding types and the Archiver import collision")
forms.add_argument("--document-tabs", action="store_true", help="Qualify the production Archiver HTML document tabs") forms.add_argument("--document-tabs", action="store_true", help="Qualify the production Archiver HTML document tabs")
forms.add_argument("--saved-document", action="store_true", help="Open the Archiver saved HTML and tag example") forms.add_argument("--saved-document", action="store_true", help="Open the Archiver saved HTML and tag example")
args = p.parse_args() args = p.parse_args()
if (args.connection_form or args.grid_docking or args.saved_document or args.document_tabs or args.import_form) and not args.archiver: if (args.connection_form or args.grid_docking or args.saved_document or args.document_tabs or args.import_form or args.folder_actions) and not args.archiver:
p.error("Selecting an Archiver view requires --archiver") p.error("Selecting an Archiver view requires --archiver")
base = Path(tempfile.mkdtemp(prefix="neitzel-designer-host-")).resolve() base = Path(tempfile.mkdtemp(prefix="neitzel-designer-host-")).resolve()
project = base / "project" project = base / "project"
@@ -37,6 +38,8 @@ if args.archiver:
subprocess.run([sys.executable, ROOT / "scripts/configure-library-example.py", "--project", project, subprocess.run([sys.executable, ROOT / "scripts/configure-library-example.py", "--project", project,
"--target-java-home", args.target_java_home], check=True) "--target-java-home", args.target_java_home], check=True)
view = "ConnectionForm" if args.connection_form else "ArchiveWindow" view = "ConnectionForm" if args.connection_form else "ArchiveWindow"
if args.folder_actions:
view = "DocumentDetails" if args.check else "FolderTab"
if args.document_tabs and args.check: if args.document_tabs and args.check:
view = "DocumentTag" view = "DocumentTag"
if args.grid_docking: if args.grid_docking:
@@ -100,6 +103,8 @@ else:
suite = "Connection" suite = "Connection"
elif args.grid_docking: elif args.grid_docking:
suite = "GridDock" suite = "GridDock"
elif args.folder_actions:
suite = "FolderActions"
elif args.import_form: elif args.import_form:
suite = "Import" suite = "Import"
elif args.document_tabs: elif args.document_tabs:
@@ -108,7 +113,7 @@ else:
suite = "SavedDocument" suite = "SavedDocument"
probe = f"{suite}WorkflowProbe" if args.archiver else "WorkflowProbe" probe = f"{suite}WorkflowProbe" if args.archiver else "WorkflowProbe"
files = [sources / "WorkflowProbe.java"] files = [sources / "WorkflowProbe.java"]
if args.connection_form or args.saved_document or args.document_tabs or args.import_form: if args.connection_form or args.saved_document or args.document_tabs or args.import_form or args.folder_actions:
files.append(sources / "FormWorkflowProbe.java") files.append(sources / "FormWorkflowProbe.java")
if args.archiver: if args.archiver:
files.append(sources / f"{probe}.java") files.append(sources / f"{probe}.java")