Release NeitzelLib 1.0.2 with saved HTML viewing and row selection

Supply default selection colors through the row container’s user-agent stylesheet so JavaFX can style large result sets within the existing materialization test timeout.
This commit is contained in:
2026-11-22 20:11:22 +01:00
parent 32f8d28159
commit b2e0724611
36 changed files with 1287 additions and 49 deletions
+4 -1
View File
@@ -30,7 +30,10 @@ Use `de.neitzel.grid` for shared models/source types and `de.neitzel.fx.view` fo
- Header clicks alternate ascending/descending sort for that mapped column; `setSort(null)` clears user sorting. Sorting/filter/page-size changes request the first page (All remains All with fresh consent checks).
- `setFilters`, `setSort`, `setPageRequest`, `setSource`, `load`, `refresh`, and `retry` delegate to the coordinator; returned rows are never locally filtered again.
- `stateProperty` exposes requested versus displayed query, result, phase and error. Loading/failed rows stay visible but disabled; selected loaded data becomes unavailable while those rows are stale. Query/navigation controls remain usable.
- `selectedKeyProperty` retains an off-page identity. `selectedElementProperty` exposes only current displayed selected data. A successfully replaced source clears selection. `confirmedDeleted(key)` clears that key and refreshes; absence from a page alone does not imply deletion.
- `selectionMode` is configurable in Java or FXML: `NONE`, `SINGLE` (default), or `MULTIPLE`, using `RowSelectionMode`. Changing to NONE clears selection; changing to SINGLE keeps the lead key. Selection mode is application configuration and is not persisted in saved setups.
- `selectedKeysProperty` is a read-only observable list retaining off-page identities. `selectedElementsProperty` contains selected models only while their rows are visible and interactive. `selectedKeyProperty` / `selectedElementProperty` expose the lead key/model for compatibility. Single-item actions should require exactly one selected key and one loaded element.
- `select(key)` replaces selection (`null` clears); `selectKeys(keys)` replaces a multiple selection, with the last key as lead. Click replaces, Ctrl/Cmd-click toggles, Shift-click selects a range in visible grouped order, Ctrl/Cmd-Shift-click adds a range. Arrow/Home/End keys move through visible rows; Shift extends, Ctrl/Cmd moves focus, Space selects, Ctrl/Cmd-Space toggles, Ctrl/Cmd-A selects visible rows, Escape clears. Embedded editors keep their own keys. Rows have default selection colors even without an application theme.
- A successfully replaced source clears all selection. `confirmedDeleted(key)` removes only that key and refreshes; absence from a page alone does not imply deletion. Collapsed groups retain their keys but expose no actionable elements for hidden rows.
- Empty results disable navigation. Unknown totals are displayed as unknown and disable Last. A disappeared page receives one bounded correction; subsequent invalidation becomes an error with Retry.
## Guards, warnings and supersession
+2 -1
View File
@@ -6,10 +6,11 @@ context. The optional `ViewLoader` applies NeitzelLib binding declarations.
| Control | FXML configuration | Data and lifetime |
| --- | --- | --- |
| `de.neitzel.fx.view.DataGrid` | Columns, typed attributes, widths, filters, grouping, page size and setup identity | Bind `items` or `source`; explicitly load after configuration, close with the view |
| `de.neitzel.fx.view.DataGrid` | Columns, typed attributes, widths, filters, grouping, page size, `selectionMode` and setup identity | Bind `items` or `source`; explicitly load after configuration, close with the view |
| `de.neitzel.fx.view.Table` | `collection`, `row`, `Column` declarations | Existing ViewLoader collection/Component rows and `selection` binding |
| `de.neitzel.fx.control.StatusBar` | `leftItems`, `rightItems` containing ordinary Nodes | Bind the properties of the contained controls |
| `de.neitzel.fx.control.AutoCompleteTextField` | Standard TextField attributes and a `suggestions` list of strings | Type a prefix, use arrow keys and Enter or select with the mouse. Selecting emits the normal text-field action |
| `de.neitzel.fx.control.HtmlViewer` | `mediaButtonVisible`, `mediaLoadText`, `mediaReloadText`, `mediaTooltipText`, `noExternalMediaText` | Explicit `load` / `loadHtml` / `display`; call `close()` when disposed. See [HTML viewer](html-viewer.md) |
| `de.neitzel.fx.control.TagChip` | `text`, `removable` (false by default), `onRemove` | The action handler owns removing the tag from its model |
| `de.neitzel.fx.docking.DockPane` | `initialLayout`, `DockLayout`, group/split definitions | Attach a DockingManager to open application-owned content |
| `de.neitzel.fx.control.NonNegativeIntegerSpinner` | `minimum`, `maximum`, `initialValue` constructor attributes | Bind writable `number`, which shares the value factory's property |
+80
View File
@@ -0,0 +1,80 @@
# Saved HTML viewer
`de.neitzel.fx.control.HtmlViewer` displays local HTML and SingleFile exports.
It preserves saved CSS, classes, inline styles, embedded fonts and background
images. SVGs are rendered as isolated images; embedded WebP is converted to PNG
in memory for WebView. Files are never rewritten. The control needs ordinary
JavaFX only, with no MVVM or injection initialization.
```java
// In Application.start(Stage stage):
var viewer = new HtmlViewer();
stage.setScene(new Scene(viewer, 900, 600));
stage.setOnHidden(event -> viewer.close());
stage.show();
viewer.load(Path.of("saved-page.html"));
```
`load(Path)` and `loadHtml(String)` prepare content on an owned virtual thread.
`loadHtml(String, URI)` additionally accepts an HTTP(S) source address for relative
images. It never fetches that address. A saved `<base href>` takes precedence.
Input is limited to 32 MiB (UTF-8 bytes for strings). File loads detect the saved encoding.
WebP conversion is bounded to 16 megapixels per image and a 64 MiB encoded-image
budget per preparation. Invalid or oversized images keep their original data.
For applications that already prepare documents in the background, use
`HtmlDocument.read(Path)` or `HtmlDocument.parse(String[, URI])` off the FX thread,
then `viewer.display(document)` on the FX thread. A prepared document is immutable
and may be shared between viewers; permissions are never shared with it.
All viewer operations and property access belong on the FX thread.
`loadingProperty()` covers preparation and browser loading; `errorProperty()`
reports the current preparation/rendering failure. A progress indicator and error
message are included. New loads cancel pending work and discard stale results.
`clear()` releases the current content and leaves the viewer reusable. `close()`
also cancels pending work, is idempotent, and makes future loads fail.
## External images
Each displayed document starts offline. The included **Load external media**
button calls `loadExternalImages()`, which explicitly allows HTTP(S) images only
for that viewer and document. The same permission covers CSS background images.
`externalImagesAvailableProperty()` indicates detected external image addresses;
`externalImagesAllowedProperty()` reports whether permission was granted.
Loading or displaying another document, clearing, or closing revokes permission.
No permission is stored in configuration or in the source file.
JavaScript, embedded webpages, external stylesheets, external fonts and navigation
remain disabled. Embedded SVG is rendered in
[SVG secure image mode](https://www.w3.org/TR/SVG/latest/conform.html), rather than
as active SVG markup. The document CSP is also applied to saved CSS that the CSS
parser does not understand. This is a saved-document viewer; pages that require
JavaScript or missing source images cannot be reconstructed.
Set `mediaButtonVisible=false` if the application supplies its own action.
Bind that action to availability/loading and call `loadExternalImages()` on click.
Applications still own document tabs, archive paths, metadata, search text, and
opening files in external applications.
## FXML and translations
Construction performs no file or network I/O. Ordinary `FXMLLoader` can create
an idle viewer; the controller explicitly loads its document afterward.
```xml
<?import de.neitzel.fx.control.HtmlViewer?>
<HtmlViewer xmlns:fx="http://javafx.com/fxml/1" fx:id="article"
mediaButtonVisible="true"
mediaLoadText="Externe Medien laden"
mediaReloadText="Externe Medien erneut laden"
mediaTooltipText="Lädt Bilder nur für diese Ansicht und kontaktiert deren Server."
noExternalMediaText="Keine auflösbaren externen Bildadressen gefunden."/>
```
The four text attributes also expose writable StringProperties for ordinary
binding or live `Messages.observable(...)` translations. Style classes are
`html-viewer` on the root and `html-viewer-media-load` on its action button.
The tests cover SVG/CSS/WebP rendering through WebView snapshot pixels, offline
opening, per-viewer grants, replacement/close, loopback network requests, error
handling, and ordinary FXML loading. They require a graphical JavaFX session.
+5 -5
View File
@@ -1,19 +1,19 @@
# Your first JavaFX application
This walkthrough creates a complete Maven project with one editable name and a label that follows it. It uses Java 25, JavaFX 27.0.1 and NeitzelLib 1.0.1. The source build below uses the matching release tag.
This walkthrough creates a complete Maven project with one editable name and a label that follows it. It uses Java 25, JavaFX 27.0.1 and NeitzelLib 1.0.2. The source build below uses the matching release tag.
## Prepare the library
Install a JDK 25. Use the library's Maven wrapper (3.9.11), or a separate Maven installation version 3.9.11 or newer. Check `java -version` and `./mvnw -version` before building; on macOS, select the JDK with `export JAVA_HOME=$(/usr/libexec/java_home -v 25)` if necessary.
```bash
git clone --branch v1.0.1 https://gitea.neitzel.de/konrad/NeitzelLib.git
git clone --branch v1.0.2 https://gitea.neitzel.de/konrad/NeitzelLib.git
cd NeitzelLib
./mvnw -pl fx-example -am install
./mvnw -f fx-example/pom.xml javafx:run
```
The `install` command installs the parent POM, `core`, `injection` and `fx` into your local Maven repository and builds the example. Surefire fails the build when a test fails. The XML reports show which tests ran. The `javafx:run` command opens the [person desk example](../../fx-example/README.md). Run `javafx:run` only on the example POM, not with `-am`: the reactor parent is not a JavaFX application.
The `install` command installs the parent POM, `core`, `data-grid`, `injection` and `fx` into your local Maven repository and builds the example. Surefire fails the build when a test fails. The XML reports show which tests ran. The `javafx:run` command opens the [person desk example](../../fx-example/README.md). Run `javafx:run` only on the example POM, not with `-am`: the reactor parent is not a JavaFX application.
Check test results after the build (requires Python 3):
@@ -66,7 +66,7 @@ hello-fx/
<dependency>
<groupId>de.neitzel.lib</groupId>
<artifactId>fx</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
@@ -190,7 +190,7 @@ For a named-module application, see the [module and lifecycle notes](architectur
| Symptom | Check |
| --- | --- |
| Maven cannot resolve `de.neitzel.lib:fx:1.0.1` or its parent | Install the library reactor first; use the same Maven local repository for both projects. For direct downloads, see the [Maven repository setup](../../README.md#use-a-release-from-maven). |
| Maven cannot resolve `de.neitzel.lib:fx:1.0.2` or its parent | Install the library reactor first; use the same Maven local repository for both projects. For direct downloads, see the [Maven repository setup](../../README.md#use-a-release-from-maven). |
| `No plugin found for prefix 'javafx'` | Invoke the example POM directly, or use the complete application POM above. Do not invoke the goal on the library reactor parent. |
| JavaFX runtime/native library failure | Check the JDK version, architecture and JavaFX dependencies actually resolved; avoid mixing native artifacts from different platforms or JavaFX versions. |
| `getResource(...)` returns null | The FXML belongs under `src/main/resources` in the matching package; verify it was copied to `target/classes`. Resource names are case-sensitive. |
+1 -1
View File
@@ -21,7 +21,7 @@ The renderer preserves supplied row order and does no local filtering, sorting,
`setColumnOrder` validates complete stable-ID membership and fixed positions before updating headers and fields. `setColumnWidth` accepts default/explicit intent; it returns the clamped applied width so the coordinator can report adjustments. Row roots must have zero padding (put padding inside mapped fields). Rows use zero inter-field spacing to align with result headers; action controls keep their intrinsic size. The result integration now also supplies native resize/reorder and grouping support
when composed by DataGrid; the stable programmatic operations remain available. Header requests can be delegated through `setOnSortRequest`; the renderer never sorts locally.
`select(key)` retains an off-page key; the read-only loaded selected element becomes null until that key returns. Row clicks and blank-body clicks update this separate result selection. The old `Table.selectionProperty()` remains the legacy path and is not the result-mode selection API.
`setSelectionMode(RowSelectionMode.NONE/SINGLE/MULTIPLE)` configures selection (default SINGLE). `select(key)` replaces selection; `selectKeys(keys)` supports multiple identities, including off-page keys. `selectedKeysProperty()` and `selectedElementsProperty()` expose unmodifiable observable lists; loaded elements include only visible interactive rows. The singular properties expose the lead. `deselect(key)` removes one identity. See [DataGrid selection](data-grid.md) for mouse and keyboard gestures. Row clicks and blank-body clicks update this separate result selection. The old `Table.selectionProperty()` remains the legacy path and is not the result-mode selection API.
`close()` is idempotent, removes rows/handlers and disposes row resources. Disposal failures do not undo an already published page; observe `disposalFailureProperty()` to surface them. Explicit close is necessary; attaching/removing a Table from a Scene does not infer application ownership.