Author: [EMAIL PROTECTED]
Date: Fri Nov 21 09:26:43 2008
New Revision: 4155

Modified:
     
branches/1_6_datepicker/user/src/com/google/gwt/user/datepicker/client/CalendarView.java
     
branches/1_6_datepicker/user/src/com/google/gwt/user/datepicker/client/DatePicker.java
     
branches/1_6_datepicker/user/src/com/google/gwt/user/datepicker/client/DefaultCalendarView.java

Log:
removing helper methods from calendar view and re-ordering its date  
arguments to the end as well

Modified:  
branches/1_6_datepicker/user/src/com/google/gwt/user/datepicker/client/CalendarView.java
==============================================================================
---  
branches/1_6_datepicker/user/src/com/google/gwt/user/datepicker/client/CalendarView.java
         
(original)
+++  
branches/1_6_datepicker/user/src/com/google/gwt/user/datepicker/client/CalendarView.java
         
Fri Nov 21 09:26:43 2008
@@ -35,24 +35,10 @@
    /**
     * Adds a style name to the cell of the supplied date. This style is  
only set
     * until the next time the [EMAIL PROTECTED] CalendarView} is refreshed.
-   *
-   * @param date date that will have the supplied style added
-   * @param styleName style name to add
-   */
-  public abstract void addStyleToDate(Date date, String styleName);
-
-  /**
-   * Adds a style to the cell of the supplied dates. This is only set  
until the
-   * next time the [EMAIL PROTECTED] CalendarView} is refreshed.
-   *
-   * @param dates dates that will have the supplied style added
     * @param styleName style name to add
+   * @param date date that will have the supplied style added
     */
-  public void addStyleToDates(Iterable<Date> dates, String styleName) {
-    for (Date date : dates) {
-      addStyleToDate(date, styleName);
-    }
-  }
+  public abstract void addStyleToDate(String styleName, Date date);

    /**
     * Returns the first date that is currently shown by the calendar.
@@ -76,52 +62,23 @@
     */
    public abstract boolean isDateEnabled(Date date);

-  /**
-   * Is the cell representing the given date visible?
-   *
-   * @param date the date
-   * @return whether the date is visible
-   */
-  public boolean isDateVisible(Date date) {
-    Date first = getFirstDate();
-    Date last = getLastDate();
-    return (date != null && (first.equals(date) || last.equals(date) ||  
(first.before(date) && last.after(date))));
-  }
-
    @Override
    public abstract void refresh();

    /**
     * Removes a visible style name from the cell of the supplied date.
-   *
-   * @param date date that will have the supplied style added
     * @param styleName style name to remove
+   * @param date date that will have the supplied style added
     */
-  public abstract void removeStyleFromDate(Date date, String styleName);
+  public abstract void removeStyleFromDate(String styleName, Date date);

    /**
     * Enables or Disables a particular date. by default all valid dates are
     * enabled after a rendering event. Disabled dates cannot be selected.
-   *
-   * @param date date to enable or disable
-   *
     * @param enabled true for enabled, false for disabled
+   * @param date date to enable or disable
     */
-  public abstract void setDateEnabled(Date date, boolean enabled);
-
-  /**
-   * Enables or disables multiple dates.
-   *
-   * @param dates dates to [en|dis]able
-   * @param enabled true to enable, false to disable
-   */
-  public void setDatesEnabled(Iterable<Date> dates, boolean enabled) {
-    for (Date date : dates) {
-      assert isDateVisible(date) : date
-          + " cannot be enabled or disabled as it is not visible";
-      setDateEnabled(date, enabled);
-    }
-  }
+  public abstract void setDateEnabled(boolean enabled, Date date);

    /**
     * Allows the calendar view to update the date picker's highlighted date.

Modified:  
branches/1_6_datepicker/user/src/com/google/gwt/user/datepicker/client/DatePicker.java
==============================================================================
---  
branches/1_6_datepicker/user/src/com/google/gwt/user/datepicker/client/DatePicker.java
   
(original)
+++  
branches/1_6_datepicker/user/src/com/google/gwt/user/datepicker/client/DatePicker.java
   
Fri Nov 21 09:26:43 2008
@@ -228,13 +228,14 @@
    /**
     * Globally adds a style name to a date. i.e. the style name is  
associated
     * with the date each time it is rendered.
+   *
     * @param styleName style name
     * @param date date
     */
    public void addGlobalStyleToDate(String styleName, Date date) {
      styler.setStyleName(date, styleName, true);
      if (isDateVisible(date)) {
-      getView().addStyleToDate(date, styleName);
+      getView().addStyleToDate(styleName, date);
      }
    }

@@ -255,8 +256,8 @@
     */
    public HandlerRegistration addShowRangeHandlerAndFire(
        ShowRangeHandler<Date> handler) {
-    ShowRangeEvent<Date> event = new  
ShowRangeEvent<Date>(getView().getFirstDate(),
-        getView().getLastDate()) {
+    ShowRangeEvent<Date> event = new ShowRangeEvent<Date>(
+        getView().getFirstDate(), getView().getLastDate()) {
      };
      handler.onShowRange(event);
      return addShowRangeHandler(handler);
@@ -265,22 +266,26 @@
    /**
     * Shows the given style name on the specified date. This is only set  
until
     * the next time the DatePicker is refreshed.
+   *
     * @param styleName style name
     * @param visibleDate current visible date
     */
    public final void addStyleToVisibleDate(String styleName, Date  
visibleDate) {
-    getView().addStyleToDate(visibleDate, styleName);
+    getView().addStyleToDate(styleName, visibleDate);
    }

    /**
     * Adds a style name on a set of currently visible dates. This is only  
set
     * until the next time the DatePicker is refreshed.
+   *
     * @param styleName style name to remove
     * @param visibleDates dates that will have the supplied style removed
     */
    public final void addStyleToVisibleDates(String styleName,
        Iterable<Date> visibleDates) {
-    getView().addStyleToDates(visibleDates, styleName);
+    for (Date date : visibleDates) {
+      getView().addStyleToDate(styleName, date);
+    }
    }

    public HandlerRegistration addValueChangeHandler(
@@ -297,7 +302,7 @@
     * </p>
     *
     */
-  public Date getCurrentMonth(){
+  public Date getCurrentMonth() {
      return getModel().getCurrentMonth();
    }

@@ -356,7 +361,10 @@
     * @return is the date currently shown
     */
    public boolean isDateVisible(Date date) {
-    return getView().isDateVisible(date);
+    CalendarView r = getView();
+    Date first = r.getFirstDate();
+    Date last = r.getLastDate();
+    return (date != null && (first.equals(date) || last.equals(date) ||  
(first.before(date) && last.after(date))));
    }

    /**
@@ -372,18 +380,20 @@

    /**
     * Globally removes a style from a date.
+   *
     * @param styleName style name
     * @param date date
     */
    public void removeGlobalStyleFromDate(String styleName, Date date) {
      styler.setStyleName(date, styleName, false);
      if (isDateVisible(date)) {
-      getView().removeStyleFromDate(date, styleName);
+      getView().removeStyleFromDate(styleName, date);
      }
    }

    /**
     * Removes a style name from multiple visible dates.
+   *
     * @param styleName style name to remove
     * @param dates dates that will have the supplied style removed
     */
@@ -392,9 +402,10 @@
      while (dates.hasNext()) {
        Date date = dates.next();
        assert (isDateVisible(date)) : date + " should be visible";
-      getView().removeStyleFromDate(date, styleName);
+      getView().removeStyleFromDate(styleName, date);
      }
    }
+
    /**
     * Sets the date picker to show the given month, use [EMAIL PROTECTED]  
#getFirstDate()}
     * and [EMAIL PROTECTED] #getLastDate()} to access the exact date range the 
date  
picker
@@ -403,6 +414,7 @@
     * A datepicker <b> may </b> show days not in the current month. It
     * <b>must</b> show all days in the current month.
     * </p>
+   *
     * @param month the month to show
     */
    public void setCurrentMonth(Date month) {
@@ -413,24 +425,31 @@
    /**
     * Sets a visible date to be enabled or disabled. This is only set until  
the
     * next time the DatePicker is refreshed.
+   *
     * @param enabled is enabled
     * @param date the date
     */
    public final void setEnabledOnVisibleDate(boolean enabled, Date date) {
      assert isDateVisible(date) : date
          + " cannot be enabled or disabled as it is not visible";
-    getView().setDateEnabled(date, enabled);
+    getView().setDateEnabled(enabled, date);
    }

    /**
     * Sets a group of visible dates to be enabled or disabled. This is only  
set
     * until the next time the DatePicker is refreshed.
+   *
     * @param enabled is enabled
     * @param dates the dates
     */
    public final void setEnabledOnVisibleDates(boolean enabled,
        Iterable<Date> dates) {
-    getView().setDatesEnabled(dates, enabled);
+    CalendarView r = getView();
+    for (Date date : dates) {
+      assert isDateVisible(date) : date
+          + " cannot be enabled or disabled as it is not visible";
+      r.setDateEnabled(enabled, date);
+    }
    }

    /**
@@ -522,8 +541,8 @@
    }

    /**
-   * Gets the [EMAIL PROTECTED] DatePicker.Css} associated with this date 
picker for  
use by
-   * extended month and cell grids.
+   * Gets the css associated with this date picker for use by extended  
month and
+   * cell grids.
     *
     * @return the css.
     */

Modified:  
branches/1_6_datepicker/user/src/com/google/gwt/user/datepicker/client/DefaultCalendarView.java
==============================================================================
---  
branches/1_6_datepicker/user/src/com/google/gwt/user/datepicker/client/DefaultCalendarView.java
  
(original)
+++  
branches/1_6_datepicker/user/src/com/google/gwt/user/datepicker/client/DefaultCalendarView.java
  
Fri Nov 21 09:26:43 2008
@@ -149,8 +149,8 @@
    }

    @Override
-  public void addStyleToDate(Date date, String styleName) {
-    assert isDateVisible(date) : "You tried to add style " + styleName + "  
to "
+  public void addStyleToDate(String styleName, Date date) {
+    assert getDatePicker().isDateVisible(date) : "You tried to add style "  
+ styleName + " to "
          + date + ". The calendar is currently showing " + getFirstDate()
          + " to " + getLastDate();
      getCell(date).addStyleName(styleName);
@@ -192,12 +192,12 @@
    }

    @Override
-  public void removeStyleFromDate(Date date, String styleName) {
+  public void removeStyleFromDate(String styleName, Date date) {
      getCell(date).removeStyleName(styleName);
    }

    @Override
-  public void setDateEnabled(Date date, boolean enabled) {
+  public void setDateEnabled(boolean enabled, Date date) {
      getCell(date).setEnabled(enabled);
    }


--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to