You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit eccf33e
Browse filesBrowse the repository at this point in the historyBrowse files
scijava-settings: one TOML file a person can read and edit
Settings live at ~/.config/<app>/settings.toml on every platform,
honoring XDG_CONFIG_HOME, overridable by a system property. Not what
each platform would prefer, and deliberately: what was wrong with
java.util.prefs was that the store was *opaque*, and the cure for that
is one answer to "where is it?" rather than three correct ones. Appose
made the same choice.
`Settings` is an object, not a singleton and not a service. Settings
belong to an application, and two applications sharing a JVM want two of
them. That is the line this codebase had been drawing without saying it:
static facades for stateless capabilities -- Converters, Locations,
Scripts, since converting a string to an int does not depend on which
application you are -- and scoped objects for anything with identity or
lifetime. A static settings store would have quietly spent the
multiple-contexts promise, and then the honest question would be why
there is a container at all.
A table per command, keyed by its identifier rather than by its
component's coordinates: a class moving between artifacts would
otherwise lose what the user chose, which is a refactor nobody should be
punished for. Values map onto TOML's own types by a small hardcoded
table with string as the fallback, so a List<File> is an array of
strings rather than one mangled string, and reading converts
element-wise through convert3. Widgets need no serialization API for
this: serialization is a property of the type, and a widget is a view --
which is also why it needs no answer per toolkit.
Comments survive a save. The file is one people edit, and a store that
ate the "# 0.7 because the detector is noisy" beside a value is one they
would stop editing.
The TOML is parsed here: tables, all four string forms, integers in four
bases, floats, booleans, all four date-and-time types, arrays -- with
inline tables and arrays of tables refused by line number rather than
misunderstood. Neither candidate library is modular, and an automatic
module in a foundation component is the trade that dropped MigLayout;
the API is small enough that tomlj can take its place later.
Persistence is LoadInputs and SaveInputs, both preprocessors, so a
caller can run a command without persistence interfering. Saving before
the run rather than after is Curtis's call and a good one: saving
afterwards loses the values whenever the run threw, which is exactly
when the user is about to try again. There is a test that fails under
the other design.
Two things fell out below it:
- Execution.isSupplied(key), because "did the caller pass this?" is not
"is this parameter empty?" -- a double is never empty, so loading by
null-check would never fill a primitive, and overwriting regardless
would make a remembered value beat an explicit one. SciJava Common
used a mutable `resolved` flag per parameter; the run knows what it
was given, so it is asked instead.
- A convert3 bug: CastConverter saw a List bound for List<File>, called
it already the right type, and returned a List<String> untouched --
the right container full of the wrong things. It now declines a
parameterized collection and lets the element-wise converter have it.
The earlier tests missed this because they all converted arrays to
lists, where the raw types differ.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NShAz21gbEHnGzhVnC47cb
|`Prefs`|`scijava-context` prefs service (Phase 2); already deprecated in SJC |planned|
50
+
|`Prefs`|`org.scijava.settings.Settings`; already deprecated in SJC |ported|
51
51
|`ProcessUtils`|`org.scijava.common3.Processes`, reimplemented on `ProcessBuilder`; no longer needs `ReadInto`| ported |
52
52
|`PropertiesHelper`| none — inline | dropped |
53
53
|`Sizable`, `SizableArrayList`| none — the reflective-resizing rationale died with Java 17 | dropped |
@@ -117,7 +117,7 @@ A **dropped** row is a successful outcome, not a gap.
117
117
|`plugin` (the `HandlerPlugin`/`WrapperPlugin`/`TypedPlugin`/`SingletonPlugin` hierarchy and their services) | not ported — each user of these inlines the small contract it needs, as `DataHandle` did | dropped |
118
118
|`service`|`org.scijava.context`: `Service` (no longer a plugin, and discovered via `ServiceLoader`), with `Context` holding them. `SciJavaService` has no equivalent — a marker is not needed. `ServiceHelper` and `ServiceIndex` are internal to `Context`| ported |
119
119
|`object`| with the widgets and conversion layer that use it (Phase 3/4), so a consumer shapes it | planned |
120
-
|`prefs`|split: a TOML settings store under `~/.config/fiji` (design settled in [migration-plan.md](migration-plan.md)), and widget value persistence, which belongs with the input harvester (Phase 4). Explicitly **not**`java.util.prefs`| planned|
120
+
|`prefs`|`org.scijava.settings`: one TOML file a person can read, edit and copy, at `~/.config/<app>/settings.toml` on every platform. `PrefService` becomes `Settings`, an ordinary object rather than a service or a singleton - settings belong to an application, and two applications in one JVM want two of them. A table per command (its identifier), a key per parameter; values map onto TOML's own types, so a `List<File>` is an array of strings rather than one mangled string, and reading converts through `scijava-convert3`. Widget value persistence is `LoadInputs` and `SaveInputs`, both **preprocessors**: saving after the run would lose the values exactly when a run failed and the user is about to try again | ported|
121
121
|`app`| mostly `org.scijava.meta` for version and title metadata; the rest is app-shell material, dropped | planned |
122
122
|`thread`| EDT dispatch belongs with the UI layer (Phase 4); parallelism is `org.scijava.concurrent`| planned |
123
123
|`convert`|`org.scijava.convert3`: `Converter` asks one question - can you turn *this value* into *that type* - where SciJava Common had eight `canConvert` overloads and a `ConversionRequest` to carry the combinations. `ConvertService` becomes `Converters`, backed by plain `ServiceLoader` so that conversion sits *below* the container: parameter binding converts, and a script or command line supplies strings for everything. `DefaultConverter`'s pile of special cases becomes one converter per concern (cast, number, string, to-string, array, collection, constructor, file/path), each contributable and orderable by priority. `Converter.of(String.class, Foo.class, Foo::parse)` covers the common case in a line | ported |
0 commit comments