1 4 package com.nightlabs.rcp.exceptionhandler.wizard; 5 6 import org.apache.log4j.Logger; 7 import org.eclipse.jface.dialogs.MessageDialog; 8 9 import com.nightlabs.config.Config; 10 import com.nightlabs.rcp.wizard.DynamicPathWizard; 11 import com.nightlabs.rcp.wizard.IDynamicPathWizardPage; 12 13 16 public class ExceptionHandlerWizard extends DynamicPathWizard 17 { 18 public static final Logger LOGGER = Logger.getLogger(ExceptionHandlerWizard.class) ; 19 20 private ErrorReport errorReport; 21 22 private UserCommentPage sendExceptionPage; 23 24 private ExceptionSummaryPage exceptionSummaryPage; 25 26 27 28 29 33 public ExceptionHandlerWizard(ErrorReport errorReport) 34 { 35 this.errorReport = errorReport; 36 } 37 38 public IDynamicPathWizardPage createWizardEntryPage() 39 { 40 ExceptionHandlerEntryPage entry = new ExceptionHandlerEntryPage(); 41 sendExceptionPage = new UserCommentPage(); 42 exceptionSummaryPage = new ExceptionSummaryPage(); 43 addDynamicWizardPage(sendExceptionPage); 44 addDynamicWizardPage(exceptionSummaryPage); 45 setForcePreviousAndNextButtons(true); 46 return entry; 47 } 48 49 52 public boolean performFinish() 53 { 54 if (getStartingPage() == getDynamicWizardDialog().getCurrentPage()) 55 return true; 56 57 try { 58 Config configuration = Config.sharedInstance(); 60 61 ErrorReportSenderCfMod cfMod = (ErrorReportSenderCfMod) configuration.createConfigModule(ErrorReportSenderCfMod.class); 63 64 Class clazz; 65 try { 66 clazz = Class.forName(cfMod.getErrorReportSenderClass()); 67 } catch (Throwable x) { 68 throw new ClassNotFoundException ( 69 "Invalid configuration parameter in \"" + ErrorReportSenderCfMod.class + "\": Unable to load class \"" + cfMod.getErrorReportSenderClass() + "\"!", x); 70 } 71 72 if (!ErrorReportSender.class.isAssignableFrom(clazz)) 73 throw new ClassCastException ( 74 "Invalid configuration parameter in \"" + ErrorReportSenderCfMod.class + "\": Class \"" + cfMod.getErrorReportSenderClass() + "\" does not implement interface \""+ErrorReportSender.class.getName()+"\"!"); 75 76 ErrorReportSender sender = (ErrorReportSender) clazz.newInstance(); 77 sender.sendErrorReport(errorReport); 78 return true; 79 } catch (Throwable e) { 80 LOGGER.fatal("Sending ErrorReport failed!", e); 81 new MessageDialog( 82 getShell(), 83 "Sending Error Report failed!", 84 null, 85 e.getClass().getName() + ": " + e.getLocalizedMessage(), 86 MessageDialog.ERROR, 87 new String []{"OK"}, 88 0).open(); 89 } 90 return false; 91 } 92 93 public ErrorReport getErrorReport() 94 { 95 return errorReport; 96 } 97 } 98 | Popular Tags |