Edit popup menu commands and literal DataGrid group keys

This commit is contained in:
2026-11-25 13:52:30 +01:00
parent 9c63b2dd0f
commit d99e2e69cd
14 changed files with 581 additions and 30 deletions
@@ -76,6 +76,47 @@ class GridDockDocumentTest {
assertThrows(IllegalArgumentException.class, () -> doc.set(col, "fixedPosition", "2"));
}
@Test
void pathLabelsRoundTripWithoutChangingNeighbouringMapEntries() throws Exception {
String source =
"""
<?import de.neitzel.fx.view.*?>
<DataGridColumn><groupLabels Post='Alt' another="%reference"/><!-- keep --></DataGridColumn>
""";
for (String key : java.util.List.of("/", "Post/Eingang West", "Ohne Endung", "$path & more")) {
var doc = new GridDockDocument(source);
String edited =
doc.xml.source.apply(doc.groupLabel(doc.xml.elements.getFirst(), key, "%T & T", false));
var changed = new GridDockDocument(edited);
var col = changed.xml.elements.getFirst();
assertEquals("%T & T", changed.groupLabels(col).get(key));
assertTrue(edited.contains("<groupLabels Post='Alt' another=\"%reference\"/><!-- keep -->"));
String removed = changed.xml.source.apply(changed.groupLabel(col, key, "", true));
var restored = new GridDockDocument(removed);
assertEquals(
java.util.Map.of("Post", "Alt"), restored.groupLabels(restored.xml.elements.getFirst()));
assertTrue(removed.contains("<groupLabels Post='Alt' another=\"%reference\"/><!-- keep -->"));
}
}
@Test
void deletingAPairPreservesSiblingsAndReferences() throws Exception {
String source =
"""
<?import de.neitzel.fx.view.*?>
<DataGridColumn><DataGridColumn.groupLabel><!-- keep -->
<javafx.util.Pair key="/" value="Archiv"/><javafx.util.Pair key="Post/Eingang" value="%title"/>
</DataGridColumn.groupLabel></DataGridColumn>
""";
var doc = new GridDockDocument(source);
var col = doc.xml.elements.getFirst();
assertEquals(
source.replace("<javafx.util.Pair key=\"/\" value=\"Archiv\"/>", ""),
doc.xml.source.apply(doc.groupLabel(col, "/", "", true)));
assertThrows(
IllegalArgumentException.class, () -> doc.groupLabel(col, "Post/Eingang", "", true));
}
@Test
void implicitRowAttributeAndGroupingSurviveRename() throws Exception {
var source =