Class SettingsWindowCommon

java.lang.Object
com.everdro1d.libs.swing.windows.settings.SettingsWindowCommon

public class SettingsWindowCommon extends Object
The SettingsWindowCommon class provides utility methods for importing and exporting user settings, managing file paths for settings, and interacting with file choosers.

This class is non-instantiable and contains only static methods.

Features:

  • Import settings from an XML file and apply them using Preferences.
  • Export current settings to an XML file using Preferences.
  • Retrieve or set file paths for settings using a custom file chooser.

Example Usage:

 String filePath = SettingsWindowCommon.getFilePathUser(true, true, frame, localeManager, prefs);
 SettingsWindowCommon.exportSettings(filePath, true, frame, prefs);
 

Note: This class cannot be instantiated.

  • Method Details

    • importSettings

      public static void importSettings(String filePath, boolean debug, JFrame settingsFrame)
      Imports settings from an XML file and applies them using Preferences.
      Parameters:
      filePath - the path to the XML file containing the settings
      debug - whether to enable debug logging
      settingsFrame - the parent frame for displaying messages
    • exportSettings

      public static void exportSettings(String filePath, boolean debug, JFrame settingsFrame, Preferences prefs)
      Exports current settings to an XML file using Preferences.
      Parameters:
      filePath - the path to save the XML file
      debug - whether to enable debug logging
      settingsFrame - the parent frame for displaying messages
      prefs - the Preferences node to export
    • getFilePathUser

      public static String getFilePathUser(boolean export, boolean debug, JFrame settingsFrame, LocaleManager localeManager, Preferences prefs)
      Retrieves the file path for importing or exporting settings using a file chooser.
      Parameters:
      export - whether the operation is an export
      debug - whether to enable debug logging
      settingsFrame - the parent frame for the file chooser
      localeManager - the LocaleManager for localization
      prefs - the Preferences node to store the file path
      Returns:
      the selected file path, or an empty string if canceled