001: /*
002: * JFolder, Copyright 2001-2006 Gary Steinmetz
003: *
004: * Distributable under LGPL license.
005: * See terms of license at gnu.org.
006: */
007:
008: package org.jfolder.console.view.display;
009:
010: //base classes
011: import java.io.IOException;
012: import java.util.ArrayList;
013: import java.util.HashMap;
014:
015: //project specific classes
016: import org.jfolder.common.UnexpectedSystemException;
017: import org.jfolder.common.function.WebPageTagInstanceViewContextInfo;
018: import org.jfolder.common.utils.xml.XMLHelper;
019: import org.jfolder.common.web.template.ConsoleTemplateContext;
020: import org.jfolder.common.web.template.ConsoleTemplateSession;
021: import org.jfolder.common.web.template.PageSetupContext;
022: import org.jfolder.common.web.template.RcthConstraintBuilderDirectiveStep;
023: import org.jfolder.console.view.base.PopUpViewHolder;
024: import org.jfolder.console.view.base.PopUpViewTitleHelper;
025:
026: //other classes
027:
028: public class PopUpViewIterativeHelper {
029:
030: //
031: private PopUpViewIterativeHelper() {
032: }
033:
034: //
035: //
036: //
037: protected final static void displayIterativeHtmlView(
038: PopUpViewHolder inPuvh) {
039: //
040: //
041: //
042: //
043: try {
044: //
045: //
046: //ConsolePageContext localCpc = inPuvh.getConsolePageContext();
047: //ConsolePageSession localCps =
048: // localCpc.getConsolePageSession();
049: ConsoleTemplateContext localCtc = inPuvh
050: .getConsoleTemplateContext();
051: ConsoleTemplateSession localCts = inPuvh
052: .getConsoleTemplateSession();
053: PageSetupContext localPsc = localCts.getPageSetupContext();
054: //
055: //
056: //generate title
057: //
058: //
059: String nonHtmlsTitle = PopUpViewTitleHelper
060: .constructIterativeTitle(inPuvh);
061: //
062: //
063: //generate pop-up
064: //
065: //
066: inPuvh.pushStudioMacroEditDirectiveAsPopUp();
067: //
068: String nonHtmlPopUp[] = PopUpViewSelector
069: .createNonHtmlPopUp(inPuvh, 0, inPuvh.getInfo()
070: .getContentLength(), false, true);
071: //String nonHtmlPopUpId = localCts.getPreviousToggleLink();
072: //
073: //
074: //
075: //
076: //
077: //
078: //generate drop-down ids
079: //
080: String subSectionIds[] = new String[((inPuvh.getInfo()
081: .getContentLength() / 3))];
082: StringBuffer closeSubSections = new StringBuffer();
083: int icount1 = inPuvh.getInfo().getContentLength();
084: for (int i = 0; i < icount1; i = i + 3) {
085: //
086: localCts.pushToggleLinkDontRecordThisBranch();
087: localCts.pushToggleLinkWebPageViewIterativeSubSection();
088: localCts.pushToggleLink(((i / 3) + 1) + "");
089: //
090: String nextId = localCts.getToggleLink();
091: //
092: localCts.popToggleLink();
093: localCts.popToggleLink();
094: localCts.popToggleLink();
095: //
096: subSectionIds[((i / 3))] = nextId;
097: closeSubSections.append(" closeSection('" + nextId
098: + "');");
099: }
100: //
101: //generate drop-down
102: //
103: ArrayList dropDownLabels = new ArrayList();
104: ArrayList dropDownValues = new ArrayList();
105: //
106: //
107: int icount2 = inPuvh.getInfo().getContentLength();
108: for (int i = 0; i < icount2; i = i + 3) {
109: dropDownLabels.add(((i / 3) + 1) + "");
110: dropDownValues.add("openSection('"
111: + subSectionIds[((i / 3))] + "')");
112: }
113: //
114: //
115: HashMap dropDownAttrs = new HashMap();
116: dropDownAttrs.put("onclick", "stopEventPropogation(event)");
117: HashMap dropDownStyles = new HashMap();
118: //
119: dropDownStyles.put("font-size", "8pt");
120: //
121: String dropDownOnChange = closeSubSections
122: + " eval(this.value);";
123: //
124: String dropDownContent = localCtc.createDropDownBox(
125: //inIdIndex + "", dropDownLabels, dropDownValues,
126: localPsc.getWebPageViewPopUpCount() + "",
127: dropDownLabels, dropDownValues, dropDownAttrs,
128: dropDownStyles, 0, null, dropDownOnChange, null);
129: String dropDownId = localCts.getPreviousToggleLink();
130: //
131: //
132: //
133: //
134: //
135: //
136: //
137: //display
138: //
139: //
140: inPuvh
141: .appendText("<table"
142: + " cellspacing=\"0\" cellpadding=\"0\""
143: + " style=\"display: inline-block; border: 1px solid black\">"
144: + "<tr>" + "<td>");
145: //
146: String popUpId = PopUpViewSelector.constructPopUpLink(
147: nonHtmlPopUp[0], nonHtmlPopUp[1], nonHtmlsTitle,
148: inPuvh, (nonHtmlPopUp[2] != null));
149: //
150: //
151: //
152: //ArrayList localActions = new ArrayList();
153: //
154: inPuvh.popStudioMacroEditDirectiveAsPopUp(popUpId);
155: //
156: //
157: //
158: inPuvh.appendText("</td><td>" + XMLHelper.NBSP_XML
159: + "</td>");
160: inPuvh.appendText("<td align=\"right\">");
161: inPuvh.appendText(dropDownContent);
162: inPuvh.appendText("</td></tr>");
163: //
164: //
165: int icount = inPuvh.getInfo().getContentLength();
166: for (int i = 0; i < icount; i = i + 3) {
167: //
168: inPuvh.pushStudioMacroEditDirectiveAsHtmlIterative();
169: //
170: //
171: WebPageTagInstanceViewContextInfo nextWptivci = inPuvh
172: .getInfo().getContentAsInfo(i + 1);
173: //
174: String display = "none";
175: if (i == 0) {
176: display = "block";
177: }
178: //
179: inPuvh.appendText("<tr style=\"display: " + display
180: + "\" id=\"" + subSectionIds[((i / 3))]
181: + "\"><td colspan=\"3\">");
182: //
183: //
184: PopUpViewSelector
185: .chooseSubHtmlView(inPuvh, nextWptivci);
186: //
187: inPuvh.appendText("</td></tr>");
188: //
189: //
190: inPuvh.popStudioMacroEditDirectiveAsHtmlIterative(
191: dropDownId,
192: ((String) dropDownValues.get(i / 3)),
193: closeSubSections + " " + "openSection('"
194: + subSectionIds[((i / 3))] + "')");
195: //
196: }
197: //
198: inPuvh.appendText("</table>");
199: //
200: //
201: } catch (IOException ioe) {
202: throw new UnexpectedSystemException(ioe);
203: }
204: //
205: //
206: //
207: }
208: //
209: //
210: //
211: }
|