|
@@ -1,18 +1,12 @@ |
1 |
1 |
|
package com.temp.client.foundation.widget.dialog; |
2 |
2 |
|
|
3 |
|
- |
import com.temp.client.foundation.handler.DialogClose; |
4 |
|
- |
import com.temp.client.foundation.util.UtilsGwt; |
5 |
|
- |
import com.temp.client.foundation.widget.LeftRightPanel; |
6 |
|
- |
import com.temp.client.foundation.widget.OurPushButton; |
7 |
|
- |
import com.temp.shared.utils.ExceptionStackTracePrintStream; |
8 |
|
- |
import com.temp.shared.utils.SourceIssues; |
9 |
|
- |
import com.temp.shared.utils.StringUtils; |
10 |
|
- |
|
11 |
|
- |
import com.google.gwt.core.client.GWT; |
12 |
|
- |
import com.google.gwt.event.dom.client.ClickEvent; |
13 |
|
- |
import com.google.gwt.event.dom.client.ClickHandler; |
14 |
|
- |
import com.google.gwt.user.client.ui.VerticalPanel; |
15 |
|
- |
import com.google.gwt.user.client.ui.Widget; |
|
3 |
+ |
import com.google.gwt.core.client.*; |
|
4 |
+ |
import com.google.gwt.event.dom.client.*; |
|
5 |
+ |
import com.google.gwt.user.client.ui.*; |
|
6 |
+ |
import com.temp.client.foundation.handler.*; |
|
7 |
+ |
import com.temp.client.foundation.util.*; |
|
8 |
+ |
import com.temp.client.foundation.widget.*; |
|
9 |
+ |
import com.temp.shared.utils.*; |
16 |
10 |
|
|
17 |
11 |
|
/** |
18 |
12 |
|
* This custom dialog shows custom title, body lines (description) followed by a |
|
@@ -28,73 +22,74 @@ |
28 |
22 |
|
|
29 |
23 |
|
private final SourceIssues sourceIssues; |
30 |
24 |
|
|
31 |
|
- |
public ExceptionDialog(boolean noDetails, String title, Integer contentWidth, String source, String context, Throwable throwable, String... bodyTextBlocksAboveControlButtons) { |
32 |
|
- |
super("images/dialog/alertIcon.png", contentWidth, title); |
33 |
|
- |
|
34 |
|
- |
sourceIssues = new SourceIssues(source, context, throwable); |
35 |
|
- |
if (!sourceIssues.hasThrowables()) { |
36 |
|
- |
throw new IllegalArgumentException("ExceptionDialog requested w/o an Exception!"); |
|
25 |
+ |
public ExceptionDialog( boolean noDetails, String title, Integer contentWidth, String source, String context, Throwable throwable, |
|
26 |
+ |
String... bodyTextBlocksAboveControlButtons ) { |
|
27 |
+ |
super( "images/dialog/alertIcon.png", contentWidth, title ); |
|
28 |
+ |
|
|
29 |
+ |
sourceIssues = new SourceIssues( source, context, throwable ); |
|
30 |
+ |
if ( !sourceIssues.hasThrowables() ) { |
|
31 |
+ |
throw new IllegalArgumentException( "ExceptionDialog requested w/o an Exception!" ); |
37 |
32 |
|
} |
38 |
33 |
|
boolean detailsButtonAdded = false; |
39 |
34 |
|
VerticalPanel panel = new VerticalPanel(); |
40 |
35 |
|
|
41 |
|
- |
if (bodyTextBlocksAboveControlButtons != null) { |
42 |
|
- |
for (String block : bodyTextBlocksAboveControlButtons) { |
43 |
|
- |
if (block != null) { |
|
36 |
+ |
if ( bodyTextBlocksAboveControlButtons != null ) { |
|
37 |
+ |
for ( String block : bodyTextBlocksAboveControlButtons ) { |
|
38 |
+ |
if ( block != null ) { |
44 |
39 |
|
Widget widget; |
45 |
|
- |
int addDetailsAt = block.indexOf(DETAILS_BUTTON_SUBSTITUTION_ID); |
46 |
|
- |
if (addDetailsAt == -1) { |
47 |
|
- |
widget = makeLabel(block); |
|
40 |
+ |
int addDetailsAt = block.indexOf( DETAILS_BUTTON_SUBSTITUTION_ID ); |
|
41 |
+ |
if ( addDetailsAt == -1 ) { |
|
42 |
+ |
widget = makeLabel( block ); |
48 |
43 |
|
} else { |
49 |
|
- |
String left = block.substring(0, addDetailsAt); |
50 |
|
- |
String right = block.substring(addDetailsAt + DETAILS_BUTTON_SUBSTITUTION_ID.length()); |
51 |
|
- |
if (noDetails) { |
52 |
|
- |
widget = makeLabel(left + right); |
|
44 |
+ |
String left = block.substring( 0, addDetailsAt ); |
|
45 |
+ |
String right = block.substring( addDetailsAt + DETAILS_BUTTON_SUBSTITUTION_ID.length() ); |
|
46 |
+ |
if ( noDetails ) { |
|
47 |
+ |
widget = makeLabel( left + right ); |
53 |
48 |
|
} else { |
54 |
49 |
|
detailsButtonAdded = true; |
55 |
|
- |
if (StringUtils.isBlank(right)) { |
56 |
|
- |
widget = new LeftRightPanel(makeLabel(left), createDetailsButton()); |
|
50 |
+ |
if ( StringUtils.isBlank( right ) ) { |
|
51 |
+ |
widget = new LeftRightPanel( makeLabel( left ), createDetailsButton() ); |
57 |
52 |
|
} else { |
58 |
|
- |
widget = UtilsGwt.horizontal(makeLabel(left), createDetailsButton(), makeLabel(right)); |
|
53 |
+ |
widget = UtilsGwt.horizontal( makeLabel( left ), createDetailsButton(), makeLabel( right ) ); |
59 |
54 |
|
} |
60 |
55 |
|
} |
61 |
56 |
|
} |
62 |
|
- |
addWithSpacing(panel, widget); |
|
57 |
+ |
addWithSpacing( panel, widget ); |
63 |
58 |
|
} |
64 |
59 |
|
} |
65 |
60 |
|
} |
66 |
|
- |
if (!detailsButtonAdded && !noDetails) { |
67 |
|
- |
addWithSpacing(panel, new LeftRightPanel(makeLabel(" "), createDetailsButton())); |
|
61 |
+ |
if ( !detailsButtonAdded && !noDetails ) { |
|
62 |
+ |
addWithSpacing( panel, new LeftRightPanel( makeLabel( " " ), createDetailsButton() ) ); |
68 |
63 |
|
} |
69 |
|
- |
setBody(panel, new OurPushButton("close").add(hideClickHandler)); |
|
64 |
+ |
setBody( panel, new OurPushButton( "close" ).add( hideClickHandler ) ); |
70 |
65 |
|
} |
71 |
66 |
|
|
72 |
|
- |
public ExceptionDialog(boolean noDetails, String title, String source, String context, Throwable throwable, String... bodyTextBlocksAboveControlButtons) { |
73 |
|
- |
this(noDetails, title, null, source, context, throwable, bodyTextBlocksAboveControlButtons); |
|
67 |
+ |
public ExceptionDialog( boolean noDetails, String title, String source, String context, Throwable throwable, String... bodyTextBlocksAboveControlButtons ) { |
|
68 |
+ |
this( noDetails, title, null, source, context, throwable, bodyTextBlocksAboveControlButtons ); |
74 |
69 |
|
} |
75 |
70 |
|
|
76 |
|
- |
public void add(String context, Throwable... throwables) { |
77 |
|
- |
sourceIssues.add(context, throwables); |
|
71 |
+ |
public void add( String context, Throwable... throwables ) { |
|
72 |
+ |
sourceIssues.add( context, throwables ); |
78 |
73 |
|
} |
79 |
74 |
|
|
80 |
|
- |
public void show(DialogClose closeListener) { |
81 |
|
- |
setCloseListener(closeListener); |
|
75 |
+ |
public void show( DialogClose closeListener ) { |
|
76 |
+ |
setCloseListener( closeListener ); |
82 |
77 |
|
show(); |
83 |
78 |
|
} |
84 |
79 |
|
|
85 |
80 |
|
private Widget createDetailsButton() { |
86 |
|
- |
return new OurPushButton("details", new ClickHandler() { |
|
81 |
+ |
return new OurPushButton( "details", new ClickHandler() { |
87 |
82 |
|
@Override |
88 |
|
- |
public void onClick(ClickEvent event) { |
|
83 |
+ |
public void onClick( ClickEvent event ) { |
89 |
84 |
|
ExceptionStackTracePrintStream ps = new ExceptionStackTracePrintStream(); |
90 |
|
- |
sourceIssues.dumpToAsHTML(ps, !GWT.isProdMode()); |
91 |
|
- |
UtilsGwt.windowOpenWithHtml("Exceptions", UtilsGwt.CHROMELESS_SCROLLABLE_WITH_MENUS, wrapWithHtmlStuff(ps.toString())); |
|
85 |
+ |
sourceIssues.dumpToAsHTML( ps, !GWT.isProdMode() ); |
|
86 |
+ |
UtilsGwt.windowOpenWithHtml( "Exceptions", UtilsGwt.CHROMELESS_SCROLLABLE_WITH_MENUS, wrapWithHtmlStuff( ps.toString() ) ); |
92 |
87 |
|
} |
93 |
|
- |
}); |
|
88 |
+ |
} ); |
94 |
89 |
|
} |
95 |
90 |
|
|
96 |
|
- |
protected String wrapWithHtmlStuff(String details) { |
|
91 |
+ |
protected String wrapWithHtmlStuff( String details ) { |
97 |
92 |
|
return "<!DOCTYPE html>\n" + // |
98 |
|
- |
"<html><body style='font-family:sans-serif'>" + details + "</body></html>"; |
|
93 |
+ |
"<html><body style='font-family:sans-serif'>" + details + "</body></html>"; |
99 |
94 |
|
} |
100 |
95 |
|
} |