From: Marc Englund Date: Tue, 23 Oct 2007 07:01:24 +0000 (+0000) Subject: ICalendar -> demo.reservation (part II) X-Git-Tag: 6.7.0.beta1~5788 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=485a8906e9f3a1c086869c3a94e7d0b0309922c5;p=vaadin-framework.git ICalendar -> demo.reservation (part II) svn changeset:2582/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/demo/reservation/gwt/client/ui/CalendarEntry.java b/src/com/itmill/toolkit/demo/reservation/gwt/client/ui/CalendarEntry.java deleted file mode 100644 index 424a4ff586..0000000000 --- a/src/com/itmill/toolkit/demo/reservation/gwt/client/ui/CalendarEntry.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.itmill.toolkit.demo.reservation.gwt.client.ui; - -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(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); - d.setMinutes(0); - this.start = d; - if (end != null) { - d = new Date(end.getTime()); - d.setSeconds(0); - d.setMinutes(0); - this.end = d; - } else { - end = start; - } - } else { - this.start = start; - this.end = end; - } - this.title = title; - this.description = description; - this.notime = notime; - } - - 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() { - return start; - } - - public void setStart(Date start) { - this.start = start; - } - - public Date getEnd() { - return end; - } - - public void setEnd(Date end) { - this.end = end; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public boolean isNotime() { - return notime; - } - - public void setNotime(boolean notime) { - this.notime = notime; - } - - public String getStringForDate(Date d) { - // TODO format from DateTimeService - String s = ""; - if (!notime) { - if (!DateTimeService.isSameDay(d, start)) { - s += (start.getYear() + 1900) + "." + (start.getMonth() + 1) - + "." + start.getDate() + " "; - } - int i = start.getHours(); - s += (i < 10 ? "0" : "") + i; - s += ":"; - i = start.getMinutes(); - s += (i < 10 ? "0" : "") + i; - if (!start.equals(end)) { - s += " - "; - if (!DateTimeService.isSameDay(start, end)) { - s += (end.getYear() + 1900) + "." + (end.getMonth() + 1) - + "." + end.getDate() + " "; - } - i = end.getHours(); - s += (i < 10 ? "0" : "") + i; - s += ":"; - i = end.getMinutes(); - s += (i < 10 ? "0" : "") + i; - } - s += " "; - } - if (title!=null) { - s += title; - } - return s; - } - -} \ No newline at end of file diff --git a/src/com/itmill/toolkit/demo/reservation/gwt/client/ui/ICalendar.java b/src/com/itmill/toolkit/demo/reservation/gwt/client/ui/ICalendar.java index 03845a8e22..3dadb9a2f6 100644 --- a/src/com/itmill/toolkit/demo/reservation/gwt/client/ui/ICalendar.java +++ b/src/com/itmill/toolkit/demo/reservation/gwt/client/ui/ICalendar.java @@ -15,6 +15,7 @@ import com.google.gwt.user.client.ui.TableListener; import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection; import com.itmill.toolkit.terminal.gwt.client.DateTimeService; import com.itmill.toolkit.terminal.gwt.client.UIDL; +import com.itmill.toolkit.terminal.gwt.client.ui.CalendarEntry; import com.itmill.toolkit.terminal.gwt.client.ui.CalendarPanel; import com.itmill.toolkit.terminal.gwt.client.ui.IDateField; import com.itmill.toolkit.terminal.gwt.client.ui.CalendarPanel.CalendarEntrySource; diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarEntry.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarEntry.java new file mode 100644 index 0000000000..075f68cbf6 --- /dev/null +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarEntry.java @@ -0,0 +1,122 @@ +package com.itmill.toolkit.terminal.gwt.client.ui; + +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(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); + d.setMinutes(0); + this.start = d; + if (end != null) { + d = new Date(end.getTime()); + d.setSeconds(0); + d.setMinutes(0); + this.end = d; + } else { + end = start; + } + } else { + this.start = start; + this.end = end; + } + this.title = title; + this.description = description; + this.notime = notime; + } + + 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() { + return start; + } + + public void setStart(Date start) { + this.start = start; + } + + public Date getEnd() { + return end; + } + + public void setEnd(Date end) { + this.end = end; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public boolean isNotime() { + return notime; + } + + public void setNotime(boolean notime) { + this.notime = notime; + } + + public String getStringForDate(Date d) { + // TODO format from DateTimeService + String s = ""; + if (!notime) { + if (!DateTimeService.isSameDay(d, start)) { + s += (start.getYear() + 1900) + "." + (start.getMonth() + 1) + + "." + start.getDate() + " "; + } + int i = start.getHours(); + s += (i < 10 ? "0" : "") + i; + s += ":"; + i = start.getMinutes(); + s += (i < 10 ? "0" : "") + i; + if (!start.equals(end)) { + s += " - "; + if (!DateTimeService.isSameDay(start, end)) { + s += (end.getYear() + 1900) + "." + (end.getMonth() + 1) + + "." + end.getDate() + " "; + } + i = end.getHours(); + s += (i < 10 ? "0" : "") + i; + s += ":"; + i = end.getMinutes(); + s += (i < 10 ? "0" : "") + i; + } + s += " "; + } + if (title!=null) { + s += title; + } + return s; + } + +} \ No newline at end of file diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarPanel.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarPanel.java index 6eb7749f26..0fc60e25dc 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarPanel.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/CalendarPanel.java @@ -15,7 +15,6 @@ import com.google.gwt.user.client.ui.SourcesMouseEvents; import com.google.gwt.user.client.ui.SourcesTableEvents; import com.google.gwt.user.client.ui.TableListener; import com.google.gwt.user.client.ui.Widget; -import com.itmill.toolkit.demo.reservation.gwt.client.ui.CalendarEntry; import com.itmill.toolkit.terminal.gwt.client.DateTimeService; import com.itmill.toolkit.terminal.gwt.client.LocaleService;