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
// This Source Code is in the Public Domain per: http://unlicense.org
package org.litesoft.GWT.forms.client.components.impls.input;

import org.litesoft.GWT.client.widgets.*;
import org.litesoft.GWT.forms.client.components.nonpublic.*;
import org.litesoft.commonfoundation.typeutils.gregorian.*;
import org.litesoft.core.simpletypes.temporal.*;
import org.litesoft.core.simpletypes.temporal.nonpublic.*;
import org.litesoft.uispecification.*;

import java.util.*;

public class FormDatePicker extends AbstractTextFieldWithPicker {
    private DateFormat mDateFormat;
    private TemporalParser mTemporalParser;

    public FormDatePicker( String pFieldLabel, UiFont pLabelFont, String pTooltip, String pCancelText, String pTodayText, DateFormat pDateFormat ) {
        // 1234567-101
        // 04 JAN 1957
        super( pTooltip, true, pDateFormat.getFormat().length(), "Calendar", new MyPicker( pCancelText, pTodayText ) );
        initialize( pFieldLabel, pLabelFont, pTooltip );

        mDateFormat = pDateFormat;
        String zFieldOrder = pDateFormat.getFieldOrder();
        if ( zFieldOrder.equals( "dMy" ) && mDateFormat.getFormat().contains( "MMM" ) ) {
            zFieldOrder = "Mdy";
        }
        mTemporalParser = new TemporalParser( zFieldOrder );
    }

    @Override
    protected Object parseNotEmptyTextFieldToInternalForm( String pText, Object pLastValidInternalFormValue )
            throws IllegalArgumentException {
        UtilDateAdaptor zInadequatePartsSource =
                (pLastValidInternalFormValue instanceof CalendarYMD) ? ((CalendarYMD) pLastValidInternalFormValue).toUtilDateAdaptor() : null;
        return mTemporalParser.parseDate( pText, mDateFormat.getDateRes(), zInadequatePartsSource );
    }

    @Override
    protected void pickerClosed( boolean autoClosed ) {
        super.pickerClosed( autoClosed );
        Date value = getPicker().getExitValue();

        if ( value != null ) {
            setTextValueFromPicker( mDateFormat.format( new CalendarYMD( value ) ) );
        }
    }

    @Override
    protected void showPicker( int pAbsoluteLeft, int pAbsoluteTop, Object pCurrentValue, Object pLastValidInternalFormValue ) {
        Date zDate;
        if ( pCurrentValue instanceof CalendarYMD ) {
            zDate = ((CalendarYMD) pCurrentValue).toUtilDate();
        } else if ( pLastValidInternalFormValue instanceof CalendarYMD ) {
            zDate = ((CalendarYMD) pLastValidInternalFormValue).toUtilDate();
        } else {
            zDate = new Date();
        }
        getPicker().setFullDate( zDate );
        super.showPicker( pAbsoluteLeft, pAbsoluteTop, pCurrentValue, pLastValidInternalFormValue );
    }

    private MyPicker getPicker() {
        return (MyPicker) mPicker;
    }

    private static class MyPicker extends ExtendableDatePicker {
        private Date mExitValue = null;
        private Button mTodayButton;

        public MyPicker( String pCancelText, String pTodayText ) {
            addDialogButtonPanel( Button.named( pCancelText ).red().text().create(), //
                                  mTodayButton = Button.named( "Today" ).blue().text( pTodayText ).create() );
        }

        @Override
        protected void dialogButtonClicked( Button pButton ) {
            if ( mTodayButton == pButton ) {
                mExitValue = new Date();
            }
            hide();
        }

        public Date getExitValue() {
            return mExitValue;
        }

        @Override
        public void show() {
            mExitValue = null;
            super.show();
        }

        @Override
        protected void dateSelectedByClick( Date pDate ) {
            mExitValue = selectedDate();
            hide();
        }
    }
}

Commits for litesoft/trunk/Java/GWT/Client/src/org/litesoft/GWT/forms/client/components/impls/input/FormDatePicker.java

Diff revisions: vs.
Revision Author Commited Message
950 Diff Diff GeorgeS picture GeorgeS Thu 19 Jun, 2014 17:57:04 +0000

New Lines

948 Diff Diff GeorgeS picture GeorgeS Sat 07 Jun, 2014 23:42:39 +0000

Jusefuls Formatter Updated to New Code Format

947 Diff Diff GeorgeS picture GeorgeS Fri 06 Jun, 2014 23:36:56 +0000

Correct Spelling of package!

942 Diff Diff GeorgeS picture GeorgeS Mon 02 Jun, 2014 23:41:46 +0000

Extracting commonfoundation

862 Diff Diff GeorgeS picture GeorgeS Thu 15 Nov, 2012 02:23:36 +0000

On the Way...

860 Diff Diff GeorgeS picture GeorgeS Mon 05 Nov, 2012 01:39:02 +0000
853 Diff Diff GeorgeS picture GeorgeS Sun 04 Nov, 2012 15:18:21 +0000
851 Diff Diff GeorgeS picture GeorgeS Mon 08 Oct, 2012 00:05:32 +0000

Breaking the code as Temporal changes are implemented...

142 Diff Diff GeorgeS picture GeorgeS Sun 13 Mar, 2011 23:01:57 +0000
141 GeorgeS picture GeorgeS Sun 13 Mar, 2011 21:13:37 +0000