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.util.HashMap;
012:
013: //project specific classes
014: import org.jfolder.common.UnexpectedSystemException;
015: import org.jfolder.common.function.WebPageTagInstanceViewContextInfo;
016: import org.jfolder.common.utils.misc.MiscHelper;
017: import org.jfolder.common.utils.xml.XMLHelper;
018: import org.jfolder.common.web.template.ConsoleTemplateContext;
019: import org.jfolder.console.view.base.PopUpViewHelper;
020: import org.jfolder.console.view.base.PopUpViewHolder;
021:
022: //other classes
023:
024: public class PopUpViewPlainHelper {
025:
026: //
027: //private final static int INDENT_INCREMENT = 4;
028: //
029: private PopUpViewPlainHelper() {
030: }
031:
032: //
033: //
034: //
035: protected final static void displayPlainView(
036: PopUpViewHolder inPuvh, int inIndent, boolean inLimitDepth) {
037: //
038: //
039: if (inPuvh.getInfo().isMarkedAsNonHtml()) {
040: subProcessNonHtmlAsInline(inPuvh, inIndent, inLimitDepth);
041: } else if (inPuvh.getInfo().isMarkedAsIterativeNonHtml()) {
042: subProcessIterativeNonHtmlAsInline(inPuvh, inIndent,
043: inLimitDepth);
044: } else {
045: throw UnexpectedSystemException.unknownState();
046: }
047: //
048: }
049:
050: private final static void subProcessNonHtmlAsInline(
051: PopUpViewHolder inPuvh, int inIndent, boolean inLimitDepth) {
052: //
053: //
054: PopUpViewHelper.createPopUpNonHtmlSpanStart(inPuvh);
055: //
056: PopUpViewHelper.createPopUpNonHtmlSpanMiddle(inPuvh, inPuvh
057: .getInfo().getNonHtmlStartContent());
058: //
059: //
060: //
061: if (!inLimitDepth) {
062: for (int i = 0; i < inPuvh.getInfo().getContentLength(); i++) {
063: //
064: WebPageTagInstanceViewContextInfo nextWptivci = inPuvh
065: .getInfo().getContentAsInfo(i);
066: //
067: //
068: PopUpViewSelector.choosePlainView(inPuvh, nextWptivci,
069: inIndent, inLimitDepth);
070: }
071: }
072: //
073: //
074: //
075: //
076: PopUpViewHelper.createPopUpNonHtmlSpanMiddle(inPuvh, inPuvh
077: .getInfo().getNonHtmlEndContent());
078: //
079: //
080: PopUpViewHelper.createPopUpNonHtmlSpanEnd(inPuvh);
081: }
082:
083: private final static void subProcessIterativeNonHtmlAsInline(
084: PopUpViewHolder inPuvh, int inIndent, boolean inLimitDepth) {
085: //
086: //
087: if (inPuvh.getInfo().getIdHandle().length > 0) {
088: renderSelectableNonHtmlStart(inPuvh);
089: }
090: //
091: for (int i = 0; i < inPuvh.getInfo().getContentLength(); i = i + 3) {
092: //
093: //
094: WebPageTagInstanceViewContextInfo nextStartWptivci = inPuvh
095: .getInfo().getContentAsInfo(i);
096: WebPageTagInstanceViewContextInfo nextMiddleWptivci = inPuvh
097: .getInfo().getContentAsInfo(i + 1);
098: WebPageTagInstanceViewContextInfo nextEndWptivci = inPuvh
099: .getInfo().getContentAsInfo(i + 2);
100: //
101: //
102: //
103: ////////////////////////////////////////////////
104: //write beginning content
105: //
106: PopUpViewSelector.choosePlainView(inPuvh, nextStartWptivci,
107: inIndent, inLimitDepth);
108: //
109: //
110: ////////////////////////////////////////////////
111: //write middle content
112: //
113: int nextIndent = inIndent + 1;//INDENT_INCREMENT;
114: //
115: //String subPad = MiscHelper.fixString(
116: // "", nextIndent + INDENT_INCREMENT) + "//";
117: //
118: //
119: if (!inLimitDepth) {
120: //subPad = XMLHelper.fromStringToHTML(subPad) + "<br/>";
121: //
122: inPuvh.appendText("<table><tr><td width=\"");
123: inPuvh.appendText((nextIndent * 20) + "");
124: inPuvh.appendText("\">");
125: inPuvh.appendText(ConsoleTemplateContext.padNbsp(1));
126: inPuvh.appendText("</td><td>//</td></tr></table>");
127: //
128: //
129: //inPuvh.appendText("<br/>");
130: ////
131: //inPuvh.appendText(subPad);
132: //
133: //
134: PopUpViewSelector.choosePlainVertical(inPuvh,
135: nextMiddleWptivci, nextIndent, inLimitDepth);
136: //
137: //
138: //inPuvh.appendText("<br/>");
139: //
140: inPuvh.appendText("<table><tr><td width=\"");
141: inPuvh.appendText((nextIndent * 20) + "");
142: inPuvh.appendText("\">");
143: inPuvh.appendText(ConsoleTemplateContext.padNbsp(1));
144: inPuvh.appendText("</td><td>//</td></tr></table>");
145: }
146: //
147: //
148: //
149: //
150: //
151: ////////////////////////////////////////////////
152: //write end content
153: //
154: //
155: String endStartContent = nextEndWptivci
156: .getNonHtmlStartContent();
157: String endEndContent = nextEndWptivci
158: .getNonHtmlEndContent();
159:
160: if ((endStartContent != null && endStartContent.length() > 0)
161: || (endEndContent != null && endEndContent.length() > 0)
162: || nextEndWptivci.getContentLength() > 0) {
163: //
164: //if (!inLimitDepth) {
165: // inPuvh.appendText(subPad);
166: //}
167: //inPuvh.appendText(XMLHelper.fromStringToHTML(
168: // MiscHelper.fixString("", nextIndent)));
169: //
170: //
171: PopUpViewSelector.choosePlainView(inPuvh,
172: nextEndWptivci, inIndent, inLimitDepth);
173: //
174: }
175: //
176: }
177: //
178: //
179: if (inPuvh.getInfo().getIdHandle().length > 0) {
180: renderSelectableNonHtmlEnd(inPuvh);
181: }
182: //
183: }
184:
185: //
186: //
187: //
188: protected final static void renderSelectableNonHtmlStart(
189: PopUpViewHolder inPuvh) {
190: //
191: //
192: HashMap attrs = PopUpViewHelper.getBorderAreaAttributes(inPuvh,
193: true);
194: //PopUpViewHelper.createPopUpNonHtmlSpanStart(inPuvh);
195: inPuvh.appendText("<table ");
196: inPuvh.appendText(XMLHelper.convertAttrs(attrs));
197: inPuvh.appendText("><tr><td>");
198: }
199:
200: protected final static void renderSelectableNonHtmlEnd(
201: PopUpViewHolder inPuvh) {
202: //
203: //
204: //PopUpViewHelper.createPopUpNonHtmlSpanEnd(inPuvh);
205: inPuvh.appendText("</td></tr></table>");
206: }
207: }
|