Skip to content

Conversation

@kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Nov 21, 2025

Identify the Bug or Feature request

Resolves #185

Description of the Change

At the UI-level, resource libraries in the RPTools tab of the Add Resource to Library dialog are now displayed in a JTable instead of a JList, with the library name and size shown in separate columns. This lets the user sort based on either field. We've also added the author to the UI, so the user can now sort based on that as well.

Internally, I've pulled the library downloading and parsing logic out of AddResourceDialog and into a separate LibraryUtils class, with the Library record representing the data parsed out of the downloaded library list. It works roughly as the old DownloadListWorker, but:

  1. Isn't tied to a UI
  2. Uses CompletionStage for easier chaining compared to SwingWorker
  3. Validates the library list instead of trusting it's contents to be correct.
  4. Handles large packs by using long sizes instead of int. This is just future proofing as no packs are currently anywhere close to 2GB.

I've also modified the error handling when installing libraries so that only a single error dialog is shown to the user rather than one per library per failure. The new dialog also tells the user which libraries failed to install, so there's a tiny bit of #5885 sneaking in here.

Final change is to rename the view files to match AddResourceDialog, as previously they each snuck differents ss in their names, making the association less clear.

Possible Drawbacks

Less calories burnt clicking through dialogs on shoddy network connections.

Documentation Notes

The RPTools library list can now be sorted based on library name, author, or size:
image

Release Notes

  • Added the ability to sort RPTools Library list by library name, author or size.

This change is Reviewable

@kwvanderlinde kwvanderlinde self-assigned this Nov 21, 2025
@github-actions github-actions bot added the feature Adding functionality that adds value label Nov 21, 2025
@kwvanderlinde kwvanderlinde moved this from Todo to Awaiting-Review in MapTool 1.19 Nov 21, 2025
@kwvanderlinde kwvanderlinde marked this pull request as draft November 22, 2025 00:09
`LibraryUtils` handles the downloading and parsing of the library list, representing the results as a collection of
`Library` records. When parsing the library list, it is much more strict about required formats, not permitted empty
names, paths, or sizes, and not allowing paths that result in invalid URLs.

`LibraryUtils` is also responsible for downloading and installing such a collectionm, though as a separate operation so
that the caller can filter the results if desired.

With the change in responsibilities, the test for `DownloadListWorker` in `AddResourceDialogTest` have been moved to the
new `LibraryUtilsTest` and test `LibraryUtil#parseLibraryList(String)`. The other tests in `AddResourceDialogTest`
tested that `LibraryRow` initialized itself properly, but that is no longer a real concern now that it just wraps a
`Library` and `Library` is basic record.

Error reporting works differently now. Previously, we would show error dialogs to the user any time anything went wrong,
often regarding things that have nothing to with them or the current MT installation. E.g., we would show a popup if the
server returned an invalid path for a library. What we do now is to collect all the failed installations - regardless of
why they failed - and show the user one dialog to inform them which of their desired libraries could not be
installed. As a result, some i18n keys have been removed.
The raw `JList` is now a `JList<LibraryRow>`, ensuring that it never contains a `String.` This completely avoids
possibilities such as seen in RPTools#343.

This is accomplished by moving the informational and error messages out of the `JList` and into a dedicated
`JLabel`. This label is only displayed when there is a message to show the user and is completely hidden otherwise.
With the `JTable`, we now have separate columns for the library name and the size. The user can sort by either column by
clicking on the column header.

With this change, there is no more need for `LibraryRow` as we don't depend on the `#toString()` method of the rows as
was needed with `JList`.
The library author is displayed in a new column of the RPTools table. This not only distinguishes it, but allows the
user to sort by author in addition to library name or size if they so desire.

For backwards compatibility, the author in the download library list is optional (though in practice it already exists
in the listing). It's also just not a critical detail, so it's okay if it is missing. If there is no author, the dialog
will display the name as "unknown" (`dialog.addresource.unknownAuthor`).

With three equal-width columns, there is no longer enough room to display most library names. So we instead assign 60%
of the table width to the library name, 25% to the author name, and 15% to the size. The user can resize these if
needed, but in practice this appears to provide sufficient room. Once the user resizes any columns, the proportions they
set will be preserve even if the table is subsequently resized.
@kwvanderlinde kwvanderlinde force-pushed the feature/185-sorted-artpacks branch from fcc8fca to 36dec6d Compare November 22, 2025 03:20
@kwvanderlinde kwvanderlinde marked this pull request as ready for review November 22, 2025 03:32
@github-project-automation github-project-automation bot moved this from Awaiting-Review to To-Be-Merged in MapTool 1.19 Nov 25, 2025
@cwisniew cwisniew added this pull request to the merge queue Nov 25, 2025
Merged via the queue into RPTools:develop with commit ce97f3b Nov 25, 2025
4 checks passed
@github-project-automation github-project-automation bot moved this from To-Be-Merged to Merged in MapTool 1.19 Nov 25, 2025
@kwvanderlinde kwvanderlinde deleted the feature/185-sorted-artpacks branch November 25, 2025 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Adding functionality that adds value

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

Artpacks should be sorted alphabetically in MapTool

2 participants