Accept literal group keys in DataGrid column FXML

This commit is contained in:
2026-11-25 13:30:55 +01:00
parent 9522ed90ce
commit 2625616b2f
3 changed files with 27 additions and 0 deletions
@@ -21,6 +21,12 @@ public final class DataGridColumn {
@Setter(lombok.AccessLevel.NONE)
private final java.util.Map<String, String> groupLabels = new java.util.LinkedHashMap<>();
/** Adds one FXML group label whose key can contain spaces, paths or other non-name characters. */
public static void setGroupLabel(DataGridColumn column, javafx.util.Pair<String, String> entry) {
column.groupLabels.put(java.util.Objects.requireNonNull(entry.getKey(), "group key"),
java.util.Objects.requireNonNull(entry.getValue(), "group label"));
}
private double width = 150;
private double minimumWidth = 80;
private double maximumWidth = 1200;
@@ -55,6 +55,22 @@ class DataGridFxmlTest {
</DataGrid>
""";
@Test
void groupLabelEntriesRetainLiteralKeysAlongsideMapAttributes() throws IOException {
String xml = """
<?import de.neitzel.fx.view.DataGridColumn?>
<DataGridColumn>
<groupLabels Post="Postfach"/>
<DataGridColumn.groupLabel><javafx.util.Pair key="/" value="Wurzel"/></DataGridColumn.groupLabel>
<DataGridColumn.groupLabel><javafx.util.Pair key="Post/Eingang" value="Eingang"/></DataGridColumn.groupLabel>
<DataGridColumn.groupLabel><javafx.util.Pair key="Ohne Endung" value="Sonstige"/></DataGridColumn.groupLabel>
</DataGridColumn>
""";
DataGridColumn column = new FXMLLoader().load(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)));
assertEquals(Map.of("Post", "Postfach", "/", "Wurzel", "Post/Eingang", "Eingang", "Ohne Endung", "Sonstige"),
column.getGroupLabels());
}
@Test
void loadsReusableTagAndCompletionControls() throws Exception {
DataGridTest.fx(() -> {