mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-22 07:02:29 +00:00
Merge branch 'main' into Tethys
Conflicts: src/loggerForms/FormsDataDisplayTable.java
This commit is contained in:
commit
c63fb3f341
@ -1096,6 +1096,7 @@ public class MapPanel extends JPanelWithPamKey implements PamObserver, ColorMana
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ds = dataBlock.getDataSelector(simpleMapRef.getUnitName(), false, DATASELECTNAME);
|
ds = dataBlock.getDataSelector(simpleMapRef.getUnitName(), false, DATASELECTNAME);
|
||||||
|
// ds = null;
|
||||||
ArrayList<PamDataUnit> dataCopy = dataBlock.getDataCopy(earliestToPlot, now, true, ds);
|
ArrayList<PamDataUnit> dataCopy = dataBlock.getDataCopy(earliestToPlot, now, true, ds);
|
||||||
duIterator = dataCopy.listIterator();
|
duIterator = dataCopy.listIterator();
|
||||||
while (duIterator.hasNext()) {
|
while (duIterator.hasNext()) {
|
||||||
|
@ -476,7 +476,7 @@ public class PamSettingManager {
|
|||||||
*/
|
*/
|
||||||
public PamSettings findSettingsOwner(String unitType, String unitName, String unitClassName) {
|
public PamSettings findSettingsOwner(String unitType, String unitName, String unitClassName) {
|
||||||
for (PamSettings owner:owners) {
|
for (PamSettings owner:owners) {
|
||||||
if (owner.getClass() != null) {
|
if (owner.getClass() != null && unitClassName != null) {
|
||||||
if (owner.getClass().getName().equals(unitClassName) == false) {
|
if (owner.getClass().getName().equals(unitClassName) == false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -59,4 +59,12 @@ public class UsedModuleInfo implements Serializable, ManagedParameters {
|
|||||||
return ps;
|
return ps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the unit name of the module being imported.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getUnitName() {
|
||||||
|
return unitName;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -116,14 +116,16 @@ public class SettingsImport {
|
|||||||
*/
|
*/
|
||||||
private PamControlledUnit importReplace(SettingsImportGroup importGroup, String replaceModule) {
|
private PamControlledUnit importReplace(SettingsImportGroup importGroup, String replaceModule) {
|
||||||
PamControlledUnitSettings mainSet = importGroup.getMainSettings();
|
PamControlledUnitSettings mainSet = importGroup.getMainSettings();
|
||||||
PamControlledUnit unit = PamController.getInstance().findControlledUnit(mainSet.getUnitType(), replaceModule);
|
UsedModuleInfo importInfo = importGroup.getUsedModuleInfo();
|
||||||
|
PamControlledUnit unit = PamController.getInstance().findControlledUnit(importInfo.getUnitType(), replaceModule);
|
||||||
if (unit == null) {
|
if (unit == null) {
|
||||||
System.out.println("Unable to find " + mainSet.getUnitType() + " " + mainSet.getUnitName() + " for settings replacement");
|
System.out.println("Unable to find " + importInfo.getUnitType() + " " + importInfo.getUnitName() + " for settings replacement");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// check we can cast it to PamSettings
|
// check we can cast it to PamSettings
|
||||||
if (PamSettings.class.isAssignableFrom(unit.getClass())) {
|
if (PamSettings.class.isAssignableFrom(unit.getClass()) && mainSet != null) {
|
||||||
try {
|
try {
|
||||||
|
mainSet.setUnitName(replaceModule);
|
||||||
((PamSettings) unit).restoreSettings(mainSet);
|
((PamSettings) unit).restoreSettings(mainSet);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
@ -132,7 +134,7 @@ public class SettingsImport {
|
|||||||
System.err.println(e.getMessage());
|
System.err.println(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadSubUnitSettings(importGroup, mainSet.getUnitName());
|
loadSubUnitSettings(importGroup, replaceModule);
|
||||||
return unit;
|
return unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +151,15 @@ public class SettingsImport {
|
|||||||
}
|
}
|
||||||
PamSettingManager setManager = PamSettingManager.getInstance();
|
PamSettingManager setManager = PamSettingManager.getInstance();
|
||||||
for (PamControlledUnitSettings pamSettings:subSets) {
|
for (PamControlledUnitSettings pamSettings:subSets) {
|
||||||
PamSettings owner = setManager.findSettingsOwner(pamSettings.getUnitType(), unitName, pamSettings.getOwnerClassName());
|
/*
|
||||||
|
* class name in pamSettings is no longer correct, so cannot use pamSettings.getOwnerClassName().
|
||||||
|
* but the classnames of all the sub modules are unknown (and will be different form the unit class name
|
||||||
|
* which can be got from importGroup.getPamModuleInfo().getClassName
|
||||||
|
* so will have to do this only on the unit type and name and hope for no conflicts (catch exception).
|
||||||
|
*/
|
||||||
|
// PamModuleInfo moduleInfo = importGroup.getPamModuleInfo();
|
||||||
|
// String className = moduleInfo.getClassName();
|
||||||
|
PamSettings owner = setManager.findSettingsOwner(pamSettings.getUnitType(), unitName, null);
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
System.out.println(String.format("Cannot find settings owner for %s %s in current model", pamSettings.getUnitType(), unitName));
|
System.out.println(String.format("Cannot find settings owner for %s %s in current model", pamSettings.getUnitType(), unitName));
|
||||||
continue;
|
continue;
|
||||||
@ -168,7 +178,8 @@ public class SettingsImport {
|
|||||||
|
|
||||||
private PamControlledUnit importNew(SettingsImportGroup importGroup) {
|
private PamControlledUnit importNew(SettingsImportGroup importGroup) {
|
||||||
PamControlledUnitSettings mainSet = importGroup.getMainSettings();
|
PamControlledUnitSettings mainSet = importGroup.getMainSettings();
|
||||||
String moduleName = mainSet.getUnitName();
|
UsedModuleInfo importInfo = importGroup.getUsedModuleInfo();
|
||||||
|
String moduleName = importInfo.unitName;
|
||||||
|
|
||||||
// check we've got a name that doesnt' exist and replace it if if does.
|
// check we've got a name that doesnt' exist and replace it if if does.
|
||||||
// int startChar = 0;
|
// int startChar = 0;
|
||||||
@ -199,11 +210,11 @@ public class SettingsImport {
|
|||||||
|
|
||||||
PamControlledUnit unit = PamController.getInstance().addModule(PamController.getMainFrame(), moduleInfo);
|
PamControlledUnit unit = PamController.getInstance().addModule(PamController.getMainFrame(), moduleInfo);
|
||||||
if (unit == null) {
|
if (unit == null) {
|
||||||
System.out.println("Unable to find " + mainSet.getUnitType() + " " + mainSet.getUnitName() + " for settings replacement");
|
System.out.println("Unable to find " + importInfo.getUnitType() + " " + importInfo.getUnitName() + " for settings replacement");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// check we can cast it to PamSettings
|
// check we can cast it to PamSettings
|
||||||
if (PamSettings.class.isAssignableFrom(unit.getClass())) {
|
if (PamSettings.class.isAssignableFrom(unit.getClass()) && mainSet != null) {
|
||||||
try {
|
try {
|
||||||
mainSet.setUnitName(unit.getUnitName()); // need to force the unit name for some modules.
|
mainSet.setUnitName(unit.getUnitName()); // need to force the unit name for some modules.
|
||||||
((PamSettings) unit).restoreSettings(mainSet);
|
((PamSettings) unit).restoreSettings(mainSet);
|
||||||
|
@ -195,12 +195,14 @@ public class SettingsImportDialog extends PamDialog {
|
|||||||
@Override
|
@Override
|
||||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||||
SettingsImportGroup set = groupedSettings.get(rowIndex);
|
SettingsImportGroup set = groupedSettings.get(rowIndex);
|
||||||
PamControlledUnitSettings mainSet = set.getMainSettings();
|
// PamControlledUnitSettings mainSet = set.getMainSettings();
|
||||||
switch (columnIndex) {
|
switch (columnIndex) {
|
||||||
case 0:
|
case 0:
|
||||||
return mainSet.getUnitType();
|
return set.getUsedModuleInfo().getUnitType();
|
||||||
|
// return mainSet.getUnitType();
|
||||||
case 1:
|
case 1:
|
||||||
return mainSet.getUnitName();
|
return set.getUsedModuleInfo().unitName;
|
||||||
|
// return mainSet.getUnitName();
|
||||||
case 2:
|
case 2:
|
||||||
// return choiceBoxes[rowIndex].getSelectedItem().toString();
|
// return choiceBoxes[rowIndex].getSelectedItem().toString();
|
||||||
return set.getImportChoice().toString();
|
return set.getImportChoice().toString();
|
||||||
|
@ -82,8 +82,10 @@ public class SettingsImportGroup {
|
|||||||
try {
|
try {
|
||||||
ownerClass = Class.forName(usedModuleInfo.className);
|
ownerClass = Class.forName(usedModuleInfo.className);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
|
|
||||||
|
System.out.println("Unknown class in loaded settings: " + usedModuleInfo.className);
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
}
|
||||||
ArrayList<PamControlledUnit> existingModules =
|
ArrayList<PamControlledUnit> existingModules =
|
||||||
PamController.getInstance().findControlledUnits(ownerClass);
|
PamController.getInstance().findControlledUnits(ownerClass);
|
||||||
|
@ -614,6 +614,32 @@ public class FormsControl extends PamControlledUnit {
|
|||||||
return new ModuleStatus(ModuleStatus.STATUS_OK);
|
return new ModuleStatus(ModuleStatus.STATUS_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some things that are meant to be boolean are coming out as int or string so
|
||||||
|
* need to do some type checking.
|
||||||
|
* @param value
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Boolean checkBadBoolean(Object value) {
|
||||||
|
if (value instanceof Boolean) {
|
||||||
|
return (Boolean) value;
|
||||||
|
}
|
||||||
|
if (value == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (value instanceof String) {
|
||||||
|
String str = (String) value;
|
||||||
|
str = str.strip();
|
||||||
|
return str.equals("1") || str.toLowerCase().equals("false");
|
||||||
|
}
|
||||||
|
if (value instanceof Integer) {
|
||||||
|
int val = (Integer) value;
|
||||||
|
return val != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
// @Override
|
// @Override
|
||||||
// public Serializable getSettingsReference() {
|
// public Serializable getSettingsReference() {
|
||||||
// return (Serializable) dummyParams;
|
// return (Serializable) dummyParams;
|
||||||
|
@ -213,7 +213,7 @@ public class FormsDataDisplayTable {
|
|||||||
if (getColumnClass(columnIndex) == Boolean.class) {
|
if (getColumnClass(columnIndex) == Boolean.class) {
|
||||||
if (value instanceof Boolean == false) {
|
if (value instanceof Boolean == false) {
|
||||||
// System.out.println("Bad boolean value: " + value);
|
// System.out.println("Bad boolean value: " + value);
|
||||||
return interpretBadBoolean(value);
|
return FormsControl.checkBadBoolean(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
@ -260,22 +260,6 @@ public class FormsDataDisplayTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Boolean interpretBadBoolean(Object value) {
|
|
||||||
if (value == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (value instanceof String) {
|
|
||||||
String str = (String) value;
|
|
||||||
str = str.strip();
|
|
||||||
return str.equals("1") || str.toLowerCase().equals("false");
|
|
||||||
}
|
|
||||||
if (value instanceof Integer) {
|
|
||||||
int val = (Integer) value;
|
|
||||||
return val != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,6 +9,7 @@ import NMEA.NMEADataBlock;
|
|||||||
import NMEA.NMEADataUnit;
|
import NMEA.NMEADataUnit;
|
||||||
import PamView.dialog.PamCheckBox;
|
import PamView.dialog.PamCheckBox;
|
||||||
import PamView.dialog.PamLabel;
|
import PamView.dialog.PamLabel;
|
||||||
|
import loggerForms.FormsControl;
|
||||||
import loggerForms.LoggerForm;
|
import loggerForms.LoggerForm;
|
||||||
import loggerForms.controlDescriptions.ControlDescription;
|
import loggerForms.controlDescriptions.ControlDescription;
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ public class CheckboxControl extends LoggerControl {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
checkBox.setSelected((Boolean) data);
|
checkBox.setSelected(FormsControl.checkBadBoolean(data));
|
||||||
}
|
}
|
||||||
catch(ClassCastException e) {
|
catch(ClassCastException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -70,7 +70,7 @@ public class FormDataSelector extends DataSelector {
|
|||||||
@Override
|
@Override
|
||||||
public double scoreData(PamDataUnit pamDataUnit) {
|
public double scoreData(PamDataUnit pamDataUnit) {
|
||||||
if (controlDataSelector == null) {
|
if (controlDataSelector == null) {
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
Object[] formData = null;
|
Object[] formData = null;
|
||||||
if (pamDataUnit instanceof FormsDataUnit) {
|
if (pamDataUnit instanceof FormsDataUnit) {
|
||||||
|
Loading…
Reference in New Issue
Block a user