Author: gbrown
Date: Tue Apr 27 20:08:14 2010
New Revision: 938632

URL: http://svn.apache.org/viewvc?rev=938632&view=rev
Log:
Don't hide last row of calendar based on the enabled state of the first button, 
since the button may have been disabled via the disabled date filter, not 
because it is part of the following month; update Query.java to use a constant 
for HTTP 200 instead of a literal.

Modified:
    pivot/trunk/tests/src/org/apache/pivot/tests/CalendarTest.java
    pivot/trunk/tests/src/org/apache/pivot/tests/calendar_test.wtkx
    pivot/trunk/web/src/org/apache/pivot/web/Query.java
    
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraCalendarSkin.java

Modified: pivot/trunk/tests/src/org/apache/pivot/tests/CalendarTest.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/CalendarTest.java?rev=938632&r1=938631&r2=938632&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/CalendarTest.java (original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/CalendarTest.java Tue Apr 27 
20:08:14 2010
@@ -19,11 +19,15 @@ package org.apache.pivot.tests;
 import org.apache.pivot.collections.Map;
 import org.apache.pivot.util.CalendarDate;
 import org.apache.pivot.util.Filter;
+import org.apache.pivot.util.concurrent.Task;
+import org.apache.pivot.util.concurrent.TaskListener;
 import org.apache.pivot.wtk.Application;
 import org.apache.pivot.wtk.Calendar;
 import org.apache.pivot.wtk.CalendarButton;
+import org.apache.pivot.wtk.CalendarButtonListener;
 import org.apache.pivot.wtk.DesktopApplicationContext;
 import org.apache.pivot.wtk.Display;
+import org.apache.pivot.wtk.TaskAdapter;
 import org.apache.pivot.wtk.Window;
 import org.apache.pivot.wtkx.WTKX;
 import org.apache.pivot.wtkx.WTKXSerializer;
@@ -41,7 +45,7 @@ public class CalendarTest implements App
         window = (Window)wtkxSerializer.readObject(this, "calendar_test.wtkx");
         wtkxSerializer.bind(this, CalendarTest.class);
 
-        Filter<CalendarDate> disabledDateFilter = new Filter<CalendarDate>() {
+        Filter<CalendarDate> todayFilter = new Filter<CalendarDate>() {
             @Override
             public boolean include(CalendarDate date) {
                 CalendarDate today = new CalendarDate();
@@ -49,8 +53,56 @@ public class CalendarTest implements App
             }
         };
 
-        calendar.setDisabledDateFilter(disabledDateFilter);
-        calendarButton.setDisabledDateFilter(disabledDateFilter);
+        calendar.setDisabledDateFilter(todayFilter);
+
+        calendarButton.getCalendarButtonListeners().add(new 
CalendarButtonListener.Adapter() {
+            @Override
+            public void yearChanged(CalendarButton calendarButton, int 
previousYear) {
+                disable();
+            }
+
+            @Override
+            public void monthChanged(CalendarButton calendarButton, int 
previousMonth) {
+                disable();
+            }
+
+            private void disable() {
+                calendarButton.setDisabledDateFilter(new 
Filter<CalendarDate>() {
+                    @Override
+                    public boolean include(CalendarDate date) {
+                        return true;
+                    }
+                });
+
+                Task<Void> task = new Task<Void>() {
+                    @Override
+                    public Void execute() {
+                        try {
+                            Thread.sleep(500);
+                        } catch (InterruptedException exception) {
+                        }
+
+                        return null;
+                    }
+                };
+
+                System.out.println("STARTING TASK");
+
+                task.execute(new TaskAdapter<Void>(new TaskListener<Void>() {
+                    @Override
+                    public void taskExecuted(Task<Void> task) {
+                        System.out.println("EXECUTED");
+                        calendarButton.setDisabledDateFilter(null);
+                    }
+
+                    @Override
+                    public void executeFailed(Task<Void> task) {
+                        System.out.println("FAILED");
+                        calendarButton.setDisabledDateFilter(null);
+                    }
+                }));
+            }
+        });
 
         window.open(display);
     }

Modified: pivot/trunk/tests/src/org/apache/pivot/tests/calendar_test.wtkx
URL: 
http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/calendar_test.wtkx?rev=938632&r1=938631&r2=938632&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/calendar_test.wtkx (original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/calendar_test.wtkx Tue Apr 27 
20:08:14 2010
@@ -27,8 +27,7 @@ limitations under the License.
                         month="2" year="2009" locale="{language:'fr', 
country:'ca'}"/>
                 </content>
             </Border>
-            <CalendarButton wtkx:id="calendarButton" selectedDate="2009-08-25"
-                locale="{language:'fr', country:'ca'}"/>
+            <CalendarButton wtkx:id="calendarButton"/>
             <ListButton listData="['One', 'Two', 'Three']"/>
         </BoxPane>
     </content>

Modified: pivot/trunk/web/src/org/apache/pivot/web/Query.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/web/src/org/apache/pivot/web/Query.java?rev=938632&r1=938631&r2=938632&view=diff
==============================================================================
--- pivot/trunk/web/src/org/apache/pivot/web/Query.java (original)
+++ pivot/trunk/web/src/org/apache/pivot/web/Query.java Tue Apr 27 20:08:14 2010
@@ -467,7 +467,7 @@ public abstract class Query<V> extends I
 
             // Read the response body
             if (method == Method.GET
-                && status == 200) {
+                && status == Query.Status.OK) {
                 InputStream inputStream = null;
                 try {
                     inputStream = connection.getInputStream();

Modified: 
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraCalendarSkin.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraCalendarSkin.java?rev=938632&r1=938631&r2=938632&view=diff
==============================================================================
--- 
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraCalendarSkin.java
 (original)
+++ 
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraCalendarSkin.java
 Tue Apr 27 20:08:14 2010
@@ -644,12 +644,6 @@ public class TerraCalendarSkin extends C
             }
         }
 
-        // Show/hide last row
-        boolean visible = dateButtons[5][0].isEnabled();
-        for (Component component : calendarTablePane.getRows().get(7)) {
-            component.setVisible(visible);
-        }
-
         today = new CalendarDate();
         updateSelection(calendar.getSelectedDate());
     }


Reply via email to