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
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
package com.temp.foundation.widgets.support;

import com.google.gwt.user.client.ui.*;
import com.temp.shared.utils.*;

public abstract class TextLabel extends Composite implements HasName
{
    protected final HTML htmlWidget = new HTML( HtmlUtils.NBSP );
    private String text = null;
    private String name;

    public final String getText()
    {
        return text;
    }

    public final void setText( String text )
    {
        commonSetText( StringUtils.noEmpty( text ) );
    }

    @Override
    public void setName( String name )
    {
        this.name = StringUtils.noEmpty( name );
    }

    @Override
    public String getName()
    {
        return name;
    }

    @Override
    public String toString()
    {
        return ObjectUtils.simpleClassName( this ) + ": '" + getText() + "'";
    }

    public final void setTextNoTrim( String text )
    {
        commonSetText( "".equals( text ) ? null : text );
    }

    public final TextLabel text( String text )
    {
        setText( text );
        return this;
    }

    public final TextLabel textNoTrim( String text )
    {
        setTextNoTrim( text );
        return this;
    }

    public final TextLabel style( String className )
    {
        className = StringUtils.noEmpty( className );
        if ( className != null )
        {
            addStyleName( className );
        }
        return this;
    }

    protected final void commonSetText( String text )
    {
        this.text = text;
        String html = StringUtils.deNull( (text == null) ? HtmlUtils.NBSP : StringUtils.noEmpty( normalizeHTML( text ) ), HtmlUtils.NBSP );
        htmlWidget.setHTML( html );
    }

    @Override
    protected void initWidget( Widget widget )
    {
        super.initWidget( widget );
        setStyleName( ObjectUtils.simpleClassName( this ) );
    }

    /**
     * @param text will NOT be null or have any leading/trailing whitespace
     *
     * @return Html Safe Text
     */
    protected abstract String normalizeHTML( String text );
}

Commits for litesoft/trunk/GWT_Sandbox/FormEngine/src/com/temp/foundation/widgets/support/TextLabel.java

Diff revisions: vs.
Revision Author Commited Message
600 GeorgeS picture GeorgeS Sun 05 Feb, 2012 18:55:58 +0000

Sync-n