|
@@ -1,349 +1,349 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package org.litesoft.GWT.forms.client.components.nonpublic; |
3 |
|
- |
|
4 |
|
- |
import org.litesoft.GWT.client.widgets.*; |
5 |
|
- |
import org.litesoft.GWT.client.widgets.nonpublic.*; |
6 |
|
- |
|
7 |
|
- |
import com.google.gwt.dom.client.*; |
8 |
|
- |
import com.google.gwt.user.client.*; |
9 |
|
- |
import com.google.gwt.user.client.Element; |
10 |
|
- |
import com.google.gwt.user.client.ui.*; |
11 |
|
- |
|
12 |
|
- |
public class FormContainerErrorPanel extends AbstractSizeableOneDimensionalPanel { |
13 |
|
- |
private static final String CLASS_POP_UP_PANEL_ERROR = "litesoft-FormPopUpPanel_error"; |
14 |
|
- |
private static final String CLASS_POP_UP_PANEL_WARNING = "litesoft-FormPopUpPanel_warning"; |
15 |
|
- |
|
16 |
|
- |
protected MessagePopUpPanel mMessagePopUpPanel = new MessagePopUpPanel(); |
17 |
|
- |
|
18 |
|
- |
public FormContainerErrorPanel() { |
19 |
|
- |
initializeElements( getHelper().create_OeTable_SeDiv_IeDiv( true ), null ); |
20 |
|
- |
CommonElementHelper.setOverflowVisible( getHelper().getStyleElement() ); |
21 |
|
- |
LLstretchableHorizontally(); |
22 |
|
- |
add( mMessagePopUpPanel ); |
23 |
|
- |
add( mMessagePopUpPanel.getIndicatorBar() ); |
24 |
|
- |
} |
25 |
|
- |
|
26 |
|
- |
public void setError( String pError ) { |
27 |
|
- |
mMessagePopUpPanel.setError( pError ); |
28 |
|
- |
} |
29 |
|
- |
|
30 |
|
- |
public void setWarning( String pWarning ) { |
31 |
|
- |
mMessagePopUpPanel.setWarning( pWarning ); |
32 |
|
- |
} |
33 |
|
- |
|
34 |
|
- |
public void clearErrorOrWarning() { |
35 |
|
- |
mMessagePopUpPanel.clearErrorOrWarning(); |
36 |
|
- |
} |
37 |
|
- |
|
38 |
|
- |
@Override |
39 |
|
- |
protected void LLdisown( Widget pWidget, int pIndex ) { |
40 |
|
- |
abstractSizeablePanel_disown( pWidget ); |
41 |
|
- |
getChildren().remove( pIndex ); |
42 |
|
- |
} |
43 |
|
- |
|
44 |
|
- |
@Override |
45 |
|
- |
protected void LLadopt( Widget pWidget, int pBeforeIndex ) { |
46 |
|
- |
pWidget.removeFromParent(); |
47 |
|
- |
abstractSizeablePanel_adopt( pWidget, getContainerElement() ); |
48 |
|
- |
getChildren().insert( pWidget, pBeforeIndex ); |
49 |
|
- |
} |
50 |
|
- |
|
51 |
|
- |
@Override |
52 |
|
- |
protected Element unwrap( Element pTD ) { |
53 |
|
- |
throw new UnsupportedOperationException( "unwrap?" ); |
54 |
|
- |
} |
55 |
|
- |
|
56 |
|
- |
@Override |
57 |
|
- |
protected Element wrap( Element pTD ) { |
58 |
|
- |
throw new UnsupportedOperationException( "wrap?" ); |
59 |
|
- |
} |
60 |
|
- |
|
61 |
|
- |
@Override |
62 |
|
- |
public void setHeight( String height ) { |
63 |
|
- |
mMessagePopUpPanel.reposition(); |
64 |
|
- |
// Do NOT pass thru! |
65 |
|
- |
} |
66 |
|
- |
|
67 |
|
- |
@Override |
68 |
|
- |
public void setWidth( String width ) { |
69 |
|
- |
if ( (mMinimumWidth == null) && anyChildren() ) { |
70 |
|
- |
Element elem = DOM.getParent( getContainerElement() ); |
71 |
|
- |
int currentWidth = DOM.getElementPropertyInt( elem, "offsetWidth" ); |
72 |
|
- |
if ( currentWidth > 0 ) { |
73 |
|
- |
getHelper().setDimensionOnChildren( this, getWidthHelper(), currentWidth ); |
74 |
|
- |
mMinimumWidth = currentWidth; |
75 |
|
- |
} |
76 |
|
- |
} |
77 |
|
- |
CommonElementHelper.setOverflowHidden( getHelper().getStyleElement() ); |
78 |
|
- |
super.setWidth( width ); |
79 |
|
- |
CommonElementHelper.setOverflowVisible( getHelper().getStyleElement() ); |
80 |
|
- |
} |
81 |
|
- |
|
82 |
|
- |
private Integer mMinimumWidth = null; |
83 |
|
- |
|
84 |
|
- |
@Override |
85 |
|
- |
protected void distributeToChildrenChangedWidth() { |
86 |
|
- |
if ( anyChildren() ) { |
87 |
|
- |
getHelper().applyChangedDimensionToChildren( this, getWidthHelper() ); |
88 |
|
- |
} |
89 |
|
- |
} |
90 |
|
- |
|
91 |
|
- |
public static class MessagePopUpPanel extends SizeableSimplePanel { |
92 |
|
- |
private static final String STYLE_NONE = "_None"; |
93 |
|
- |
private static final String STYLE_ERROR = "Error"; |
94 |
|
- |
private static final String STYLE_WARNING = "Warning"; |
95 |
|
- |
|
96 |
|
- |
private String mCurStyle = STYLE_NONE; |
97 |
|
- |
private String mCurText = ""; |
98 |
|
- |
|
99 |
|
- |
private MessageIndicatorBar mIndicatorBar = new MessageIndicatorBar(); |
100 |
|
- |
protected Label mErrorPopUpLabel = new Label( "", true ); |
101 |
|
- |
private boolean mMsgShown = false; |
102 |
|
- |
|
103 |
|
- |
public MessagePopUpPanel() { |
104 |
|
- |
super( true, "litesoft-FormPopUpPanel" ); |
105 |
|
- |
stretchableHorizontally(); |
106 |
|
- |
setWidget( mErrorPopUpLabel ); |
107 |
|
- |
Element tableElement = getElement(); |
108 |
|
- |
CommonElementHelper.setPositionAbsolute( tableElement ); |
109 |
|
- |
hide(); |
110 |
|
- |
mIndicatorBar.addClickListener( new ClickListener() { |
111 |
|
- |
@Override |
112 |
|
- |
public void onClick( Widget sender ) { |
113 |
|
- |
mIndicatorBar.updateArrowDisplay(); |
114 |
|
- |
toggleDisplay(); |
115 |
|
- |
} |
116 |
|
- |
} ); |
117 |
|
- |
} |
118 |
|
- |
|
119 |
|
- |
private void toggleDisplay() { |
120 |
|
- |
if ( !mMsgShown ) { |
121 |
|
- |
show(); |
122 |
|
- |
} else { |
123 |
|
- |
hide(); |
124 |
|
- |
} |
125 |
|
- |
} |
126 |
|
- |
|
127 |
|
- |
public boolean isErrorStyle( String pError ) { |
128 |
|
- |
return mCurStyle.equals( STYLE_ERROR ) && mCurText.equals( pError ); |
129 |
|
- |
} |
130 |
|
- |
|
131 |
|
- |
public void setError( String pError ) { |
132 |
|
- |
if ( pError != null && !isErrorStyle( pError ) ) { |
133 |
|
- |
mCurStyle = STYLE_ERROR; |
134 |
|
- |
boolean zSavedMsgShown = mMsgShown; |
135 |
|
- |
hide(); |
136 |
|
- |
setErrorStyle(); |
137 |
|
- |
mErrorPopUpLabel.setText( mCurText = pError ); |
138 |
|
- |
mIndicatorBar.setErrorStyle( pError ); |
139 |
|
- |
if ( zSavedMsgShown ) { |
140 |
|
- |
show(); |
141 |
|
- |
} |
142 |
|
- |
} |
143 |
|
- |
} |
144 |
|
- |
|
145 |
|
- |
public boolean isWarningStyle( String pWarning ) { |
146 |
|
- |
return mCurStyle.equals( STYLE_WARNING ) && mCurText.equals( pWarning ); |
147 |
|
- |
} |
148 |
|
- |
|
149 |
|
- |
public void setWarning( String pWarning ) { |
150 |
|
- |
if ( pWarning != null && !isWarningStyle( pWarning ) ) { |
151 |
|
- |
mCurStyle = STYLE_WARNING; |
152 |
|
- |
boolean zSavedMsgShown = mMsgShown; |
153 |
|
- |
hide(); |
154 |
|
- |
setWarningStyle(); |
155 |
|
- |
mErrorPopUpLabel.setText( mCurText = pWarning ); |
156 |
|
- |
mIndicatorBar.setWarningStyle( pWarning ); |
157 |
|
- |
if ( zSavedMsgShown ) { |
158 |
|
- |
show(); |
159 |
|
- |
} |
160 |
|
- |
} |
161 |
|
- |
} |
162 |
|
- |
|
163 |
|
- |
public void clearErrorOrWarning() { |
164 |
|
- |
mCurStyle = STYLE_NONE; |
165 |
|
- |
hide(); |
166 |
|
- |
mIndicatorBar.hide(); |
167 |
|
- |
DOM.setElementAttribute( mIndicatorBar.getElement(), "title", "" ); |
168 |
|
- |
mIndicatorBar.setDefaultArrowDisplay(); |
169 |
|
- |
mErrorPopUpLabel.setText( "" ); |
170 |
|
- |
mMsgShown = false; |
171 |
|
- |
} |
172 |
|
- |
|
173 |
|
- |
public MessageIndicatorBar getIndicatorBar() { |
174 |
|
- |
return mIndicatorBar; |
175 |
|
- |
} |
176 |
|
- |
|
177 |
|
- |
public void reposition() { |
178 |
|
- |
if ( mMsgShown ) { |
179 |
|
- |
hide(); |
180 |
|
- |
show(); |
181 |
|
- |
} |
182 |
|
- |
} |
183 |
|
- |
|
184 |
|
- |
public void hide() { |
185 |
|
- |
CommonElementHelper.hide( getElement() ); |
186 |
|
- |
mMsgShown = false; |
187 |
|
- |
} |
188 |
|
- |
|
189 |
|
- |
public void show() { |
190 |
|
- |
position(); |
191 |
|
- |
|
192 |
|
- |
CommonElementHelper.unhide( getElement() ); |
193 |
|
- |
mMsgShown = true; |
194 |
|
- |
} |
195 |
|
- |
|
196 |
|
- |
protected void position() { |
197 |
|
- |
int zOffsetToBottom = mIndicatorBar.getOffsetHeight(); |
198 |
|
- |
getElement().getStyle().setBottom( zOffsetToBottom, Style.Unit.PX ); |
199 |
|
- |
} |
200 |
|
- |
|
201 |
|
- |
public void setWarningStyle() { |
202 |
|
- |
removeStyleName( CLASS_POP_UP_PANEL_ERROR ); |
203 |
|
- |
addStyleName( CLASS_POP_UP_PANEL_WARNING ); |
204 |
|
- |
} |
205 |
|
- |
|
206 |
|
- |
public void setErrorStyle() { |
207 |
|
- |
removeStyleName( CLASS_POP_UP_PANEL_WARNING ); |
208 |
|
- |
addStyleName( CLASS_POP_UP_PANEL_ERROR ); |
209 |
|
- |
} |
210 |
|
- |
} |
211 |
|
- |
|
212 |
|
- |
public static class MessageIndicatorBar extends SizeableHorizontalPanel { |
213 |
|
- |
private static final String CLASS_ERROR_BAR = "litesoft-FormErrorBar"; |
214 |
|
- |
private static final String CLASS_ERROR_BAR_REGULAR = "litesoft-FormErrorBar_regular"; |
215 |
|
- |
private static final String CLASS_ERROR_BAR_MOUSEOVER = "litesoft-FormErrorBar_mouseover"; |
216 |
|
- |
|
217 |
|
- |
private static final String CLASS_WARNING_BAR = "litesoft-FormWarningBar"; |
218 |
|
- |
private static final String CLASS_WARNING_BAR_REGULAR = "litesoft-FormWarningBar_regular"; |
219 |
|
- |
private static final String CLASS_WARNING_BAR_MOUSEOVER = "litesoft-FormWarningBar_mouseover"; |
220 |
|
- |
|
221 |
|
- |
private static final String CLASS_BUTTON_BG = "litesoft-FormMsgBarButtonBg"; |
222 |
|
- |
|
223 |
|
- |
private static final String ARROW_UP = "common/images/formcomponents/uparrow_wht.gif"; |
224 |
|
- |
private static final String ARROW_DOWN = "common/images/formcomponents/downarrow_wht.gif"; |
225 |
|
- |
|
226 |
|
- |
private boolean mArrowUp = true; |
227 |
|
- |
private Image mArrowWidget = new Image( ARROW_UP ); // CLASS_BUTTON_BG |
228 |
|
- |
|
229 |
|
- |
public MessageIndicatorBar() { |
230 |
|
- |
super( true, CLASS_ERROR_BAR ); |
231 |
|
- |
|
232 |
|
- |
addStyleName( CLASS_ERROR_BAR_REGULAR ); |
233 |
|
- |
|
234 |
|
- |
sinkEvents( Event.MOUSEEVENTS ); |
235 |
|
- |
stretchableHorizontally(); |
236 |
|
- |
|
237 |
|
- |
add( new SizeableSpacer().stretchableHorizontally() ); |
238 |
|
- |
add( mArrowWidget ); |
239 |
|
- |
add( new SizeableSpacer().stretchableHorizontally() ); |
240 |
|
- |
|
241 |
|
- |
Element zArrowTD = DOM.getParent( mArrowWidget.getElement() ); |
242 |
|
- |
CommonElementHelper.setStyleClass( zArrowTD, CLASS_BUTTON_BG ); |
243 |
|
- |
hide(); |
244 |
|
- |
} |
245 |
|
- |
|
246 |
|
- |
@Override |
247 |
|
- |
public void setVisible( boolean visible ) { |
248 |
|
- |
throw new IllegalStateException( "Not Supported" ); |
249 |
|
- |
} |
250 |
|
- |
|
251 |
|
- |
public void show() { |
252 |
|
- |
CommonElementHelper.unhide( getElement() ); |
253 |
|
- |
} |
254 |
|
- |
|
255 |
|
- |
public void hide() { |
256 |
|
- |
CommonElementHelper.hide( getElement() ); |
257 |
|
- |
} |
258 |
|
- |
|
259 |
|
- |
public void setErrorStyle( String pError ) { |
260 |
|
- |
DOM.setElementAttribute( getElement(), "title", pError ); |
261 |
|
- |
removeStyleName( CLASS_WARNING_BAR ); |
262 |
|
- |
removeStyleName( CLASS_WARNING_BAR_REGULAR ); |
263 |
|
- |
addStyleName( CLASS_ERROR_BAR ); |
264 |
|
- |
addStyleName( CLASS_ERROR_BAR_REGULAR ); |
265 |
|
- |
|
266 |
|
- |
show(); |
267 |
|
- |
} |
268 |
|
- |
|
269 |
|
- |
public void setWarningStyle( String pWarning ) { |
270 |
|
- |
DOM.setElementAttribute( getElement(), "title", pWarning ); |
271 |
|
- |
removeStyleName( CLASS_ERROR_BAR ); |
272 |
|
- |
removeStyleName( CLASS_ERROR_BAR_REGULAR ); |
273 |
|
- |
addStyleName( CLASS_WARNING_BAR ); |
274 |
|
- |
addStyleName( CLASS_WARNING_BAR_REGULAR ); |
275 |
|
- |
|
276 |
|
- |
// mArrowWidget.setStyleName( CLASS_BUTTON_BG_WARNING ); |
277 |
|
- |
|
278 |
|
- |
show(); |
279 |
|
- |
} |
280 |
|
- |
|
281 |
|
- |
public void updateArrowDisplay() { |
282 |
|
- |
mArrowWidget.setUrl( (mArrowUp = !mArrowUp) ? ARROW_UP : ARROW_DOWN ); |
283 |
|
- |
} |
284 |
|
- |
|
285 |
|
- |
public void setDefaultArrowDisplay() { |
286 |
|
- |
if ( !mArrowUp ) { |
287 |
|
- |
updateArrowDisplay(); |
288 |
|
- |
} |
289 |
|
- |
} |
290 |
|
- |
|
291 |
|
- |
private void setMouseoverStyle() { |
292 |
|
- |
String styleClasses = getStyleName(); |
293 |
|
- |
|
294 |
|
- |
if ( styleClasses.indexOf( CLASS_ERROR_BAR ) > 0 ) { |
295 |
|
- |
removeStyleName( CLASS_ERROR_BAR_REGULAR ); |
296 |
|
- |
addStyleName( CLASS_ERROR_BAR_MOUSEOVER ); |
297 |
|
- |
} |
298 |
|
- |
|
299 |
|
- |
if ( styleClasses.indexOf( CLASS_WARNING_BAR ) > 0 ) { |
300 |
|
- |
removeStyleName( CLASS_WARNING_BAR_REGULAR ); |
301 |
|
- |
addStyleName( CLASS_WARNING_BAR_MOUSEOVER ); |
302 |
|
- |
} |
303 |
|
- |
} |
304 |
|
- |
|
305 |
|
- |
private void setMouseoutStyle() { |
306 |
|
- |
String styleClasses = getStyleName(); |
307 |
|
- |
|
308 |
|
- |
if ( styleClasses.indexOf( CLASS_ERROR_BAR ) > 0 ) { |
309 |
|
- |
removeStyleName( CLASS_ERROR_BAR_MOUSEOVER ); |
310 |
|
- |
addStyleName( CLASS_ERROR_BAR_REGULAR ); |
311 |
|
- |
} |
312 |
|
- |
|
313 |
|
- |
if ( styleClasses.indexOf( CLASS_WARNING_BAR ) > 0 ) { |
314 |
|
- |
removeStyleName( CLASS_WARNING_BAR_MOUSEOVER ); |
315 |
|
- |
addStyleName( CLASS_WARNING_BAR_REGULAR ); |
316 |
|
- |
} |
317 |
|
- |
} |
318 |
|
- |
|
319 |
|
- |
public void addClickListener( ClickListener pListener ) { |
320 |
|
- |
if ( pListener != null ) { |
321 |
|
- |
if ( mClickListeners == null ) { |
322 |
|
- |
mClickListeners = new ClickListenerCollection(); |
323 |
|
- |
} |
324 |
|
- |
//noinspection unchecked |
325 |
|
- |
mClickListeners.add( pListener ); |
326 |
|
- |
} |
327 |
|
- |
} |
328 |
|
- |
|
329 |
|
- |
private ClickListenerCollection mClickListeners = null; |
330 |
|
- |
|
331 |
|
- |
@Override |
332 |
|
- |
public void onBrowserEvent( Event event ) { |
333 |
|
- |
switch ( DOM.eventGetType( event ) ) { |
334 |
|
- |
case Event.ONMOUSEDOWN: { |
335 |
|
- |
if ( mClickListeners != null ) { |
336 |
|
- |
mClickListeners.fireClick( this ); |
337 |
|
- |
} |
338 |
|
- |
break; |
339 |
|
- |
} |
340 |
|
- |
case Event.ONMOUSEOVER: |
341 |
|
- |
setMouseoverStyle(); |
342 |
|
- |
break; |
343 |
|
- |
case Event.ONMOUSEOUT: |
344 |
|
- |
setMouseoutStyle(); |
345 |
|
- |
break; |
346 |
|
- |
} |
347 |
|
- |
} |
348 |
|
- |
} |
349 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package org.litesoft.GWT.forms.client.components.nonpublic; |
|
3 |
+ |
|
|
4 |
+ |
import org.litesoft.GWT.client.widgets.*; |
|
5 |
+ |
import org.litesoft.GWT.client.widgets.nonpublic.*; |
|
6 |
+ |
|
|
7 |
+ |
import com.google.gwt.dom.client.*; |
|
8 |
+ |
import com.google.gwt.user.client.*; |
|
9 |
+ |
import com.google.gwt.user.client.Element; |
|
10 |
+ |
import com.google.gwt.user.client.ui.*; |
|
11 |
+ |
|
|
12 |
+ |
public class FormContainerErrorPanel extends AbstractSizeableOneDimensionalPanel { |
|
13 |
+ |
private static final String CLASS_POP_UP_PANEL_ERROR = "litesoft-FormPopUpPanel_error"; |
|
14 |
+ |
private static final String CLASS_POP_UP_PANEL_WARNING = "litesoft-FormPopUpPanel_warning"; |
|
15 |
+ |
|
|
16 |
+ |
protected MessagePopUpPanel mMessagePopUpPanel = new MessagePopUpPanel(); |
|
17 |
+ |
|
|
18 |
+ |
public FormContainerErrorPanel() { |
|
19 |
+ |
initializeElements( getHelper().create_OeTable_SeDiv_IeDiv( true ), null ); |
|
20 |
+ |
CommonElementHelper.setOverflowVisible( getHelper().getStyleElement() ); |
|
21 |
+ |
LLstretchableHorizontally(); |
|
22 |
+ |
add( mMessagePopUpPanel ); |
|
23 |
+ |
add( mMessagePopUpPanel.getIndicatorBar() ); |
|
24 |
+ |
} |
|
25 |
+ |
|
|
26 |
+ |
public void setError( String pError ) { |
|
27 |
+ |
mMessagePopUpPanel.setError( pError ); |
|
28 |
+ |
} |
|
29 |
+ |
|
|
30 |
+ |
public void setWarning( String pWarning ) { |
|
31 |
+ |
mMessagePopUpPanel.setWarning( pWarning ); |
|
32 |
+ |
} |
|
33 |
+ |
|
|
34 |
+ |
public void clearErrorOrWarning() { |
|
35 |
+ |
mMessagePopUpPanel.clearErrorOrWarning(); |
|
36 |
+ |
} |
|
37 |
+ |
|
|
38 |
+ |
@Override |
|
39 |
+ |
protected void LLdisown( Widget pWidget, int pIndex ) { |
|
40 |
+ |
abstractSizeablePanel_disown( pWidget ); |
|
41 |
+ |
getChildren().remove( pIndex ); |
|
42 |
+ |
} |
|
43 |
+ |
|
|
44 |
+ |
@Override |
|
45 |
+ |
protected void LLadopt( Widget pWidget, int pBeforeIndex ) { |
|
46 |
+ |
pWidget.removeFromParent(); |
|
47 |
+ |
abstractSizeablePanel_adopt( pWidget, getContainerElement() ); |
|
48 |
+ |
getChildren().insert( pWidget, pBeforeIndex ); |
|
49 |
+ |
} |
|
50 |
+ |
|
|
51 |
+ |
@Override |
|
52 |
+ |
protected Element unwrap( Element pTD ) { |
|
53 |
+ |
throw new UnsupportedOperationException( "unwrap?" ); |
|
54 |
+ |
} |
|
55 |
+ |
|
|
56 |
+ |
@Override |
|
57 |
+ |
protected Element wrap( Element pTD ) { |
|
58 |
+ |
throw new UnsupportedOperationException( "wrap?" ); |
|
59 |
+ |
} |
|
60 |
+ |
|
|
61 |
+ |
@Override |
|
62 |
+ |
public void setHeight( String height ) { |
|
63 |
+ |
mMessagePopUpPanel.reposition(); |
|
64 |
+ |
// Do NOT pass thru! |
|
65 |
+ |
} |
|
66 |
+ |
|
|
67 |
+ |
@Override |
|
68 |
+ |
public void setWidth( String width ) { |
|
69 |
+ |
if ( (mMinimumWidth == null) && anyChildren() ) { |
|
70 |
+ |
Element elem = DOM.getParent( getContainerElement() ); |
|
71 |
+ |
int currentWidth = DOM.getElementPropertyInt( elem, "offsetWidth" ); |
|
72 |
+ |
if ( currentWidth > 0 ) { |
|
73 |
+ |
getHelper().setDimensionOnChildren( this, getWidthHelper(), currentWidth ); |
|
74 |
+ |
mMinimumWidth = currentWidth; |
|
75 |
+ |
} |
|
76 |
+ |
} |
|
77 |
+ |
CommonElementHelper.setOverflowHidden( getHelper().getStyleElement() ); |
|
78 |
+ |
super.setWidth( width ); |
|
79 |
+ |
CommonElementHelper.setOverflowVisible( getHelper().getStyleElement() ); |
|
80 |
+ |
} |
|
81 |
+ |
|
|
82 |
+ |
private Integer mMinimumWidth = null; |
|
83 |
+ |
|
|
84 |
+ |
@Override |
|
85 |
+ |
protected void distributeToChildrenChangedWidth() { |
|
86 |
+ |
if ( anyChildren() ) { |
|
87 |
+ |
getHelper().applyChangedDimensionToChildren( this, getWidthHelper() ); |
|
88 |
+ |
} |
|
89 |
+ |
} |
|
90 |
+ |
|
|
91 |
+ |
public static class MessagePopUpPanel extends SizeableSimplePanel { |
|
92 |
+ |
private static final String STYLE_NONE = "_None"; |
|
93 |
+ |
private static final String STYLE_ERROR = "Error"; |
|
94 |
+ |
private static final String STYLE_WARNING = "Warning"; |
|
95 |
+ |
|
|
96 |
+ |
private String mCurStyle = STYLE_NONE; |
|
97 |
+ |
private String mCurText = ""; |
|
98 |
+ |
|
|
99 |
+ |
private MessageIndicatorBar mIndicatorBar = new MessageIndicatorBar(); |
|
100 |
+ |
protected Label mErrorPopUpLabel = new Label( "", true ); |
|
101 |
+ |
private boolean mMsgShown = false; |
|
102 |
+ |
|
|
103 |
+ |
public MessagePopUpPanel() { |
|
104 |
+ |
super( true, "litesoft-FormPopUpPanel" ); |
|
105 |
+ |
stretchableHorizontally(); |
|
106 |
+ |
setWidget( mErrorPopUpLabel ); |
|
107 |
+ |
Element tableElement = getElement(); |
|
108 |
+ |
CommonElementHelper.setPositionAbsolute( tableElement ); |
|
109 |
+ |
hide(); |
|
110 |
+ |
mIndicatorBar.addClickListener( new ClickListener() { |
|
111 |
+ |
@Override |
|
112 |
+ |
public void onClick( Widget sender ) { |
|
113 |
+ |
mIndicatorBar.updateArrowDisplay(); |
|
114 |
+ |
toggleDisplay(); |
|
115 |
+ |
} |
|
116 |
+ |
} ); |
|
117 |
+ |
} |
|
118 |
+ |
|
|
119 |
+ |
private void toggleDisplay() { |
|
120 |
+ |
if ( !mMsgShown ) { |
|
121 |
+ |
show(); |
|
122 |
+ |
} else { |
|
123 |
+ |
hide(); |
|
124 |
+ |
} |
|
125 |
+ |
} |
|
126 |
+ |
|
|
127 |
+ |
public boolean isErrorStyle( String pError ) { |
|
128 |
+ |
return mCurStyle.equals( STYLE_ERROR ) && mCurText.equals( pError ); |
|
129 |
+ |
} |
|
130 |
+ |
|
|
131 |
+ |
public void setError( String pError ) { |
|
132 |
+ |
if ( pError != null && !isErrorStyle( pError ) ) { |
|
133 |
+ |
mCurStyle = STYLE_ERROR; |
|
134 |
+ |
boolean zSavedMsgShown = mMsgShown; |
|
135 |
+ |
hide(); |
|
136 |
+ |
setErrorStyle(); |
|
137 |
+ |
mErrorPopUpLabel.setText( mCurText = pError ); |
|
138 |
+ |
mIndicatorBar.setErrorStyle( pError ); |
|
139 |
+ |
if ( zSavedMsgShown ) { |
|
140 |
+ |
show(); |
|
141 |
+ |
} |
|
142 |
+ |
} |
|
143 |
+ |
} |
|
144 |
+ |
|
|
145 |
+ |
public boolean isWarningStyle( String pWarning ) { |
|
146 |
+ |
return mCurStyle.equals( STYLE_WARNING ) && mCurText.equals( pWarning ); |
|
147 |
+ |
} |
|
148 |
+ |
|
|
149 |
+ |
public void setWarning( String pWarning ) { |
|
150 |
+ |
if ( pWarning != null && !isWarningStyle( pWarning ) ) { |
|
151 |
+ |
mCurStyle = STYLE_WARNING; |
|
152 |
+ |
boolean zSavedMsgShown = mMsgShown; |
|
153 |
+ |
hide(); |
|
154 |
+ |
setWarningStyle(); |
|
155 |
+ |
mErrorPopUpLabel.setText( mCurText = pWarning ); |
|
156 |
+ |
mIndicatorBar.setWarningStyle( pWarning ); |
|
157 |
+ |
if ( zSavedMsgShown ) { |
|
158 |
+ |
show(); |
|
159 |
+ |
} |
|
160 |
+ |
} |
|
161 |
+ |
} |
|
162 |
+ |
|
|
163 |
+ |
public void clearErrorOrWarning() { |
|
164 |
+ |
mCurStyle = STYLE_NONE; |
|
165 |
+ |
hide(); |
|
166 |
+ |
mIndicatorBar.hide(); |
|
167 |
+ |
DOM.setElementAttribute( mIndicatorBar.getElement(), "title", "" ); |
|
168 |
+ |
mIndicatorBar.setDefaultArrowDisplay(); |
|
169 |
+ |
mErrorPopUpLabel.setText( "" ); |
|
170 |
+ |
mMsgShown = false; |
|
171 |
+ |
} |
|
172 |
+ |
|
|
173 |
+ |
public MessageIndicatorBar getIndicatorBar() { |
|
174 |
+ |
return mIndicatorBar; |
|
175 |
+ |
} |
|
176 |
+ |
|
|
177 |
+ |
public void reposition() { |
|
178 |
+ |
if ( mMsgShown ) { |
|
179 |
+ |
hide(); |
|
180 |
+ |
show(); |
|
181 |
+ |
} |
|
182 |
+ |
} |
|
183 |
+ |
|
|
184 |
+ |
public void hide() { |
|
185 |
+ |
CommonElementHelper.hide( getElement() ); |
|
186 |
+ |
mMsgShown = false; |
|
187 |
+ |
} |
|
188 |
+ |
|
|
189 |
+ |
public void show() { |
|
190 |
+ |
position(); |
|
191 |
+ |
|
|
192 |
+ |
CommonElementHelper.unhide( getElement() ); |
|
193 |
+ |
mMsgShown = true; |
|
194 |
+ |
} |
|
195 |
+ |
|
|
196 |
+ |
protected void position() { |
|
197 |
+ |
int zOffsetToBottom = mIndicatorBar.getOffsetHeight(); |
|
198 |
+ |
getElement().getStyle().setBottom( zOffsetToBottom, Style.Unit.PX ); |
|
199 |
+ |
} |
|
200 |
+ |
|
|
201 |
+ |
public void setWarningStyle() { |
|
202 |
+ |
removeStyleName( CLASS_POP_UP_PANEL_ERROR ); |
|
203 |
+ |
addStyleName( CLASS_POP_UP_PANEL_WARNING ); |
|
204 |
+ |
} |
|
205 |
+ |
|
|
206 |
+ |
public void setErrorStyle() { |
|
207 |
+ |
removeStyleName( CLASS_POP_UP_PANEL_WARNING ); |
|
208 |
+ |
addStyleName( CLASS_POP_UP_PANEL_ERROR ); |
|
209 |
+ |
} |
|
210 |
+ |
} |
|
211 |
+ |
|
|
212 |
+ |
public static class MessageIndicatorBar extends SizeableHorizontalPanel { |
|
213 |
+ |
private static final String CLASS_ERROR_BAR = "litesoft-FormErrorBar"; |
|
214 |
+ |
private static final String CLASS_ERROR_BAR_REGULAR = "litesoft-FormErrorBar_regular"; |
|
215 |
+ |
private static final String CLASS_ERROR_BAR_MOUSEOVER = "litesoft-FormErrorBar_mouseover"; |
|
216 |
+ |
|
|
217 |
+ |
private static final String CLASS_WARNING_BAR = "litesoft-FormWarningBar"; |
|
218 |
+ |
private static final String CLASS_WARNING_BAR_REGULAR = "litesoft-FormWarningBar_regular"; |
|
219 |
+ |
private static final String CLASS_WARNING_BAR_MOUSEOVER = "litesoft-FormWarningBar_mouseover"; |
|
220 |
+ |
|
|
221 |
+ |
private static final String CLASS_BUTTON_BG = "litesoft-FormMsgBarButtonBg"; |
|
222 |
+ |
|
|
223 |
+ |
private static final String ARROW_UP = "common/images/formcomponents/uparrow_wht.gif"; |
|
224 |
+ |
private static final String ARROW_DOWN = "common/images/formcomponents/downarrow_wht.gif"; |
|
225 |
+ |
|
|
226 |
+ |
private boolean mArrowUp = true; |
|
227 |
+ |
private Image mArrowWidget = new Image( ARROW_UP ); // CLASS_BUTTON_BG |
|
228 |
+ |
|
|
229 |
+ |
public MessageIndicatorBar() { |
|
230 |
+ |
super( true, CLASS_ERROR_BAR ); |
|
231 |
+ |
|
|
232 |
+ |
addStyleName( CLASS_ERROR_BAR_REGULAR ); |
|
233 |
+ |
|
|
234 |
+ |
sinkEvents( Event.MOUSEEVENTS ); |
|
235 |
+ |
stretchableHorizontally(); |
|
236 |
+ |
|
|
237 |
+ |
add( new SizeableSpacer().stretchableHorizontally() ); |
|
238 |
+ |
add( mArrowWidget ); |
|
239 |
+ |
add( new SizeableSpacer().stretchableHorizontally() ); |
|
240 |
+ |
|
|
241 |
+ |
Element zArrowTD = DOM.getParent( mArrowWidget.getElement() ); |
|
242 |
+ |
CommonElementHelper.setStyleClass( zArrowTD, CLASS_BUTTON_BG ); |
|
243 |
+ |
hide(); |
|
244 |
+ |
} |
|
245 |
+ |
|
|
246 |
+ |
@Override |
|
247 |
+ |
public void setVisible( boolean visible ) { |
|
248 |
+ |
throw new IllegalStateException( "Not Supported" ); |
|
249 |
+ |
} |
|
250 |
+ |
|
|
251 |
+ |
public void show() { |
|
252 |
+ |
CommonElementHelper.unhide( getElement() ); |
|
253 |
+ |
} |
|
254 |
+ |
|
|
255 |
+ |
public void hide() { |
|
256 |
+ |
CommonElementHelper.hide( getElement() ); |
|
257 |
+ |
} |
|
258 |
+ |
|
|
259 |
+ |
public void setErrorStyle( String pError ) { |
|
260 |
+ |
DOM.setElementAttribute( getElement(), "title", pError ); |
|
261 |
+ |
removeStyleName( CLASS_WARNING_BAR ); |
|
262 |
+ |
removeStyleName( CLASS_WARNING_BAR_REGULAR ); |
|
263 |
+ |
addStyleName( CLASS_ERROR_BAR ); |
|
264 |
+ |
addStyleName( CLASS_ERROR_BAR_REGULAR ); |
|
265 |
+ |
|
|
266 |
+ |
show(); |
|
267 |
+ |
} |
|
268 |
+ |
|
|
269 |
+ |
public void setWarningStyle( String pWarning ) { |
|
270 |
+ |
DOM.setElementAttribute( getElement(), "title", pWarning ); |
|
271 |
+ |
removeStyleName( CLASS_ERROR_BAR ); |
|
272 |
+ |
removeStyleName( CLASS_ERROR_BAR_REGULAR ); |
|
273 |
+ |
addStyleName( CLASS_WARNING_BAR ); |
|
274 |
+ |
addStyleName( CLASS_WARNING_BAR_REGULAR ); |
|
275 |
+ |
|
|
276 |
+ |
// mArrowWidget.setStyleName( CLASS_BUTTON_BG_WARNING ); |
|
277 |
+ |
|
|
278 |
+ |
show(); |
|
279 |
+ |
} |
|
280 |
+ |
|
|
281 |
+ |
public void updateArrowDisplay() { |
|
282 |
+ |
mArrowWidget.setUrl( (mArrowUp = !mArrowUp) ? ARROW_UP : ARROW_DOWN ); |
|
283 |
+ |
} |
|
284 |
+ |
|
|
285 |
+ |
public void setDefaultArrowDisplay() { |
|
286 |
+ |
if ( !mArrowUp ) { |
|
287 |
+ |
updateArrowDisplay(); |
|
288 |
+ |
} |
|
289 |
+ |
} |
|
290 |
+ |
|
|
291 |
+ |
private void setMouseoverStyle() { |
|
292 |
+ |
String styleClasses = getStyleName(); |
|
293 |
+ |
|
|
294 |
+ |
if ( styleClasses.indexOf( CLASS_ERROR_BAR ) > 0 ) { |
|
295 |
+ |
removeStyleName( CLASS_ERROR_BAR_REGULAR ); |
|
296 |
+ |
addStyleName( CLASS_ERROR_BAR_MOUSEOVER ); |
|
297 |
+ |
} |
|
298 |
+ |
|
|
299 |
+ |
if ( styleClasses.indexOf( CLASS_WARNING_BAR ) > 0 ) { |
|
300 |
+ |
removeStyleName( CLASS_WARNING_BAR_REGULAR ); |
|
301 |
+ |
addStyleName( CLASS_WARNING_BAR_MOUSEOVER ); |
|
302 |
+ |
} |
|
303 |
+ |
} |
|
304 |
+ |
|
|
305 |
+ |
private void setMouseoutStyle() { |
|
306 |
+ |
String styleClasses = getStyleName(); |
|
307 |
+ |
|
|
308 |
+ |
if ( styleClasses.indexOf( CLASS_ERROR_BAR ) > 0 ) { |
|
309 |
+ |
removeStyleName( CLASS_ERROR_BAR_MOUSEOVER ); |
|
310 |
+ |
addStyleName( CLASS_ERROR_BAR_REGULAR ); |
|
311 |
+ |
} |
|
312 |
+ |
|
|
313 |
+ |
if ( styleClasses.indexOf( CLASS_WARNING_BAR ) > 0 ) { |
|
314 |
+ |
removeStyleName( CLASS_WARNING_BAR_MOUSEOVER ); |
|
315 |
+ |
addStyleName( CLASS_WARNING_BAR_REGULAR ); |
|
316 |
+ |
} |
|
317 |
+ |
} |
|
318 |
+ |
|
|
319 |
+ |
public void addClickListener( ClickListener pListener ) { |
|
320 |
+ |
if ( pListener != null ) { |
|
321 |
+ |
if ( mClickListeners == null ) { |
|
322 |
+ |
mClickListeners = new ClickListenerCollection(); |
|
323 |
+ |
} |
|
324 |
+ |
//noinspection unchecked |
|
325 |
+ |
mClickListeners.add( pListener ); |
|
326 |
+ |
} |
|
327 |
+ |
} |
|
328 |
+ |
|
|
329 |
+ |
private ClickListenerCollection mClickListeners = null; |
|
330 |
+ |
|
|
331 |
+ |
@Override |
|
332 |
+ |
public void onBrowserEvent( Event event ) { |
|
333 |
+ |
switch ( DOM.eventGetType( event ) ) { |
|
334 |
+ |
case Event.ONMOUSEDOWN: { |
|
335 |
+ |
if ( mClickListeners != null ) { |
|
336 |
+ |
mClickListeners.fireClick( this ); |
|
337 |
+ |
} |
|
338 |
+ |
break; |
|
339 |
+ |
} |
|
340 |
+ |
case Event.ONMOUSEOVER: |
|
341 |
+ |
setMouseoverStyle(); |
|
342 |
+ |
break; |
|
343 |
+ |
case Event.ONMOUSEOUT: |
|
344 |
+ |
setMouseoutStyle(); |
|
345 |
+ |
break; |
|
346 |
+ |
} |
|
347 |
+ |
} |
|
348 |
+ |
} |
|
349 |
+ |
} |