|
swingx Version 2005-08-19 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jdesktop.swingx.ErrorReporter
org.jdesktop.swingx.MailErrorReporter
public class MailErrorReporter
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.ListtoAddr, 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)); } }
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 |
---|
public MailErrorReporter(String address)
address
- Method Detail |
---|
public String getMailAddr()
public void setMailAddr(String mailAddr)
mailAddr
- public void setMailTransportProxy(MailTransportProxy mailTransportProxy)
public void reportIncident(IncidentInfo info)
reportIncident
in class ErrorReporter
info
- IncidentInfo
which incorporates all the information on errorpublic String getMessageBody(IncidentInfo incident)
IncidentInfo
.
Override this method to change text formatting or contents.
incident
- - Incapsulates all the information about error
public List<String> getAttachments(IncidentInfo incident)
incident
- - Incapsulates all the information about error
|
swingx Version 2005-08-19 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |