📄 webpage.java
字号:
/*
* @(#)WebPage.java
*
* Copyright (C) 2006 Sergey Bredikhin
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package olivax.webmail;
import java.io.Writer;
import java.util.Vector;
import oliva.common.OlivaUtils;
public class WebPage {
private Vector rows = new Vector(10);
private WebPane lastPane = null;
private Vector lastRow = null;
public WebPage() {
}
public void addPane(WebPane pane) {
if(pane == null)
return;
flushLast();
lastPane = pane;
}
private void flushLast() {
if (lastPane != null) {
if (lastRow != null) {
lastRow.add(lastPane);
rows.add(lastRow);
lastRow = null;
} else
rows.add(lastPane);
}
}
public void addPaneToSameRow(WebPane pane) {
if(pane == null)
return;
if(lastPane == null) {
lastPane = pane;
return;
}
if(lastRow == null) {
lastRow = new Vector(5);
}
lastRow.add(lastPane);
lastPane = pane;
}
private String showRow(Vector row) {
StringBuffer sb = new StringBuffer();
sb.append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n");
sb.append("<tr>\r\n");
for(int i = 0; i < row.size(); i++) {
WebPane pane = (WebPane)row.get(i);
if(OlivaUtils.nvl(pane.getWidth()).equals(""))
sb.append("<td>\r\n");
else
sb.append("<td width=\"100%\">\r\n");
sb.append("\r\n").append(pane.show()).append("\r\n");
sb.append("</td>\r\n");
}
sb.append("</tr>\r\n");
sb.append("</table>\r\n");
return sb.toString();
}
public void show(Writer writer) throws Exception {
flushLast();
for(int i = 0; i < rows.size(); i++) {
Object row = rows.get(i);
if(row instanceof WebPane)
writer.write(((WebPane)row).show());
else if(row instanceof Vector)
writer.write(showRow((Vector)row));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -