Author: sdzmitrovich
Date: 2007-11-05 03:38:37 -0500 (Mon, 05 Nov 2007)
New Revision: 4692
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1247
corrected view of calendar( sometimes shifted weeks )
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java 2007-11-04
19:09:11 UTC (rev 4691)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCalendarTemplate.java 2007-11-05
08:38:37 UTC (rev 4692)
@@ -309,12 +309,15 @@
Calendar cal = Calendar.getInstance();
int month = cal.get(Calendar.MONTH);
- int day = cal.get(Calendar.DAY_OF_WEEK);
int dayN = cal.get(Calendar.DAY_OF_MONTH);
- int start = day - (dayN % NUM_DAYS_IN_WEEK + cal.getFirstDayOfWeek());
- cal.add(Calendar.DAY_OF_MONTH, -(start + dayN));
+ // shift 'cal' to month's start
+ cal.add(Calendar.DAY_OF_MONTH, -dayN);
+ // shift 'cal' to week's start
+ cal.add(Calendar.DAY_OF_MONTH, -(cal.get(Calendar.DAY_OF_WEEK) - cal
+ .getFirstDayOfWeek()));
+ //for number of week
for (int i = NUM_WEEK_ON_PAGE; i > 0; i--) {
nsIDOMElement tr = visualDocument
@@ -328,6 +331,8 @@
+ cal.get(Calendar.WEEK_OF_YEAR));
weekTD.appendChild(weekText);
tr.appendChild(weekTD);
+
+ //for number of days in week
for (int j = NUM_DAYS_IN_WEEK; j > 0; j--) {
nsIDOMElement td = visualDocument
@@ -337,6 +342,7 @@
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
+ // if 'cal' is a member of month
if (cal.get(Calendar.MONTH) == month) {
// if this is current day
@@ -344,13 +350,18 @@
&& cal.get(Calendar.MONTH) == month) {
currentAttr = TODAY_HTML_CLASS_ATTR;
- } else if (dayOfWeek == Calendar.SATURDAY
+ }
+ // if this is holiday
+ else if (dayOfWeek == Calendar.SATURDAY
|| dayOfWeek == Calendar.SUNDAY) {
currentAttr = HOL_CUR_MONTH_HTML_CLASS_ATTR;
} else {
currentAttr = CUR_MONTH_HTML_CLASS_ATTR;
}
- } else {
+ }
+ // if 'cal' isn't a member of month
+ else {
+ // if this is holiday
if (dayOfWeek == Calendar.SATURDAY
|| dayOfWeek == Calendar.SUNDAY) {
currentAttr = HOL_OTHER_MONTH_HTML_CLASS_ATTR;