Edit docking group constraints and qualify document tab behavior in IntelliJ

This commit is contained in:
2026-11-25 09:55:35 +01:00
parent dc3dd6b6be
commit 92e852e936
11 changed files with 671 additions and 156 deletions
@@ -2,21 +2,15 @@ package qualification;
import static qualification.WorkflowProbe.*;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.LocalFileSystem;
import de.neitzel.fxdesigner.workflow.DesignerWorkflow.Example;
import java.nio.file.*;
import java.util.*;
import javafx.embed.swing.SwingFXUtils;
import javafx.scene.control.*;
import javafx.scene.image.ImageView;
import javax.imageio.ImageIO;
import org.w3c.dom.Element;
/** Edits original Archiver forms in the registered IntelliJ designer. */
public final class MediaLayoutGridWorkflowProbe extends FormWorkflowProbe {
private Project project;
public final class MediaLayoutGridWorkflowProbe extends DeclarationWorkflowProbe {
void verify(Project project) throws Exception {
this.project = project;
@@ -141,8 +135,8 @@ public final class MediaLayoutGridWorkflowProbe extends FormWorkflowProbe {
inspector(true);
var original = declarations();
select("DataGrid", "grid");
gridSet("setupId", "archiver-pruefung");
gridSet("setupVersion", "2");
applySetting("setupId", "archiver-pruefung");
applySetting("setupVersion", "2");
for (var pair :
List.of(List.of("setupId", "archiver-pruefung"), List.of("setupVersion", "2"))) {
String before = source();
@@ -157,9 +151,9 @@ public final class MediaLayoutGridWorkflowProbe extends FormWorkflowProbe {
click(pane, "Undo");
await(() -> source().equals(before));
}
gridSet("groupBy", "folder");
applySetting("groupBy", "folder");
select("DataGridColumn", "folder");
gridSet("fixedPosition", "1");
applySetting("fixedPosition", "1");
combo("declaration-property", "groupLabels");
fx(
() -> {
@@ -195,142 +189,4 @@ public final class MediaLayoutGridWorkflowProbe extends FormWorkflowProbe {
build("archive-folder");
interactive("archive-folder", "grid");
}
private void open(String name) throws Exception {
var path =
Path.of(project.getBasePath(), "src/main/resources/de/neitzel/archiver/ui", name + ".fxml");
file = edt(() -> LocalFileSystem.getInstance().refreshAndFindFileByNioFile(path));
pane = openDesigner(project, file);
if (!source().contains("<?neitzel-model de.neitzel.archiver.ui."))
throw new AssertionError(name);
}
private void build(String id) throws Exception {
click(pane, "Form preview");
click(pane, "Build and Refresh");
await(
() ->
fx(
() ->
((ComboBox<?>) pane.lookup("#preview-example"))
.getItems().stream().anyMatch(item -> item.toString().contains(id))));
}
private void interactive(String id, String attempt) throws Exception {
choose("preview-example", id);
await(
() ->
fx(
() -> {
var state = ((Label) pane.lookup("#preview-state")).getText();
if (state.startsWith("Preview failed")
|| state.startsWith("Preview blocked")
|| state.startsWith("Preview unavailable"))
throw new AssertionError(id + " · " + state);
var choice = (Example) ((ComboBox<?>) pane.lookup("#preview-example")).getValue();
return ((ImageView) pane.lookup("#full-preview-image")).getImage() != null
&& state.contains(choice.label());
}));
Files.writeString(output.resolve("layout-case"), attempt);
click(pane, "Interactive preview");
String name = "result-" + attempt;
awaitTarget(name);
step(id + " · " + Files.readString(output.resolve(name)));
click(pane, "Stop preview");
}
private void reopen(String form, String saved) throws Exception {
click(pane, "Save");
await(() -> Files.readString(Path.of(file.getPath())).contains(saved));
edt(
() -> {
FileEditorManager.getInstance(project).closeFile(file);
return null;
});
open(form);
if (!source().contains(saved)) throw new AssertionError("Reopened " + form);
}
private void inspector(boolean expanded) throws Exception {
fx(
() -> {
var panel =
(TitledPane)
pane.lookupAll(".titled-pane").stream()
.filter(n -> n instanceof TitledPane t && t.getText().equals("Bindings"))
.findFirst()
.orElseThrow();
panel.setAnimated(false);
panel.setExpanded(expanded);
var tabs = (TabPane) panel.getContent();
tabs.getSelectionModel()
.select(
tabs.getTabs().stream()
.filter(t -> t.getText().equals("DataGrid / Docking"))
.findFirst()
.orElseThrow());
pane.applyCss();
pane.layout();
return null;
});
}
private void select(String name, String id) throws Exception {
fx(
() -> {
var tree = (TreeView<Element>) pane.lookup("#declaration-tree");
for (int i = 0; i < tree.getExpandedItemCount(); i++) {
var item = tree.getTreeItem(i);
var e = item.getValue();
String tag = e.getTagName();
if ((tag.equals(name) || tag.endsWith("." + name))
&& (id.isEmpty()
|| e.getAttribute("fx:id").equals(id)
|| e.getAttribute("id").equals(id)
|| e.getAttribute("destinationId").equals(id))) {
tree.getSelectionModel().select(item);
return null;
}
}
throw new AssertionError("Missing " + name + " " + id);
});
}
private void combo(String name, String text) throws Exception {
fx(
() -> {
var box = (ComboBox<String>) pane.lookup("#" + name);
box.setValue(text);
return null;
});
}
private void edit(String button, String expected) throws Exception {
String before = source();
click(pane, button);
await(
() -> {
String now = source();
var msg = fx(() -> ((Label) pane.lookup("#declaration-message")).getText());
if (!msg.isEmpty()) throw new AssertionError(msg);
return !now.equals(before)
&& now.contains(expected)
&& fx(
() ->
((TextArea) pane.lookup("#fxml-source")) == null
|| ((TextArea) pane.lookup("#fxml-source")).getText().equals(now));
});
fx(pane::flush).toCompletableFuture().get();
step(button + " · " + expected);
}
private void gridSet(String field, String value) throws Exception {
combo("declaration-property", field);
fx(
() -> {
((ComboBox<?>) pane.lookup("#declaration-value")).getEditor().setText(value);
return null;
});
edit("Apply setting", field + "=\"" + value + "\"");
}
}