View Javadoc

1   /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.student.common.ui.client.widgets;
17  
18  
19  import java.util.Date;
20  
21  import org.kuali.student.common.ui.client.widgets.impl.KSDatePickerImpl;
22  
23  import com.google.gwt.core.client.GWT;
24  import com.google.gwt.event.dom.client.BlurHandler;
25  import com.google.gwt.event.dom.client.FocusHandler;
26  import com.google.gwt.event.logical.shared.ValueChangeHandler;
27  import com.google.gwt.event.shared.HandlerRegistration;
28  
29  /**
30   * The KSDatePicker widget provides an easy way for a date to be entered by a user.  When this widget obtains focus,
31   * a datepicker popup calendar appears below the text field.  The user may either select the date using the calendar,
32   * or fill in the date manually (which will automatically selects the date for them in the calendar).
33   * 
34   * TODO 03/11/2009 - This widget currently only supports dates entered in the mm/dd/yyyy format.  Known unresolved backspace bug in Firefox.
35   * 
36   * @author Kuali Student Team
37   *
38   */
39  public class KSDatePicker extends KSDatePickerAbstract implements HasWatermark { 
40      KSDatePickerAbstract datePicker = GWT.create(KSDatePickerImpl.class);
41      
42      /**
43       * Creates a KSDatePicker widget.
44       * 
45       */
46      public KSDatePicker() {
47          this.initWidget(datePicker);
48          
49      }
50  
51      /**
52       * Get the currently selected date.
53       * 
54       * @return the Date selected
55       */
56      @Override
57      public Date getValue() {
58          return datePicker.getValue();
59      }
60  
61      /**
62       * Sets the date and selects it.
63       * 
64       * @param date the Date to set the calendar and associated field to
65       */
66      @Override
67      public void setValue(Date date) {
68          datePicker.setValue(date);
69      }
70  
71      /**
72       * @see com.google.gwt.user.client.ui.HasValue#setValue(java.lang.Object, boolean)
73       */
74      @Override
75      public void setValue(Date date, boolean fireEvents) {
76          datePicker.setValue(date, fireEvents);
77      }
78  
79      /**
80       * @see com.google.gwt.event.logical.shared.HasValueChangeHandlers#addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler)
81       */
82      @Override
83      public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Date> handler) {
84          return datePicker.addValueChangeHandler(handler);
85      }
86  
87  	@Override
88  	public HandlerRegistration addFocusHandler(FocusHandler handler) {
89  		return datePicker.addFocusHandler(handler);
90  	}
91  
92  	@Override
93  	public HandlerRegistration addBlurHandler(BlurHandler handler) {
94  		return datePicker.addBlurHandler(handler);
95  	}
96  
97      @Override
98      public boolean hasWatermark() {
99          return datePicker.hasWatermark();
100     }
101 
102     @Override
103     public void setWatermarkText(String waterMark) {
104         datePicker.setWatermarkText(waterMark);
105     }
106 
107     @Override
108     public boolean watermarkShowing() {
109         return datePicker.watermarkShowing();
110     }
111     
112     
113 }