01: /*
02: * GWT-Ext Widget Library
03: * Copyright(c) 2007-2008, GWT-Ext.
04: * licensing@gwt-ext.com
05: *
06: * http://www.gwt-ext.com/license
07: */
08:
09: package com.gwtext.client.widgets.menu;
10:
11: import com.google.gwt.core.client.JavaScriptObject;
12: import com.gwtext.client.widgets.DatePicker;
13: import com.gwtext.client.widgets.menu.event.DateMenuListener;
14:
15: /**
16: * A menu containing a {@link DateItem} component (which provides a date picker).
17: */
18: public class DateMenu extends Menu {
19:
20: /**
21: * Create a new DateMenu.
22: */
23: public DateMenu() {
24: }
25:
26: protected native JavaScriptObject create(JavaScriptObject menuConfig)/*-{
27: return new $wnd.Ext.menu.DateMenu(menuConfig);
28: }-*/;
29:
30: /**
31: * The {@link DatePicker} instance for this DateMenu.
32: *
33: * @return the DatePicker instance for this DateMenu
34: */
35: public DatePicker getPicker() {
36: return new DatePicker(getDatePicker(getOrCreateJsObj()));
37: }
38:
39: private native JavaScriptObject getDatePicker(
40: JavaScriptObject dateMenu) /*-{
41: return dateMenu.picker;
42: }-*/;
43:
44: /**
45: * Add a DateMenu listener.
46: *
47: * @param listener the listener
48: */
49: public native void addListener(DateMenuListener listener)/*-{
50:
51: var dateMenuJ = this;
52:
53: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('select',
54: function(dm, date) {
55: var dateJS = @com.gwtext.client.util.DateUtil::create(J)(date.getTime());
56: return listener.@com.gwtext.client.widgets.menu.event.DateMenuListener::onSelect(Lcom/gwtext/client/widgets/menu/DateMenu;Ljava/util/Date;)(dateMenuJ, dateJS);
57: }
58: );
59: }-*/;
60:
61: // --- config properties --
62: private DateMenuListener dateMenuListener;
63:
64: /**
65: * Return the DateMenu listener.
66: *
67: * @return the listener
68: */
69: public DateMenuListener getDateMenuListener() {
70: return dateMenuListener;
71: }
72:
73: /**
74: * Set the DateMenu listener.
75: *
76: * @param dateMenuListener the listener
77: */
78: public void setDateMenuListener(DateMenuListener dateMenuListener) {
79: this.dateMenuListener = dateMenuListener;
80: }
81: }
|