-@import "googlemap/css/googlemap.css";
\ No newline at end of file
+@import "googlemap/css/googlemap.css";\r
+\r
+.i-datefield-entrycalendar-01 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-02 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-03 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-04 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-05 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-06 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-07 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-08 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-09 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-10 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-11 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-12 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-13 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-14 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-15 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-16 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-17 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-18 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-19 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-20 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-21 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-22 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-23 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-24 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-25 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-26 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-27 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-28 {\r
+ background-color: red;\r
+}\r
+.i-datefield-entrycalendar-29 {\r
+ background-color: red;\r
+}\r
+\r
import com.itmill.toolkit.terminal.gwt.client.DateTimeService;\r
\r
public class CalendarEntry {\r
+ private String styleName;\r
private Date start;\r
private Date end;\r
private String title;\r
private String description;\r
private boolean notime;\r
\r
- public CalendarEntry(Date start, Date end, String title,\r
+ public CalendarEntry(String styleName, Date start, Date end, String title,\r
String description, boolean notime) {\r
+ this.styleName = styleName;\r
if (notime) {\r
Date d = new Date(start.getTime());\r
d.setSeconds(0);\r
this.notime = notime;\r
}\r
\r
- public CalendarEntry(Date start, Date end, String title, String description) {\r
- this(start, end, title, description, false);\r
+ public CalendarEntry(String styleName, Date start, Date end, String title,\r
+ String description) {\r
+ this(styleName, start, end, title, description, false);\r
+ }\r
+\r
+ public String getStyleName() {\r
+ return styleName;\r
}\r
\r
public Date getStart() {\r
import java.util.Iterator;\r
import java.util.List;\r
\r
+import com.google.gwt.user.client.DOM;\r
+import com.google.gwt.user.client.Element;\r
import com.google.gwt.user.client.ui.FlexTable;\r
-import com.google.gwt.user.client.ui.HTMLTable;\r
import com.google.gwt.user.client.ui.SimplePanel;\r
import com.google.gwt.user.client.ui.SourcesTableEvents;\r
import com.google.gwt.user.client.ui.TableListener;\r
\r
private CalendarPanel calPanel;\r
\r
- private HTMLTable hourTable;\r
+ private SimplePanel hourPanel;\r
+\r
+ private FlexTable hourTable;\r
\r
private EntrySource entrySource;\r
\r
}\r
\r
protected void buildDayView(Date date) {\r
- boolean firstRender = false;\r
- if (this.hourTable == null) {\r
- hourTable = new FlexTable();\r
- firstRender = true;\r
- hourTable.addTableListener(this.ftListener);\r
- SimplePanel p = new SimplePanel();\r
- p.add(hourTable);\r
- p.setStyleName(CLASSNAME + "-hours");\r
+ if (this.hourPanel == null) {\r
+ this.hourPanel = new SimplePanel();\r
+ this.hourPanel.setStyleName(CLASSNAME + "-hours");\r
this.calPanel.getFlexCellFormatter().setColSpan(8, 0, 7);\r
- this.calPanel.setWidget(8, 0, p);\r
+ this.calPanel.setWidget(8, 0, this.hourPanel);\r
+ } else {\r
+ this.hourPanel.clear();\r
}\r
- Date curr = new Date(date.getTime());\r
+ this.hourTable = new FlexTable();\r
+ this.hourTable.addTableListener(this.ftListener);\r
+ this.hourPanel.add(this.hourTable);\r
+ this.hourTable.setCellSpacing(1);\r
+\r
for (int i = 0; i < 24; i++) {\r
- curr.setHours(i);\r
String style = (i % 2 == 0 ? "even" : "odd");\r
if (realResolution >= RESOLUTION_HOUR) {\r
if (this.date != null && this.date.getHours() == i) {\r
}\r
hourTable.getRowFormatter().setStyleName(i,\r
CLASSNAME + "-row-" + style);\r
- if (firstRender) {\r
- String hstr = (i < 10 ? "0" : "") + i + ":00";\r
- if (this.dts.isTwelveHourClock()) {\r
- String ampm = (i < 12 ? "am" : "pm");\r
- hstr = (i <= 12 ? i : i - 12) + ":00 " + ampm;\r
- }\r
- hourTable.setHTML(i, 0, "<span>" + hstr + "</span>");\r
- hourTable.getCellFormatter().setStyleName(i, 0,\r
- CLASSNAME + "-time");\r
+ String hstr = (i < 10 ? "0" : "") + i + ":00";\r
+ if (this.dts.isTwelveHourClock()) {\r
+ String ampm = (i < 12 ? "am" : "pm");\r
+ hstr = (i <= 12 ? i : i - 12) + ":00 " + ampm;\r
}\r
- List entries = this.entrySource.getEntries(curr,\r
- DateTimeService.RESOLUTION_HOUR);\r
- String text = "";\r
- if (entries != null) {\r
- for (Iterator it = entries.iterator(); it.hasNext();) {\r
- CalendarEntry entry = (CalendarEntry) it.next();\r
- String title = entry.getTitle();\r
- String desc = entry.getDescription();\r
- text += (text == "" ? "" : ", ");\r
- String e = "<span"\r
- + (desc != null ? " title=\"" + desc + "\"" : "")\r
- + ">";\r
- e += (title != null ? title : "?");\r
- e += "</span>";\r
- text += e;\r
- }\r
+ hourTable.setHTML(i, 0, "<span>" + hstr + "</span>");\r
+ hourTable.getCellFormatter()\r
+ .setStyleName(i, 0, CLASSNAME + "-time");\r
+ hourTable.getCellFormatter().setWidth(i, 0, "55");\r
+\r
+ }\r
+\r
+ List entries = this.entrySource.getEntries(date,\r
+ DateTimeService.RESOLUTION_DAY);\r
+ int currentCol = 1;\r
+ for (Iterator it = entries.iterator(); it.hasNext();) {\r
+ CalendarEntry entry = (CalendarEntry) it.next();\r
+ int start = 0;\r
+ int hours = 24;\r
+ if (!entry.isNotime()) {\r
+ Date d = entry.getStart();\r
+ start = (d.getDate() < date.getDate() ? 0 : d.getHours());\r
+ d = entry.getEnd();\r
+ hours = (d.getDate() > date.getDate() ? 24 : d.getHours())\r
+ - start;\r
+ }\r
+ int col = currentCol;\r
+ if (col > 1) {\r
+ while (!this.hourTable.isCellPresent(start, col - 1))\r
+ col--;\r
}\r
- hourTable.setHTML(i, 1, text);\r
- hourTable.getCellFormatter().setStyleName(i, 1,\r
- CLASSNAME + "-title");\r
+ this.hourTable.setHTML(start, col, "<span>" + entry.getTitle()\r
+ + "</span>");\r
+ this.hourTable.getFlexCellFormatter().setRowSpan(start, col, hours);\r
+ this.hourTable.getFlexCellFormatter().setStyleName(start, col,\r
+ CLASSNAME + "-entry");\r
+ String sn = entry.getStyleName();\r
+ if (sn != null && !sn.equals("")) {\r
+ this.hourTable.getFlexCellFormatter().addStyleName(start, col,\r
+ CLASSNAME + "-" + entry.getStyleName());\r
+ }\r
+ Element el = this.hourTable.getFlexCellFormatter().getElement(\r
+ start, col);\r
+ DOM.setElementProperty(el, "title", entry.getDescription());\r
+\r
+ currentCol++;\r
}\r
\r
}\r
private HashMap items = new HashMap();\r
\r
public void addItem(UIDL item) {\r
+ String styleName = item.getStringAttribute("styleName");\r
Integer id = new Integer(item.getIntAttribute("id"));\r
long start = Long.parseLong(item.getStringAttribute("start"));\r
Date startDate = new Date(start);\r
if (items.containsKey(id)) {\r
items.remove(id);\r
}\r
- items.put(id, new CalendarEntry(startDate, endDate, title, desc,\r
- notime));\r
+ items.put(id, new CalendarEntry(styleName, startDate, endDate,\r
+ title, desc, notime));\r
}\r
\r
public List getEntries(Date date, int resolution) {\r