Subversion Repository Public Repository

litesoft

Diff Revisions 724 vs 948 for /trunk/GWT_Sandbox/FormEngine/src/com/temp/client/foundation/support/ExceptionDialogBasedSystemErrorReporter.java

Diff revisions: vs.
  @@ -1,20 +1,16 @@
1 1 package com.temp.client.foundation.support;
2 2
3 - import java.util.LinkedHashMap;
4 - import java.util.Map;
3 + import org.litesoft.core.util.*;
5 4
6 - import com.temp.client.foundation.handler.DialogClose;
7 - import com.temp.client.foundation.widget.dialog.ExceptionDialog;
8 - import com.temp.shared.utils.Assert;
9 - import com.temp.shared.utils.ContextThrowables;
10 - import com.temp.shared.utils.SourceIssues;
11 - import com.temp.shared.utils.StringUtils;
12 - import com.temp.shared.utils.SystemErrorReporter;
13 - import org.litesoft.core.util.TemplateSource;
5 + import com.temp.client.foundation.handler.*;
6 + import com.temp.client.foundation.widget.dialog.*;
7 + import com.temp.shared.utils.*;
8 +
9 + import java.util.*;
14 10
15 11 /**
16 12 * A SystemErrorReporter that utilizes an ExceptionDialog.
17 - *
13 + * <p/>
18 14 * This class is specifically designed to group multiple exceptions from the
19 15 * same "source" into a single dialog. This means that if there is an
20 16 * expectation that multiple exceptions are possible/likely, then the templates
  @@ -23,7 +19,8 @@
23 19 *
24 20 * @author georgs
25 21 */
26 - public class ExceptionDialogBasedSystemErrorReporter implements SystemErrorReporter, DialogClose {
22 + public class ExceptionDialogBasedSystemErrorReporter implements SystemErrorReporter,
23 + DialogClose {
27 24
28 25 public static final String ERROR_PERSISTS_CONTACT_TEXT = "If the error persists, please open a Contact Us.";
29 26
  @@ -33,46 +30,46 @@
33 30
34 31 private Map<String, SourceIssues> pendingIssues = new LinkedHashMap<String, SourceIssues>();
35 32
36 - public ExceptionDialogBasedSystemErrorReporter(TemplateSource ts) {
33 + public ExceptionDialogBasedSystemErrorReporter( TemplateSource ts ) {
37 34 this.ts = ts;
38 35 }
39 36
40 37 @Override
41 - public void reportSystemError(String source, String context, Throwable throwable) {
42 - source = Assert.noEmpty("source", source);
43 - context = StringUtils.noEmpty(context);
44 - Assert.notNull("throwable", throwable);
45 - if (currentDialog != null) {
46 - if (source.equals(currentDialogSource)) {
47 - currentDialog.add(context, throwable);
38 + public void reportSystemError( String source, String context, Throwable throwable ) {
39 + source = Assert.noEmpty( "source", source );
40 + context = StringUtils.noEmpty( context );
41 + Assert.notNull( "throwable", throwable );
42 + if ( currentDialog != null ) {
43 + if ( source.equals( currentDialogSource ) ) {
44 + currentDialog.add( context, throwable );
48 45 } else {
49 - SourceIssues issues = pendingIssues.get(source);
50 - if (issues == null) {
51 - pendingIssues.put(source, new SourceIssues(source, context, throwable));
46 + SourceIssues issues = pendingIssues.get( source );
47 + if ( issues == null ) {
48 + pendingIssues.put( source, new SourceIssues( source, context, throwable ) );
52 49 } else {
53 - issues.add(context, throwable);
50 + issues.add( context, throwable );
54 51 }
55 52 }
56 53 return;
57 54 }
58 - currentDialog = createDialog(currentDialogSource = source, context, throwable);
59 - currentDialog.show(this);
55 + currentDialog = createDialog( currentDialogSource = source, context, throwable );
56 + currentDialog.show( this );
60 57 }
61 58
62 59 /**
63 60 * Dialog Close Callback
64 - *
61 + * <p/>
65 62 * If there are any pending issues (SourceIssues) then display the next one.
66 63 */
67 64 @Override
68 65 public void closed() {
69 - if (pendingIssues.isEmpty()) {
66 + if ( pendingIssues.isEmpty() ) {
70 67 currentDialogSource = null;
71 68 currentDialog = null;
72 69 } else {
73 70 SourceIssues issues = pendingIssues.values().iterator().next();
74 71 String source = issues.getSource();
75 - pendingIssues.remove(source);
72 + pendingIssues.remove( source );
76 73
77 74 ContextThrowables[] contextThrowables = issues.getContextThrowables();
78 75
  @@ -80,23 +77,23 @@
80 77 String context = ct.getContext();
81 78 Throwable[] throwables = ct.getThrowables();
82 79
83 - currentDialog = createDialog(currentDialogSource = source, context, throwables[0]);
84 - for (int i = 1; i < throwables.length; i++) {
85 - currentDialog.add(context, throwables[i]);
80 + currentDialog = createDialog( currentDialogSource = source, context, throwables[0] );
81 + for ( int i = 1; i < throwables.length; i++ ) {
82 + currentDialog.add( context, throwables[i] );
86 83 }
87 - for (int i = 1; i < contextThrowables.length; i++) {
84 + for ( int i = 1; i < contextThrowables.length; i++ ) {
88 85 ct = contextThrowables[i];
89 - currentDialog.add(ct.getContext(), ct.getThrowables());
86 + currentDialog.add( ct.getContext(), ct.getThrowables() );
90 87 }
91 88
92 - currentDialog.show(this);
89 + currentDialog.show( this );
93 90 }
94 91 }
95 92
96 - protected ExceptionDialog createDialog(String source, String context, Throwable throwable) {
97 - ExceptionDisplayHelper helper = new ExceptionDisplayHelper(ts, source, context, throwable, //
98 - "", //
99 - ERROR_PERSISTS_CONTACT_TEXT);
100 - return new ExceptionDialog(helper.noDetails(), helper.getTitle(), source, context, throwable, helper.getTextBlocks());
93 + protected ExceptionDialog createDialog( String source, String context, Throwable throwable ) {
94 + ExceptionDisplayHelper helper = new ExceptionDisplayHelper( ts, source, context, throwable, //
95 + "", //
96 + ERROR_PERSISTS_CONTACT_TEXT );
97 + return new ExceptionDialog( helper.noDetails(), helper.getTitle(), source, context, throwable, helper.getTextBlocks() );
101 98 }
102 99 }