Skip to content

Conversation

@kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Nov 17, 2025

Identify the Bug or Feature request

Resolves #5818

Description of the Change

Adds a few elements to the Edit Lookup table dialog to support pick once tables:

  1. A checkbox to mark the table as pick once.
  2. A button to reset the table's picks.
  3. A new column in the table to allow the user to view and modify which entries have been picked.

When (1) is selected, the Roll field is disabled, (2) is enabled, and (3) is made visible. When (1) is not selected, the Roll field is enabled, (2) is disabled, and (3) is hidden.

As with the existing UI, none of the new element effect the table until the Accept button is hit. Also, since picks are actually handled now, they won't be lost when a table is edited unless the user explicitly resets them.

Also did some refactoring and fixes on EditLookupTablePanel:

  • It now uses GenericDialog for some nice features.
  • The Accept button is now the default button for the panel, and is highlighted as such
  • Leverages the view's field to get components in a type-safe way. Added a bit to AbeillePanel to allow replacing concrete component without using names.
  • The table rows are modeled with a custom type rather than being a list of String. This is needed to support the new boolean "Picked?" column.
  • Fixes the size of the Table Image to 150x150 to solve solve some strange reflowing as the dialog is resized.

Possible Drawbacks

Should be none

Documentation Notes

The UI can now be used to set a table as pick once and to modify the picked entries.

When pick once is enabled:
image

When pick once is disabled:
image

Release Notes

  • Added the ability to set a table as pick-once in the Edit Table dialog.

This change is Reviewable

This isn't the right situation to throw an exception, since it is at least as likely to indicate a failure for previous
code to unbind the model rather than being a problem of the current caller double-binding. Throwing an exception here
has the potential to crash MT and even the OS as the exception is reported in error dialogs on repeat.

This case still indicates a logical error, though, so log it as such. But after that, just unbind the old model and
carry on.
It also does not require the parent container name to be provided.

There was some sneaky state in the `#replaceComponent()` method to to set the `#componentMap`. field. That field is now
eagerly initialized in the constructor, including the component collection.
- Remove unused fields, component accessors, and unnecessary null checks
- Prefer `String#isEmpty()` over comparing `String#length()` against `0`
- Replace magic constants for columns with named constants, and make image-specific operations only apply to the image
  column regardless of order.
- Move tooltip assignment into the .form file
- Use ServerCommand#putLookupTable(LookupTable) to update just the one specific table instead of syncing all campaign
  properties.
- Change the `AbeillePanel<>` model type to from `LookupTableTableModel` to `LookupTable`
- Columns names don't need to be injected since they are statically defined.
- Rows are now a dedicated type rather than a list of "untyped" `String`.
- `LookupTableTableModel` no longer needs to be package-private
Also make it more idiomatic:
- `AbeillePanel` model type is `LookupTable`, not `LookupTableTableModel`.
- Actually bind a model via `#bind()` instead of using a separate `#attach()`.
- True committment via `#commit()` instead of an `ACCEPT` action listener.
- Set the `Accept` button to be the default button for the dialog.
- Forbid `null` bindings, instead requiring the caller to provide a new LookupTable
- Create EditLookupTablePanel instances on demand. They are not expensive to create, and delaying instantiation helps
  with getting dialog ownership correct as `MapTool.getFrame()` will have had a chance to be initialized.
@kwvanderlinde kwvanderlinde self-assigned this Nov 17, 2025
@github-actions github-actions bot added the feature Adding functionality that adds value label Nov 17, 2025
@kwvanderlinde kwvanderlinde moved this from Todo to Awaiting-Review in MapTool 1.19 Nov 17, 2025
@FullBleed
Copy link

This is great.

I do, however, wish the "Reset Picks" button was inline with the "Pick Once" check box and disabled when the checkbox is unchecked though.

@kwvanderlinde
Copy link
Collaborator Author

This is great.

I do, however, wish the "Reset Picks" button was inline with the "Pick Once" check box and disabled when the checkbox is unchecked though.

Sure, I can move it inline. The button is already being disabled as you'd like.

@FullBleed
Copy link

Heh, right after I hit send my brain registered your disabled description in the OP. ;)

- The panel is now split vertically in two. The top half is a JPanel containing all the table options on a grid, while
  the bottom half is the scroll pane containing the table data.
- Replaced the separate "Table Image" label with a border title on a new panel containing the `tableImage` field.
- Fix the size of the `tableImage` field at 150x150.
- Reduced the preferred scrollable viewport size of the JTable from 400 to 150 to avoid excessively tall dialogs or
  strange resizing. This is unfortunately a manually specified value for JTable, so not much opportunity to be smart
  about it.
This makes everything strongly typed as we don't need to cast the results of looking up String component names.
The new "Pick Once Table" checkbox allows the user to set a table as pick once without resorting to macros. When a table
is pick once:
- The roll option is disabled as it is not used.
- A new "Picked?" columns is shown in the table to indicate whether a raw has already been picked. The user can manually
  select or unselect these to mark specific entries as picked.
- The new "Reset Picks" button will be enabled, allowing the user to clear all the "Picked?" checkboxes.

This also means that editing a table will no longer clear the picked entries unless the user manually clears them or
changes the table to not be a pick once table.
@kwvanderlinde kwvanderlinde force-pushed the feature/5818-pick-once-ui branch from d76a933 to 8c9a78c Compare November 17, 2025 20:12
@github-project-automation github-project-automation bot moved this from Awaiting-Review to To-Be-Merged in MapTool 1.19 Nov 18, 2025
@cwisniew cwisniew added this pull request to the merge queue Nov 18, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to invalid changes in the merge commit Nov 18, 2025
@kwvanderlinde kwvanderlinde added this pull request to the merge queue Nov 18, 2025
Merged via the queue into RPTools:develop with commit cf015fa Nov 18, 2025
4 checks passed
@github-project-automation github-project-automation bot moved this from To-Be-Merged to Merged in MapTool 1.19 Nov 18, 2025
@kwvanderlinde kwvanderlinde deleted the feature/5818-pick-once-ui branch November 18, 2025 05:54
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.

[Feature]: UI support for pick-once tables

3 participants