| CODENOTIFIER | HelpYou are not signed inSign in |
Project: gwt-ext
Revision: 1819
Author: mlim1972
Date: 04 Sep 2008 04:53:11
Changes:Issue 403. Fixing problem where 'select' was not triggered when a date is picked from a DateField.
Files:| ... | ...@@ -25,6 +25,7 @@ | |
| 25 | 25 | |
| 26 | 26 | import com.google.gwt.core.client.JavaScriptObject; |
| 27 | 27 | import com.google.gwt.user.client.Element; |
| 28 | import com.gwtext.client.widgets.event.DatePickerListener; | |
| 28 | 29 | |
| 29 | 30 | import java.util.Date; |
| 30 | 31 | |
| ... | ...@@ -35,6 +36,33 @@ | |
| 35 | 36 | */ |
| 36 | 37 | public class DateField extends TextField { |
| 37 | 38 | |
| 39 | /** | |
| 40 | * Fixes issues with the normal DateField... | |
| 41 | */ | |
| 42 | static { | |
| 43 | fix(); | |
| 44 | } | |
| 45 | ||
| 46 | /** | |
| 47 | * This method is called once when the DateField is instantiated. | |
| 48 | * This method currently fixes the fire of event on select! | |
| 49 | */ | |
| 50 | private static native void fix()/*-{ | |
| 51 | $wnd.Ext.ux.DateFieldEx = $wnd.Ext.extend($wnd.Ext.form.DateField, { | |
| 52 | initComponent: function () { | |
| 53 | $wnd.Ext.ux.DateFieldEx.superclass.initComponent.call(this); | |
| 54 | this.addEvents( | |
| 55 | 'select' | |
| 56 | ); | |
| 57 | this.menuListeners.select = function (m, d) { | |
| 58 | if (this.fireEvent("select", this, d) !== false) | |
| 59 | this.setValue(d); | |
| 60 | }; | |
| 61 | } | |
| 62 | }); | |
| 63 | $wnd.Ext.reg('datefieldex', $wnd.Ext.ux.DateFieldEx); | |
| 64 | }-*/; | |
| 65 | ||
| 38 | 66 | /** |
| 39 | 67 | * Construct a new DateField. |
| 40 | 68 | */ |
| ... | ...@@ -68,7 +96,7 @@ | |
| 68 | 96 | } |
| 69 | 97 | |
| 70 | 98 | protected native JavaScriptObject create(JavaScriptObject jsObj) /*-{ |
| 71 | return new $wnd.Ext.form.DateField(jsObj); | |
| 99 | return new $wnd.Ext.ux.DateFieldEx(jsObj); | |
| 72 | 100 | }-*/; |
| 73 | 101 | |
| 74 | 102 | /** |
| ... | ...@@ -81,7 +109,23 @@ | |
| 81 | 109 | return date == -1 ? null : new Date((long)date); |
| 82 | 110 | } |
| 83 | 111 | |
| 112 | /** | |
| 113 | * Add a Date Picker Listener. | |
| 114 | * | |
| 115 | * @param listener the listener | |
| 116 | */ | |
| 117 | public native void addListener(DatePickerListener listener) /*-{ | |
| 118 | this.@com.gwtext.client.widgets.Component::addListener(Lcom/gwtext/client/widgets/event/ComponentListener;)(listener); | |
| 84 | 119 | |
| 120 | this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('select', | |
| 121 | function(datePicker, date) { | |
| 122 | var d = @com.gwtext.client.util.DateUtil::create(D)(date.getTime()); | |
| 123 | var componentJ = @com.gwtext.client.widgets.DatePicker::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(datePicker); | |
| 124 | listener.@com.gwtext.client.widgets.event.DatePickerListener::onSelect(Lcom/gwtext/client/widgets/DatePicker;Ljava/util/Date;)(componentJ, d); | |
| 125 | } | |
| 126 | ); | |
| 127 | }-*/; | |
| 128 | ||
| 85 | 129 | protected native Element getElement(JavaScriptObject jsObj) /*-{ |
| 86 | 130 | //for trigger fields, we want the text area as well as the trigger button to be treated as the element |
| 87 | 131 | //unit |
| ... | ...@@ -125,7 +169,7 @@ | |
| 125 | 169 | //-- config properties --- |
| 126 | 170 | |
| 127 | 171 | public String getXType() { |
| 128 | return "datefield"; | |
| 172 | return "datefieldex"; | |
| 129 | 173 | } |
| 130 | 174 | |
| 131 | 175 | public void setAltFormats(String altFormats) { |
| ... | ...@@ -73,7 +73,7 @@ | |
| 73 | 73 | return new $wnd.Ext.DatePicker(config); |
| 74 | 74 | }-*/; |
| 75 | 75 | |
| 76 | private static DatePicker instance(JavaScriptObject jsObj) { | |
| 76 | public static DatePicker instance(JavaScriptObject jsObj) { | |
| 77 | 77 | return new DatePicker(jsObj); |
| 78 | 78 | } |
| 79 | 79 |