|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectPamController.PamSettingManager
public class PamSettingManager
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.
| Field Summary | |
|---|---|
java.lang.String |
databaseListFile
Name of a list of recent database informations (probably just the last one) |
private java.util.ArrayList<PamSettings> |
databaseOwners
List of modules that specifically use settings from the database storage. |
(package private) java.util.ArrayList<PamControlledUnitSettings> |
databaseSettingsList
List of settings used specifically by databases. |
static java.lang.String |
external_wav
|
static java.lang.String |
fileEnd
|
private boolean |
initializationComplete
|
(package private) java.util.ArrayList<PamControlledUnitSettings> |
initialSettingsList
List of settings used by 'normal' modules. |
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) |
private boolean |
loadingLocalSettings
|
private java.util.ArrayList<PamSettings> |
owners
List of modules that have / want PAMGUARD Settings which get stored in the psf file and / or the database store. |
private static PamSettingManager |
pamSettingManager
|
private boolean |
programStart
|
private java.util.ArrayList<java.io.File> |
recentFiles
|
static java.lang.String |
remote_psf
|
static boolean |
RUN_REMOTE
running in remote mode, default normal |
private static int |
SAVE_DATABASE
Save settings to database tables (if available). |
private static int |
SAVE_PSF
Save settings to a psf file |
(package private) SettingsFileData |
settingsFileData
|
java.lang.String |
settingsListFile
Name of the file that contains a list of recent psf files. |
private boolean[] |
settingsUsed
|
private boolean |
userNotifiedAbsentDefaultSettingsFile
|
private boolean |
userNotifiedAbsentSettingsFile
|
| Constructor Summary | |
|---|---|
private |
PamSettingManager()
|
| Method Summary | |
|---|---|
void |
exportSettings(javax.swing.JFrame frame)
|
PamControlledUnitSettings |
findGeneralSettings(java.lang.String unitType)
Searches a list of settings for settings with a specific type. |
private PamSettings |
findOwner(java.util.ArrayList<PamSettings> ownersList,
java.lang.String unitType,
java.lang.String unitName)
Find the owner of some PAMGUARD settings. |
private PamControlledUnitSettings |
findSettings(java.util.ArrayList<PamControlledUnitSettings> settingsList,
boolean[] usedSettings,
PamSettings user)
Find settings in a list of settings, ignoring settings which have already been used by a module. |
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. |
private PamControlledUnitSettings |
findSettings(PamSettings user,
int whichLists)
Find settings for a particular user in one or more lists. |
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)
|
private void |
initialiseRegisteredModules()
Some modules may have already registered before the settings were loaded, so this function is called as soon as they are loaded which sends settings to all modules in the list. |
boolean |
isSettingsUnit(PamSettings settingsUser,
PamControlledUnitSettings settings)
See if a particular PamControlledUnitSettings object is the right one for a particular module that wants some settings. |
private boolean |
loadDatabaseFileData()
Loads the details of the last database to be opened. |
boolean |
loadDBSettings()
Try to get settings information from a valid databse. |
boolean |
loadLocalSettings()
Load data from settings files. |
private boolean |
loadMixedModeSettings()
Load settings for mixed mode. |
private boolean |
loadNormalSettings()
Load settings perfectly 'normally' from a psf file. |
boolean |
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. |
private boolean |
loadPSFSettings()
Open the file that contains a list of files and optionally open a dialog giving the list of recent files. |
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. |
private java.util.ArrayList<PamControlledUnitSettings> |
loadSettingsFromFile()
Load PAMGUARD settings from a psf file. |
void |
loadSettingsGroup(PamSettingsGroup settingsGroup,
boolean notifyExisting)
Load some old settings into all modules. |
private boolean |
loadViewerSettings()
Load settings for viewer mode. |
void |
notifyModelChanged(int changeType)
Called everytime anything in the model changes. |
private java.io.ObjectInputStream |
openInputFile()
Open psf file for settings input. |
private java.io.ObjectInputStream |
openInputFileResource()
Returns total gobbledygook - need to improve the way PAMGAURD creates new psf files. |
java.io.ObjectOutputStream |
openOutputFile()
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 |
private boolean |
saveDatabaseFileData()
Save the details of the most recently used database. |
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. |
private boolean |
saveSettingsFileData()
Save the list of recently used settings files. |
private boolean |
saveSettingsToDatabase()
See if there is a database module in PAMGUARD and if so, save the settings in serialised from in the Pamguard_Settings and Pamguard_Settings_Last tables. |
boolean |
saveSettingsToFile()
Save settings to the default (most recently used) psf file. |
void |
setDefaultFile(java.lang.String defaultFile)
Set the default (first) file in the settings file data. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static PamSettingManager pamSettingManager
private java.util.ArrayList<PamSettings> owners
private java.util.ArrayList<PamSettings> databaseOwners
java.util.ArrayList<PamControlledUnitSettings> initialSettingsList
java.util.ArrayList<PamControlledUnitSettings> databaseSettingsList
public static final java.lang.String fileEnd
public transient java.lang.String settingsListFile
public transient java.lang.String databaseListFile
public static final int LIST_UNITS
public static final int LIST_DATABASESTUFF
private static final int SAVE_PSF
private static final int SAVE_DATABASE
public static boolean RUN_REMOTE
public static java.lang.String remote_psf
public static java.lang.String external_wav
private boolean loadingLocalSettings
private java.util.ArrayList<java.io.File> recentFiles
private boolean[] settingsUsed
private boolean userNotifiedAbsentSettingsFile
private boolean userNotifiedAbsentDefaultSettingsFile
private boolean programStart
SettingsFileData settingsFileData
private boolean initializationComplete
| Constructor Detail |
|---|
private PamSettingManager()
| Method Detail |
|---|
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
private PamControlledUnitSettings findSettings(PamSettings user,
int whichLists)
user - PamSettings user.whichLists - lists to search
private PamControlledUnitSettings findSettings(java.util.ArrayList<PamControlledUnitSettings> settingsList,
boolean[] usedSettings,
PamSettings user)
settingsList - settings listusedSettings - list of settings that have already been used.user - module that uses the settings.
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 type
public boolean saveFinalSettings()
public boolean saveSettings(int saveWhere)
saveWhere -
public boolean saveSettingsToFile()
public boolean loadPAMSettings(int runMode)
runMode -
private boolean loadNormalSettings()
private boolean loadViewerSettings()
private boolean loadMixedModeSettings()
private void initialiseRegisteredModules()
private boolean loadPSFSettings()
Unfortunately, as soon as this gets called th efirst time, it tries to open a database to get more settings information and different database plug ins all start trying to get more settings and it goes round and round and round. Need to ensure that these loop around only get given the general settings information.
public boolean loadLocalSettings()
This is just the general data - the list of recently used psf files and recent database files.
public boolean loadDBSettings()
private boolean saveSettingsToDatabase()
private PamSettings findOwner(java.util.ArrayList<PamSettings> ownersList,
java.lang.String unitType,
java.lang.String unitName)
ownersList - which list to searchunitType - unit typeunitName - unit name
private java.util.ArrayList<PamControlledUnitSettings> loadSettingsFromFile()
public boolean isSettingsUnit(PamSettings settingsUser,
PamControlledUnitSettings settings)
settingsUser - User of settingssettings - Settings object.
public java.io.ObjectOutputStream openOutputFile()
private java.io.ObjectInputStream openInputFile()
private java.io.ObjectInputStream openInputFileResource()
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.
private boolean saveSettingsFileData()
private boolean loadDatabaseFileData()
private boolean saveDatabaseFileData()
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 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)
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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||