Subversion Repository Public Repository

litesoft

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.GWT.client.widgets;

import org.litesoft.GWT.client.util.*;

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 NeverEmptyHtmlEscapingLabel extends HTML implements StyledSafeTextSink {
    public NeverEmptyHtmlEscapingLabel() {
        this( null );
    }

    public NeverEmptyHtmlEscapingLabel( 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 supported on OurLabel - use setText()" );
    }
}

Commits for litesoft/trunk/Java/GWT/Client/src/org/litesoft/GWT/client/widgets/NeverEmptyHtmlEscapingLabel.java

Diff revisions: vs.
Revision Author Commited Message
950 Diff Diff GeorgeS picture GeorgeS Thu 19 Jun, 2014 17:57:04 +0000

New Lines

948 Diff Diff GeorgeS picture GeorgeS Sat 07 Jun, 2014 23:42:39 +0000

Jusefuls Formatter Updated to New Code Format

712 GeorgeS picture GeorgeS Sat 09 Jun, 2012 22:46:04 +0000

Move PAV stuff into LiteSoft