Merge literal DataGrid group label keys
This commit is contained in:
@@ -710,3 +710,8 @@ The reference above covers the FXML declarations and their behavior. These are t
|
|||||||
`property(name)` returns `Property<?>`: cast to the known property type when writing from Java, for example `((StringProperty) loaded.property("name")).set("Grace")`. Generated accessors avoid these casts. `storedProperty` is for subclasses and reads only stored Model Attributes; it does not invoke custom reflective accessors. Internal loaders, appliers and identity-cache helpers are implementation details, not extension APIs.
|
`property(name)` returns `Property<?>`: cast to the known property type when writing from Java, for example `((StringProperty) loaded.property("name")).set("Grace")`. Generated accessors avoid these casts. `storedProperty` is for subclasses and reads only stored Model Attributes; it does not invoke custom reflective accessors. Internal loaders, appliers and identity-cache helpers are implementation details, not extension APIs.
|
||||||
|
|
||||||
For threading, strong identity retention, context reuse, the absence of a general disposal API, and JPMS reflection, see [architecture and lifetime](docs/architecture.md). For an independent application POM and runnable files, use the [complete quick start](docs/quick-start.md).
|
For threading, strong identity retention, context reuse, the absence of a general disposal API, and JPMS reflection, see [architecture and lifetime](docs/architecture.md). For an independent application POM and runnable files, use the [complete quick start](docs/quick-start.md).
|
||||||
|
|
||||||
|
DataGrid columns accept arbitrary string keys for group captions through the attached
|
||||||
|
`DataGridColumn.groupLabel` property. For example,
|
||||||
|
`<DataGridColumn.groupLabel><javafx.util.Pair key="Post/Eingang West" value="Eingang"/></DataGridColumn.groupLabel>`
|
||||||
|
writes the literal key into the same map as `<groupLabels Post="Postfach"/>`.
|
||||||
|
|||||||
@@ -21,6 +21,12 @@ public final class DataGridColumn {
|
|||||||
@Setter(lombok.AccessLevel.NONE)
|
@Setter(lombok.AccessLevel.NONE)
|
||||||
private final java.util.Map<String, String> groupLabels = new java.util.LinkedHashMap<>();
|
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 width = 150;
|
||||||
private double minimumWidth = 80;
|
private double minimumWidth = 80;
|
||||||
private double maximumWidth = 1200;
|
private double maximumWidth = 1200;
|
||||||
|
|||||||
@@ -55,6 +55,22 @@ class DataGridFxmlTest {
|
|||||||
</DataGrid>
|
</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
|
@Test
|
||||||
void loadsReusableTagAndCompletionControls() throws Exception {
|
void loadsReusableTagAndCompletionControls() throws Exception {
|
||||||
DataGridTest.fx(() -> {
|
DataGridTest.fx(() -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user