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

/**
 * The State of an InputField is the combination of the following boolean states:
 * <p/>
 * Changed
 * Errored
 * Focused
 */
public class StateInputField {
    public static final StateInputField BASE = new StateInputField( false, false, false );

    private boolean mChanged, mErrored, mFocused;

    private StateInputField( boolean pChanged, boolean pErrored, boolean pFocused ) {
        mChanged = pChanged;
        mErrored = pErrored;
        mFocused = pFocused;
    }

    public boolean isChanged() {
        return mChanged;
    }

    public boolean isErrored() {
        return mErrored;
    }

    public boolean isFocused() {
        return mFocused;
    }

    public StateInputField changed( boolean pChanged ) {
        return changeTo( pChanged, mErrored, mFocused );
    }

    public StateInputField errored( boolean pErrored ) {
        return changeTo( mChanged, pErrored, mFocused );
    }

    public StateInputField focused( boolean pFocused ) {
        return changeTo( mChanged, mErrored, pFocused );
    }

    private StateInputField changeTo( boolean pChanged, boolean pErrored, boolean pFocused ) {
        if ( (mChanged == pChanged) && (mErrored == pErrored) && (mFocused == pFocused) ) {
            return this;
        }
        return new StateInputField( pChanged, pErrored, pFocused );
    }

    @Override
    public boolean equals( Object o ) {
        return (this == o) || ((o instanceof StateInputField) && equals( (StateInputField) o ));
    }

    public boolean equals( StateInputField them ) {
        return (them != null) //
               && (this.mChanged == them.mChanged) //
               && (this.mErrored == them.mErrored) //
               && (this.mFocused == them.mFocused);
    }

    @Override
    public int hashCode() {
        int result = (mChanged ? 1 : 0);
        result = (result << 1) + (mErrored ? 1 : 0);
        result = (result << 1) + (mFocused ? 1 : 0);
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        add( sb, "Changed", mChanged );
        add( sb, "Errored", mErrored );
        add( sb, "Focused", mFocused );
        return sb.toString();
    }

    public String toCSS() {
        return "IF_Box" + this;
    }

    private void add( StringBuilder sb, String what, boolean flag ) {
        if ( flag ) {
            sb.append( what );
        }
    }
}

Commits for litesoft/trunk/GWT_Sandbox/FormEngine/src/com/temp/client/foundation/widget/input/fieldsupport/StateInputField.java

Diff revisions: vs.
Revision Author Commited Message
948 Diff Diff GeorgeS picture GeorgeS Sat 07 Jun, 2014 23:42:39 +0000

Jusefuls Formatter Updated to New Code Format

629 Diff Diff GeorgeS picture GeorgeS Tue 17 Apr, 2012 05:47:55 +0000
626 GeorgeS picture GeorgeS Wed 11 Apr, 2012 19:39:41 +0000