litesoft
@ 942
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 |
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt package org.litesoft.GWT.forms.client.components.impls.input; import java.util.*; 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.*; public class FormTimePicker extends AbstractTextFieldWithPicker { public FormTimePicker( String pLabel, UiFont pLabelFont, String pTooltip, TimeRes pTimeRes, String pCancelText, String pOKText ) { super( pTooltip, false, calcLength( pTimeRes ), "Time", new MyPicker( pCancelText, pOKText, deNull( pTimeRes ) ) ); initialize( pLabel, pLabelFont, pTooltip ); } private static TimeRes deNull( TimeRes pTimeRes ) { return (pTimeRes != null) ? pTimeRes : TimeRes.ToSEC; } private static int calcLength( TimeRes pTimeRes ) { switch ( deNull( pTimeRes ).getIndex() ) { default: case TimeRes.MSECindex: // 13:32:59.999 return 12; // .........1234567-1012 case TimeRes.SECindex: //. 13:32:59 return 8; // ..........12345678 case TimeRes.MINindex: //. 13:32 return 5; // ..........12345 case TimeRes.HOURindex: // 13 return 2; // ..........12 } } @Override protected Object parseNotEmptyTextFieldToInternalForm( String pText, Object pLastValidInternalFormValue ) { UtilDateAdaptor zInadequatePartsSource = (pLastValidInternalFormValue instanceof SimpleTime) ? ((SimpleTime) pLastValidInternalFormValue).getUtilDateAdaptor() : null; return TemporalParser.YMD.parseTime( pText, getPicker().getTimeFields(), zInadequatePartsSource ); } @Override protected void pickerClosed( boolean autoClosed ) { super.pickerClosed( autoClosed ); SimpleTime value = getPicker().getExitValue(); if ( value != null ) { setTextValueFromPicker( value.toString() ); } } @Override protected void showPicker( int pAbsoluteLeft, int pAbsoluteTop, Object pCurrentValue, Object pLastValidInternalFormValue ) { SimpleTime zTime; if ( pCurrentValue instanceof SimpleTime ) { zTime = (SimpleTime) pCurrentValue; } else if ( pLastValidInternalFormValue instanceof SimpleTime ) { zTime = (SimpleTime) pLastValidInternalFormValue; } else { zTime = SimpleTime.timeComponents( new Date() ); } getPicker().setInitialValues( zTime ); super.showPicker( pAbsoluteLeft, pAbsoluteTop, pCurrentValue, pLastValidInternalFormValue ); } private MyPicker getPicker() { return (MyPicker) mPicker; } private static class MyPicker extends ExtendableDialogPicker { private SimpleTime mExitValue = null; private int mTimeFields; private TimePickerFieldsPanel mTimeFieldsPanel; private Button mOkButton; public MyPicker( String pCancelText, String pOKText, TimeRes pTimeRes ) { mTimeFields = pTimeRes.getIndex() + 1; mTimeFieldsPanel = new TimePickerFieldsPanel( "litesoft-TimePickerFieldsPanel", mTimeFields, null ); addExtensionPanel( mTimeFieldsPanel ); addDialogButtonPanel( CancelButton.factory( pCancelText ).create(), // mOkButton = OKButton.factory( pOKText ).create() ); } public int getTimeFields() { return mTimeFields; } @Override protected void dialogButtonClicked( Button pButton ) { if ( mOkButton == pButton ) { mExitValue = mTimeFieldsPanel.getSimpleTime(); } hide(); } public SimpleTime getExitValue() { return mExitValue; } @Override public void show() { mExitValue = null; super.show(); } public void setInitialValues( SimpleTime pTime ) { mTimeFieldsPanel.setTimeFields( pTime.getUtilDateAdaptor() ); } } } |
Commits for litesoft/trunk/Java/GWT/Client/src/org/litesoft/GWT/forms/client/components/impls/input/FormTimePicker.java
Revision | Author | Commited | Message |
---|---|---|---|
942 Diff | GeorgeS | Mon 02 Jun, 2014 23:41:46 +0000 | Extracting commonfoundation |
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 Diff | GeorgeS | Thu 17 Feb, 2011 20:51:19 +0000 | |
103 Diff | GeorgeS | Tue 15 Feb, 2011 01:54:45 +0000 | |
49 Diff | GeorgeS | Mon 12 Apr, 2010 02:59:10 +0000 | License Text |
23 Diff | GeorgeS | Wed 24 Feb, 2010 00:34:32 +0000 | |
2 | GeorgeS | Sun 07 Feb, 2010 12:50:58 +0000 |