litesoft
@ 948
litesoft / trunk / GWT_Sandbox / MultiModule / common / src / org / litesoft / sandbox / infrastructure / client / widgets / OurLabel.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 52 53 54 55 |
package org.litesoft.sandbox.infrastructure.client.widgets; import org.litesoft.sandbox.infrastructure.client.*; import com.google.gwt.safehtml.shared.*; import com.google.gwt.user.client.ui.*; /** * A Label that ALWAYS contains something and preserves spaces and escapes all HTML. * <p/> * Note: while it extends an HTML widget, you may NOT set the HTML, only the text! */ public class OurLabel extends HTML implements StyledSafeTextSink { public OurLabel() { this( null ); } public OurLabel( String text ) { setText( text ); } @Override public void setText( String text ) { super.setHTML( SafeHtmlizer.getInstance().noEmpty1stLine( text ).asString() ); } @Override public void setText( String text, Direction dir ) { super.setHTML( SafeHtmlizer.getInstance().noEmpty1stLine( text ), dir ); } @Override public void setHTML( String html ) { unsupported(); } @Override public void setHTML( String html, Direction dir ) { unsupported(); } @Override public void setHTML( SafeHtml html ) { unsupported(); } @Override public void setHTML( SafeHtml html, Direction dir ) { unsupported(); } private void unsupported() { throw new UnsupportedOperationException( "setting HTML directly NOT support on OurLabel - use setText()" ); } } |