001: /*
002: * GWT-Ext Widget Library
003: * Copyright(c) 2007-2008, GWT-Ext.
004: * licensing@gwt-ext.com
005: *
006: * http://www.gwt-ext.com/license
007: */
008:
009: package com.gwtext.client.widgets.form;
010:
011: import com.google.gwt.core.client.JavaScriptObject;
012: import com.gwtext.client.util.JavaScriptObjectHelper;
013:
014: import java.util.Date;
015:
016: /**
017: * Basic text field.
018: */
019: public class TimeField extends Field {
020:
021: private static JavaScriptObject configPrototype;
022:
023: static {
024: init();
025: }
026:
027: private static native void init()/*-{
028: var c = new $wnd.Ext.form.TimeField();
029: @com.gwtext.client.widgets.form.TimeField::configPrototype = c.initialConfig;
030: }-*/;
031:
032: protected JavaScriptObject getConfigPrototype() {
033: return configPrototype;
034: }
035:
036: public String getXType() {
037: return "timefield";
038: }
039:
040: public TimeField() {
041: }
042:
043: public TimeField(String fieldLabel) {
044: super (fieldLabel);
045: }
046:
047: public TimeField(String fieldLabel, String name) {
048: super (fieldLabel, name);
049: }
050:
051: public TimeField(String fieldLabel, String name, int width) {
052: super (fieldLabel, name, width);
053: }
054:
055: public TimeField(JavaScriptObject jsObj) {
056: super (jsObj);
057: }
058:
059: protected native JavaScriptObject create(JavaScriptObject jsObj) /*-{
060: return new $wnd.Ext.form.TimeField(jsObj);
061: }-*/;
062:
063: //--- config properties ---
064:
065: /**
066: * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
067: *
068: * @param altFormats the alt formats
069: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
070: */
071: public void setAltFormats(String altFormats)
072: throws IllegalStateException {
073: setAttribute("altFormats", altFormats, true);
074: }
075:
076: /**
077: * The default date format string which can be overriden for localization support. The format must be valid according to Date.parseDate (defaults to 'm/d/y').
078: *
079: * @param format the date format string
080: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
081: */
082: public void setFormat(String format) throws IllegalStateException {
083: setAttribute("format", format, true);
084: }
085:
086: /**
087: * The number of minutes between each time value in the list (defaults to 15).
088: *
089: * @param increment the number of minutes between each time value in the list (defaults to 15).
090: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
091: */
092: public void setIncrement(int increment)
093: throws IllegalStateException {
094: setAttribute("increment", increment, false);
095: }
096:
097: /**
098: * The error text to display when the time in the field is invalid (defaults to '{value} is not a valid time - it must be in the format {format}').
099: *
100: * @param invalidtext the error text to display when the time in the field is invalid
101: */
102: public void setInvalidText(String invalidtext) {
103: setAttribute("invalidText", invalidtext, true, true);
104: }
105:
106: /**
107: * The error text to display when the time is after maxValue (defaults to 'The time in this field must be equal to or before {0}').
108: *
109: * @param maxText The error text to display when the time is after maxValue
110: */
111: public void setMaxText(String maxText) {
112: setAttribute("maxText", maxText, true, true);
113: }
114:
115: /**
116: * The maximum allowed time.
117: *
118: * @param maxValue the max value
119: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
120: */
121: public void setMaxValue(Date maxValue) throws IllegalStateException {
122: setAttribute("maxValue", maxValue, true);
123: }
124:
125: /**
126: * The maximum allowed time in valid date format.
127: * @param maxValue The maximum allowed time.
128: *
129: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
130: */
131: public void setMaxValue(String maxValue)
132: throws IllegalStateException {
133: setAttribute("maxValue", maxValue, true);
134: }
135:
136: /**
137: * The error text to display when the date in the cell is before minValue (defaults to 'The time in this field must be equal to or after {0}').
138: *
139: * @param minText The error text to display when the date in the cell is before minValue
140: */
141: public void setMinText(String minText) {
142: setAttribute("minText", minText, true, true);
143: }
144:
145: /**
146: * The minimum allowed time.
147: *
148: * @param minValue The minimum allowed time.
149: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
150: */
151: public void setMinValue(Date minValue) throws IllegalStateException {
152: setAttribute("minValue", minValue, true);
153: }
154:
155: /**
156: * The minimum allowed time in valid date format.
157: *
158: * @param minValue The minimum allowed time.
159: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
160: */
161: public void setMinValue(String minValue)
162: throws IllegalStateException {
163: setAttribute("minValue", minValue, true);
164: }
165: }
|