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

import com.google.gwt.core.client.*;
import com.google.gwt.dom.client.*;
import com.google.gwt.event.dom.client.*;
import com.google.gwt.uibinder.client.*;
import com.google.gwt.user.client.*;
import com.google.gwt.user.client.ui.*;
import com.temp.shared.utils.*;

public class HelpWidget extends Composite implements IsWidget
{
    interface HelpWidgetUIBinder extends UiBinder<Widget, HelpWidget>
    {
    }

    @UiField Image helpImage;

    private String section = "";
    private String context = "";

    private static HelpWidgetUIBinder uiBinder = GWT.create( HelpWidgetUIBinder.class );

    public HelpWidget()
    {
        initWidget( uiBinder.createAndBindUi( this ) );
        helpImage.getElement().getStyle().setVisibility( Style.Visibility.HIDDEN );
    }

    public void setSection( String section )
    {
        this.section = StringUtils.deNull( section ).trim();
    }

    public void setContext( String context )
    {
        this.context = StringUtils.deNull( context ).trim();
    }

    public void setSectionAndContext( String sectionAndContext )
    {
        sectionAndContext = StringUtils.deNull( sectionAndContext ).trim();
        int hashAt = sectionAndContext.indexOf( '#' );
        if ( hashAt == -1 )
        {
            setSection( sectionAndContext );
            setContext( null );
        }
        else
        {
            setSection( sectionAndContext.substring( 0, hashAt ) );
            setContext( sectionAndContext.substring( hashAt + 1 ) );
        }
    }

    public HelpWidget link( String sectionAndContext )
    {
        setSectionAndContext( sectionAndContext );
        return this;
    }

    // <g:Anchor tabIndex='-1' ui:field = 'helpurl' href='' text="?" target='simple EDI - help'/>
    @Override protected void onAttach()
    {
        super.onAttach();
        if ( section.length() != 0 )
        {
            helpImage.setTitle( "Display Help for: " + section + " " + context );
            helpImage.addClickHandler( new ClickHandler()
            {
                @Override public void onClick( ClickEvent event )
                {
                    Window.open( "http://simpleedi.amazon.com/help/" + section + ".html#" + context, "simple EDI - help", "" );
                }
            } );
            helpImage.getElement().getStyle().setVisibility( Style.Visibility.VISIBLE );
        }
    }
}

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

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

Sync-n