Update command line options

This commit is contained in:
Douglas Gillespie 2022-04-13 17:03:44 +01:00
parent 54f789eead
commit 81fd9f5481
6 changed files with 92 additions and 2 deletions

View File

@ -6,7 +6,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk-16.0.2">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>

View File

@ -33,6 +33,7 @@ public class GenericSwingDialog extends PamDialog {
GenericSwingDialog swingDialog = new GenericSwingDialog(parentFrame, title, dialogPanels);
swingDialog.setParams();
swingDialog.pack();
swingDialog.setVisible(true);
return swingDialog.allOk;
}

View File

@ -27,6 +27,7 @@ import org.w3c.dom.Element;
import pamScrollSystem.ViewLoadObserver;
import pamViewFX.pamTask.PamTaskUpdate;
import pamguard.GlobalArguments;
//import com.mysql.jdbc.NdbLoadBalanceExceptionChecker;
@ -137,6 +138,9 @@ PamSettingsSource, OfflineDataStore {
//TODO- temp; for debug;
private int nUnits=0;
// arg name for global change to store name.
public static final String GlobalFolderArg = "-binaryfolder";
/**
* The FX GUI for binary store
*/
@ -402,9 +406,52 @@ PamSettingsSource, OfflineDataStore {
public boolean restoreSettings(
PamControlledUnitSettings pamControlledUnitSettings) {
binaryStoreSettings = ((BinaryStoreSettings) pamControlledUnitSettings.getSettings()).clone();
/*
* Then check to see if there is a command line override of the currently stored folder name.
*/
String globFolder = GlobalArguments.getParam(GlobalFolderArg);
if (globFolder != null) {
boolean ok = checkGlobFolder(globFolder);
if (ok) {
binaryStoreSettings.setStoreLocation(globFolder); // remember it.
}
else {
System.err.println("Unable to set binary storage folder " + globFolder);
}
}
return true;
}
/**
* Set and create if necessary the global folder.
* @param globFolder
*/
private boolean checkGlobFolder(String globFolder) {
File outFold = new File(globFolder);
if (outFold.exists()) {
if (outFold.isDirectory()) {
return true; // all OK
}
else {
return false; // it must be a file - that's bad !
}
}
// try to create it.
try {
if (outFold.mkdirs()) {
FileFunctions.setNonIndexingBit(outFold);
return true;
}
else {
return false; // unable to make the folder.
}
}
catch (Exception e) {
System.err.println("Can't set binary store folder: " + e.getLocalizedMessage());
return false;
}
}
@Override
public JMenuItem createFileMenu(JFrame parentFrame) {
JMenuItem m;

View File

@ -374,7 +374,7 @@ public class ClickDetector extends PamProcess {
* @see PamguardMVC.PamProcess#SetupProcess()
*/
@Override
public void setupProcess() {
public synchronized void setupProcess() {
pauseDetection = true;

View File

@ -0,0 +1,33 @@
package pamguard;
import java.util.HashMap;
/**
* Global parameter pairs set at startup time.<br>
* These are the arguments passed to the command line. <br>Basically all going into a static hash map
* @author dg50
*
*/
public class GlobalArguments {
static HashMap<String, String> globalFlags = new HashMap<>();
/**
* Set a global parameter value
* @param name value name
* @param value parameter value
*/
public static void setParam(String name, String value) {
globalFlags.put(name, value);
}
/**
* Get a global parameter value
* @param name value name
* @return value
*/
public static String getParam(String name) {
return globalFlags.get(name);
}
}

View File

@ -39,6 +39,7 @@ import PamView.FullScreen;
import PamView.ScreenSize;
import PamView.dialog.warn.WarnOnce;
import PamguardMVC.debug.Debug;
import binaryFileStorage.BinaryStore;
import dataPlotsFX.JamieDev;
import java.io.BufferedReader;
import java.io.File;
@ -213,6 +214,14 @@ public class Pamguard {
System.out.println("Disabling log file from command line switch...");
ProxyPrintStream.disableLogFile();
}
else if (anArg.equalsIgnoreCase(BinaryStore.GlobalFolderArg)) {
// output folder for binary files.
GlobalArguments.setParam(anArg, args[iArg++]);
}
else if (anArg.equalsIgnoreCase("-databasefile")) {
// database file name
GlobalArguments.setParam(anArg, args[iArg++]);
}
else if (anArg.equalsIgnoreCase("-help")) {
System.out.println("--PamGuard Help");
System.out.println("\n--For standard GUI deployment run without any options.\n");