We now print the missing classes to stdout.
MessageHandler can have selectable text if you invoke MessageHandler.warning(String, Throwable) and click on the Stack Trace button. However, in general, we don't call MessageHandler.warning(), we throw an exception instead. See bug #4147 "Error message with selectable text" for details.
I don't think we want to use MessageHandler.warning() here because it brings up yet another dialog to click through when there is a missing class or classes. So, I stuck with printing to stderr. If a dialog is really wanted, then perhaps MoMLParser could check for a property being set before calling MessageHandler? Maybe
if (!StringUtilities.getProperty("KEPLER").equals("")) {
MessageHandler.warning("Missing Classes", new Exception(warning.toString()));
}
A couple of changes I made to the patch:
1) Use a HashSet so that missing classes appear only once
2) Added a private method to add classes to the Set of missing classes so that we can call this from multiple places.
The guts of the code look like:
// See https://projects.ecoinformatics.org/ecoinfo/issues/6587: summarize missing actors
if (_missingClasses != null) {
StringBuffer warning = new StringBuffer();
for(String missingClass : _missingClasses) {
warning.append(missingClass + ", ");
}
// Get rid of the trailing comma and space.
warning.delete(warning.length()-2, warning.length());
// Adding another dialog is annoying, so we print out the warning.
System.err.println("Warning: Missing Classes: " + warning);
// MessageHandler(String) is not selectable, so we use MessageHandler(String, Throwable).
//MessageHandler.warning("Missing Classes", new Exception(warning.toString()));
}
The ptII repo change is r69837.
I'm leaving this for Dan to close if he thinks it is closeable.