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