[jfxcalendarpicker~source-code-repository:40] in the middle of introducing JFXtras for the control skin; the pickers an

  • From: tbee@kenai.com
  • To: commits@jfxcalendarpicker.kenai.com
  • Subject: [jfxcalendarpicker~source-code-repository:40] in the middle of introducing JFXtras for the control skin; the pickers an
  • Date: Thu, 1 Oct 2009 18:11:17 +0000

Project:    jfxcalendarpicker
Repository: source-code-repository
Revision:   40
Author:     tbee
Date:       2009-10-01 18:11:16 UTC
Link:       

Log Message:
------------
in the middle of introducing JFXtras for the control skin; the pickers and 
MigLayout


Revisions:
----------
40


Modified Paths:
---------------
JFXCalendarPicker/nbproject/genfiles.properties
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerSkin.java
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerSkinAbstract.fx
JFXCalendarPicker/nbproject/build-impl.xml
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerSkinStandard.fx
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerSkinControls.fx
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerTest.fx
JFXCalendarPicker/nbproject/project.properties
JFXCalendarPicker/nbproject/project.xml
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPicker.fx


Diffs:
------
Index: JFXCalendarPicker/nbproject/project.properties
===================================================================
--- JFXCalendarPicker/nbproject/project.properties      (revision 39)
+++ JFXCalendarPicker/nbproject/project.properties      (revision 40)
@@ -20,9 +20,17 @@
 dist.jar=${dist.dir}/JFXCalendarPicker.jar
 dist.javadoc.dir=${dist.dir}/javadoc
 excludes=
+file.reference.JFXtras-0.5-controls.jar=lib/JFXtras-0.5-controls.jar
+file.reference.JFXtras-0.5.jar=lib/JFXtras-0.5.jar
+file.reference.jfxtras-common.jar=lib/jfxtras-common.jar
+file.reference.miglayout-3.7.1.jar=lib/miglayout-3.7.1.jar
+file.reference.miglayout-3.7.jar=lib/miglayout-3.7.jar
 includes=**
 jar.compress=true
-javac.classpath=
+javac.classpath=\
+    ${file.reference.JFXtras-0.5-controls.jar}:\
+    ${file.reference.miglayout-3.7.1.jar}:\
+    ${reference.JFXtras_Core.jar}
 # Space-separated list of extra javac options
 javac.compilerargs=
 javac.deprecation=false
@@ -42,6 +50,8 @@
 main.class=nl.innovationinvestments.javafx.control.CalendarPickerTest
 pack200.jar.compress=true
 platform.active=default_fx_platform
+project.JFXtras_Core=../../jfxtras.core/trunk/common
+reference.JFXtras_Core.jar=${project.JFXtras_Core}/dist/jfxtras-common.jar
 run.classpath=\
     ${javac.classpath}:\
     ${build.classes.dir}
Index: JFXCalendarPicker/nbproject/project.xml
===================================================================
--- JFXCalendarPicker/nbproject/project.xml     (revision 39)
+++ JFXCalendarPicker/nbproject/project.xml     (revision 40)
@@ -9,5 +9,15 @@
                 <root id="src.dir"/>
             </source-roots>
         </data>
+        <references 
xmlns="http://www.netbeans.org/ns/ant-project-references/1";>
+            <reference>
+                <foreign-project>JFXtras_Core</foreign-project>
+                <artifact-type>jar</artifact-type>
+                <script>build.xml</script>
+                <target>jar</target>
+                <clean-target>clean</clean-target>
+                <id>jar</id>
+            </reference>
+        </references>
     </configuration>
 </project>
Index: JFXCalendarPicker/nbproject/genfiles.properties
===================================================================
--- JFXCalendarPicker/nbproject/genfiles.properties     (revision 39)
+++ JFXCalendarPicker/nbproject/genfiles.properties     (revision 40)
@@ -1,8 +1,8 @@
-build.xml.data.CRC32=f8b62926
+build.xml.data.CRC32=acade8be
 build.xml.script.CRC32=2a413adb
 build.xml.stylesheet.CRC32=bdec6f99@1.8.1
 # This file is used by a NetBeans-based IDE to track changes in generated 
files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never 
regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=f8b62926
-nbproject/build-impl.xml.script.CRC32=a13f0fca
+nbproject/build-impl.xml.data.CRC32=acade8be
+nbproject/build-impl.xml.script.CRC32=229f056a
 nbproject/build-impl.xml.stylesheet.CRC32=e7782709@1.8.1
Index: JFXCalendarPicker/nbproject/build-impl.xml
===================================================================
--- JFXCalendarPicker/nbproject/build-impl.xml  (revision 39)
+++ JFXCalendarPicker/nbproject/build-impl.xml  (revision 40)
@@ -134,7 +134,9 @@
                     COMPILATION SECTION
                     ===================
     -->
-    <target depends="init" name="deps-jar" unless="no.deps"/>
+    <target depends="init" name="deps-jar" unless="no.deps">
+        <ant antfile="${project.JFXtras_Core}/build.xml" inheritall="false" 
target="jar"/>
+    </target>
     <target name="-pre-compile">
         <!-- Empty placeholder for easier customization.-->
         <!-- You can override this target in the ../build.xml file.-->
Index: 
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPicker.fx
===================================================================
--- 
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPicker.fx
     (revision 39)
+++ 
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPicker.fx
     (revision 40)
@@ -54,7 +54,7 @@
                        // modify the range
                        
//CalendarPickerSkinControls.printlnCalendar("calendar on replace: updating 
range", calendar);
                        calendars = [calendar];
-                       (skin as CalendarPickerSkin).refresh();
+                       (skin as CalendarPickerSkin).refresh_calendar();
                }
        };
 
@@ -75,7 +75,7 @@
                        {
                                // set calendar to the first value in the 
range
                                calendar = calendars[0];
-                               (skin as CalendarPickerSkin).refresh();
+                               (skin as 
CalendarPickerSkin).refresh_calendar();
                        }
                }
        };
Index: 
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerTest.fx
===================================================================
--- 
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerTest.fx
 (revision 39)
+++ 
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerTest.fx
 (revision 40)
@@ -119,7 +119,7 @@
                }
        }
 };
-skinComboBox.select(0);
+skinComboBox.select(1);
 
 
 
Index: 
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerSkinStandard.fx
===================================================================
--- 
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerSkinStandard.fx
 (revision 39)
+++ 
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerSkinStandard.fx
 (revision 40)
@@ -176,8 +176,13 @@
        /**
         * accumulate refresh calls
         */
-       override public function refresh() : Void
+       override public function refresh_calendar() : Void
        {
+               refresh_context();
+       }
+
+       override public function refresh_context() : Void
+       {
                //println("refresh();");
                iRefreshTimeline.playFromStart();
        }
@@ -196,7 +201,6 @@
                }
        ]};
 
-
        public function refreshActual() : Void
        {
                //println("refreshActual();");
@@ -318,6 +322,7 @@
                // set header
                headerLabel.text = "{getMonthName()} 
{calendar.get(java.util.Calendar.YEAR)}";
        }
+
        public function refreshPlaceHeader() : Void
        {
                // set header
Index: 
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerSkin.java
===================================================================
--- 
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerSkin.java
       (revision 39)
+++ 
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerSkin.java
       (revision 40)
@@ -12,4 +12,6 @@
 public interface CalendarPickerSkin
 {
        public void refresh();
+       public void refresh_calendar();
+       public void refresh_context();
 }
Index: 
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerSkinAbstract.fx
===================================================================
--- 
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerSkinAbstract.fx
 (revision 39)
+++ 
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerSkinAbstract.fx
 (revision 40)
@@ -26,7 +26,7 @@
        {
                // allways 1st of the month (no problems with a possible 30th 
februari)
                calendar.set(java.util.Calendar.DATE, 1);
-               refresh()
+               refresh_calendar()
        }
        ;
 
@@ -50,7 +50,7 @@
                        // change the formatter
                        simpleDateFormat = 
(java.text.SimpleDateFormat.getDateInstance(java.text.SimpleDateFormat.LONG, 
locale) as java.text.SimpleDateFormat);
 
-                       // refresh
+                       // refresh all (a change in context may have 
consequence on how a calendar is visualized)
                        refresh();
                }
        }
@@ -63,9 +63,16 @@
        // create the behavior that comes with this control
        override protected var behavior = CalendarPickerBehavior{};
 
-       // to be implemented by the actual skin
-       // TODO: split refresh into a locale related and calendar related 
part?
-       abstract override public function refresh() : Void;
+       // refresh all
+       override public function refresh() : Void
+       {
+               refresh_context();
+               refresh_calendar();
+       }
+       // refresh because the calendar has changed
+       abstract override public function refresh_calendar() : Void;
+       // refresh because the context has changed
+       abstract override public function refresh_context() : Void;
 
 
        // 
===========================================================================================
Index: 
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerSkinControls.fx
===================================================================
--- 
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerSkinControls.fx
 (revision 39)
+++ 
JFXCalendarPicker/src/nl/innovationinvestments/javafx/control/CalendarPickerSkinControls.fx
 (revision 40)
@@ -9,7 +9,12 @@
 import javafx.scene.layout.*;
 import javafx.scene.paint.*;
 import javafx.scene.effect.*;
-import nl.innovationinvestments.javafx.control.ComboBox;
+import org.jfxtras.scene.control.*;
+import org.jfxtras.scene.layout.MigLayout;
+import javafx.scene.Group;
+import net.miginfocom.layout.CC;
+import javafx.scene.shape.Rectangle;
+import net.miginfocom.layout.LC;
 
 /**
  * @author Tom Eugelink
@@ -23,7 +28,7 @@
        // maximum 6 week each with 7 buttons
        var buttons : ToggleButton[] = for (i in [0..(6*7)-1]) ToggleButton
        {
-               text: "btn{i}"
+               text: "?"
                onMouseClicked: function (mouseEvent): Void { 
clicked(buttons[i].text, mouseEvent.shiftDown, mouseEvent.controlDown);  }
        };
 
@@ -34,70 +39,40 @@
        var dayLabels : Label[] = for (i in [0..6]) Label { text: "dy{i}" };
 
        // month
-       var monthComboBox : ComboBox = ComboBox { items: [ for (i in [0..11]) 
"mnth{i}" ] };
-       var monthSelectedIndexChanged = bind monthComboBox.selectedIndex // 
on change event
-       on replace
-       {
-               // update the calendar
-               if (monthComboBox.selectedIndex >= 0)
-               {
-                       calendar.set(java.util.Calendar.MONTH, 
monthComboBox.selectedIndex);
-                       refresh();
-               }
-       };
-       var monthPrevButton : Button = Button { text: "<", action: 
function(): Void
-       {
-               if (monthComboBox.selectedIndex > 0) { 
monthComboBox.selectPreviousRow();  }
-               else
-               {
-                       var lYear = 
java.lang.Integer.parseInt(yearTextBox.text);
-                       calendar.set(java.util.Calendar.YEAR, lYear - 1);
-                       calendar.set(java.util.Calendar.MONTH, 11);
-                       refresh();
-               }
-       }};
-       var monthNextButton : Button = Button { text: ">", action: 
function(): Void
-       {
-               if (monthComboBox.selectedIndex < 11) { 
monthComboBox.selectNextRow(); }
-               else
-               {
-                       var lYear = 
java.lang.Integer.parseInt(yearTextBox.text);
-                       calendar.set(java.util.Calendar.YEAR, lYear + 1);
-                       calendar.set(java.util.Calendar.MONTH, 0);
-                       refresh();
-               }
-       }};
+       var monthPicker = Picker
+       { pickerType: PickerType.SIDE_SCROLL
+    , dropDown: true
+    , cyclic: true
+    , items: [ "January", "February", "March", "April", "May", "June", 
"July", "August", "September", "October", "November", "December" ]
+    };
+       // detect changed selected item
+       var monthPickerSelectedIndex: Integer = bind 
monthPicker.selectedIndex on replace
+    {
+               calendar.set(java.util.Calendar.MONTH, 
monthPickerSelectedIndex);
+               refresh_calendar();
+    };
+       // detect if we cycle end->begin or vice versa and update the year 
accordingly
+       var monthPickerCycleChange: Integer = bind monthPicker.cycleChange on 
replace
+    {
+               yearPicker.select(yearPicker.selectedIndex + 
monthPicker.cycleChange);
+    };
 
        // year
-       var yearTextBox = TextBox { text: "year" };
-       var yearTextBoxFocus = bind yearTextBox.focused
-       on replace
-       {
-               // only on focus lost
-               if (yearTextBoxFocus == false)
+       var yearPicker = Picker
+       { pickerType: PickerType.SIDE_SCROLL
+       , items: [1900..2100]
+    };
+       // detect changed selected item
+       var yearPickerSelectedItem: Object = bind yearPicker.selectedItem on 
replace
+    {
+               var lYear : Integer = yearPickerSelectedItem as Integer;
+               try
                {
-                       try
-                       {
-                               var lYear = 
java.lang.Integer.parseInt(yearTextBox.text);
-                               calendar.set(java.util.Calendar.YEAR, lYear);
-                       }
-                       catch ( e :java.lang.NumberFormatException ) { /* 
ignored on purpose */ }
-                       refresh();
+                       calendar.set(java.util.Calendar.YEAR, lYear);
                }
-       }
-       ;
-       var yearPrevButton : Button = Button { text: "<", action: function(): 
Void
-       {
-               var lYear = java.lang.Integer.parseInt(yearTextBox.text);
-               calendar.set(java.util.Calendar.YEAR, lYear - 1);
-               refresh();
-       } };
-       var yearNextButton : Button = Button { text: ">", action: function(): 
Void
-       {
-               var lYear = java.lang.Integer.parseInt(yearTextBox.text);
-               calendar.set(java.util.Calendar.YEAR, lYear + 1);
-               refresh();
-       } };
+               catch ( e :java.lang.NumberFormatException ) { /* ignored on 
purpose */ }
+               refresh_calendar();
+    };
 
        // just for accessing the colors
        var dummyLabel = Label{ text: "dummy" };
@@ -105,38 +80,53 @@
        // 
===========================================================================================
        // layout
 
+       var picker = MigLayout
+       { constraints: LC{}.debug(1000)
+       , content: 
+               [ MigLayout.migNode( monthPicker, 
CC{}.skip(1).width("10px").growX().spanX(4) ), MigLayout.migNode( yearPicker, 
CC{}.width("10px").growX().spanX(3).wrap() )
+               , MigLayout.migNode( Label{}, CC{} ),                       
for (i in [0..(6-1)]) MigLayout.migNode( dayLabels[i],  CC{}.alignX("center") 
), MigLayout.migNode( dayLabels[6], CC{}.alignX("center").wrap() )
+               , MigLayout.migNode( weekLabels[0], CC{}.alignX("right") ), 
for (i in [(0*7)..(1*7)-2]) MigLayout.migNode( buttons[i], CC{} ),            
   MigLayout.migNode( buttons[(1*7)-1], CC{}.wrap() )
+               , MigLayout.migNode( weekLabels[1], CC{}.alignX("right") ), 
for (i in [(1*7)..(2*7)-2]) MigLayout.migNode( buttons[i], CC{} ),            
   MigLayout.migNode( buttons[(2*7)-1], CC{}.wrap() )
+               , MigLayout.migNode( weekLabels[2], CC{}.alignX("right") ), 
for (i in [(2*7)..(3*7)-2]) MigLayout.migNode( buttons[i], CC{} ),            
   MigLayout.migNode( buttons[(3*7)-1], CC{}.wrap() )
+               , MigLayout.migNode( weekLabels[3], CC{}.alignX("right") ), 
for (i in [(3*7)..(4*7)-2]) MigLayout.migNode( buttons[i], CC{} ),            
   MigLayout.migNode( buttons[(4*7)-1], CC{}.wrap() )
+               , MigLayout.migNode( weekLabels[4], CC{}.alignX("right") ), 
for (i in [(4*7)..(5*7)-2]) MigLayout.migNode( buttons[i], CC{} ),            
   MigLayout.migNode( buttons[(5*7)-1], CC{}.wrap() )
+               , MigLayout.migNode( weekLabels[5], CC{}.alignX("right") ), 
for (i in [(5*7)..(6*7)-2]) MigLayout.migNode( buttons[i], CC{} ),            
   MigLayout.migNode( buttons[(6*7)-1], CC{}.wrap() )
+               ]
+       };
+
+       // the outer border
+       public-init var borderTop : Color = Color.web("#95989E");
+       public-init var borderBottom : Color = Color.web("#585B61");
+       public-init var borderGradientOuterColor : Color = Color.WHITE;
+       public-init var borderGradientMiddleColor : Color = 
Color.web("#dddfe5");
+       var border : Rectangle = Rectangle 
+       { width: bind picker.width
+    , height: bind picker.height
+    , arcWidth: 10
+    , arcHeight: 10
+       , stroke: LinearGradient
+               { startX: 0.0, startY: 0.0, endX: 0.0, endY: 1.0
+               , proportional: true
+               , stops:
+                       [ Stop { offset: 0.0 color: borderTop }
+                       , Stop { offset: 1.0 color: borderBottom }
+                       ]
+               }
+    , fill: LinearGradient
+               { startX: 0.0, startY: 0.0, endX: 0.0, endY: 1.0
+               , proportional: true
+               , stops:
+                       [ Stop { offset: 0.0 color: borderGradientOuterColor }
+                       , Stop { offset: 0.4 color: borderGradientMiddleColor 
}
+                       , Stop { offset: 0.9 color: borderGradientOuterColor }
+                       ]
+               }
+    };
+
        // build scene
        init
        {
-               node =  VBox
-                               {
-                                       content:
-                                       [
-                                               HBox
-                                               {
-                                                       content:
-                                                       [ monthComboBox, 
monthPrevButton, monthNextButton
-                                                       , Label{text: "   "}
-                                                       , yearTextBox, 
yearPrevButton, yearNextButton
-                                                       ]
-                                               }
-                                       ,       Tile
-                                               {
-                                                       hgap: 2
-                                                       vgap: 2
-                                                       columns: 8
-                                                       content:
-                                                       [       Label{}      
, for (i in [0..6]) dayLabels[i]
-                                                       ,       
weekLabels[0], for (i in [(0*7)..(1*7)-1]) buttons[i]
-                                                       ,       
weekLabels[1], for (i in [(1*7)..(2*7)-1]) buttons[i]
-                                                       ,       
weekLabels[2], for (i in [(2*7)..(3*7)-1]) buttons[i]
-                                                       ,       
weekLabels[3], for (i in [(3*7)..(4*7)-1]) buttons[i]
-                                                       ,       
weekLabels[4], for (i in [(4*7)..(5*7)-1]) buttons[i]
-                                                       ,       
weekLabels[5], for (i in [(5*7)..(6*7)-1]) buttons[i]
-                                                       ]
-                                               }
-                                       ]
-                               }
+               node = Group { content: [border, picker ] }
        }
 
        // 
===========================================================================================
@@ -149,8 +139,8 @@
 
                // create the calendar
                var lCalendar = boundControl.calendar.clone() as 
java.util.Calendar;
-               lCalendar.set(java.util.Calendar.YEAR, 
java.lang.Integer.parseInt(yearTextBox.text));
-               lCalendar.set(java.util.Calendar.MONTH, 
monthComboBox.selectedIndex);
+               lCalendar.set(java.util.Calendar.YEAR, 
yearPicker.selectedItem as Integer);
+               lCalendar.set(java.util.Calendar.MONTH, 
monthPicker.selectedIndex);
                lCalendar.set(java.util.Calendar.DATE, lIdx);
 
                // set it
@@ -161,27 +151,17 @@
        // 
===========================================================================================
        // CalendarPickerSkin interface
 
-       // TODO: only refresh when something actually has changed
-       override public function refresh() : Void
+
+       override public function refresh_calendar() : Void
        {
                // year
-               var lYear = calendar.get(java.util.Calendar.YEAR);
-               yearTextBox.text = "{lYear}";
+               var lYear : Integer = calendar.get(java.util.Calendar.YEAR);
+               yearPicker.selectItem(lYear);
 
                // month
-               var lMonth = calendar.get(java.util.Calendar.MONTH);
-               monthComboBox.items = getMonthNames();
-               monthComboBox.select(lMonth);
+               var lMonth : Integer = calendar.get(java.util.Calendar.MONTH);
+               monthPicker.select(lMonth);
 
-               // setup the dayLabels
-               var lWeekdayNames = getWeekdayNames();
-               for (i in  [0..6])
-               {
-                       // assign day
-                       dayLabels[i].text = lWeekdayNames[i];
-                       dayLabels[i].textFill = if ( isWeekdayWeekend(i) ) 
Color.RED else dummyLabel.textFill; // TODO: colors customizable
-               }
-
                // setup the weekLabels
                var lWeekLabels = getWeekLabels();
                for (i in [0..5])
@@ -233,5 +213,24 @@
                {
                        buttons[i].visible = false;
                }
+
+// print me layout info
+println("width {picker.width}");
+//println("most right component {buttons[(1*7)-1].x} + 
{buttons[(1*7)-1].width}");
+
        }
+       override public function refresh_context() : Void
+       {
+               // month
+               monthPicker.items = getMonthNames();
+
+               // setup the dayLabels
+               var lWeekdayNames = getWeekdayNames();
+               for (i in  [0..6])
+               {
+                       // assign day
+                       dayLabels[i].text = lWeekdayNames[i];
+                       dayLabels[i].textFill = if ( isWeekdayWeekend(i) ) 
Color.RED else dummyLabel.textFill; // TODO: colors customizable
+               }
+       }
 }





[jfxcalendarpicker~source-code-repository:40] in the middle of introducing JFXtras for the control skin; the pickers an

tbee 10/01/2009
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close