1 19 20 package org.netbeans.modules.websvc.registry.ui; 21 22 import org.openide.DialogDescriptor; 23 import org.openide.DialogDisplayer; 24 import org.openide.ErrorManager; 25 import org.openide.NotifyDescriptor; 26 import org.openide.util.NbBundle; 27 import org.openide.util.HelpCtx; 28 import javax.swing.text.html.HTMLEditorKit ; 29 30 import java.io.StringWriter ; 31 32 import javax.swing.JButton ; 33 34 import java.awt.Dialog ; 35 36 40 public class MethodExceptionDialog extends javax.swing.JPanel { 41 42 private String currentMessage = ""; 43 private JButton okButton = new JButton (NbBundle.getMessage(this.getClass(), "OPTION_OK")); 44 private DialogDescriptor dlg; 45 private Dialog dialog; 46 47 48 public MethodExceptionDialog(Exception inException) { 49 initComponents(); 50 setMessage(inException,false); 51 52 } 53 public void show(){ 54 55 dlg = new DialogDescriptor(this, NbBundle.getMessage(this.getClass(), "CLIENT_EXCEPTION"), 56 false, NotifyDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, 57 DialogDescriptor.DEFAULT_ALIGN, this.getHelpCtx(), null); 58 dlg.setOptions(new Object [] { okButton }); 59 dialog = DialogDisplayer.getDefault().createDialog(dlg); 60 dialog.setSize(500,300); 61 dialog.show(); 62 } 63 public HelpCtx getHelpCtx() { 64 return new HelpCtx(TestWebServiceMethodDlg.class); 65 } 66 67 72 private void initComponents() { scrollPane = new javax.swing.JScrollPane (); 74 messagePane = new javax.swing.JEditorPane (); 75 76 setLayout(new java.awt.BorderLayout ()); 77 78 messagePane.setEditorKit(new HTMLEditorKit () 79 ); 80 scrollPane.setViewportView(messagePane); 81 82 add(scrollPane, java.awt.BorderLayout.CENTER); 83 84 } 86 public void setMessage(Exception inException,boolean keepOld){ 87 88 89 String htmlStart = "<HTML><HEAD>" + 90 "<style type=\"text/css\">" + 91 "body { font-family: Verdana, sans-serif; font-size: 12; }" + 92 "</style>" + 93 "</HEAD>" + 94 "<BODY>"; 95 String htmlEnd = "</BODY></HTML>"; 96 String exceptionString = ""; 97 100 Throwable cause = inException; 101 while(null != cause) { 102 exceptionString += "<BR><FONT COLOR=\"RED\">" + cause.getLocalizedMessage() + "</FONT>"; 103 StackTraceElement [] traceElements = cause.getStackTrace(); 104 String stackTrace = "<BR>Stack Trace<BR><BR>"; 105 for(int ii=0;ii < traceElements.length;ii++) { 106 exceptionString += "<BR>" + traceElements[ii].toString(); 107 } 108 cause = cause.getCause(); 109 if(null != cause) { 110 exceptionString += "<BR>Next Exception Layer"; 111 } 112 } 113 114 115 if(keepOld) { 116 currentMessage += exceptionString; 117 } else { 118 currentMessage = exceptionString; 119 } 120 121 122 123 124 messagePane.setText(htmlStart + currentMessage + htmlEnd); 125 } 126 127 128 private javax.swing.JEditorPane messagePane; 130 private javax.swing.JScrollPane scrollPane; 131 133 } 134 | Popular Tags |