swingx
Version 2005-08-19

org.jdesktop.swingx
Class MailErrorReporter

java.lang.Object
  extended by org.jdesktop.swingx.ErrorReporter
      extended by org.jdesktop.swingx.MailErrorReporter

public class MailErrorReporter
extends ErrorReporter

This reporter initializes and uses default mail user agent to send information to predefined mail address. To send error message one needs to configure an MailTransportProxy. For example, here is how to use it with JDIC library


 import org.jdesktop.swingx.util.MailTransportProxy;
 import org.jdesktop.swingx.*;
 import org.jdesktop.jdic.desktop.Message;
 import org.jdesktop.jdic.desktop.Desktop;
 import org.jdesktop.jdic.desktop.DesktopException;

 public class TestApp {
     public static class MyMailTransport implements MailTransportProxy {
         public void mailMessage(java.util.List toAddr,
                                 java.util.List ccAddr,
                                 String subject, String body,
                                 java.util.List attach) throws Error {
             Error result = null;

             Message msg = new Message();
             msg.setToAddrs(toAddr);
             msg.setCcAddrs(ccAddr);
             msg.setSubject(subject);
             msg.setBody(body);
             try {
                 msg.setAttachments(attach);
             } catch (IOException e) {
                 e.printStackTrace();
             }
             try {
                 Desktop.mail(msg);
             } catch (DesktopException e) {
                 result = new Error(e);
                 result.setStackTrace(Thread.currentThread().getStackTrace());
                 throw result;
             }
         }
     }
     public static void main(String args[]) {
         JFrame jf = new JFrame("Main frame");
     ... In the program body ...
         String errorDetails = "The filter factory can't accept this value";
         MailErrorReporter reporter = new MailErrorReporter("someone@the.net");
         reporter.setMailTransportProxy(new MyMailTransport());
         JXErrorDialog.setReporter(reporter);
         JXErrorDialog.showDialog(jf, "Filter Error", new RuntimeException(errorDetails));
     }
 } 

Version:
1.0

Constructor Summary
MailErrorReporter(String address)
          Constructs new MailErrorReporter with the given address assigned as destination address for error report.
 
Method Summary
 List<String> getAttachments(IncidentInfo incident)
          This method is used to extract list of paths to files that we want to send as attachment with the current incident report mwssage.
 String getMailAddr()
          Get the mail address to which send error report
 String getMessageBody(IncidentInfo incident)
          This method is used to extract text message from the provided IncidentInfo.
 void reportIncident(IncidentInfo info)
          Report given incident by popping up system default mail user agent with prepared message
 void setMailAddr(String mailAddr)
          Set the address to which we will send mail
 void setMailTransportProxy(MailTransportProxy mailTransportProxy)
           
 
Methods inherited from class org.jdesktop.swingx.ErrorReporter
getActionName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MailErrorReporter

public MailErrorReporter(String address)
Constructs new MailErrorReporter with the given address assigned as destination address for error report.

Parameters:
address -
Method Detail

getMailAddr

public String getMailAddr()
Get the mail address to which send error report

Returns:
mail address

setMailAddr

public void setMailAddr(String mailAddr)
Set the address to which we will send mail

Parameters:
mailAddr -

setMailTransportProxy

public void setMailTransportProxy(MailTransportProxy mailTransportProxy)

reportIncident

public void reportIncident(IncidentInfo info)
Report given incident by popping up system default mail user agent with prepared message

Specified by:
reportIncident in class ErrorReporter
Parameters:
info - IncidentInfo which incorporates all the information on error

getMessageBody

public String getMessageBody(IncidentInfo incident)
This method is used to extract text message from the provided IncidentInfo. Override this method to change text formatting or contents.

Parameters:
incident - - Incapsulates all the information about error
Returns:
String to be used as a body message in report.

getAttachments

public List<String> getAttachments(IncidentInfo incident)
This method is used to extract list of paths to files that we want to send as attachment with the current incident report mwssage.

Parameters:
incident - - Incapsulates all the information about error
Returns:
List of Strings containing pathis to files

swingx
Version 2005-08-19