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
package org.litesoft.sandbox.infrastructure.client.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.*;

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 HelpWidget( String section, String context )
    {
        this();
        setSection( section );
        setContext( context );
    }

    public void setSection( String section )
    {
        this.section = (section == null) ? "" : section.trim(); // default trimmed
    }

    public void setContext( String context )
    {
        this.context = (context == null) ? "" : context.trim();
    }

    // <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://litesoft.org/help/" + section + ".html#" + context, "help", "" );
                }
            } );
            helpImage.getElement().getStyle().setVisibility( Style.Visibility.VISIBLE );
        }
    }
}

Commits for litesoft/trunk/GWT_Sandbox/MultiModule/common/src/org/litesoft/sandbox/infrastructure/client/widgets/HelpWidget.java

Diff revisions: vs.
Revision Author Commited Message
551 Diff Diff GeorgeS picture GeorgeS Tue 11 Oct, 2011 03:28:49 +0000
540 GeorgeS picture GeorgeS Mon 03 Oct, 2011 04:22:28 +0000