Edit popup menu commands and literal DataGrid group keys
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
package qualification;
|
||||
|
||||
import static qualification.WorkflowProbe.*;
|
||||
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
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;
|
||||
|
||||
/** Edit the production menu templates, then invoke them through their owning views. */
|
||||
public final class RowMenusWorkflowProbe extends DeclarationWorkflowProbe {
|
||||
@Override
|
||||
void verify(Project project) throws Exception {
|
||||
this.project = project;
|
||||
open("FolderTab");
|
||||
build("folder-actions");
|
||||
interactive("folder-actions", "original");
|
||||
// Reopen the owning form from disk after saving the external menu templates.
|
||||
edt(
|
||||
() -> {
|
||||
FileEditorManager.getInstance(project).closeFile(file);
|
||||
return null;
|
||||
});
|
||||
menu("FolderRowMenu", "open", "open", "openExternal", "Extern prüfen", 6);
|
||||
menu("TrashRowMenu", "delete", "deleteSelection", "restoreSelection", "Auswahl zurückholen", 3);
|
||||
menu("TrashFileMenu", "open", "open", "open", "Diese Datei öffnen", 1);
|
||||
open("TrashPane");
|
||||
build("trash-full");
|
||||
interactive("trash-full", "trash");
|
||||
open("FolderTab");
|
||||
build("folder-actions");
|
||||
interactive("folder-actions", "edited");
|
||||
inspector(true);
|
||||
select("DataGrid", "grid");
|
||||
applySetting("groupBy", "folder");
|
||||
for (var entry :
|
||||
List.of(
|
||||
List.of("folder", "Post", "Postfach"),
|
||||
List.of("folder", "/", "Archivwurzel"),
|
||||
List.of("folder", "Post/Eingang", "Eingangspost"),
|
||||
List.of("folder", "Post/Eingang West", "Westpost"),
|
||||
List.of("type", "Ohne Endung", "Endungslose Dateien"))) {
|
||||
select("DataGridColumn", entry.get(0));
|
||||
combo("declaration-property", "groupLabels");
|
||||
fx(
|
||||
() -> {
|
||||
((ComboBox<?>) pane.lookup("#group-label-key")).getEditor().setText(entry.get(1));
|
||||
((TextField) pane.lookup("#group-label-text")).setText(entry.get(2));
|
||||
return null;
|
||||
});
|
||||
edit("Set group label", entry.get(2));
|
||||
}
|
||||
reopen("FolderTab", "Endungslose Dateien");
|
||||
for (var entry :
|
||||
List.of(
|
||||
List.of("folder", "/"),
|
||||
List.of("folder", "Post/Eingang"),
|
||||
List.of("folder", "Post/Eingang West"),
|
||||
List.of("type", "Ohne Endung"))) {
|
||||
inspector(true);
|
||||
select("DataGridColumn", entry.getFirst());
|
||||
combo("declaration-property", "groupLabels");
|
||||
choose("group-label-key", entry.getLast());
|
||||
String before = source();
|
||||
click(pane, "Remove group label");
|
||||
await(() -> !source().contains("key=\"" + entry.getLast() + "\""));
|
||||
click(pane, "Undo");
|
||||
await(() -> source().equals(before));
|
||||
fx(pane::flush).toCompletableFuture().get();
|
||||
step("Reopened, removed and restored literal key [" + entry.getLast() + "]");
|
||||
}
|
||||
build("folder-groups");
|
||||
interactive("folder-groups", "groups");
|
||||
Files.writeString(output.resolve("SUCCESS.txt"), Files.readString(output.resolve("steps.txt")));
|
||||
}
|
||||
|
||||
private void menu(
|
||||
String name, String control, String oldPath, String path, String label, int count)
|
||||
throws Exception {
|
||||
open(name);
|
||||
click(pane, "Form preview");
|
||||
click(pane, "Build and Refresh");
|
||||
await(
|
||||
() ->
|
||||
fx(
|
||||
() ->
|
||||
pane.lookupAll(".label").stream()
|
||||
.anyMatch(n -> n instanceof Label l && "0 examples".equals(l.getText()))
|
||||
|| ((Label) pane.lookup("#preview-state"))
|
||||
.getText()
|
||||
.startsWith("Select a preview example")));
|
||||
commands(control, oldPath, count);
|
||||
click(pane, "Discover / Validate Commands");
|
||||
await(
|
||||
() ->
|
||||
fx(
|
||||
() ->
|
||||
((Label) pane.lookup("#command-status"))
|
||||
.getText()
|
||||
.contains("No detected binding errors.")));
|
||||
if (!path.equals(oldPath)) {
|
||||
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)
|
||||
.findFirst()
|
||||
.orElseThrow();
|
||||
if (!choices.getItems().contains(path)) throw new AssertionError(choices.getItems());
|
||||
choices.getSelectionModel().select(path);
|
||||
return null;
|
||||
});
|
||||
click(pane, "Apply Command binding");
|
||||
await(() -> source().contains("control=\"" + control + "\" path=\"" + path + "\""));
|
||||
}
|
||||
controls(true);
|
||||
choose("form-control", "MenuItem #" + control);
|
||||
set("text", label, "text=\"" + label + "\"");
|
||||
reopen(name, "text=\"" + label + "\"");
|
||||
commands(control, path, count);
|
||||
if (name.equals("TrashRowMenu"))
|
||||
fx(
|
||||
() -> {
|
||||
ImageIO.write(
|
||||
SwingFXUtils.fromFXImage(pane.snapshot(null, null), null),
|
||||
"png",
|
||||
output.resolve("intellij.png").toFile());
|
||||
return null;
|
||||
});
|
||||
step(name + " reopened: " + label + " → " + path);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user