Repository: flex-asjs
Updated Branches:
  refs/heads/develop e28de643d -> 2053d408b


Added DateChooserList to hold the days of the month.


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/a05642bc
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/a05642bc
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/a05642bc

Branch: refs/heads/develop
Commit: a05642bc6aedac110b90b9e06a00d176e0954442
Parents: a261075
Author: Peter Ent <[email protected]>
Authored: Mon Dec 12 11:28:18 2016 -0500
Committer: Peter Ent <[email protected]>
Committed: Mon Dec 12 11:28:18 2016 -0500

----------------------------------------------------------------------
 .../projects/HTML/src/main/flex/HTMLClasses.as  |   1 +
 .../flex/org/apache/flex/html/DateChooser.as    |   1 -
 .../apache/flex/html/beads/DateChooserView.as   | 202 +++++++++----------
 .../controllers/DateChooserMouseController.as   |  20 +-
 .../flex/html/supportClasses/DateChooserList.as |  38 ++++
 .../HTML/src/main/resources/basic-manifest.xml  |   1 +
 .../HTML/src/main/resources/defaults.css        |  11 +
 7 files changed, 158 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a05642bc/frameworks/projects/HTML/src/main/flex/HTMLClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/HTMLClasses.as 
b/frameworks/projects/HTML/src/main/flex/HTMLClasses.as
index 23a48a5..ba565a5 100644
--- a/frameworks/projects/HTML/src/main/flex/HTMLClasses.as
+++ b/frameworks/projects/HTML/src/main/flex/HTMLClasses.as
@@ -175,6 +175,7 @@ internal class HTMLClasses
        import org.apache.flex.html.supportClasses.DateChooserButton; 
DateChooserButton;
        import org.apache.flex.html.supportClasses.DateHeaderButton; 
DateHeaderButton;
        import org.apache.flex.html.supportClasses.GraphicsItemRenderer; 
GraphicsItemRenderer;
+       import org.apache.flex.html.supportClasses.DateChooserList; 
DateChooserList;
 
     import org.apache.flex.html.beads.TitleBarView; TitleBarView;
     import org.apache.flex.html.beads.TitleBarMeasurementBead; 
TitleBarMeasurementBead;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a05642bc/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DateChooser.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DateChooser.as 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DateChooser.as
index 62b5a3e..ff5ef28 100644
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DateChooser.as
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/DateChooser.as
@@ -47,7 +47,6 @@ package org.apache.flex.html
                public function DateChooser()
                {
                        super();
-                       className = "DateChooser";
 
                        // fix the DateChooser's size
                        width = 280;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a05642bc/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DateChooserView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DateChooserView.as
 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DateChooserView.as
index a88c767..5b5dbb5 100644
--- 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DateChooserView.as
+++ 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/DateChooserView.as
@@ -28,11 +28,12 @@ package org.apache.flex.html.beads
        import org.apache.flex.events.Event;
        import org.apache.flex.events.IEventDispatcher;
        import org.apache.flex.html.Container;
+       import org.apache.flex.html.List;
        import org.apache.flex.html.TextButton;
        import org.apache.flex.html.beads.layouts.TileLayout;
        import org.apache.flex.html.beads.models.DateChooserModel;
-       import org.apache.flex.html.supportClasses.DateChooserButton;
        import org.apache.flex.html.supportClasses.DateHeaderButton;
+       import org.apache.flex.html.supportClasses.DateChooserList;
 
        /**
         * The DateChooserView class is a view bead for the DateChooser. This 
class
@@ -54,43 +55,34 @@ package org.apache.flex.html.beads
                {
                }
                
-               /**
-                *  @copy org.apache.flex.core.IBead#strand
-                *
-                *  @langversion 3.0
-                *  @playerversion Flash 10.2
-                *  @playerversion AIR 2.6
-                *  @productversion FlexJS 0.0
-                */
                override public function set strand(value:IStrand):void
                {
                        super.strand = value;
-                       _strand = value;
-
-                       // make sure there is a model.
+                       
                        model = _strand.getBeadByType(IBeadModel) as 
DateChooserModel;
                        if (model == null) {
                                model = new 
(ValuesManager.valuesImpl.getValue(_strand,"iBeadModel")) as DateChooserModel;
                        }
                        
model.addEventListener("displayedMonthChanged",handleModelChange);
                        
model.addEventListener("displayedYearChanged",handleModelChange);
-
+                       
                        var host:UIBase = value as UIBase;
                        host.addEventListener("widthChanged", handleSizeChange);
                        host.addEventListener("heightChanged", 
handleSizeChange);
-
+                       
                        createChildren();
                        layoutContents();
                }
-
+               
+               private var model:DateChooserModel;
+               
                private var _prevMonthButton:DateHeaderButton;
                private var _nextMonthButton:DateHeaderButton;
-               private var _dayButtons:Array;
                private var monthLabel:DateHeaderButton;
-               private var dayContainer:Container;
-
-               private var model:DateChooserModel;
-
+               private var daysContainer:List;
+               
+               private var _dayNames:Array;
+               
                /**
                 *  The button that causes the previous month to be displayed 
by the DateChooser.
                 *
@@ -103,7 +95,7 @@ package org.apache.flex.html.beads
                {
                        return _prevMonthButton;
                }
-
+               
                /**
                 *  The button that causes the next month to be displayed by 
the DateChooser.
                 *
@@ -116,48 +108,27 @@ package org.apache.flex.html.beads
                {
                        return _nextMonthButton;
                }
-
+               
+               public function get dayList():List
+               {
+                       return daysContainer;
+               }
+               
                /**
                 * The array of DateChooserButton instances that represent each 
day of the month.
                 */
-               public function get dayButtons():Array
+               
+               public function get dayNames():Array
                {
-                       return _dayButtons;
+                       return _dayNames;
                }
-
+               
                private function handleSizeChange(event:Event):void
                {
                        layoutContents();
                }
-
-               private function layoutContents():void
-               {
-                       var sw:Number = UIBase(_strand).width;
-                       var sh:Number = UIBase(_strand).height;
-
-                       _prevMonthButton.x = 0;
-                       _prevMonthButton.y = 0;
-
-                       _nextMonthButton.x = sw - _nextMonthButton.width;
-                       _nextMonthButton.y = 0;
-
-                       monthLabel.x = _prevMonthButton.x + 
_prevMonthButton.width;
-                       monthLabel.y = 0;
-                       monthLabel.width = sw - _prevMonthButton.width - 
_nextMonthButton.width;
-
-                       dayContainer.x = 0;
-                       dayContainer.y = monthLabel.y + monthLabel.height + 4;
-                       dayContainer.width = sw;
-                       dayContainer.height = sh - (monthLabel.height+5);
-                       
-                       COMPILE::SWF {
-                               displayBackgroundAndBorder(_strand as UIBase);
-                       }
-
-                       IEventDispatcher(_strand).dispatchEvent( new 
Event("layoutNeeded") );
-                       IEventDispatcher(dayContainer).dispatchEvent( new 
Event("layoutNeeded") );
-               }
-
+               
+               
                /**
                 * @private
                 */
@@ -168,49 +139,70 @@ package org.apache.flex.html.beads
                        _prevMonthButton.height = 20;
                        _prevMonthButton.text = "<";
                        UIBase(_strand).addElement(_prevMonthButton);
-
+                       
                        _nextMonthButton = new DateHeaderButton();
                        _nextMonthButton.width = 40;
                        _nextMonthButton.height = 20;
                        _nextMonthButton.text = ">";
                        UIBase(_strand).addElement(_nextMonthButton);
-
+                       
                        monthLabel = new DateHeaderButton();
                        monthLabel.text = "Month Here";
                        monthLabel.width = 100;
                        monthLabel.height = 20;
                        UIBase(_strand).addElement(monthLabel);
-
-                       dayContainer = new Container();
-                       dayContainer.className = "DayContainer";
-                       var tileLayout:TileLayout = new TileLayout();
-                       dayContainer.addBead(tileLayout);
-            UIBase(_strand).addElement(dayContainer, false);
-
-                       tileLayout.numColumns = 7;
-
+                       
+                       daysContainer = new DateChooserList();
+                       UIBase(_strand).addElement(daysContainer, false);
+                       
+                       //tileLayout.numColumns = 7;
+                       
+                       _dayNames = new Array();
+                       
                        // the calendar has 7 columns with 6 rows, the first 
row are the day names
                        for(var i:int=0; i < 7; i++) {
-                               var dayName:DateChooserButton = new 
DateChooserButton();
-                               dayName.text = model.dayNames[i];
-                               dayName.dayOfMonth = 0;
-                               dayContainer.addElement(dayName, false);
+                               dayNames.push(model.dayNames[i]);
                        }
-
-                       _dayButtons = new Array();
-
+                       
                        for(i=0; i < 42; i++) {
-                               var date:DateChooserButton = new 
DateChooserButton();
-                               date.text = String(i+1);
-                               dayContainer.addElement(date, false);
-                               dayButtons.push(date);
+                               dayNames.push(String(i+1));
                        }
-
-                       IEventDispatcher(dayContainer).dispatchEvent( new 
Event("itemsCreated") );
-
+                       
+                       IEventDispatcher(daysContainer).dispatchEvent( new 
Event("itemsCreated") );
+                       
                        updateCalendar();
                }
-
+               
+               private function layoutContents():void
+               {
+                       var sw:Number = UIBase(_strand).width;
+                       var sh:Number = UIBase(_strand).height;
+                       
+                       _prevMonthButton.x = 0;
+                       _prevMonthButton.y = 0;
+                       
+                       _nextMonthButton.x = sw - _nextMonthButton.width;
+                       _nextMonthButton.y = 0;
+                       
+                       monthLabel.x = _prevMonthButton.x + 
_prevMonthButton.width;
+                       monthLabel.y = 0;
+                       monthLabel.width = sw - _prevMonthButton.width - 
_nextMonthButton.width;
+                       
+                       daysContainer.x = 0;
+                       daysContainer.y = monthLabel.y + monthLabel.height + 4;
+                       daysContainer.width = sw;
+                       daysContainer.height = sh - (monthLabel.height+5);
+                       
+                       daysContainer.dataProvider = dayNames;
+                       
+                       COMPILE::SWF {
+                               displayBackgroundAndBorder(_strand as UIBase);
+                       }
+                       
+                       IEventDispatcher(_strand).dispatchEvent( new 
Event("layoutNeeded") );
+                       IEventDispatcher(daysContainer).dispatchEvent( new 
Event("layoutNeeded") );
+               }
+               
                /**
                 * @private
                 */
@@ -218,52 +210,40 @@ package org.apache.flex.html.beads
                {
                        monthLabel.text = 
model.monthNames[model.displayedMonth] + " " +
                                String(model.displayedYear);
-
+                       
                        var firstDay:Date = new 
Date(model.displayedYear,model.displayedMonth,1);
-
+                       
                        // blank out the labels for the first firstDay.day-1 
entries.
                        for(var i:int=0; i < firstDay.getDay(); i++) {
-                               var dateButton:DateChooserButton = 
dayButtons[i] as DateChooserButton;
-                               dateButton.dayOfMonth = -1;
-                               dateButton.text = "";
+                               dayNames[i+7] = "";
                        }
-
+                       
                        // flag today
                        var today:Date = new Date();
-
+                       
                        // renumber to the last day of the month
                        var dayNumber:int = 1;
                        var numDays:Number = 
numberOfDaysInMonth(model.displayedMonth, model.displayedYear);
-
-                       for(; i < dayButtons.length && dayNumber <= numDays; 
i++) {
-                               dateButton = dayButtons[i] as DateChooserButton;
-                               dateButton.dayOfMonth = dayNumber;
-                               dateButton.text = String(dayNumber++);
-
-                               if (model.displayedMonth == today.getMonth() &&
-                                   model.displayedYear == today.getFullYear() 
&&
-                                   (dayNumber-1) == today.getDate()) {
-                                   dateButton.id = "todayDateChooserButton";
-                               } else {
-                                       dateButton.id = "";
-                               }
+                       
+                       for(; i < dayNames.length-7 && dayNumber <= numDays; 
i++) {
+                               dayNames[i+7] = String(dayNumber++);
                        }
-
+                       
                        // blank out the rest
-                       for(; i < dayButtons.length; i++) {
-                               dateButton = dayButtons[i] as DateChooserButton;
-                               dateButton.dayOfMonth = -1;
-                               dateButton.text = "";
+                       for(; i < dayNames.length-7; i++) {
+                               dayNames[i+7] = "";
                        }
+                       
+                       daysContainer.dataProvider = dayNames;
                }
-
+               
                /**
                 * @private
                 */
                private function numberOfDaysInMonth(month:Number, 
year:Number):Number
                {
                        var n:int;
-
+                       
                        if (month == 1) // Feb
                        {
                                if (((year % 4 == 0) && (year % 100 != 0)) || 
(year % 400 == 0)) // leap year
@@ -271,16 +251,16 @@ package org.apache.flex.html.beads
                                else
                                        n = 28;
                        }
-
+                               
                        else if (month == 3 || month == 5 || month == 8 || 
month == 10)
                                n = 30;
-
+                               
                        else
                                n = 31;
-
+                       
                        return n;
                }
-
+               
                /**
                 * @private
                 */

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a05642bc/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/controllers/DateChooserMouseController.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/controllers/DateChooserMouseController.as
 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/controllers/DateChooserMouseController.as
index 26c17fe..1b8b86b 100644
--- 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/controllers/DateChooserMouseController.as
+++ 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/controllers/DateChooserMouseController.as
@@ -21,6 +21,7 @@ package org.apache.flex.html.beads.controllers
        import org.apache.flex.html.beads.DateChooserView;
        import org.apache.flex.html.beads.models.DateChooserModel;
        import org.apache.flex.html.supportClasses.DateChooserButton;
+       import org.apache.flex.html.supportClasses.DateChooserList;
        
        import org.apache.flex.core.IBeadController;
        import org.apache.flex.core.IBeadModel;
@@ -72,10 +73,11 @@ package org.apache.flex.html.beads.controllers
                        view.prevMonthButton.addEventListener("click", 
prevMonthClickHandler);
                        view.nextMonthButton.addEventListener("click", 
nextMonthClickHandler);
                        
-                       var dayButtons:Array = view.dayButtons;
-                       for(var i:int=0; i < dayButtons.length; i++) {
-                               
IEventDispatcher(dayButtons[i]).addEventListener("click", 
dayButtonClickHandler);
-                       }
+                       
IEventDispatcher(view.dayList).addEventListener("change", listHandler);
+//                     var dayButtons:Array = view.dayButtons;
+//                     for(var i:int=0; i < dayButtons.length; i++) {
+//                             
IEventDispatcher(dayButtons[i]).addEventListener("click", 
dayButtonClickHandler);
+//                     }
                }
                
                /**
@@ -110,6 +112,16 @@ package org.apache.flex.html.beads.controllers
                        model.displayedYear = year;
                }
                
+               private function listHandler(event:Event):void
+               {
+                       var list:DateChooserList = event.target as 
DateChooserList;
+                       var model:DateChooserModel = 
_strand.getBeadByType(IBeadModel) as DateChooserModel;
+                       var newDate:Date = new 
Date(model.displayedYear,model.displayedMonth,list.selectedIndex-7);
+                       
+                       model.selectedDate = newDate;
+                       IEventDispatcher(_strand).dispatchEvent( new 
Event("change") );
+               }
+               
                /**
                 * @private
                 */

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a05642bc/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DateChooserList.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DateChooserList.as
 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DateChooserList.as
new file mode 100644
index 0000000..75c32e1
--- /dev/null
+++ 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/supportClasses/DateChooserList.as
@@ -0,0 +1,38 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 org.apache.flex.html.supportClasses
+{
+       import org.apache.flex.html.List;
+       import org.apache.flex.html.supportClasses.Viewport;
+       import org.apache.flex.html.beads.layouts.TileLayout;
+       
+       public class DateChooserList extends List
+       {
+               public function DateChooserList()
+               {
+                       super();
+                       
+                       addBead(new Viewport());
+                       
+                       var tileLayout:TileLayout = new TileLayout();
+                       tileLayout.numColumns = 7;
+                       addBead(tileLayout);
+               }
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a05642bc/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/resources/basic-manifest.xml 
b/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
index 36570e5..2bc645d 100644
--- a/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
@@ -122,6 +122,7 @@
     <component id="TextItemRendererFactoryForStringVectorData" 
class="org.apache.flex.html.beads.TextItemRendererFactoryForStringVectorData" />
 
     <component id="DateChooser" class="org.apache.flex.html.DateChooser"/>
+    <component id="DateChooserList" 
class="org.apache.flex.html.supportClasses.DateChooserList" />
     <component id="DateField" class="org.apache.flex.html.DateField"/>
     <component id="VerticalColumnLayout" 
class="org.apache.flex.html.beads.layouts.VerticalColumnLayout" />
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a05642bc/frameworks/projects/HTML/src/main/resources/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/resources/defaults.css 
b/frameworks/projects/HTML/src/main/resources/defaults.css
index 2f88cca..667c0fd 100644
--- a/frameworks/projects/HTML/src/main/resources/defaults.css
+++ b/frameworks/projects/HTML/src/main/resources/defaults.css
@@ -201,6 +201,17 @@ DateChooser {
        height: 240px;
 }
 
+DateChooserList {
+       IDataProviderItemRendererMapper: 
ClassReference("org.apache.flex.html.beads.TextItemRendererFactoryForArrayData");
+       IItemRendererClassFactory: 
ClassReference("org.apache.flex.core.ItemRendererClassFactory");
+       IItemRenderer: 
ClassReference("org.apache.flex.html.supportClasses.StringItemRenderer");
+       border-style: solid;
+       border-radius: 4px;
+       border-color: #0000DD;
+       border-width: 1px;
+       background-color: #DDDDFF;
+}
+
 DateField {
        IBeadView:   ClassReference("org.apache.flex.html.beads.DateFieldView");
        IBeadModel:  
ClassReference("org.apache.flex.html.beads.models.DateChooserModel");

Reply via email to