|
@@ -1,13 +1,10 @@ |
1 |
1 |
|
package com.temp.client.foundation.util; |
2 |
2 |
|
|
3 |
|
- |
import java.util.List; |
4 |
|
- |
|
|
3 |
+ |
import com.google.gwt.user.client.*; |
5 |
4 |
|
import com.google.gwt.user.client.ui.*; |
6 |
|
- |
import com.temp.client.foundation.widget.Spacer; |
|
5 |
+ |
import com.temp.client.foundation.widget.*; |
7 |
6 |
|
|
8 |
|
- |
import com.google.gwt.user.client.DOM; |
9 |
|
- |
import com.google.gwt.user.client.Element; |
10 |
|
- |
import com.google.gwt.user.client.Window; |
|
7 |
+ |
import java.util.*; |
11 |
8 |
|
|
12 |
9 |
|
/** |
13 |
10 |
|
* This Utility class provides low level support for GWT Widgets & UI. |
|
@@ -17,39 +14,39 @@ |
17 |
14 |
|
public class UtilsGwt { |
18 |
15 |
|
|
19 |
16 |
|
public static void busyCursor() { |
20 |
|
- |
RootPanel.get().getElement().getStyle().setProperty("cursor", "wait"); |
|
17 |
+ |
RootPanel.get().getElement().getStyle().setProperty( "cursor", "wait" ); |
21 |
18 |
|
} |
22 |
19 |
|
|
23 |
20 |
|
public static void regularCursor() { |
24 |
|
- |
RootPanel.get().getElement().getStyle().setProperty("cursor", "auto"); |
|
21 |
+ |
RootPanel.get().getElement().getStyle().setProperty( "cursor", "auto" ); |
25 |
22 |
|
} |
26 |
23 |
|
|
27 |
|
- |
public static void hide(Widget widget) { |
28 |
|
- |
setHidden(widget, true); |
|
24 |
+ |
public static void hide( Widget widget ) { |
|
25 |
+ |
setHidden( widget, true ); |
29 |
26 |
|
} |
30 |
27 |
|
|
31 |
|
- |
public static void unhide(Widget widget) { |
32 |
|
- |
setHidden(widget, false); |
|
28 |
+ |
public static void unhide( Widget widget ) { |
|
29 |
+ |
setHidden( widget, false ); |
33 |
30 |
|
} |
34 |
31 |
|
|
35 |
|
- |
public static void setHidden(Widget widget, boolean hide) { |
36 |
|
- |
if (widget != null) { |
37 |
|
- |
CommonElementHelper.setHidden(widget.getElement(), hide); |
|
32 |
+ |
public static void setHidden( Widget widget, boolean hide ) { |
|
33 |
+ |
if ( widget != null ) { |
|
34 |
+ |
CommonElementHelper.setHidden( widget.getElement(), hide ); |
38 |
35 |
|
} |
39 |
36 |
|
} |
40 |
37 |
|
|
41 |
|
- |
public static boolean isHidden(Widget widget) { |
42 |
|
- |
return CommonElementHelper.isHidden(widget.getElement()); |
|
38 |
+ |
public static boolean isHidden( Widget widget ) { |
|
39 |
+ |
return CommonElementHelper.isHidden( widget.getElement() ); |
43 |
40 |
|
} |
44 |
41 |
|
|
45 |
|
- |
public static boolean isVisible(Widget widget) { |
46 |
|
- |
return CommonElementHelper.isVisible(widget.getElement()); |
|
42 |
+ |
public static boolean isVisible( Widget widget ) { |
|
43 |
+ |
return CommonElementHelper.isVisible( widget.getElement() ); |
47 |
44 |
|
} |
48 |
45 |
|
|
49 |
|
- |
public static boolean isRecursiveVisible(Widget widget) { |
50 |
|
- |
if (widget != null && widget.isAttached()) { |
51 |
|
- |
while (!isHidden(widget) && isVisible(widget)) { |
52 |
|
- |
if (null == (widget = widget.getParent())) { |
|
46 |
+ |
public static boolean isRecursiveVisible( Widget widget ) { |
|
47 |
+ |
if ( widget != null && widget.isAttached() ) { |
|
48 |
+ |
while ( !isHidden( widget ) && isVisible( widget ) ) { |
|
49 |
+ |
if ( null == (widget = widget.getParent()) ) { |
53 |
50 |
|
return true; |
54 |
51 |
|
} |
55 |
52 |
|
} |
|
@@ -57,59 +54,59 @@ |
57 |
54 |
|
return false; |
58 |
55 |
|
} |
59 |
56 |
|
|
60 |
|
- |
public static void enableWithStyle(boolean enable, Widget widget, String enabledCssClassName, String disabledCssClassName) { |
61 |
|
- |
if (enable) { |
62 |
|
- |
changeStyleOnFromTo(widget, disabledCssClassName, enabledCssClassName); |
|
57 |
+ |
public static void enableWithStyle( boolean enable, Widget widget, String enabledCssClassName, String disabledCssClassName ) { |
|
58 |
+ |
if ( enable ) { |
|
59 |
+ |
changeStyleOnFromTo( widget, disabledCssClassName, enabledCssClassName ); |
63 |
60 |
|
} else { |
64 |
|
- |
changeStyleOnFromTo(widget, enabledCssClassName, disabledCssClassName); |
|
61 |
+ |
changeStyleOnFromTo( widget, enabledCssClassName, disabledCssClassName ); |
65 |
62 |
|
} |
66 |
63 |
|
} |
67 |
64 |
|
|
68 |
|
- |
public static void changeStyleOnFromTo(Widget widget, String fromCssClassName, String toCssClassName) { |
69 |
|
- |
widget.removeStyleName(fromCssClassName); |
70 |
|
- |
widget.addStyleName(toCssClassName); |
|
65 |
+ |
public static void changeStyleOnFromTo( Widget widget, String fromCssClassName, String toCssClassName ) { |
|
66 |
+ |
widget.removeStyleName( fromCssClassName ); |
|
67 |
+ |
widget.addStyleName( toCssClassName ); |
71 |
68 |
|
} |
72 |
69 |
|
|
73 |
|
- |
public static String getMetaElementContent(String id) { |
74 |
|
- |
Element metaElement = DOM.getElementById(id); |
75 |
|
- |
return (metaElement == null) ? null : metaElement.getAttribute("content"); |
|
70 |
+ |
public static String getMetaElementContent( String id ) { |
|
71 |
+ |
Element metaElement = DOM.getElementById( id ); |
|
72 |
+ |
return (metaElement == null) ? null : metaElement.getAttribute( "content" ); |
76 |
73 |
|
} |
77 |
74 |
|
|
78 |
75 |
|
public static String getCustomerFullName() { |
79 |
|
- |
return UtilsGwt.getMetaElementContent("meta-username"); |
|
76 |
+ |
return UtilsGwt.getMetaElementContent( "meta-username" ); |
80 |
77 |
|
} |
81 |
78 |
|
|
82 |
79 |
|
public static String getCustomerEmailId() { |
83 |
|
- |
return UtilsGwt.getMetaElementContent("meta-email"); |
|
80 |
+ |
return UtilsGwt.getMetaElementContent( "meta-email" ); |
84 |
81 |
|
} |
85 |
82 |
|
|
86 |
|
- |
public static Widget horizontal(Widget... pWidgets) { |
|
83 |
+ |
public static Widget horizontal( Widget... pWidgets ) { |
87 |
84 |
|
HorizontalPanel zPanel = new HorizontalPanel(); |
88 |
|
- |
if (pWidgets != null) { |
89 |
|
- |
for (Widget zWidget : pWidgets) { |
90 |
|
- |
if (zWidget != null) { |
91 |
|
- |
zPanel.add(zWidget); |
|
85 |
+ |
if ( pWidgets != null ) { |
|
86 |
+ |
for ( Widget zWidget : pWidgets ) { |
|
87 |
+ |
if ( zWidget != null ) { |
|
88 |
+ |
zPanel.add( zWidget ); |
92 |
89 |
|
} |
93 |
90 |
|
} |
94 |
91 |
|
} |
95 |
|
- |
if (zPanel.getWidgetCount() == 0) { |
96 |
|
- |
zPanel.add(new Spacer()); |
|
92 |
+ |
if ( zPanel.getWidgetCount() == 0 ) { |
|
93 |
+ |
zPanel.add( new Spacer() ); |
97 |
94 |
|
} |
98 |
95 |
|
return zPanel; |
99 |
96 |
|
} |
100 |
97 |
|
|
101 |
|
- |
public static VerticalPanel vertical(String styleClassName) { |
|
98 |
+ |
public static VerticalPanel vertical( String styleClassName ) { |
102 |
99 |
|
VerticalPanel zPanel = new VerticalPanel(); |
103 |
100 |
|
zPanel.addStyleName( styleClassName ); |
104 |
101 |
|
return zPanel; |
105 |
102 |
|
} |
106 |
103 |
|
|
107 |
|
- |
public static VerticalPanel add(VerticalPanel panel, IsWidget widget) { |
108 |
|
- |
return (widget == null) ? panel : add(panel, widget.asWidget()); |
|
104 |
+ |
public static VerticalPanel add( VerticalPanel panel, IsWidget widget ) { |
|
105 |
+ |
return (widget == null) ? panel : add( panel, widget.asWidget() ); |
109 |
106 |
|
} |
110 |
107 |
|
|
111 |
|
- |
public static VerticalPanel add(VerticalPanel panel, Widget widget) { |
112 |
|
- |
if ((panel != null) && (widget != null)) { |
|
108 |
+ |
public static VerticalPanel add( VerticalPanel panel, Widget widget ) { |
|
109 |
+ |
if ( (panel != null) && (widget != null) ) { |
113 |
110 |
|
panel.add( widget ); |
114 |
111 |
|
} |
115 |
112 |
|
return panel; |
|
@@ -117,7 +114,7 @@ |
117 |
114 |
|
|
118 |
115 |
|
/** |
119 |
116 |
|
* set the "ID" of the Widget to a simplified class Name. |
120 |
|
- |
* |
|
117 |
+ |
* <p/> |
121 |
118 |
|
* Simplified class Name is one that: |
122 |
119 |
|
* <ol> |
123 |
120 |
|
* <li>Ignores Inner Classes (removes '$' and anything after)</li> |
|
@@ -128,29 +125,27 @@ |
128 |
125 |
|
* "com.temp.client.module.dashboard.dash.DashViewImpl$1" -> |
129 |
126 |
|
* "DashView" |
130 |
127 |
|
*/ |
131 |
|
- |
public static void setIdToClassNameOf(Widget widget, Object forClassName) { |
132 |
|
- |
if ((widget != null) && (forClassName != null)) { |
|
128 |
+ |
public static void setIdToClassNameOf( Widget widget, Object forClassName ) { |
|
129 |
+ |
if ( (widget != null) && (forClassName != null) ) { |
133 |
130 |
|
String name = "." + forClassName.getClass().getName() + "$"; |
134 |
|
- |
name = name.substring(0, name.indexOf('$')); |
135 |
|
- |
name = name.substring(name.lastIndexOf('.') + 1); |
136 |
|
- |
if (name.endsWith("Impl")) { |
137 |
|
- |
name = name.substring(0, name.length() - 4); |
|
131 |
+ |
name = name.substring( 0, name.indexOf( '$' ) ); |
|
132 |
+ |
name = name.substring( name.lastIndexOf( '.' ) + 1 ); |
|
133 |
+ |
if ( name.endsWith( "Impl" ) ) { |
|
134 |
+ |
name = name.substring( 0, name.length() - 4 ); |
138 |
135 |
|
} |
139 |
|
- |
widget.getElement().setId(name); |
|
136 |
+ |
widget.getElement().setId( name ); |
140 |
137 |
|
} |
141 |
138 |
|
} |
142 |
139 |
|
|
143 |
|
- |
public static native void openWithFocus(String url, String name, String features) /*-{ |
144 |
|
- |
var win = $wnd.open(url, name, features); |
|
140 |
+ |
public static native void openWithFocus( String url, String name, String features ) /*-{ |
|
141 |
+ |
var win = $wnd.open( url, name, features ); |
145 |
142 |
|
win.focus(); |
146 |
143 |
|
}-*/; |
147 |
144 |
|
|
148 |
145 |
|
public static final String CHROMELESS_SCROLLABLE_WITH_MENUS = "directories=0,location=0,toolbar=0,status=1,resizable=1,scrollbars=1,menubar=1"; |
149 |
146 |
|
|
150 |
|
- |
public static void windowOpenWithHtml( String pName, String pFeatures, String pHTML ) |
151 |
|
- |
{ |
152 |
|
- |
if ( !trywindowOpenWithHtml( pName, pFeatures, pHTML ) ) |
153 |
|
- |
{ |
|
147 |
+ |
public static void windowOpenWithHtml( String pName, String pFeatures, String pHTML ) { |
|
148 |
+ |
if ( !trywindowOpenWithHtml( pName, pFeatures, pHTML ) ) { |
154 |
149 |
|
popupsBlocked(); |
155 |
150 |
|
} |
156 |
151 |
|
} |
|
@@ -166,17 +161,17 @@ |
166 |
161 |
|
return true; |
167 |
162 |
|
}-*/; |
168 |
163 |
|
|
169 |
|
- |
private static void popupsBlocked() |
170 |
|
- |
{ |
171 |
|
- |
Window.alert( "Browser Configuration Error\n\n\nThis feature requires pop-up windows to run properly.\n\nPlease change your browser options to unblock pop-ups." ); |
|
164 |
+ |
private static void popupsBlocked() { |
|
165 |
+ |
Window.alert( |
|
166 |
+ |
"Browser Configuration Error\n\n\nThis feature requires pop-up windows to run properly.\n\nPlease change your browser options to unblock " + |
|
167 |
+ |
"pop-ups." ); |
172 |
168 |
|
} |
173 |
169 |
|
|
174 |
|
- |
public static String convertToString(List<String> inputList) |
175 |
|
- |
{ |
|
170 |
+ |
public static String convertToString( List<String> inputList ) { |
176 |
171 |
|
String result = null; |
177 |
|
- |
if (inputList != null) { |
|
172 |
+ |
if ( inputList != null ) { |
178 |
173 |
|
result = inputList.toString(); |
179 |
|
- |
result = result.substring(0, result.length() - 1); |
|
174 |
+ |
result = result.substring( 0, result.length() - 1 ); |
180 |
175 |
|
} |
181 |
176 |
|
return result; |
182 |
177 |
|
} |