litesoft
@ 950
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 |
// 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 FormTimestampPicker extends AbstractTextFieldWithPicker { public FormTimestampPicker( String pFieldLabel, UiFont pLabelFont, String pTooltip, TimeRes pTimeRes, String pCancelText, String pOKText ) { super( pTooltip, false, calcLength( pTimeRes ), "CalendarTime", new MyPicker( pCancelText, pOKText, deNull( pTimeRes ) ) ); initialize( pFieldLabel, pLabelFont, pTooltip ); } private static TimeRes deNull( TimeRes pTimeRes ) { return (pTimeRes != null) ? pTimeRes : TimeRes.ToMSEC; } private static int calcLength( TimeRes pTimeRes ) { switch ( deNull( pTimeRes ).getIndex() ) { default: case TimeRes.MSECindex: // 1957/01/04 13:32:59.999 return 23; // .........1234567-101234567-20123 case TimeRes.SECindex: //. 1957/01/04 13:32:59 return 19; // .........1234567-10123456789 case TimeRes.MINindex: //. 1957/01/04 13:32 return 16; // .........1234567-10123456 case TimeRes.HOURindex: // 1957/01/04 13 return 13; // .........1234567-10123 } } @Override protected Object parseNotEmptyTextFieldToInternalForm( String pText, Object pLastValidInternalFormValue ) { UtilDateAdaptor zInadequatePartsSource = (pLastValidInternalFormValue instanceof SimpleTimestamp) ? ((SimpleTimestamp) pLastValidInternalFormValue).getUtilDateAdaptor() : null; return TemporalParser.YMD.parseTimestamp( pText, getPicker().getTimeFields(), zInadequatePartsSource ); } @Override protected void pickerClosed( boolean autoClosed ) { super.pickerClosed( autoClosed ); SimpleTimestamp value = getPicker().getExitValue(); if ( value != null ) { setTextValueFromPicker( value.toString() ); } } @Override protected void showPicker( int pAbsoluteLeft, int pAbsoluteTop, Object pCurrentValue, Object pLastValidInternalFormValue ) { SimpleTimestamp zTimestamp; if ( pCurrentValue instanceof SimpleTimestamp ) { zTimestamp = (SimpleTimestamp) pCurrentValue; } else if ( pLastValidInternalFormValue instanceof SimpleTimestamp ) { zTimestamp = (SimpleTimestamp) pLastValidInternalFormValue; } else { zTimestamp = new SimpleTimestamp( new Date() ); } getPicker().setInitialValues( zTimestamp ); super.showPicker( pAbsoluteLeft, pAbsoluteTop, pCurrentValue, pLastValidInternalFormValue ); } private MyPicker getPicker() { return (MyPicker) mPicker; } private static class MyPicker extends ExtendableDatePicker implements HigherOrderAdjustable { private SimpleTimestamp mExitValue = null; private int mTimeFields; private Button mOkButton; public MyPicker( String pCancelText, String pOKText, TimeRes pTimeRes ) { mTimeFields = pTimeRes.getIndex() + 1; mTimeFieldsPanel = new TimePickerFieldsPanel( "litesoft-TimestampTimePickerFieldsPanel", mTimeFields, this ); addExtensionPanel( mTimeFieldsPanel ); addDialogButtonPanel( CancelButton.factory( pCancelText ).create(), // mOkButton = OKButton.factory( pOKText ).create() ); } public int getTimeFields() { return mTimeFields; } public SimpleTimestamp getExitValue() { return mExitValue; } @Override public void show() { mExitValue = null; super.show(); } @Override protected void dateSelectedByClick( Date pDate ) { } @Override protected void dialogButtonClicked( Button pButton ) { if ( mOkButton == pButton ) { mExitValue = new SimpleTimestamp( new CalendarYMD( selectedDate() ), mTimeFieldsPanel.getSimpleTime() ); } hide(); } private TimePickerFieldsPanel mTimeFieldsPanel; public void setInitialValues( SimpleTimestamp pTimestamp ) { UtilDateAdaptor adaptor = pTimestamp.getUtilDateAdaptor(); setFullDate( adaptor.getWallDate() ); mTimeFieldsPanel.setTimeFields( adaptor ); } @Override public void adjustValue( int pAdjustBy ) { CalendarYMD date = new CalendarYMD( selectedDate() ).addDays( pAdjustBy ); setFullDate( date.toUtilDate() ); } } } |
Commits for litesoft/trunk/Java/GWT/Client/src/org/litesoft/GWT/forms/client/components/impls/input/FormTimestampPicker.java
Revision | Author | Commited | Message |
---|---|---|---|
950 Diff | GeorgeS | Thu 19 Jun, 2014 17:57:04 +0000 | New Lines |
948 Diff | GeorgeS | Sat 07 Jun, 2014 23:42:39 +0000 | Jusefuls Formatter Updated to New Code Format |
947 Diff | GeorgeS | Fri 06 Jun, 2014 23:36:56 +0000 | Correct Spelling of package! |
942 Diff | GeorgeS | Mon 02 Jun, 2014 23:41:46 +0000 | Extracting commonfoundation |
860 Diff | GeorgeS | Mon 05 Nov, 2012 01:39:02 +0000 | |
851 Diff | GeorgeS | Mon 08 Oct, 2012 00:05:32 +0000 | Breaking the code as Temporal changes are implemented... |
151 Diff | GeorgeS | Thu 17 Mar, 2011 04:16:22 +0000 | |
136 Diff | GeorgeS | Wed 09 Mar, 2011 21:09:51 +0000 | |
133 Diff | GeorgeS | Wed 09 Mar, 2011 00:33:28 +0000 | |
105 | GeorgeS | Thu 17 Feb, 2011 20:51:19 +0000 |