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

import com.google.gwt.safehtml.shared.*;
import com.google.gwt.user.client.*;
import com.google.gwt.user.client.ui.*;
import com.sun.istack.internal.*;

public class SpanPanel extends ComplexPanel
{
    /**
     * Creates an HTML panel based on a span.
     */
    public SpanPanel()
    {
        setElement( DOM.createSpan() );
    }

    /**
     * Creates an HTML panel with the specified HTML contents inside a span element.
     *
     * @param html the panel's HTML
     */
    public SpanPanel( @Nullable String html )
    {
        this();
        /*
        * Normally would call this("div", html), but that method
        * has some slightly expensive IE defensiveness that we just
        * don't need for a div
        */
        getElement().setInnerHTML( html );
    }

    /**
     * Initializes the panel's HTML from a given {@link SafeHtml} object.
     *
     * @param safeHtml the html to set.
     */
    public SpanPanel( @NotNull SafeHtml safeHtml )
    {
        this( safeHtml.asString() );
    }

    /**
     * Adds a child element to the panel.
     *
     * @param elem the element to add
     */
    public void add( @Nullable com.google.gwt.dom.client.Element elem )
    {
        if ( elem != null )
        {
            getElement().appendChild( elem );
        }
    }

    /**
     * Adds a child widget to the panel.
     *
     * @param widget the widget to be added
     */
    @Override
    public void add( @Nullable Widget widget )
    {
        if ( widget != null )
        {
            add( widget, getElement() );
        }
    }
}

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

Diff revisions: vs.
Revision Author Commited Message
751 GeorgeS picture GeorgeS Sat 07 Jul, 2012 18:21:49 +0000