📄 abstracthtmlview.java
字号:
/*--------------------------------------------------------------------------*
| Copyright (C) 2006 Christopher Kohlhaas |
| |
| This program is free software; you can redistribute it and/or modify |
| it under the terms of the GNU General Public License as published by the |
| Free Software Foundation. A copy of the license has been included with |
| these distribution in the COPYING file, if not go to www.fsf.org |
| |
| As a special exception, you are granted the permissions to link this |
| program with every library, which license fulfills the Open Source |
| Definition as published by the Open Source Initiative (OSI). |
*--------------------------------------------------------------------------*/
package org.rapla.components.calendarview.html;
import java.util.*;
import org.rapla.components.calendarview.Block;
import org.rapla.components.calendarview.Builder;
import org.rapla.components.calendarview.CalendarView;
import org.rapla.components.calendarview.WeekdayMapper;
import org.rapla.components.calendarview.BlockComparator;
public abstract class AbstractHTMLView implements CalendarView {
public static String COLOR_NO_RESOURCE = "#BBEEBB";
protected Collection builders = new ArrayList();
/** shared calendar instance. Only used for temporary stored values. */
Calendar blockCalendar;
WeekdayMapper weekdayMapper;
Date startDate;
Date endDate;
String m_html;
protected Collection excludeDays = Collections.EMPTY_SET;
Locale locale;
TimeZone timeZone;
Builder builder;
public void setTimeZone(TimeZone timeZone) {
this.timeZone = timeZone;
if ( locale != null) {
blockCalendar = createCalendar();
}
}
public void setLocale(Locale locale) {
this.locale = locale;
if ( timeZone != null) {
blockCalendar = createCalendar();
}
weekdayMapper = new WeekdayMapper( locale );
}
public TimeZone getTimeZone() {
return timeZone;
}
public void addBuilder(Builder b) {
builders.add(b);
}
public void removeBuilder(Builder b) {
builders.remove(b);
}
public void rebuild(Builder builder) {
try {
addBuilder( builder);
rebuild();
} finally {
removeBuilder( builder );
}
}
public void setToDate(Date weekDate) {
calcMinMaxDates( weekDate );
}
public void setExcludeDays(Collection excludeDays) {
this.excludeDays = excludeDays;
if (startDate != null)
calcMinMaxDates( startDate );
}
abstract public Collection getBlocks();
abstract void calcMinMaxDates( Date date );
Calendar createCalendar() {
return Calendar.getInstance(getTimeZone(),locale);
}
void checkBlock( Block bl ) {
if ( !bl.getStart().before(this.endDate)) {
throw new IllegalStateException("Start-date " +bl.getStart() + " must be before calendar end at " +this.endDate);
}
}
public Date getStartDate() {
return startDate;
}
public Date getEndDate() {
return endDate;
}
public String getHtml() {
return m_html;
}
protected class HTMLSmallDaySlot extends ArrayList {
private static final long serialVersionUID = 1L;
private String date;
public HTMLSmallDaySlot(String date) {
super(2);
this.date = date;
}
public void putBlock(Block block) {
add( block );
}
public void sort() {
Collections.sort( this, BlockComparator.COMPARATOR);
}
public void paint(StringBuffer out) {
out.append("<div valign=\"top\" align=\"right\">");
out.append( date );
out.append("</div>\n");
for ( int i=0;i<size();i++) {
Block block = (Block) get(i);
out.append("<div valign=\"top\" class=\"month_block\"");
if ( block instanceof HTMLBlock ) {
out.append(" style=\"background-color:" + ((HTMLBlock)block).getBackgroundColor() + ";\"");
}
out.append(">");
out.append(block.toString());
out.append("</div>\n");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -