Skip to content

Optimize Apply/OK/Restore Defaults to skip redundant work#138

Open
kaleb-tracqi wants to merge 2 commits into
nyetwurk:masterfrom
kaleb-tracqi:feature/dark-mode-theme
Open

Optimize Apply/OK/Restore Defaults to skip redundant work#138
kaleb-tracqi wants to merge 2 commits into
nyetwurk:masterfrom
kaleb-tracqi:feature/dark-mode-theme

Conversation

@kaleb-tracqi
Copy link
Copy Markdown
Contributor

@kaleb-tracqi kaleb-tracqi commented Apr 30, 2026

Summary

Adds state tracking to all 5 dialog window types so that clicking Apply, OK, or Restore Defaults is a no-op when the UI state hasn't changed since the last apply.

Approach

  • State snapshot (SmoothingWindow, FilterWindow, FATSChartFrame, PreferencesEditor): captureState() returns Object[] of current UI values, compared via Arrays.equals() to lastAppliedState
  • Dirty flag (RangeSelectorWindow): Tree-based selection uses a simpler dirty flag

Files changed

  • ECUxPlotWindow.java — dirty flag infrastructure
  • SmoothingWindow.java — state snapshot for smoothing params
  • FilterWindow.java — state snapshot for filter params
  • RangeSelectorWindow.java — dirty flag on tree clicks
  • FATSChartFrame.java — state snapshot with combo box handling
  • PreferencesEditor.java — generic field tracking with trackField()
  • FATSEditor.java — override captureState() for custom fields
  • PIDEditor.java — register 9 custom fields

Testing

  • make compile — builds successfully
  • make test — all 12 tests pass

Closes #121

@kaleb-tracqi kaleb-tracqi changed the title Optimize Apply/OK/Restore Defaults to skip redundant work Optimize dialog buttons & add tooltips for calculated fields Apr 30, 2026
@kaleb-tracqi kaleb-tracqi changed the title Optimize dialog buttons & add tooltips for calculated fields Optimize Apply/OK/Restore Defaults to skip redundant work Apr 30, 2026
@nyetwurk
Copy link
Copy Markdown
Owner

nyetwurk commented May 3, 2026

Needs a rebase

When a user clicks Apply, OK, or Restore Defaults and then clicks
any of those buttons again without making changes, the expensive
rebuild/refresh operations are now skipped.

Approach by window type:
- SmoothingWindow, FilterWindow, FATSChartFrame: State snapshot
  comparison via captureState()/lastAppliedState. Before applying,
  compare current UI state to last applied state; skip if unchanged.
- RangeSelectorWindow: Dirty flag set on tree clicks, Select All,
  and Select None; checked and cleared in applySelection().
- PreferencesEditor (base for SAE, Constants, Fueling, FATS, PID
  editors): State snapshot of tracked text field values. Subclasses
  with custom fields (FATSEditor, PIDEditor) override captureState()
  or register fields via trackField().

Fixes nyetwurk#121

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kaleb-tracqi kaleb-tracqi force-pushed the feature/dark-mode-theme branch from fdb646f to 2d53b84 Compare May 8, 2026 04:25
@nyetwurk
Copy link
Copy Markdown
Owner

I'm not sure i like how private Object[] captureState() works. If you add/remove objects you have to update captureState()... maybe some sort of reflection? Or some other kind of implicit native cloneable and comparable/serializable object within the parent that keeps the current state (and can be copied)

Replace fragile manual Object[] captureState() methods with a reusable
UIStateTracker class. Components register via track() at creation time,
and the tracker handles state capture/comparison automatically.

- Add UIStateTracker with track(), snapshot(), hasChanged(), clear()
- ECUxPlotWindow: embed stateTracker for SmoothingWindow/FilterWindow
- PreferencesEditor: replace trackedFields/captureState/trackField
- FATSChartFrame: own stateTracker instance (extends ChartFrame)
- FATSEditor: stateTracker.clear() + re-track custom fields
- PIDEditor: stateTracker.track() replaces trackField()
- Remove all manual Object[] captureState() methods

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

Optimize "Ok", "Apply", and "Restore Defaults" so they don't repeat work.

2 participants