0001: /*
0002: * JFolder, Copyright 2001-2006 Gary Steinmetz
0003: *
0004: * Distributable under LGPL license.
0005: * See terms of license at gnu.org.
0006: */
0007:
0008: package org.jfolder.console.view.display;
0009:
0010: //base classes
0011: import java.util.ArrayList;
0012: import java.util.HashMap;
0013:
0014: //project specific classes
0015: import org.jfolder.common.UnexpectedSystemException;
0016: import org.jfolder.common.function.WebPageTagInstanceViewContextInfo;
0017: import org.jfolder.common.tagging.ConceptTag;
0018: import org.jfolder.common.tagging.ConceptTagCharacteristic;
0019: import org.jfolder.common.tagging.ConceptTagCharacteristicHolder;
0020: import org.jfolder.common.tagging.ConceptTagConstraint;
0021: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
0022: import org.jfolder.common.tagging.ConceptTagHelper;
0023: import org.jfolder.common.tagging.ConceptTagPreferences;
0024: import org.jfolder.common.utils.misc.CommonSeparators;
0025: import org.jfolder.common.utils.misc.MiscHelper;
0026: import org.jfolder.common.utils.xml.XMLHelper;
0027: import org.jfolder.common.web.template.ConsoleTemplateContext;
0028: import org.jfolder.common.web.template.ConsoleTemplateParameters;
0029: import org.jfolder.common.web.template.ConsoleTemplateSession;
0030: import org.jfolder.common.web.template.PageSetupContext;
0031: import org.jfolder.common.web.template.RcthConstraintBuilderDirectiveStep;
0032: import org.jfolder.console.view.base.PopUpViewHelper;
0033: import org.jfolder.console.view.base.PopUpViewHolder;
0034: import org.jfolder.console.view.base.PopUpViewTitleHelper;
0035:
0036: //other classes
0037:
0038: public class PopUpViewSelector {
0039:
0040: //
0041: public final static int TYPE__PLAIN = 1;
0042: public final static int TYPE__HTML = 2;
0043: public final static int TYPE__ITERATIVE = 3;
0044: public final static int TYPE__SUB_HTML = 4;
0045: public final static int TYPE__ITERATIVE_HTML = 5;
0046: public final static int TYPE__PLAIN_VERTICAL = 6;
0047: public final static int TYPE__PLAIN_POP_UP = 7;
0048:
0049: //
0050: private PopUpViewSelector() {
0051: }
0052:
0053: //
0054: protected final static void chooseHtmlView(PopUpViewHolder inPuvh,
0055: WebPageTagInstanceViewContextInfo inWptivci) {
0056: //
0057: chooseView(inPuvh, TYPE__HTML, inWptivci, 0, false);
0058: }
0059:
0060: protected final static void choosePlainView(PopUpViewHolder inPuvh,
0061: WebPageTagInstanceViewContextInfo inWptivci, int inIndent,
0062: boolean inLimitDepth) {
0063: //
0064: chooseView(inPuvh, TYPE__PLAIN, inWptivci, inIndent,
0065: inLimitDepth);
0066: }
0067:
0068: protected final static void chooseSubHtmlView(
0069: PopUpViewHolder inPuvh,
0070: WebPageTagInstanceViewContextInfo inWptivci) {
0071: //
0072: chooseView(inPuvh, TYPE__SUB_HTML, inWptivci, 0, false);
0073: }
0074:
0075: protected final static void chooseIterativeHtmlView(
0076: PopUpViewHolder inPuvh,
0077: WebPageTagInstanceViewContextInfo inWptivci) {
0078: //
0079: chooseView(inPuvh, TYPE__ITERATIVE_HTML, inWptivci, 0, false);
0080: }
0081:
0082: protected final static void choosePlainVertical(
0083: PopUpViewHolder inPuvh,
0084: WebPageTagInstanceViewContextInfo inWptivci, int inIndent,
0085: boolean inLimitDepth) {
0086: //
0087: chooseView(inPuvh, TYPE__PLAIN_VERTICAL, inWptivci, inIndent,
0088: inLimitDepth);
0089: }
0090:
0091: private final static String[] choosePlainPopUp(
0092: PopUpViewHolder inPuvh,
0093: WebPageTagInstanceViewContextInfo inWptivci) {
0094: //
0095: return chooseView(inPuvh, TYPE__PLAIN_POP_UP, inWptivci, 0,
0096: false);
0097: }
0098:
0099: //
0100: private final static String[] chooseView(PopUpViewHolder inPuvh,
0101: int inType, WebPageTagInstanceViewContextInfo inWptivci,
0102: int inIndent, boolean inLimitDepth) {
0103: //
0104: String outValue[] = null;
0105: //
0106: //
0107: WebPageTagInstanceViewContextInfo parentWptivci[] = new WebPageTagInstanceViewContextInfo[1];
0108: String parentEarmark[][] = new String[1][];
0109: String parentErrorId[] = new String[1];
0110: boolean parentMenuPresent[] = new boolean[1];
0111: String parentDefaultConstraint[] = new String[1];
0112: int parentCurrentIdCount[] = new int[1];
0113: pushIdHandle(inPuvh, inWptivci, parentWptivci, parentEarmark,
0114: parentErrorId, parentMenuPresent,
0115: parentDefaultConstraint, parentCurrentIdCount);
0116: //
0117: //
0118: //
0119: if (inType == TYPE__HTML) {
0120: PopUpViewHtmlHelper.displayHtmlView(inPuvh);
0121: } else if (inType == TYPE__PLAIN) {
0122: PopUpViewPlainHelper.displayPlainView(inPuvh, inIndent,
0123: inLimitDepth);
0124: } else if (inType == TYPE__SUB_HTML) {
0125: generateSubViewFromHtml(inPuvh);
0126: } else if (inType == TYPE__ITERATIVE_HTML) {
0127: PopUpViewIterativeHelper.displayIterativeHtmlView(inPuvh);
0128: } else if (inType == TYPE__PLAIN_VERTICAL) {
0129: processNonHtmlVertically(inPuvh, 0, inWptivci
0130: .getContentLength(), inIndent, inLimitDepth);
0131: } else if (inType == TYPE__PLAIN_POP_UP) {
0132: outValue = createNonHtmlPopUp(inPuvh, 0, inWptivci
0133: .getContentLength(), false, false);
0134: //processNonHtmlVertically(
0135: // inPuvh, 0, inWptivci.getContentLength(),
0136: // inIndent, inLimitDepth);
0137: } else {
0138: throw new UnexpectedSystemException("Unknown Type '"
0139: + inType + "'");
0140: }
0141: //
0142: //
0143: //
0144: popIdHandle(inPuvh, parentWptivci, parentEarmark,
0145: parentErrorId, parentMenuPresent,
0146: parentDefaultConstraint, parentCurrentIdCount);
0147: //
0148: //
0149: return outValue;
0150: }
0151:
0152: //
0153: //
0154: //
0155: //
0156: private final static void pushIdHandle(PopUpViewHolder inPuvh,
0157: WebPageTagInstanceViewContextInfo inWptivci,
0158: WebPageTagInstanceViewContextInfo inParentWptivci[],
0159: String inParentEarmark[][], String inParentErrorId[],
0160: boolean inParentMenuActive[],
0161: String inParentDefaultConstraint[],
0162: int inParentCurrentIdCount[]) {
0163: //
0164: //
0165: //
0166: //PUSH - GENERAL
0167: if (true) {
0168: inWptivci.markPush();
0169: }
0170: //
0171: //
0172: //PUSH - INFO
0173: if (true) {
0174: inParentWptivci[0] = inPuvh.getInfo();
0175: inPuvh.setInfo(inWptivci);
0176: }
0177: //
0178: //
0179: //PUSH - CTCHAR
0180: if (true) {
0181: //
0182: //
0183: ConsoleTemplateSession localCts = inPuvh
0184: .getConsoleTemplateSession();
0185: //
0186: Object idHandle[] = inPuvh.getInfo().getIdHandle();
0187: for (int i = 0; i < idHandle.length; i++) {
0188: //
0189: //
0190: //
0191: ConceptTagConstraintHolder puvhCtconh = inPuvh
0192: .getConstraintHolder();
0193: ConceptTagConstraint puvhCtcon = inPuvh.getConstraint();
0194: Integer puvhStaticIndex = inPuvh.getStaticIndex();
0195: //
0196: //
0197: //
0198: Object nextIdPartObj = idHandle[i];
0199: //
0200: String nextIdPart = null;
0201: ConceptTagCharacteristic nextIdPartCtchar = null;
0202: Integer nextIdPartInt = null;
0203: //
0204: if (nextIdPartObj instanceof ConceptTagCharacteristic) {
0205: nextIdPartCtchar = ((ConceptTagCharacteristic) nextIdPartObj);
0206: nextIdPart = nextIdPartCtchar.getConstraintName();
0207: } else if (nextIdPartObj instanceof Integer) {
0208: nextIdPartInt = ((Integer) nextIdPartObj);
0209: nextIdPart = nextIdPartInt.toString();
0210: } else {
0211: throw UnexpectedSystemException.unknownState();
0212: }
0213: //
0214: localCts.pushToggleLink(nextIdPart);
0215: inPuvh.getToggleSuffix().add(nextIdPart);
0216: //
0217: //
0218: if (puvhStaticIndex == null && puvhCtcon != null
0219: && puvhCtconh == null) {
0220: //
0221: int nextIdIndex = Integer.parseInt(nextIdPart);
0222: ConceptTagCharacteristic localCtchar = puvhCtcon
0223: .getCharacteristic();
0224: //
0225: //TO DO: null should be replaced by inIctc,
0226: // no big deal though
0227: if (localCtchar.isHolder(nextIdIndex, null)) {
0228: //
0229: inPuvh.setConstraintHolder(puvhCtcon
0230: .getConstraintHolder(nextIdIndex));
0231: inPuvh.setConstraint(null);
0232: } else {
0233: inPuvh.setStaticIndex(new Integer(nextIdIndex));
0234: }
0235: } else if (puvhStaticIndex == null && puvhCtcon == null
0236: && puvhCtconh != null) {
0237: //
0238: ConceptTagPreferences localCtp = inPuvh
0239: .getConstraintHolder().getPreferences();
0240: //
0241: if (localCtp.getAttributeConstraintName().equals(
0242: nextIdPart)) {
0243: //
0244: inPuvh.setConstraintHolder(puvhCtconh
0245: .getAttributes());
0246: } else if (localCtp.getStyleConstraintName()
0247: .equals(nextIdPart)) {
0248: //
0249: inPuvh.setConstraintHolder(puvhCtconh
0250: .getStyles());
0251: } else {
0252: //if (nextIdPartCtchar == )
0253: ConceptTagConstraint nextLocalCtcon = null;
0254: ConceptTagCharacteristic nextLocalCtchar = null;
0255: if (localCtp.getUnconstrainedSymbol().equals(
0256: nextIdPart)) {
0257: //
0258: nextLocalCtcon = puvhCtconh
0259: .getUndefinedConstraint();
0260: nextLocalCtchar = nextLocalCtcon
0261: .getCharacteristic();
0262: } else {
0263: nextLocalCtcon = puvhCtconh
0264: .getConstraint(nextIdPart);
0265: nextLocalCtchar = nextLocalCtcon
0266: .getCharacteristic();
0267: }
0268: //
0269: //
0270: //
0271: if (nextIdPartCtchar == nextLocalCtchar) {
0272: //
0273: inPuvh.setConstraintHolder(null);
0274: inPuvh.setConstraint(nextLocalCtcon);
0275: //
0276: } else {
0277: //ConceptTagCharacteristic nextLocalCtchar =
0278: // nextLocalCtcon.getCharacteristic();
0279: //testE.printStackTrace();
0280: throw new UnexpectedSystemException(
0281: "Characteristic '"
0282: + nextLocalCtchar
0283: .getConstraintName()
0284: + "' does not equal '"
0285: + nextIdPartCtchar
0286: .getConstraintName()
0287: + "'");
0288: }
0289:
0290: }
0291: //
0292: } else {
0293: throw UnexpectedSystemException.unknownState();
0294: }
0295: //
0296: //
0297: //if (inCtcon[0] == null && inCtconh[0] == null) {
0298: // MiscHelper.println("Null Found = " + stackCount);
0299: //}
0300: //
0301: //
0302: //
0303: //
0304: //
0305: //if (idHandle[i] instanceof ConceptTagCharacteristic
0306: // && inPuvh.getConstraint() != null) {
0307: // //
0308: // ConceptTagCharacteristic ctchar1 =
0309: // ((ConceptTagCharacteristic)idHandle[i]);
0310: // ConceptTagCharacteristic ctchar2 =
0311: // inPuvh.getConstraint().getCharacteristic();
0312: // //
0313: // MiscHelper.println("<!----- PH ----->");
0314: // MiscHelper.println(
0315: // " ctchar1 = "
0316: // + ctchar1.getHandleAsArrayListWithoutIndex());
0317: // MiscHelper.println(
0318: // " ctchar2 = "
0319: // + ctchar2.getHandleAsArrayListWithoutIndex());
0320: // MiscHelper.println("<!----- PH ----->");
0321: //}
0322: }
0323: }
0324: //
0325: //
0326: //PUSH - EARMARK ID
0327: if (true) {
0328: if (inPuvh.getInfo().getIdHandle().length > 0) {
0329: //
0330: inParentEarmark[0] = inPuvh.getEarmark();
0331: if (inPuvh.getInfo().isSubEarmarkPresent()) {
0332: //
0333: inPuvh.pushStudioMacroEditDirectiveAsEarmark();
0334: //
0335: String localEarmark[] = choosePlainPopUp(inPuvh,
0336: inPuvh.getInfo().getSubEarmark());
0337: inPuvh.setEarmark(localEarmark);
0338: //
0339: //
0340: //ArrayList localActions = new ArrayList();
0341: //
0342: ConsoleTemplateSession localCts = inPuvh
0343: .getConsoleTemplateSession();
0344: //
0345: localCts.pushToggleLinkAnchorPoint();
0346: localCts.pushToggleLink("0");
0347: //
0348: inPuvh
0349: .popStudioMacroEditDirectiveAsEarmark(localCts
0350: .getToggleLink());
0351: //
0352: localCts.popToggleLink();
0353: localCts.popToggleLink();
0354: } else {
0355: inPuvh.setEarmark(null);
0356: }
0357: //
0358: }
0359: }
0360: //
0361: //
0362: //PUSH - ERROR ID, this is dependent on CTCHAR
0363: if (true) {
0364: //
0365: //
0366: if (inPuvh.getInfo().getIdHandle().length > 0) {
0367: //
0368: inParentErrorId[0] = inPuvh.getErrorId();
0369: //
0370: //
0371: //
0372: WebPageTagInstanceViewContextInfo errorInfo = PopUpViewHelper
0373: .getErrorInfo(inPuvh);
0374: //
0375: String errorId = null;
0376: if (errorInfo != null) {
0377: String errorRes[] = choosePlainPopUp(inPuvh,
0378: errorInfo);
0379: errorId = errorRes[1];
0380: }
0381: inPuvh.setErrorId(errorId);
0382: }
0383: }
0384: //
0385: //
0386: //PUSH - DEFAULT CONSTRAINT
0387: if (true) {
0388: if (inPuvh.getInfo().getIdHandle().length > 0) {
0389: inParentDefaultConstraint[0] = inPuvh
0390: .getDefaultConstraint();
0391: inPuvh.setDefaultConstraint(inPuvh.getInfo()
0392: .getDefaultConstraint());
0393: } else if (inPuvh.getInfo().getDefaultConstraint() != null) {
0394: inParentDefaultConstraint[0] = inPuvh
0395: .getDefaultConstraint();
0396: inPuvh.setDefaultConstraint(inPuvh.getInfo()
0397: .getDefaultConstraint());
0398: } else {
0399: //do nothing
0400: }
0401: //
0402: //
0403: //
0404: //
0405: if (inParentDefaultConstraint[0] != null
0406: && inPuvh.getDefaultConstraint() != null) {
0407: //
0408: //
0409: ConceptTagConstraint localCtcon = PopUpViewHelper
0410: .getConstraint(inPuvh.getConstraint(), inPuvh
0411: .getStaticIndex(), inPuvh
0412: .getConstraintHolder());
0413: int localCtconIndex = PopUpViewHelper
0414: .getConstraintIndex(inPuvh.getConstraint(),
0415: inPuvh.getStaticIndex(), inPuvh
0416: .getConstraintHolder());
0417: //
0418: ConceptTagCharacteristic localCtchar = localCtcon
0419: .getCharacteristic();
0420: //
0421: String handle = localCtchar.getHandle(localCtconIndex);
0422: //
0423: ConceptTagConstraintHolder localCtCtcon = ConceptTagHelper
0424: .getNearestConceptTag(localCtchar
0425: .getPreferences().getRootHolder(),
0426: handle, new StringBuffer());
0427: ConceptTag localCt = localCtCtcon
0428: .getCharacteristicHolder().getConceptTag();
0429: //
0430: throw new UnexpectedSystemException("ConceptTag '"
0431: + localCt.getClass().getName()
0432: + "' sets default constraint '"
0433: + inPuvh.getDefaultConstraint()
0434: + "' after setting default constraint '"
0435: + inParentDefaultConstraint[0] + "'");
0436: }
0437: }
0438: //
0439: //
0440: //PUSH - MENU ACTIVE
0441: if (true) {
0442: inParentMenuActive[0] = inPuvh.isMenuActive();
0443: if (inPuvh.getInfo().getIdHandle().length > 0
0444: || inPuvh.getInfo().getDefaultConstraint() != null) {
0445: //
0446: inPuvh.setMenuActive(true);
0447: } else {
0448: inPuvh.setMenuActive(false);
0449: }
0450: }
0451: //
0452: //
0453: //PUSH - CURRENT ID COUNT
0454: if (true) {
0455: if (inPuvh.getInfo().getIdHandle().length > 0) {
0456: inParentCurrentIdCount[0] = inPuvh.getCurrentIdCount();
0457: inPuvh.resetCurrentIdCount();
0458: }
0459: }
0460: //
0461: //
0462: //
0463: //
0464: //
0465: //
0466: try {
0467: //
0468: MiscHelper.println("PopUpViewSel HANDLE = "
0469: + inPuvh.getHandleParent() + " ("
0470: + inPuvh.getHandleIndex() + ")");
0471: ConceptTagConstraint localCtcon = PopUpViewHelper
0472: .getConstraint(inPuvh.getConstraint(), inPuvh
0473: .getStaticIndex(), inPuvh
0474: .getConstraintHolder());
0475: //
0476: ConceptTagConstraintHolder localCtCtconh = ConceptTagHelper
0477: .getNearestConceptTag(localCtcon.getPreferences()
0478: .getRootHolder(), inPuvh.getHandleParent(),
0479: new StringBuffer());
0480: //
0481: MiscHelper.println("PopUpViewSel PARENT-CT = "
0482: + localCtCtconh.getCharacteristicHolder()
0483: .getConceptTag());
0484: } catch (Exception e) {
0485: MiscHelper.println("PopUpViewSel HANDLE (Not Available)");
0486: }
0487: }
0488:
0489: //
0490: //
0491: //
0492: private final static void popIdHandle(PopUpViewHolder inPuvh,
0493: WebPageTagInstanceViewContextInfo inParentWptivci[],
0494: String inParentEarmark[][], String inParentErrorId[],
0495: boolean inParentMenuActive[],
0496: String inParentDefaultConstraint[],
0497: int inParentCurrentIdCount[]) {
0498: //
0499: //
0500: //POP - CURRENT ID COUNT
0501: if (true) {
0502: if (inPuvh.getInfo().getIdHandle().length > 0) {
0503: inPuvh.setCurrentIdCount(inParentCurrentIdCount[0]);
0504: }
0505: }
0506: //
0507: //
0508: //POP - MENU ACTIVE
0509: if (true) {
0510: inPuvh.setMenuActive(inParentMenuActive[0]);
0511: }
0512: //
0513: //
0514: //POP - DEFAULT CONSTRAINT
0515: if (true) {
0516: if (inPuvh.getInfo().getIdHandle().length > 0) {
0517: inPuvh
0518: .setDefaultConstraint(inParentDefaultConstraint[0]);
0519: } else if (inPuvh.getInfo().getDefaultConstraint() != null) {
0520: inPuvh
0521: .setDefaultConstraint(inParentDefaultConstraint[0]);
0522: } else {
0523: //do nothing
0524: }
0525: }
0526: //
0527: //
0528: //POP - ERROR ID
0529: if (true) {
0530: if (inPuvh.getInfo().getIdHandle().length > 0) {
0531: inPuvh.setErrorId(inParentErrorId[0]);
0532: }
0533: }
0534: //
0535: //
0536: //POP - EARMARK ID
0537: if (true) {
0538: if (inPuvh.getInfo().getIdHandle().length > 0) {
0539: inPuvh.setEarmark(inParentEarmark[0]);
0540: }
0541: }
0542: //
0543: //
0544: //POP - CTCHAR
0545: if (true) {
0546: //
0547: //
0548: ConsoleTemplateSession localCts = inPuvh
0549: .getConsoleTemplateSession();
0550: //
0551: Object idHandle[] = inPuvh.getInfo().getIdHandle();
0552: for (int i = idHandle.length - 1; i >= 0; i--) {
0553: //
0554: //
0555: //if (idHandle[i] instanceof ConceptTagCharacteristic
0556: // && inPuvh.getConstraint() != null) {
0557: // //
0558: // ConceptTagCharacteristic ctchar1 =
0559: // ((ConceptTagCharacteristic)idHandle[i]);
0560: // ConceptTagCharacteristic ctchar2 =
0561: // inPuvh.getConstraint().getCharacteristic();
0562: // //
0563: // MiscHelper.println("<!----- PH ----->");
0564: // MiscHelper.println(
0565: // " ctchar1 = "
0566: // + ctchar1.getHandleAsArrayListWithoutIndex());
0567: // MiscHelper.println(
0568: // " ctchar2 = "
0569: // + ctchar2.getHandleAsArrayListWithoutIndex());
0570: // MiscHelper.println("<!----- PH ----->");
0571: //}
0572: //
0573: //
0574: //
0575: ConceptTagConstraintHolder puvhCtconh = inPuvh
0576: .getConstraintHolder();
0577: ConceptTagConstraint puvhCtcon = inPuvh.getConstraint();
0578: Integer puvhStaticIndex = inPuvh.getStaticIndex();
0579: //
0580: //
0581: Object nextIdPartObj = idHandle[i];
0582: //
0583: //stackCount--;
0584: localCts.popToggleLink();
0585: inPuvh.getToggleSuffix().remove(
0586: inPuvh.getToggleSuffix().size() - 1);
0587: //
0588: //
0589: //ConceptTagConstraintHolder backupCtconh = inCtconh[0];
0590: //ConceptTagConstraint backupCtcon = inCtcon[0];
0591: //
0592: //
0593: if (puvhStaticIndex != null && puvhCtcon != null
0594: && puvhCtconh == null) {
0595: //
0596: //
0597: if (nextIdPartObj.equals(puvhStaticIndex)) {
0598: inPuvh.setStaticIndex(null);
0599: } else {
0600: throw new UnexpectedSystemException("Index '"
0601: + nextIdPartObj
0602: + "' doesn't equal index '"
0603: + puvhStaticIndex + "'");
0604: }
0605: } else if (puvhStaticIndex == null && puvhCtcon != null
0606: && puvhCtconh == null) {
0607: //
0608: //
0609: if (nextIdPartObj instanceof ConceptTagCharacteristic) {
0610: //
0611: ConceptTagCharacteristic nextIdPartCtchar = ((ConceptTagCharacteristic) nextIdPartObj);
0612: ConceptTagCharacteristic localCtchar = puvhCtcon
0613: .getCharacteristic();
0614: //
0615: if (nextIdPartCtchar == localCtchar) {
0616: //
0617: inPuvh.setConstraintHolder(puvhCtcon
0618: .getParentConstraintHolder());
0619: inPuvh.setConstraint(null);
0620: } else {
0621: throw new UnexpectedSystemException(
0622: "Characteristic '"
0623: + nextIdPartCtchar
0624: .getConstraintName()
0625: + "' doesn't equal Characteristic '"
0626: + localCtchar
0627: .getConstraintName()
0628: + "'");
0629: }
0630: } else {
0631: throw new UnexpectedSystemException("'"
0632: + nextIdPartObj
0633: + "' isn't a ConceptTagCharacteristic");
0634: }
0635: } else if (puvhStaticIndex == null && puvhCtcon == null
0636: && puvhCtconh != null) {
0637: //
0638: //
0639: ConceptTagConstraintHolder localCtconh = inPuvh
0640: .getConstraintHolder();
0641: if (localCtconh.isParentConstraintPresent()) {
0642: //
0643: ConceptTagCharacteristicHolder localCtcharh = puvhCtconh
0644: .getCharacteristicHolder();
0645: //int localCtcharhIndex =
0646: // localCtcharh.getParentCharacteristicIndex();
0647: ConceptTagCharacteristic nextParCtchar = ((ConceptTagCharacteristic) idHandle[(i - 1)]);
0648: int nextIdPartInt = ((Integer) nextIdPartObj)
0649: .intValue();
0650: //ConceptTagCharacteristicHolder nextIdPartCtcharh =
0651: // ()
0652: //
0653: if (nextParCtchar.isHolder(nextIdPartInt, null)
0654: && localCtcharh == nextParCtchar
0655: .getValueAsHolder(
0656: nextIdPartInt, null)) {
0657: //
0658: ConceptTagConstraint parentCtcon = puvhCtconh
0659: .getParentConstraint();
0660: //
0661: inPuvh.setConstraint(parentCtcon);
0662: inPuvh.setConstraintHolder(null);
0663: } else {
0664: throw new UnexpectedSystemException(
0665: "ConceptTagCharacteristicHolder mismatch");
0666: }
0667: } else {
0668: throw UnexpectedSystemException.unknownState();
0669: //inCtconh[0] =
0670: // (inCtconh[0]).getParentConstraintHolder();
0671: }
0672: } else {
0673: throw UnexpectedSystemException.unknownState();
0674: }
0675: //
0676: //
0677: //if (inCtcon[0] == null && inCtconh[0] == null) {
0678: // MiscHelper.println("Null Found = " + stackCount);
0679: //}
0680: }
0681: }
0682: //
0683: //
0684: //POP - INFO
0685: if (true) {
0686: inPuvh.setInfo(inParentWptivci[0]);
0687: }
0688: //
0689: //
0690: //POP - GENERAL
0691: if (true) {
0692: inPuvh.getInfo().markPop();
0693: }
0694: //
0695: }
0696:
0697: //
0698: //
0699: //
0700: //
0701: //
0702: //
0703: //
0704: //
0705: //
0706: //
0707: //
0708: //
0709: //
0710: //
0711: //
0712: //
0713: //
0714: //
0715: //
0716: //
0717: //
0718: //
0719: protected final static void generateSubViewFromHtml(
0720: PopUpViewHolder inPuvh) {
0721: //
0722: if (PopUpViewHelper.isAllLocalHtml(inPuvh.getInfo())) {
0723: for (int i = 0; i < inPuvh.getInfo().getContentLength(); i++) {
0724: //
0725: WebPageTagInstanceViewContextInfo nextWptivci = inPuvh
0726: .getInfo().getContentAsInfo(i);
0727: //
0728: PopUpViewSelector.chooseHtmlView(inPuvh, nextWptivci);
0729: }
0730: } else {
0731: Integer indexOfFirstNonHtml = null;
0732: for (int i = 0; i < inPuvh.getInfo().getContentLength(); i++) {
0733: //
0734: WebPageTagInstanceViewContextInfo nextWptivci = inPuvh
0735: .getInfo().getContentAsInfo(i);
0736: //
0737: if (nextWptivci.isMarkedAsHtml()) {
0738: if (indexOfFirstNonHtml != null) {
0739: processNonHtmlBlock(inPuvh, indexOfFirstNonHtml
0740: .intValue(), i);
0741: indexOfFirstNonHtml = null;
0742: }
0743: PopUpViewSelector.chooseHtmlView(inPuvh,
0744: nextWptivci);
0745: } else if (nextWptivci.isMarkedAsNonHtml()) {
0746: if (indexOfFirstNonHtml == null) {
0747: indexOfFirstNonHtml = new Integer(i);
0748: }
0749: } else if (nextWptivci.isMarkedAsIterativeNonHtml()) {
0750: if (PopUpViewHelper.isAllNonHtml(nextWptivci)) {
0751: if (indexOfFirstNonHtml == null) {
0752: indexOfFirstNonHtml = new Integer(i);
0753: }
0754: } else {
0755: if (indexOfFirstNonHtml != null) {
0756: //
0757: processNonHtmlBlock(inPuvh,
0758: indexOfFirstNonHtml.intValue(), i);
0759: indexOfFirstNonHtml = null;
0760: }
0761: //
0762: //
0763: chooseIterativeHtmlView(inPuvh, nextWptivci);
0764: }
0765: } else {
0766: throw UnexpectedSystemException.unknownState();
0767: }
0768: }
0769: if (indexOfFirstNonHtml != null) {
0770: processNonHtmlBlock(inPuvh, indexOfFirstNonHtml
0771: .intValue(), inPuvh.getInfo()
0772: .getContentLength());
0773: indexOfFirstNonHtml = null;
0774: }
0775: }
0776: }
0777:
0778: //
0779: //
0780: //
0781: //
0782: //
0783: //
0784: //
0785: //
0786: //
0787: //
0788: //
0789: //
0790: //
0791: //
0792: private final static void processNonHtmlBlock(
0793: PopUpViewHolder inPuvh, int inStartIndex, int inEndIndex) {
0794: //
0795: //
0796: ConsoleTemplateSession localCts = inPuvh
0797: .getConsoleTemplateSession();
0798: //
0799: //
0800: //generate title
0801: //
0802: //
0803: String nonHtmlsTitle = PopUpViewTitleHelper.constructTitle(
0804: inPuvh.getInfo(), inStartIndex, inEndIndex, false);
0805: //
0806: //
0807: //generate pop-up
0808: //
0809: //
0810: //
0811: //
0812: inPuvh.pushStudioMacroEditDirectiveAsPopUp();
0813: //
0814: //String nonHtmlPopUpId[] = new String[1];
0815: String nonHtmlPopUp[] = createNonHtmlPopUp(inPuvh,
0816: inStartIndex, inEndIndex, false, false);
0817: //
0818: //
0819: //
0820: //ArrayList localActions = new ArrayList();
0821: //
0822: //
0823: String popUpId = constructPopUpLink(nonHtmlPopUp[0],
0824: nonHtmlPopUp[1], nonHtmlsTitle, inPuvh,
0825: (nonHtmlPopUp[2] != null));
0826: //
0827: inPuvh.popStudioMacroEditDirectiveAsPopUp(popUpId);
0828: }
0829:
0830: //
0831: protected final static String constructPopUpLink(String inPopUp,
0832: String inPopUpId, String inTitle, PopUpViewHolder inPuvh,
0833: boolean inErrorPresent) {
0834: //
0835: //
0836: String outValue = null;
0837: //
0838: //
0839: //
0840: ConsoleTemplateSession localCts = inPuvh
0841: .getConsoleTemplateSession();
0842: PageSetupContext localPsc = localCts.getPageSetupContext();
0843: //
0844: //
0845: //
0846: localCts.pushToggleLinkDontRecordThisBranch();
0847: localCts.pushToggleLinkWebPageViewPopUpCaller();
0848: //localCps.pushToggleLink(inIdIndex + "");
0849: localCts.pushToggleLink(localPsc.getWebPageViewPopUpCount()
0850: + "");
0851: //
0852: //
0853: //
0854: //
0855: //
0856: //
0857: //
0858: HashMap attrs = new HashMap();
0859: //
0860: String mouseOutBorder = "";
0861: if (inErrorPresent) {
0862: mouseOutBorder = "2px dashed red";
0863: }
0864: String mouseOverBorder = "1px dashed blue";
0865: //
0866: attrs.put("onclick", "openWebPageViewPopUp('" + inPopUpId
0867: + "'); stopEventPropogation(event);");
0868: attrs.put("title", inTitle);
0869: attrs.put("id", localCts.getToggleLink());
0870: outValue = localCts.getToggleLink();
0871: attrs.put("onmouseout", "this.style.cursor = 'auto'");
0872: attrs.put("onmouseover", "this.style.cursor = 'pointer'");
0873: attrs.put("style", "border: " + mouseOutBorder);
0874: attrs.put("onmouseover", "this.style.border = '"
0875: + mouseOverBorder + "'");
0876: // + " studioCloseAllMenus(this);"
0877: // + " stopEventPropogation(event);");
0878: attrs.put("onmouseout", "this.style.border = '"
0879: + mouseOutBorder + "'");
0880: // + " studioCloseAllMenus(this);"
0881: // + " stopEventPropogation(event);");
0882: //
0883: //inPuvh.appendText("<span onclick=\"openWebPageViewPopUp('" + inPopUpId
0884: // + "'); stopEventPropogation(event);\" title=\"" + inTitle
0885: // + "\" id=\"" + localCts.getToggleLink() + "\""
0886: // + " onmouseout=\"this.style.cursor = 'auto'\""
0887: // + " onmouseover=\"this.style.cursor = 'pointer'\""
0888: // + ">(*" + localPsc.getWebPageViewPopUpCount() + ")</span>");
0889: //
0890: //
0891: //
0892: inPuvh.appendText("<span ");
0893: inPuvh.appendText(XMLHelper.convertAttrs(attrs));
0894: inPuvh.appendText(">(*");
0895: inPuvh.appendText(Integer.toString(localPsc
0896: .getWebPageViewPopUpCount()));
0897: inPuvh.appendText(")</span>");
0898: //
0899: //
0900: localCts.popToggleLink();
0901: localCts.popToggleLink();
0902: localCts.popToggleLink();
0903: //
0904: //
0905: //
0906: //
0907: return outValue;
0908: }
0909:
0910: //
0911: //
0912: //
0913: protected final static String[] createNonHtmlPopUp(
0914: PopUpViewHolder inPuvh, int inStartIndex, int inEndIndex,
0915: boolean inLimitDepth, boolean inIterative) {
0916: //
0917: String outValue[] = new String[3];
0918: //
0919: //
0920: //
0921: boolean parentDescendentErrorPresent = inPuvh
0922: .isDescendentErrorPresent();
0923: inPuvh.setDescendentErrorPresent(false);
0924: //
0925: //
0926: //
0927: //
0928: StringBuffer sb = new StringBuffer();
0929: //
0930: ConsoleTemplateSession localCts = inPuvh
0931: .getConsoleTemplateSession();
0932: PageSetupContext localPsc = localCts.getPageSetupContext();
0933: //
0934: localCts.pushToggleLinkDontRecordThisBranch();
0935: localCts.pushToggleLinkWebPageViewPopUp();
0936: //
0937: //int currentIdIndex = 0;
0938: //do {
0939: //}
0940: //while ();
0941: //localCps.pushToggleLink(currentIdIndex + "");
0942: //localCps.pushToggleLink(inIdIndex + "");
0943: localCts.pushToggleLink(localPsc.getWebPageViewPopUpCount()
0944: + "");
0945: //
0946: //
0947: //
0948: outValue[1] = localCts.getToggleLink();
0949: //
0950: //outValue.append(inWptivci.getIterativeOuterStart());
0951: //
0952: sb.append("<div id=\"" + outValue[1]
0953: + "\""
0954: + " style=\"z-index: "
0955: + CommonSeparators.Z_INDEX__WEB_PAGE_VIEW
0956: + ";"
0957: //+ " border-style: groove;"
0958: + " background-color: #F5F5DC;"
0959: //+ " border-color: #333333;"
0960: + " position: absolute; border-width: 3px;"
0961: + " width: 600px; height: 400px; overflow: scroll;"
0962: + " border-style: ridge; display: none\">");
0963: //
0964: //
0965: sb
0966: .append("<table width=\"6550\"><tr>"
0967: + "<td align=\"right\" width=\"550\">"
0968: + "<img onclick=\"closeSection('"
0969: + localCts.getToggleLink()
0970: + "'); exposeHeavyWeightPageComponents()\" src=\""
0971: + ConsoleTemplateParameters.GIF_WEB_PAGE_VIEW_POP_UP_CLOSE
0972: + "\" onmouseout=\"this.style.cursor = 'auto'\""
0973: + " onmouseover=\"this.style.cursor = 'pointer'\">"
0974: + "</td><td width=\"6000\">"
0975: + XMLHelper.NBSP_XML + "</td></tr>"
0976: + "<tr><td valign=\"top\" colspan=\"2\">");
0977: //
0978: //
0979: //
0980: //
0981: if (!inIterative) {
0982: //
0983: StringBuffer previousSb = inPuvh.getStringBuffer();
0984: //
0985: inPuvh.setStringBuffer(sb);
0986: //
0987: //
0988: //
0989: processNonHtmlVertically(inPuvh, inStartIndex, inEndIndex,
0990: 0, inLimitDepth);
0991: //
0992: //
0993: //
0994: inPuvh.setStringBuffer(previousSb);
0995: } else {
0996: //
0997: StringBuffer previousSb = inPuvh.getStringBuffer();
0998: //
0999: inPuvh.setStringBuffer(sb);
1000: //
1001: //
1002: //
1003: processIterativeNonHtmlVertically(inPuvh, 0, inLimitDepth);
1004: //
1005: //
1006: //
1007: inPuvh.setStringBuffer(previousSb);
1008: }
1009: //
1010: //
1011: //
1012: sb.append("</td></tr></table>");
1013: //
1014: //
1015: //
1016: sb.append("</div>");
1017: //
1018: //outValue.append(inWptivci.getIterativeOuterEnd());
1019: //
1020: //
1021: //
1022: //
1023: localCts.popToggleLink();
1024: localCts.popToggleLink();
1025: localCts.popToggleLink();
1026: //
1027: outValue[0] = sb.toString();
1028: //
1029: //
1030: //
1031: //
1032: if (inPuvh.isDescendentErrorPresent()) {
1033: outValue[2] = "ERROR";
1034: } else {
1035: outValue[2] = null;
1036: }
1037: //
1038: //
1039: //
1040: localPsc.addWebPageViewPopUp(outValue[0]);
1041: //
1042: //
1043: //
1044: inPuvh.setDescendentErrorPresent(parentDescendentErrorPresent);
1045: //
1046: //
1047: //
1048: //
1049: //
1050: //
1051: return outValue;
1052: }
1053:
1054: private final static void processNonHtmlVertically(
1055: PopUpViewHolder inPuvh, int inStartIndex, int inEndIndex,
1056: int inIndent, boolean inLimitDepth) {
1057: //
1058: //
1059: //
1060: //
1061: boolean tableInUse = ((inEndIndex - inStartIndex) > 0);
1062: if (tableInUse) {
1063: inPuvh.appendText("<table>");
1064: }
1065: //
1066: for (int i = inStartIndex; i < inEndIndex; i++) {
1067: //
1068: WebPageTagInstanceViewContextInfo nextWptivci = inPuvh
1069: .getInfo().getContentAsInfo(i);
1070: //
1071: //outValue.append(inWptivci.getIterativeInnerStart());
1072: //
1073: //if (i > inStartIndex) {
1074: // inPuvh.appendText("<br/>");
1075: //}
1076: //
1077: //
1078: inPuvh.appendText("<tr>");
1079: //
1080: if (inIndent > 0) {
1081: inPuvh.appendText("<td width=\"");
1082: inPuvh.appendText((inIndent * 20) + "");
1083: inPuvh.appendText("\">");
1084: inPuvh.appendText(ConsoleTemplateContext.padNbsp(1));
1085: inPuvh.appendText("</td>");
1086: }
1087: //
1088: //
1089: //inPuvh.appendText(
1090: // ConsoleTemplateContext.padNbsp(inIndent*2) + "- ");
1091: inPuvh.appendText("<td valign=\"top\">- </td>");
1092: //
1093: if (nextWptivci.getIdHandle().length > 0) {
1094: //
1095: HashMap attrs = new HashMap();
1096: //
1097: boolean localErrorPresent = PopUpViewHelper
1098: .isLocalErrorPresent(inPuvh.getConstraint(),
1099: inPuvh.getStaticIndex(), inPuvh
1100: .getConstraintHolder());
1101: if (localErrorPresent) {
1102: inPuvh.setDescendentErrorPresent(localErrorPresent);
1103: }
1104: //
1105: //attrs.put("onclick", );
1106: inPuvh.appendText("<td ");
1107: inPuvh.appendText(XMLHelper.convertAttrs(attrs));
1108: inPuvh.appendText(">");
1109: } else {
1110: inPuvh.appendText("<td>");
1111: }
1112: choosePlainView(inPuvh, nextWptivci, inIndent, inLimitDepth);
1113: inPuvh.appendText("</td>");
1114: //
1115: //outValue.append(inWptivci.getIterativeInnerEnd());
1116: //
1117: inPuvh.appendText("</tr>");
1118: }
1119: //
1120: if (tableInUse) {
1121: inPuvh.appendText("</table>");
1122: }
1123: }
1124:
1125: //
1126: //
1127: //
1128: protected final static void processIterativeNonHtmlVertically(
1129: PopUpViewHolder inPuvh, int inIndent, boolean inLimitDepth) {
1130: //
1131: //
1132: //
1133: //
1134: boolean tableInUse = (inPuvh.getInfo().getContentLength() > 0);
1135: if (tableInUse) {
1136: inPuvh.appendText("<table>");
1137: }
1138: //
1139: for (int i = 0; i < inPuvh.getInfo().getContentLength(); i = i + 3) {
1140: //
1141: //
1142: //
1143: WebPageTagInstanceViewContextInfo nextStartWptivci = inPuvh
1144: .getInfo().getContentAsInfo(i);
1145: WebPageTagInstanceViewContextInfo nextEndWptivci = inPuvh
1146: .getInfo().getContentAsInfo(i + 2);
1147: //
1148: //
1149: //
1150: //
1151: //outValue.append(inWptivci.getIterativeInnerStart());
1152: //
1153: inPuvh.appendText("<tr>");
1154: //
1155: //
1156: if (inIndent > 0) {
1157: inPuvh.appendText("<td width=\"");
1158: inPuvh.appendText((inIndent * 20) + "");
1159: inPuvh.appendText("\">");
1160: inPuvh.appendText(ConsoleTemplateContext.padNbsp(1));
1161: inPuvh.appendText("</td>");
1162: }
1163: //
1164: //if (i > 0) {
1165: // inPuvh.appendText("<br/>");
1166: //}
1167: //
1168: //
1169: //
1170: inPuvh.appendText("<td valign=\"top\">- </td>");
1171: //
1172: //inPuvh.appendText(
1173: // ConsoleTemplateContext.padNbsp(inIndent*2) + "- ");
1174: //
1175: //
1176: //
1177: //
1178: inPuvh.appendText("<td>");
1179: //
1180: PopUpViewPlainHelper.renderSelectableNonHtmlStart(inPuvh);
1181: //
1182: PopUpViewSelector.choosePlainView(inPuvh, nextStartWptivci,
1183: inIndent, inLimitDepth);
1184: //
1185: inPuvh.appendText("....");
1186: //
1187: PopUpViewSelector.choosePlainView(inPuvh, nextEndWptivci,
1188: inIndent, inLimitDepth);
1189: //
1190: PopUpViewPlainHelper.renderSelectableNonHtmlEnd(inPuvh);
1191: //
1192: inPuvh.appendText("</td>");
1193: //
1194: //
1195: //
1196: //
1197: //
1198: inPuvh.appendText("</tr>");
1199: //
1200: //outValue.append(inWptivci.getIterativeInnerEnd());
1201: //
1202: //
1203: }
1204: //if (inPuvh.getInfo().getContentLength() == 0) {
1205: // inPuvh.appendText("(No Iterative Structure)");
1206: //}
1207: //
1208: //
1209: if (tableInUse) {
1210: inPuvh.appendText("</table>");
1211: }
1212: //
1213: //
1214: }
1215: }
|