public class PamSettingManager
extends java.lang.Object
When the GUI closes, SaveSettings is called, SaveSettings goes through the list of registered objects and asks each one to give it a reference to an Object containing the settings (this MUST implement serialisable). This can be the object itself, but will more likely be a reference to another object just containing settings parameters. The class implementing PamSettings must also provide functions getUnitType, getUnitName and getSettingsVersion. These four pieces of information are then bundled into a PamControlledUnitSettings which is added to an array list which is then stored in a serialised file.
When PAMGUARD starts, after all detectors have been created, the serialised file is reopened. Each PamControlledUnitSettings is taken in turn and compared with the list of registered objects to find one with the same name, type and settings version. Once one is found, it is given the reference to the settings data which t is responsible for casting into whatever class it requires.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
external_wav |
static java.lang.String |
fileEnd |
static java.lang.String |
fileEndXML |
static int |
LIST_DATABASESTUFF
Identifier for modules which are part of the database system.
|
static int |
LIST_UNITS
Identifier for modules that go in the 'normal' list
(everything apart from database modules)
|
static int |
LOAD_SETTINGS_CANCEL |
static int |
LOAD_SETTINGS_NEW |
static int |
LOAD_SETTINGS_OK |
static java.lang.String |
remote_psf |
static boolean |
RUN_REMOTE
running in remote mode, default normal
|
Modifier and Type | Method and Description |
---|---|
void |
exportSettings(javax.swing.JFrame frame) |
PamControlledUnitSettings |
findGeneralSettings(java.lang.String unitType)
Searches a list of settings for settings with a
specific type.
|
PamControlledUnitSettings |
findSettings(java.util.ArrayList<PamControlledUnitSettings> settingsList,
java.lang.String unitType,
java.lang.String unitName)
Find settings in a list of settings by name and by type.
|
PamControlledUnitSettings |
findSettingsForType(java.lang.String unitType)
Find the settings for a given unit type and any name
|
PamSettingsGroup |
getCurrentSettingsGroup() |
java.lang.String |
getDefaultFile() |
static PamSettingManager |
getInstance() |
java.util.ArrayList<PamSettings> |
getOwners() |
java.lang.String |
getSettingsFileName()
Get the most recently used settings file name.
|
void |
importSettings(javax.swing.JFrame frame)
Import a configuration during viewer mode operation.
|
boolean |
isSettingsUnit(PamSettings settingsUser,
PamControlledUnitSettings settings)
See if a particular PamControlledUnitSettings object is the right one
for a particular module that wants some settings.
|
int |
loadDBSettings()
Try to get settings information from a valid databse.
|
boolean |
loadLocalSettings()
Load data from settings files.
|
int |
loadPAMSettings(int runMode)
Load the PAMGAURD settings either from psf file or from
a database, depending on the run mode and type of settings required.
|
boolean |
loadSettingsFileData()
Now that the database is becoming much more fundamental to settings
storage and retrieval, the latest database settings should go into
the main settings file.
|
void |
loadSettingsFrom(javax.swing.JFrame frame)
pop up the dialog that's shown at start up to show
a list of recent settings file and give the opportunity
for browsing for more.
|
void |
loadSettingsGroup(PamSettingsGroup settingsGroup,
boolean notifyExisting)
Load some old settings into all modules.
|
void |
notifyModelChanged(int changeType)
Called everytime anything in the model changes.
|
void |
objectToXMLFile(java.lang.Object serialisableObject,
java.io.File file)
An object is serializable iff ....
|
java.io.ObjectOutputStream |
openOutputFile(java.lang.String outputFile)
Open psf file for settings serialised output.
|
boolean |
registerSettings(PamSettings pamUnit)
Register a PAMGAURD module that wants to store settings in a
serialised file (.psf file) and / or have those settings stored
in the database settings table.
|
boolean |
registerSettings(PamSettings pamUnit,
int whichLists)
Register modules that have settings information that
should be stored in serialised form in
psf files and database Pamguard_Settings tables.
|
void |
reset()
Clear all settings from the manager
|
boolean |
saveFinalSettings()
Call just before PAMGUARD exits to save the settings
either to psf and / or database tables.
|
boolean |
saveSettings(int saveWhere)
Save settings to a psf file and / or the database tables.
|
void |
saveSettings(javax.swing.JFrame frame)
saves settings in the current file
|
void |
saveSettingsAs(javax.swing.JFrame frame)
Save settings to a new psf file.
|
void |
saveSettingsAsXML(javax.swing.JFrame frame)
Save settings to a new psf file.
|
boolean |
saveSettingsToFile() |
boolean |
saveSettingsToFile(java.lang.String fileName)
Save configuration settings to the default (most recently used) psf file.
|
boolean |
saveSettingsToXMLFile(java.io.File file)
Save configuration settings to a PSFX file (XML).
|
void |
setDefaultFile(java.lang.String defaultFile)
Set the default (first) file in the settings file data.
|
public static final int LOAD_SETTINGS_OK
public static final int LOAD_SETTINGS_CANCEL
public static final int LOAD_SETTINGS_NEW
public static final java.lang.String fileEnd
public static final java.lang.String fileEndXML
public static final int LIST_UNITS
public static final int LIST_DATABASESTUFF
public static boolean RUN_REMOTE
public static java.lang.String remote_psf
public static java.lang.String external_wav
public static PamSettingManager getInstance()
public void reset()
public void notifyModelChanged(int changeType)
changeType
- type of changepublic boolean registerSettings(PamSettings pamUnit)
Normally, all modules will call this for at least one set of settings. Often the PamSettings is implemented by the class that extends PamControlledunit, but it's also possible to have multiple sub modules, processes or displays implemnt PamSettings so that different settings for different bits of a PamControlledUnit are stored separately.
pamUnit
- Reference to a PamSettings modulePamSettings
,
PamControlledUnit
public boolean registerSettings(PamSettings pamUnit, int whichLists)
pamUnit
- Unit containing the settingswhichLists
- which lists to store the settings in. N.B. These are internal lists and not the external storage. Basically any database modules connected with settings should to in LIST_DATABASESTUFF everything else (including the normal database) should go to LISTS_UNITS
public PamControlledUnitSettings findGeneralSettings(java.lang.String unitType)
unitType
- PamControlledUnitSettings
public PamControlledUnitSettings findSettings(java.util.ArrayList<PamControlledUnitSettings> settingsList, java.lang.String unitType, java.lang.String unitName)
settingsList
- settings list to searchunitType
- unit nameunitName
- unit typepublic boolean saveFinalSettings()
public boolean saveSettings(int saveWhere)
saveWhere
- public boolean saveSettingsToFile()
public boolean saveSettingsToFile(java.lang.String fileName)
public boolean saveSettingsToXMLFile(java.io.File file)
public void objectToXMLFile(java.lang.Object serialisableObject, java.io.File file)
public int loadPAMSettings(int runMode)
runMode
- public boolean loadLocalSettings()
This is just the general data - the list of recently used psf files and recent database files.
public int loadDBSettings()
public boolean isSettingsUnit(PamSettings settingsUser, PamControlledUnitSettings settings)
settingsUser
- User of settingssettings
- Settings object.public java.io.ObjectOutputStream openOutputFile(java.lang.String outputFile)
public boolean loadSettingsFileData()
We therefore need some modules (i.e. database ones) to also store their settings in a general settings list so that they can be read in before any other settings are read in. So each unit when it registers, says whether it should be included in the general list as well as the specific data file.
public java.lang.String getSettingsFileName()
public java.lang.String getDefaultFile()
public void saveSettings(javax.swing.JFrame frame)
frame
- GUI frame (needed for dialog, can be null)public void saveSettingsAs(javax.swing.JFrame frame)
frame
- parent frame for dialog.public void saveSettingsAsXML(javax.swing.JFrame frame)
frame
- parent frame for dialog.public void setDefaultFile(java.lang.String defaultFile)
defaultFile
- File name string.public void loadSettingsFrom(javax.swing.JFrame frame)
frame
- parent frame for dialog (can be null)public void importSettings(javax.swing.JFrame frame)
frame
- public void exportSettings(javax.swing.JFrame frame)
public java.util.ArrayList<PamSettings> getOwners()
public PamSettingsGroup getCurrentSettingsGroup()
public void loadSettingsGroup(PamSettingsGroup settingsGroup, boolean notifyExisting)
Currently used in viewer mode to load reloaded settings from binary files and the database.
settingsGroup
- settings group to load.send
- these new settings round to all existing modules.public PamControlledUnitSettings findSettingsForType(java.lang.String unitType)