diff options
author | Marc Englund <marc.englund@itmill.com> | 2007-10-17 14:19:14 +0000 |
---|---|---|
committer | Marc Englund <marc.englund@itmill.com> | 2007-10-17 14:19:14 +0000 |
commit | 06354790d76aa44c4f86023dd43f0f137b8ee976 (patch) | |
tree | 022bb921881e9b6a02d87bd97e3993c6ffd3294a /src | |
parent | 1508111a4e17764ca81a741486d8fe174d7ab9ea (diff) | |
download | vaadin-framework-06354790d76aa44c4f86023dd43f0f137b8ee976.tar.gz vaadin-framework-06354790d76aa44c4f86023dd43f0f137b8ee976.zip |
Significant speedup. Added more generated data.
svn changeset:2543/svn branch:trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/com/itmill/toolkit/demo/reservation/SampleDB.java | 10 | ||||
-rw-r--r-- | src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java | 32 |
2 files changed, 31 insertions, 11 deletions
diff --git a/src/com/itmill/toolkit/demo/reservation/SampleDB.java b/src/com/itmill/toolkit/demo/reservation/SampleDB.java index 7f2225eee1..764b7d9977 100644 --- a/src/com/itmill/toolkit/demo/reservation/SampleDB.java +++ b/src/com/itmill/toolkit/demo/reservation/SampleDB.java @@ -376,7 +376,7 @@ public class SampleDB { } public void generateReservations() { - int days = 10; + int days = 30; String descriptions[] = { "Picking up guests from airport", "Sightseeing with the guests", @@ -396,6 +396,9 @@ public class SampleDB { Container resources = getResources(c); Collection rIds = resources.getItemIds(); Calendar cal = Calendar.getInstance(); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); //cal.add(Calendar.DAY_OF_MONTH, -days); for (int i = 0;i<days;i++) { for (Iterator rit = rIds.iterator();rit.hasNext();) { @@ -406,9 +409,8 @@ public class SampleDB { Date start = new Date(cal.getTimeInMillis()); start.setHours(s); Date end = new Date(cal.getTimeInMillis()); - start.setHours(e); + end.setHours(e); addReservation(resource, 0, start, end, descriptions[(int)Math.floor(Math.random()*descriptions.length)]); - break; } cal.add(Calendar.DAY_OF_MONTH, 1); } @@ -426,7 +428,7 @@ public class SampleDB { "w/ company logo. 12m3 storage space.", "Turku", new Double(60.452171), new Double(22.2995) }, { "03", "03 Saab 93", - "Cabriolet<br/>Keys from the rental desk.", "Turku", + "Cabriolet. Keys from the rental desk.", "Turku", new Double(60.4507), new Double(22.295551) }, { "04", "04 Volvo S60", "Key from the rental desk.", "Turku", new Double(60.434722), new Double(22.224398) }, diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java index 8ba19ab790..9afbb2cfbb 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java @@ -194,7 +194,7 @@ public class ICalendar extends IDateField { private class EntrySource implements CalendarPanel.CalendarEntrySource {
- private HashMap items = new HashMap();
+ private HashMap dates = new HashMap();
public void addItem(UIDL item) {
String styleName = item.getStringAttribute("styleName");
@@ -207,16 +207,34 @@ public class ICalendar extends IDateField { String title = item.getStringAttribute("title");
String desc = item.getStringAttribute("description");
boolean notime = item.getBooleanAttribute("notime");
- if (items.containsKey(id)) {
- items.remove(id);
+ CalendarEntry entry = new CalendarEntry(styleName, startDate,
+ endDate, title, desc, notime);
+
+ // TODO should remove+readd if the same entry (id) is added again
+
+ for (Date d = entry.getStart(); d.getYear() <= entry.getEnd()
+ .getYear()
+ && d.getMonth() <= entry.getEnd().getYear()
+ && d.getDate() <= entry.getEnd().getDate(); d.setTime(d
+ .getTime() + 86400000)) {
+ String key = d.getYear() + "" + d.getMonth() + "" + d.getDate();
+ ArrayList l = (ArrayList) dates.get(key);
+ if (l == null) {
+ l = new ArrayList();
+ dates.put(key, l);
+ }
+ l.add(entry);
}
- items.put(id, new CalendarEntry(styleName, startDate, endDate,
- title, desc, notime));
}
public List getEntries(Date date, int resolution) {
+ List entries = (List) dates.get(date.getYear() + "" + date.getMonth() + ""
+ + date.getDate());
ArrayList res = new ArrayList();
- for (Iterator it = this.items.values().iterator(); it.hasNext();) {
+ if (entries == null) {
+ return res;
+ }
+ for (Iterator it = entries.iterator(); it.hasNext();) {
CalendarEntry item = (CalendarEntry) it.next();
if (DateTimeService.isInRange(date, item.getStart(), item
.getEnd(), resolution)) {
@@ -228,7 +246,7 @@ public class ICalendar extends IDateField { }
public void clear() {
- items.clear();
+ dates.clear();
}
}
|