]> source.dussan.org Git - vaadin-framework.git/commitdiff
#8311 Additional CRLF->LF fixes
authorArtur Signell <artur.signell@itmill.com>
Fri, 27 Jan 2012 14:17:02 +0000 (14:17 +0000)
committerArtur Signell <artur.signell@itmill.com>
Fri, 27 Jan 2012 14:17:02 +0000 (14:17 +0000)
svn changeset:22799/svn branch:6.8

src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java
src/com/vaadin/terminal/gwt/client/ui/VSlider.java
tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/AddComponentsTest.java
tests/server-side/com/vaadin/tests/server/component/csslayout/AddComponentsTest.java
tests/server-side/com/vaadin/tests/server/componentcontainer/AbstractIndexedLayoutTest.java
tests/testbench/com/vaadin/tests/application/WebBrowserSizeTest.java
tests/testbench/com/vaadin/tests/application/WebBrowserTest.java
tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.java

index e35bd93f67b1e0b2041eb94b17b8d4c8fc8e96c4..a2f03d6176d58944265a9eeccd9be98a8615d8b3 100644 (file)
@@ -72,7 +72,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
 
     /**
      * FocusChangeListener is notified when the panel changes its _focused_
-     * value. It can be set with
+     * value.
      */
     public interface FocusChangeListener {
         void focusChanged(Date focusedDate);
@@ -103,6 +103,8 @@ public class VCalendarPanel extends FocusableFlexTable implements
 
     private static final String CN_SELECTED = "selected";
 
+    private static final String CN_OFFMONTH = "offmonth";
+
     /**
      * Represents a click handler for when a user selects a value by using the
      * mouse
@@ -117,7 +119,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
          */
         public void onClick(ClickEvent event) {
             Day day = (Day) event.getSource();
-            focusDay(day.getDay());
+            focusDay(day.getDate());
             selectFocused();
             onSubmit();
         }
@@ -151,6 +153,8 @@ public class VCalendarPanel extends FocusableFlexTable implements
 
     private boolean showISOWeekNumbers;
 
+    private Date displayedMonth;
+
     private Date focusedDate;
 
     private Day selectedDay;
@@ -187,21 +191,22 @@ public class VCalendarPanel extends FocusableFlexTable implements
     }
 
     /**
-     * Sets the focus to given day of current time. Used when moving in the
-     * calender with the keyboard.
+     * Sets the focus to given date in the current view. Used when moving in the
+     * calendar with the keyboard.
      * 
-     * @param day
-     *            The day number from by Date.getDate()
+     * @param date
+     *            A Date representing the day of month to be focused. Must be
+     *            one of the days currently visible.
      */
-    private void focusDay(int day) {
+    private void focusDay(Date date) {
         // Only used when calender body is present
         if (resolution > VDateField.RESOLUTION_MONTH) {
             if (focusedDay != null) {
                 focusedDay.removeStyleDependentName(CN_FOCUSED);
             }
 
-            if (day > 0 && focusedDate != null) {
-                focusedDate.setDate(day);
+            if (date != null && focusedDate != null) {
+                focusedDate.setTime(date.getTime());
                 int rowCount = days.getRowCount();
                 for (int i = 0; i < rowCount; i++) {
                     int cellCount = days.getCellCount(i);
@@ -209,7 +214,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
                         Widget widget = days.getWidget(i, j);
                         if (widget != null && widget instanceof Day) {
                             Day curday = (Day) widget;
-                            if (curday.getDay() == day) {
+                            if (curday.getDate().equals(date)) {
                                 curday.addStyleDependentName(CN_FOCUSED);
                                 focusedDay = curday;
                                 focusedRow = i;
@@ -223,11 +228,14 @@ public class VCalendarPanel extends FocusableFlexTable implements
     }
 
     /**
-     * Sets the selection hightlight to a given date of current time
+     * Sets the selection highlight to a given day in the current view
+     * 
+     * @param date
+     *            A Date representing the day of month to be selected. Must be
+     *            one of the days currently visible.
      * 
-     * @param day
      */
-    private void selectDate(int day) {
+    private void selectDate(Date date) {
         if (selectedDay != null) {
             selectedDay.removeStyleDependentName(CN_SELECTED);
         }
@@ -239,7 +247,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
                 Widget widget = days.getWidget(i, j);
                 if (widget != null && widget instanceof Day) {
                     Day curday = (Day) widget;
-                    if (curday.getDay() == day) {
+                    if (curday.getDate().equals(date)) {
                         curday.addStyleDependentName(CN_SELECTED);
                         selectedDay = curday;
                         return;
@@ -278,7 +286,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
             // it was forced to 1 above.
             value.setDate(focusedDate.getDate());
 
-            selectDate(focusedDate.getDate());
+            selectDate(focusedDate);
         } else {
             VConsole.log("Trying to select a the focused date which is NULL!");
         }
@@ -467,97 +475,62 @@ public class VCalendarPanel extends FocusableFlexTable implements
             }
         }
 
-        // The day of month that is selected, -1 if no day of this month is
-        // selected (i.e, showing another month/year than selected or nothing is
-        // selected)
-        int dayOfMonthSelected = -1;
-        // The day of month that is today, -1 if no day of this month is today
-        // (i.e., showing another month/year than current)
-        int dayOfMonthToday = -1;
-
-        boolean initiallyNull = value == null;
-
-        if (!initiallyNull && value.getMonth() == focusedDate.getMonth()
-                && value.getYear() == focusedDate.getYear()) {
-            dayOfMonthSelected = value.getDate();
-        }
-        final Date today = new Date();
-        if (today.getMonth() == focusedDate.getMonth()
-                && today.getYear() == focusedDate.getYear()) {
-            dayOfMonthToday = today.getDate();
-        }
+        // today must have zeroed hours, minutes, seconds, and milliseconds
+        final Date tmp = new Date();
+        final Date today = new Date(tmp.getYear(), tmp.getMonth(),
+                tmp.getDate());
 
         final int startWeekDay = getDateTimeService().getStartWeekDay(
                 focusedDate);
-        final int daysInMonth = DateTimeService
-                .getNumberOfDaysInMonth(focusedDate);
-
-        int dayCount = 0;
-        final Date curr = new Date(focusedDate.getTime());
+        final Date curr = (Date) focusedDate.clone();
+        // Start from the first day of the week that at least partially belongs
+        // to the current month
+        curr.setDate(-startWeekDay);
 
         // No month has more than 6 weeks so 6 is a safe maximum for rows.
         for (int weekOfMonth = 1; weekOfMonth < 7; weekOfMonth++) {
-            boolean weekNumberProcessed[] = new boolean[] { false, false,
-                    false, false, false, false, false };
-
             for (int dayOfWeek = 0; dayOfWeek < 7; dayOfWeek++) {
-                if (!(weekOfMonth == 1 && dayOfWeek < startWeekDay)) {
-
-                    if (dayCount >= daysInMonth) {
-                        // All days printed and we are done
-                        break;
-                    }
-
-                    final int dayOfMonth = ++dayCount;
-
-                    curr.setDate(dayCount);
 
-                    // Actually write the day of month
-                    Day day = new Day(dayOfMonth);
+                // Actually write the day of month
+                Day day = new Day((Date) curr.clone());
 
-                    if (dayOfMonthSelected == dayOfMonth) {
-                        day.addStyleDependentName(CN_SELECTED);
-                        selectedDay = day;
+                if (curr.equals(value)) {
+                    day.addStyleDependentName(CN_SELECTED);
+                    selectedDay = day;
+                }
+                if (curr.equals(today)) {
+                    day.addStyleDependentName(CN_TODAY);
+                }
+                if (curr.equals(focusedDate)) {
+                    focusedDay = day;
+                    focusedRow = weekOfMonth;
+                    if (hasFocus) {
+                        day.addStyleDependentName(CN_FOCUSED);
                     }
+                }
+                if (curr.getMonth() != focusedDate.getMonth()) {
+                    day.addStyleDependentName(CN_OFFMONTH);
+                }
 
-                    if (dayOfMonthToday == dayOfMonth) {
-                        day.addStyleDependentName(CN_TODAY);
-                    }
+                days.setWidget(weekOfMonth, firstWeekdayColumn + dayOfWeek, day);
 
-                    if (dayOfMonth == focusedDate.getDate()) {
-                        focusedDay = day;
-                        focusedRow = weekOfMonth;
-                        if (hasFocus) {
-                            day.addStyleDependentName(CN_FOCUSED);
-                        }
-                    }
+                // ISO week numbers if requested
+                days.getCellFormatter().setVisible(weekOfMonth, weekColumn,
+                        isShowISOWeekNumbers());
+                if (isShowISOWeekNumbers()) {
+                    final String baseCssClass = VDateField.CLASSNAME
+                            + "-calendarpanel-weeknumber";
+                    String weekCssClass = baseCssClass;
 
-                    days.setWidget(weekOfMonth, firstWeekdayColumn + dayOfWeek,
-                            day);
-
-                    // ISO week numbers if requested
-                    if (!weekNumberProcessed[weekOfMonth]) {
-                        days.getCellFormatter().setVisible(weekOfMonth,
-                                weekColumn, isShowISOWeekNumbers());
-                        if (isShowISOWeekNumbers()) {
-                            final String baseCssClass = VDateField.CLASSNAME
-                                    + "-calendarpanel-weeknumber";
-                            String weekCssClass = baseCssClass;
-
-                            int weekNumber = DateTimeService
-                                    .getISOWeekNumber(curr);
-
-                            days.setHTML(weekOfMonth, 0, "<span class=\""
-                                    + weekCssClass + "\"" + ">" + weekNumber
-                                    + "</span>");
-                            weekNumberProcessed[weekOfMonth] = true;
-                        }
+                    int weekNumber = DateTimeService.getISOWeekNumber(curr);
 
-                    }
+                    days.setHTML(weekOfMonth, 0, "<span class=\""
+                            + weekCssClass + "\"" + ">" + weekNumber
+                            + "</span>");
                 }
+                curr.setDate(curr.getDate() + 1);
             }
         }
-
     }
 
     /**
@@ -621,6 +594,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
         while (focusedDate.getMonth() != requestedMonth) {
             focusedDate.setDate(focusedDate.getDate() - 1);
         }
+        displayedMonth.setMonth(displayedMonth.getMonth() + 1);
 
         renderCalendar();
     }
@@ -640,6 +614,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
         while (focusedDate.getMonth() == currentMonth) {
             focusedDate.setDate(focusedDate.getDate() - 1);
         }
+        displayedMonth.setMonth(displayedMonth.getMonth() - 1);
 
         renderCalendar();
     }
@@ -649,6 +624,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
      */
     private void focusPreviousYear(int years) {
         focusedDate.setYear(focusedDate.getYear() - years);
+        displayedMonth.setYear(displayedMonth.getYear() - years);
         renderCalendar();
     }
 
@@ -657,6 +633,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
      */
     private void focusNextYear(int years) {
         focusedDate.setYear(focusedDate.getYear() + years);
+        displayedMonth.setYear(displayedMonth.getYear() + years);
         renderCalendar();
     }
 
@@ -905,7 +882,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
 
             if (newCurrentDate.getMonth() == focusedDate.getMonth()) {
                 // Month did not change, only move the selection
-                focusDay(focusedDate.getDate() + 1);
+                focusDay(newCurrentDate);
             } else {
                 // If the month changed we need to re-render the calendar
                 focusedDate.setDate(focusedDate.getDate() + 1);
@@ -924,7 +901,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
 
             if (newCurrentDate.getMonth() == focusedDate.getMonth()) {
                 // Month did not change, only move the selection
-                focusDay(focusedDate.getDate() - 1);
+                focusDay(newCurrentDate);
             } else {
                 // If the month changed we need to re-render the calendar
                 focusedDate.setDate(focusedDate.getDate() - 1);
@@ -944,10 +921,10 @@ public class VCalendarPanel extends FocusableFlexTable implements
             if (newCurrentDate.getMonth() == focusedDate.getMonth()
                     && focusedRow > 1) {
                 // Month did not change, only move the selection
-                focusDay(focusedDate.getDate() - 7);
+                focusDay(newCurrentDate);
             } else {
                 // If the month changed we need to re-render the calendar
-                focusedDate.setDate(focusedDate.getDate() - 7);
+                focusedDate = newCurrentDate;
                 renderCalendar();
             }
 
@@ -963,10 +940,10 @@ public class VCalendarPanel extends FocusableFlexTable implements
 
             if (newCurrentDate.getMonth() == focusedDate.getMonth()) {
                 // Month did not change, only move the selection
-                focusDay(focusedDate.getDate() + 7);
+                focusDay(newCurrentDate);
             } else {
                 // If the month changed we need to re-render the calendar
-                focusedDate.setDate(focusedDate.getDate() + 7);
+                focusedDate = newCurrentDate;
                 renderCalendar();
 
             }
@@ -1210,27 +1187,28 @@ public class VCalendarPanel extends FocusableFlexTable implements
             return;
         }
 
-        Date oldFocusedValue = focusedDate;
+        Date oldDisplayedMonth = displayedMonth;
         value = currentDate;
 
         if (value == null) {
-            focusedDate = null;
+            focusedDate = displayedMonth = null;
         } else {
             focusedDate = (Date) value.clone();
+            displayedMonth = (Date) value.clone();
         }
 
         // Re-render calendar if month or year of focused date has changed
-        if (oldFocusedValue == null || value == null
-                || oldFocusedValue.getYear() != value.getYear()
-                || oldFocusedValue.getMonth() != value.getMonth()) {
+        if (oldDisplayedMonth == null || value == null
+                || oldDisplayedMonth.getYear() != value.getYear()
+                || oldDisplayedMonth.getMonth() != value.getMonth()) {
             renderCalendar();
         } else {
-            focusDay(currentDate.getDate());
+            focusDay(currentDate);
             selectFocused();
         }
 
         if (!hasFocus) {
-            focusDay(-1);
+            focusDay((Date) null);
         }
     }
 
@@ -1552,20 +1530,23 @@ public class VCalendarPanel extends FocusableFlexTable implements
 
     }
 
+    /**
+     * A widget representing a single day in the calendar panel.
+     */
     private class Day extends InlineHTML {
         private static final String BASECLASS = VDateField.CLASSNAME
                 + "-calendarpanel-day";
-        private final int day;
+        private final Date date;
 
-        Day(int dayOfMonth) {
-            super("" + dayOfMonth);
+        Day(Date date) {
+            super("" + date.getDate());
             setStyleName(BASECLASS);
-            day = dayOfMonth;
+            this.date = date;
             addClickHandler(dayClickHandler);
         }
 
-        public int getDay() {
-            return day;
+        public Date getDate() {
+            return date;
         }
     }
 
@@ -1648,7 +1629,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
     public void onBlur(final BlurEvent event) {
         if (event.getSource() instanceof VCalendarPanel) {
             hasFocus = false;
-            focusDay(-1);
+            focusDay(null);
         }
     }
 
@@ -1665,7 +1646,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
 
             // Focuses the current day if the calendar shows the days
             if (focusedDay != null) {
-                focusDay(focusedDay.getDay());
+                focusDay(focusedDate);
             }
         }
     }
@@ -1696,7 +1677,17 @@ public class VCalendarPanel extends FocusableFlexTable implements
             // Day, find out which dayOfMonth and use that as the identifier
             Day day = Util.findWidget(subElement, Day.class);
             if (day != null) {
-                return SUBPART_DAY + day.getDay();
+                Date date = day.getDate();
+                int id = date.getDate();
+                // Zero or negative ids map to days of the preceding month,
+                // past-the-end-of-month ids to days of the following month
+                if (date.getMonth() < displayedMonth.getMonth()) {
+                    id -= DateTimeService.getNumberOfDaysInMonth(date);
+                } else if (date.getMonth() > displayedMonth.getMonth()) {
+                    id += DateTimeService
+                            .getNumberOfDaysInMonth(displayedMonth);
+                }
+                return SUBPART_DAY + id;
             }
         } else if (time != null) {
             if (contains(time.hours, subElement)) {
@@ -1762,14 +1753,18 @@ public class VCalendarPanel extends FocusableFlexTable implements
             return time.ampm.getElement();
         }
         if (subPart.startsWith(SUBPART_DAY)) {
+            // Zero or negative ids map to days in the preceding month,
+            // past-the-end-of-month ids to days in the following month
             int dayOfMonth = Integer.parseInt(subPart.substring(SUBPART_DAY
                     .length()));
+            Date date = new Date(displayedMonth.getYear(),
+                    displayedMonth.getMonth(), dayOfMonth);
             Iterator<Widget> iter = days.iterator();
             while (iter.hasNext()) {
                 Widget w = iter.next();
                 if (w instanceof Day) {
                     Day day = (Day) w;
-                    if (day.getDay() == dayOfMonth) {
+                    if (day.getDate().equals(date)) {
                         return day.getElement();
                     }
                 }
index a001ca7f1337ecd57d3e2a1b73f66ef9b088c44a..4a463466138411df12b9b226a9711f5afdcdd69b 100644 (file)
@@ -425,10 +425,6 @@ public class VSlider extends SimpleFocusablePanel implements Paintable, Field,
                 setValueByEvent(event, true);
                 DOM.eventCancelBubble(event, true);
             }
-        } else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN && dragging) {
-            dragging = false;
-            DOM.releaseCapture(getElement());
-            setValueByEvent(event, true);
         }
     }
 
index bd67841f3364b62ed1badca76c60f5fe2a85f7fb..1971fb6d0e3013565dbcbd7b2d5a4a25902a1343 100644 (file)
@@ -1,14 +1,14 @@
 package com.vaadin.tests.server.component.abstractorderedlayout;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.fail;
-
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
 import org.junit.Test;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
+
 import com.vaadin.ui.AbstractOrderedLayout;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.HorizontalLayout;
index d4a05927680fdfa2afa2482692ed843a0d059c30..c0d739b5977864452b0938b2d5359eb0c68ad5ed 100644 (file)
@@ -5,8 +5,8 @@ import java.util.NoSuchElementException;
 
 import org.junit.Test;
 
-import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
 import static org.junit.Assert.fail;
 
 import com.vaadin.ui.Component;
index 9271e9f1b3f8397c14a7b67ea89fc53ab844c553..e3e743d02abd654d9cb35dcd7679c71545da9bb8 100644 (file)
@@ -1,84 +1,84 @@
-package com.vaadin.tests.server.componentcontainer;\r
-\r
-import junit.framework.TestCase;\r
-\r
-import com.vaadin.ui.Component;\r
-import com.vaadin.ui.Label;\r
-import com.vaadin.ui.Layout;\r
-\r
-public abstract class AbstractIndexedLayoutTest extends TestCase {\r
-\r
-    private Layout layout;\r
-\r
-    protected abstract Layout createLayout();\r
-\r
-    @Override\r
-    protected void setUp() throws Exception {\r
-        layout = createLayout();\r
-    }\r
-\r
-    public Layout getLayout() {\r
-        return layout;\r
-    }\r
-\r
-    public void testAddRemoveComponent() {\r
-        Label c1 = new Label();\r
-        Label c2 = new Label();\r
-\r
-        layout.addComponent(c1);\r
-\r
-        assertEquals(c1, getComponent(0));\r
-        assertEquals(1, getComponentCount());\r
-        layout.addComponent(c2);\r
-        assertEquals(c1, getComponent(0));\r
-        assertEquals(c2, getComponent(1));\r
-        assertEquals(2, getComponentCount());\r
-        layout.removeComponent(c1);\r
-        assertEquals(c2, getComponent(0));\r
-        assertEquals(1, getComponentCount());\r
-        layout.removeComponent(c2);\r
-        assertEquals(0, getComponentCount());\r
-    }\r
-\r
-    protected abstract int getComponentCount();\r
-\r
-    protected abstract Component getComponent(int index);\r
-\r
-    protected abstract int getComponentIndex(Component c);\r
-\r
-    public void testGetComponentIndex() {\r
-        Label c1 = new Label();\r
-        Label c2 = new Label();\r
-\r
-        layout.addComponent(c1);\r
-        assertEquals(0, getComponentIndex(c1));\r
-        layout.addComponent(c2);\r
-        assertEquals(0, getComponentIndex(c1));\r
-        assertEquals(1, getComponentIndex(c2));\r
-        layout.removeComponent(c1);\r
-        assertEquals(0, getComponentIndex(c2));\r
-        layout.removeComponent(c2);\r
-        assertEquals(-1, getComponentIndex(c2));\r
-        assertEquals(-1, getComponentIndex(c1));\r
-    }\r
-\r
-    public void testGetComponent() {\r
-        Label c1 = new Label();\r
-        Label c2 = new Label();\r
-\r
-        layout.addComponent(c1);\r
-        assertEquals(c1, getComponent(0));\r
-        layout.addComponent(c2);\r
-        assertEquals(c1, getComponent(0));\r
-        assertEquals(c2, getComponent(1));\r
-        layout.removeComponent(c1);\r
-        assertEquals(c2, getComponent(0));\r
-        layout.removeComponent(c2);\r
-        try {\r
-            getComponent(0);\r
-            fail();\r
-        } catch (IndexOutOfBoundsException e) {\r
-            // Expected\r
-        }\r
-    }\r
-}\r
+package com.vaadin.tests.server.componentcontainer;
+
+import junit.framework.TestCase;
+
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Layout;
+
+public abstract class AbstractIndexedLayoutTest extends TestCase {
+
+    private Layout layout;
+
+    protected abstract Layout createLayout();
+
+    @Override
+    protected void setUp() throws Exception {
+        layout = createLayout();
+    }
+
+    public Layout getLayout() {
+        return layout;
+    }
+
+    public void testAddRemoveComponent() {
+        Label c1 = new Label();
+        Label c2 = new Label();
+
+        layout.addComponent(c1);
+
+        assertEquals(c1, getComponent(0));
+        assertEquals(1, getComponentCount());
+        layout.addComponent(c2);
+        assertEquals(c1, getComponent(0));
+        assertEquals(c2, getComponent(1));
+        assertEquals(2, getComponentCount());
+        layout.removeComponent(c1);
+        assertEquals(c2, getComponent(0));
+        assertEquals(1, getComponentCount());
+        layout.removeComponent(c2);
+        assertEquals(0, getComponentCount());
+    }
+
+    protected abstract int getComponentCount();
+
+    protected abstract Component getComponent(int index);
+
+    protected abstract int getComponentIndex(Component c);
+
+    public void testGetComponentIndex() {
+        Label c1 = new Label();
+        Label c2 = new Label();
+
+        layout.addComponent(c1);
+        assertEquals(0, getComponentIndex(c1));
+        layout.addComponent(c2);
+        assertEquals(0, getComponentIndex(c1));
+        assertEquals(1, getComponentIndex(c2));
+        layout.removeComponent(c1);
+        assertEquals(0, getComponentIndex(c2));
+        layout.removeComponent(c2);
+        assertEquals(-1, getComponentIndex(c2));
+        assertEquals(-1, getComponentIndex(c1));
+    }
+
+    public void testGetComponent() {
+        Label c1 = new Label();
+        Label c2 = new Label();
+
+        layout.addComponent(c1);
+        assertEquals(c1, getComponent(0));
+        layout.addComponent(c2);
+        assertEquals(c1, getComponent(0));
+        assertEquals(c2, getComponent(1));
+        layout.removeComponent(c1);
+        assertEquals(c2, getComponent(0));
+        layout.removeComponent(c2);
+        try {
+            getComponent(0);
+            fail();
+        } catch (IndexOutOfBoundsException e) {
+            // Expected
+        }
+    }
+}
index f2726118d4597d3f1909068e497c23aa3fa01e6b..eacf2a0e532c6025e504e3206736ca234ae519c1 100644 (file)
@@ -1,45 +1,45 @@
-package com.vaadin.tests.application;\r
-\r
-import com.vaadin.tests.components.TestBase;\r
-import com.vaadin.ui.Button;\r
-import com.vaadin.ui.Button.ClickEvent;\r
-import com.vaadin.ui.Label;\r
-\r
-public class WebBrowserSizeTest extends TestBase {\r
-\r
-    @Override\r
-    protected void setup() {\r
-\r
-        final Label screenSizeLabel = new Label("n/a");\r
-        screenSizeLabel.setCaption("Screen size");\r
-\r
-        final Label browserSizeLabel = new Label("n/a");\r
-        browserSizeLabel.setCaption("Client (browser window) size");\r
-\r
-        final Button update = new Button("Refresh", new Button.ClickListener() {\r
-\r
-            public void buttonClick(ClickEvent event) {\r
-                screenSizeLabel.setValue(getBrowser().getScreenWidth() + " x "\r
-                        + getBrowser().getScreenHeight());\r
-                browserSizeLabel.setValue(getBrowser().getClientWidth() + " x "\r
-                        + getBrowser().getClientHeight());\r
-            }\r
-        });\r
-\r
-        addComponent(update);\r
-        addComponent(screenSizeLabel);\r
-        addComponent(browserSizeLabel);\r
-\r
-    }\r
-\r
-    @Override\r
-    protected String getDescription() {\r
-        return "Verifies that browser sizes are reported correctly. Note that client width differs depending on browser decorations.";\r
-    }\r
-\r
-    @Override\r
-    protected Integer getTicketNumber() {\r
-        return 5655;\r
-    }\r
-\r
-}\r
+package com.vaadin.tests.application;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+
+public class WebBrowserSizeTest extends TestBase {
+
+    @Override
+    protected void setup() {
+
+        final Label screenSizeLabel = new Label("n/a");
+        screenSizeLabel.setCaption("Screen size");
+
+        final Label browserSizeLabel = new Label("n/a");
+        browserSizeLabel.setCaption("Client (browser window) size");
+
+        final Button update = new Button("Refresh", new Button.ClickListener() {
+
+            public void buttonClick(ClickEvent event) {
+                screenSizeLabel.setValue(getBrowser().getScreenWidth() + " x "
+                        + getBrowser().getScreenHeight());
+                browserSizeLabel.setValue(getBrowser().getClientWidth() + " x "
+                        + getBrowser().getClientHeight());
+            }
+        });
+
+        addComponent(update);
+        addComponent(screenSizeLabel);
+        addComponent(browserSizeLabel);
+
+    }
+
+    @Override
+    protected String getDescription() {
+        return "Verifies that browser sizes are reported correctly. Note that client width differs depending on browser decorations.";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 5655;
+    }
+
+}
index 4508e4ef9008ffa33b1d34baf99281b77d74d6e3..35235bbe1fe1c9580034b8cb38901e727bd2e1cb 100644 (file)
@@ -71,6 +71,7 @@ public class WebBrowserTest extends TestBase {
 
                         curDateLabel.setValue(getBrowser().getCurrentDate()
                                 .toString());
+
                     }
                 });
 
@@ -82,7 +83,6 @@ public class WebBrowserTest extends TestBase {
         addComponent(curDateLabel);
         addComponent(diffLabel);
         addComponent(containsLabel);
-
     }
 
     @Override
index 4fc8f87398f0998902332152460e01e81f3c3e56..357c61f4f64fa23efba1b9da032ca9bc2b5524ce 100644 (file)
@@ -1,69 +1,69 @@
-package com.vaadin.tests.components.datefield;\r
-\r
-import java.util.Calendar;\r
-import java.util.Locale;\r
-\r
-import com.vaadin.tests.components.TestBase;\r
-import com.vaadin.ui.Button;\r
-import com.vaadin.ui.Button.ClickEvent;\r
-import com.vaadin.ui.Button.ClickListener;\r
-import com.vaadin.ui.DateField;\r
-import com.vaadin.ui.PopupDateField;\r
-\r
-@SuppressWarnings("serial")\r
-public class PopupDateFieldExtendedRange extends TestBase {\r
-\r
-    private Calendar date = Calendar.getInstance();\r
-\r
-    @Override\r
-    protected void setup() {\r
-        date.set(2011, 0, 1);\r
-\r
-        getLayout().setSpacing(true);\r
-\r
-        final PopupDateField[] fields = new PopupDateField[3];\r
-\r
-        fields[0] = makeDateField();\r
-        fields[0].setLocale(new Locale("fi", "FI"));\r
-        fields[0].setCaption("Finnish locale");\r
-\r
-        fields[1] = makeDateField();\r
-        fields[1].setLocale(new Locale("en", "US"));\r
-        fields[1].setCaption("US English locale");\r
-\r
-        fields[2] = makeDateField();\r
-        fields[2].setLocale(new Locale("fi", "FI"));\r
-        fields[2].setShowISOWeekNumbers(true);\r
-        fields[2].setCaption("Finnish locale with week numbers");\r
-\r
-        for (PopupDateField f : fields) {\r
-            addComponent(f);\r
-        }\r
-\r
-        addComponent(new Button("Change date", new ClickListener() {\r
-            public void buttonClick(ClickEvent event) {\r
-                date.set(2010, 1, 16);\r
-                for (PopupDateField f : fields) {\r
-                    f.setValue(date.getTime());\r
-                }\r
-            }\r
-        }));\r
-    }\r
-\r
-    @Override\r
-    protected String getDescription() {\r
-        return "Show a few days of the preceding and following months in the datefield popup";\r
-    }\r
-\r
-    @Override\r
-    protected Integer getTicketNumber() {\r
-        return 6718;\r
-    }\r
-\r
-    private PopupDateField makeDateField() {\r
-        PopupDateField pdf = new PopupDateField();\r
-        pdf.setResolution(DateField.RESOLUTION_DAY);\r
-        pdf.setValue(date.getTime());\r
-        return pdf;\r
-    }\r
-}\r
+package com.vaadin.tests.components.datefield;
+
+import java.util.Calendar;
+import java.util.Locale;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.PopupDateField;
+
+@SuppressWarnings("serial")
+public class PopupDateFieldExtendedRange extends TestBase {
+
+    private Calendar date = Calendar.getInstance();
+
+    @Override
+    protected void setup() {
+        date.set(2011, 0, 1);
+
+        getLayout().setSpacing(true);
+
+        final PopupDateField[] fields = new PopupDateField[3];
+
+        fields[0] = makeDateField();
+        fields[0].setLocale(new Locale("fi", "FI"));
+        fields[0].setCaption("Finnish locale");
+
+        fields[1] = makeDateField();
+        fields[1].setLocale(new Locale("en", "US"));
+        fields[1].setCaption("US English locale");
+
+        fields[2] = makeDateField();
+        fields[2].setLocale(new Locale("fi", "FI"));
+        fields[2].setShowISOWeekNumbers(true);
+        fields[2].setCaption("Finnish locale with week numbers");
+
+        for (PopupDateField f : fields) {
+            addComponent(f);
+        }
+
+        addComponent(new Button("Change date", new ClickListener() {
+            public void buttonClick(ClickEvent event) {
+                date.set(2010, 1, 16);
+                for (PopupDateField f : fields) {
+                    f.setValue(date.getTime());
+                }
+            }
+        }));
+    }
+
+    @Override
+    protected String getDescription() {
+        return "Show a few days of the preceding and following months in the datefield popup";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 6718;
+    }
+
+    private PopupDateField makeDateField() {
+        PopupDateField pdf = new PopupDateField();
+        pdf.setResolution(DateField.RESOLUTION_DAY);
+        pdf.setValue(date.getTime());
+        return pdf;
+    }
+}