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.ArrayList;
012: import java.util.HashMap;
013:
014: //project specific classes
015: import org.jfolder.common.UnexpectedSystemException;
016: import org.jfolder.common.function.WebPageTagInstanceViewContext;
017: import org.jfolder.common.function.WebPageTagInstanceViewContextInfo;
018: import org.jfolder.common.function.WebPageTagInstanceViewContextSubHtmlInfo;
019: import org.jfolder.common.tagging.ConceptTag;
020: import org.jfolder.common.tagging.ConceptTagCharacteristicHolder;
021: import org.jfolder.common.tagging.ConceptTagConstraint;
022: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
023: import org.jfolder.common.tagging.ConceptTagHelper;
024: import org.jfolder.common.tagging.ConceptTagPreferences;
025: import org.jfolder.common.utils.misc.MiscHelper;
026: import org.jfolder.common.utils.xml.XMLHelper;
027: import org.jfolder.common.web.template.ConsoleTemplateSession;
028: import org.jfolder.common.web.template.RcthConstraintBuilderDirectiveStep;
029: import org.jfolder.console.view.base.PopUpViewHelper;
030: import org.jfolder.console.view.base.PopUpViewHolder;
031:
032: //other classes
033:
034: public class PopUpViewHtmlHelper {
035:
036: //
037: private PopUpViewHtmlHelper() {
038: }
039:
040: //
041: protected final static void displayHtmlView(PopUpViewHolder inPuvh) {
042: //
043: //
044: //
045: //
046: //
047: if (inPuvh.getInfo().isMultiPartHtmlContentPresent()) {
048: //
049: //
050: //
051: WebPageTagInstanceViewContextSubHtmlInfo subHtmlInfo = inPuvh
052: .getInfo().getContentAsSubHtml();
053: //
054: //
055: HashMap subHtmlAttrs = subHtmlInfo.getAttributes();
056: loadAttributes(inPuvh, subHtmlAttrs);
057: //
058: //
059: inPuvh.appendText("<" + subHtmlInfo.getName()
060: + XMLHelper.convertAttrs(subHtmlAttrs) + ">");
061: //inPuvh.appendText(inPuvh.getInfo().getStartFirstHalfContent());
062: //
063: //inPuvh.appendText(inPuvh.getInfo().getStartLastHalfContent());
064: } else if (inPuvh.getInfo().isNonHtmlPresent()) {
065: //
066: //
067: //
068: throw new UnexpectedSystemException("Unknown state for '"
069: + getConceptTag(inPuvh) + "'");
070: //inPuvh.appendText(inPuvh.getInfo().getNonHtmlEndContent());
071: } else if (inPuvh.getInfo().isHtmlContentPresent()) {
072: //
073: if (inPuvh.isMenuActive()) {
074: //
075: //
076: HashMap subHtmlAttrs = new HashMap();
077: loadAttributes(inPuvh, subHtmlAttrs);
078: //
079: //
080: inPuvh.appendText("<" + "span"
081: + XMLHelper.convertAttrs(subHtmlAttrs) + ">");
082: }
083: //
084: //
085: //if (inPuvh.getInfo().getHtmlStartContent() == null) {
086: // //
087: // MiscHelper.println("PopUpViewHtmlHelper null found");
088: //}
089: //
090: if (inPuvh.getInfo().isHtmlContentFormatted()) {
091: String text = inPuvh.getInfo().getHtmlStartContent();
092: //text = WebPageTagInstanceViewContext.convertTextToHtml(text);
093: inPuvh.appendText(text);
094: } else {
095: String text = inPuvh.getInfo().getHtmlStartContent();
096: text = WebPageTagInstanceViewContext
097: .convertTextToStudioHtml(text);
098: inPuvh.appendText(text);
099: }
100: //throw new UnexpectedSystemException(
101: // "Unknown state for '" + inPuvh.getToggleSuffix() + "'");
102: } else {
103: throw new UnexpectedSystemException("Unknown state for '"
104: + getConceptTag(inPuvh) + "'");
105: }
106: //
107: //
108: //
109: //
110: //
111: PopUpViewSelector.generateSubViewFromHtml(inPuvh);
112: //
113: //
114: //
115: //
116: //
117: if (inPuvh.getInfo().isMultiPartHtmlContentPresent()) {
118: //
119: WebPageTagInstanceViewContextSubHtmlInfo subHtmlInfo = inPuvh
120: .getInfo().getContentAsSubHtml();
121: inPuvh.appendText("</");
122: inPuvh.appendText(subHtmlInfo.getName());
123: inPuvh.appendText(">");
124: } else if (inPuvh.getInfo().isNonHtmlPresent()) {
125: throw new UnexpectedSystemException("Unknown state for '"
126: + getConceptTag(inPuvh) + "'");
127: //inPuvh.appendText(inPuvh.getInfo().getNonHtmlEndContent());
128: } else if (inPuvh.getInfo().isHtmlContentPresent()) {
129: //
130: if (inPuvh.getInfo().isHtmlContentFormatted()) {
131: String text = inPuvh.getInfo().getHtmlEndContent();
132: //text = WebPageTagInstanceViewContext.convertTextToHtml(text);
133: inPuvh.appendText(text);
134: } else {
135: String text = inPuvh.getInfo().getHtmlEndContent();
136: text = WebPageTagInstanceViewContext
137: .convertTextToStudioHtml(text);
138: inPuvh.appendText(text);
139: }
140: //
141: if (inPuvh.isMenuActive()) {
142: inPuvh.appendText("</span>");
143:
144: }
145: //throw new UnexpectedSystemException(
146: // "Unknown state for '" + inPuvh.getToggleSuffix() + "'");
147: } else {
148: throw new UnexpectedSystemException("Unknown state for '"
149: + getConceptTag(inPuvh) + "'");
150: }
151: //
152: }
153:
154: //
155: //
156: //
157: //
158: //
159: //
160: private final static String getConceptTag(PopUpViewHolder inPuvh) {
161:
162: String outValue = null;
163:
164: ConceptTagConstraint localCtcon = PopUpViewHelper
165: .getConstraint(inPuvh.getConstraint(), inPuvh
166: .getStaticIndex(), inPuvh.getConstraintHolder());
167: ConceptTagConstraintHolder localCtconh = PopUpViewHelper
168: .getConstraintHolder(inPuvh.getConstraint(), inPuvh
169: .getStaticIndex(), inPuvh.getConstraintHolder());
170: int localCtconIndex = PopUpViewHelper.getConstraintIndex(inPuvh
171: .getConstraint(), inPuvh.getStaticIndex(), inPuvh
172: .getConstraintHolder());
173: //
174: ConceptTagPreferences localCtp = localCtcon.getPreferences();
175: //
176: String localHandle = localCtcon.getCharacteristic()
177: .getHandleWithoutIndex();
178: if (localCtconh != null) {
179: localHandle = localCtconh.getCharacteristicHolder()
180: .getHandle();
181: }
182: //
183: ConceptTagConstraintHolder localCtCtconh = ConceptTagHelper
184: .getNearestConceptTag(localCtp.getRootHolder(),
185: localHandle, new StringBuffer());
186: ConceptTagCharacteristicHolder localCtCtcharh = localCtconh
187: .getCharacteristicHolder();
188:
189: ConceptTag localCt = localCtCtcharh.getConceptTag();
190:
191: outValue = localCt.getClass().getName();
192:
193: return outValue;
194: }
195:
196: //
197: //
198: //
199: private final static void loadAttributes(PopUpViewHolder inPuvh,
200: HashMap inAttrs) {
201: //
202: if (inPuvh.isMenuActive()) {
203: //
204: //
205: inPuvh.pushStudioMacroEditDirectiveAsTarget();
206: //
207: //
208: //
209: String subHtmlAction = PopUpViewHelper
210: .createStudioUsabilityPopUp(inPuvh, false, true,
211: true);
212: inAttrs.put("onclick", subHtmlAction);
213: //
214: //
215: //
216: //
217: ConsoleTemplateSession localCts = inPuvh
218: .getConsoleTemplateSession();
219: localCts.pushToggleLinkAnchorPoint();
220: localCts.pushToggleLink(inPuvh.incrementCurrentIdCount()
221: + "");
222: String localId = localCts.getToggleLink();
223: localCts.popToggleLink();
224: localCts.popToggleLink();
225: //
226: inAttrs.put("id", localId);
227: //
228: //
229: //
230: boolean localErrorPresent = PopUpViewHelper
231: .isLocalErrorPresent(inPuvh.getConstraint(), inPuvh
232: .getStaticIndex(), inPuvh
233: .getConstraintHolder());
234: if (localErrorPresent) {
235: inPuvh.setDescendentErrorPresent(localErrorPresent);
236: }
237: String mouseOutBorder = inPuvh.getInfo()
238: .getMouseOutBorder();
239: if ((inPuvh.getErrorId() != null || inPuvh
240: .isEarmarkErrorPresent())
241: && inPuvh.getInfo().getIdHandle().length > 0) {
242: //
243: mouseOutBorder = WebPageTagInstanceViewContextInfo
244: .getErrorBorder();
245: }
246: //
247: String mouseOverBorder = inPuvh.getInfo()
248: .getMouseOverBorder();
249: //
250: inAttrs.put("onmouseout", "this.style.border = '"
251: + mouseOutBorder + "';"
252: + " stopEventPropogation(event);");
253: inAttrs.put("onmouseover", "this.style.border = '"
254: + mouseOverBorder + "';"
255: + " studioCloseAllMenus(this);"
256: + " stopEventPropogation(event);");
257: if (inPuvh.getInfo().isMultiPartHtmlContentPresent()
258: && inPuvh.getInfo().getContentAsSubHtml()
259: .isStylesPresent()) {
260: //
261: inAttrs.put("style", "border: "
262: + mouseOutBorder
263: + "; "
264: + XMLHelper.fromStylesToAttr(inPuvh.getInfo()
265: .getContentAsSubHtml().getStyles()));
266: } else {
267: inAttrs.put("style", "border: " + mouseOutBorder);
268: }
269: inAttrs.put("title", PopUpViewHelper.getTitle(inPuvh));
270: //
271: //
272: //
273: String localHandleParent = inPuvh.getHandleParent();
274: Integer localHandleIndex = inPuvh.getHandleIndex();
275: //
276: ArrayList localActions = new ArrayList();
277: localActions.add(PopUpViewHelper
278: .createStudioUsabilityPopUp(inPuvh, false, false,
279: false));
280: PopUpViewHelper.generateStudioUsabilityPopUpSelection(
281: inPuvh, false, localActions);
282: //
283: ArrayList localParentActions = new ArrayList();
284: localParentActions.add(PopUpViewHelper
285: .createStudioUsabilityPopUp(inPuvh, false, false,
286: false));
287: PopUpViewHelper.generateStudioUsabilityPopUpSelection(
288: inPuvh, true, localParentActions);
289: //
290: inPuvh.popStudioMacroEditDirectiveAsTarget(localId,
291: localHandleParent, localHandleIndex, localActions,
292: localParentActions);
293: //
294: //
295: }
296: }
297: }
|