Subversion Repository Public Repository

litesoft

Diff Revisions 531 vs 533 for /trunk/GWT_Sandbox/Upload/src/org/litesoft/sandbox/csapp/client/widgets/UploadWidget.java

Diff revisions: vs.
  @@ -9,16 +9,15 @@
9 9 {
10 10 public interface Callback
11 11 {
12 + public Image createBusyImage();
13 +
14 + public Widget createWaitingMessageWidget( Widget secondsRemaining );
15 +
12 16 public void timeout( String filename );
13 17
14 18 public void parseResponse( String fileName, String pHtmlResponse );
15 19 }
16 20
17 - private static final String BUSY_IMAGE_URL = "common/Money.gif";
18 - private static final int SECONDS_TO_WAIT = 30;
19 - private static final String[] BUSY_PRE_SECONDS_REMAINING_MESSAGE = {"Checking Certificate Validity,", "this can take a while..."};
20 - private static final String[] BUSY_POST_SECONDS_REMAINING_MESSAGE = {"seconds until timeout."};
21 -
22 21 private static int instance = 1;
23 22
24 23 private final FileUpload upload = createFileUploadWidget();
  @@ -28,14 +27,16 @@
28 27 private final Widget sizingWidget;
29 28 private boolean externallyEnabled;
30 29
30 + private final int secondsToWait;
31 31 private final Callback callback;
32 32
33 33 private String servletPath;
34 34 private Timer timer;
35 35 private boolean sized = false;
36 36
37 - public UploadWidget( ButtonBase illusionaryClickWidget, Callback callback )
37 + public UploadWidget( ButtonBase illusionaryClickWidget, int secondsToWait, Callback callback )
38 38 {
39 + this.secondsToWait = secondsToWait;
39 40 this.callback = callback;
40 41 externallyEnabled = illusionaryClickWidget.isEnabled();
41 42 sizingWidget = createConstrainer( this.illusionaryClickWidget = illusionaryClickWidget );
  @@ -285,7 +286,7 @@
285 286 {
286 287 private Widget messageWidget;
287 288 private boolean messageShowing = false;
288 - private int secondsRemaining = SECONDS_TO_WAIT;
289 + private int secondsRemaining = secondsToWait;
289 290 private Label secondsRemainingLabel = new Label( "" + secondsRemaining );
290 291 private long started = System.currentTimeMillis();
291 292 private float currentOpacity = 0;
  @@ -302,19 +303,12 @@
302 303 VerticalPanel outerpanel = new VerticalPanel();
303 304 outerpanel.setStyleName( "UploadWidgetBusyContainer" );
304 305 outerpanel.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER );
305 - outerpanel.add( new Image( BUSY_IMAGE_URL ) );
306 - VerticalPanel panel = new VerticalPanel();
307 - panel.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER );
308 - for ( String line : BUSY_PRE_SECONDS_REMAINING_MESSAGE )
309 - {
310 - panel.add( new Label( line ) );
311 - }
312 - panel.add( secondsRemainingLabel );
313 - for ( String line : BUSY_POST_SECONDS_REMAINING_MESSAGE )
306 + Image busyImage = callback.createBusyImage();
307 + if ( busyImage != null )
314 308 {
315 - panel.add( new Label( line ) );
309 + outerpanel.add( busyImage );
316 310 }
317 - outerpanel.add( createStylingDiv( "UploadWidgetBusyMessage", panel ) );
311 + outerpanel.add( createStylingDiv( "UploadWidgetBusyMessage", callback.createWaitingMessageWidget( secondsRemainingLabel ) ) );
318 312 outerpanel.getElement().getStyle().setVisibility( Style.Visibility.HIDDEN );
319 313 setWidget( messageWidget = outerpanel );
320 314 startTimer();
  @@ -354,7 +348,7 @@
354 348 messageShowing = true;
355 349 messageWidget.getElement().getStyle().setVisibility( Style.Visibility.VISIBLE );
356 350 }
357 - int calcSecondsRemaining = SECONDS_TO_WAIT - secondsPassed;
351 + int calcSecondsRemaining = secondsToWait - secondsPassed;
358 352 if ( calcSecondsRemaining < 1 )
359 353 {
360 354 stopTimer();