1 31 32 package org.opencms.workplace.list; 33 34 import java.io.IOException ; 35 import java.util.Iterator ; 36 import java.util.List ; 37 38 import javax.servlet.ServletException ; 39 import javax.servlet.jsp.JspException ; 40 import javax.servlet.jsp.JspWriter ; 41 42 51 public class CmsMultiListDialog { 52 53 54 private A_CmsListDialog m_activeWp; 55 56 57 private List m_wps; 58 59 64 public CmsMultiListDialog(List wps) { 65 66 m_wps = wps; 67 Iterator i = m_wps.iterator(); 68 while (i.hasNext()) { 69 A_CmsListDialog wp = (A_CmsListDialog)i.next(); 70 if (wp.isActive()) { 71 m_activeWp = wp; 72 } 73 } 74 if (m_activeWp == null) { 75 m_activeWp = (A_CmsListDialog)m_wps.get(0); 76 } 77 } 78 79 86 public void displayDialog() throws JspException , IOException , ServletException { 87 88 displayDialog(false); 89 } 90 91 101 public void displayDialog(boolean writeLater) throws JspException , IOException , ServletException { 102 103 m_activeWp.actionDialog(); 105 if (m_activeWp.isForwarded()) { 106 return; 107 } 108 109 Iterator i = m_wps.iterator(); 110 while (i.hasNext()) { 111 A_CmsListDialog wp = (A_CmsListDialog)i.next(); 112 wp.refreshList(); 113 } 114 115 if (writeLater) { 116 return; 117 } 118 writeDialog(); 119 } 120 121 126 public A_CmsListDialog getActiveWp() { 127 128 return m_activeWp; 129 } 130 131 136 public boolean isForwarded() { 137 138 Iterator i = m_wps.iterator(); 139 while (i.hasNext()) { 140 A_CmsListDialog wp = (A_CmsListDialog)i.next(); 141 if (wp.isForwarded()) { 142 return true; 143 } 144 } 145 return false; 146 } 147 148 153 public void writeDialog() throws IOException { 154 155 JspWriter out = m_activeWp.getJsp().getJspContext().getOut(); 156 out.print(defaultActionHtml()); 157 } 158 159 164 protected String defaultActionHtml() { 165 166 StringBuffer result = new StringBuffer (2048); 167 result.append(defaultActionHtmlStart()); 168 result.append(defaultActionHtmlContent()); 169 result.append(defaultActionHtmlEnd()); 170 return result.toString(); 171 } 172 173 178 protected String defaultActionHtmlContent() { 179 180 StringBuffer result = new StringBuffer (2048); 181 result.append("<table id='twolists' cellpadding='0' cellspacing='0' align='center' width='100%'>\n"); 182 Iterator i = m_wps.iterator(); 183 while (i.hasNext()) { 184 A_CmsListDialog wp = (A_CmsListDialog)i.next(); 185 result.append("\t<tr>\n"); 186 result.append("\t\t<td valign='top'>\n"); 187 result.append("\t\t\t").append(wp.defaultActionHtmlContent()).append("\n"); 188 result.append("\t\t</td>\n"); 189 result.append("\t</tr>\n"); 190 result.append("\t<tr><td height='20'/></tr>\n"); 191 } 192 result.append("</table>\n"); 193 return result.toString(); 194 } 195 196 201 protected String defaultActionHtmlEnd() { 202 203 return m_activeWp.defaultActionHtmlEnd() + m_activeWp.dialogContentEnd(); 204 } 205 206 211 protected String defaultActionHtmlStart() { 212 213 return m_activeWp.getList().listJs(getActiveWp().getLocale()) 214 + m_activeWp.dialogContentStart(getActiveWp().getParamTitle()); 215 } 216 } 217 | Popular Tags |