Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/Java/GWT/Client/src/org/litesoft/GWT/client/UtilsGwt.java

Diff revisions: vs.
  @@ -1,359 +1,359 @@
1 - // This Source Code is in the Public Domain per: http://unlicense.org
2 - package org.litesoft.GWT.client;
3 -
4 - import org.litesoft.GWT.client.widgets.nonpublic.*;
5 - import org.litesoft.commonfoundation.typeutils.*;
6 - import org.litesoft.core.*;
7 -
8 - import com.google.gwt.event.shared.*;
9 - import com.google.gwt.user.client.*;
10 - import com.google.gwt.user.client.ui.*;
11 -
12 - import java.util.*;
13 -
14 - /**
15 - * @noinspection NonJREEmulationClassesInClientCode
16 - */
17 - public class UtilsGwt {
18 - public static native String getURL()/*-{
19 - return $wnd.location.href;
20 - }-*/;
21 -
22 - // redirect the browser to the given url
23 - public static native void redirect( String url )/*-{
24 - $wnd.location.href = url;
25 - }-*/;
26 -
27 - public static native void windowResizeTo( int pWidth, int pHeight ) /*-{
28 - $wnd.resizeTo( pWidth, pHeight );
29 - }-*/;
30 -
31 - /**
32 - * Native method to get a cell's element.
33 - *
34 - * @param pTable the table element
35 - * @param pRow the row of the cell
36 - * @param pCol the column of the cell
37 - *
38 - * @return the TD element
39 - */
40 - public static native Element getTableTD( Element pTable, int pRow, int pCol ) /*-{
41 - return pTable.rows[pRow].cells[pCol];
42 - }-*/;
43 -
44 - public static native Element getElementById( String pID ) /*-{
45 - return $wnd.document.getElementById( pID );
46 - }-*/;
47 -
48 - /**
49 - * Programmatically simulate a User Click Event on an Element located by ID (pID).
50 - *
51 - * @param pID ID of the element to "click".
52 - *
53 - * @return Error text - null/empty means no error.
54 - */
55 - public static native String clickElementByID( String pID ) /*-{
56 - var zDoc = $wnd.document;
57 - var zTarget = zDoc.getElementById( pID );
58 - if ( zTarget )
59 - {
60 - var zStep = 1;
61 - try
62 - {
63 - if ( zDoc.dispatchEvent ) // W3C
64 - {
65 - zStep = 2;
66 - var zEvent = document.createEvent( "MouseEvents" );
67 - zStep = 3;
68 - zEvent.initMouseEvent( "click", true, true, window, 1, 1, 1, 1, 1, false, false, false, false, 0, zTarget );
69 - zStep = 4;
70 - zTarget.dispatchEvent( zEvent );
71 - return null;
72 - }
73 - zStep = 5;
74 - if ( document.fireEvent ) // IE
75 - {
76 - zStep = 6;
77 - zTarget.fireEvent( "onclick" );
78 - return null;
79 - }
80 - return "Un-recognized/supported Browser";
81 - }
82 - catch ( e )
83 - {
84 - return "Exception at " + zStep + " in clickElementByID:\n\n" + e;
85 - }
86 - }
87 - return "No Element found w/ ID: " + pID;
88 - }-*/;
89 -
90 - public static native boolean windowExists( String name ) /*-{
91 - var winHandle = $wnd.open( "", name, "" );
92 - return winHandle ? true : false;
93 - }-*/;
94 -
95 - public static native void ourWindowToFront() /*-{
96 - $wnd.focus();
97 - }-*/;
98 -
99 - public static native void windowToFront( String name ) /*-{
100 - var winHandle = $wnd.open( "", name, "" );
101 - winHandle.focus();
102 - }-*/;
103 -
104 - public static native void closeWindow() /*-{
105 - $wnd.close();
106 - }-*/;
107 -
108 - public static native void closeWindow( String name ) /*-{
109 - var winHandle = $wnd.open( "", name, "" );
110 - if ( winHandle.DisableCloseConfirmFlag != true )
111 - winHandle.DisableCloseConfirmFlag = true;
112 - winHandle.close();
113 - }-*/;
114 -
115 - public static native boolean isDisableCloseConfirm() /*-{
116 - return !($wnd.DisableCloseConfirmFlag != true);
117 - }-*/;
118 -
119 - public static native void setDisableCloseConfirm( boolean pDisableConfirm ) /*-{
120 - $wnd.DisableCloseConfirmFlag = pDisableConfirm;
121 - }-*/;
122 -
123 - public static native boolean trywindowOpenWithHtml( String pName, String pFeatures, String pHTML ) /*-{
124 - var winHandle = $wnd.open( "", pName, pFeatures );
125 - if ( !winHandle )
126 - {
127 - return false;
128 - }
129 - winHandle.document.write( pHTML );
130 - winHandle.document.close();
131 - return true;
132 - }-*/;
133 -
134 - public static native boolean tryWindowOpen( String pURL, String pName, String pFeatures ) /*-{
135 - var winHandle = $wnd.open( pURL, pName, pFeatures );
136 - return winHandle ? true : false;
137 - }-*/;
138 -
139 - public static boolean windowOpen( String pURL, String pName, String pFeatures ) {
140 - if ( tryWindowOpen( pURL, pName, pFeatures ) ) {
141 - return true;
142 - }
143 - popupsBlocked();
144 - return false;
145 - }
146 -
147 - private static final String CHROMELESS = "directories=0,location=0,menubar=0,status=1,toolbar=0,resizable=1";
148 -
149 - public static final String CHROMELESS_SCROLLED = CHROMELESS + ",scrollbars=1";
150 -
151 - public static final String CHROMELESS_OVERFLOW = CHROMELESS + ",scrollbars=0";
152 -
153 - public static boolean tryWindowOpenChromeless( String pURL, String pName ) {
154 - return tryWindowOpen( pURL, pName, CHROMELESS_OVERFLOW );
155 - }
156 -
157 - public static boolean windowOpenChromeless( String pURL, String pName ) {
158 - return windowOpen( pURL, pName, CHROMELESS_OVERFLOW );
159 - }
160 -
161 - public static void windowOpenWithHtml( String pName, String pFeatures, String pHTML ) {
162 - if ( !trywindowOpenWithHtml( pName, pFeatures, pHTML ) ) {
163 - popupsBlocked();
164 - }
165 - }
166 -
167 - public static void windowOpenWithHtml( String pName, String pHTML ) {
168 - windowOpenWithHtml( pName, "", pHTML );
169 - }
170 -
171 - public static void setWindowTitle( String pTitle ) {
172 - if ( sWindowNameInWindowTitle ) {
173 - pTitle += " - '" + WindowName.get() + "'";
174 - }
175 - Window.setTitle( pTitle );
176 - }
177 -
178 - private static boolean sWindowNameInWindowTitle = false;
179 -
180 - public static void addWindowNameToWindowTitle() {
181 - sWindowNameInWindowTitle = true;
182 - setWindowTitle( Window.getTitle() );
183 - }
184 -
185 - private static void popupsBlocked() {
186 - AlertManager.alert( "NewClient", "Browser Configuration Error",
187 - "This application requires pop-up windows to run properly.\n\nPlease change your browser options to unblock pop-ups." );
188 - }
189 -
190 - public static void eventPreventDefaultAndCancelBubble( Event pEvent ) {
191 - pEvent.preventDefault();
192 - pEvent.stopPropagation();
193 - }
194 -
195 - public static boolean wasAltKeyDownOnCurrentEvent() {
196 - return DOM.eventGetAltKey( DOM.eventGetCurrentEvent() );
197 - }
198 -
199 - public static boolean wasCtrlKeyDownOnCurrentEvent() {
200 - // Use Command key for Macs. Ctrl key usually always triggers contextual menu on Macs.
201 - if ( UserAgent.getInstance().getPlatform() == Platform.Mac ) {
202 - return DOM.eventGetCurrentEvent().getMetaKey();
203 - } else {
204 - return DOM.eventGetCurrentEvent().getCtrlKey();
205 - }
206 - }
207 -
208 - public static String shortClassname( String pClassName ) {
209 - String name = "." + ClassNameFromGoogleClassToStringMethod( pClassName ) + "$";
210 - name = name.substring( 0, name.indexOf( '$' ) );
211 - return name.substring( name.lastIndexOf( '.' ) + 1 );
212 - }
213 -
214 - public static String ClassNameFromGoogleClassToStringMethod( String pClassName ) {
215 - pClassName = Strings.deNull( pClassName ).trim();
216 - int index = pClassName.indexOf( ' ' ) + 1;
217 - return index > 0 ? pClassName.substring( index ) : pClassName;
218 - }
219 -
220 - public static boolean equalGwtClassStrings( String pClassName1, String pClassName2 ) {
221 - return ClassNameFromGoogleClassToStringMethod( pClassName1 ).equals( ClassNameFromGoogleClassToStringMethod( pClassName2 ) );
222 - }
223 -
224 - public static void closeWindowNoConfirm( int pMilliSecDelay ) {
225 - setDisableCloseConfirm( true );
226 - new com.google.gwt.user.client.Timer() // Fully qualified as there are Multiple Versions
227 - {
228 - @Override
229 - public void run() {
230 - closeWindow();
231 - }
232 - }.schedule( (pMilliSecDelay < 1) ? 1 : pMilliSecDelay );
233 - }
234 -
235 - public static void closeWindowNoConfirm( String pAlertMessage ) {
236 - closeWindowNoConfirm( pAlertMessage, null );
237 - }
238 -
239 - public static void closeWindowNoConfirm( String pAlertMessage, Exception pRootProblem ) {
240 - AlertManager.alert( "WinClose", null, pAlertMessage, pRootProblem, new DialogCloseCallBack() {
241 - @Override
242 - public void dialogClosed() {
243 - setDisableCloseConfirm( true );
244 - closeWindow();
245 - }
246 - } );
247 - }
248 -
249 - private static Set<WindowClosingConfirmMessageProvider> sListeners = new HashSet<WindowClosingConfirmMessageProvider>();
250 -
251 - public static void addListener( WindowClosingConfirmMessageProvider pListener ) {
252 - if ( pListener != null ) {
253 - if ( sListeners.add( pListener ) ) {
254 - manageWindowCloseHandler();
255 - }
256 - }
257 - }
258 -
259 - public static boolean removeListener( WindowClosingConfirmMessageProvider pListener ) {
260 - if ( pListener != null ) {
261 - if ( sListeners.remove( pListener ) ) {
262 - manageWindowCloseHandler();
263 - return true;
264 - }
265 - }
266 - return false;
267 - }
268 -
269 - private static void manageWindowCloseHandler() {
270 - if ( sListeners.isEmpty() ) {
271 - if ( sCloseHandlerRegistration != null ) {
272 - sCloseHandlerRegistration.removeHandler();
273 - sCloseHandlerRegistration = null;
274 - }
275 - } else if ( sCloseHandlerRegistration == null ) {
276 - sCloseHandlerRegistration = Window.addWindowClosingHandler( sCloseHandler );
277 - }
278 - }
279 -
280 - private static HandlerRegistration sCloseHandlerRegistration = null;
281 - private static Window.ClosingHandler sCloseHandler = new Window.ClosingHandler() {
282 - @Override
283 - public void onWindowClosing( Window.ClosingEvent pEvent ) {
284 - if ( !isDisableCloseConfirm() && !sListeners.isEmpty() ) {
285 - StringBuilder sb = new StringBuilder();
286 - for ( WindowClosingConfirmMessageProvider zProvider : sListeners ) {
287 - String msg = zProvider.getOnWindowClosingConfirmMessage();
288 - if ( msg != null ) {
289 - if ( sb.length() != 0 ) {
290 - sb.append( '\n' );
291 - }
292 - sb.append( msg );
293 - }
294 - }
295 - if ( sb.length() != 0 ) {
296 - pEvent.setMessage( sb.toString() );
297 - }
298 - }
299 - }
300 - };
301 -
302 - public static void busyCursor() {
303 - RootPanel.get().getElement().getStyle().setProperty( "cursor", "wait" );
304 - }
305 -
306 - public static void regularCursor() {
307 - RootPanel.get().getElement().getStyle().setProperty( "cursor", "auto" );
308 - }
309 -
310 - public static void hide( Widget pWidget ) {
311 - setHidden( pWidget, true );
312 - }
313 -
314 - public static void unhide( Widget pWidget ) {
315 - setHidden( pWidget, false );
316 - }
317 -
318 - public static void setHidden( Widget pWidget, boolean pHide ) {
319 - CommonElementHelper.setHidden( pWidget.getElement(), pHide );
320 - }
321 -
322 - public static boolean isHidden( Widget pWidget ) {
323 - return CommonElementHelper.isHidden( pWidget.getElement() );
324 - }
325 -
326 - public static boolean isVisible( Widget pWidget ) {
327 - return CommonElementHelper.isVisible( pWidget.getElement() );
328 - }
329 -
330 - public static void style( Widget pWidget, String pStyleName, boolean pAdd ) {
331 - if ( pAdd ) {
332 - pWidget.addStyleName( pStyleName );
333 - } else {
334 - pWidget.removeStyleName( pStyleName );
335 - }
336 - }
337 -
338 - public static boolean isRecursiveVisible( Widget pWidget ) {
339 - if ( pWidget != null && pWidget.isAttached() ) {
340 - while ( !isHidden( pWidget ) && isVisible( pWidget ) ) {
341 - if ( null == (pWidget = pWidget.getParent()) ) {
342 - return true;
343 - }
344 - }
345 - }
346 - return false;
347 - }
348 -
349 - public static String getExpando( Element pElement, String pName ) {
350 - return pElement.getPropertyString( pName );
351 - }
352 -
353 - /**
354 - * Set a non-standard attribute.
355 - */
356 - public static void setExpando( Element pElement, String pName, String pValue ) {
357 - pElement.setPropertyString( pName, pValue );
358 - }
359 - }
1 + // This Source Code is in the Public Domain per: http://unlicense.org
2 + package org.litesoft.GWT.client;
3 +
4 + import org.litesoft.GWT.client.widgets.nonpublic.*;
5 + import org.litesoft.commonfoundation.base.*;
6 + import org.litesoft.core.*;
7 +
8 + import com.google.gwt.event.shared.*;
9 + import com.google.gwt.user.client.*;
10 + import com.google.gwt.user.client.ui.*;
11 +
12 + import java.util.*;
13 +
14 + /**
15 + * @noinspection NonJREEmulationClassesInClientCode
16 + */
17 + public class UtilsGwt {
18 + public static native String getURL()/*-{
19 + return $wnd.location.href;
20 + }-*/;
21 +
22 + // redirect the browser to the given url
23 + public static native void redirect( String url )/*-{
24 + $wnd.location.href = url;
25 + }-*/;
26 +
27 + public static native void windowResizeTo( int pWidth, int pHeight ) /*-{
28 + $wnd.resizeTo( pWidth, pHeight );
29 + }-*/;
30 +
31 + /**
32 + * Native method to get a cell's element.
33 + *
34 + * @param pTable the table element
35 + * @param pRow the row of the cell
36 + * @param pCol the column of the cell
37 + *
38 + * @return the TD element
39 + */
40 + public static native Element getTableTD( Element pTable, int pRow, int pCol ) /*-{
41 + return pTable.rows[pRow].cells[pCol];
42 + }-*/;
43 +
44 + public static native Element getElementById( String pID ) /*-{
45 + return $wnd.document.getElementById( pID );
46 + }-*/;
47 +
48 + /**
49 + * Programmatically simulate a User Click Event on an Element located by ID (pID).
50 + *
51 + * @param pID ID of the element to "click".
52 + *
53 + * @return Error text - null/empty means no error.
54 + */
55 + public static native String clickElementByID( String pID ) /*-{
56 + var zDoc = $wnd.document;
57 + var zTarget = zDoc.getElementById( pID );
58 + if ( zTarget )
59 + {
60 + var zStep = 1;
61 + try
62 + {
63 + if ( zDoc.dispatchEvent ) // W3C
64 + {
65 + zStep = 2;
66 + var zEvent = document.createEvent( "MouseEvents" );
67 + zStep = 3;
68 + zEvent.initMouseEvent( "click", true, true, window, 1, 1, 1, 1, 1, false, false, false, false, 0, zTarget );
69 + zStep = 4;
70 + zTarget.dispatchEvent( zEvent );
71 + return null;
72 + }
73 + zStep = 5;
74 + if ( document.fireEvent ) // IE
75 + {
76 + zStep = 6;
77 + zTarget.fireEvent( "onclick" );
78 + return null;
79 + }
80 + return "Un-recognized/supported Browser";
81 + }
82 + catch ( e )
83 + {
84 + return "Exception at " + zStep + " in clickElementByID:\n\n" + e;
85 + }
86 + }
87 + return "No Element found w/ ID: " + pID;
88 + }-*/;
89 +
90 + public static native boolean windowExists( String name ) /*-{
91 + var winHandle = $wnd.open( "", name, "" );
92 + return winHandle ? true : false;
93 + }-*/;
94 +
95 + public static native void ourWindowToFront() /*-{
96 + $wnd.focus();
97 + }-*/;
98 +
99 + public static native void windowToFront( String name ) /*-{
100 + var winHandle = $wnd.open( "", name, "" );
101 + winHandle.focus();
102 + }-*/;
103 +
104 + public static native void closeWindow() /*-{
105 + $wnd.close();
106 + }-*/;
107 +
108 + public static native void closeWindow( String name ) /*-{
109 + var winHandle = $wnd.open( "", name, "" );
110 + if ( winHandle.DisableCloseConfirmFlag != true )
111 + winHandle.DisableCloseConfirmFlag = true;
112 + winHandle.close();
113 + }-*/;
114 +
115 + public static native boolean isDisableCloseConfirm() /*-{
116 + return !($wnd.DisableCloseConfirmFlag != true);
117 + }-*/;
118 +
119 + public static native void setDisableCloseConfirm( boolean pDisableConfirm ) /*-{
120 + $wnd.DisableCloseConfirmFlag = pDisableConfirm;
121 + }-*/;
122 +
123 + public static native boolean trywindowOpenWithHtml( String pName, String pFeatures, String pHTML ) /*-{
124 + var winHandle = $wnd.open( "", pName, pFeatures );
125 + if ( !winHandle )
126 + {
127 + return false;
128 + }
129 + winHandle.document.write( pHTML );
130 + winHandle.document.close();
131 + return true;
132 + }-*/;
133 +
134 + public static native boolean tryWindowOpen( String pURL, String pName, String pFeatures ) /*-{
135 + var winHandle = $wnd.open( pURL, pName, pFeatures );
136 + return winHandle ? true : false;
137 + }-*/;
138 +
139 + public static boolean windowOpen( String pURL, String pName, String pFeatures ) {
140 + if ( tryWindowOpen( pURL, pName, pFeatures ) ) {
141 + return true;
142 + }
143 + popupsBlocked();
144 + return false;
145 + }
146 +
147 + private static final String CHROMELESS = "directories=0,location=0,menubar=0,status=1,toolbar=0,resizable=1";
148 +
149 + public static final String CHROMELESS_SCROLLED = CHROMELESS + ",scrollbars=1";
150 +
151 + public static final String CHROMELESS_OVERFLOW = CHROMELESS + ",scrollbars=0";
152 +
153 + public static boolean tryWindowOpenChromeless( String pURL, String pName ) {
154 + return tryWindowOpen( pURL, pName, CHROMELESS_OVERFLOW );
155 + }
156 +
157 + public static boolean windowOpenChromeless( String pURL, String pName ) {
158 + return windowOpen( pURL, pName, CHROMELESS_OVERFLOW );
159 + }
160 +
161 + public static void windowOpenWithHtml( String pName, String pFeatures, String pHTML ) {
162 + if ( !trywindowOpenWithHtml( pName, pFeatures, pHTML ) ) {
163 + popupsBlocked();
164 + }
165 + }
166 +
167 + public static void windowOpenWithHtml( String pName, String pHTML ) {
168 + windowOpenWithHtml( pName, "", pHTML );
169 + }
170 +
171 + public static void setWindowTitle( String pTitle ) {
172 + if ( sWindowNameInWindowTitle ) {
173 + pTitle += " - '" + WindowName.get() + "'";
174 + }
175 + Window.setTitle( pTitle );
176 + }
177 +
178 + private static boolean sWindowNameInWindowTitle = false;
179 +
180 + public static void addWindowNameToWindowTitle() {
181 + sWindowNameInWindowTitle = true;
182 + setWindowTitle( Window.getTitle() );
183 + }
184 +
185 + private static void popupsBlocked() {
186 + AlertManager.alert( "NewClient", "Browser Configuration Error",
187 + "This application requires pop-up windows to run properly.\n\nPlease change your browser options to unblock pop-ups." );
188 + }
189 +
190 + public static void eventPreventDefaultAndCancelBubble( Event pEvent ) {
191 + pEvent.preventDefault();
192 + pEvent.stopPropagation();
193 + }
194 +
195 + public static boolean wasAltKeyDownOnCurrentEvent() {
196 + return DOM.eventGetAltKey( DOM.eventGetCurrentEvent() );
197 + }
198 +
199 + public static boolean wasCtrlKeyDownOnCurrentEvent() {
200 + // Use Command key for Macs. Ctrl key usually always triggers contextual menu on Macs.
201 + if ( UserAgent.getInstance().getPlatform() == Platform.Mac ) {
202 + return DOM.eventGetCurrentEvent().getMetaKey();
203 + } else {
204 + return DOM.eventGetCurrentEvent().getCtrlKey();
205 + }
206 + }
207 +
208 + public static String shortClassname( String pClassName ) {
209 + String name = "." + ClassNameFromGoogleClassToStringMethod( pClassName ) + "$";
210 + name = name.substring( 0, name.indexOf( '$' ) );
211 + return name.substring( name.lastIndexOf( '.' ) + 1 );
212 + }
213 +
214 + public static String ClassNameFromGoogleClassToStringMethod( String pClassName ) {
215 + pClassName = ConstrainTo.notNull( pClassName ).trim();
216 + int index = pClassName.indexOf( ' ' ) + 1;
217 + return index > 0 ? pClassName.substring( index ) : pClassName;
218 + }
219 +
220 + public static boolean equalGwtClassStrings( String pClassName1, String pClassName2 ) {
221 + return ClassNameFromGoogleClassToStringMethod( pClassName1 ).equals( ClassNameFromGoogleClassToStringMethod( pClassName2 ) );
222 + }
223 +
224 + public static void closeWindowNoConfirm( int pMilliSecDelay ) {
225 + setDisableCloseConfirm( true );
226 + new com.google.gwt.user.client.Timer() // Fully qualified as there are Multiple Versions
227 + {
228 + @Override
229 + public void run() {
230 + closeWindow();
231 + }
232 + }.schedule( (pMilliSecDelay < 1) ? 1 : pMilliSecDelay );
233 + }
234 +
235 + public static void closeWindowNoConfirm( String pAlertMessage ) {
236 + closeWindowNoConfirm( pAlertMessage, null );
237 + }
238 +
239 + public static void closeWindowNoConfirm( String pAlertMessage, Exception pRootProblem ) {
240 + AlertManager.alert( "WinClose", null, pAlertMessage, pRootProblem, new DialogCloseCallBack() {
241 + @Override
242 + public void dialogClosed() {
243 + setDisableCloseConfirm( true );
244 + closeWindow();
245 + }
246 + } );
247 + }
248 +
249 + private static Set<WindowClosingConfirmMessageProvider> sListeners = new HashSet<WindowClosingConfirmMessageProvider>();
250 +
251 + public static void addListener( WindowClosingConfirmMessageProvider pListener ) {
252 + if ( pListener != null ) {
253 + if ( sListeners.add( pListener ) ) {
254 + manageWindowCloseHandler();
255 + }
256 + }
257 + }
258 +
259 + public static boolean removeListener( WindowClosingConfirmMessageProvider pListener ) {
260 + if ( pListener != null ) {
261 + if ( sListeners.remove( pListener ) ) {
262 + manageWindowCloseHandler();
263 + return true;
264 + }
265 + }
266 + return false;
267 + }
268 +
269 + private static void manageWindowCloseHandler() {
270 + if ( sListeners.isEmpty() ) {
271 + if ( sCloseHandlerRegistration != null ) {
272 + sCloseHandlerRegistration.removeHandler();
273 + sCloseHandlerRegistration = null;
274 + }
275 + } else if ( sCloseHandlerRegistration == null ) {
276 + sCloseHandlerRegistration = Window.addWindowClosingHandler( sCloseHandler );
277 + }
278 + }
279 +
280 + private static HandlerRegistration sCloseHandlerRegistration = null;
281 + private static Window.ClosingHandler sCloseHandler = new Window.ClosingHandler() {
282 + @Override
283 + public void onWindowClosing( Window.ClosingEvent pEvent ) {
284 + if ( !isDisableCloseConfirm() && !sListeners.isEmpty() ) {
285 + StringBuilder sb = new StringBuilder();
286 + for ( WindowClosingConfirmMessageProvider zProvider : sListeners ) {
287 + String msg = zProvider.getOnWindowClosingConfirmMessage();
288 + if ( msg != null ) {
289 + if ( sb.length() != 0 ) {
290 + sb.append( '\n' );
291 + }
292 + sb.append( msg );
293 + }
294 + }
295 + if ( sb.length() != 0 ) {
296 + pEvent.setMessage( sb.toString() );
297 + }
298 + }
299 + }
300 + };
301 +
302 + public static void busyCursor() {
303 + RootPanel.get().getElement().getStyle().setProperty( "cursor", "wait" );
304 + }
305 +
306 + public static void regularCursor() {
307 + RootPanel.get().getElement().getStyle().setProperty( "cursor", "auto" );
308 + }
309 +
310 + public static void hide( Widget pWidget ) {
311 + setHidden( pWidget, true );
312 + }
313 +
314 + public static void unhide( Widget pWidget ) {
315 + setHidden( pWidget, false );
316 + }
317 +
318 + public static void setHidden( Widget pWidget, boolean pHide ) {
319 + CommonElementHelper.setHidden( pWidget.getElement(), pHide );
320 + }
321 +
322 + public static boolean isHidden( Widget pWidget ) {
323 + return CommonElementHelper.isHidden( pWidget.getElement() );
324 + }
325 +
326 + public static boolean isVisible( Widget pWidget ) {
327 + return CommonElementHelper.isVisible( pWidget.getElement() );
328 + }
329 +
330 + public static void style( Widget pWidget, String pStyleName, boolean pAdd ) {
331 + if ( pAdd ) {
332 + pWidget.addStyleName( pStyleName );
333 + } else {
334 + pWidget.removeStyleName( pStyleName );
335 + }
336 + }
337 +
338 + public static boolean isRecursiveVisible( Widget pWidget ) {
339 + if ( pWidget != null && pWidget.isAttached() ) {
340 + while ( !isHidden( pWidget ) && isVisible( pWidget ) ) {
341 + if ( null == (pWidget = pWidget.getParent()) ) {
342 + return true;
343 + }
344 + }
345 + }
346 + return false;
347 + }
348 +
349 + public static String getExpando( Element pElement, String pName ) {
350 + return pElement.getPropertyString( pName );
351 + }
352 +
353 + /**
354 + * Set a non-standard attribute.
355 + */
356 + public static void setExpando( Element pElement, String pName, String pValue ) {
357 + pElement.setPropertyString( pName, pValue );
358 + }
359 + }