📄 calendarview.java
字号:
/*
*
* Copyright (c) 2004 SourceTap - www.sourcetap.com
*
* The contents of this file are subject to the SourceTap Public License
* ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
*/
package com.sourcetap.sfa.activity;
import java.util.Calendar;
/**
* DOCUMENT ME!
*
*/
public class CalendarView {
public static final int MONTH_VIEW = 0;
public static final int DAY_VIEW = 0;
public static final int WEEK_VIEW = 0;
private static final int currentMonth = Calendar.getInstance().get(Calendar.MONTH) +
1;
private static final int currentYear = Calendar.getInstance().get(Calendar.YEAR);
private static final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
public CalendarView() {
}
/**
* DOCUMENT ME!
*
* @return
*/
public static String getCalendar() {
return "";
}
/**
* DOCUMENT ME!
*
* @param year
* @param month
* @param day
* @param destURL
*
* @return
*/
public static String getSmallMonthCalendarHTML(int year, int month,
int day, String destURL) {
Calendar calendar = CalendarUtil.getCalendar(year, month, 1);
int firstDay = calendar.get(Calendar.DAY_OF_WEEK);
int rows;
if (((CalendarUtil.daysInMonth[month] == 31) && (firstDay >= 6)) ||
((CalendarUtil.daysInMonth[month] == 30) && (firstDay == 7))) {
rows = 6;
} else if ((CalendarUtil.daysInMonth[month] == 28) && (firstDay == 1)) {
rows = 4;
} else {
rows = 5;
}
StringBuffer returnString = new StringBuffer();
returnString.append(
"<table class=\"tabularSectionTitleTable\" width=\"100%\">\n");
returnString.append(" <tr>\n");
returnString.append(" <td>\n");
returnString.append(" " + smallMonthHeader(year, month) + "\n");
returnString.append(" </td>\n");
returnString.append(" </tr>\n");
returnString.append("</table>\n");
returnString.append(
"<table class=\"tabularSectionDisplayTable\" width=\"100%\">\n");
//style=\"border: 0.02cm solid black; border-collapse: collapse; table-layout: fixed; \" border=\"0\"
returnString.append(" <tr class=\"tabularSectionLabel\">\n");
for (int i = 0; i < 7; i++) {
returnString.append(" <td>\n");
returnString.append(" " +
CalendarUtil.dayLabel[i].substring(0, 2) + "\n");
returnString.append(" </td>\n");
}
returnString.append(" </tr>\n");
int dayCounter = 1;
int loopCounter = 1;
String dayDetail = "";
for (int j = 1; j <= rows; j++) {
returnString.append(" <tr>\n");
for (int i = 1; i < 8; i++) {
returnString.append(" <td class=\"tabularSectionField\"");
// if it is a valid day of the month
if ((loopCounter >= firstDay) &&
(dayCounter <= CalendarUtil.daysInMonth[month])) {
// if the counter is on today
if ((dayCounter == currentDay) && (month == currentMonth) &&
(year == currentYear)) {
returnString.append(" bgcolor=\"#C0C0C0\"");
}
returnString.append(">\n");
// See if this is the currently selected day.
if ((dayCounter == day) && (month == currentMonth) &&
(year == currentYear)) {
returnString.append("<B>");
}
returnString.append(
" <a href=\"/sfa/control/frontpage?action=day&day=" +
dayCounter + "&month=" + month + "&year=" +
year + " \">\n");
returnString.append(" " + dayCounter + "\n");
returnString.append(" </a>\n");
if ((dayCounter == day) && (month == currentMonth) &&
(year == currentYear)) {
returnString.append("</B>");
}
returnString.append(" <br>\n");
dayCounter++;
} else {
// not a valid day, make a blank cell
returnString.append(">\n");
returnString.append(" \n");
}
returnString.append(" </td>\n");
loopCounter++;
}
// returnString.append("<td align=\"center\"><div class=\"tabletext\"><a href=\"/sfa/control/activityCalendar?action=week&day=" + (dayCounter-1) + "&month=" + month + "&year=" + year + "\" >w<br>e<br>e<br>k</a></div></td>");
returnString.append(" </tr>\n");
}
returnString.append("</table>");
return returnString.toString();
}
/**
* DOCUMENT ME!
*
* @param year
* @param month
*
* @return
*/
private static String monthHeader(int year, int month) {
StringBuffer returnString = new StringBuffer();
if (month == Calendar.FEBRUARY) {
CalendarUtil.daysInMonth[2] = (((year % 400) == 0) ||
(((year % 4) == 0) && ((year % 100) != 0))) ? 29 : 28;
}
returnString.append(
"<a href=\"/sfa/control/activityCalendar?action=month&month=" +
((month != 1) ? (month - 1) : 12) + "&year=" +
((month != 1) ? year : (year - 1)) + " \"><</a> ");
returnString.append(CalendarUtil.monthLabel[month]);
returnString.append(" ");
returnString.append(year);
returnString.append(
" <a href=\"/sfa/control/activityCalendar?action=month&month=" +
((month != 12) ? (month + 1) : 1) + "&year=" +
((month != 12) ? year : (year + 1)) + " \">></a> ");
return returnString.toString();
}
/**
* DOCUMENT ME!
*
* @param year
* @param month
*
* @return
*/
private static String smallMonthHeader(int year, int month) {
StringBuffer returnString = new StringBuffer();
if (month == Calendar.FEBRUARY) {
CalendarUtil.daysInMonth[2] = (((year % 400) == 0) ||
(((year % 4) == 0) && ((year % 100) != 0))) ? 29 : 28;
}
returnString.append(
" <a class=\"tabularSectionAnchorSelected\" href=\"/sfa/control/frontpage?action=month&month=" +
((month != 1) ? (month - 1) : 12) + "&year=" +
((month != 1) ? year : (year - 1)) + " \">\n");
returnString.append(" <<\n");
returnString.append(" </a>\n");
returnString.append(" \n");
returnString.append(CalendarUtil.monthLabel[month]);
returnString.append(" ");
returnString.append(year);
returnString.append(" ");
returnString.append(
" <a class=\"tabularSectionAnchorSelected\" href=\"/sfa/control/frontpage?action=month&month=" +
((month != 12) ? (month + 1) : 1) + "&year=" +
((month != 12) ? year : (year + 1)) + " \">\n");
returnString.append(" >>\n");
returnString.append(" </a>\n");
returnString.append(" \n");
return returnString.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -