fix metadata diaog

And also change class loader for plugins to not initialise classes since it causes an error if a plugin is depenent on a class in a plugin not yet loaded
This commit is contained in:
Douglas Gillespie 2024-05-22 19:08:58 +01:00
parent 4e0eacde99
commit 63b2572b8b
5 changed files with 30 additions and 13 deletions

View File

@ -6,9 +6,8 @@
<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/jdk-21.0.2.13-hotspot">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>

View File

@ -1,9 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=18
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=18
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@ -13,4 +13,4 @@ org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=18
org.eclipse.jdt.core.compiler.source=17

View File

@ -1197,7 +1197,13 @@ final public class PamModel implements PamSettings {
// Save the name of the class to the global pluginBeingLoaded variable, and load the class.
this.setPluginBeingLoaded(className);
// Class c = cl.loadClass(className);
Class c = Class.forName(className, true, classLoader);
/*
* Was Failing here if a plugin is loaded before a plugin that has classes
* this one is dependent on. Seems that if we set the second parameter to
* false then it doesn't fully initialize the class, so will be OK, get past
* this stage and fully load the class when it's used.
*/
Class c = Class.forName(className, false, classLoader);
if (getPluginBeingLoaded()==null) {
continue;
}
@ -1278,7 +1284,8 @@ final public class PamModel implements PamSettings {
"This may have been caused by an incompatibility between " +
"the plug-in and this version of PAMGuard. Please check the developer's website " +
"for help.<p>" +
"This plug-in will not be available for loading";
"This plug-in will not be available for loading<p>" +
e1.getClass().getName() + ": " + e1.getLocalizedMessage();
String help = null;
int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help, e1);
System.err.println("Exception while loading " + className);
@ -1288,12 +1295,14 @@ final public class PamModel implements PamSettings {
}
}
} catch (Throwable ex) {
ex.printStackTrace();
String title = "Error accessing plug-in module";
String msg = "There is an error with the plug-in module " + jarList.get(i).getName() + ".<p>" +
"This may have been caused by an incompatibility between " +
"the plug-in and this version of PAMGuard. Please check the developer's website " +
"for help.<p>" +
"This plug-in will not be available for loading";
"This plug-in will not be available for loading<p>" +
ex.getClass().getName() + ": " + ex.getLocalizedMessage();
String help = null;
int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help, ex);
System.err.println("Exception while loading " + jarList.get(i).getName());

View File

@ -185,10 +185,18 @@ public class PamArrayUtils {
public static double median(double[] numArray) {
Arrays.sort(numArray);
double median;
if (numArray.length % 2 == 0)
median = ((double)numArray[numArray.length/2] + (double) numArray[numArray.length/2 - 1])/2;
else
median = (double) numArray[numArray.length/2];
int n = numArray.length;
if (n == 0) {
return 0;
}
if (n % 2 == 0) {
n/=2;
median = ((double)numArray[n] + (double) numArray[n - 1])/2;
}
else {
n/=2;
median = (double) numArray[n];
}
return median;
}

View File

@ -98,7 +98,8 @@ public class MetaDataDialog extends PamDialog {
@Override
public boolean getParams() {
Deployment deployment = pamguardMetaData.getDeployment();
boolean ok = descriptionPanel.getParams(deployment.getDescription());
boolean ok = projectInformationPanel.getParams(deployment);
ok &= descriptionPanel.getParams(deployment.getDescription());
ok &= responsiblePanel.getParams(deployment.getMetadataInfo().getContact());
ok &= deploymentPeriodPanel.getParams(pamguardMetaData);