From 21e4a77849363ab12037e7d8faf93eb6ff666738 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 16 Sep 2010 13:43:24 +0000 Subject: [PATCH] different kind of fix for #5592 svn changeset:14965/svn branch:6.4 --- .../terminal/gwt/client/ui/VCalendarPanel.java | 15 ++++----------- .../terminal/gwt/client/ui/VPopupCalendar.java | 10 ++++++++-- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java index 40c9887c83..6ffa66d6cd 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java @@ -134,8 +134,6 @@ public class VCalendarPanel extends FocusableFlexTable implements private FlexTable days = new FlexTable(); - /* Needed to identify resolution changes */ - private int oldResolution = 0; private int resolution = VDateField.RESOLUTION_YEAR; private int focusedRow; @@ -290,10 +288,7 @@ public class VCalendarPanel extends FocusableFlexTable implements } public void setResolution(int resolution) { - if (resolution != this.resolution) { - oldResolution = this.resolution; - this.resolution = resolution; - } + this.resolution = resolution; } private boolean isReadonly() { @@ -591,14 +586,12 @@ public class VCalendarPanel extends FocusableFlexTable implements buildCalendarBody(); } - if (isTimeSelectorNeeded() - && (time == null || resolution != oldResolution)) { + if (isTimeSelectorNeeded() && time == null) { time = new VTime(); setWidget(2, 0, time); getFlexCellFormatter().setColSpan(2, 0, 5); getFlexCellFormatter().setStyleName(2, 0, VDateField.CLASSNAME + "-calendarpanel-time"); - oldResolution = resolution; } else if (isTimeSelectorNeeded()) { time.updateTimes(); } else if (time != null) { @@ -1230,8 +1223,8 @@ public class VCalendarPanel extends FocusableFlexTable implements focusedDate = (Date) value.clone(); } - // Re-render calendar if the resolution or the month or year has changed - if (oldResolution != resolution || oldValue == null || value == null + // Re-render calendar if month or year has changed + if (oldValue == null || value == null || oldValue.getYear() != value.getYear() || oldValue.getMonth() != value.getMonth()) { renderCalendar(); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java b/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java index 35151cf4c3..281b5a8df4 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java @@ -24,10 +24,10 @@ import com.vaadin.terminal.gwt.client.ApplicationConnection; import com.vaadin.terminal.gwt.client.DateTimeService; import com.vaadin.terminal.gwt.client.Paintable; import com.vaadin.terminal.gwt.client.UIDL; +import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.FocusChangeListener; import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.FocusOutListener; import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.SubmitListener; import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.TimeChangeListener; -import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.FocusChangeListener; /** * Represents a date selection component with a text field and a popup date @@ -160,7 +160,13 @@ public class VPopupCalendar extends VTextualDate implements Paintable, Field, + resolutionToString(currentResolution)); calendar.setDateTimeService(getDateTimeService()); calendar.setShowISOWeekNumbers(isShowISOWeekNumbers()); - calendar.setResolution(currentResolution); + if (calendar.getResolution() != currentResolution) { + calendar.setResolution(currentResolution); + if (calendar.getDate() != null) { + // force re-render when changing resolution only + calendar.renderCalendar(); + } + } calendarToggle.setEnabled(enabled); if (currentResolution <= RESOLUTION_MONTH) { -- 2.39.5