|
@@ -1,49 +1,30 @@ |
1 |
1 |
|
package com.temp.client.foundation.widget.upload; |
2 |
2 |
|
|
3 |
|
- |
import com.temp.shared.utils.StringUtils; |
4 |
|
- |
|
5 |
|
- |
import com.google.gwt.dom.client.Style; |
6 |
|
- |
import com.google.gwt.dom.client.Style.Cursor; |
7 |
|
- |
import com.google.gwt.dom.client.Style.Overflow; |
8 |
|
- |
import com.google.gwt.dom.client.Style.Position; |
9 |
|
- |
import com.google.gwt.dom.client.Style.Unit; |
10 |
|
- |
import com.google.gwt.dom.client.Style.Visibility; |
|
3 |
+ |
import com.google.gwt.dom.client.*; |
|
4 |
+ |
import com.google.gwt.dom.client.Style.*; |
11 |
5 |
|
import com.google.gwt.user.client.Element; |
12 |
|
- |
import com.google.gwt.user.client.Timer; |
13 |
|
- |
import com.google.gwt.user.client.Window; |
14 |
|
- |
import com.google.gwt.user.client.ui.ButtonBase; |
15 |
|
- |
import com.google.gwt.user.client.ui.Composite; |
16 |
|
- |
import com.google.gwt.user.client.ui.FileUpload; |
17 |
|
- |
import com.google.gwt.user.client.ui.FlowPanel; |
18 |
|
- |
import com.google.gwt.user.client.ui.FormPanel; |
19 |
|
- |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
20 |
|
- |
import com.google.gwt.user.client.ui.HorizontalPanel; |
21 |
|
- |
import com.google.gwt.user.client.ui.Image; |
22 |
|
- |
import com.google.gwt.user.client.ui.IsWidget; |
23 |
|
- |
import com.google.gwt.user.client.ui.Label; |
24 |
|
- |
import com.google.gwt.user.client.ui.PopupPanel; |
25 |
|
- |
import com.google.gwt.user.client.ui.SimplePanel; |
26 |
|
- |
import com.google.gwt.user.client.ui.VerticalPanel; |
27 |
|
- |
import com.google.gwt.user.client.ui.Widget; |
|
6 |
+ |
import com.google.gwt.user.client.*; |
|
7 |
+ |
import com.google.gwt.user.client.ui.*; |
|
8 |
+ |
import com.temp.shared.utils.*; |
28 |
9 |
|
|
29 |
10 |
|
public class UploadWidget extends Composite implements IsWidget { |
30 |
11 |
|
public interface Callback { |
31 |
12 |
|
public Image createBusyImage(); |
32 |
13 |
|
|
33 |
|
- |
public Widget createWaitingMessageWidget(Widget secondsRemaining); |
|
14 |
+ |
public Widget createWaitingMessageWidget( Widget secondsRemaining ); |
34 |
15 |
|
|
35 |
|
- |
public void requestingUpload(String filename); |
|
16 |
+ |
public void requestingUpload( String filename ); |
36 |
17 |
|
|
37 |
|
- |
public void timeout(String filename); |
|
18 |
+ |
public void timeout( String filename ); |
38 |
19 |
|
|
39 |
|
- |
public void parseResponse(String fileName, String pHtmlResponse); |
|
20 |
+ |
public void parseResponse( String fileName, String pHtmlResponse ); |
40 |
21 |
|
} |
41 |
22 |
|
|
42 |
23 |
|
private static int instance = 1; |
43 |
24 |
|
|
44 |
25 |
|
private final FileUpload upload = createFileUploadWidget(); |
45 |
|
- |
private final FormPanel formPanel = createFormPanel(upload); |
46 |
|
- |
private final SimplePanel viewPort = createViewPort(createFormFloater(formPanel)); |
|
26 |
+ |
private final FormPanel formPanel = createFormPanel( upload ); |
|
27 |
+ |
private final SimplePanel viewPort = createViewPort( createFormFloater( formPanel ) ); |
47 |
28 |
|
private final ButtonBase illusionaryClickWidget, removeButton; |
48 |
29 |
|
private final Widget sizingWidget; |
49 |
30 |
|
|
|
@@ -57,45 +38,45 @@ |
57 |
38 |
|
private Timer timer; |
58 |
39 |
|
private boolean sized = false; |
59 |
40 |
|
|
60 |
|
- |
public UploadWidget(ButtonBase illusionaryClickWidget, ButtonBase removeButton, int secondsToWait, Callback callback) { |
|
41 |
+ |
public UploadWidget( ButtonBase illusionaryClickWidget, ButtonBase removeButton, int secondsToWait, Callback callback ) { |
61 |
42 |
|
this.illusionaryClickWidget = illusionaryClickWidget; |
62 |
43 |
|
this.removeButton = removeButton; |
63 |
44 |
|
this.secondsToWait = secondsToWait; |
64 |
45 |
|
this.callback = callback; |
65 |
46 |
|
externallyEnabled = illusionaryClickWidget.isEnabled(); |
66 |
|
- |
sizingWidget = createConstrainer(illusionaryClickWidget); |
67 |
|
- |
initWidget(createStylingDiv("UploadWidget", createConstrainer(createFlowPanel(sizingWidget, viewPort)))); |
|
47 |
+ |
sizingWidget = createConstrainer( illusionaryClickWidget ); |
|
48 |
+ |
initWidget( createStylingDiv( "UploadWidget", createConstrainer( createFlowPanel( sizingWidget, viewPort ) ) ) ); |
68 |
49 |
|
|
69 |
|
- |
formPanel.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() { |
|
50 |
+ |
formPanel.addSubmitCompleteHandler( new FormPanel.SubmitCompleteHandler() { |
70 |
51 |
|
@Override |
71 |
|
- |
public void onSubmitComplete(FormPanel.SubmitCompleteEvent event) { |
72 |
|
- |
submitResponse(StringUtils.noEmpty(event.getResults())); |
|
52 |
+ |
public void onSubmitComplete( FormPanel.SubmitCompleteEvent event ) { |
|
53 |
+ |
submitResponse( StringUtils.noEmpty( event.getResults() ) ); |
73 |
54 |
|
} |
74 |
|
- |
}); |
|
55 |
+ |
} ); |
75 |
56 |
|
} |
76 |
57 |
|
|
77 |
|
- |
public void setServletPath(String url) { |
78 |
|
- |
servletPath = StringUtils.noEmpty(url); |
|
58 |
+ |
public void setServletPath( String url ) { |
|
59 |
+ |
servletPath = StringUtils.noEmpty( url ); |
79 |
60 |
|
} |
80 |
61 |
|
|
81 |
|
- |
public void setRemoveButtonEnabled(boolean enable) { |
82 |
|
- |
enableRemoveButton(removeButtonExternallyEnabled = enable); |
|
62 |
+ |
public void setRemoveButtonEnabled( boolean enable ) { |
|
63 |
+ |
enableRemoveButton( removeButtonExternallyEnabled = enable ); |
83 |
64 |
|
} |
84 |
65 |
|
|
85 |
|
- |
public void setEnabled(boolean enable) { |
86 |
|
- |
enableWidgets(externallyEnabled = enable); |
|
66 |
+ |
public void setEnabled( boolean enable ) { |
|
67 |
+ |
enableWidgets( externallyEnabled = enable ); |
87 |
68 |
|
} |
88 |
69 |
|
|
89 |
|
- |
private void enableWidgets(boolean enable) { |
90 |
|
- |
enableRemoveButton(enable); |
|
70 |
+ |
private void enableWidgets( boolean enable ) { |
|
71 |
+ |
enableRemoveButton( enable ); |
91 |
72 |
|
|
92 |
73 |
|
enable &= externallyEnabled; |
93 |
|
- |
illusionaryClickWidget.setEnabled(enable); |
94 |
|
- |
upload.setEnabled(enable); |
|
74 |
+ |
illusionaryClickWidget.setEnabled( enable ); |
|
75 |
+ |
upload.setEnabled( enable ); |
95 |
76 |
|
} |
96 |
77 |
|
|
97 |
|
- |
private void enableRemoveButton(boolean enable) { |
98 |
|
- |
removeButton.setEnabled(enable && externallyEnabled && removeButtonExternallyEnabled); |
|
78 |
+ |
private void enableRemoveButton( boolean enable ) { |
|
79 |
+ |
removeButton.setEnabled( enable && externallyEnabled && removeButtonExternallyEnabled ); |
99 |
80 |
|
} |
100 |
81 |
|
|
101 |
82 |
|
@Override |
|
@@ -111,7 +92,7 @@ |
111 |
92 |
|
} |
112 |
93 |
|
|
113 |
94 |
|
private void stopTimer() { |
114 |
|
- |
if (timer != null) { |
|
95 |
+ |
if ( timer != null ) { |
115 |
96 |
|
timer.cancel(); |
116 |
97 |
|
timer = null; |
117 |
98 |
|
} |
|
@@ -123,133 +104,133 @@ |
123 |
104 |
|
@Override |
124 |
105 |
|
public void run() { |
125 |
106 |
|
sized = sized || size(); |
126 |
|
- |
String filename = StringUtils.noEmpty(upload.getFilename()); |
127 |
|
- |
if (filename != null) { |
|
107 |
+ |
String filename = StringUtils.noEmpty( upload.getFilename() ); |
|
108 |
+ |
if ( filename != null ) { |
128 |
109 |
|
stopTimer(); |
129 |
|
- |
submitForm(lastSubmittedFileName = filename); |
|
110 |
+ |
submitForm( lastSubmittedFileName = filename ); |
130 |
111 |
|
formPanel.reset(); |
131 |
112 |
|
} |
132 |
113 |
|
} |
133 |
|
- |
}).scheduleRepeating(250); |
|
114 |
+ |
}).scheduleRepeating( 250 ); |
134 |
115 |
|
} |
135 |
116 |
|
|
136 |
117 |
|
private boolean size() { |
137 |
118 |
|
int width = sizingWidget.getOffsetWidth(); |
138 |
119 |
|
int height = sizingWidget.getOffsetHeight(); |
139 |
|
- |
if ((width < 16) || (height < 16)) { |
|
120 |
+ |
if ( (width < 16) || (height < 16) ) { |
140 |
121 |
|
return false; |
141 |
122 |
|
} |
142 |
|
- |
viewPort.setSize(width + "px", height + "px"); |
|
123 |
+ |
viewPort.setSize( width + "px", height + "px" ); |
143 |
124 |
|
return true; |
144 |
125 |
|
} |
145 |
126 |
|
|
146 |
127 |
|
private void resetUploadWidget() { |
147 |
|
- |
enableWidgets(true); |
|
128 |
+ |
enableWidgets( true ); |
148 |
129 |
|
startTimer(); |
149 |
130 |
|
} |
150 |
131 |
|
|
151 |
|
- |
private void submitForm(String filename) { |
152 |
|
- |
System.out.println("UploadWidget.submitForm: " + filename + " to " + servletPath); |
153 |
|
- |
if (servletPath == null) { |
154 |
|
- |
throw new IllegalStateException("No Servlet Path Set"); |
|
132 |
+ |
private void submitForm( String filename ) { |
|
133 |
+ |
System.out.println( "UploadWidget.submitForm: " + filename + " to " + servletPath ); |
|
134 |
+ |
if ( servletPath == null ) { |
|
135 |
+ |
throw new IllegalStateException( "No Servlet Path Set" ); |
155 |
136 |
|
} |
156 |
|
- |
callback.requestingUpload(filename); |
157 |
|
- |
formPanel.setAction(servletPath); |
|
137 |
+ |
callback.requestingUpload( filename ); |
|
138 |
+ |
formPanel.setAction( servletPath ); |
158 |
139 |
|
formPanel.submit(); |
159 |
|
- |
enableWidgets(false); |
|
140 |
+ |
enableWidgets( false ); |
160 |
141 |
|
showBusy(); |
161 |
142 |
|
} |
162 |
143 |
|
|
163 |
144 |
|
private void timeout() { |
164 |
145 |
|
hideBusy(); |
165 |
146 |
|
resetUploadWidget(); |
166 |
|
- |
callback.timeout(lastSubmittedFileName); |
|
147 |
+ |
callback.timeout( lastSubmittedFileName ); |
167 |
148 |
|
} |
168 |
149 |
|
|
169 |
|
- |
private void submitResponse(String htmlResponse) { |
|
150 |
+ |
private void submitResponse( String htmlResponse ) { |
170 |
151 |
|
hideBusy(); |
171 |
|
- |
if ((htmlResponse != null) || (lastSubmittedFileName != null)) { |
|
152 |
+ |
if ( (htmlResponse != null) || (lastSubmittedFileName != null) ) { |
172 |
153 |
|
resetUploadWidget(); |
173 |
154 |
|
String fileName = lastSubmittedFileName; |
174 |
155 |
|
lastSubmittedFileName = null; |
175 |
|
- |
callback.parseResponse(fileName, htmlResponse); |
|
156 |
+ |
callback.parseResponse( fileName, htmlResponse ); |
176 |
157 |
|
} |
177 |
158 |
|
} |
178 |
159 |
|
|
179 |
|
- |
private static Widget createConstrainer(Widget widget) { |
|
160 |
+ |
private static Widget createConstrainer( Widget widget ) { |
180 |
161 |
|
HorizontalPanel constrainer = new HorizontalPanel(); |
181 |
|
- |
constrainer.add(widget); |
|
162 |
+ |
constrainer.add( widget ); |
182 |
163 |
|
return constrainer; |
183 |
164 |
|
} |
184 |
165 |
|
|
185 |
|
- |
private static Widget createStylingDiv(String styleName, Widget widget) { |
|
166 |
+ |
private static Widget createStylingDiv( String styleName, Widget widget ) { |
186 |
167 |
|
SimplePanel divBasePanel = new SimplePanel(); |
187 |
|
- |
divBasePanel.addStyleName(styleName); |
188 |
|
- |
divBasePanel.setWidget(widget); |
|
168 |
+ |
divBasePanel.addStyleName( styleName ); |
|
169 |
+ |
divBasePanel.setWidget( widget ); |
189 |
170 |
|
return divBasePanel; |
190 |
171 |
|
} |
191 |
172 |
|
|
192 |
|
- |
private static Widget createFlowPanel(Widget widget1, Widget widget2) { |
|
173 |
+ |
private static Widget createFlowPanel( Widget widget1, Widget widget2 ) { |
193 |
174 |
|
FlowPanel panel = new FlowPanel(); |
194 |
|
- |
panel.getElement().getStyle().setPosition(Position.RELATIVE); |
195 |
|
- |
panel.add(widget1); |
196 |
|
- |
panel.add(widget2); |
|
175 |
+ |
panel.getElement().getStyle().setPosition( Position.RELATIVE ); |
|
176 |
+ |
panel.add( widget1 ); |
|
177 |
+ |
panel.add( widget2 ); |
197 |
178 |
|
return panel; |
198 |
179 |
|
} |
199 |
180 |
|
|
200 |
|
- |
private static SimplePanel createViewPort(Widget widget) { |
|
181 |
+ |
private static SimplePanel createViewPort( Widget widget ) { |
201 |
182 |
|
SimplePanel viewPort = new SimplePanel(); |
202 |
183 |
|
Element element = viewPort.getElement(); |
203 |
184 |
|
Style style = element.getStyle(); |
204 |
|
- |
style.setPosition(Position.ABSOLUTE); |
205 |
|
- |
style.setLeft(0, Unit.PX); |
206 |
|
- |
style.setTop(0, Unit.PX); |
207 |
|
- |
style.setOverflow(Overflow.HIDDEN); |
208 |
|
- |
viewPort.setWidget(widget); |
209 |
|
- |
viewPort.setSize("1px", "1px"); |
|
185 |
+ |
style.setPosition( Position.ABSOLUTE ); |
|
186 |
+ |
style.setLeft( 0, Unit.PX ); |
|
187 |
+ |
style.setTop( 0, Unit.PX ); |
|
188 |
+ |
style.setOverflow( Overflow.HIDDEN ); |
|
189 |
+ |
viewPort.setWidget( widget ); |
|
190 |
+ |
viewPort.setSize( "1px", "1px" ); |
210 |
191 |
|
return viewPort; |
211 |
192 |
|
} |
212 |
193 |
|
|
213 |
|
- |
private static SimplePanel createFormFloater(Widget widget) { |
|
194 |
+ |
private static SimplePanel createFormFloater( Widget widget ) { |
214 |
195 |
|
SimplePanel panel = new SimplePanel(); |
215 |
|
- |
panel.setSize("1000px", "400px"); |
|
196 |
+ |
panel.setSize( "1000px", "400px" ); |
216 |
197 |
|
Style style = panel.getElement().getStyle(); |
217 |
|
- |
style.setPosition(Position.RELATIVE); |
218 |
|
- |
style.setLeft(-600, Unit.PX); |
219 |
|
- |
style.setTop(-5, Unit.PX); |
220 |
|
- |
panel.setWidget(createConstrainer(widget)); |
|
198 |
+ |
style.setPosition( Position.RELATIVE ); |
|
199 |
+ |
style.setLeft( -600, Unit.PX ); |
|
200 |
+ |
style.setTop( -5, Unit.PX ); |
|
201 |
+ |
panel.setWidget( createConstrainer( widget ) ); |
221 |
202 |
|
return panel; |
222 |
203 |
|
} |
223 |
204 |
|
|
224 |
|
- |
private static FormPanel createFormPanel(FileUpload upload) { |
|
205 |
+ |
private static FormPanel createFormPanel( FileUpload upload ) { |
225 |
206 |
|
FormPanel form = new FormPanel(); |
226 |
|
- |
form.add(upload); |
|
207 |
+ |
form.add( upload ); |
227 |
208 |
|
Style style = form.getElement().getStyle(); |
228 |
|
- |
style.setMargin(0, Unit.PX); |
229 |
|
- |
style.setPadding(0, Unit.PX); |
|
209 |
+ |
style.setMargin( 0, Unit.PX ); |
|
210 |
+ |
style.setPadding( 0, Unit.PX ); |
230 |
211 |
|
// Because we're going to add a FileUpload widget, we'll need to set the |
231 |
212 |
|
// form to use the POST method, and multipart MIME encoding. |
232 |
|
- |
form.setEncoding(FormPanel.ENCODING_MULTIPART); |
233 |
|
- |
form.setMethod(FormPanel.METHOD_POST); |
|
213 |
+ |
form.setEncoding( FormPanel.ENCODING_MULTIPART ); |
|
214 |
+ |
form.setMethod( FormPanel.METHOD_POST ); |
234 |
215 |
|
return form; |
235 |
216 |
|
} |
236 |
217 |
|
|
237 |
218 |
|
private static FileUpload createFileUploadWidget() { |
238 |
219 |
|
FileUpload upload = new FileUpload(); |
239 |
|
- |
upload.setName("UploadWidget" + instance++); |
240 |
|
- |
upload.getElement().setAttribute("size", "1"); |
241 |
|
- |
upload.setSize("1000px", "400px"); |
|
220 |
+ |
upload.setName( "UploadWidget" + instance++ ); |
|
221 |
+ |
upload.getElement().setAttribute( "size", "1" ); |
|
222 |
+ |
upload.setSize( "1000px", "400px" ); |
242 |
223 |
|
Style style = upload.getElement().getStyle(); |
243 |
|
- |
style.setMargin(0, Unit.PX); |
244 |
|
- |
style.setPadding(0, Unit.PX); |
245 |
|
- |
style.setBorderWidth(0, Unit.PX); |
246 |
|
- |
style.setFontSize(200, Unit.PX); |
247 |
|
- |
style.setOpacity(0); // Tested w/ FireFox & IE8! |
|
224 |
+ |
style.setMargin( 0, Unit.PX ); |
|
225 |
+ |
style.setPadding( 0, Unit.PX ); |
|
226 |
+ |
style.setBorderWidth( 0, Unit.PX ); |
|
227 |
+ |
style.setFontSize( 200, Unit.PX ); |
|
228 |
+ |
style.setOpacity( 0 ); // Tested w/ FireFox & IE8! |
248 |
229 |
|
return upload; |
249 |
230 |
|
} |
250 |
231 |
|
|
251 |
232 |
|
protected void hideBusy() { |
252 |
|
- |
if (busyPopup != null) { |
|
233 |
+ |
if ( busyPopup != null ) { |
253 |
234 |
|
busyPopup.hide(); |
254 |
235 |
|
busyPopup = null; |
255 |
236 |
|
} |
|
@@ -257,14 +238,14 @@ |
257 |
238 |
|
|
258 |
239 |
|
protected void showBusy() { |
259 |
240 |
|
hideBusy(); |
260 |
|
- |
(busyPopup = new OurBusyPopup()).setPopupPositionAndShow(new PopupPanel.PositionCallback() { |
|
241 |
+ |
(busyPopup = new OurBusyPopup()).setPopupPositionAndShow( new PopupPanel.PositionCallback() { |
261 |
242 |
|
@Override |
262 |
|
- |
public void setPosition(int offsetWidth, int offsetHeight) { |
|
243 |
+ |
public void setPosition( int offsetWidth, int offsetHeight ) { |
263 |
244 |
|
int left = (Window.getClientWidth() - offsetWidth) / 2; |
264 |
245 |
|
int top = (Window.getClientHeight() - offsetHeight) / 2; |
265 |
|
- |
busyPopup.setPopupPosition(left, top); |
|
246 |
+ |
busyPopup.setPopupPosition( left, top ); |
266 |
247 |
|
} |
267 |
|
- |
}); |
|
248 |
+ |
} ); |
268 |
249 |
|
} |
269 |
250 |
|
|
270 |
251 |
|
private OurBusyPopup busyPopup; |
|
@@ -273,28 +254,28 @@ |
273 |
254 |
|
private Widget messageWidget; |
274 |
255 |
|
private boolean messageShowing = false; |
275 |
256 |
|
private int secondsRemaining = secondsToWait; |
276 |
|
- |
private Label secondsRemainingLabel = new Label("" + secondsRemaining); |
|
257 |
+ |
private Label secondsRemainingLabel = new Label( "" + secondsRemaining ); |
277 |
258 |
|
private long started = System.currentTimeMillis(); |
278 |
259 |
|
private float currentOpacity = 0; |
279 |
260 |
|
private Timer timer; |
280 |
261 |
|
|
281 |
262 |
|
private OurBusyPopup() { |
282 |
|
- |
setModal(true); |
283 |
|
- |
setGlassEnabled(true); |
284 |
|
- |
getGlassElement().getStyle().setBackgroundColor("#fff"); |
285 |
|
- |
getGlassElement().getStyle().setCursor(Cursor.WAIT); |
286 |
|
- |
getGlassElement().getStyle().setOpacity(currentOpacity); |
|
263 |
+ |
setModal( true ); |
|
264 |
+ |
setGlassEnabled( true ); |
|
265 |
+ |
getGlassElement().getStyle().setBackgroundColor( "#fff" ); |
|
266 |
+ |
getGlassElement().getStyle().setCursor( Cursor.WAIT ); |
|
267 |
+ |
getGlassElement().getStyle().setOpacity( currentOpacity ); |
287 |
268 |
|
|
288 |
269 |
|
VerticalPanel outerpanel = new VerticalPanel(); |
289 |
|
- |
outerpanel.setStyleName("UploadWidgetBusyContainer"); |
290 |
|
- |
outerpanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); |
|
270 |
+ |
outerpanel.setStyleName( "UploadWidgetBusyContainer" ); |
|
271 |
+ |
outerpanel.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER ); |
291 |
272 |
|
Image busyImage = callback.createBusyImage(); |
292 |
|
- |
if (busyImage != null) { |
293 |
|
- |
outerpanel.add(busyImage); |
|
273 |
+ |
if ( busyImage != null ) { |
|
274 |
+ |
outerpanel.add( busyImage ); |
294 |
275 |
|
} |
295 |
|
- |
outerpanel.add(createStylingDiv("UploadWidgetBusyMessage", callback.createWaitingMessageWidget(secondsRemainingLabel))); |
296 |
|
- |
outerpanel.getElement().getStyle().setVisibility(Visibility.HIDDEN); |
297 |
|
- |
setWidget(messageWidget = outerpanel); |
|
276 |
+ |
outerpanel.add( createStylingDiv( "UploadWidgetBusyMessage", callback.createWaitingMessageWidget( secondsRemainingLabel ) ) ); |
|
277 |
+ |
outerpanel.getElement().getStyle().setVisibility( Visibility.HIDDEN ); |
|
278 |
+ |
setWidget( messageWidget = outerpanel ); |
298 |
279 |
|
startTimer(); |
299 |
280 |
|
} |
300 |
281 |
|
|
|
@@ -305,7 +286,7 @@ |
305 |
286 |
|
} |
306 |
287 |
|
|
307 |
288 |
|
private void stopTimer() { |
308 |
|
- |
if (timer != null) { |
|
289 |
+ |
if ( timer != null ) { |
309 |
290 |
|
timer.cancel(); |
310 |
291 |
|
timer = null; |
311 |
292 |
|
} |
|
@@ -316,26 +297,26 @@ |
316 |
297 |
|
(timer = new Timer() { |
317 |
298 |
|
@Override |
318 |
299 |
|
public void run() { |
319 |
|
- |
if (currentOpacity < 0.75) { |
320 |
|
- |
getGlassElement().getStyle().setOpacity(currentOpacity += 0.025); |
|
300 |
+ |
if ( currentOpacity < 0.75 ) { |
|
301 |
+ |
getGlassElement().getStyle().setOpacity( currentOpacity += 0.025 ); |
321 |
302 |
|
} |
322 |
303 |
|
int secondsPassed = (int) ((System.currentTimeMillis() - started) / 1000); |
323 |
|
- |
if ((secondsPassed > 1) && !messageShowing) { |
|
304 |
+ |
if ( (secondsPassed > 1) && !messageShowing ) { |
324 |
305 |
|
messageShowing = true; |
325 |
|
- |
messageWidget.getElement().getStyle().setVisibility(Visibility.VISIBLE); |
|
306 |
+ |
messageWidget.getElement().getStyle().setVisibility( Visibility.VISIBLE ); |
326 |
307 |
|
} |
327 |
308 |
|
int calcSecondsRemaining = secondsToWait - secondsPassed; |
328 |
|
- |
if (calcSecondsRemaining < 1) { |
|
309 |
+ |
if ( calcSecondsRemaining < 1 ) { |
329 |
310 |
|
stopTimer(); |
330 |
311 |
|
timeout(); |
331 |
312 |
|
return; |
332 |
313 |
|
} |
333 |
|
- |
if (calcSecondsRemaining != secondsRemaining) { |
|
314 |
+ |
if ( calcSecondsRemaining != secondsRemaining ) { |
334 |
315 |
|
secondsRemaining = calcSecondsRemaining; |
335 |
|
- |
secondsRemainingLabel.setText(Integer.toString(secondsRemaining)); |
|
316 |
+ |
secondsRemainingLabel.setText( Integer.toString( secondsRemaining ) ); |
336 |
317 |
|
} |
337 |
318 |
|
} |
338 |
|
- |
}).scheduleRepeating(100); |
|
319 |
+ |
}).scheduleRepeating( 100 ); |
339 |
320 |
|
} |
340 |
321 |
|
} |
341 |
322 |
|
} |