aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/itmill/toolkit/demo/reservation/ReservationApplication.java4
-rw-r--r--src/com/itmill/toolkit/demo/reservation/gwt/public/reservr/styles.css91
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarEntry.java13
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java106
4 files changed, 166 insertions, 48 deletions
diff --git a/src/com/itmill/toolkit/demo/reservation/ReservationApplication.java b/src/com/itmill/toolkit/demo/reservation/ReservationApplication.java
index 2f9d8da779..b5b59c8ba6 100644
--- a/src/com/itmill/toolkit/demo/reservation/ReservationApplication.java
+++ b/src/com/itmill/toolkit/demo/reservation/ReservationApplication.java
@@ -31,7 +31,8 @@ public class ReservationApplication extends Application {
private CalendarField reservedFrom;
private static final long DEFAULT_GAP_MILLIS = 3600000; // one hour
- private long currentGapMillis = DEFAULT_GAP_MILLIS;
+ private long currentGapMillis = DEFAULT_GAP_MILLIS; // current length of
+ // reservation
private CalendarField reservedTo;
private Label resourceName;
@@ -262,6 +263,7 @@ public class ReservationApplication extends Application {
}
private void initCalendarFieldPropertyIds(CalendarField cal) {
+ cal.setItemStyleNamePropertyId(SampleDB.Resource.PROPERTY_ID_STYLENAME);
cal
.setItemStartPropertyId(SampleDB.Reservation.PROPERTY_ID_RESERVED_FROM);
cal.setItemEndPropertyId(SampleDB.Reservation.PROPERTY_ID_RESERVED_TO);
diff --git a/src/com/itmill/toolkit/demo/reservation/gwt/public/reservr/styles.css b/src/com/itmill/toolkit/demo/reservation/gwt/public/reservr/styles.css
index 14761b77e1..b0e3510e92 100644
--- a/src/com/itmill/toolkit/demo/reservation/gwt/public/reservr/styles.css
+++ b/src/com/itmill/toolkit/demo/reservation/gwt/public/reservr/styles.css
@@ -1 +1,90 @@
-@import "googlemap/css/googlemap.css"; \ No newline at end of file
+@import "googlemap/css/googlemap.css";
+
+.i-datefield-entrycalendar-01 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-02 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-03 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-04 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-05 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-06 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-07 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-08 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-09 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-10 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-11 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-12 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-13 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-14 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-15 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-16 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-17 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-18 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-19 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-20 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-21 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-22 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-23 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-24 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-25 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-26 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-27 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-28 {
+ background-color: red;
+}
+.i-datefield-entrycalendar-29 {
+ background-color: red;
+}
+
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarEntry.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarEntry.java
index 56447949e1..cebdee2b71 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarEntry.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarEntry.java
@@ -5,14 +5,16 @@ import java.util.Date;
import com.itmill.toolkit.terminal.gwt.client.DateTimeService;
public class CalendarEntry {
+ private String styleName;
private Date start;
private Date end;
private String title;
private String description;
private boolean notime;
- public CalendarEntry(Date start, Date end, String title,
+ public CalendarEntry(String styleName, Date start, Date end, String title,
String description, boolean notime) {
+ this.styleName = styleName;
if (notime) {
Date d = new Date(start.getTime());
d.setSeconds(0);
@@ -35,8 +37,13 @@ public class CalendarEntry {
this.notime = notime;
}
- public CalendarEntry(Date start, Date end, String title, String description) {
- this(start, end, title, description, false);
+ public CalendarEntry(String styleName, Date start, Date end, String title,
+ String description) {
+ this(styleName, start, end, title, description, false);
+ }
+
+ public String getStyleName() {
+ return styleName;
}
public Date getStart() {
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 dea6ee2d54..098456ab72 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/ICalendar.java
@@ -6,8 +6,9 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.FlexTable;
-import com.google.gwt.user.client.ui.HTMLTable;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.SourcesTableEvents;
import com.google.gwt.user.client.ui.TableListener;
@@ -19,7 +20,9 @@ public class ICalendar extends IDateField {
private CalendarPanel calPanel;
- private HTMLTable hourTable;
+ private SimplePanel hourPanel;
+
+ private FlexTable hourTable;
private EntrySource entrySource;
@@ -75,20 +78,20 @@ public class ICalendar extends IDateField {
}
protected void buildDayView(Date date) {
- boolean firstRender = false;
- if (this.hourTable == null) {
- hourTable = new FlexTable();
- firstRender = true;
- hourTable.addTableListener(this.ftListener);
- SimplePanel p = new SimplePanel();
- p.add(hourTable);
- p.setStyleName(CLASSNAME + "-hours");
+ if (this.hourPanel == null) {
+ this.hourPanel = new SimplePanel();
+ this.hourPanel.setStyleName(CLASSNAME + "-hours");
this.calPanel.getFlexCellFormatter().setColSpan(8, 0, 7);
- this.calPanel.setWidget(8, 0, p);
+ this.calPanel.setWidget(8, 0, this.hourPanel);
+ } else {
+ this.hourPanel.clear();
}
- Date curr = new Date(date.getTime());
+ this.hourTable = new FlexTable();
+ this.hourTable.addTableListener(this.ftListener);
+ this.hourPanel.add(this.hourTable);
+ this.hourTable.setCellSpacing(1);
+
for (int i = 0; i < 24; i++) {
- curr.setHours(i);
String style = (i % 2 == 0 ? "even" : "odd");
if (realResolution >= RESOLUTION_HOUR) {
if (this.date != null && this.date.getHours() == i) {
@@ -97,36 +100,52 @@ public class ICalendar extends IDateField {
}
hourTable.getRowFormatter().setStyleName(i,
CLASSNAME + "-row-" + style);
- if (firstRender) {
- String hstr = (i < 10 ? "0" : "") + i + ":00";
- if (this.dts.isTwelveHourClock()) {
- String ampm = (i < 12 ? "am" : "pm");
- hstr = (i <= 12 ? i : i - 12) + ":00 " + ampm;
- }
- hourTable.setHTML(i, 0, "<span>" + hstr + "</span>");
- hourTable.getCellFormatter().setStyleName(i, 0,
- CLASSNAME + "-time");
+ String hstr = (i < 10 ? "0" : "") + i + ":00";
+ if (this.dts.isTwelveHourClock()) {
+ String ampm = (i < 12 ? "am" : "pm");
+ hstr = (i <= 12 ? i : i - 12) + ":00 " + ampm;
}
- List entries = this.entrySource.getEntries(curr,
- DateTimeService.RESOLUTION_HOUR);
- String text = "";
- if (entries != null) {
- for (Iterator it = entries.iterator(); it.hasNext();) {
- CalendarEntry entry = (CalendarEntry) it.next();
- String title = entry.getTitle();
- String desc = entry.getDescription();
- text += (text == "" ? "" : ", ");
- String e = "<span"
- + (desc != null ? " title=\"" + desc + "\"" : "")
- + ">";
- e += (title != null ? title : "?");
- e += "</span>";
- text += e;
- }
+ hourTable.setHTML(i, 0, "<span>" + hstr + "</span>");
+ hourTable.getCellFormatter()
+ .setStyleName(i, 0, CLASSNAME + "-time");
+ hourTable.getCellFormatter().setWidth(i, 0, "55");
+
+ }
+
+ List entries = this.entrySource.getEntries(date,
+ DateTimeService.RESOLUTION_DAY);
+ int currentCol = 1;
+ for (Iterator it = entries.iterator(); it.hasNext();) {
+ CalendarEntry entry = (CalendarEntry) it.next();
+ int start = 0;
+ int hours = 24;
+ if (!entry.isNotime()) {
+ Date d = entry.getStart();
+ start = (d.getDate() < date.getDate() ? 0 : d.getHours());
+ d = entry.getEnd();
+ hours = (d.getDate() > date.getDate() ? 24 : d.getHours())
+ - start;
+ }
+ int col = currentCol;
+ if (col > 1) {
+ while (!this.hourTable.isCellPresent(start, col - 1))
+ col--;
}
- hourTable.setHTML(i, 1, text);
- hourTable.getCellFormatter().setStyleName(i, 1,
- CLASSNAME + "-title");
+ this.hourTable.setHTML(start, col, "<span>" + entry.getTitle()
+ + "</span>");
+ this.hourTable.getFlexCellFormatter().setRowSpan(start, col, hours);
+ this.hourTable.getFlexCellFormatter().setStyleName(start, col,
+ CLASSNAME + "-entry");
+ String sn = entry.getStyleName();
+ if (sn != null && !sn.equals("")) {
+ this.hourTable.getFlexCellFormatter().addStyleName(start, col,
+ CLASSNAME + "-" + entry.getStyleName());
+ }
+ Element el = this.hourTable.getFlexCellFormatter().getElement(
+ start, col);
+ DOM.setElementProperty(el, "title", entry.getDescription());
+
+ currentCol++;
}
}
@@ -148,6 +167,7 @@ public class ICalendar extends IDateField {
private HashMap items = new HashMap();
public void addItem(UIDL item) {
+ String styleName = item.getStringAttribute("styleName");
Integer id = new Integer(item.getIntAttribute("id"));
long start = Long.parseLong(item.getStringAttribute("start"));
Date startDate = new Date(start);
@@ -160,8 +180,8 @@ public class ICalendar extends IDateField {
if (items.containsKey(id)) {
items.remove(id);
}
- items.put(id, new CalendarEntry(startDate, endDate, title, desc,
- notime));
+ items.put(id, new CalendarEntry(styleName, startDate, endDate,
+ title, desc, notime));
}
public List getEntries(Date date, int resolution) {