diff --git a/README.html b/README.html index e399e1e8..901b0c81 100644 --- a/README.html +++ b/README.html @@ -325,7 +325,8 @@ href="http://www.gnu.org/licenses/gpl-3.0-standalone.html">http://www.gnu.org/li

The latest version of PAMGuard has been tested on 64 bit Windows 10. We expect it to work without problems on 64 bit versions of Windows -8 and probably 7.

+8 and probably 7. Some testing has been undertaken on Windows 11 and nothing +unexpected has been noted.

On Windows, download and run the Windows installer.

@@ -364,11 +365,11 @@ you should be able to launch PAMGUARD via an appropriate command line which should be something like:

java --Xms384m -Xmx1024m -Djava.library.path=lib64 -jar PamguardBeta_xxxxxx.jar

+-Xms384m -Xmx4096m -Djava.library.path=lib64 -jar Pamguard_xxxxxx.jar

-

The -Xms384m -Xmx1024m specify the initial and maximum heap -size for the JVM being used to run Pamguard i.e. how much memory it gets to -use. The default max size usually being too low.

+

The -Xms384m -Xmx4096m specify the initial and maximum heap +size for the JVM being used to run Pamguard i.e. how much memory it gets to use. +The default max size usually being too low.

The -Djava.library.path=lib64 tells the JVM that it should look in the folder called "lib64" for the required shared libraries @@ -381,13 +382,16 @@ just run the appropriately named executable (e.g. PamguardBeta_MixedMode.exe or PamguardBeta_ViewerMode.exe):

java --Xms384m -Xmx1024m -Djava.library.path=lib64 -jar PamguardBeta_xxxxxx.jar -v

+-Xms384m -Xmx4096m -Djava.library.path=lib64 -jar PamguardBeta_xxxxxx.jar -v

 

LATEST VERSION 2.02.03 February 2022

+href="#_Latest_Version_2.02.05">LATEST VERSION 2.02.05 October 2022 + +

Version 2.02.03 February 2022

Version 2.02.02 October 2021

@@ -437,64 +441,78 @@ Version 2.00.11 October 2017

Beta Version 2.00.10 June 2017

-

Version -1.15.11 MAY 2017

+

Older Versions

-

Version 1.15.10 -March 2017

+

Latest Version 2.02.05 October 2022

-

Version -1.15.09 January 2017

+

Click Train Detector Features and Bug Fixes

-

Version -1.15.08 November 2016

+

Features

-

Version -1.15.07 November 2016

+

Changes to GUI to make dialog shorter for +low DPI screens.

-

Version -1.15.06 November 2016

+

Complete rewrite of the classification +system to have nested classifiers which can be enabled or disabled.

-

Version 1.15.05 -September 2016

+

Changes to classification GUI to +accommodate the new classification system.

-

Version -1.15.04 July 2016

+

Addition of data selectors to the minimum +number of clicks accepted by the classifier. This allows the click-by-click +classifier and the click train detector to be used to together to improve +classification accuracy.

-

Version -1.15.03 April 2016

+

Bug fixes

-

Version -1.15.02 March 2016

+

Click detection bug fix in kernel which +improved click fragmentation.

-

Version -1.15.00 February 2016

+

Bug fix to database were JSON data from +classifier was being trimmed.

-

Version 1.14.00 -Beta, September 2015

+

Documentation

-

Version 1.13.05 -Beta, July 2015

+

Comprehensive help file including +description of the algorithm, screen grabs and examples.

-

Version 1.13.04 -Beta, June 2015

+

Bug fixes

-

Version 1.13.03 -Beta, March 2015

+

Other Features

-

Version 1.13.02 -Beta, January 2015

+

Help documentation for Backup Manager

-

Version 1.13.01 -Beta, January 2015

+

Help documentation for Matched Click +Classifier

-

Version 1.13.00 -Beta December 2014

+

Database logging of offline tasks (such as +click re-classification, bearing calculation, etc.)

-

Older Versions

+

Data selector for Whistle Classifier module

-

Latest Version -2.02.03 February 2022

+

Variable sound output level when using +National Instruments devices for sound playback.

+ +

Speed improvement when processing flac +audio files.

+ +

Bug Fixes

+ +

Soundtrap DWV import. Will now generate binary +files even if DWV file doesn’t exist (which is correct behavior in quiet +conditions when no clicks were detected).

+ +

Spectrogram. Changes to stop occasional +crashing when restarting processing of wav files.

+ +

Sizing of dialogs on ultra high definition +monitors so that data fields are sized correctly.

+ +

Fixed a memory leak in ROCCA

+ +

Version 2.02.03 +February 2022

Some minor bug fixes following our migration to GitHub. Note that the older Bug numbers only refer to bugs reported on the SVN site. New @@ -640,8 +658,9 @@ lang=EN-US> Improvements to datamap display, to ensure even small images will be shown

4.        -Allow Clip Generator to create both a binary record and a wav file

+lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'>       Allow Clip Generator to create both a binary record and a +wav file

5.        @@ -732,10 +751,10 @@ Version 2.00.10 before proceeding with installation and use of this version.

This version of PAMGuard has been bundled with Java 13 -(release 13.0.1). PSFX files generated in previous beta releases (2.xx.xx) -should be compatible with this version, and vice-versa. PSF files generated in -core releases (1.15.xx) can be loaded in this version, but will be converted to -PSFX files when PAMGuard exits.

+(release 13.0.1). PSFX files generated in previous beta releases (2.xx.xx) should +be compatible with this version, and vice-versa. PSF files generated in core +releases (1.15.xx) can be loaded in this version, but will be converted to PSFX +files when PAMGuard exits.

Bug Fixes

@@ -833,8 +852,9 @@ August 2020

If you are upgrading from a PAMGuard core release (1.15.xx), PAMGuard Version 2 contains major updates. You should read and -understand the notes listed for Beta Version -2.00.10 before proceeding with installation and use of this version.

+understand the notes listed for Beta +Version 2.00.10 before proceeding with installation and use of this +version.

This version of PAMGuard has been bundled with Java 13 (release 13.0.1). PSFX files generated in previous beta releases (2.xx.xx) @@ -985,8 +1005,9 @@ lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'> &nb Added global hotkeys to Logger module.

10.        -Added channel display to noise one band measurement display.

+lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'>       Added channel display to noise one band measurement display. +

11.        @@ -1098,17 +1119,18 @@ Bug 447. Viewer mode throws exception when trying to load beamformer localisations

16.        -Bug 448. Detection Group Localiser data units not being loaded in Viewer mode.

+lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'>       Bug 448. Detection Group Localiser data units not being +loaded in Viewer mode.

17.        Bug 449. Rocca Encounter Stats output file calculating incorrect values.

18.        -Bug 450. Ishmael Detectors subscribing to FFTDataBlock twice, meaning they -process each data unit 2x doubling the output.

+lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'>       Bug 450. Ishmael Detectors subscribing to FFTDataBlock +twice, meaning they process each data unit 2x doubling the output.

Upgrades

@@ -1213,9 +1235,9 @@ lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'> &nb Bug 430. Rocca calculates inflection point parameters incorrectly

5.        -Bug 431. Error when trying to mark section of spectrogram to send to Bearing -Calculator module

+lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'>       Bug 431. Error when trying to mark section of spectrogram to +send to Bearing Calculator module

6.        @@ -1326,8 +1348,8 @@ Click Train Detector upgrades, including ability to import time chunks from csv file for batch processing.

3.        -Better display of microseconds in dialogs.

+lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'>       Better display of microseconds in dialogs.

4.        @@ -1431,9 +1453,9 @@ lang=EN-US> Matched template classifier extended to handle multiple templates.

5.        -New methods for handling and logging time offsets from the PC clock based -either on GPS NMEA data or on pings of an NTP time server.

+lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'>       New methods for handling and logging time offsets from the +PC clock based either on GPS NMEA data or on pings of an NTP time server.

6.        @@ -1489,8 +1511,8 @@ lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'> &nb

Upgrades

1.        -Added decimal degrees option to latitude/longitude dialog.

+lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'>       Added decimal degrees option to latitude/longitude dialog.

2.        @@ -1680,8 +1702,8 @@ lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'> &nb

10.        -Bug 376. Error when using a serialised data map which spans a period of -time in which Pamguard modules have changed.

+Bug 376. Error when using a serialised data map which spans a period of time +in which Pamguard modules have changed.

11.        @@ -1799,8 +1821,8 @@ and encouraged to manually fix the database.

-

Beta Version 2.00.12 -January 2018

+

Beta Version +2.00.12 January 2018

PAMGuard Version 2 contains major updates. You should read and understand the notes listed for

+

 

+ +

Older Versions

+

Version 1.15.11 May 2017

@@ -2093,8 +2120,8 @@ list grew to a ridiculous size. Code has been put in place to a) stop it happening again and b) to repair any configuration files which are corrupted. Corrupted files will be slow to load, slow to save and will be > several megabytes in size. It may be necessary to delete the PamguardSettings table in -any databases since these too may have become oversized which will slow down -viewer mode PAMGuard start-up.

+any databases since these too may have become oversized which will slow down viewer +mode PAMGuard start-up.

2.       @@ -2103,8 +2130,8 @@ after the contour was recalculated. This has been corrected.

3.       -Bug 310. When exiting Viewer mode, PAMGuard queries the user whether they -are sure they want to exit without saving even though they selected Bug 310. When exiting Viewer mode, PAMGuard queries the user whether +they are sure they want to exit without saving even though they selected Save and Exit. Corrected, and added an Exit without Save option.

@@ -2227,8 +2254,8 @@ sample rate.

font-stretch: normal'>       Bug 305. Date and Time not being correctly extracted from wav files created using SoundTrap recorders. Fixed by correctly -finding and unpacking information in the accompanying xml log files that come -with SoundTrap files.

+finding and unpacking information in the accompanying xml log files that come with +SoundTrap files.

Version 1.15.06 November 2016

@@ -2267,11 +2294,11 @@ was used. This is fixed.

5.          -Bug 295. If a click has a total length of a single sample, the code attempting -to estimate the time delay between channels would crash. This is now fixed. -This could only occur if both pre sample and post sample were set to 0 in the -click detector, which is generally not a good idea, so this bug may have been -there for some time, it's just that no one noticed before. Fixed

+Bug 295. If a click has a total length of a single sample, the code +attempting to estimate the time delay between channels would crash. This is now +fixed. This could only occur if both pre sample and post sample were set to 0 +in the click detector, which is generally not a good idea, so this bug may have +been there for some time, it's just that no one noticed before. Fixed

6.          @@ -2365,9 +2392,9 @@ automatic click train identification and tracking.

5.       -The automatic click train identification is now using -the same internal structures as the manual tracking, so it's possible to -combine automatic and manual tracking.

+The automatic click train identification is now using the +same internal structures as the manual tracking, so it's possible to combine +automatic and manual tracking.

6.       @@ -2384,9 +2411,9 @@ the future.

Logger Form Design

-

A GUI driven system for designing Logger forms has been released. -Currently, this feature has no online help, but is reasonably intuitive -compared to the old method of typing directly into the database.

+

A GUI driven system for designing Logger forms has been +released. Currently, this feature has no online help, but is reasonably +intuitive compared to the old method of typing directly into the database.

Improved Number handling

@@ -2447,9 +2474,8 @@ today. 

5.        -Bug 277. Text fields in classifier dialog were not large enough to -display times greater than 10ms. We have increased length of text fields in the -dialog.

+Bug 277. Text fields in classifier dialog were not large enough to display +times greater than 10ms. We have increased length of text fields in the dialog.

6.        @@ -2458,17 +2484,17 @@ changes in future releases. New PAMGuard releases will always be able to open older binary files, however, with previous PAMGuard releases if a newer file format was opened, then PAMGuard was unable to check that the file format was newer and would attempt to read the files and might even corrupt them. Now it -will recognise that it cannot open the files, display appropriate error messages -and not attempt to read the files. NOTE that at this time there are no planned -file format changes and that this is purely a future proofing exercise.

+will recognise that it cannot open the files, display appropriate error +messages and not attempt to read the files. NOTE that at this time there are no +planned file format changes and that this is purely a future proofing exercise.

7.        Bug 279. GUI Resizing: The whole PAMGuard GUI would suddenly resize to something very small when a dialog is opened. This has been traced to improper use of a common dialog component SourcePanel which tries to repack its parent -Window. Some programmers had inadvertently set it to repack the main PAMGuard -GUI instead. This has been Fixed.

+Window. Some programmers had inadvertently set it to repack the main PAMGuard GUI +instead. This has been Fixed.

8.        @@ -2542,16 +2568,16 @@ and datagram creation.

Version 1.15.00 February 2016

-

Beta Version 1.15.00 64 bit and Core -version 1.15.00 32 bit. Both using identical Java core software but linking to +

Beta Version 1.15.00 64 bit and Core version +1.15.00 32 bit. Both using identical Java core software but linking to different libraries for control of sound input devices.

This is the first release of a 64 bit -version of PAMGuard. As with the 32 bit version a number of C language libraries -are required to interface to external sound cards and other data acquisition -devices. These have been extensively tested on several different computers, but -may not be as stable as the 32 bit versions. Please report any problems -immediately to the PAMGuard team.

+version of PAMGuard. As with the 32 bit version a number of C language +libraries are required to interface to external sound cards and other data +acquisition devices. These have been extensively tested on several different +computers, but may not be as stable as the 32 bit versions. Please report any +problems immediately to the PAMGuard team.

Other Changes

@@ -2625,8 +2651,8 @@ name="_Toc312065299">Version 1.14.00 Beta, September 2015

The format of configuration files has changed for version -1.14.00. Older configurations will load with this new version, but configurations -saved with 1.14.00 may not open correctly with earlier versions.

+1.14.00. Older configurations will load with this new version, but +configurations saved with 1.14.00 may not open correctly with earlier versions.

PAMGuard Versions 1.14.00 and above will work with Java 8. PAMGuard will continue to work with Java 7, but support for Java 7 will be @@ -2693,9 +2719,9 @@ displaying in the viewer. This is now fixed.

3.        Bug 248. Crash in hydrophone array manager. Bug in -array manager would crash PAMGuard when the click detector was configured with more -channels than the sound acquisition system (almost impossible to achieve, but -someone managed it).

+array manager would crash PAMGuard when the click detector was configured with +more channels than the sound acquisition system (almost impossible to achieve, +but someone managed it).

4.        @@ -2789,9 +2815,9 @@ lang=EN-US>1. +tab of the spectrogram configuration dialog, and also right click on the +spectrogram and select to display the annotations. Annotations are saved to the +database so you will also need a database module in your configuration.  

2.              @@ -2814,9 +2840,9 @@ option with caution !

5.              -The Open Office Database system has been removed from the list of available -options since it is not reliable. If you require a free database solution we -recommend you use the MySql Community Server The Open Office Database system has been removed from the list of +available options since it is not reliable. If you require a free database +solution we recommend you use the MySql Community Server http://dev.mysql.com/downloads/mysql/

4.              -Bug 226. Spectrogram Mark Observer list doesn't refresh when modules -added or removed.

+Bug 226. Spectrogram Mark Observer list doesn't refresh when modules added +or removed.

5.              @@ -2896,9 +2922,9 @@ be specified by the user in the Rocca Parameters dialog Notes tab.

1.     Bug -209. Map zoom level. This was zoomed right into a range of about 1m when new maps -were created. This is now fixed and it starts with a default range of 10km on -the display.

+209. Map zoom level. This was zoomed right into a range of about 1m when new +maps were created. This is now fixed and it starts with a default range of 10km +on the display.

2.     Bug @@ -3187,8 +3213,8 @@ whistle.

. Did not affect band level calculations.
  • Bug in noise band monitor. Crashed when sample rate was exactly 2kHz. Fixed
  • -
  • Memory leak in click detector. Severe - memory leak when processing clicks in viewer mode now fixed.
  • +
  • Memory leak in click detector. + Severe memory leak when processing clicks in viewer mode now fixed.
  • Flickering of click display (http://sourceforge.net/p/pamguard/bugs/191/) now fixed.
  • @@ -3206,8 +3232,6 @@ whistle.

     

    -

    Older Versions

    -

    Version 1.12.00 Beta February 2013

    New Modules

    @@ -3245,14 +3269,14 @@ mode, making is easy to scroll through and view data for short time periods.

    GPS

    -

    Function to import GPS data from other -data sources for the PAMGuard viewer.

    +

    Function to import GPS data from +other data sources for the PAMGuard viewer.

    Database

    -

    Can now copy data from binary -storage to the database offline for any module having both binary and database -storage.

    +

    Can now copy data from binary storage +to the database offline for any module having both binary and database storage. +

    Can create a blank MS Access database (2007 and later *.accdb formats only).

    @@ -3351,12 +3375,12 @@ elements has been fixed.

    '         -Database Speed: A substantial rewriting of some of the indexing methods -in the database module has led to a significant increase in the speed at which data -are written to the database (orders of magnitude for large databases). This is -having a significant impact on the overall reliability of the software. Other -changes have increased the speed (again by orders of magnitude) at which data -are read back into PAMGuard when using the viewer.

    +Database Speed: A substantial rewriting of some of the indexing methods in +the database module has led to a significant increase in the speed at which +data are written to the database (orders of magnitude for large databases). +This is having a significant impact on the overall reliability of the software. +Other changes have increased the speed (again by orders of magnitude) at which +data are read back into PAMGuard when using the viewer.

    '         @@ -3444,9 +3468,9 @@ Symbol'>''         Offline event marking. Offline event marking similar to functionality in -RainbowClick is now available in the PAMGUARD viewer. Event summary data is -stored in the database and can also be exported to text files (e.g. for -importing into the Distance software). 

    +RainbowClick is now available in the PAMGUARD viewer. Event summary data is stored +in the database and can also be exported to text files (e.g. for importing into +the Distance software). 

    '         @@ -3459,8 +3483,8 @@ Symbol'>''         -Bearings can be calculated using the envelope of the waveform rather than -the full waveform. The waveform or envelope can also be filtered prior to +Bearings can be calculated using the envelope of the waveform rather +than the full waveform. The waveform or envelope can also be filtered prior to bearing calculation.

    ''         -Bearing ambiguity resolution for planar and volumetric arrays. New -features in array dialog for estimations of errors on array location. These -feed into to a maximum likelihood estimate of angles from small 2D or 3D sub -arrays to give two polar angle coordinates. this can be used to resolve left -right ambiguity and is implemented for both the click and the whistle/moan -detectors. As a result, the click detector bearing time display can now be set -to go from -180 to 180 degrees rather than 0 - 180 degrees. In this case, -clicks in the upper half of the bearing display will be to port and clicks in -the right half will be to starboard. As you pass a whale which is to port, the -clicks will move UP the display. In the long term, I hope to turn this display -around so that time is up the screen rather than across. 

    +Bearing ambiguity resolution for planar and volumetric arrays. New features +in array dialog for estimations of errors on array location. These feed into to +a maximum likelihood estimate of angles from small 2D or 3D sub arrays to give +two polar angle coordinates. this can be used to resolve left right ambiguity +and is implemented for both the click and the whistle/moan detectors. As a +result, the click detector bearing time display can now be set to go from -180 +to 180 degrees rather than 0 - 180 degrees. In this case, clicks in the upper +half of the bearing display will be to port and clicks in the right half will +be to starboard. As you pass a whale which is to port, the clicks will move UP +the display. In the long term, I hope to turn this display around so that time +is up the screen rather than across. 

    Small features and bug fixes

    @@ -4110,10 +4134,10 @@ help pages

    Bug Fixes

    -

    Memory leak caused by Night / Day colour manager now fixed. -This would cause memory leaks when multiple files were being analysed off-line -and would eventually crash PAMGUARD. The way that colours are managed in -PAMGUARD has been rewritten. 

    +

    Memory leak caused by Night / Day colour manager now fixed. This +would cause memory leaks when multiple files were being analysed off-line and +would eventually crash PAMGUARD. The way that colours are managed in PAMGUARD +has been rewritten. 

    Some issues with Swing fixed that might have been causing hang ups on startup especially on Macs/Linux machines

    @@ -4184,8 +4208,8 @@ file)

    Changes

    -

    The User Input module (for text entry of information by the -user) has been moved from the Displays sub menu of the Add Modules menu, to +

    The User Input module (for text entry of information by the user) +has been moved from the Displays sub menu of the Add Modules menu, to Utilities. This will not affect how existing settings files are loaded.

    Multi-screen environments.

    @@ -4356,8 +4380,8 @@ channels or textual content change.

    '         -Model viewer. Have stopped it from jumping on top of the main PAMGUARD - display when dialogs are closed.

    +Model viewer. Have stopped it from jumping on top of the main PAMGUARD  display +when dialogs are closed.

    '         @@ -4688,12 +4712,12 @@ and Ishmael-type detectors and localisers.

    Information from above modules can be displayed on configurable user displays which support real time scrolling spectrograms and radar displays. Detection and localisation information can be optionally -displayed on the map display.Map enhancements include improved scrolling -whereby the user can click and drag to pan the area. PamGuard can now interface -with MySQL database servers and users can easily select which information is -logged. (This replaces the previous 'flat-file' logging feature). A simulation -module allows virtual vocalising animals to be placed on the map to assist in -training and development. Extensive online user help has been added to PamGuard +displayed on the map display.Map enhancements include improved scrolling whereby +the user can click and drag to pan the area. PamGuard can now interface with +MySQL database servers and users can easily select which information is logged. +(This replaces the previous 'flat-file' logging feature). A simulation module +allows virtual vocalising animals to be placed on the map to assist in training +and development. Extensive online user help has been added to PamGuard Application

    0.03b - first version used in a real 'at sea' environment.18/08/06

    diff --git a/src/Acquisition/FileInputSystem.java b/src/Acquisition/FileInputSystem.java index 71f0e24a..771af349 100644 --- a/src/Acquisition/FileInputSystem.java +++ b/src/Acquisition/FileInputSystem.java @@ -627,7 +627,7 @@ public class FileInputSystem extends DaqSystem implements ActionListener, PamSe "

    Please check to ensure that the file exists, and that the path entered in PAMGuard is correct.

    " + "

    Note this error may also indicate that the file is corrupt and unreadable by PAMGuard.

    "; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help); return false; } diff --git a/src/PamController/PSFXReadWriter.java b/src/PamController/PSFXReadWriter.java index 50fbaac8..b3c07cd0 100644 --- a/src/PamController/PSFXReadWriter.java +++ b/src/PamController/PSFXReadWriter.java @@ -178,7 +178,7 @@ public class PSFXReadWriter { * occurr when running under PAMDog control. */ if (pamBuoyGlobals.getNetworkControlPort() == null) { - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help); } else { /* diff --git a/src/PamController/PamController.java b/src/PamController/PamController.java index b15d0ee1..af85a10d 100644 --- a/src/PamController/PamController.java +++ b/src/PamController/PamController.java @@ -2731,7 +2731,12 @@ public class PamController implements PamControllerInterface, PamSettings { @Override public GuiFrameManager getGuiFrameManager() { - return (GuiFrameManager) guiFrameManager; + if (guiFrameManager instanceof GuiFrameManager) { + return (GuiFrameManager) guiFrameManager; + } + else { + return null; + } } public void sortFrameTitles(){ diff --git a/src/PamController/PamSettingManager.java b/src/PamController/PamSettingManager.java index 7cc187f0..1e4f1d7a 100644 --- a/src/PamController/PamSettingManager.java +++ b/src/PamController/PamSettingManager.java @@ -1,19 +1,19 @@ /* PAMGUARD - Passive Acoustic Monitoring GUARDianship. - * To assist in the Detection Classification and Localisation + * To assist in the Detection Classification and Localisation * of marine mammals (cetaceans). - * - * Copyright (C) 2006 - * + * + * Copyright (C) 2006 + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -100,10 +100,10 @@ import amplifier.AmpParameters; /** * @author Doug Gillespie - * + * * Singleton class for managing Pam settings - where and how they are stored in * a persistent way between runs. - * + * * Any class that wants is settings saved should register with the * PamSettingsManager. *

    @@ -122,8 +122,8 @@ import amplifier.AmpParameters; * 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. - * - * + * + * */ public class PamSettingManager { @@ -135,34 +135,34 @@ public class PamSettingManager { /** * List of modules that have / want PAMGUARD Settings - * which get stored in the psf file and / or the database store. + * which get stored in the psf file and / or the database store. */ private ArrayList owners; /** * List of modules that specifically use settings from the database - * storage. + * storage. */ private ArrayList databaseOwners; /** * List of modules that are stored globally on the PC - * with a single common psf type file. + * with a single common psf type file. */ private ArrayList globalOwners; private ArrayList globalSettings; /** - * List of settings used by 'normal' modules. + * List of settings used by 'normal' modules. */ private ArrayList initialSettingsList; /** - * List of settings used specifically by databases. + * List of settings used specifically by databases. * This list never get's stored anywhere, but is just held - * in memory so that the database identified at startup in - * viewer and mixed modes gets reloaded later on . + * in memory so that the database identified at startup in + * viewer and mixed modes gets reloaded later on . */ private ArrayList databaseSettingsList; @@ -172,7 +172,7 @@ public class PamSettingManager { static public final String fileEndx = "psfx"; static public final String fileEndXML = "psfxml"; private static boolean saveAsPSFX = true; - + static public String getCurrentSettingsFileEnd() { if (saveAsPSFX) { return fileEndx; @@ -183,7 +183,7 @@ public class PamSettingManager { } /** - * Name of the file that contains a list of recent psf files. + * Name of the file that contains a list of recent psf files. */ transient private final String settingsListFileName = "PamSettingsFilesUID"; @@ -206,13 +206,13 @@ public class PamSettingManager { public static final int LIST_UNITS = 0x1; /** - * Identifier for modules which are part of the database system. + * Identifier for modules which are part of the database system. */ public static final int LIST_DATABASESTUFF = 0x2; /** - * Stuff which is global to the computer system (at the user level). - * Invented for colour settings, might extend to other things too. + * Stuff which is global to the computer system (at the user level). + * Invented for colour settings, might extend to other things too. */ public static final int LIST_SYSTEMGLOBAL = 0x4; @@ -221,7 +221,7 @@ public class PamSettingManager { */ static private final int SAVE_PSF = 0x1; /** - * Save settings to database tables (if available). + * Save settings to database tables (if available). */ static private final int SAVE_DATABASE = 0x2; @@ -243,7 +243,7 @@ public class PamSettingManager { private boolean programStart = true; private SettingsFileData settingsFileData; - + private PamSettingManager() { owners = new ArrayList(); @@ -274,9 +274,9 @@ public class PamSettingManager { * Flag to indicate that initialisation of PAMGUARD has completed. */ private boolean initializationComplete = false; - + /** - * Called everytime anything in the model changes. + * Called everytime anything in the model changes. * @param changeType type of change */ public void notifyModelChanged(int changeType) { @@ -286,14 +286,14 @@ public class PamSettingManager { } /** - * Register a PAMGAURD module that wants to store settings in a + * 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. - *

    Normally, all modules will + * in the database settings table. + *

    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 + * 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 + * implemnt PamSettings so that different settings for different bits of * a PamControlledUnit are stored separately. * @see PamSettings * @see PamControlledUnit @@ -306,15 +306,15 @@ public class PamSettingManager { } /** - * Register modules that have settings information that - * should be stored in serialised form in - * psf files and database Pamguard_Settings tables. + * Register modules that have settings information that + * should be stored in serialised form in + * psf files and database Pamguard_Settings tables. * @param pamUnit Unit containing the settings * @param whichLists which lists to store the settings in.

    - * N.B. These are internal lists and not the external storage. Basically + * 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 - * @return true if settings registered sucessfully. + * everything else (including the normal database) should go to LISTS_UNITS + * @return true if settings registered sucessfully. */ public boolean registerSettings(PamSettings pamUnit, int whichLists) { @@ -342,10 +342,10 @@ public class PamSettingManager { } /** - * Find settings for a particular user in one or more lists. - * @param user PamSettings user. - * @param whichLists lists to search - * @return settings object. + * Find settings for a particular user in one or more lists. + * @param user PamSettings user. + * @param whichLists lists to search + * @return settings object. */ private PamControlledUnitSettings findSettings(PamSettings user, int whichLists) { PamControlledUnitSettings settings = null; @@ -373,18 +373,18 @@ public class PamSettingManager { } /** * Find settings in a list of settings, ignoring settings which have - * already been used by a module. + * already been used by a module. * @param settingsList settings list - * @param usedSettings list of settings that have already been used. - * @param user module that uses the settings. - * @return Settings object. + * @param usedSettings list of settings that have already been used. + * @param user module that uses the settings. + * @return Settings object. */ - private PamControlledUnitSettings findSettings(ArrayList settingsList, + private PamControlledUnitSettings findSettings(ArrayList settingsList, boolean[] usedSettings, PamSettings user) { if (settingsList == null) return null; // go through the list and see if any match this module. Avoid repeats. for (int i = 0; i < settingsList.size(); i++) { - if (usedSettings != null && usedSettings[i]) continue; + if (usedSettings != null && usedSettings[i]) continue; if (isSettingsUnit(user, settingsList.get(i))) { if (usedSettings != null) { usedSettings[i] = true; @@ -393,10 +393,10 @@ public class PamSettingManager { } } /* - * To improve complex module loading where settings may be saved by multiple sub-modules, in + * To improve complex module loading where settings may be saved by multiple sub-modules, in * July 2015 many modules which had fixed settings had their settings names and types changed ! * Therefore these modules won't have found their settings on the first go, so need to also check - * against the alternate names defined for each class. + * against the alternate names defined for each class. * It should be possible to work out from the settingsUser.Class what changes may have been made ! */ SettingsNameChange otherName = SettingsNameChanger.getInstance().findNameChange(user); @@ -404,7 +404,7 @@ public class PamSettingManager { return null; } for (int i = 0; i < settingsList.size(); i++) { - if (usedSettings != null && usedSettings[i]) continue; + if (usedSettings != null && usedSettings[i]) continue; if (isSettingsUnit(otherName, settingsList.get(i))) { if (usedSettings != null) { usedSettings[i] = true; @@ -419,7 +419,7 @@ public class PamSettingManager { /** * Searches a list of settings for settings with a - * specific type. + * specific type. * @param unitType * @return PamControlledUnitSettings or null if none found * @see PamControlledUnitSettings @@ -437,8 +437,8 @@ public class PamSettingManager { } /** - * Find settings in a list of settings by name and by type. - * @param settingsList settings list to search + * Find settings in a list of settings by name and by type. + * @param settingsList settings list to search * @param unitType unit name * @param unitName unit type * @return settings object @@ -468,11 +468,11 @@ public class PamSettingManager { } /** - * Find a settings owner for a type, name and class. + * Find a settings owner for a type, name and class. * @param unitType unit Type * @param unitName unit Name * @param unitClass unit Class - * @return Settings owner or null. + * @return Settings owner or null. */ public PamSettings findSettingsOwner(String unitType, String unitName, String unitClassName) { for (PamSettings owner:owners) { @@ -491,8 +491,8 @@ public class PamSettingManager { /** * Call just before PAMGUARD exits to save the settings - * either to psf and / or database tables. - * @return true if settings saved sucessfully. + * either to psf and / or database tables. + * @return true if settings saved sucessfully. */ public boolean saveFinalSettings() { int runMode = PamController.getInstance().getRunMode(); @@ -511,9 +511,9 @@ public class PamSettingManager { } /** - * Save settings to a psf file and / or the database tables. + * Save settings to a psf file and / or the database tables. * @param saveWhere - * @return true if sucessful + * @return true if sucessful */ public boolean saveSettings(int saveWhere) { @@ -542,7 +542,7 @@ public class PamSettingManager { } /** * Always save the settings file data (list of recent files) since it includes - * static information such as whether to show day tips. + * static information such as whether to show day tips. */ saveSettingsFileData(); @@ -560,8 +560,8 @@ public class PamSettingManager { } /** - * Save configuration settings to the default (most recently used) psf file. - * @return true if successful. + * Save configuration settings to the default (most recently used) psf file. + * @return true if successful. */ public boolean saveSettingsToFile(String fileName) { if (saveAsPSFX) { @@ -587,7 +587,7 @@ public class PamSettingManager { ObjectOutputStream outStream = openOutputFile(setFile.getAbsolutePath()); for (PamSettings gs:globalOwners) { - PamControlledUnitSettings pus = new PamControlledUnitSettings(gs.getUnitType(), + PamControlledUnitSettings pus = new PamControlledUnitSettings(gs.getUnitType(), gs.getUnitName(), gs.getClass().getName(), gs.getSettingsVersion(), gs.getSettingsReference()); try { outStream.writeObject(pus); @@ -605,7 +605,7 @@ public class PamSettingManager { ObjectInputStream ois = null; boolean ok= true; try { - ois = new ObjectInputStream(new FileInputStream(setFile)); + ois = new ObjectInputStream(new FileInputStream(setFile)); } catch (IOException e) { ok = false; @@ -637,8 +637,8 @@ public class PamSettingManager { } /** - * Save configuration settings to the default (most recently used) psf file. - * @return true if successful. + * Save configuration settings to the default (most recently used) psf file. + * @return true if successful. */ public boolean saveSettingsToPSFFile(String fileName) { @@ -651,9 +651,9 @@ public class PamSettingManager { for (int i = 0; i < owners.size(); i++) { pamSettingsList .add(new PamControlledUnitSettings(owners.get(i) - .getUnitType(), owners.get(i).getUnitName(), + .getUnitType(), owners.get(i).getUnitName(), owners.get(i).getClass().getName(), - owners.get(i).getSettingsVersion(), + owners.get(i).getSettingsVersion(), owners.get(i).getSettingsReference())); } int nUsed = pamSettingsList.size(); @@ -667,14 +667,14 @@ public class PamSettingManager { if (initialSettingsList != null) { for (int i = 0; i < initialSettingsList.size(); i++) { if (settingsUsed != null && settingsUsed.length > i && settingsUsed[i]) continue; - + // if this is a duplicate of something already in the list, warn the user and find out if they want to remove it if (thisIsADuplicate(pamSettingsList, initialSettingsList.get(i))) { if (firstDuplicateFound) { firstDuplicateFound = false; String msg = "Duplicate settings have been found in the psf file. Please select whether to keep them in the psf, or to" + " delete them. Duplicate settings will not cause Pamguard to crash, however they will enlarge the psf file over time."; - int ans; + int ans; if (PamGUIManager.getGUIType()==PamGUIManager.FX) ans = WarnOnce.showWarningFX(PamController.getInstance().getGuiManagerFX().getMainScene().getOwner(), "Duplicate settings encountered", PamUtilsFX.htmlToNormal(msg), AlertType.WARNING, null, null, "Keep Duplicates", "Delete Duplicates"); else ans = WarnOnce.showWarning(null, "Duplicate settings encountered", msg, WarnOnce.OK_CANCEL_OPTION, null, null,"Keep Duplicates", "Delete Duplicates"); @@ -685,7 +685,7 @@ public class PamSettingManager { if (purgeDuplicates) continue; pamSettingsList.add(initialSettingsList.get(i)); } - + // if this is not a duplicate, go ahead and add it to the list else { pamSettingsList.add(initialSettingsList.get(i)); @@ -714,7 +714,7 @@ public class PamSettingManager { return false; } - // try { // experimenting with xml output. + // try { // experimenting with xml output. // FileOutputStream fos = new FileOutputStream("pamguard.xml"); // XMLEncoder xe = new XMLEncoder(fos); // for (int i = 0; i < nUsed; i++) { @@ -738,7 +738,7 @@ public class PamSettingManager { /** * Checks if the PamControlledSettings object is already in the settings ArrayList. Comparison is done by - * checking the unit type and unit name. + * checking the unit type and unit name. * @param pamSettingsList the ArrayList containing the PamControlledUnitSettings * @param settingToCheck the PamControlledUnitSettings to check * @return true if it is in the list, false if not @@ -756,7 +756,7 @@ public class PamSettingManager { } /** - * Save configuration settings to a PSFX file (XML). + * Save configuration settings to a PSFX file (XML). * @return true if successful. */ public boolean saveSettingsToXMLFile(File file) { @@ -771,9 +771,9 @@ public class PamSettingManager { for (int i = 0; i < owners.size(); i++) { pamSettingsList .add(new PamControlledUnitSettings(owners.get(i) - .getUnitType(), owners.get(i).getUnitName(), - owners.get(i).getClass().getName(), - owners.get(i).getSettingsVersion(), + .getUnitType(), owners.get(i).getUnitName(), + owners.get(i).getClass().getName(), + owners.get(i).getSettingsVersion(), owners.get(i).getSettingsReference())); } int nUsed = pamSettingsList.size(); @@ -824,16 +824,16 @@ public class PamSettingManager { // e.printStackTrace(); // } // System.out.println("done!"); - // + // // } System.out.println("The code for objectToXMLFile(Object serialisableObject, File file) has been commented out!!"); } /** - * Load the PAMGAURD settings either from psf file or from - * a database, depending on the run mode and type of settings required. + * Load the PAMGAURD settings either from psf file or from + * a database, depending on the run mode and type of settings required. * @param runMode - * @return OK if load was successful. + * @return OK if load was successful. */ public int loadPAMSettings(int runMode) { int ans = LOAD_SETTINGS_OK; @@ -857,7 +857,7 @@ public class PamSettingManager { ans = loadNormalSettings(); break; default: - return LOAD_SETTINGS_CANCEL; + return LOAD_SETTINGS_CANCEL; } if (ans == LOAD_SETTINGS_OK) { initialiseRegisteredModules(); @@ -866,36 +866,36 @@ public class PamSettingManager { } /** - * Load settings perfectly 'normally' from a psf file. - * @return OK whether or not any settings were loaded. + * Load settings perfectly 'normally' from a psf file. + * @return OK whether or not any settings were loaded. */ private int loadNormalSettings() { return loadPSFSettings(); } /** - * Load settings for viewer mode. These must come from - * an old PAMGUARD database containing settings information. - * @return true if settings loaded sucessfully. + * Load settings for viewer mode. These must come from + * an old PAMGUARD database containing settings information. + * @return true if settings loaded sucessfully. */ private int loadViewerSettings() { return loadDBSettings(); } /** - * Load settings for mixed mode. These must come from - * an old PAMGUARD database containing settings information. - * @return true if settings loaded sucessfully. + * Load settings for mixed mode. These must come from + * an old PAMGUARD database containing settings information. + * @return true if settings loaded sucessfully. */ private int loadMixedModeSettings() { return loadDBSettings(); } /** - * Some modules may have already registered before the + * 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. + * as soon as they are loaded which sends settings to + * all modules in the list. */ private void initialiseRegisteredModules() { if (owners == null) { @@ -920,9 +920,9 @@ public class PamSettingManager { /** * Open the file that contains a list of files and optionally open a dialog - * giving the list of recent files. + * giving the list of recent files. *

    - * Unfortunately, as soon as this gets called the first time, it tries to + * Unfortunately, as soon as this gets called the first 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 @@ -936,14 +936,14 @@ public class PamSettingManager { } if (loadingLocalSettings) return LOAD_SETTINGS_OK; if ( - // settingsFileData.showFileList && + // settingsFileData.showFileList && programStart) { SettingsFileData newData = showSettingsDailog(settingsFileData); if (newData != null) { settingsFileData = newData.clone(); /* * Save the settings file data immediately so that if we crash, this file - * is still at the top of the list next time we run. + * is still at the top of the list next time we run. */ saveSettingsFileData(); } @@ -954,19 +954,19 @@ public class PamSettingManager { } File ff = settingsFileData.getFirstFile(); } - + // if we are running a psf remotely, add it to the SettingsFileData list else { setDefaultFile(PamSettingManager.remote_psf); } initialSettingsList = loadSettingsFromFile(); - //XMLSettings + //XMLSettings // initialSettingsList = loadSettingsFromXMLFile(); /*TODO FIXME -implement this properly (see also PamGui-line 478) to enable saving menu item * so far it works for some settings- one it doesn't work for is File Folder Acquisition - * + * * output from loading XML * ------------------------------------ PAMGUARD Version 1.11.02j branch SMRU @@ -980,7 +980,7 @@ public class PamSettingManager { os.version 6.1 java.library.path lib For further information and bug reporting visit www.pamguard.org - If possible, bug reports and support requests should + If possible, bug reports and support requests should contain a copy of the full text displayed in this window. (Windows users right click on window title bar for edit / copy options) @@ -1005,7 +1005,7 @@ public class PamSettingManager { * ------------------------------------- * Looks like not ALL information has been stored correctly-might be best to contact XStream about resolution - * + * */ @@ -1017,7 +1017,7 @@ public class PamSettingManager { * Load data from settings files. *

    * This is just the general data - the list of recently used - * psf files and recent database files. + * psf files and recent database files. */ public boolean loadLocalSettings() { @@ -1028,25 +1028,25 @@ public class PamSettingManager { if (PamSettingManager.RUN_REMOTE == false) { if (settingsFileData != null) { TipOfTheDayManager.getInstance().setShowAtStart(settingsFileData.showTipAtStartup); - if (settingsFileData.showTipAtStartup) { + if (settingsFileData.showTipAtStartup) { if (PamGUIManager.isSwing()) { TipOfTheDayManager.getInstance().showTip(null, null); } } } } - + // if the scaling factor = 0 (happens on first load), set it to 1. Then scale the display if (settingsFileData.getScalingFactor()==0.0) { settingsFileData.setScalingFactor(1.0); } scaleDisplay(settingsFileData.getScalingFactor()); - - - boolean ok = true; // always ok if non - database settings are used. + + + boolean ok = true; // always ok if non - database settings are used. // // if (PamController.getInstance().getRunMode() != PamController.RUN_NORMAL) { - // ok = loadDBSettings(); + // ok = loadDBSettings(); // } loadingLocalSettings = false; @@ -1059,9 +1059,9 @@ public class PamSettingManager { * Adjust the size of the text by the scaleFactor variable. This was added in response to the issue of PAMGuard not * scaling properly on 4K monitors. Things that aren't affected by this code: buttons and icons, the window title font, * the time font, and the html in the help files. - * + * * In order to finish this off, put more work into scaling the button images. - * + * * @param scalingFactor */ private void scaleDisplay(double scalingFactor) { @@ -1104,14 +1104,14 @@ public class PamSettingManager { "Tree.font", "Viewport.font" }; - //TODO - does work with NIMBUS look and feel. + //TODO - does work with NIMBUS look and feel. for (int i=0; i ownersList, String unitType, String unitName) { PamSettings owner; @@ -1234,8 +1234,8 @@ public class PamSettingManager { } /** - * Load PAMGUARD settings from a psf OR a psfx file. - * @return Array list of settings. + * Load PAMGUARD settings from a psf OR a psfx file. + * @return Array list of settings. */ private ArrayList loadSettingsFromFile() { String inputFile = getSettingsFileName(); @@ -1257,13 +1257,13 @@ public class PamSettingManager { return null; } /** - * Load PAMGUARD settings from a psf file. - * @return Array list of settings. + * Load PAMGUARD settings from a psf file. + * @return Array list of settings. */ private ArrayList loadSettingsFromPSFFile() { - ArrayList newSettingsList = + ArrayList newSettingsList = new ArrayList(); PamControlledUnitSettings newSetting; @@ -1292,17 +1292,17 @@ public class PamSettingManager { "

    The module may or may not load, and even if it " + "loads it may have lost it's settings. Please check before performing any analysis.

    "; String help = null; - - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help); - + + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help); + break; } catch (IOException io){ System.out.println(io.getMessage()); /** - * DG 10/8/2015 There is a break here, basically if I change the + * DG 10/8/2015 There is a break here, basically if I change the * serialVerionUID of any class it will get stuck in an infinite loop - * unless I break - so don't ever change serialVersionUID's !!!!! + * unless I break - so don't ever change serialVersionUID's !!!!! */ break; } @@ -1313,7 +1313,7 @@ public class PamSettingManager { "It is likely that an older version of Java is trying to load a class which is from a newer version. " + "This module will not be loaded, and will be removed from the psf file to prevent instabilities."; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help); System.err.println("Exception while loading " + Ex.getMessage()); } catch (ClassNotFoundException Ex){ @@ -1328,7 +1328,7 @@ public class PamSettingManager { "depending on which modules are being used and if they've changed between versions. It is recommended that you " + "check all module configuration parameters to verify the information is still accurate, prior to running. "; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help, Ex); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help, Ex); } // print and continue - there may be other things we can deal with. @@ -1342,7 +1342,7 @@ public class PamSettingManager { "support@pamguard.org.

    " + "This module will not be loaded, and will be removed from the psf file to prevent instabilities."; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help, Ex); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help, Ex); System.err.println("Exception while loading " + Ex.getMessage()); } } @@ -1378,8 +1378,8 @@ public class PamSettingManager { //XMLSettings // /** - // * Load PAMGUARD settings from a psf file. - // * @return Array list of settings. + // * Load PAMGUARD settings from a psf file. + // * @return Array list of settings. // */ // private ArrayList loadSettingsFromXMLFile() { // @@ -1420,24 +1420,24 @@ public class PamSettingManager { /** - * Quick print list of all settings to work out wtf is going on. + * Quick print list of all settings to work out wtf is going on. * @param newSettingsList */ private void listSettings( ArrayList newSettingsList) { int iSet = 0; for (PamControlledUnitSettings set:newSettingsList) { - System.out.printf("%02d Type %s Name %s Class %s\n", iSet++, set.getUnitType(), + System.out.printf("%02d Type %s Name %s Class %s\n", iSet++, set.getUnitType(), set.getUnitName(), set.getSettings().getClass().toString()); } } - + /** * Similar to listSettings, but instead of listing all modules only list them once but with a note if * there are duplicates - * + * * @param newSettingsList */ private boolean summarizeSettings(ArrayList newSettingsList) { @@ -1457,19 +1457,19 @@ public class PamSettingManager { alreadySeen[j] = true; } } -// System.out.printf("Type: %s; Name: %s; Class: %s; is found in psf settings %d time(s)\n", set.getUnitType(), +// System.out.printf("Type: %s; Name: %s; Class: %s; is found in psf settings %d time(s)\n", set.getUnitType(), // set.getUnitName(), set.getSettings().getClass().toString(), count); if (count>1) duplicatesFound=true; } return duplicatesFound; } - + /** * See if a particular PamControlledUnitSettings object is the right one - * for a particular module that wants some settings. + * for a particular module that wants some settings. * @param settingsUser User of settings - * @param settings Settings object. - * @return true if matched. + * @param settings Settings object. + * @return true if matched. */ public boolean isSettingsUnit(PamSettings settingsUser, PamControlledUnitSettings settings) { if (settings.getUnitName() == null || settingsUser.getUnitName() == null) return false; @@ -1477,10 +1477,10 @@ public class PamSettingManager { if (settings.getUnitName().equals(settingsUser.getUnitName()) - && settings.getUnitType().equals(settingsUser.getUnitType()) + && settings.getUnitType().equals(settingsUser.getUnitType()) && settings.versionNo == settingsUser.getSettingsVersion()){ return true; - } + } return false; } @@ -1488,10 +1488,10 @@ public class PamSettingManager { /** * Name check used when the initial setting search failed but it's been found that there has been a type - * name change within the settings user. + * name change within the settings user. * @param otherName alternate name information - * @param settings PAm Settings. - * @return true if seem to be the same. + * @param settings PAm Settings. + * @return true if seem to be the same. */ private boolean isSettingsUnit(SettingsNameChange otherName, PamControlledUnitSettings settings) { if (otherName.getModuleClass().getName().equals(settings.getOwnerClassName())) { @@ -1507,8 +1507,8 @@ public class PamSettingManager { } /** - * Open psf file for settings serialised output. - * @return stream handle. + * Open psf file for settings serialised output. + * @return stream handle. */ public ObjectOutputStream openOutputFile(String outputFile) { try { @@ -1522,7 +1522,7 @@ public class PamSettingManager { /** * Open psf file for settings input.
    does no work with psfx files - * @return stream handle. + * @return stream handle. */ private ObjectInputStream openInputFile() { // System.out.println("Loading settings from " + getSettingsFileName()); @@ -1544,7 +1544,7 @@ public class PamSettingManager { // +"\nThis is expected on first use." // , // "PamSettingManager", - // JOptionPane.WARNING_MESSAGE); + // JOptionPane.WARNING_MESSAGE); // userNotifiedAbsentSettingsFile= true; // } String msg = "You are opening new configuration file: " + getSettingsFileName(); @@ -1561,13 +1561,13 @@ public class PamSettingManager { // /** // * Returns total gobbledygook - need to improve the way - // * PAMGAURD creates new psf files. - // * @return lies. + // * PAMGAURD creates new psf files. + // * @return lies. // */ // private ObjectInputStream openInputFileResource() { // try { // return new ObjectInputStream( //new FileInputStream( - // ClassLoader.getSystemResourceAsStream("DefaultPamguardSettings.psf")); + // ClassLoader.getSystemResourceAsStream("DefaultPamguardSettings.psf")); // } catch (Exception Ex) { //// //Ex.printStackTrace(); //// System.out.println("Serialized default settings file not found!"); @@ -1583,8 +1583,8 @@ public class PamSettingManager { // } /** - * The settings list file is a file containing a list of recently - * used psf files. + * The settings list file is a file containing a list of recently + * used psf files. * @return The settings list file */ private File getSettingsListFile() { @@ -1604,7 +1604,7 @@ public class PamSettingManager { /** * Get a file for global settings - * @return File for global settings storage. + * @return File for global settings storage. */ private File getGlobalSettingsFile() { String fileName = pamguard.Pamguard.getSettingsFolder() + File.separator + gloablListfileName + settingsListFileEnd; @@ -1612,7 +1612,7 @@ public class PamSettingManager { } /** - * Get a list of recently used databases. + * Get a list of recently used databases. * @return list of recently used databases */ private File getDatabaseListFile() { @@ -1621,13 +1621,13 @@ public class PamSettingManager { } /** - * Get the settings folder name and if necessary, - * create the folder since it may not exist. - * + * Get the settings folder name and if necessary, + * create the folder since it may not exist. + * * 2019/10/02 mo * MOVED TO pamguard.Pamguard AS A STATIC FUNCTION, SO THAT WE CAN ACCESS * IT FOR THE LOG FILE WHEN PAMGUARD FIRST STARTS - * + * * @return folder name string, (with no file separator on the end) */ // private String getSettingsFolder() { @@ -1638,24 +1638,24 @@ public class PamSettingManager { // if (f.exists() == false) { // f.mkdirs(); // } -// // default folder doesn't work for psf since it saves the settings file back into the wrong place. +// // default folder doesn't work for psf since it saves the settings file back into the wrong place. //// String defFolder = PamFolders.getDefaultProjectFolder(); // return settingsFolder; // } /** * Now that the database is becoming much more fundamental to settings - * storage and retrieval, the latest database settings should go into + * storage and retrieval, the latest database settings should go into * the main settings file. This contains a list of recent databases. The trouble is, - * the settings are spread amongst several different settings object (e.g. one that - * tells us what type of database, another that tells us a list of recent databases - * for a specific database type, etc. + * the settings are spread amongst several different settings object (e.g. one that + * tells us what type of database, another that tells us a list of recent databases + * for a specific database type, etc. *

    * 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. - * + * the general list as well as the specific data file. + * */ public boolean loadSettingsFileData() { ObjectInputStream is = null; @@ -1699,25 +1699,25 @@ public class PamSettingManager { * will do is copy all psf files from the installed directory * over into the settingsFolder and then populate the list * in a settings list file so that users get a reasonably - * coherent startup experience. + * coherent startup experience. */ private void createSettingsListFile() { /** - * List all psf files in the program folder. - * I think that we should already be working in that folder, - * so can just list the files. + * List all psf files in the program folder. + * I think that we should already be working in that folder, + * so can just list the files. */ settingsFileData = new SettingsFileData(); PamFileFilter psfFilter = new PamFileFilter("psf files", ".psf"); - - // if we're running the beta version, also add in psfx files. To test for beta, check if + + // if we're running the beta version, also add in psfx files. To test for beta, check if // the version number starts with anything besides a 1 if (!PamguardVersionInfo.version.startsWith("1")) { psfFilter.addFileType(".psfx"); } psfFilter.setAcceptFolders(false); String settingsFolder = pamguard.Pamguard.getSettingsFolder() + File.separator; - // list files in the current folder. + // list files in the current folder. String userDir = System.getProperty("user.dir"); File folder = new File(userDir); File[] psfFiles = folder.listFiles(psfFilter); @@ -1729,7 +1729,7 @@ public class PamSettingManager { File newFile = new File(settingsFolder + File.separator + aFile.getName()); // aFile.renameTo(newFile); copyFile(aFile, newFile); - // then add it to the list. + // then add it to the list. settingsFileData.setFirstFile(newFile); } } @@ -1763,7 +1763,7 @@ public class PamSettingManager { } /** - * Save the list of recently used settings files. + * Save the list of recently used settings files. * @return true if write OK. */ private boolean saveSettingsFileData() { @@ -1794,9 +1794,9 @@ public class PamSettingManager { } /** - * Loads the details of the last database to be opened. This will + * Loads the details of the last database to be opened. This will * probably be in the form of multiple serialised objects since - * the database information is spread amongst several plug in sub-modules. + * the database information is spread amongst several plug in sub-modules. * @return true if settings data loaded ok */ private boolean loadDatabaseFileData() { @@ -1841,8 +1841,8 @@ public class PamSettingManager { return true; } /** - * Save the details of the most recently used database. - * @return true if successful. + * Save the details of the most recently used database. + * @return true if successful. */ private boolean saveDatabaseFileData() { @@ -1858,7 +1858,7 @@ public class PamSettingManager { for (int i = 0; i < databaseOwners.size(); i++) { dbOwner = databaseOwners.get(i); aSet = new PamControlledUnitSettings(dbOwner.getUnitType(), - dbOwner.getUnitName(), dbOwner.getClass().getName(), + dbOwner.getUnitName(), dbOwner.getClass().getName(), dbOwner.getSettingsVersion(), dbOwner.getSettingsReference()); databaseSettingsList.add(aSet); } @@ -1870,15 +1870,15 @@ public class PamSettingManager { return false; } - // write out the settings for all units in the general owners list. + // write out the settings for all units in the general owners list. ArrayList generalSettingsList; generalSettingsList = new ArrayList(); for (int i = 0; i < databaseOwners.size(); i++) { generalSettingsList .add(new PamControlledUnitSettings(databaseOwners.get(i) - .getUnitType(), databaseOwners.get(i).getUnitName(), - databaseOwners.get(i).getClass().getName(), - databaseOwners.get(i).getSettingsVersion(), + .getUnitType(), databaseOwners.get(i).getUnitName(), + databaseOwners.get(i).getClass().getName(), + databaseOwners.get(i).getSettingsVersion(), databaseOwners.get(i).getSettingsReference())); } try { @@ -1904,13 +1904,13 @@ public class PamSettingManager { * Get the most recently used settings file name. We have added a switch in here * to allow for the direct setting of the psf used from the command line. This * can be used in remote on non remote deployments. - * @return File name string. + * @return File name string. */ public String getSettingsFileName() { if (PamSettingManager.remote_psf != null) { // System.out.println("Automatically loading settings from " + remote_psf); return remote_psf; - } + } else { if (settingsFileData == null || settingsFileData.getFirstFile() == null) { return null; @@ -1938,7 +1938,7 @@ public class PamSettingManager { } /** - * Save settings to a new psf file. + * Save settings to a new psf file. * @param frame parent frame for dialog. */ public void saveSettingsAs(JFrame frame) { @@ -1982,7 +1982,7 @@ public class PamSettingManager { } // /** - // * Save settings to a new psf file. + // * Save settings to a new psf file. // * @param frame parent frame for dialog. // */ // public void saveSettingsAsXML(JFrame frame) { @@ -2018,15 +2018,15 @@ public class PamSettingManager { /** - * Set the default (first) file in the settings file data. - * @param defaultFile File name string. + * Set the default (first) file in the settings file data. + * @param defaultFile File name string. */ public void setDefaultFile(String defaultFile) { /** - * If saving from viewer or mixed mode, then the + * If saving from viewer or mixed mode, then the * settingsFileData may not have been loaded, in which case - * load it now so that old psf names remain in the list. + * load it now so that old psf names remain in the list. */ if (settingsFileData == null) { // System.out.println("Must load settings file first"); @@ -2044,7 +2044,7 @@ public class PamSettingManager { * 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. IF the new settings file is - * different from the current one, then send a command off + * different from the current one, then send a command off * to the Controller to re-do the entire Pamguard system model * @param frame parent frame for dialog (can be null) */ @@ -2055,7 +2055,7 @@ public class PamSettingManager { if (settingsFileData != null) { currentFile = settingsFileData.getFirstFile(); } - SettingsFileData newData = showSettingsDailog(settingsFileData); + SettingsFileData newData = showSettingsDailog(settingsFileData); if (newData == null) { return; } @@ -2063,7 +2063,7 @@ public class PamSettingManager { if (settingsFileData.getFirstFile() != currentFile) { settingsFileData.setFirstFile(currentFile); saveSettingsFileData(); - // rebuild the entire model. + // rebuild the entire model. PamControllerInterface pamController = PamController.getInstance(); if (pamController == null) return; pamController.totalModelRebuild(); @@ -2072,7 +2072,7 @@ public class PamSettingManager { } /** - * Import a configuration during viewer mode operation. + * Import a configuration during viewer mode operation. * @param frame */ public void importSettings(JFrame frame) { @@ -2083,22 +2083,22 @@ public class PamSettingManager { if (settingsFileData != null) { currentFile = settingsFileData.getFirstFile(); } - - + + SettingsFileData newData = showSettingsDailog(settingsFileData); if (newData == null) { return; } - + ArrayList settings = loadSettingsFromFile(); if (settings == null) { String msg = "Unable to load settings from " + getSettingsFileName(); WarnOnce.showWarning(frame, "Settings Import", msg, WarnOnce.OK_OPTION); return; } - + /* - * Should now have a valid settings file. Import the data from it. + * Should now have a valid settings file. Import the data from it. */ PamSettingsGroup pamSettingsGroup = new PamSettingsGroup(System.currentTimeMillis()); for (PamControlledUnitSettings pus:settings) { @@ -2113,10 +2113,10 @@ public class PamSettingManager { * Load a settings file and return the contents in a settings group * object. Give the time of the settings group as the time the file * was modified. the settings load code is a bit of a mess - this function - * has been written mainly so that it can be called from Matlab and r - * so that those languages can load PAMGuard settings. - * @param psfFile psf file object. - * @return loaded settings from the file. + * has been written mainly so that it can be called from Matlab and r + * so that those languages can load PAMGuard settings. + * @param psfFile psf file object. + * @return loaded settings from the file. */ public PamSettingsGroup loadSettings(File psfFile) { if (psfFile == null) { @@ -2151,7 +2151,7 @@ public class PamSettingManager { catch (ClassNotFoundException Ex){ // print and continue - there may be othere things we can deal with. Ex.printStackTrace(); - + } catch (Exception Ex) { Ex.printStackTrace(); @@ -2179,8 +2179,8 @@ public class PamSettingManager { } /** - * - * @return everything about every set of settings currently loaded. + * + * @return everything about every set of settings currently loaded. */ public PamSettingsGroup getCurrentSettingsGroup() { PamSettingsGroup psg = new PamSettingsGroup(PamCalendar.getTimeInMillis()); @@ -2188,7 +2188,7 @@ public class PamSettingManager { PamSettings ps; for (int i = 0; i < owners.size(); i++) { ps = owners.get(i); - pcus = new PamControlledUnitSettings(ps.getUnitType(), ps.getUnitName(), + pcus = new PamControlledUnitSettings(ps.getUnitType(), ps.getUnitName(), ps.getClass().getName(), ps.getSettingsVersion(), ps.getSettingsReference()); psg.addSettings(pcus); @@ -2199,9 +2199,9 @@ public class PamSettingManager { /** * Load some old settings into all modules. *

    Currently used in viewer mode to load reloaded settings - * from binary files and the database. + * from binary files and the database. * @param settingsGroup settings group to load. - * @param send these new settings round to all existing modules. + * @param send these new settings round to all existing modules. */ public void loadSettingsGroup(PamSettingsGroup settingsGroup, boolean notifyExisting) { ArrayList tempSettingsList = settingsGroup.getUnitSettings(); @@ -2209,7 +2209,7 @@ public class PamSettingManager { /////////////deleteDBsettings /* TODO FIXME -better way? TEMPORARY - GW - * delete DB settings so when old settings psf is restored over current settings + * delete DB settings so when old settings psf is restored over current settings * the current DB will not be changed!! */ ArrayList DBsettingTypes = new ArrayList(); @@ -2252,13 +2252,13 @@ public class PamSettingManager { } return null; } - + /** - * Find a list of unit settings by type and name. If both are specified, then it's going to - * (hopefully only return one setting. Otherwise, with null or wildcard names we may get many. + * Find a list of unit settings by type and name. If both are specified, then it's going to + * (hopefully only return one setting. Otherwise, with null or wildcard names we may get many. * @param unitType unit type, can be wildcard * or null * @param unitName unit name, can be wildcard * or null - * @return Array list of settings. + * @return Array list of settings. */ public ArrayList findPamSettings(String unitType, String unitName) { if (owners == null) { @@ -2280,19 +2280,19 @@ public class PamSettingManager { } foundSettings.add(owner); } - + return foundSettings; } - - + + /** - * Show a dialog to allow the user to select a .psf file path. - * @param settingsFileData - * @return the settings file data. + * Show a dialog to allow the user to select a .psf file path. + * @param settingsFileData + * @return the settings file data. */ private SettingsFileData showSettingsDailog(SettingsFileData settingsFileData) { SettingsFileData newData; - int flag=PamGUIManager.getGUIType(); + int flag=PamGUIManager.getGUIType(); switch (flag) { case PamGUIManager.SWING: newData = SettingsFileDialog.showDialog(null, settingsFileData); @@ -2313,10 +2313,10 @@ public class PamSettingManager { public ArrayList getInitialSettingsList() { return initialSettingsList; } - + /** * Get the current scaling factor - * + * * @return */ public double getCurrentDisplayScaling() { @@ -2331,11 +2331,11 @@ public class PamSettingManager { if (newScalingFactor != 0 && newScalingFactor != settingsFileData.getScalingFactor()) { // scaleDisplay(newScalingFactor); settingsFileData.setScalingFactor(newScalingFactor); - + String message = "You have changed PAMGuard's display scaling. Please restart PAMGuard in order to update your display."; int ans = WarnOnce.showWarning(frame, "New Display Scaling", message, WarnOnce.OK_OPTION); } - + } } diff --git a/src/PamController/PamguardVersionInfo.java b/src/PamController/PamguardVersionInfo.java index 2e7b0198..01258c63 100644 --- a/src/PamController/PamguardVersionInfo.java +++ b/src/PamController/PamguardVersionInfo.java @@ -31,12 +31,12 @@ public class PamguardVersionInfo { * Version number, major version.minorversion.sub-release. * Note: can't go higher than sub-release 'f' */ - static public final String version = "2.02.04ae"; + static public final String version = "2.02.05"; /** * Release date */ - static public final String date = "29 September 2022"; + static public final String date = "21 October 2022"; // /** // * Release type - Beta or Core diff --git a/src/PamController/command/CommandManager.java b/src/PamController/command/CommandManager.java index e734abec..01533e28 100644 --- a/src/PamController/command/CommandManager.java +++ b/src/PamController/command/CommandManager.java @@ -35,6 +35,7 @@ public abstract class CommandManager extends PamControlledUnit { commandsList.add(new SummaryPeekCommand()); commandsList.add(new TellModuleCommand()); commandsList.add(new ExitCommand()); + commandsList.add(new ExitNoSaveCommand()); commandsList.add(new KillCommand()); commandsList.add(new HelpCommand(this)); commandsList.add(new GetXMLSettings()); diff --git a/src/PamController/command/ExitCommand.java b/src/PamController/command/ExitCommand.java index 76c8fcee..a44c91ce 100644 --- a/src/PamController/command/ExitCommand.java +++ b/src/PamController/command/ExitCommand.java @@ -24,7 +24,7 @@ public class ExitCommand extends ExtCommand { @Override public String getHint() { - return "Exit PAMGuard, stopping detectors prior to exiting"; + return "Exit PAMGuard, stopping detectors and saving configuration prior to exiting"; } diff --git a/src/PamController/command/ExitNoSaveCommand.java b/src/PamController/command/ExitNoSaveCommand.java new file mode 100644 index 00000000..4c12c58a --- /dev/null +++ b/src/PamController/command/ExitNoSaveCommand.java @@ -0,0 +1,24 @@ +package PamController.command; + +import PamController.PamController; + +public class ExitNoSaveCommand extends ExtCommand { + + public ExitNoSaveCommand() { + super("ExitNoSave", false); + } + + @Override + public String execute(String command) { + PamController.getInstance().pamStop(); + System.exit(0); + return getName(); + } + + @Override + public String getHint() { + return "Exit PAMGuard, stopping detectors but not saving configuration"; + } + + +} diff --git a/src/PamModel/PamModel.java b/src/PamModel/PamModel.java index 5d57f7e2..153fa2eb 100644 --- a/src/PamModel/PamModel.java +++ b/src/PamModel/PamModel.java @@ -1256,7 +1256,7 @@ final public class PamModel implements PamModelInterface, PamSettings { "for help.

    " + "This plug-in will not be available for loading"; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help, e1); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help, e1); System.err.println("Exception while loading " + className); continue; } @@ -1270,7 +1270,7 @@ final public class PamModel implements PamModelInterface, PamSettings { "for help.

    " + "This plug-in will not be available for loading"; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help, ex); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help, ex); System.err.println("Exception while loading " + jarList.get(i).getName()); continue; } @@ -1361,7 +1361,7 @@ final public class PamModel implements PamModelInterface, PamSettings { "for help.

    " + "This plug-in will not be available for loading"; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help, e1); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help, e1); System.err.println("Exception while loading " + pf.getDefaultName()); pluginList.remove(pf); continue; diff --git a/src/PamUtils/PamAudioFileFilter.java b/src/PamUtils/PamAudioFileFilter.java index e1f20a95..b903cbf7 100644 --- a/src/PamUtils/PamAudioFileFilter.java +++ b/src/PamUtils/PamAudioFileFilter.java @@ -17,7 +17,7 @@ public class PamAudioFileFilter extends PamFileFilter { // addFileType(".AIFF"); // addFileType(".FLAC"); addFileType(".flac"); - addFileType(".sud"); +// addFileType(".sud"); } } diff --git a/src/PamUtils/PamExceptionHandler.java b/src/PamUtils/PamExceptionHandler.java index 44722dac..28b91103 100644 --- a/src/PamUtils/PamExceptionHandler.java +++ b/src/PamUtils/PamExceptionHandler.java @@ -35,7 +35,7 @@ public class PamExceptionHandler implements Thread.UncaughtExceptionHandler { "for help.

    " + "This plug-in will not be available for loading"; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help, exception); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help, exception); System.err.println("Exception while loading " + pluginInterface); exception.printStackTrace(); } else { diff --git a/src/PamView/dialog/PamDialog.java b/src/PamView/dialog/PamDialog.java index 80d7a459..e3c94234 100644 --- a/src/PamView/dialog/PamDialog.java +++ b/src/PamView/dialog/PamDialog.java @@ -63,6 +63,7 @@ abstract public class PamDialog extends JDialog { private String warningTitle; private boolean warnDefaultSetting = true; private CancelObserver cancelObserver; + private boolean firstShowing = true; public JPanel getButtonPanel() { return buttonPanel; @@ -146,7 +147,7 @@ abstract public class PamDialog extends JDialog { return parentFrame; } try { - return PamController.getInstance().getGuiFrameManager().getFrame(0); + return PamController.getMainFrame(); } catch (Exception e) { return null; @@ -283,6 +284,10 @@ abstract public class PamDialog extends JDialog { if (getOwner() == null) { moveToMouseLocation(); } + if (firstShowing) { + firstShowing = false; + super.pack(); + } } try{ super.setVisible(visible); diff --git a/src/PamView/dialog/warn/WarnOnce.java b/src/PamView/dialog/warn/WarnOnce.java index 6efc5b79..bee48997 100644 --- a/src/PamView/dialog/warn/WarnOnce.java +++ b/src/PamView/dialog/warn/WarnOnce.java @@ -88,7 +88,7 @@ public class WarnOnce implements PamSettings { public static int showWarning(String title, String message, int messageType, String helpPoint, Throwable error, String okButtonText, String cancelButtonText) { if (PamGUIManager.isSwing()) { - return singleInstance.showWarningDialog(PamController.getInstance().getGuiFrameManager().getFrame(0), + return singleInstance.showWarningDialog(PamController.getMainFrame(), title, message, messageType, helpPoint, error, okButtonText, cancelButtonText); } else if (PamGUIManager.isFX()) { @@ -220,7 +220,7 @@ public class WarnOnce implements PamSettings { * otherwise OK_OPTION will always be returned. */ public static int showWarning(Window parent, String title, String message, int messageType, String helpPoint, Throwable error) { - if (! PamController.checkIfNetworkControlled()) { + if (canShowDialog()) { return singleInstance.showWarningDialog(parent, title, message, messageType, helpPoint, error, null, null); } else { System.out.println(" "); @@ -231,6 +231,16 @@ public class WarnOnce implements PamSettings { } } + private static boolean canShowDialog() { + if (PamController.checkIfNetworkControlled()) { + return false; + } + if (PamGUIManager.getGUIType() == PamGUIManager.NOGUI) { + return false; + } + return true; + } + /** * Show a warning message. * @param parent parent frame @@ -361,10 +371,16 @@ public class WarnOnce implements PamSettings { } // show the warning - WarnOnceDialog wo = new WarnOnceDialog(parent, title, message, messageType, helpPoint, error, okButtonText, cancelButtonText); - warnOnceList.setShowWarning(messageName, wo.isShowAgain()); - showThisSess.put(messageName, wo.isShowThisSess()); - return wo.getAnswer(); + if (canShowDialog()) { + WarnOnceDialog wo = new WarnOnceDialog(parent, title, message, messageType, helpPoint, error, okButtonText, cancelButtonText); + warnOnceList.setShowWarning(messageName, wo.isShowAgain()); + showThisSess.put(messageName, wo.isShowThisSess()); + return wo.getAnswer(); + } + else { + System.out.println(message); + return OK_OPTION; + } } diff --git a/src/PamguardMVC/uid/binaryUIDFunctions.java b/src/PamguardMVC/uid/binaryUIDFunctions.java index 274e5bee..f8959935 100644 --- a/src/PamguardMVC/uid/binaryUIDFunctions.java +++ b/src/PamguardMVC/uid/binaryUIDFunctions.java @@ -120,8 +120,8 @@ public class binaryUIDFunctions { } } } catch (Exception e) { - System.out.println("Error reading binary UID data from log file"); - e.printStackTrace(); + System.out.println("Error reading binary UID data from log file" + logFileData); +// e.printStackTrace(); } // try (BufferedReader br = new BufferedReader(new FileReader(logFileData))) { @@ -320,7 +320,7 @@ public class binaryUIDFunctions { + footer.getHighestUID() + ". It is not possible to know whether all of the original data objects have been recovered.

    "; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help); } } @@ -429,7 +429,7 @@ public class binaryUIDFunctions { + " data objects. The last object UID recovered is " + footer.getHighestUID() + ". It is not possible to know whether all of the original data objects have been recovered.

    "; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help); } } @@ -531,10 +531,12 @@ public class binaryUIDFunctions { out.close(); } } catch (TransformerException e) { - e.printStackTrace(); + System.err.println(e.getMessage()); +// e.printStackTrace(); return false; } catch (IOException e) { - e.printStackTrace(); + System.err.println(e.getMessage()); +// e.printStackTrace(); return false; } return true; diff --git a/src/alarm/actions/email/SendEmailAction.java b/src/alarm/actions/email/SendEmailAction.java index affefc79..d422193e 100644 --- a/src/alarm/actions/email/SendEmailAction.java +++ b/src/alarm/actions/email/SendEmailAction.java @@ -263,7 +263,7 @@ public class SendEmailAction extends AlarmAction implements PamSettings { ". The alarm will not be able to send emails until " + "this is fixed. Please check the Alarm Email Settings to ensure they are correct."; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help, e); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help, e); e.printStackTrace(); emailReady=AlarmAction.ALARM_CANT_DO; } diff --git a/src/beamformer/algorithms/BeamAlgoParamsPane.java b/src/beamformer/algorithms/BeamAlgoParamsPane.java index 78d6e230..5810d848 100644 --- a/src/beamformer/algorithms/BeamAlgoParamsPane.java +++ b/src/beamformer/algorithms/BeamAlgoParamsPane.java @@ -1346,7 +1346,7 @@ public class BeamAlgoParamsPane extends SettingsPane { "The beamformer needs this information in order to run. There will be no output until " + "a valid Acquisition module is added and the Pamguard run is restarted."; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help, e); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help, e); sourceProcess=null; e.printStackTrace(); return; @@ -1357,7 +1357,7 @@ public class BeamAlgoParamsPane extends SettingsPane { "The beamformer needs this information in order to run. There will be no output until " + "a valid Acquisition module is added and the Pamguard run is restarted."; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help, null); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help, null); return; } diff --git a/src/beamformer/algorithms/basicFreqDomain/BasicFreqDomBeamFormer.java b/src/beamformer/algorithms/basicFreqDomain/BasicFreqDomBeamFormer.java index 15502545..6e20c08f 100644 --- a/src/beamformer/algorithms/basicFreqDomain/BasicFreqDomBeamFormer.java +++ b/src/beamformer/algorithms/basicFreqDomain/BasicFreqDomBeamFormer.java @@ -226,7 +226,7 @@ public class BasicFreqDomBeamFormer implements BeamFormerAlgorithm { "The beamformer needs this information in order to run. There will be no output until " + "a valid Acquisition module is added and the Pamguard run is restarted."; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help, e); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help, e); sourceProcess=null; e.printStackTrace(); return; @@ -237,7 +237,7 @@ public class BasicFreqDomBeamFormer implements BeamFormerAlgorithm { "The beamformer needs this information in order to run. There will be no output until " + "a valid Acquisition module is added and the Pamguard run is restarted."; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help, null); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help, null); return; } diff --git a/src/beamformer/algorithms/mvdr/MVDRalgorithm.java b/src/beamformer/algorithms/mvdr/MVDRalgorithm.java index 6c5c47e1..050566f6 100644 --- a/src/beamformer/algorithms/mvdr/MVDRalgorithm.java +++ b/src/beamformer/algorithms/mvdr/MVDRalgorithm.java @@ -257,7 +257,7 @@ public class MVDRalgorithm implements BeamFormerAlgorithm { "The beamformer needs this information in order to run. There will be no output until " + "a valid Acquisition module is added and the Pamguard run is restarted."; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help, e); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help, e); sourceProcess=null; e.printStackTrace(); return; @@ -268,7 +268,7 @@ public class MVDRalgorithm implements BeamFormerAlgorithm { "The beamformer needs this information in order to run. There will be no output until " + "a valid Acquisition module is added and the Pamguard run is restarted."; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help, null); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help, null); return; } diff --git a/src/clickTrainDetector/offline/CTClassifierOfflineTask.java b/src/clickTrainDetector/offline/CTClassifierOfflineTask.java index 4dd9b084..1daf99c8 100644 --- a/src/clickTrainDetector/offline/CTClassifierOfflineTask.java +++ b/src/clickTrainDetector/offline/CTClassifierOfflineTask.java @@ -52,7 +52,7 @@ public class CTClassifierOfflineTask extends OfflineTask { // Debug.out.println("Hello: CTDataUnit: UID " + ctDataUnit.getUID() + " " + ctDataUnit.getSubDetectionsCount()); // } - clickTrainControl.getSwingGUI().showSettingsDialog(PamController.getInstance().getGuiFrameManager().getFrame(0), true); + clickTrainControl.getSwingGUI().showSettingsDialog(PamController.getMainFrame(), true); return true; } diff --git a/src/clickTrainDetector/offline/ClickTrainOfflineTask.java b/src/clickTrainDetector/offline/ClickTrainOfflineTask.java index b858badb..6d583a2d 100644 --- a/src/clickTrainDetector/offline/ClickTrainOfflineTask.java +++ b/src/clickTrainDetector/offline/ClickTrainOfflineTask.java @@ -156,7 +156,7 @@ public class ClickTrainOfflineTask extends OfflineTask> { @Override public boolean callSettings() { - clickTrainControl.getSwingGUI().showSettingsDialog(PamController.getInstance().getGuiFrameManager().getFrame(0), false); + clickTrainControl.getSwingGUI().showSettingsDialog(PamController.getMainFrame(), false); return true; } diff --git a/src/depthReadout/MccDialog.java b/src/depthReadout/MccDialog.java index cd3de156..6134c588 100644 --- a/src/depthReadout/MccDialog.java +++ b/src/depthReadout/MccDialog.java @@ -386,7 +386,7 @@ public class MccDialog extends PamDialog { String msg = "

    PAMGuard cannot find an analog input device. Please ensure that you have a " + "device plugged into your computer, and you have the correct drivers installed.

    "; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help); return; } if (mccDepthParameters.iBoard >= 0 && diff --git a/src/generalDatabase/DBControl.java b/src/generalDatabase/DBControl.java index 031d8232..96adf97f 100644 --- a/src/generalDatabase/DBControl.java +++ b/src/generalDatabase/DBControl.java @@ -229,7 +229,7 @@ PamSettingsSource { "be configured to be looking in a different folder. Please check the expected folder location, as well " + "as the PAMGuard settings."; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help); return false; } if (forcedName == null) { diff --git a/src/generalDatabase/DBProcess.java b/src/generalDatabase/DBProcess.java index 805f33b0..75b9b027 100644 --- a/src/generalDatabase/DBProcess.java +++ b/src/generalDatabase/DBProcess.java @@ -290,7 +290,7 @@ public class DBProcess extends PamProcess { + theForm.getUdfTableDefinition().getTableName() + " with the " + theForm.getFormName() + " form format currently in memory. If this is correct, press Ok. If you do not want to " + "change the format stored in the database, press Cancel.

    "; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.OK_CANCEL_OPTION); if (ans == WarnOnce.CANCEL_OPTION) { continue; diff --git a/src/generalDatabase/lookupTables/LookUpTables.java b/src/generalDatabase/lookupTables/LookUpTables.java index 16ca640c..daea762f 100644 --- a/src/generalDatabase/lookupTables/LookUpTables.java +++ b/src/generalDatabase/lookupTables/LookUpTables.java @@ -152,7 +152,7 @@ public class LookUpTables { String msg = "PAMGuard is about to modify the Lookup table in the database. It will be adding new rows to the end of the table, possibly " + "duplicating existing topics if you are switching from a database that already had Lookup information.

    " + "If this is correct, press Ok. If you do not want to change the database table, press Cancel.

    "; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.OK_CANCEL_OPTION); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.OK_CANCEL_OPTION); if (ans==WarnOnce.CANCEL_OPTION) { return false; } diff --git a/src/matchedTemplateClassifer/offline/MTClassifierOfflineTask.java b/src/matchedTemplateClassifer/offline/MTClassifierOfflineTask.java index 04483690..99b9ca68 100644 --- a/src/matchedTemplateClassifer/offline/MTClassifierOfflineTask.java +++ b/src/matchedTemplateClassifer/offline/MTClassifierOfflineTask.java @@ -110,7 +110,7 @@ public class MTClassifierOfflineTask extends OfflineTask> { @Override public boolean callSettings() { - mtClassifierControl.showSettingsDialog(PamController.getInstance().getGuiFrameManager().getFrame(0)); + mtClassifierControl.showSettingsDialog(PamController.getMainFrame()); return true; } diff --git a/src/radardisplay/RadarParameters.java b/src/radardisplay/RadarParameters.java index ddf936e7..9f7f61a3 100644 --- a/src/radardisplay/RadarParameters.java +++ b/src/radardisplay/RadarParameters.java @@ -172,7 +172,7 @@ public class RadarParameters extends UserFrameParameters implements Serializable String msg = "

    The Radar Display parameters have been upgraded. Please open the " + "Radar Display dialog panel to ensure that the correct datablocks are being displayed

    "; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help); } @Override diff --git a/src/rawDeepLearningClassifier/offline/DLOfflineTask.java b/src/rawDeepLearningClassifier/offline/DLOfflineTask.java index 0e2aa265..5d9f8d97 100644 --- a/src/rawDeepLearningClassifier/offline/DLOfflineTask.java +++ b/src/rawDeepLearningClassifier/offline/DLOfflineTask.java @@ -121,7 +121,7 @@ public class DLOfflineTask extends OfflineTask>{ @Override public boolean callSettings() { - dlControl.showSettingsDialog(PamController.getInstance().getGuiFrameManager().getFrame(0)); + dlControl.showSettingsDialog(PamController.getMainFrame()); return true; } diff --git a/src/rocca/RoccaProcess.java b/src/rocca/RoccaProcess.java index f49ff04d..b21709df 100644 --- a/src/rocca/RoccaProcess.java +++ b/src/rocca/RoccaProcess.java @@ -940,7 +940,7 @@ public class RoccaProcess extends PamProcess { "This will happen when re-analyzing data that has already been analyzed, but it may " + "also indicate that your filename template is inadequate and returning duplicate filenames.

    "; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help); } @@ -1088,7 +1088,7 @@ public class RoccaProcess extends PamProcess { "This will happen when re-analyzing data that has already been analyzed, but it may " + "also indicate that your filename template is inadequate and returning duplicate filenames.

    "; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help); } diff --git a/src/rocca/RoccaSpecPopUp.java b/src/rocca/RoccaSpecPopUp.java index 7cc42fe8..ffd39d34 100644 --- a/src/rocca/RoccaSpecPopUp.java +++ b/src/rocca/RoccaSpecPopUp.java @@ -2025,7 +2025,7 @@ public class RoccaSpecPopUp extends javax.swing.JPanel { "This will happen when re-analyzing data that has already been analyzed, but it may " + "also indicate that your filename template is inadequate and returning duplicate filenames.

    "; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help); } @@ -2361,7 +2361,7 @@ public class RoccaSpecPopUp extends javax.swing.JPanel { "This will happen when re-analyzing data that has already been analyzed, but it may " + "also indicate that your filename template is inadequate and returning duplicate filenames.

    "; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help); } diff --git a/src/rocca/RoccaWhistleSelect.java b/src/rocca/RoccaWhistleSelect.java index 72f1f59e..100d4289 100644 --- a/src/rocca/RoccaWhistleSelect.java +++ b/src/rocca/RoccaWhistleSelect.java @@ -187,7 +187,7 @@ public class RoccaWhistleSelect extends PamProcess implements SpectrogramMarkObs "underlying detection information necessary to recalculate ancillary variables (e.g. time between detections, detection density, " + "detections/second, etc). You will need to start a new Encounter to ensure all variables are calculated correctly.

    "; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help); String dummy = roccaControl.roccaSidePanel.sidePanel.addASighting(false); } diff --git a/src/soundtrap/DWVConvertInformation.java b/src/soundtrap/DWVConvertInformation.java index f18caea7..bb0da67b 100644 --- a/src/soundtrap/DWVConvertInformation.java +++ b/src/soundtrap/DWVConvertInformation.java @@ -9,13 +9,17 @@ public class DWVConvertInformation { private STGroupInfo fileGroup; private int nDWV; - private int nDone; + private int nDWVDone; + private int nFileDone; + private int nFile; - public DWVConvertInformation(STGroupInfo fileGroup, int nDWV, int nDone) { + public DWVConvertInformation(STGroupInfo fileGroup, int nFile, int nFileDone, int nDWV, int nDWVDone) { this.fileGroup = fileGroup; + this.nFile = nFile; + this.nFileDone = nFileDone; this.nDWV = nDWV; - this.nDone = nDone; + this.nDWVDone = nDWVDone; } @@ -36,10 +40,26 @@ public class DWVConvertInformation { /** - * @return the nDone + * @return the nDWVDone */ - public int getnDone() { - return nDone; + public int getnDWVDone() { + return nDWVDone; + } + + + /** + * @return the nFileDone + */ + public int getnFileDone() { + return nFileDone; + } + + + /** + * @return the nFile + */ + public int getnFile() { + return nFile; } } diff --git a/src/soundtrap/DWVConverter.java b/src/soundtrap/DWVConverter.java index 1c9d1bc4..ca4ba9d0 100644 --- a/src/soundtrap/DWVConverter.java +++ b/src/soundtrap/DWVConverter.java @@ -81,8 +81,10 @@ public class DWVConverter { binarySource.setBinaryStorageStream(outputStream); binaryStream = clickBinaryDataSource.getBinaryStorageStream(); + int iFile = 0; + int nFile = fileGroups.size(); for (STGroupInfo fileGroup:fileGroups) { - processFiles(fileGroup); + processFiles(fileGroup, nFile, ++iFile); if (keepRunning == false) { break; } @@ -94,16 +96,30 @@ public class DWVConverter { return null; } - private void processFiles(STGroupInfo fileGroup) { - this.publish(new DWVConvertInformation(fileGroup, 0, 0)); - if (fileGroup.hasDWV() == false) return; + private void processFiles(STGroupInfo fileGroup, int nFile, int iFile) { + this.publish(new DWVConvertInformation(fileGroup, nFile, iFile, 0, 0)); + if (fileGroup.hasDWV() == false) { + /* + * Don't do this. In quiet conditions there will be a BCL file with a start and stop time + * but if there were no detections there will be no dwv file. We should make the pgdf file + * in any case so that there is a full PAMGuard record of effort. + * In other circumstances dwv files don't actually have data, in which case there may still be + * a null file, which is not so good. Will have to think about how to report this - perhaps in + * this case it's better not to make a pgdf file to show a genuine gap in the data. + */ +// return; + } BCLReader bclReader = new BCLReader(fileGroup.getBclFile()); boolean ok = bclReader.open(); if (ok == false) return; - DWVReader dwvReader = new DWVReader(fileGroup.getDwvFile(), fileGroup.getDwvInfo()); - dwvReader.openDWV(); - int nDWV = dwvReader.getNumDWV(); - int repStep = Math.max(1, nDWV/100); + int nDWV = 0; + DWVReader dwvReader = null; + if (fileGroup.hasDWV()) { + dwvReader = new DWVReader(fileGroup.getDwvFile(), fileGroup.getDwvInfo()); + dwvReader.openDWV(); + nDWV = dwvReader.getNumDWV(); + } + int repStep = Math.max(10, nDWV/100); int nRead = 0; while (true) { BCLLine bclLine = bclReader.nextBCLLine(); @@ -127,7 +143,7 @@ public class DWVConverter { dataLine(fileGroup, bclLine, dwvReader); nRead++; if (nRead%repStep == 0) { - this.publish(new DWVConvertInformation(fileGroup, nDWV, nRead)); + this.publish(new DWVConvertInformation(fileGroup, nFile, iFile, nDWV, nRead)); } break; @@ -140,10 +156,14 @@ public class DWVConverter { // e.printStackTrace(); // } } + this.publish(new DWVConvertInformation(fileGroup, nFile, iFile, nDWV, nDWV)); } private void dataLine(STGroupInfo fileGroup, BCLLine bclLine, DWVReader dwvReader) { - double[] dwvData = dwvReader.readNextClick(null); + double[] dwvData = null; + if (dwvReader != null) { + dwvData = dwvReader.readNextClick(null); + } if (dwvData == null) { return; // can happen if file didn't flush correclty and some dwv is missing. } @@ -185,21 +205,37 @@ public class DWVConverter { } if (bclLine.getState() == 1) { - long dwvFileStart = fileGroup.getDwvInfo().getTimeInfo().samplingStartTimeUTC; - long wavFileStart = fileGroup.getWavInfo().getTimeInfo().samplingStartTimeUTC; fileStartMicroseconds = bclLine.getMicroSeconds(); - Debug.out.printf("DWV start %s wav start %s bcl start %s\n", PamCalendar.formatDBDateTime(dwvFileStart), - PamCalendar.formatDBDateTime(wavFileStart), PamCalendar.formatDBDateTime(bclLine.getMilliseconds())); + long wavFileStart = fileGroup.getWavInfo().getTimeInfo().samplingStartTimeUTC; + try { + if (fileGroup.getDwvInfo() != null) { + long dwvFileStart = fileGroup.getDwvInfo().getTimeInfo().samplingStartTimeUTC; + Debug.out.printf("DWV start %s wav start %s bcl start %s\n", PamCalendar.formatDBDateTime(dwvFileStart), + PamCalendar.formatDBDateTime(wavFileStart), PamCalendar.formatDBDateTime(bclLine.getMilliseconds())); + } + else { + Debug.out.printf("No DWV File !!! wav start %s bcl start %s\n", + PamCalendar.formatDBDateTime(wavFileStart), PamCalendar.formatDBDateTime(bclLine.getMilliseconds())); + } + } + catch (Exception e) { + System.out.println(e.getMessage()); + } binaryStream.openOutputFiles(bclLine.getMilliseconds()); binaryStream.writeHeader(bclLine.getMilliseconds(), System.currentTimeMillis()); binaryStream.writeModuleHeader(); onEffort = true; } if (bclLine.getState() == 0) { - long dwvFileStop = fileGroup.getDwvInfo().getTimeInfo().samplingStopTimeUTC; - long wavFileStop = fileGroup.getWavInfo().getTimeInfo().samplingStopTimeUTC; - Debug.out.printf("DWV stop %s wav stop %s E stop %s\n", PamCalendar.formatDBDateTime(dwvFileStop), - PamCalendar.formatDBDateTime(wavFileStop), PamCalendar.formatDBDateTime(bclLine.getMilliseconds())); + try { + long dwvFileStop = fileGroup.getDwvInfo().getTimeInfo().samplingStopTimeUTC; + long wavFileStop = fileGroup.getWavInfo().getTimeInfo().samplingStopTimeUTC; + Debug.out.printf("DWV stop %s wav stop %s E stop %s\n", PamCalendar.formatDBDateTime(dwvFileStop), + PamCalendar.formatDBDateTime(wavFileStop), PamCalendar.formatDBDateTime(bclLine.getMilliseconds())); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } binaryStream.writeModuleFooter(); binaryStream.writeFooter(bclLine.getMilliseconds(), System.currentTimeMillis(), BinaryFooter.END_UNKNOWN); binaryStream.closeFile(); diff --git a/src/soundtrap/ImportBCLDialog.java b/src/soundtrap/ImportBCLDialog.java index bff30c88..a0396d8c 100644 --- a/src/soundtrap/ImportBCLDialog.java +++ b/src/soundtrap/ImportBCLDialog.java @@ -56,7 +56,7 @@ public class ImportBCLDialog extends PamDialog { private JTextField customDateTimeFormat; private JLabel fileCountInfo; private JLabel thisFileInfo; - private JProgressBar allProgress; + private JProgressBar oneFileProgress, totalProgress; private JComboBox detectorName; private int nSoundTraps; private Hashtable uniqueDevices = new Hashtable<>(); @@ -162,8 +162,10 @@ public class ImportBCLDialog extends PamDialog { thisFileInfo = new JLabel(" - "); progressPanel.add(thisFileInfo); - allProgress = new JProgressBar(); - progressPanel.add(allProgress); + totalProgress = new JProgressBar(); + progressPanel.add(totalProgress); + oneFileProgress = new JProgressBar(); + progressPanel.add(oneFileProgress); startButton = new JButton("Start"); getButtonPanel().add(startButton, 0); @@ -388,10 +390,14 @@ public class ImportBCLDialog extends PamDialog { thisFileInfo.setText("NO DWV records"); return; } - int prog = dwvConvertInformation.getnDone() * 100 / dwvConvertInformation.getnDWV(); - allProgress.setValue(prog); - thisFileInfo.setText(String.format("Repacked %d of %d clicks", dwvConvertInformation.getnDone(), - dwvConvertInformation.getnDWV())); + int prog = dwvConvertInformation.getnDWVDone() * 100 / dwvConvertInformation.getnDWV(); + oneFileProgress.setValue(prog); + thisFileInfo.setText(String.format("Repacked %d of %d clicks in file %d of %d", + dwvConvertInformation.getnDWVDone(), dwvConvertInformation.getnDWV(), + dwvConvertInformation.getnFileDone(), dwvConvertInformation.getnFile())); + + prog = dwvConvertInformation.getnFileDone() * 100 / dwvConvertInformation.getnFile(); + totalProgress.setValue(prog); } @Override @@ -460,7 +466,7 @@ public class ImportBCLDialog extends PamDialog { ". The file may be corrupt, or missing information needed. Import is suspended; " + "Please fix the file manually or remove it from the folder, and try to import again."; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.OK_OPTION, null, null, "Cancel Import", null); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.OK_OPTION, null, null, "Cancel Import", null); break; } @@ -473,7 +479,7 @@ public class ImportBCLDialog extends PamDialog { ". PAMGuard is trying to use the format " + customDateTimeFormat.getText() + " but without " + "success. Please change the format in this dialog to match the one used for SamplingStartTimeUTC in your *.log.xml files"; String help = null; - int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.OK_OPTION, null, null, "Cancel Import", null); + int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.OK_OPTION, null, null, "Cancel Import", null); // if (ans == WarnOnce.OK_OPTION) { break; // }