[Title] Create stack trace dialog
authorho.namkoong <ho.namkoong@samsung.com>
Sat, 1 Sep 2012 12:26:36 +0000 (21:26 +0900)
committerho.namkoong <ho.namkoong@samsung.com>
Mon, 3 Sep 2012 01:41:22 +0000 (10:41 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: I68f732b5511997071530d600de9bae10b9612533

org.tizen.common/src/org/tizen/common/util/CipherUtil.java
org.tizen.common/src/org/tizen/common/util/SWTUtil.java

index dbaec53..2521a44 100644 (file)
@@ -35,7 +35,7 @@ import org.tizen.common.util.log.Logger;
 import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
 
 /**
- * PluginUtil 
+ * CipherUtil 
  * 
  * This is a util class for encrypting and decrypting plain texts. 
  *  
@@ -43,7 +43,7 @@ import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
  */
 public class CipherUtil {
 
-    private static final String password = "ANYLINKhijklmnopqrstuvwx";
+    private static final String password = "KYANINYLhijklmnopqrstuvwx";
     private static SecretKey SECRETE_KEY;
     private static Cipher DES_CIPHER;
     private static final String ALGORITHM = "DESede";
@@ -57,7 +57,7 @@ public class CipherUtil {
             
             DES_CIPHER = Cipher.getInstance(ALGORITHM + "/ECB/PKCS5Padding");
         } catch (Throwable t) {
-            Logger.error("Exception occurred while creating secrete key", t);
+            Logger.error("Exception occurred while creating secret key", t);
         }
     }
     
index 5d0c0ed..42b0f13 100755 (executable)
@@ -26,10 +26,14 @@ package org.tizen.common.util;
 
 import java.awt.Dimension;
 import java.awt.Toolkit;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Stack;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -37,6 +41,10 @@ import java.util.regex.Pattern;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.resources.IWorkspaceRoot;
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.ScrolledComposite;
 import org.eclipse.swt.events.VerifyEvent;
@@ -484,4 +492,32 @@ public class SWTUtil {
         }
         c.setLayoutData(gd);
     }
+    
+    /**
+     * Make error dialog which prints stack trace of the throwable 
+     *
+     * @param title title of the dialog
+     * @param msg message of the dialog
+     * @param t throwable diaog prints out 
+     * @param shell parent shell of this dialog
+     * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+     */
+    public static void errorDialogWithStackTrace(String title, String msg, Throwable t, String pluginId, Shell shell) {
+        
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        t.printStackTrace(pw);
+        
+        final String trace = sw.toString();
+        
+        List<Status> childStatuses = new ArrayList<Status>();
+        
+        for(String line: trace.split("\n")) {
+            childStatuses.add(new Status(IStatus.ERROR, pluginId, line));
+        }
+        
+        MultiStatus ms = new MultiStatus(pluginId, IStatus.ERROR, childStatuses.toArray(new Status[] {}), t.getLocalizedMessage(), t);
+        
+        ErrorDialog.openError(shell, "Error Dialog", msg, ms);
+    }
 }