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
package com.temp.foundation.client.widget;

import com.google.gwt.event.dom.client.*;
import com.google.gwt.user.client.ui.*;

public class NamedIconButton extends CompositeButton<NamedIconButton> {
    public NamedIconButton() {
    }

    public NamedIconButton( String name ) {
        this();
        setName( name );
    }

    public NamedIconButton( String name, ClickHandler handler ) {
        this( name );
        add( handler );
    }

    @Override
    public void setName( String name ) {
        super.setName( name );
        proxyTo.getUpFace().setImage( new Image( getImageUrl( getName() ) ) );
    }

    public NamedIconButton add( ClickHandler handler ) {
        if ( handler != null ) {
            proxyTo.addClickHandler( handler );
        }
        return this;
    }

    private static String getImageUrl( String name ) {
        return "images/icons/" + name + ".png";
    }

    public static String createSafeHtmlElement( String name, String safeHtmlAltToolTip ) {
        return createSafeHtmlElementWithIdAndStyle( null, name, safeHtmlAltToolTip, null );
    }

    public static String createSafeHtmlElementWithId( String id, String name, String safeHtmlAltToolTip ) {
        return createSafeHtmlElementWithIdAndStyle( id, name, safeHtmlAltToolTip, null );
    }

    public static String createSafeHtmlElement( String name, String safeHtmlAltToolTip, String styleName ) {
        return createSafeHtmlElementWithIdAndStyle( null, name, safeHtmlAltToolTip, styleName );
    }

    public static String createSafeHtmlElementWithId( String id, String name, String safeHtmlAltToolTip, String styleName ) {
        return createSafeHtmlElementWithIdAndStyle( id, name, safeHtmlAltToolTip, styleName );
    }

    private static String createSafeHtmlElementWithIdAndStyle( String id, String name, String safeHtmlAltToolTip, String styleName ) {
        return createSafeHtmlElementWithImageUrl( id, safeHtmlAltToolTip, styleName, getImageUrl( name ) );
    }
}

Commits for litesoft/trunk/GWT_Sandbox/FormEngine/src/com/temp/foundation/client/widget/NamedIconButton.java

Diff revisions: vs.
Revision Author Commited Message
965 GeorgeS picture GeorgeS Fri 01 Aug, 2014 03:20:35 +0000

!