litesoft
@ 965
litesoft / trunk / GWT_Sandbox / FormEngine / src / com / temp / foundation / client / widget / WrappingNamedLabel.java
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 |
package com.temp.foundation.client.widget; import com.temp.common.shared.utils.*; public class WrappingNamedLabel extends NamedLabel { private static final int MINIMUM_MAX_LINE_CHARACTER_LENGTH = 5; private Integer maxLineCharacterLength; public WrappingNamedLabel() { } public WrappingNamedLabel( int maxLineCharacterLength, String text ) { setMaxLineCharacterLength( maxLineCharacterLength ); setText( text ); } public WrappingNamedLabel style( String className ) { addStyleName( className ); return this; } public WrappingNamedLabel wrapAfter( int maxLineCharacterLength ) { setMaxLineCharacterLength( maxLineCharacterLength ); return this; } public void setMaxLineCharacterLength( Integer maxLineCharacterLength ) { if ( (maxLineCharacterLength != null) && (maxLineCharacterLength < MINIMUM_MAX_LINE_CHARACTER_LENGTH) ) { throw new IllegalArgumentException( "maxLineCharacterLength too small" ); } this.maxLineCharacterLength = maxLineCharacterLength; } public Integer getMaxLineCharacterLength() { return maxLineCharacterLength; } @Override public void setText( String text, Direction dir ) { throw new UnsupportedOperationException(); } @Override public void setText( String text ) { String adjustedText = StringUtils.wrap( text, maxLineCharacterLength ); String html = SafeHtmlizer.getInstance().noEmpty( adjustedText ); getElement().setInnerHTML( html ); } } |
Commits for litesoft/trunk/GWT_Sandbox/FormEngine/src/com/temp/foundation/client/widget/WrappingNamedLabel.java
Revision | Author | Commited | Message |
---|---|---|---|
965 | GeorgeS | Fri 01 Aug, 2014 03:20:35 +0000 | ! |