📄 htmlraplablock.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.plugin.abstractcalendar;
import java.util.Date;
import org.rapla.components.calendarview.html.HTMLBlock;
import org.rapla.components.util.xml.XMLWriter;
import org.rapla.entities.domain.Allocatable;
import org.rapla.entities.dynamictype.Attribute;
import org.rapla.framework.RaplaException;
import org.rapla.gui.internal.view.AppointmentInfoUI;
class HTMLRaplaBlock extends AbstractRaplaBlock implements HTMLBlock {
private int m_day;
private int m_row;
private int m_rowCount;
private int index = 0;
public void setStart(Date start) {
m_start = start;
}
public void setEnd(Date end) {
m_end = end;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public void setRowCount(int rows) {
m_rowCount = rows;
}
public void setRow(int row) {
m_row = row;
}
public int getRowCount() {
return m_rowCount;
}
public int getRow() {
return m_row;
}
public void setDay(int day) {
m_day = day;
}
public int getDay() {
return m_day;
}
public String getBackgroundColor() {
return getColorsAsHex()[0];
}
public String toString() {
StringBuffer buf = new StringBuffer();
String label = XMLWriter.encode(getName( getReservation()));
String timeString = getTimeString();
if ( getContext().isAnonymous()) {
String anonymous = "    ???";
if ( timeString != null) {
return timeString + " " + anonymous;
} else {
return anonymous;
}
}
if ( timeString != null) {
label = timeString + "<br/>" + label;
}
try {
AppointmentInfoUI reservationInfo = new AppointmentInfoUI(getContext().getBuildContext().getServiceManager());
String url = null;
Attribute[] attributes = getReservation().getClassification().getAttributes();
for ( int i=0;i<attributes.length;i++) {
String value = getReservation().getClassification().getValueAsString( attributes[i],getBuildContext().getRaplaLocale().getLocale());
if ( value == null)
continue;
int httpStart =value.indexOf("http://");
if ( httpStart < 0)
continue;
int httpEnd = Math.max( value.indexOf(" ")-1, value.length());
url = value.substring( httpStart, httpEnd );
}
buf.append( "<a href=\"");
if ( url != null) {
buf.append( url );
} else {
buf.append( "#" + index );
}
buf.append( "\">" );
if ( url != null) {
buf.append( "<span class=\"link\">");
}
buf.append( label );
if ( url != null) {
buf.append( "</span>");
}
buf.append( "<span class=\"tooltip\">");
buf.append(reservationInfo.getTooltip(getAppointment()));
buf.append( "</span>");
buf.append( "</a>" );
} catch (RaplaException ex) {
buf.append( label );
}
if (getBuildContext().isPersonVisible()) {
Allocatable[] persons = getReservation().getPersons();
for (int i=0; i<persons.length;i ++) {
if (!getContext().isVisible(persons[i]))
continue;
buf.append("<br>");
buf.append("<span class=\"person\">");
buf.append(XMLWriter.encode(getName(persons[i])));
buf.append("</span>");
}
}
if (getBuildContext().isResourceVisible()) {
Allocatable[] resources = getReservation().getResources();
for (int i=0; i<resources.length;i ++) {
if (!getContext().isVisible(resources[i]))
continue;
buf.append("<br>");
buf.append("<span class=\"resource\">");
buf.append(XMLWriter.encode(getName(resources[i])));
buf.append("</span>");
}
}
return buf.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -