001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/calendar/tags/sakai_2-4-1/calendar-summary-tool/tool/src/java/org/sakaiproject/tool/summarycalendar/ui/Day.java $
003: * $Id: Day.java 22354 2007-03-09 15:13:14Z nuno@ufp.pt $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2006, 2007 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.tool.summarycalendar.ui;
021:
022: import java.io.Serializable;
023: import java.text.SimpleDateFormat;
024: import java.util.Calendar;
025: import java.util.Date;
026: import java.util.List;
027:
028: public class Day implements Serializable {
029: private static final long serialVersionUID = 1136403394613377956L;
030: public final static String STYLE_TODAY = "calToday";
031: public final static String STYLE_SELECTEDDAY = "calSelectedDay";
032: public final static String STYLE_WITH_ACTIVITY = "calDayWithActivity";
033: public final static String STYLE_WITHOUT_ACTIVITY = "calDayWithoutActivity";
034: public final static String STYLE_OTHER_WITHOUT_ACTIVITY = "calOtherDayWithNoActivity";
035:
036: Date date = null;
037: String styleClass = "";
038: List eventSummaryList = null;
039: boolean hasEvents = false;
040:
041: int dayOfMonth = -1;
042: boolean isToday = false;
043: boolean occursInOtherMonth = false;
044: boolean isSelected = false;
045:
046: String backgroundCSSProperty = "";
047:
048: public Day() {
049: }
050:
051: public Day(Date date, boolean hasEvents) {
052: this .hasEvents = hasEvents;
053: this .date = date;
054: }
055:
056: public void setDate(Date date) {
057: this .date = date;
058: }
059:
060: public String getDateAsString() {
061: SimpleDateFormat formatter = new SimpleDateFormat(
062: CalendarBean.DATE_FORMAT);
063: return formatter.format(date);
064: }
065:
066: public int getDayOfMonth() {
067: if (dayOfMonth == -1) {
068: Calendar c = Calendar.getInstance();
069: c.setTime(date);
070: dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
071: }
072: return dayOfMonth;
073: }
074:
075: public boolean getHasEvents() {
076: return hasEvents;
077: }
078:
079: public void setHasEvents(boolean hasEvents) {
080: this .hasEvents = hasEvents;
081: }
082:
083: public String getStyleClass() {
084: StringBuffer buff = new StringBuffer();
085: if (isToday)
086: buff.append(" " + STYLE_TODAY + " ");
087: if (occursInOtherMonth && !hasEvents)
088: buff.append(" " + STYLE_OTHER_WITHOUT_ACTIVITY + " ");
089: else {
090: if (hasEvents)
091: buff.append(" " + STYLE_WITH_ACTIVITY + " ");
092: else
093: buff.append(" " + STYLE_WITHOUT_ACTIVITY + " ");
094: if (isSelected)
095: buff.append(" " + STYLE_SELECTEDDAY + " ");
096: }
097: this .styleClass = buff.toString();
098: return this .styleClass;
099: }
100:
101: public void setBackgroundCSSProperty(String color) {
102: this .backgroundCSSProperty = color;
103: }
104:
105: public String getBackgroundCSSProperty() {
106: return this .backgroundCSSProperty;
107: }
108:
109: public void setToday(boolean val) {
110: this .isToday = val;
111: }
112:
113: public void setOccursInOtherMonth(boolean val) {
114: this .occursInOtherMonth = val;
115: }
116:
117: public boolean isSelected() {
118: return isSelected;
119: }
120:
121: public void setSelected(boolean isSelected) {
122: this.isSelected = isSelected;
123: }
124:
125: }
|