@@ -48,10 +48,6 @@ public class ErrorWindow extends Dialog {
4848
4949 private static final Logger logger = LoggerFactory .getLogger (ErrorWindow .class );
5050
51- private static final String DEFAULT_CAPTION = "<h3 style='margin-top:0px;text-align:center'>An error has occurred</h3>" ;
52-
53- private static final String DEFAULT_ERROR_LABEL_MESSAGE = "Please contact the system administrator for more information." ;
54-
5551 private VerticalLayout exceptionTraceLayout ;
5652
5753 private final Throwable cause ;
@@ -62,32 +58,50 @@ public class ErrorWindow extends Dialog {
6258
6359 private boolean productionMode ;
6460
61+ private ErrorWindowI18n i18n ;
62+
6563 public ErrorWindow (final Throwable cause ) {
66- this (cause , null , isProductionMode ());
64+ this (cause , null , isProductionMode (), ErrorWindowI18n .createDefault ());
65+ }
66+
67+ public ErrorWindow (final Throwable cause , final ErrorWindowI18n i18n ) {
68+ this (cause , null , isProductionMode (), i18n );
6769 }
6870
6971 public ErrorWindow (final Throwable cause , final String errorMessage ) {
70- this (cause , errorMessage , isProductionMode ());
72+ this (cause , errorMessage , isProductionMode (), ErrorWindowI18n .createDefault ());
73+ }
74+
75+ public ErrorWindow (final Throwable cause , final String errorMessage , final ErrorWindowI18n i18n ) {
76+ this (cause , errorMessage , isProductionMode (), i18n );
7177 }
7278
7379 public ErrorWindow (final Throwable cause , final String errorMessage , boolean productionMode ) {
80+ this (cause , errorMessage , productionMode , ErrorWindowI18n .createDefault ());
81+ }
82+ public ErrorWindow (final Throwable cause , final String errorMessage , boolean productionMode , final ErrorWindowI18n i18n ) {
7483 super ();
7584
7685 uuid = UUID .randomUUID ().toString ();
7786 this .cause = cause ;
7887 this .errorMessage = errorMessage ;
7988 this .productionMode = productionMode ;
89+ this .i18n = i18n ;
8090 initWindow ();
8191 }
8292
8393 public ErrorWindow (ErrorDetails errorDetails ) {
84- this (errorDetails . getThrowable (), errorDetails . getCause ());
94+ this (errorDetails , ErrorWindowI18n . createDefault ());
8595 }
8696
8797 public ErrorWindow (ErrorDetails errorDetails , boolean productionMode ) {
8898 this (errorDetails .getThrowable (), errorDetails .getCause (), productionMode );
8999 }
90100
101+ public ErrorWindow (ErrorDetails errorDetails , final ErrorWindowI18n i18n ) {
102+ this (errorDetails .getThrowable (), errorDetails .getCause (), i18n );
103+ }
104+
91105 private static boolean isProductionMode () {
92106 return ErrorManager .getErrorWindowFactory ().isProductionMode ();
93107 }
@@ -110,7 +124,7 @@ private VerticalLayout createMainLayout() {
110124 mainLayout .setPadding (false );
111125 mainLayout .setMargin (false );
112126
113- final Html title = new Html (DEFAULT_CAPTION );
127+ final Html title = new Html (String . format ( "<h3 style='margin-top:0px;text-align:center'>%s</h3>" , i18n . getCaption ()) );
114128 title .getElement ().getStyle ().set ("width" , "100%" );
115129 mainLayout .add (title );
116130
@@ -129,7 +143,7 @@ private VerticalLayout createMainLayout() {
129143 mainLayout .add (createExceptionTraceLayout ());
130144 }
131145
132- final Button closeButton = new Button ("Close" , event -> close ());
146+ final Button closeButton = new Button (i18n . getClose () , event -> close ());
133147 buttonsLayout .add (closeButton );
134148 mainLayout .add (buttonsLayout );
135149 mainLayout .setHorizontalComponentAlignment (Alignment .END , buttonsLayout );
@@ -138,7 +152,7 @@ private VerticalLayout createMainLayout() {
138152 }
139153
140154 private Button createDetailsButtonLayout () {
141- final Button errorDetailsButton = new Button ("Show error detail" , event -> {
155+ final Button errorDetailsButton = new Button (i18n . getDetails () , event -> {
142156 boolean visible = !exceptionTraceLayout .isVisible ();
143157 exceptionTraceLayout .setVisible (visible );
144158 if (visible ) {
@@ -175,9 +189,9 @@ protected TextArea createStackTraceArea() {
175189 }
176190
177191 protected Html createErrorLabel () {
178- String label = errorMessage == null ? DEFAULT_ERROR_LABEL_MESSAGE : errorMessage ;
192+ String label = errorMessage == null ? i18n . getDefaultErrorMessage () : errorMessage ;
179193 if (productionMode ) {
180- label = label .concat (String .format ("<br />Please report the following code to system administrator: <h4><p><center>%s<center/></p></h4>" , uuid ));
194+ label = label .concat (String .format ("<br />%s <h4><p><center>%s<center/></p></h4>" , i18n . getInstructions () , uuid ));
181195 }
182196 final Html errorLabel = new Html ("<span>" + label + "</span>" );
183197 errorLabel .getElement ().getStyle ().set ("width" , "100%" );
0 commit comments