NOTICE! This is a static HTML version of a legacy ImageJ Trac ticket.

The ImageJ project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Ticket #373 (closed task: fixed)

Opened 2011-03-14T14:39:14-05:00

Last modified 2011-09-12T14:58:30-05:00

Setup preferences correctly at program startup

Reported by: bdezonia Owned by: bdezonia
Priority: major Milestone: imagej-2.0-alpha5
Component: Core Version:
Severity: serious Keywords:
Cc: Blocked By:


IJ1 & IJ2 maintain similar settings. We will have code for keeping them in sync so that IJ1 commands, looking at IJ1 prefs, act accordingly when IJ2 prefs have been set.

But we need to initialize the IJ2 preferences at some time. We can take one of two approaches.

1) On startup check for IJ2 prefs and load them if existing. If not existing set the IJ2 preferences to defaults. Then set each pref to its corresponding IJ1 value if it exists in the IJ1 prefs. Save the pref keys to disk.

2) once only, set the IJ2 preferences to their default values and write them out. User's current settings are lost. After that always load the prefs from IJ2's store. From then on the prefs will always reflect the user's choices. Cleaner but may ruffle some users' feathers.

Change History

comment:1 Changed 2011-03-31T23:37:03-05:00 by curtis

  • Milestone changed from imagej-2.0-alpha1 to imagej-2.0-alpha2

comment:2 Changed 2011-06-28T17:07:48-05:00 by bdezonia

Taking approach number 2. I have stubbed out fake initialization in as a placeholder for actual code. To be implemented.

comment:3 Changed 2011-07-29T12:57:39-05:00 by bdezonia

  • Milestone changed from imagej-2.0-beta1 to imagej-2.0-alpha5

Removed stub from Main. Need to determine where to do this.

comment:4 Changed 2011-07-29T14:36:31-05:00 by bdezonia

The way to handle this is to change the Prefs.get() to take a default value. Then if the setting does not exist via disk load it will get initialized correctly and persisted from then on. Update calls as needed with defaults.

comment:5 Changed 2011-08-31T15:43:14-05:00 by bdezonia

Updated OptionsSynchronizer to pass defaults. This turns out not to be sufficient. The initialization of values in IJ2 has to happen somewhere other than the legacy layer. By the time the legacy layer latches on to them they have been initialized to 0, "", etc.

comment:6 Changed 2011-09-12T14:58:30-05:00 by bdezonia

  • Status changed from new to closed
  • Resolution set to fixed

Fixes by Curtis and Barry. Final commit in 0c803bfcb23b34910d2221e1e7192b5c0e6a2761.