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
package org.litesoft.datt.client.ui.views;

import org.litesoft.GWT.client.*;
import org.litesoft.GWT.client.view.*;
import org.litesoft.GWT.client.widgets.*;
import org.litesoft.GWT.forms.client.*;
import org.litesoft.bo.views.*;
import org.litesoft.core.util.*;
import org.litesoft.datt.client.boviews.*;

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

public class NewUserEmailDialog extends AbstractNewUserDialog implements NewUserPhoneConfirmationDialog.CallBack
{
    public interface CallBack extends DialogCloseCallBack
    {
        public void succeeded( String pLogonEmail, UserView pUserView );
    }

    private CallBack mCallBack;

    public NewUserEmailDialog( String pLogonEmail, String pPhoneNumber, CallBack pCallBack )
    {
        super( pLogonEmail, pPhoneNumber, null );
        UtilsCommon.assertNotNull( "CallBack", mCallBack = pCallBack );

        setViewTitle( "New User" );

        add( new SizeableSpacer( 5 ).stretchable() );
        add( createLogonEmail() );
        add( new SizeableSpacer( 5 ).stretchable() );
    }

    @Override
    public void aboutToShow()
    {
        super.aboutToShow();
        mFE.initialize();
        mFE.setNamedComponentValueAsUser( UserViewNames.aLogonEmail, mLogonEmail );
    }

    private Widget createLogonEmail()
    {
        FormBinder<UserView> zFormBinder = new FormBinder<UserView>( mFE, UserViewMetaData.getInstance() );

        return zFormBinder.add( UserViewNames.aLogonEmail );
    }

    @Override
    protected void submitRequested()
    {
        String zLogonEmail = UtilsCommon.noEmpty( (String) mFE.getNamedComponentValue( UserView.aLogonEmail ) );

        if ( zLogonEmail != null )
        {
            mDataProvider.validateLogonEmailAvailable( zLogonEmail, new FetchRowDataProviderCallBack<UserView>()
            {
                @Override
                public void error( String pError )
                {
                    setDialogErrorMessage( pError );
                }

                @Override
                public void success( UserView pRow )
                {
                    if ( pRow == null ) // No row found, Go on to Add User
                    {
                        close();
                        mCallBack.succeeded( (String) mFE.getNamedComponentValue( UserViewNames.aLogonEmail ), null );
                        return;
                    }
                    if ( mPhoneNumber.equals( pRow.getPhoneNumber() ) )  // User found with same Logon & same entered PhoneNumber: Go on to Add User
                    {
                        close();
                        mCallBack.succeeded( (String) mFE.getNamedComponentValue( UserViewNames.aLogonEmail ), pRow );
                        return;
                    }
                    mUserView = pRow;
                    new DialogViewDialog( new NewUserPhoneConfirmationDialog( mLogonEmail, mPhoneNumber, pRow, NewUserEmailDialog.this ) ).show();
                }
            } );
        }
    }

    @Override
    public void succeeded()
    {
        close();
        mCallBack.succeeded( (String) mFE.getNamedComponentValue( UserViewNames.aLogonEmail ), mUserView );
    }

    @Override
    public void cancel()
    {
        super.cancel();
        mCallBack.dialogClosed();
    }

    protected static String cursoryEmailCheck( String pEmail, String pWhat )
    {
        try
        {
            new EmailAddress( pEmail );
            return null;
        }
        catch ( IllegalArgumentException e )
        {
            return DeCamelizer.resolve( pWhat ) + " is unacceptable: " + e.getMessage();
        }
    }
}

Commits for litesoft/trunk/Java/DATT/src/org/litesoft/datt/client/ui/views/NewUserEmailDialog.java

Diff revisions: vs.
Revision Author Commited Message
430 GeorgeS picture GeorgeS Sat 20 Aug, 2011 19:46:21 +0000