ptolemy.vergil
Class VergilErrorHandler

java.lang.Object
  extended by ptolemy.vergil.VergilErrorHandler
All Implemented Interfaces:
ErrorHandler

public class VergilErrorHandler
extends java.lang.Object
implements ErrorHandler

This error handler attempts to replace any failed MoML elements with generic versions so that the parsing of the MoML can continue. The generic versions, where appropriate, have icons that indicate failure.

Since:
Ptolemy II 2.0
Version:
$Id: VergilErrorHandler.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee
Accepted Rating:
Red (reviewmoderator)
Proposed Rating:
Red (eal)

Field Summary
private  boolean _skipping
           
private  boolean _skippingEnabled
           
 
Fields inherited from interface ptolemy.moml.ErrorHandler
CANCEL, CONTINUE, RETHROW
 
Constructor Summary
VergilErrorHandler()
           
 
Method Summary
private  int _showStackTrace(java.awt.Component context, boolean skipElement, boolean skippingEnabled, java.lang.Throwable exception, java.lang.String info)
          Display a stack trace dialog.
 void enableErrorSkipping(boolean enable)
          Enable or disable skipping of errors.
 int handleError(java.lang.String element, NamedObj context, java.lang.Throwable exception)
          Handle an error.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_skippingEnabled

private boolean _skippingEnabled

_skipping

private boolean _skipping
Constructor Detail

VergilErrorHandler

public VergilErrorHandler()
Method Detail

enableErrorSkipping

public void enableErrorSkipping(boolean enable)
Enable or disable skipping of errors. If this method is called with a true argument, then do not report subsequent errors when handleError() is called, and instead return CONTINUE. If it is called with a false argument, then report all subsequent errors.

This method is intended to be used when an operation may trigger a large number of errors, and the user interface wishes to offer the user the option of ignoring them. This method should be called with a true argument before the operation begins, and then called with a false argument after the operation ends.

Specified by:
enableErrorSkipping in interface ErrorHandler
Parameters:
enable - True to enable skipping, false to disable.

handleError

public int handleError(java.lang.String element,
                       NamedObj context,
                       java.lang.Throwable exception)
Handle an error.

Specified by:
handleError in interface ErrorHandler
Parameters:
element - The XML element that triggered the error.
context - The container object for the element.
exception - The exception that was thrown.
Returns:
CONTINUE to skip this element, CANCEL to abort processing of the XML, IGNORE to continue to process the XML as if nothing had happened, or RETHROW to request that the exception be rethrown.

_showStackTrace

private int _showStackTrace(java.awt.Component context,
                            boolean skipElement,
                            boolean skippingEnabled,
                            java.lang.Throwable exception,
                            java.lang.String info)
Display a stack trace dialog. The "info" argument is a string printed at the top of the dialog instead of the Exception message.

Parameters:
context - The context.
skipElement - True if one of the buttons should be 'Skip element'. If skippingEnabled is true, then the value of skipElement is ignored.
skippingEnabled - True if one of the buttons should be 'Skip remaining messages'.
exception - The exception.
info - A message.
Returns:
CONTINUE to skip this element, CANCEL to abort processing of the XML.