[Schmitzm-commits] r1313 - in trunk: src/schmitzm/mail src/schmitzm/swing src/schmitzm/swing/resource/locales src_junit/schmitzm/swing

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sun Nov 28 23:14:52 CET 2010


Author: alfonx
Date: 2010-11-28 23:14:52 +0100 (Sun, 28 Nov 2010)
New Revision: 1313

Modified:
   trunk/src/schmitzm/mail/MailUtil.java
   trunk/src/schmitzm/mail/Mailer.java
   trunk/src/schmitzm/swing/ExceptionDialog.java
   trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties
   trunk/src_junit/schmitzm/swing/ExceptionDialogTest.java
Log:


Modified: trunk/src/schmitzm/mail/MailUtil.java
===================================================================
--- trunk/src/schmitzm/mail/MailUtil.java	2010-11-28 21:51:04 UTC (rev 1312)
+++ trunk/src/schmitzm/mail/MailUtil.java	2010-11-28 22:14:52 UTC (rev 1313)
@@ -5,6 +5,7 @@
 import java.util.Date;
 import java.util.Locale;
 import java.util.Properties;
+import java.util.Set;
 
 import javax.mail.Message;
 import javax.mail.MessagingException;
@@ -168,8 +169,8 @@
 	 * @throws AddressException
 	 */
 	public static void sendExceptionMail(String mailDestAddr, Throwable err,
-			Object additionalInfo, Mailer smtpMailer) throws AddressException,
-			MessagingException {
+			Set<Object> additionalInfo, Mailer smtpMailer)
+			throws AddressException, MessagingException {
 		String exceptionMess = err.getMessage();
 		String exceptionStack = LangUtil.getStackTraceFromException(err);
 
@@ -181,10 +182,9 @@
 				.append(System.getProperty("java.version")).append("\n");
 
 		// insert optinal additional comment
-		if (additionalInfo != null) {
-			additionalInfo = LangUtil.trimNewlines(additionalInfo.toString());
-
-			mailBody.append(additionalInfo + "\n");
+		for (Object s : additionalInfo) {
+			String ss = LangUtil.trimNewlines(s.toString());
+			mailBody.append(ss + "\n");
 		}
 
 		mailBody.append("Comment:      ___________").append("\n").append("\n")
@@ -211,7 +211,7 @@
 	}
 
 	public static void sendDesktopExceptionMail(String destMailAddr,
-			Throwable error, Object additionalInfo) {
+			Throwable error, Set<Object> additionalInfo) {
 		try {
 			sendExceptionMail(destMailAddr, error, additionalInfo, null);
 		} catch (AddressException e) {

Modified: trunk/src/schmitzm/mail/Mailer.java
===================================================================
--- trunk/src/schmitzm/mail/Mailer.java	2010-11-28 21:51:04 UTC (rev 1312)
+++ trunk/src/schmitzm/mail/Mailer.java	2010-11-28 22:14:52 UTC (rev 1313)
@@ -1,5 +1,7 @@
 package schmitzm.mail;
 
+import java.util.Set;
+
 import javax.mail.MessagingException;
 import javax.mail.internet.AddressException;
 
@@ -29,7 +31,8 @@
 	}
 
 	public void sendMail(String mailDestAddr, Throwable error,
-			Object additionalInfo) throws AddressException, MessagingException {
+			Set<Object> additionalInfo) throws AddressException,
+			MessagingException {
 		MailUtil.sendExceptionMail(mailDestAddr, error, additionalInfo, this);
 	}
 

Modified: trunk/src/schmitzm/swing/ExceptionDialog.java
===================================================================
--- trunk/src/schmitzm/swing/ExceptionDialog.java	2010-11-28 21:51:04 UTC (rev 1312)
+++ trunk/src/schmitzm/swing/ExceptionDialog.java	2010-11-28 22:14:52 UTC (rev 1313)
@@ -38,6 +38,7 @@
 import java.lang.reflect.InvocationTargetException;
 import java.util.HashSet;
 import java.util.Set;
+import java.util.TreeSet;
 
 import javax.swing.JButton;
 import javax.swing.JDialog;
@@ -76,7 +77,7 @@
 	 * information (e.g. program version) when sending exception reports (e.g.
 	 * by mail)
 	 */
-	private static Object additionalAppInfo = null;
+	private static Set<Object> additionalAppInfo = new TreeSet<Object>();
 
 	/** Speichert den angezeigten Fehler. */
 	protected Throwable err = null;
@@ -273,13 +274,15 @@
 						smtpMailer.sendMail(destMailAddr, getError(),
 								getAdditionalAppInfo());
 
-						JOptionPane
-								.showMessageDialog(
-										ExceptionDialog.this,
-										SwingUtil
-												.R("ExceptionDialog.Mail.SendBySmtpOk"));
+						// JOptionPane
+						// .showMessageDialog(
+						// ExceptionDialog.this,
+						// SwingUtil
+						// .R("ExceptionDialog.Mail.SendBySmtpOk"));
+						// return;
 
-						return;
+						// Even if this was successfull, we tryto send a
+						// bugreport from
 					} catch (Exception ee) {
 					}
 				}
@@ -511,11 +514,11 @@
 		return throwRuntimeExceptionsBack;
 	}
 
-	public static void setAdditionalAppInfo(Object additionalAppInfo) {
-		ExceptionDialog.additionalAppInfo = additionalAppInfo;
+	public static void addAdditionalAppInfo(Object additionalAppInfo) {
+		ExceptionDialog.additionalAppInfo.add(additionalAppInfo);
 	}
 
-	public static Object getAdditionalAppInfo() {
+	public static Set<Object> getAdditionalAppInfo() {
 		return additionalAppInfo;
 	}
 

Modified: trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties
===================================================================
--- trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties	2010-11-28 21:51:04 UTC (rev 1312)
+++ trunk/src/schmitzm/swing/resource/locales/SwingResourceBundle.properties	2010-11-28 22:14:52 UTC (rev 1313)
@@ -94,7 +94,7 @@
 ExceptionDialog.CopyToConsole=Copy to console
 ExceptionDialog.Mail=Mail
 ExceptionDialog.MailDisabled.Desc=Mailing currently not available, because a destination mail address for bug reporting is not set in this application (ExceptionDialog.setMailDestinationAddress(..))
-ExceptionDialog.Mail.SendBySmtpOk=<html>An email has been send to bugreport at wikisquare.de.<br>If you supplied your email-address, expect feedback from tzeggai at wikisquare.de.</html>
+#ExceptionDialog.Mail.SendBySmtpOk=<html>An email has been send to bugreport at wikisquare.de.<br>If you supplied your email-address, expect feedback from tzeggai at wikisquare.de.</html>
 
 ManualInputOption.PasswordVisible.visibility=visible
 

Modified: trunk/src_junit/schmitzm/swing/ExceptionDialogTest.java
===================================================================
--- trunk/src_junit/schmitzm/swing/ExceptionDialogTest.java	2010-11-28 21:51:04 UTC (rev 1312)
+++ trunk/src_junit/schmitzm/swing/ExceptionDialogTest.java	2010-11-28 22:14:52 UTC (rev 1313)
@@ -19,33 +19,41 @@
 	}
 
 	@Test
-	public void testShowThrowable() throws InterruptedException, InvocationTargetException {
-		ExceptionDialog.show(new RuntimeException("Test on Application Thread"));
-		
+	public void testShowThrowable() throws InterruptedException,
+			InvocationTargetException {
+		ExceptionDialog
+				.show(new RuntimeException("Test on Application Thread"));
+
 		SwingUtilities.invokeAndWait(new Runnable() {
-			
+
 			@Override
 			public void run() {
-				ExceptionDialog.show(new RuntimeException("Test on EDT Thread"));	
+				ExceptionDialog
+						.show(new RuntimeException("Test on EDT Thread"));
 			}
 		});
 	}
 
 	@Test
-	public void testShowThrowableWithMailAndHTMLInEception() throws InterruptedException, InvocationTargetException {
+	public void testShowThrowableWithMailAndHTMLInEception()
+			throws InterruptedException, InvocationTargetException {
 		ExceptionDialog.setMailDestinationAddress("tzeggai at wikisquare.de");
-		ExceptionDialog.setAdditionalAppInfo("more <html><i>Samolellen</i></html> information\nand more information");
+		ExceptionDialog
+				.addAdditionalAppInfo("more <html><i>Samolellen</i></html> information\nand more information");
 		// TODO automatisch schliessen
-		ExceptionDialog.show(new RuntimeException("Test <html><i>Samolellen</i></html>more info"));
+		ExceptionDialog.show(new RuntimeException(
+				"Test <html><i>Samolellen</i></html>more info"));
 	}
 
-
 	@Test
-	public void testShowThrowableWithMail() throws InterruptedException, InvocationTargetException {
+	public void testShowThrowableWithMail() throws InterruptedException,
+			InvocationTargetException {
 		ExceptionDialog.setMailDestinationAddress("tzeggai at wikisquare.de");
-		ExceptionDialog.setAdditionalAppInfo("more information\nand more information");
+		ExceptionDialog
+				.addAdditionalAppInfo("more information\nand more information");
 		// TODO automatisch schliessen
-		ExceptionDialog.show(new RuntimeException("Test with mail that conatins more info"));
+		ExceptionDialog.show(new RuntimeException(
+				"Test with mail that conatins more info"));
 	}
 
 }



More information about the Schmitzm-commits mailing list