1 4 package com.tc; 5 6 import org.apache.commons.io.IOUtils; 7 8 import org.dijon.Dialog; 9 import org.dijon.DialogResource; 10 11 import com.tc.admin.common.XButton; 12 import com.tc.admin.common.XTextArea; 13 import com.tc.admin.common.XTextField; 14 15 import java.awt.event.ActionEvent ; 16 import java.awt.event.ActionListener ; 17 import java.io.PrintWriter ; 18 import java.io.StringWriter ; 19 20 public class ErrorDialog extends Dialog { 21 private static DialogResource m_dialogRes; 22 23 private XTextArea m_errorText; 24 private XTextField m_messageText; 25 private XButton m_closeButton; 26 27 static { 28 m_dialogRes = SessionIntegrator.getContext().topRes.findDialog("ErrorDialog"); 29 } 30 31 public ErrorDialog() { 32 super(m_dialogRes); 33 34 m_errorText = (XTextArea)findComponent("ErrorText"); 35 m_messageText = (XTextField)findComponent("MessageText"); 36 m_closeButton = (XButton)findComponent("CloseButton"); 37 38 m_closeButton.addActionListener(new ActionListener () { 39 public void actionPerformed(ActionEvent ae) { 40 setVisible(false); 41 } 42 }); 43 } 44 45 public ErrorDialog(String message, Throwable t) { 46 this(); 47 48 if(t != null) { 49 setError(t); 50 } 51 setMessage(message); 52 } 53 54 public void setError(Throwable t) { 55 StringWriter sw = new StringWriter (); 56 PrintWriter pw = new PrintWriter (sw); 57 58 t.printStackTrace(pw); 59 setErrorText(sw.toString()); 60 IOUtils.closeQuietly(pw); 61 } 62 63 public void setErrorText(String errorText) { 64 m_errorText.setText(errorText); 65 } 66 67 public void setMessage(String message) { 68 m_messageText.setText(message); 69 } 70 } 71 | Popular Tags |