You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cf...@apache.org on 2012/08/06 23:26:02 UTC
svn commit: r1370028 [33/43] - in
/incubator/flex/whiteboard/cframpton/adobe.next: ./ frameworks/
frameworks/projects/advancedgrids/src/mx/collections/
frameworks/projects/advancedgrids/src/mx/controls/
frameworks/projects/airframework/src/mx/managers/...
Added: incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/DateSet.as
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/DateSet.as?rev=1370028&view=auto
==============================================================================
--- incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/DateSet.as (added)
+++ incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/DateSet.as Mon Aug 6 21:25:54 2012
@@ -0,0 +1,637 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package spark.components.calendarClasses
+{
+import flash.events.Event;
+import flash.events.EventDispatcher;
+
+import mx.core.mx_internal;
+import mx.events.FlexEvent;
+
+import spark.components.DateChooser;
+
+use namespace mx_internal;
+
+/**
+ * The DateSet class is used to represent a set of dates.
+ * The time portion of each Date is ignored.
+ *
+ * <p>To include all dates after, set <code>minDate</code> to today's date.
+ * To include all dates before today, set <code>maxDate</code> to today's date.
+ * </p>
+ *
+ * @see spark.components.DateChooser#selectableDates
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+
+/**
+ * @private
+ * Usage examples:
+ * 1. Select a single date.
+ * 2. Select only dates within a given range.
+ * 3. Select from a list of dates and/or date ranges, for example 5/7/11, 5/12/11-5/16/11, 5/21/11, etc.
+ * 4. Disable a list of dates and/or date ranges, for example, 7/2/11, 7/5/11, 7/10/11.
+ * 5. Disable all dates before a certain date or after a certain date.
+ * 6. Disable all dates before today (special case of #5). Enable all dates from today forward.
+ * 7. Only dates in the displayed month are selectable.
+ * 8. Only certain day(s) of the week are selectable or disable certain day(s) of the week.
+ * 9. Only certain day(s) within a date range are selectable, for example, Mondays between 7/1/11 and 8/31/11.
+ * 10. Select all dates within x days +/- of a given date.
+ */
+
+public class DateSet extends EventDispatcher
+{
+ include "../../core/Version.as";
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructor.
+ * By default all days between <code>minDate</code> and <code>maxDate</code> are included.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ public function DateSet()
+ {
+ super();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // excludedDateRanges
+ //----------------------------------
+
+ private var _excludedDateRanges:Vector.<DateRange>;
+ private var excludedDateRangesChanged:Boolean = false;
+
+ [Bindable("excludedDateRangesChanged")]
+
+ /**
+ * The date ranges that are excluded from the set.
+ * This is an Vector of <code>DateRange</code>.
+ *
+ * <p>If you get the the vector of excluded dates it will be normalized.
+ * This means it will be sorted based on the startDate of each DateRange and overlapping
+ * DateRanges will be combined.</p>
+ *
+ * @default null
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ public function get excludedDateRanges():Vector.<DateRange>
+ {
+ if (excludedDateRangesChanged)
+ {
+ _excludedDateRanges = DateRange.normalizeDateRanges(_excludedDateRanges);
+ excludedDateRangesChanged = false;
+ }
+
+ return _excludedDateRanges;
+ }
+
+ /**
+ * @private
+ */
+ public function set excludedDateRanges(value:Vector.<DateRange>):void
+ {
+ if (_excludedDateRanges == value)
+ return;
+
+ _excludedDateRanges = value;
+ excludedDateRangesChanged = true;
+
+ dispatchChangeEvent("excludedDateRangesChanged");
+ }
+
+ //----------------------------------
+ // excludedDays
+ //----------------------------------
+
+ private var _excludedDays:Vector.<int>;
+
+ [Bindable("excludedDaysChanged")]
+
+ /**
+ * The list of days of the week (0 for Sunday, 1 for Monday, and so on) that are
+ * excluded from the set.
+ * This is an Vector of <code>int</code>.
+ *
+ * @default null
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ public function get excludedDays():Vector.<int>
+ {
+ return _excludedDays;
+ }
+
+ /**
+ * @private
+ */
+ public function set excludedDays(value:Vector.<int>):void
+ {
+ if (_excludedDays == value)
+ return;
+
+ _excludedDays = value;
+
+ dispatchChangeEvent("excludedDaysChanged");
+ }
+
+ //----------------------------------
+ // excludeWeekends
+ //----------------------------------
+
+ // Removed by PARB to reduce complexity of API. Can use exludedDays.
+
+ //----------------------------------
+ // includedDateRanges
+ //----------------------------------
+
+ private var _includedDateRanges:Vector.<DateRange>;
+ private var includedDateRangesChanged:Boolean = false;
+
+ [Bindable("includedDateRangesChanged")]
+
+ /**
+ * The date ranges that are included in the set.
+ * This is an Vector of <code>DateRange</code>.
+ * Any dates ealier than <code>minDate</code> and later than <code>maxDate</code> are
+ * ignored and not included in the set.
+ *
+ * <p>If this is not set, then all dates between <code>minDate</code> and <code>maxDate</code>,
+ * inclusive, are implicitly included in the set.</p>
+ *
+ * <p>If you get the the vector of excluded dates it will be normalized.
+ * This means it will be sorted based on the startDate of each DateRange and overlapping
+ * DateRanges will be combined.</p>
+ *
+ * @default null
+ *
+ * @see #minDate
+ * @see #maxDate
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ public function get includedDateRanges():Vector.<DateRange>
+ {
+ if (includedDateRangesChanged)
+ {
+ _includedDateRanges = DateRange.normalizeDateRanges(_includedDateRanges);
+ includedDateRangesChanged = false;
+ }
+
+ return _includedDateRanges;
+ }
+
+ /**
+ * @private
+ */
+ public function set includedDateRanges(value:Vector.<DateRange>):void
+ {
+ if (_includedDateRanges == value)
+ return;
+
+ _includedDateRanges = value;
+ includedDateRangesChanged = true;
+
+ dispatchChangeEvent("includedDateRangesChanged");
+ }
+
+ //----------------------------------
+ // includedDays
+ //----------------------------------
+
+ // Removed by PARB to reduce complexity of API. Can include range and then specify excludedDays.
+
+ //----------------------------------
+ // filterFunction
+ //----------------------------------
+
+ private var _filterFunction:Function;
+
+ [Inspectable(category="Advanced")]
+
+ /**
+ * Specifies a callback function used to determine if a given date that is in the computed
+ * set of included dates should be excluded from the set.
+ * This function allows you to refine the computed set of included dates by excluding
+ * additional dates.
+ * If defined, the <code>isDateIncluded</code> method calls this function if the date is
+ * in the set of computed included dates.
+ *
+ * <p>The signature of the <code>filterFunction</code> function must match the
+ * following:
+ *
+ * <pre>filterFunction(date:Date):Boolean</pre>
+ * </p>
+ *
+ * <p>The filterFunction should return <code>true</code> if the date is to be included in the
+ * set and it should return <code>false</code> if the date should be excluded from the set.</p>
+ *
+ * <p>For example, you could use this function if you want to include every third Wednesday
+ * of the month. You would exclude all days but Wednesday with <code>excludedDays</code>
+ * and then you would write this function to return true if the date is the third
+ * Wednesday of the month.</p>
+ *
+ * @default null
+ *
+ * @see #isDateIncluded()
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ public function get filterFunction():Function
+ {
+ return _filterFunction;
+ }
+
+ /**
+ * @private
+ */
+ public function set filterFunction(value:Function):void
+ {
+ _filterFunction = value;
+ }
+
+ //----------------------------------
+ // minDate
+ //----------------------------------
+
+ private var _minDate:Date = new Date(DateChooser.MIN_DATE_DEFAULT.time);
+
+ [Bindable("minDateChanged")]
+
+ /**
+ * The earliest date that can be included in the set.
+ * If you limit the range it will reduce the search time for selectable dates.
+ * The earliest valid date is January 1, 1601.
+ *
+ * <p>If <code>includedDateRanges</code> is not set, then all dates between
+ * <code>minDate</code> and <code>maxDate</code>, inclusive, are implicitly included in the
+ * set.</p>
+ *
+ * @default January 1, 1900
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ public function get minDate():Date
+ {
+ return _minDate ? new Date(_minDate.time) : null;
+ }
+
+ /**
+ * @private
+ */
+ public function set minDate(value:Date):void
+ {
+ if (_minDate == value)
+ return;
+
+ if (value == null || value.time < DateChooser.MIN_DATE.time)
+ value = new Date(DateChooser.MIN_DATE.time);
+
+ _minDate = new Date(value.time);
+
+ dispatchChangeEvent("minDateChanged");
+ }
+
+ //----------------------------------
+ // maxDate
+ //----------------------------------
+
+ private var _maxDate:Date = new Date(DateChooser.MAX_DATE_DEFAULT.time);
+
+ [Bindable("maxDateChanged")]
+
+ /**
+ * The latest date that can be included in the set.
+ * If you limit the range it will reduce the search time for selectable dates.
+ * The latest valid date is December 31, 9999.
+ *
+ * <p>If <code>includedDateRanges</code> is not set, then all dates between
+ * <code>minDate</code> and <code>maxDate</code>, inclusive, are implicitly included in the
+ * set.</p>
+ *
+ * @default December 31, 2100
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ public function get maxDate():Date
+ {
+ return _maxDate ? new Date(_maxDate.time) : null;
+ }
+
+ /**
+ * @private
+ */
+ public function set maxDate(value:Date):void
+ {
+ if (_maxDate == value)
+ return;
+
+ if (value == null || value.time > DateChooser.MAX_DATE.time)
+ value = new Date(DateChooser.MAX_DATE.time);
+
+ _maxDate = new Date(value.time);
+
+ dispatchChangeEvent("maxDateChanged");
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Overridden methods
+ //
+ //--------------------------------------------------------------------------
+
+ override public function toString():String
+ {
+ return "[DateSet" +
+ (minDate ? " minDate=" + minDate.toLocaleString() : "") +
+ (maxDate ? " maxDate=" + maxDate.toLocaleString() : "") +
+ (includedDateRanges ? " includedDateRanges=" + includedDateRanges : "") +
+ (excludedDateRanges ? " excludedDateRanges=" + excludedDateRanges : "") +
+ (excludedDays ? " excludedDays=" + excludedDays : "") +
+ "]";
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Public Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Returns true if the <code>date</code> is included in the computed set of included
+ * dates.
+ * The computed set incorporates the DateSet properties,
+ * <code>includedDates</code>, <code>excludedDates</code>, <code>excludedDays</code>,
+ * <code>minDate</code>, <code>maxDate/code and the <code>filterFunction</code>.
+ *
+ * <p>The set of included dates is computed in the following order:</p>
+ *
+ * <ol>
+ * <li>Include all dates in <code>includedDateRanges</code> between <code>minDate</code>
+ * and <code>maxDate</code>, inclusive.</li>
+ * <li>If <code>includedDateRanges</code> is not specified,
+ * include all dates between <code>minDate</code> and <code>maxDate</code>, inclusive.</li>
+ * <li>Exclude all dates in <code>excludedDateRanges</code>.</li>
+ * <li>Exclude all <code>excludedDays</code></li>
+ * </ol>
+ *
+ * <p>If <code>date</code> is in the set of computed dates, and the
+ * <code>filterFunction</code></p> is defined, the <code>filterFunction</code> is executed to
+ * determine if the <code>date</code> should remain in the set.</p>
+ *
+ * @param date The date to test for inclusion in the computed set.
+ *
+ * @returns <code>true</code> if the date is included in the computed set.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ public function isDateIncluded(date:Date):Boolean
+ {
+ if (date == null)
+ return false;
+
+ // If minDate/maxDate specified, is date within that range.
+ if (_minDate && DateUtil.dateCompare(_minDate, date) > 0)
+ return false;
+
+ if (_maxDate && DateUtil.dateCompare(date, _maxDate) > 0)
+ return false;
+
+ // If there are any included date ranges then this date must be explicitly included to be
+ // in the set.
+ if (includedDateRanges && !isDateExplicitlyIncluded(date))
+ return false;
+
+ // This date passed all the inclusion tests. Check that it is not specifically excluded.
+ if (isDateExplicitlyExcluded(date))
+ return false;
+
+ // If function specified, let it decide any final exclusions.
+ if (filterFunction != null)
+ return filterFunction(date);
+
+ return true;
+ }
+
+ /**
+ * Returns true if all the dates in <code>range</code>, are included in computed set of
+ * included dates.
+ * The <code>isDateIncluded</code> method is used to determine if each date in
+ * <code>range</code> is included.
+ *
+ * @see #isDateIncluded
+ *
+ * @param range The range of dates to test for inclusion in the computed set.
+ *
+ * @returns <code>true</code> all the date in the date range are included in the computed set.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ public function isDateRangeIncluded(range:DateRange):Boolean
+ {
+ if (!range)
+ return false;
+
+ var nextDate:Date = DateUtil.scrubTimeValue(range.startDate);
+ var endTime:Number = DateUtil.scrubTimeValue(range.endDate).time;
+
+ while (nextDate.getTime() <= endTime)
+ {
+ if (!isDateIncluded(nextDate))
+ return false;
+
+ nextDate.date += 1;
+ }
+
+ return true;
+ }
+
+ /**
+ * Get the next included date after <code>date</code>.
+ * The <code>isDateIncluded</code> method is used to test dates for inclusion.
+ *
+ * @returns the next included date or null if one is not found between date and maxDate.
+ *
+ * @see #isDateIncluded
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ public function getNextIncludedDate(date:Date):Date
+ {
+ if (date == null)
+ return null;
+
+ // FIXME: replace with GAT method
+ date = new Date(date.fullYear, date.month, date.date + 1);
+
+ while (!isDateIncluded(date) && DateUtil.dateCompare(date, _maxDate) <= 0)
+ {
+ date.date++;
+ }
+
+ return DateUtil.dateCompare(date, _maxDate) <= 0 ? date : null;
+ }
+
+ /**
+ * Get the previous included date before <code>date</code>.
+ * The <code>isDateIncluded</code> method is used to test dates for inclusion.
+ *
+ * @returns the previous included date or null if one is not found between date and minDate.
+ *
+ * @see #isDateIncluded
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ public function getPreviousIncludedDate(date:Date):Date
+ {
+ if (date == null)
+ return null;
+
+ // FIXME: replace with GAT method
+ date = new Date(date.fullYear, date.month, date.date - 1);
+
+ while (!isDateIncluded(date) && DateUtil.dateCompare(_minDate, date) <= 0)
+ {
+ date.date--;
+ }
+
+ return DateUtil.dateCompare(date, _minDate) >= 0 ? date : null;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Private Methods
+ //
+ //--------------------------------------------------------------------------
+
+ private function dispatchChangeEvent(type:String):void
+ {
+ if (hasEventListener(type))
+ dispatchEvent(new Event(type));
+ }
+
+ /**
+ * Return true if the given date is explicitly excluded
+ * from the set.
+ */
+ private function isDateExplicitlyExcluded(date:Date):Boolean
+ {
+ if (excludedDays)
+ {
+ var dayOfTheWeek:int = date.getDay();
+ for each (var d:int in excludedDays)
+ {
+ if (dayOfTheWeek == d)
+ return true;
+ }
+ }
+
+ if (excludedDateRanges)
+ {
+ for each (var dateRange:DateRange in excludedDateRanges)
+ {
+ if (dateRange.isDateIncluded(date))
+ return true;
+
+ if (DateUtil.dateCompare(dateRange.startDate, date) > 0)
+ break;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Return true if the given date is explicitly included
+ * in the set.
+ */
+ private function isDateExplicitlyIncluded(date:Date):Boolean
+ {
+ if (includedDateRanges)
+ {
+ for each (var dateRange:DateRange in includedDateRanges)
+ {
+ if (dateRange.isDateIncluded(date))
+ return true;
+
+ if (DateUtil.dateCompare(dateRange.startDate, date) > 0)
+ break;
+ }
+ }
+
+ return false;
+ }
+}
+}
\ No newline at end of file
Propchange: incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/DateSet.as
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/DateSet.as
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/DateUtil.as
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/DateUtil.as?rev=1370028&view=auto
==============================================================================
--- incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/DateUtil.as (added)
+++ incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/DateUtil.as Mon Aug 6 21:25:54 2012
@@ -0,0 +1,143 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package spark.components.calendarClasses
+{
+ [ExcludeClass]
+
+ import flash.events.Event;
+ import flash.events.EventDispatcher;
+
+ import mx.events.FlexEvent;
+ import mx.utils.ObjectUtil;
+
+ /**
+ * The DateUtil class contains date and time utility functions.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ public class DateUtil
+ {
+ include "../../core/Version.as";
+
+ //--------------------------------------------------------------------------
+ //
+ // Class methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Compares the fullYear, month and date properties of two dates, returning -1 if the
+ * first date is before the second, 0 if the dates are equal, or 1 if the first date
+ * is after the second.
+ * The time portion of both date is ignored.
+ *
+ * @param date1 The first date.
+ * @param date2 The second date.
+ *
+ * @returns -1 if date1 < date2, 0 if date1 = date2, 1 if date1 > date2.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ public static function dateCompare(date1:Date, date2:Date):Number
+ {
+ if (date1 == null && date2 == null)
+ return 0;
+
+ if (date1 == null)
+ return 1;
+
+ if (date2 == null)
+ return -1;
+
+ if (date1.fullYear < date2.fullYear)
+ return -1;
+ if (date1.fullYear > date2.fullYear)
+ return 1;
+
+ // Years are the same.
+ if (date1.month < date2.month)
+ return -1;
+ if (date1.month > date2.month)
+ return 1;
+
+ // Months are the same.
+ if (date1.date < date2.date)
+ return -1;
+ if (date1.date > date2.date)
+ return 1;
+
+ // Dates are the same.
+ return 0;
+ }
+
+ /**
+ * Returns <code>true</code> if day, month and fullYear of date1 are equal to day,
+ * month and fullYear of date2.
+ * The time portion of both date is ignored.
+ *
+ * @param date1 The first date.
+ * @param date2 The second date.
+ *
+ * @returns true if the dates are equal (times are ignored).
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ public static function datesEqual(date1:Date, date2:Date):Boolean
+ {
+ return (date1 == null && date2 == null) ||
+ (date1 && date2 &&
+ date1.date == date2.date && date1.month == date2.month &&
+ date1.fullYear == date2.fullYear);
+ }
+
+ /**
+ * Creates a new Date with the same date fields as <code>value</code> but the time
+ * fields (hours, minutes, seconds, milliseconds) are set to zero.
+ * This is useful if you want to compare dates.
+ *
+ * @default "now"
+ *
+ * @param value The Date.
+ *
+ * @returns A new date object with the time fields zeroed out.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ public static function scrubTimeValue(value:Date):Date
+ {
+ if (value == null)
+ value = new Date();
+
+ return new Date(value.getFullYear(), value.getMonth(), value.getDate(), 0, 0, 0, 0);
+ }
+ }
+}
\ No newline at end of file
Propchange: incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/DateUtil.as
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/DateUtil.as
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/IDateItemRenderer.as
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/IDateItemRenderer.as?rev=1370028&view=auto
==============================================================================
--- incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/IDateItemRenderer.as (added)
+++ incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/IDateItemRenderer.as Mon Aug 6 21:25:54 2012
@@ -0,0 +1,323 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package spark.components.calendarClasses
+{
+ import flash.events.IEventDispatcher;
+
+ import spark.components.MonthGrid;
+
+ import mx.core.IDataRenderer;
+ import mx.core.IInvalidating;
+ import mx.core.IVisualElement;
+ import mx.managers.ILayoutManagerClient;
+
+ /**
+ * The IDateItemRenderer interface must be implemented by DateChooser's MonthGrid item
+ * renderers.
+ * The MonthGrid uses this API to provide the item renderer with the information needed to
+ * render one day of the week or day of the month <i>cell</i> in the date grid.
+ *
+ * <p>All of the renderer's properties are set during the execution of its parent's
+ * <code>updateDisplayList()</code> method.
+ * After the properties have been set, the item renderer's <code>prepare()</code> method is
+ * called.
+ * An IDateItemRenderer implementation should override the <code>prepare()</code> method
+ * to make any final adjustments to its properties or any aspect of its visual elements.
+ * Typically, the <code>prepare()</code> is used to configure the renderer's visual
+ * elements based on the <code>data</code> property.</p>
+ *
+ * <p>When an item renderer is no longer needed, either because it's going to be added
+ * to an internal reusable renderer "free" list, or because it's never going to be
+ * used again, the IDateItemRenderer <code>discard()</code> method is called.</p>
+ *
+ * @see spark.components.DateChooser
+ * @see spark.components.calendarClasses.MonthGrid
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ public interface IDateItemRenderer extends IEventDispatcher, IDataRenderer, IVisualElement
+ {
+ /**
+ * The Date associated with this item renderer.
+ *
+ * @default null
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ function get date():Date;
+
+ /**
+ * The column index for this item renderer's cell.
+ *
+ * @default -1
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ function get columnIndex():int;
+ function set columnIndex(value:int):void;
+
+ /**
+ * The row index for this item renderer's cell.
+ *
+ * @default -1
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ function get rowIndex():int;
+ function set rowIndex(value:int):void;
+
+ /**
+ * This property is set to <code>true</code> when one of two input gestures occurs within a
+ * date cell: either the mouse button or the touch screen is pressed.
+ * The <code>down</code> property is reset to <code>false</code> when
+ * the mouse button goes up, the user lifts off
+ * the touch screen, or the mouse/touch is dragged out of the date cell.
+ *
+ * <p>Unlike a List item renderer, date item renderers do not have exclusive
+ * responsibility for displaying the down indicator. The Grid itself
+ * renders the down indicator for the selected row or cell.
+ * The item renderer can also change its visual properties to emphasize
+ * that it's being pressed.</p>
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ function get down():Boolean;
+ function set down(value:Boolean):void;
+
+ /**
+ * Contains <code>true</code> if the item renderer is being dragged,
+ * typically as part of a drag and drop operation.
+ * Currently, drag and drop is not supported by the Spark DateChooser control.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+// function get dragging():Boolean;
+// function set dragging(value:Boolean):void;
+
+ /**
+ * Contains <code>true</code> if the item renderer is under the mouse.
+ *
+ * <p>Unlike a List item renderer, date item renderers do not have exclusive
+ * responsibility for displaying something to indicate that the renderer
+ * or its row is under the mouse. The Grid itself automatically displays the
+ * hoverIndicator skin part for the hovered row or cell. date item renderers
+ * can also change their properties to emphasize that they're hovered.</p>
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ function get hovered():Boolean;
+ function set hovered(value:Boolean):void;
+
+ /**
+ * The String to display in the item renderer.
+ *
+ * <p>The DateItemRenderer class automatically copies the
+ * value of this property to the text property
+ * of its labelDisplay element, if that element was specified.
+ * If the renderer is a day of the week cell, the label is set to the value returned
+ * by formatting the date with the <code>dayOfTheWeekFormatter</code>.
+ * If the renderer is a day of the month cell, the label is set to the value returned
+ * by formatting the date with the <code>dayOfTheMonthFormatter</code>.</p>
+ *
+ * @see spark.components.gridClasses.GridItemRenderer
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ function get label():String;
+ function set label(value:String):void;
+
+ /**
+ * Contains <code>true</code> if the item renderer's cell is part
+ * of the current selection.
+ *
+ * <p> Unlike a List item renderer,
+ * date item renderers do not have exclusive responsibility for displaying
+ * something to indicate that they're part of the selection.
+ * The MonthGrid itself automatically displays the selectionIndicator skin part for the
+ * selected date cells.
+ * The item renderer can also change its visual properties to emphasize that it's part
+ * of the selection.</p>
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ function get selected():Boolean;
+ function set selected(value:Boolean):void;
+
+ /**
+ * Contains <code>true</code> if the item renderer's cell is indicated by the caret.
+ *
+ * <p> Unlike a List item renderer, date item renderers do not have exclusive
+ * responsibility for displaying something to indicate their cell or row has
+ * the caret.
+ * The MonthGrid itself automatically displays the caretIndicator skin part for the
+ * caret date cell.
+ * The item renderer can also change its visual properties to emphasize that it has the
+ * caret.</p>
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ function get showsCaret():Boolean;
+ function set showsCaret(value:Boolean):void;
+
+ /**
+ * Contains <code>true</code> if the date of the item renderer's cell can be selected.
+ * Cells which represent dates that are not in the list of the
+ * DateChooser's <code>selectableDates</code> are not enabled.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ function get enabled():Boolean;
+ function set enabled(value:Boolean):void;
+
+ /**
+ * Contains <code>true</code> if the date of the item renderer's cell is
+ * in the next month, i.e. <code>displayedMonth</code> + 1.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ function get nextMonth():Boolean;
+ function set nextMonth(value:Boolean):void;
+
+ /**
+ * Contains <code>true</code> if the date of the item renderer's cell is
+ * in the previous month, i.e. <code>displayedMonth</code> - 1.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ function get previousMonth():Boolean;
+ function set previousMonth(value:Boolean):void;
+
+ /**
+ * Contains <code>true</code> if the date of the item renderer's cell is today.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ function get today():Boolean;
+ function set today(value:Boolean):void;
+
+ /**
+ * Contains <code>true</code> if the date of the item renderer's cell is Monday through
+ * Friday.
+ * <i>Note there are locales which have a different definition of weekday and this
+ * does not currently reflect that.</i>
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ function get weekday():Boolean;
+ function set weekday(value:Boolean):void
+
+ /**
+ * Called from the item renderer parent's <code>updateDisplayList()</code> method
+ * after all of the renderer's properties have been set.
+ * The <code>hasBeenRecycled</code> parameter is <code>false</code>
+ * if this renderer has not been used before, meaning it was not recycled.
+ * This method is called when a renderer is about to become visible
+ * and each time it's redisplayed because of a change in a renderer
+ * property, or because a redisplay was explicitly requested.
+ *
+ * <p>This method can be used to configure all of a renderer's visual
+ * elements and properties.
+ * Using this method can be more efficient than binding <code>data</code>
+ * properties to visual element properties.
+ * Note: Because the <code>prepare()</code> method is called frequently,
+ * make sure that it is coded efficiently.</p>
+ *
+ * <p>The <code>prepare()</code> method may be called many times
+ * before the <code>discard()</code> method is called.</p>
+ *
+ * <p>This method is not intended to be called directly.
+ * It is called by the MonthGrid implementation.</p>
+ *
+ * @param hasBeenRecycled <code>true</code> if this renderer is being reused.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ function prepare(hasBeenRecycled:Boolean):void;
+
+ /**
+ * Called from the item renderer parent's <code>updateDisplayList()</code> method
+ * when it has been determined that this renderer will no longer be visible.
+ * If the <code>willBeRecycled</code> parameter is <code>true</code>,
+ * then the owner adds this renderer to its internal free list for reuse.
+ * Implementations can use this method to clear any renderer properties that are
+ * no longer needed.
+ *
+ * <p>This method is not intended to be called directly.
+ * It is called by the MonthGrid implementation.</p>
+ *
+ * @param willBeRecycled <code>true</code> if this renderer is going to be added
+ * to the owner's internal free list for reuse.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ function discard(willBeRecycled:Boolean):void;
+ }
+}
\ No newline at end of file
Propchange: incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/IDateItemRenderer.as
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/IDateItemRenderer.as
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/IMonthGridVisualElement.as
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/IMonthGridVisualElement.as?rev=1370028&view=auto
==============================================================================
--- incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/IMonthGridVisualElement.as (added)
+++ incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/IMonthGridVisualElement.as Mon Aug 6 21:25:54 2012
@@ -0,0 +1,95 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package spark.components.calendarClasses
+{
+
+import spark.components.DateChooser;
+import spark.components.MonthGrid;
+
+/**
+ * This interface provides a method that dynamically created visual
+ * elements in the date selector can use to configure themselves before they're displayed.
+ * It's called as needed when a factory generated visual element
+ * is created or reused. It is not intended to be called directly.
+ *
+ * <p>This is an optional interface for all of the factory-generated
+ * visual elements: <code>columnSeparator</code>, <code>hoverIndicator</code>,
+ * <code>rowSeparator</code>, <code>selectionIndicator</code>, and <code>todayIndicator</code>.
+ * It's typically used to configure generated visual elements with
+ * DateChooser's style values. For example, to use the value of the
+ * DateChooser's "todayColor" style for the today indicator's fill color,
+ * one would define the <code>prepareDateVisualElement()</code>
+ * method like this:</p>
+ *
+ * <p>
+ * <pre>
+ * public function prepareDateSelectorVisualElement(monthGrid:MonthGrid):void
+ * {
+ * todayIndicatorFill.color = monthGrid.getStyle("todayColor");
+ * }
+ * </pre>
+ * </p>
+ *
+ * <p>There are many more examples like this in DateChooserSkin.mxml.
+ * Note that custom DateChooser skin visual elements can choose not to implement this interface
+ * if the the added flexibility isn't needed.</p>
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+public interface IMonthGridVisualElement
+{
+ /**
+ * This method is called before a visual element of the MonthGrid is rendered to give the
+ * element a chance to configure itself.
+ *
+ * <p>The <code>rowIndex</code> and <code>columnIndex</code> parameters specify the
+ * the cell the visual element will occupy. If <code>columnIndex</code> = -1 then the visual
+ * element occupies a row. If <code>rowIndex</code> = -1 then the visual element occupies
+ * a column.
+ * If the visual element is a separator, it is before the renderer at the given
+ * <code>rowIndex</code> or <code>columnIndex</code>.</p>
+ *
+ * The method's parameters specify what
+ * row (if columnIndex = -1), or column (if rowIndex = -1) the visual element will occupy.
+ *
+ * <p>If the visual element is generated by a factory valued
+ * DateChooser skin part, like selectionIndicator or hoverIndicator,
+ * then <code>monthGrid.dateChooser</code> will be the DateChooser for which
+ * monthGrid is a skin part.</p>
+ *
+ * <p>You can use <code>monthGrid.getDateItemRenderer(rowIndex, columnIndex)</code> to
+ * access the renderer at this location.</p>
+ *
+ * @param monthGrid The MonthGrid associated with this visual element.
+ * @param rowIndex The row coordinate of the cell the visual element will occupy, or -1
+ * @param columnIndex The column coordinate of the cell the visual element will occupy, or -1
+ *
+ * @langversion 3.0
+ * @playerversion Flash 11
+ * @playerversion AIR 3.0
+ * @productversion Flex 5.0
+ */
+ function prepareMonthGridVisualElement(monthGrid:MonthGrid, rowIndex:int, columnIndex:int):void;
+
+}
+}
\ No newline at end of file
Propchange: incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/IMonthGridVisualElement.as
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/IMonthGridVisualElement.as
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/MonthArrayList.as
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/MonthArrayList.as?rev=1370028&view=auto
==============================================================================
--- incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/MonthArrayList.as (added)
+++ incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/MonthArrayList.as Mon Aug 6 21:25:54 2012
@@ -0,0 +1,111 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package spark.components.calendarClasses
+{
+ import mx.collections.ArrayList;
+ import mx.collections.IList;
+ import mx.core.mx_internal;
+
+ import spark.components.DateChooser;
+ import spark.components.calendarClasses.*;
+ import spark.globalization.supportClasses.DateTimeFormatterEx;
+
+ use namespace mx_internal;
+
+ [ExcludeClass]
+
+ /**
+ * The MonthArrayList class is a customized subclass of ArrayList is
+ * used as the dataProvider for the DateChooser's dataGroup.
+ * It enables the dataGroup to virtualize the displayable months by mapping between
+ * the month and fullYear of a Date and an index in the ArrayList.
+ *
+ * This class should not be accessed directly.
+ * All accesses should be through the DateChooser's dataGroup.
+ */
+ public class MonthArrayList extends ArrayList implements IList
+ {
+ public function MonthArrayList(source:Array=null)
+ {
+ super(source);
+ }
+
+ private static const minDate:Date = DateChooser.MIN_DATE;
+ private static const maxDate:Date = DateChooser.MAX_DATE;
+ private static const minYear:int = DateChooser.MIN_DATE.fullYear;
+ private static const maxYear:int = DateChooser.MAX_DATE.fullYear;
+
+ /**
+ * @private
+ * Assumes Gregorian calendar with 12 months.
+ */
+ static public function indexToDate(index:int):Date
+ {
+ var year:int = index / 12 + minYear;
+ var month:int = index - ((year - minYear) * 12);
+
+ return new Date(year, month);
+ }
+
+ /**
+ * @private
+ * Assumes Gregorian calendar with 12 months.
+ */
+ static public function dateToIndex(date:Date):int
+ {
+ if (date == null || date.time < minDate.time || date.time > maxDate.time)
+ return -1;
+
+ return (date.fullYear - minYear) * 12 + date.month;
+ }
+
+ [Bindable("collectionChange")]
+
+ /**
+ * @private
+ * Assumes Gregorian calendar with 12 months.
+ */
+ override public function get length():int
+ {
+ return (maxYear - minYear + 1) * 12;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Overridden Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ */
+ override public function getItemAt(index:int, prefetch:int = 0):Object
+ {
+ if (index < 0 || index >= length)
+ return super.getItemAt(index, prefetch);
+
+ if (source[index] === undefined)
+ source[index] = indexToDate(index);
+
+ return source[index];
+ }
+ }
+
+}
\ No newline at end of file
Propchange: incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/MonthArrayList.as
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/flex/whiteboard/cframpton/adobe.next/frameworks/projects/spark/src/spark/components/calendarClasses/MonthArrayList.as
------------------------------------------------------------------------------
svn:mime-type = text/plain