Database opening from Explorer

Sorted so that a viewer database can be opened by right clicking on a
sqlite3 file. Requires updated installer to make appropriate registry
changes. Will be in 2.02.10
This commit is contained in:
Douglas Gillespie 2023-12-29 17:55:30 +00:00
parent b7cbd2592f
commit f5c3ce06ce
4 changed files with 38 additions and 8 deletions

View File

@ -4,7 +4,7 @@
<groupId>org.pamguard</groupId>
<artifactId>Pamguard</artifactId>
<name>Pamguard Java12+</name>
<version>2.02.09e</version>
<version>2.02.09f</version>
<description>Pamguard for Java 12+, using Maven to control dependcies</description>
<url>www.pamguard.org</url>
<organization>

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.pamguard</groupId>
<artifactId>Pamguard</artifactId>
<version>2.02.09e</version>
<version>2.02.09f</version>
<name>Pamguard Java12+</name>
<description>Pamguard for Java 12+, using Maven to control dependcies</description>
<url>www.pamguard.org</url>

View File

@ -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.09e";
static public final String version = "2.02.09f";
/**
* Release date
*/
static public final String date = "18 December 2023";
static public final String date = "28 December 2023";
// /**
// * Release type - Beta or Core

View File

@ -30,6 +30,7 @@ import org.apache.commons.io.FilenameUtils;
import offlineProcessing.DataCopyTask;
import offlineProcessing.OLProcessDialog;
import offlineProcessing.OfflineTaskGroup;
import pamguard.GlobalArguments;
import warnings.PamWarning;
import warnings.WarningSystem;
import PamController.PamConfiguration;
@ -698,9 +699,17 @@ PamSettingsSource {
*/
public boolean selectDatabase(Frame frame, String selectTitle) {
//this is a bit messy but difficult to figure this out in controller framework because
//this is called before the controller has initialised properly.
if (PamGUIManager.getGUIType()==PamGUIManager.FX) {
// also have to allow for the database being passed as a command line option, in which case
// we don't want to open the dialog.
String currentDB = null;
DBParameters newParams = checkPassedDatabase();
if (newParams != null) {
}
else if (PamGUIManager.getGUIType()==PamGUIManager.FX) {
//open FX
return ((DBGuiFX) getGUI(PamGUIManager.FX)).selectDatabase(PamController.getMainStage(), selectTitle, true);
}
@ -711,12 +720,13 @@ PamSettingsSource {
// object and retrieving the name of the first database in the recently-used list. Double-check the connection
// field - if it's null, it means we don't actually have the database loaded so just clear the name and continue
// (this happens when starting Viewer mode)
String currentDB = databaseSystems.get(dbParameters.getDatabaseSystem()).getDatabaseName();
currentDB = databaseSystems.get(dbParameters.getDatabaseSystem()).getDatabaseName();
if (connection==null) {
currentDB = null;
}
DBParameters newParams = DBDialog.showDialog(this, frame, dbParameters, selectTitle);
newParams = DBDialog.showDialog(this, frame, dbParameters, selectTitle);
}
if (newParams != null) {
// first, check if there is a Lookup table. If so, make sure to copy the contents over before
// we lose the reference to the old database
@ -757,10 +767,30 @@ PamSettingsSource {
PamController.getInstance().getUidManager().runStartupChecks(); // if we've loaded a new database, synch the datablocks with the UID info
return true;
}
}
return false;
}
/**
* Check to see if a database has been passed to PAMGuard as a parameter from the command line.
* @return
*/
DBParameters checkPassedDatabase() {
String passedDatabase = GlobalArguments.getParam(DBControl.GlobalDatabaseNameArg);
if (passedDatabase != null) {
/*
* assume it's a file based database. Anything else is going to get more complicated and will require
* a fair amount of type checing, connecint to servers, etc.
*/
if (passedDatabase.endsWith(".sqlite3")) {
DBParameters newParams = dbParameters;
newParams.setDatabaseName(passedDatabase);
newParams.setDatabaseSystem(0);
return newParams;
}
}
return null;
}
/**
* Set dB paramaters
* @param dbParameters