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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt
package org.litesoft.GWT.client.widgets;

import java.util.*;

import org.litesoft.GWT.client.command.*;
import org.litesoft.GWT.client.widgets.nonpublic.*;
import org.litesoft.core.typeutils.*;
import org.litesoft.core.typeutils.Objects;
import org.litesoft.uispecification.*;

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

public abstract class DefButtonNamedTypedFactory
{
    public enum BasicForm
    {
        Text, Image
    }

    public enum Form
    {
        Text( BasicForm.Text ), BigText( BasicForm.Text ), Icon( BasicForm.Image ), Picker( BasicForm.Image );

        private BasicForm mBasicForm;

        Form( BasicForm pBasicForm )
        {
            mBasicForm = pBasicForm;
        }

        public BasicForm getBasicForm()
        {
            return mBasicForm;
        }
    }

    protected final DefButtonNamedTyped mTyped;
    private final Form mForm;
    private String mCustomStyle, mEnabledToolTip, mDisabledToolTip; // initialized to null
    private boolean mDisabled = false;
    private List<ClickHandler> mClickHandlers;

    protected DefButtonNamedTypedFactory( DefButtonNamedTyped pTyped, Form pForm )
    {
        Objects.assertNotNull( "Typed", mTyped = pTyped );
        Objects.assertNotNull( "Form", mForm = pForm );
    }

    public final String getName()
    {
        return mTyped.getName();
    }

    public String getSize()
    {
        return mTyped.getSize();
    }

    public final String getType()
    {
        return mTyped.getType();
    }

    public final Form getForm()
    {
        return mForm;
    }

    public final boolean isDisabled()
    {
        return mDisabled;
    }

    public final String getEnabledToolTip()
    {
        return mEnabledToolTip;
    }

    public final String getDisabledToolTip()
    {
        return mDisabledToolTip;
    }

    public final List<ClickHandler> getClickHandlers()
    {
        return (mClickHandlers != null) ? mClickHandlers : Collections.<ClickHandler>emptyList();
    }

    public final DefButtonNamedTypedFactory disabled()
    {
        mDisabled = true;
        return this;
    }

    public final DefButtonNamedTypedFactory add( ClickHandler pClickHandler )
    {
        if ( pClickHandler != null )
        {
            if ( mClickHandlers == null )
            {
                mClickHandlers = new ArrayList<ClickHandler>();
            }
            mClickHandlers.add( pClickHandler );
        }
        return this;
    }

    public final DefButtonNamedTypedFactory add( CommandHandlerAdaptor pAdaptor )
    {
        return add( (ClickHandler) pAdaptor );
    }

    public final DefButtonNamedTypedFactory add( Command pCommand )
    {
        return (pCommand == null) ? this : add( new ClickHandlerCommandAdaptor( pCommand ) );
    }

    public final DefButtonNamedTypedFactory add( ViewDef pTarget )
    {
        Objects.assertNotNull( "Target (ViewDef)", pTarget );
        return add( new ShowScreenCommand( pTarget ) );
    }

    public final DefButtonNamedTypedFactory add( ViewDef pTarget, UriFragmentIdParams pParams )
    {
        Objects.assertNotNull( "Target (ViewDef)", pTarget );
        return add( new ShowScreenCommand( pTarget, pParams ) );
    }

    public final DefButtonNamedTypedFactory add( final ViewDef pTarget, final UriFragmentIdParams.ScreenParamsFactory pFactory )
    {
        Objects.assertNotNull( "Target (ViewDef)", pTarget );
        Objects.assertNotNull( "Factory", pFactory );
        return add( new ClickHandler()
        {
            @Override
            public void onClick( ClickEvent event )
            {
                new ShowScreenCommand( pTarget, pFactory.create( pTarget ) ).execute();
            }
        } );
    }

    public String getCustomStyle()
    {
        return mCustomStyle;
    }

    public DefButtonNamedTypedFactory customStyle( String pCustomStyle )
    {
        mCustomStyle = Strings.noEmpty( pCustomStyle );
        return this;
    }

    public final DefButtonNamedTypedFactory enabledToolTip( String pEnabledToolTip )
    {
        mEnabledToolTip = Strings.noEmpty( pEnabledToolTip );
        return this;
    }

    public final DefButtonNamedTypedFactory disabledToolTip( String pDisabledToolTip )
    {
        mDisabledToolTip = (pDisabledToolTip == null) ? null : pDisabledToolTip.trim();
        return this;
    }

    public final Button create()
    {
        Button zButton = ButtonFactoryFactory.getFactory().create( this );
        for ( ClickHandler zHandler : getClickHandlers() )
        {
            zButton.addClickHandler( zHandler );
        }
        return zButton;
    }

    protected abstract String getFormDescription();

    @Override
    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        sb.append( getType() ).append( "( " ).append( getName() ).append( " )" );
        if ( mDisabled )
        {
            sb.append( " Disabled" );
        }
        if ( mCustomStyle != null )
        {
            sb.append( " + " ).append( mCustomStyle );
        }
        sb.append( ": " ).append( mForm ).append( getFormDescription() );
        if ( (mEnabledToolTip != null) || (mDisabledToolTip != null) )
        {
            if ( mDisabledToolTip == null )
            {
                sb.append( "\n    ToolTip: " ).append( mEnabledToolTip );
            }
            else
            {
                if ( mEnabledToolTip != null )
                {
                    sb.append( "\n    Enabled  ToolTip: " ).append( mEnabledToolTip );
                }
                if ( mDisabledToolTip != null )
                {
                    if ( mDisabledToolTip.length() == 0 )
                    {
                        sb.append( "\n    No Disabled ToolTip" );
                    }
                    else
                    {
                        sb.append( "\n    Disabled ToolTip: " ).append( mDisabledToolTip );
                    }
                }
            }
        }
        return sb.toString();
    }
}

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

Diff revisions: vs.
Revision Author Commited Message
917 Diff Diff GeorgeS picture GeorgeS Sun 08 Dec, 2013 20:49:56 +0000

1.7 prep & VersionedStaticContentFilter upgrade to new “/ver” model!

804 Diff Diff GeorgeS picture GeorgeS Wed 15 Aug, 2012 12:48:51 +0000
801 Diff Diff GeorgeS picture GeorgeS Wed 15 Aug, 2012 03:59:02 +0000
144 Diff Diff GeorgeS picture GeorgeS Mon 14 Mar, 2011 03:42:34 +0000
142 Diff Diff GeorgeS picture GeorgeS Sun 13 Mar, 2011 23:01:57 +0000
140 Diff Diff GeorgeS picture GeorgeS Sun 13 Mar, 2011 20:50:57 +0000
137 Diff Diff GeorgeS picture GeorgeS Thu 10 Mar, 2011 15:22:37 +0000
133 Diff Diff GeorgeS picture GeorgeS Wed 09 Mar, 2011 00:33:28 +0000
125 Diff Diff GeorgeS picture GeorgeS Sun 06 Mar, 2011 22:45:45 +0000
123 GeorgeS picture GeorgeS Sat 05 Mar, 2011 01:35:24 +0000