Project

General

Profile

Feature #6587

summarize missing actors

Added by Daniel Crawl over 4 years ago. Updated over 3 years ago.

Status:
New
Priority:
Low
Assignee:
Category:
general
Target version:
Start date:
08/21/2014
Due date:
% Done:

90%

Estimated time:
Spent time:
Bugzilla-Id:

Description

If a workflow is opened that contains actors that are not present in the class path, an error dialog is displayed for each actor. It would be nice if a list of all the missing actors were displayed.

Attached is a modified MoMLParser.java (based on ptolemy-kepler-2.4 sources) from Philippe Huyhn that displays the missing actors. The list of missing actors is written to stdout. Using MessageHandler would be preferred since it displays a dialog, but MessageHandler appears to not allow copy and paste.

MoMLParser.java (336 KB) MoMLParser.java Daniel Crawl, 08/21/2014 09:49 AM

History

#1 Updated by Christopher Brooks over 4 years ago

I'll take a look.

#2 Updated by Christopher Brooks over 4 years ago

  • % Done changed from 0 to 90

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.

#3 Updated by Daniel Crawl over 4 years ago

Thanks for folding these changes in to MoMLParser, Christopher. I'll ask Philippe if he really wants a dialog or stderr is fine.

#4 Updated by Daniel Crawl over 3 years ago

  • Priority changed from Normal to Low
  • Target version changed from 2.5.0 to 2.X.Y

I agree with you that stderr is better than another dialog, but Philippe wants a dialog. Could MoMLParser check a property like ptolemy.ptII.missingClassesDialog? The default value can be false to use stderr.

I'm lowering the priority since this has been around a long time.

Also available in: Atom PDF