Allow preferences and chat controller to be bound to a file set

ChatPreferences gains a constructor taking a preferences file name relative to
the application directory, so "profiles/OP2/preferences.xml" is as valid as the
historic flat "preferences.xml". A missing file is still seeded from the
bundled template, which gives an additional operator the same clean defaults a
first installation gets.

ChatController gains a constructor that passes both relative file names and the
seed flag through to ChatPreferences and DBController. The existing
constructors delegate to the historic file names, so nothing changes yet.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hpa6bjie5qkeNG62y6FmXm
This commit is contained in:
Claude
2026-09-07 07:36:27 +00:00
parent f27cca27e0
commit ac850e339b
2 changed files with 48 additions and 3 deletions
@@ -2866,9 +2866,35 @@ private ObservableList<String>
* @param setOwnChatMemberObject * @param setOwnChatMemberObject
*/ */
public ChatController(ChatMember setOwnChatMemberObject,StatusUpdateListener listener) { public ChatController(ChatMember setOwnChatMemberObject,StatusUpdateListener listener) {
this(setOwnChatMemberObject,
listener,
ChatPreferences.PREFERENCES_FILE,
DBController.DATABASE_FILE,
true);
}
/**
* Creates a chat controller bound to the files of one operator profile.
*
* <p>Both file names are resolved below the application directory. This is the only
* place where the active operator profile enters the controller; everything below
* works on the resulting {@link ChatPreferences} and {@link DBController} instances
* without knowing about profiles at all.</p>
*
* @param setOwnChatMemberObject chat member object representing the local station
* @param listener callback for thread status updates
* @param preferencesRelativeFileName preferences file name relative to the application directory
* @param workedDatabaseRelativeFileName worked-station database file name relative to the application directory
* @param seedWorkedDatabaseFromResource true to seed a missing database from the bundled template
*/
public ChatController(ChatMember setOwnChatMemberObject,
StatusUpdateListener listener,
String preferencesRelativeFileName,
String workedDatabaseRelativeFileName,
boolean seedWorkedDatabaseFromResource) {
super(); super();
chatPreferences = new ChatPreferences(); chatPreferences = new ChatPreferences(preferencesRelativeFileName);
chatPreferences.readPreferencesFromXmlFile(); chatPreferences.readPreferencesFromXmlFile();
// this.statusListener = listener; // this.statusListener = listener;
lstNotify_QSOSniffer_sniffedCallSignList = lstNotify_QSOSniffer_sniffedCallSignList =
@@ -2930,7 +2956,7 @@ private ObservableList<String>
} }
}); });
dbHandler = new DBController(); dbHandler = new DBController(workedDatabaseRelativeFileName, seedWorkedDatabaseFromResource);
reachabilityService = new ReachabilityService(this); reachabilityService = new ReachabilityService(this);
rebuildWorkedGrossFieldCacheFromDatabase(); rebuildWorkedGrossFieldCacheFromDatabase();
@@ -79,7 +79,26 @@ public class ChatPreferences {
* TODO: delete this from the kst4contest.view/Main.java! * TODO: delete this from the kst4contest.view/Main.java!
*/ */
public ChatPreferences() { public ChatPreferences() {
ApplicationFileUtils.copyResourceIfRequired(ApplicationConstants.APPLICATION_NAME, PREFERENCE_RESOURCE, PREFERENCES_FILE); this(PREFERENCES_FILE);
}
/**
* Creates preferences bound to one operator profile.
*
* <p>The file name is resolved below the application directory, so both
* "preferences.xml" for the root installation and "profiles/OP2/preferences.xml"
* for an additional operator profile are valid. A missing file is seeded from the
* bundled template, which gives a new profile the same clean defaults a first-ever
* installation gets.</p>
*
* @param applicationRelativeFileName preferences file name relative to the application directory
*/
public ChatPreferences(final String applicationRelativeFileName) {
ApplicationFileUtils.copyResourceIfRequired(ApplicationConstants.APPLICATION_NAME, PREFERENCE_RESOURCE, applicationRelativeFileName);
this.storeAndRestorePreferencesFileName = ApplicationFileUtils.getFilePath(
ApplicationConstants.APPLICATION_NAME,
applicationRelativeFileName
);
// lstNotify_QSOSniffer_sniffedCallSignList.add("DF0GEB"); // lstNotify_QSOSniffer_sniffedCallSignList.add("DF0GEB");