From: Marc Englund Date: Wed, 17 Oct 2007 14:19:14 +0000 (+0000) Subject: Significant speedup. Added more generated data. X-Git-Tag: 6.7.0.beta1~5826 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=06354790d76aa44c4f86023dd43f0f137b8ee976;p=vaadin-framework.git Significant speedup. Added more generated data. svn changeset:2543/svn branch:trunk --- 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;iKeys 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(); } }