Skip to content

Add addSpinnerButton to InputPage for bounded integer settings (#56)#57

Merged
khatchad merged 1 commit into
masterfrom
issue-56-spinner-button
Jun 22, 2026
Merged

Add addSpinnerButton to InputPage for bounded integer settings (#56)#57
khatchad merged 1 commit into
masterfrom
issue-56-spinner-button

Conversation

@khatchad

@khatchad khatchad commented Jun 22, 2026

Copy link
Copy Markdown
Member

Closes #56.

Adds a sibling addSpinnerButton alongside InputPage.addIntegerButton:

protected void addSpinnerButton(String text, String key, int defaultValue, int minimum,
        Consumer<Integer> valueConsumer, Composite result)

For settings that are small bounded positive integers (e.g. a k-CFA depth), an SWT Spinner is a better control than the free-text Text field: it offers up/down steppers, enforces integer-only input, and pins a minimum, eliminating the free-text parse-failure path the Text listener silently swallows.

Details

  • Seed-safe the same way as addIntegerButton—seeds defaultValue into the dialog settings when key is absent.
  • Backed by Spinner with setMinimum(minimum); the ModifyListener reads getSelection() directly, so there is no Integer.parseInt/NumberFormatException swallow.
  • A stored value below the minimum is clamped by the spinner and read back via getSelection(), so the consumer and settings stay consistent with the displayed control (handles migration of an existing setting onto a spinner).
  • addIntegerButton is retained for unbounded or free-form integer entry; subclasses choose per field.

Consumers

🤖 Generated with Claude Code

Render small bounded positive integer settings with an SWT Spinner
instead of a free-text Text field. The spinner offers up/down steppers,
enforces integer-only input, and pins a minimum, eliminating the silent
parse-failure path of the Text-backed addIntegerButton.

addSpinnerButton is seed-safe in the same way as addIntegerButton
(seeds defaultValue into the dialog settings when the key is absent).
A stored value below the minimum is clamped by the spinner and read
back so the consumer and settings stay consistent with the control.

addIntegerButton is retained for unbounded or free-form integer entry;
subclasses choose per field.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014ydAvERPms47vaUevbsoFX
Copilot AI review requested due to automatic review settings June 22, 2026 14:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new InputPage helper to render bounded integer settings using an SWT Spinner, intended to improve UX and avoid free-text parsing failures compared to addIntegerButton.

Changes:

  • Introduces addSpinnerButton(...) to create a label + Spinner, seed dialog settings, and propagate values via a Consumer<Integer>.
  • Adds SWT Spinner import to support the new control.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +105 to +107
Spinner spinner = new Spinner(result, SWT.BORDER);
spinner.setMinimum(minimum);
spinner.setSelection(this.settings.getInt(key));
@khatchad khatchad changed the title Add addSpinnerButton to InputPage for bounded integer settings (#56) Add addSpinnerButton to InputPage for bounded integer settings (#56) Jun 22, 2026
@khatchad
khatchad merged commit 6e7eebd into master Jun 22, 2026
6 checks passed
@khatchad
khatchad deleted the issue-56-spinner-button branch June 22, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a spinner option control to InputPage for bounded integer settings

2 participants