diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2010-09-09 10:15:00 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2010-09-09 10:15:00 +0000 |
commit | b864d221076b0babccddea3f1f98514d71b52fd5 (patch) | |
tree | 52805520c186f6a9053229a2a0a772d0e5e691f7 /src | |
parent | c694ce35ed14f282c32c53fe52eb30680a1ad57f (diff) | |
download | vaadin-framework-b864d221076b0babccddea3f1f98514d71b52fd5.tar.gz vaadin-framework-b864d221076b0babccddea3f1f98514d71b52fd5.zip |
fixes #5567
svn changeset:14799/svn branch:6.4
Diffstat (limited to 'src')
3 files changed, 31 insertions, 7 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java index fdcd6d65dd..16d27bb053 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java @@ -584,7 +584,7 @@ public class VCalendarPanel extends FocusableFlexTable implements if (getResolution() <= VDateField.RESOLUTION_MONTH
&& valueChangeListener != null) {
- valueChangeListener.changed(focusedDate);
+ valueChangeListener.changed(new Date(focusedDate.getTime()));
}
Date start = new Date();
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VDateFieldCalendar.java b/src/com/vaadin/terminal/gwt/client/ui/VDateFieldCalendar.java index 385257ccf6..d276ce23f9 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VDateFieldCalendar.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VDateFieldCalendar.java @@ -13,6 +13,7 @@ import com.vaadin.terminal.gwt.client.UIDL; 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.ValueChangeListener;
public class VDateFieldCalendar extends VDateField {
@@ -69,10 +70,33 @@ public class VDateFieldCalendar extends VDateField { });
}
+ if (currentResolution <= RESOLUTION_MONTH) {
+ caleandarPanel.setValueChangeListener(new ValueChangeListener() {
+ public void changed(Date date) {
+ Date date2 = new Date(caleandarPanel.getDate().getTime());
+ /*
+ * Update the value of calendarPanel
+ */
+ date2.setYear(date.getYear());
+ date2.setMonth(date.getMonth());
+ caleandarPanel.setDate(date2);
+ /*
+ * Then update the value from panel to server
+ */
+ updateValueFromPanel();
+ }
+ });
+ } else {
+ caleandarPanel.setValueChangeListener(null);
+ }
+
// Update possible changes
caleandarPanel.renderCalendar();
}
+ /**
+ * TODO refactor: almost same method as in VPopupCalendar.updateValue
+ */
private void updateValueFromPanel() {
Date date2 = caleandarPanel.getDate();
Date currentDate = getCurrentDate();
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java b/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java index ba91df0888..ae7bea406e 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java @@ -166,10 +166,15 @@ public class VPopupCalendar extends VTextualDate implements Paintable, Field, if (currentResolution <= RESOLUTION_MONTH) {
calendar.setValueChangeListener(new ValueChangeListener() {
public void changed(Date date) {
- setCurrentDate(date);
+ updateValue(date);
buildDate();
+ Date date2 = calendar.getDate();
+ date2.setYear(date.getYear());
+ date2.setMonth(date.getMonth());
}
});
+ } else {
+ calendar.setValueChangeListener(null);
}
if (currentResolution > RESOLUTION_DAY) {
@@ -324,11 +329,6 @@ public class VPopupCalendar extends VTextualDate implements Paintable, Field, */
public void onClose(CloseEvent<PopupPanel> event) {
if (event.getSource() == popup) {
- if (getCurrentResolution() <= VDateField.RESOLUTION_MONTH) {
- // due to UI limitations always fetch date from popup if
- // resolution is month or year
- setDate(calendar.getDate());
- }
buildDate();
focus();
|