summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/com/vaadin/ui')
-rw-r--r--server/src/com/vaadin/ui/AbstractSelect.java19
-rw-r--r--server/src/com/vaadin/ui/Calendar.java22
-rw-r--r--server/src/com/vaadin/ui/Table.java2
-rw-r--r--server/src/com/vaadin/ui/UI.java2
-rw-r--r--server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java4
-rw-r--r--server/src/com/vaadin/ui/components/calendar/handler/BasicBackwardHandler.java16
-rw-r--r--server/src/com/vaadin/ui/components/calendar/handler/BasicForwardHandler.java16
7 files changed, 78 insertions, 3 deletions
diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java
index b083db3183..2c4dd5be5d 100644
--- a/server/src/com/vaadin/ui/AbstractSelect.java
+++ b/server/src/com/vaadin/ui/AbstractSelect.java
@@ -1675,6 +1675,8 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
// Clears the item id mapping table
itemIdMapper.removeAll();
+ adjustSelection();
+
// Notify all listeners
fireItemSetChange();
}
@@ -1713,6 +1715,23 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
}
/**
+ * Removes orphaned ids from selection.
+ */
+ protected void adjustSelection() {
+ Object value = getValue();
+ if (isMultiSelect() && (value instanceof Collection)) {
+ Collection<?> collection = (Collection<?>) value;
+ for (Object id : collection) {
+ if (!containsId(id)) {
+ unselect(id);
+ }
+ }
+ } else if (!containsId(value)) {
+ unselect(value);
+ }
+ }
+
+ /**
* Implementation of item set change event.
*/
private static class ItemSetChangeEvent extends EventObject implements
diff --git a/server/src/com/vaadin/ui/Calendar.java b/server/src/com/vaadin/ui/Calendar.java
index 63ac9fe35c..72ff6eb0e0 100644
--- a/server/src/com/vaadin/ui/Calendar.java
+++ b/server/src/com/vaadin/ui/Calendar.java
@@ -516,7 +516,8 @@ public class Calendar extends AbstractComponent implements
day.date = df_date.format(date);
day.localizedDateFormat = weeklyCaptionFormatter.format(date);
day.dayOfWeek = getDowByLocale(currentCalendar);
- day.week = currentCalendar.get(java.util.Calendar.WEEK_OF_YEAR);
+ day.week = getWeek(currentCalendar);
+ day.yearOfWeek = getYearOfWeek(currentCalendar);
days.add(day);
@@ -560,6 +561,23 @@ public class Calendar extends AbstractComponent implements
state.actions = createActionsList(actionMap);
}
+ private int getWeek(java.util.Calendar calendar) {
+ return calendar.get(java.util.Calendar.WEEK_OF_YEAR);
+ }
+
+ private int getYearOfWeek(java.util.Calendar calendar) {
+ // Would use calendar.getWeekYear() but it's only available since 1.7.
+ int week = getWeek(calendar);
+ int month = calendar.get(java.util.Calendar.MONTH);
+ int year = calendar.get(java.util.Calendar.YEAR);
+
+ if (week == 1 && month == java.util.Calendar.DECEMBER) {
+ return year + 1;
+ }
+
+ return year;
+ }
+
private void setActionsForEachHalfHour(
Map<CalendarDateRange, Set<Action>> actionMap, Date start,
Date end, Action.Handler actionHandler) {
@@ -1772,7 +1790,7 @@ public class Calendar extends AbstractComponent implements
String[] splitted = event.split("w");
if (splitted.length == 2) {
try {
- int yr = 1900 + Integer.parseInt(splitted[0]);
+ int yr = Integer.parseInt(splitted[0]);
int week = Integer.parseInt(splitted[1]);
fireWeekClick(week, yr);
} catch (NumberFormatException e) {
diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java
index 34d48a9b18..9da25d3e48 100644
--- a/server/src/com/vaadin/ui/Table.java
+++ b/server/src/com/vaadin/ui/Table.java
@@ -1029,7 +1029,7 @@ public class Table extends AbstractSelect implements Action.Container,
* </p>
*
* <p>
- * If Table has width set ({@link #setWidth(float, int)} ) the client side
+ * If Table has height set ({@link #setHeight(float, int)} ) the client side
* may update the page length automatically the correct value.
* </p>
*
diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java
index 438b086ec2..78cb5488e8 100644
--- a/server/src/com/vaadin/ui/UI.java
+++ b/server/src/com/vaadin/ui/UI.java
@@ -499,6 +499,7 @@ public abstract class UI extends AbstractSingleComponentContainer implements
private void attachWindow(Window w) {
windows.add(w);
w.setParent(this);
+ fireComponentAttachEvent(w);
markAsDirty();
}
@@ -523,6 +524,7 @@ public abstract class UI extends AbstractSingleComponentContainer implements
window.setParent(null);
markAsDirty();
window.fireClose();
+ fireComponentDetachEvent(window);
return true;
}
diff --git a/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java b/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java
index 8dff224627..fcaabcc079 100644
--- a/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java
+++ b/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java
@@ -442,6 +442,8 @@ public class ContainerEventProvider implements CalendarEditableEventProvider,
/**
* Set the all day property for the event
+ *
+ * @since 7.3.4
*/
public void setAllDayProperty(Object allDayProperty) {
this.allDayProperty = allDayProperty;
@@ -449,6 +451,8 @@ public class ContainerEventProvider implements CalendarEditableEventProvider,
/**
* Get the all day property for the event
+ *
+ * @since 7.3.4
*/
public Object getAllDayProperty() {
return allDayProperty;
diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicBackwardHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicBackwardHandler.java
index f4d47f89d4..0e99b26856 100644
--- a/server/src/com/vaadin/ui/components/calendar/handler/BasicBackwardHandler.java
+++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicBackwardHandler.java
@@ -47,6 +47,7 @@ public class BasicBackwardHandler implements BackwardHandler {
// calculate amount to move back
int durationInDays = (int) (((end.getTime()) - start.getTime()) / DateConstants.DAYINMILLIS);
durationInDays++;
+ // for week view durationInDays = -7, for day view durationInDays = -1
durationInDays = -durationInDays;
// set new start and end times
@@ -59,6 +60,21 @@ public class BasicBackwardHandler implements BackwardHandler {
javaCalendar.add(java.util.Calendar.DATE, durationInDays);
Date newEnd = javaCalendar.getTime();
+ if (start.equals(end)) { // day view
+ int firstDay = event.getComponent().getFirstVisibleDayOfWeek();
+ int lastDay = event.getComponent().getLastVisibleDayOfWeek();
+ int dayOfWeek = javaCalendar.get(Calendar.DAY_OF_WEEK);
+
+ // we suppose that 7 >= lastDay >= firstDay >= 1
+ while (!(firstDay <= dayOfWeek && dayOfWeek <= lastDay)) {
+ javaCalendar.add(java.util.Calendar.DATE, -1);
+ dayOfWeek = javaCalendar.get(Calendar.DAY_OF_WEEK);
+ }
+
+ newStart = javaCalendar.getTime();
+ newEnd = javaCalendar.getTime();
+ }
+
setDates(event, newStart, newEnd);
}
diff --git a/server/src/com/vaadin/ui/components/calendar/handler/BasicForwardHandler.java b/server/src/com/vaadin/ui/components/calendar/handler/BasicForwardHandler.java
index 96c3c097dc..45b44cb673 100644
--- a/server/src/com/vaadin/ui/components/calendar/handler/BasicForwardHandler.java
+++ b/server/src/com/vaadin/ui/components/calendar/handler/BasicForwardHandler.java
@@ -45,6 +45,7 @@ public class BasicForwardHandler implements ForwardHandler {
// calculate amount to move forward
int durationInDays = (int) (((end.getTime()) - start.getTime()) / DateConstants.DAYINMILLIS);
+ // for week view durationInDays = 7, for day view durationInDays = 1
durationInDays++;
// set new start and end times
@@ -57,6 +58,21 @@ public class BasicForwardHandler implements ForwardHandler {
javaCalendar.add(java.util.Calendar.DATE, durationInDays);
Date newEnd = javaCalendar.getTime();
+ if (start.equals(end)) { // day view
+ int firstDay = event.getComponent().getFirstVisibleDayOfWeek();
+ int lastDay = event.getComponent().getLastVisibleDayOfWeek();
+ int dayOfWeek = javaCalendar.get(Calendar.DAY_OF_WEEK);
+
+ // we suppose that 7 >= lastDay >= firstDay >= 1
+ while (!(firstDay <= dayOfWeek && dayOfWeek <= lastDay)) {
+ javaCalendar.add(java.util.Calendar.DATE, 1);
+ dayOfWeek = javaCalendar.get(Calendar.DAY_OF_WEEK);
+ }
+
+ newStart = javaCalendar.getTime();
+ newEnd = javaCalendar.getTime();
+ }
+
setDates(event, newStart, newEnd);
}