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.base;
0009:
0010: //base classes
0011: import java.io.IOException;
0012: import java.io.Writer;
0013: import java.util.ArrayList;
0014: import java.util.HashMap;
0015: import java.util.HashSet;
0016: import java.util.Iterator;
0017: import java.util.StringTokenizer;
0018:
0019: //project specific classes
0020: import org.jfolder.common.UnexpectedSystemException;
0021: import org.jfolder.common.function.WebPageTagInstanceViewContext;
0022: import org.jfolder.common.function.WebPageTagInstanceViewContextInfo;
0023: import org.jfolder.common.function.WebPageTagPreferences;
0024: import org.jfolder.common.tagging.ConceptTag;
0025: import org.jfolder.common.tagging.ConceptTagPreferences;
0026: import org.jfolder.common.tagging.RootConceptTagHolder;
0027: import org.jfolder.common.utils.misc.CommonSeparators;
0028: import org.jfolder.common.utils.misc.MiscHelper;
0029: import org.jfolder.common.utils.xml.XMLHelper;
0030: import org.jfolder.common.web.template.ConsoleParameterContext;
0031: import org.jfolder.common.web.template.ConsoleTemplateContext;
0032: import org.jfolder.common.web.template.ConsoleTemplateSession;
0033: import org.jfolder.common.web.template.CreationParameterContext;
0034: import org.jfolder.common.web.template.MenuBranch;
0035: import org.jfolder.common.web.template.PageSetupContext;
0036: import org.jfolder.common.web.template.RecordActionContext;
0037: import org.jfolder.common.web.template.SubmitActionContext;
0038: import org.jfolder.common.web.template.SubmitActionParameters;
0039: import org.jfolder.console.view.display.PopUpViewCreator;
0040: import org.jfolder.web.page.RootWebPageTag;
0041:
0042: //other classes
0043:
0044: public abstract class ConsolePageContext extends ConsoleTemplateContext {
0045:
0046: //
0047: protected final static String PROPERTIES_PREFIX = "PROPERTIES_";
0048:
0049: private ConsolePageSession cps = null;
0050: private String cpcHandle = null;
0051: //private String localName = null;
0052: //private String treeState = null;
0053: private String highlightHandle = null;
0054: //
0055: //
0056: private boolean defaultHighlightHandleAndTreeInitialized = false;
0057: private String defaultHighlightHandle = null;
0058: private HashSet defaultTreeBranches = null;
0059: //
0060: private String name = null;
0061: //
0062: private HashMap subCpcs = null;
0063:
0064: //protected ConsolePageContext() {
0065: // super();
0066: //}
0067:
0068: //
0069: protected ConsolePageContext(ConsolePageSession inCps) {
0070: //
0071: super ();
0072: //
0073: this .name = MAIN_TOGGLE_SECTION;
0074: //
0075: this .cps = inCps;
0076: //setTreeState("");
0077: //setHighlightHandle("");
0078: //
0079: this .defaultHighlightHandle = "";
0080: this .defaultTreeBranches = new HashSet();
0081: //
0082: this .subCpcs = new HashMap();
0083: }
0084:
0085: //
0086: protected ConsolePageContext(ConsolePageContext inCpc, String inName) {
0087: //
0088: super ();
0089: //
0090: this .name = inName;
0091: //
0092: initialize(inCpc);
0093: //
0094: this .defaultHighlightHandle = "";
0095: this .defaultTreeBranches = new HashSet();
0096: //
0097: this .subCpcs = new HashMap();
0098: this .cps = inCpc.getConsolePageSession();
0099: }
0100:
0101: protected void initialize(ConsolePageContext inCpc, String inName) {
0102: //
0103: super .initialize(inCpc);
0104: //
0105: //StringBuffer updatedName = new StringBuffer();
0106: //updatedName.append(inCpc.getName());
0107: //updatedName.append(ConsoleTemplateParameters.SUB_CPC_SEPARATOR);
0108: //updatedName.append(inName);
0109: //
0110: //setName(updatedName.toString());
0111: //
0112: this .cps = inCpc.getConsolePageSession();
0113: }
0114:
0115: public void prepareForReuse() {
0116: this .subCpcs = new HashMap();
0117: super .prepareForReuse();
0118: }
0119:
0120: //
0121: public void considerDefaultSettings() {
0122: if (!this .defaultHighlightHandleAndTreeInitialized) {
0123: //
0124: setHighlightHandle(this .defaultHighlightHandle);
0125: //
0126: //StringBuffer treeStateSb = new StringBuffer();
0127: Iterator iter = this .defaultTreeBranches.iterator();
0128: while (iter.hasNext()) {
0129: String nextBranch = (String) iter.next();
0130: if (!isTreeComponentPresent(nextBranch)) {
0131: addTreeComponent(nextBranch);
0132: }
0133: //treeStateSb.append(BRANCH_SEPARATOR);
0134: //treeStateSb.append(nextBranch);
0135: //treeStateSb.append(BRANCH_SEPARATOR);
0136: }
0137: //setTreeState(treeStateSb.toString());
0138: //
0139: this .defaultHighlightHandleAndTreeInitialized = true;
0140: }
0141: }
0142:
0143: //
0144: public boolean isSubConsolePageContextPresent(String inName) {
0145:
0146: boolean outValue = false;
0147:
0148: this .cps.pushToggleLink(inName);
0149: outValue = isSubConsolePageContextPresent();
0150: this .cps.popToggleLink();
0151:
0152: return outValue;
0153: }
0154:
0155: private boolean isSubConsolePageContextPresent() {
0156: return (this .subCpcs.containsKey(this .cps.getToggleLink()));
0157: }
0158:
0159: //
0160: public void registerSubConsolePageContext(String inName,
0161: ConsoleTemplateContext inSubCpc) {
0162:
0163: this .cps.pushToggleLink(inName);
0164: if (!(isSubConsolePageContextPresent())) {
0165: registerSubConsolePageContext(inSubCpc);
0166: } else {
0167: throw new UnexpectedSystemException(
0168: ("'" + inName + "' already registered"));
0169: }
0170: this .cps.popToggleLink();
0171: }
0172:
0173: private void registerSubConsolePageContext(
0174: ConsoleTemplateContext inSubCpc) {
0175:
0176: if (!(isSubConsolePageContextPresent())) {
0177: this .subCpcs.put(this .cps.getToggleLink(), inSubCpc);
0178: } else {
0179: throw new UnexpectedSystemException(
0180: ("'" + this .cps.getToggleLink() + "' already registered"));
0181: }
0182: }
0183:
0184: //
0185: public ConsoleTemplateContext getSubConsolePageContext(String inName) {
0186:
0187: ConsoleTemplateContext outValue = null;
0188:
0189: this .cps.pushToggleLink(inName);
0190: outValue = getSubConsolePageContext();
0191: this .cps.popToggleLink();
0192:
0193: return outValue;
0194: }
0195:
0196: private ConsoleTemplateContext getSubConsolePageContext() {
0197:
0198: ConsoleTemplateContext outValue = null;
0199:
0200: if ((isSubConsolePageContextPresent())) {
0201: outValue = ((ConsoleTemplateContext) (this .subCpcs
0202: .get(this .cps.getToggleLink())));
0203: } else {
0204: throw new UnexpectedSystemException(("'"
0205: + this .cps.getToggleLink() + "' not present"));
0206: }
0207:
0208: return outValue;
0209: }
0210:
0211: //
0212: //public String getName() {
0213: // return this.name;
0214: //}
0215: //protected void setName(String inName) {
0216: // this.name = inName;
0217: //}
0218: //
0219: public String getHandle() {
0220: return this .cpcHandle;
0221: }
0222:
0223: protected void setHandle(String inCpcHandle) {
0224: this .cpcHandle = inCpcHandle;
0225: }
0226:
0227: //
0228: public void setDefaultHighlightHandle(String inHandle) {
0229: this .defaultHighlightHandle = inHandle;
0230: }
0231:
0232: public void addDefaultTreeBranch(String inHandle) {
0233: this .defaultTreeBranches.add(inHandle);
0234: }
0235:
0236: //
0237: //private UnexpectedSystemException e = null;
0238: public void createConsolePage(Writer inWriter,
0239: PageSetupContext inPsc) throws IOException {
0240: //
0241: //if (this.e != null) {
0242: // throw new UnexpectedSystemException(this.e);
0243: //}
0244: //else {
0245: // this.e = new UnexpectedSystemException("First Call");
0246: //}
0247: this .cps.pushToggleLinkSection(this .name);
0248: //
0249: //register sub-context, if necessary
0250: if (isSubConsolePageContextPresent()) {
0251: ConsoleTemplateContext subCpc = getSubConsolePageContext();
0252: if (this != subCpc) {
0253: throw new UnexpectedSystemException(
0254: "Sub-ConsolePageContext already registered for '"
0255: + this .cps.getToggleLink() + "'");
0256: }
0257: } else {
0258: registerSubConsolePageContext(this );
0259: }
0260: //
0261: super .createConsolePage(inWriter, inPsc);
0262: this .cps.popToggleLink();
0263: }
0264:
0265: //
0266: //public String getTreeState() {
0267: // return this.treeState;
0268: //}
0269: //public void setTreeState(String inTreeState) {
0270: // this.treeState = inTreeState;
0271: //}
0272: public String getHighlightHandle() {
0273: return this .highlightHandle;
0274: }
0275:
0276: public void setHighlightHandle(String inHandle) {
0277: this .highlightHandle = inHandle;
0278: }
0279:
0280: /*
0281: private void ensureHandlePathInTree(String inHandle) {
0282: RootConceptTagHolder localRcth =
0283: getConsolePageSession().getCurrentApplicationRootHolder();
0284: ConceptTagPreferences localCtp = localRcth.getPreferences();
0285: String hc = localCtp.getHandleConjunction();
0286: String scanString = inHandle;
0287:
0288: do {
0289: //String nextBranch =
0290: // BRANCH_SEPARATOR + scanString + BRANCH_SEPARATOR;
0291: //
0292: //String currentTreeState = getTreeState();
0293: if (!isTreeComponentPresent(scanString)) {
0294: addTreeComponent(scanString);
0295: }
0296: //if (currentTreeState.indexOf(nextBranch) == -1) {
0297: // setTreeState(currentTreeState + nextBranch);
0298: //}
0299: int nextCropPoint = scanString.indexOf(hc);
0300: if (nextCropPoint != -1) {
0301: scanString = scanString.substring(0, nextCropPoint);
0302: }
0303: else {
0304: scanString = "";
0305: }
0306: }
0307: while(scanString.length() >= localCtp.getRootHandle().length());
0308: }
0309: */
0310: //
0311: //
0312: //
0313: public void adjustNumericHandleWithCommonStems(String inHandle,
0314: String inCommonStems[], boolean inDeleteNotAdd,
0315: ConceptTagPreferences inCtp) {
0316: //
0317: String convertedHandle = MiscHelper.literalReplace(inHandle,
0318: inCtp.getHandleConjunction(),
0319: ConsoleTemplateSession.TOGGLE_LINK_SEPARATOR);
0320: //
0321: String currentTreeState = getTreeState();
0322: for (int i = 0; i < inCommonStems.length; i++) {
0323: String nextCommonStem = inCommonStems[i];
0324: String nextFullHandle = nextCommonStem
0325: + ConsoleTemplateSession.TOGGLE_LINK_SEPARATOR
0326: + convertedHandle;
0327: //
0328: currentTreeState = adjustTreeForChange(currentTreeState,
0329: nextFullHandle, inDeleteNotAdd, true);
0330: setTreeState(currentTreeState);
0331: }
0332: }
0333:
0334: //
0335: //
0336: public void createButton(String inId, String inLabel, int inWidth,
0337: String inOnClick, HashMap inTableAttrs,
0338: HashMap inTableStyles, HashMap inCellAttrs,
0339: HashMap inCellStyles) throws IOException {
0340: //
0341: createButton(inId, inLabel, new Integer(inWidth), inOnClick,
0342: inTableAttrs, inTableStyles, inCellAttrs, inCellStyles);
0343: }
0344:
0345: public void createButton(String inId, String inLabel,
0346: Integer inWidth, String inOnClick, HashMap inTableAttrs,
0347: HashMap inTableStyles, HashMap inCellAttrs,
0348: HashMap inCellStyles) throws IOException {
0349: //
0350: ConsolePageSession localCps = getConsolePageSession();
0351:
0352: localCps.pushToggleLinkTableButton();
0353: localCps.pushToggleLink(inId);
0354: //
0355: if (inOnClick != null) {
0356: inOnClick = "recordClick('" + localCps.getToggleLink()
0357: + "'); " + inOnClick;
0358: }
0359: //
0360: super .createButton(localCps.getToggleLink(), inLabel, inWidth,
0361: inOnClick, inTableAttrs, inTableStyles, inCellAttrs,
0362: inCellStyles);
0363: //
0364: localCps.popToggleLink();
0365: localCps.popToggleLink();
0366: }
0367:
0368: protected String createTextArea(String inId, String inValue,
0369: HashMap inAttrs, HashMap inStyles, Integer inRows,
0370: Integer inColumns, String inOnChange) throws IOException {
0371:
0372: String outValue = null;
0373:
0374: ConsolePageSession localCps = getConsolePageSession();
0375: localCps.pushToggleLinkTextArea();
0376: localCps.pushToggleLink(inId);
0377:
0378: if (inOnChange == null) {
0379: inOnChange = "";
0380: }
0381: if (inOnChange != null) {
0382: inOnChange = "recordValueChange('"
0383: + localCps.getToggleLink() + "', this.value); "
0384: + inOnChange;
0385: }
0386:
0387: outValue = super .createTextArea(localCps.getToggleLink(),
0388: inValue, inAttrs, inStyles, inRows, inColumns,
0389: inOnChange);
0390:
0391: localCps.popToggleLink();
0392: localCps.popToggleLink();
0393:
0394: return outValue;
0395: }
0396:
0397: protected String createTextBox(String inId, String inValue,
0398: HashMap inAttrs, HashMap inStyles, Integer inSize,
0399: Integer inMaxLength, String inOnChange) throws IOException {
0400:
0401: String outValue = null;
0402:
0403: ConsolePageSession localCps = getConsolePageSession();
0404: localCps.pushToggleLinkTextBox();
0405: localCps.pushToggleLink(inId);
0406:
0407: if (inOnChange == null) {
0408: inOnChange = "";
0409: }
0410: if (inOnChange != null) {
0411: inOnChange = "recordValueChange('"
0412: + localCps.getToggleLink() + "', this.value); "
0413: + inOnChange;
0414: }
0415:
0416: outValue = super .createTextBox(localCps.getToggleLink(),
0417: inValue, inAttrs, inStyles, inSize, inMaxLength,
0418: inOnChange);
0419:
0420: localCps.popToggleLink();
0421: localCps.popToggleLink();
0422:
0423: return outValue;
0424: }
0425:
0426: public String createDropDownBox(String inId, ArrayList inLabels,
0427: ArrayList inValues, HashMap inAttrs, HashMap inStyles,
0428: int inSelected, Integer inSize, String inOnChange,
0429: ArrayList inOnSelect) throws IOException {
0430: //
0431: String outValue = null;
0432:
0433: ConsolePageSession localCps = getConsolePageSession();
0434: localCps.pushToggleLinkDropDownBox();
0435: localCps.pushToggleLink(inId);
0436:
0437: //
0438: PageSetupContext localPsc = localCps.getPageSetupContext();
0439: localPsc.registerHeavyWeightPageComponent(localCps
0440: .getToggleLink());
0441: //
0442: if (inOnChange == null) {
0443: inOnChange = "";
0444: }
0445: //
0446: if (inOnChange != null) {
0447: inOnChange = "recordValueChange('"
0448: + localCps.getToggleLink() + "', this.value); "
0449: + inOnChange;
0450: }
0451: //
0452: outValue = super .createDropDownBox(localCps.getToggleLink(),
0453: inLabels, inValues, inAttrs, inStyles, inSelected,
0454: inSize, inOnChange, inOnSelect);
0455:
0456: localCps.popToggleLink();
0457: localCps.popToggleLink();
0458:
0459: return outValue;
0460: }
0461:
0462: protected String createFileUpload(String inId, Integer inSize) {
0463: return createFileUpload(inId, inSize, null, null);
0464: }
0465:
0466: protected String createFileUpload(String inId, Integer inSize,
0467: HashMap inAttrs, HashMap inStyles) {
0468:
0469: String outValue = null;
0470:
0471: ConsolePageSession localCps = getConsolePageSession();
0472: localCps.pushToggleLinkFileUpload();
0473: localCps.pushToggleLink(inId);
0474:
0475: outValue = super .createFileUpload(localCps.getToggleLink(),
0476: inSize, inAttrs, inStyles);
0477:
0478: localCps.popToggleLink();
0479: localCps.popToggleLink();
0480:
0481: return outValue;
0482: }
0483:
0484: protected String createStaticImage(String inId, String inSrc,
0485: HashMap inAttrs, HashMap inStyles) throws IOException {
0486:
0487: String outValue = null;
0488:
0489: ConsolePageSession localCps = getConsolePageSession();
0490: localCps.pushToggleLinkStaticImage();
0491: localCps.pushToggleLink(inId);
0492:
0493: outValue = super .createStaticImage(localCps.getToggleLink(),
0494: inSrc, inAttrs, inStyles);
0495:
0496: localCps.popToggleLink();
0497: localCps.popToggleLink();
0498:
0499: return outValue;
0500: }
0501:
0502: protected String createHiddenField(String inId, String inValue,
0503: HashMap inAttrs) throws IOException {
0504:
0505: String outValue = null;
0506:
0507: ConsolePageSession localCps = getConsolePageSession();
0508: localCps.pushToggleLinkHiddenField();
0509: localCps.pushToggleLink(inId);
0510:
0511: outValue = super .createHiddenField(localCps.getToggleLink(),
0512: inValue, inAttrs);
0513:
0514: localCps.popToggleLink();
0515: localCps.popToggleLink();
0516:
0517: return outValue;
0518: }
0519:
0520: //
0521: protected void startAutoTogglingTableAndRowAndCell(HashMap inProps)
0522: throws IOException {
0523:
0524: startEnclosingTableAndRowAndCell(inProps, this .cps
0525: .getToggleLink());
0526: }
0527:
0528: protected void startAutoTogglingTableAndRowAndCell()
0529: throws IOException {
0530:
0531: startEnclosingTableAndRowAndCell(null, this .cps.getToggleLink());
0532: }
0533:
0534: //
0535: protected String getAutoTogglingLinkWithTargetId(String inTargetId,
0536: String inLabel, String inAction) {
0537: //
0538: return getToggleLinkWithTargetId(inTargetId, inLabel, this .cps
0539: .getToggleLink(), inAction);
0540: }
0541:
0542: protected String getAutoTogglingLinkWithTargetId(String inTargetId,
0543: String inLabel) {
0544: //
0545: return getToggleLinkWithTargetId(inTargetId, inLabel, this .cps
0546: .getToggleLink());
0547: }
0548:
0549: public String getToggleLinkWithTargetId(String inTargetId,
0550: String inLabel, String inDestinationId, String inAction) {
0551: //
0552: String outValue = null;
0553:
0554: ConsolePageSession localCps = getConsolePageSession();
0555: localCps.pushToggleLinkToggleCaller();
0556: localCps.pushToggleLink(inTargetId);
0557:
0558: outValue = super .getToggleLinkWithTargetId(localCps
0559: .getToggleLink(), inLabel, inDestinationId, inAction);
0560:
0561: localCps.popToggleLink();
0562: localCps.popToggleLink();
0563:
0564: return outValue;
0565: }
0566:
0567: //
0568:
0569: public ConsolePageSession getConsolePageSession() {
0570: return this .cps;
0571: }
0572:
0573: //protected String getHandle() {
0574: // return super.getHandle();
0575: //}
0576:
0577: protected String getSequenceCode() {
0578: return getConsolePageSession().getCurrentSequenceCode();
0579: }
0580:
0581: protected boolean isTemplate() {
0582: return false;
0583: }
0584:
0585: public String getMacroInterval() {
0586: return getConsolePageSession().getMacroInterval();
0587: }
0588:
0589: protected void startBodyTag() throws IOException {
0590: printAndIndent("<body onmouseover=\"closeOpenTagMenus('')\""
0591: //+ " onmousemove=\"move(event)\""
0592: + " onload=\"arrangeSubSectionPosition(); executeMacro();\">");
0593: }
0594:
0595: protected void endCommonPageExtensions() throws IOException {
0596:
0597: ConsolePageSession localCps = getConsolePageSession();
0598:
0599: ArrayList origToggleLink = localCps.getToggleLinkAsArrayList();
0600:
0601: for (int i = 0; i < localCps.getMenuCount(); i++) {
0602: ArrayList nextToggleLink = localCps.getMenuToggleLink(i);
0603: MenuBranch nextBranch = localCps.getMenuBranch(i);
0604: //
0605: HashMap nextTableProps = localCps.getMenuTableProps(i);
0606: HashMap nextTableStyles = localCps.getMenuTableStyles(i);
0607: HashMap nextCellProps = localCps.getMenuCellProps(i);
0608: HashMap nextCellStyles = localCps.getMenuCellStyles(i);
0609: Integer textLimit = localCps.getMenuTextLimit(i);
0610: //
0611: localCps.setToggleLink(nextToggleLink);
0612: getSubMenu(localCps, nextBranch,
0613: CommonSeparators.Z_INDEX__MENU_BASE,
0614: nextTableProps, nextTableStyles, nextCellProps,
0615: nextCellStyles, textLimit);
0616: }
0617:
0618: localCps.setToggleLink(origToggleLink);
0619: //
0620: //
0621: //
0622: //
0623: //
0624: PageSetupContext localPsc = localCps.getPageSetupContext();
0625: for (int i = 0; i < localPsc.getWebPageViewPopUpCount(); i++) {
0626: String nextPopUp = localPsc.getWebPageViewPopUp(i);
0627: simpleAndPrint(nextPopUp);
0628: }
0629: }
0630:
0631: protected void startAndEndOtherPageComponents() throws IOException {
0632: SubCreationConceptTagConsolePageContext.newInstance(this );
0633: }
0634:
0635: protected void startAndEndPreparationBeforeSubmitFunction()
0636: throws IOException {
0637: //
0638: ConsolePageSession localCps = getConsolePageSession();
0639: PageSetupContext localPsc = localCps.getPageSetupContext();
0640: ArrayList currSubSecPos = localPsc
0641: .getCurrentSubSectionPositions();
0642: //
0643: String setSubSecPos = SubmitActionContext
0644: .getSubSectionPositionOfForm()
0645: + ".value =";
0646: //
0647: printAndIndent("function preparationBeforeSubmit() {");
0648: simpleAndPrint(setSubSecPos);
0649: justIndent();
0650: //
0651: if (currSubSecPos.size() > 0) {
0652: simpleAndPrint("preparationBeforeSubmitSubSec(null)");
0653: } else {
0654: simpleAndPrint("preparationBeforeSubmitSubSec(null);");
0655: }
0656: //
0657: if (currSubSecPos.size() > 0) {
0658: for (int i = 0; i < currSubSecPos.size(); i++) {
0659: String nextValue = ((String) currSubSecPos.get(i));
0660: StringBuffer sb = new StringBuffer();
0661: //if (i > 0) {
0662: sb.append("+ ");
0663: //}
0664: sb.append("preparationBeforeSubmitSubSec("
0665: + singleQuotes(nextValue) + ")");
0666: if (i == (currSubSecPos.size() - 1)) {
0667: sb.append(";");
0668: }
0669: simpleAndPrint(sb.toString());
0670: }
0671: }
0672: justRevert();
0673: revertAndPrint("}");
0674: //
0675: //
0676: //
0677: String valueObj = getPageComponent("inValue", false);
0678: //
0679: printAndIndent("function preparationBeforeSubmitSubSec(inValue) {");
0680: simpleAndPrint("var outValue = null;");
0681: printAndIndent("if (inValue != null) {");
0682: simpleAndPrint("outValue = "
0683: + singleQuotes(CommonSeparators.BRANCH_SEPARATOR));
0684: justIndent();
0685: simpleAndPrint("+ inValue");
0686: simpleAndPrint("+ "
0687: + singleQuotes(CommonSeparators.SUB_TOKEN_SEPARATOR));
0688: simpleAndPrint("+ " + valueObj + ".scrollLeft");
0689: simpleAndPrint("+ "
0690: + singleQuotes(CommonSeparators.SUB_TOKEN_SEPARATOR));
0691: simpleAndPrint("+ " + valueObj + ".scrollTop");
0692: simpleAndPrint("+ "
0693: + singleQuotes(CommonSeparators.BRANCH_SEPARATOR) + ";");
0694: justRevert();
0695: revertAndPrint("}");
0696: printAndIndent("else {");
0697: simpleAndPrint("outValue = "
0698: + singleQuotes(CommonSeparators.BRANCH_SEPARATOR));
0699: justIndent();
0700: simpleAndPrint("+ document.body.scrollLeft");
0701: simpleAndPrint("+ "
0702: + singleQuotes(CommonSeparators.SUB_TOKEN_SEPARATOR));
0703: simpleAndPrint("+ document.body.scrollTop");
0704: simpleAndPrint("+ "
0705: + singleQuotes(CommonSeparators.BRANCH_SEPARATOR) + ";");
0706: justRevert();
0707: revertAndPrint("}");
0708: simpleAndPrint("return outValue;");
0709: revertAndPrint("}");
0710: }
0711:
0712: protected void startAndEndHideHeavyWeightPageComponentsFunction()
0713: throws IOException {
0714: //
0715: ConsolePageSession localCps = getConsolePageSession();
0716: PageSetupContext localPsc = localCps.getPageSetupContext();
0717: //
0718: printAndIndent("function hideHeavyWeightPageComponents() {");
0719: printAndIndent("if (isIE()) {");
0720: for (int i = 0; i < localPsc.getHeavyWeightPageComponentCount(); i++) {
0721: String nextId = localPsc.getHeavyWeightPageComponent(i);
0722: simpleAndPrint("closeSection('" + nextId + "');");
0723: }
0724: revertAndPrint("}");
0725: revertAndPrint("}");
0726: }
0727:
0728: protected void startAndEndExposeHeavyWeightPageComponentsFunction()
0729: throws IOException {
0730: //
0731: ConsolePageSession localCps = getConsolePageSession();
0732: PageSetupContext localPsc = localCps.getPageSetupContext();
0733: //
0734: printAndIndent("function exposeHeavyWeightPageComponents() {");
0735: printAndIndent("if (isIE()) {");
0736: for (int i = 0; i < localPsc.getHeavyWeightPageComponentCount(); i++) {
0737: String nextId = localPsc.getHeavyWeightPageComponent(i);
0738: simpleAndPrint("openSection('" + nextId + "');");
0739: }
0740: revertAndPrint("}");
0741: revertAndPrint("}");
0742: }
0743:
0744: protected void startAndEndIsCreationParameterClosedFunction()
0745: throws IOException {
0746: //
0747: printAndIndent("function isCreationParameterClosed() {");
0748: simpleAndPrint("return isSectionClosed('"
0749: + CreationParameterContext.getBaseId() + "');");
0750: revertAndPrint("}");
0751: }
0752:
0753: protected void startAndEndExecuteCreationParameterFunction()
0754: throws IOException {
0755: //
0756: ConsolePageSession localCps = getConsolePageSession();
0757: PageSetupContext localPsc = localCps.getPageSetupContext();
0758: //
0759: printAndIndent("function executeCreationParameter(inName) {");
0760: simpleAndPrint("");
0761: simpleAndPrint("var outValue = true;");
0762: simpleAndPrint("");
0763: for (int i = 0; i < localPsc.getCreationParameterCount(); i++) {
0764: //
0765: String nextName = localPsc.getCreationParameterName(i);
0766: CreationParameterContext nextAction = localPsc
0767: .getCreationParameterAction(i);
0768: //
0769: simpleAndPrint("//");
0770: printAndIndent("if (inName == '" + nextName + "') {");
0771: simpleAndPrint("eval('"
0772: + XMLHelper.fromStringToJSCData(nextAction
0773: .createParameterCall()) + "');");
0774: revertAndPrint("}");
0775: }
0776: simpleAndPrint("");
0777: simpleAndPrint("return outValue;");
0778: revertAndPrint("}");
0779: }
0780:
0781: protected void startAndEndAdditionalCommonFunctions()
0782: throws IOException {
0783: CreationParameterContext.renderConceptTagCreationFunction(this );
0784: //startAndEndGraphFuctions();
0785: startAndEndRecordFunction();
0786: startAndEndArrangeSubSectionPositionFunction();
0787: }
0788:
0789: private void startAndEndArrangeSubSectionPositionFunction()
0790: throws IOException {
0791: //
0792: printAndIndent("function arrangeSubSectionPosition() {");
0793: //
0794: //
0795: //build subsection position directives
0796: String subSectionPositions = getSubSectionPosition();
0797:
0798: StringTokenizer st1 = new StringTokenizer(subSectionPositions,
0799: CommonSeparators.BRANCH_SEPARATOR);
0800: while (st1.hasMoreTokens()) {
0801: String nextToken1 = st1.nextToken();
0802: if (nextToken1.length() > 0) {
0803: StringTokenizer st2 = new StringTokenizer(nextToken1,
0804: CommonSeparators.SUB_TOKEN_SEPARATOR);
0805: ArrayList positionParts = new ArrayList();
0806: while (st2.hasMoreTokens()) {
0807: String nextToken2 = st2.nextToken();
0808: if (nextToken2.length() > 0) {
0809: positionParts.add(nextToken2);
0810: }
0811: }
0812: //
0813: if (positionParts.size() == 2) {
0814: //
0815: simpleAndPrint("//");
0816: simpleAndPrint("document.body.scrollLeft = "
0817: + positionParts.get(0) + ";");
0818: simpleAndPrint("document.body.scrollTop = "
0819: + positionParts.get(1) + ";");
0820: } else if (positionParts.size() == 3) {
0821: //
0822: String subSection = ((String) positionParts.get(0));
0823: //
0824: subSection = adjustSubSecIfConfigChangeIsMade(subSection);
0825: //
0826: if (subSection != null) {
0827: //
0828: subSection = getPageComponent(subSection);
0829: simpleAndPrint("//");
0830: simpleAndPrint(subSection + ".scrollLeft = "
0831: + positionParts.get(1) + ";");
0832: simpleAndPrint(subSection + ".scrollTop = "
0833: + positionParts.get(2) + ";");
0834: }
0835: } else {
0836: MiscHelper.println("ConPagCon unkParts = "
0837: + positionParts);
0838: }
0839: }
0840: }
0841: //
0842: //
0843: //
0844: ConsolePageSession localCps = getConsolePageSession();
0845: PageSetupContext localPsc = localCps.getPageSetupContext();
0846: ArrayList highlightHandleShifts = localPsc
0847: .getShiftSubSectionToHighlightHandles();
0848: //
0849: for (int i = 0; i < highlightHandleShifts.size(); i++) {
0850: String s[] = ((String[]) highlightHandleShifts.get(i));
0851: String nextSectionId = getPageComponent(s[0]);
0852: String nextHighlightHandleId = getPageComponent(s[1]);
0853: //
0854: simpleAndPrint("//");
0855: //simpleAndPrint(
0856: // "alert('l=' + " + nextHighlightHandleId + ".offsetLeft);");
0857: //simpleAndPrint(
0858: // "alert('t=' + " + nextHighlightHandleId + ".offsetTop);");
0859: //
0860: simpleAndPrint(nextSectionId + ".scrollLeft = "
0861: + nextSectionId + ".scrollLeft"
0862: + " + getTrueOffsetLeft(" + nextHighlightHandleId
0863: + ")" + " - getTrueOffsetLeft(" + nextSectionId
0864: + ");");
0865: simpleAndPrint(nextSectionId + ".scrollTop = "
0866: + nextSectionId + ".scrollTop"
0867: + " + getTrueOffsetTop(" + nextHighlightHandleId
0868: + ")" + " - getTrueOffsetTop(" + nextSectionId
0869: + ");");
0870: }
0871:
0872: revertAndPrint("}");
0873: }
0874:
0875: private String adjustSubSecIfConfigChangeIsMade(String inId) {
0876:
0877: String outValue = null;
0878:
0879: //
0880: ConsolePageSession localCps = getConsolePageSession();
0881: PageSetupContext localPsc = localCps.getPageSetupContext();
0882:
0883: ArrayList origParts = MiscHelper.parseHandle(inId,
0884: CommonSeparators.TOGGLE_LINK_SEPARATOR);
0885:
0886: ArrayList possibleCurParts = localPsc
0887: .getCurrentSubSectionPositions();
0888: for (int i = 0; i < possibleCurParts.size(); i++) {
0889: String nextCurrSubSectionId = ((String) possibleCurParts
0890: .get(i));
0891: ArrayList nextCurrSubSectionParts = MiscHelper.parseHandle(
0892: nextCurrSubSectionId,
0893: CommonSeparators.TOGGLE_LINK_SEPARATOR);
0894: //
0895: if (origParts.size() > 0
0896: && nextCurrSubSectionParts.size() > 0) {
0897: //
0898: Object lastOrigParts = origParts
0899: .get(origParts.size() - 1);
0900: Object lastCurSubSecParts = nextCurrSubSectionParts
0901: .get(nextCurrSubSectionParts.size() - 1);
0902: //
0903: if (lastOrigParts.equals(lastCurSubSecParts)) {
0904: outValue = nextCurrSubSectionId;
0905: break;
0906: }
0907: }
0908: }
0909:
0910: return outValue;
0911: }
0912:
0913: private void startAndEndRecordFunction() throws IOException {
0914:
0915: //
0916: RecordActionContext rac1 = RecordActionContext
0917: .newInstance(this );
0918: rac1.addAction(ConsoleParameterContext.FIRST_INPUT,
0919: singleQuotes(RecordActionContext.ACTION__IN_PAGE));
0920: rac1.addAction(ConsoleParameterContext.SECOND_INPUT,
0921: singleQuotes(RecordActionContext.SUB_ACTION__CLICK));
0922: rac1.addParameter(ConsoleParameterContext.FIRST_INPUT, "inId");
0923: //
0924: printAndIndent("function recordClick(inId) {");
0925: simpleAndPrint(rac1.recordActionCall());
0926: revertAndPrint("}");
0927:
0928: //
0929: RecordActionContext rac2 = RecordActionContext
0930: .newInstance(this );
0931: rac2.addAction(ConsoleParameterContext.FIRST_INPUT,
0932: singleQuotes(RecordActionContext.ACTION__IN_PAGE));
0933: rac2
0934: .addAction(
0935: ConsoleParameterContext.SECOND_INPUT,
0936: singleQuotes(RecordActionContext.SUB_ACTION__CHANGE_VALUE));
0937: rac2.addParameter(ConsoleParameterContext.FIRST_INPUT, "inId");
0938: rac2.addParameter(ConsoleParameterContext.SECOND_INPUT,
0939: "inValue");
0940: //
0941: printAndIndent("function recordValueChange(inId, inValue) {");
0942: simpleAndPrint(rac2.recordActionCall());
0943: revertAndPrint("}");
0944: }
0945:
0946: //
0947: protected SubmitActionContext createRefreshSac() {
0948:
0949: //
0950: SubmitActionContext outValue = SubmitActionContext
0951: .newInstance(this );
0952:
0953: outValue.addAction(ConsoleParameterContext.FIRST_INPUT,
0954: singleQuotes(SubmitActionParameters.REFRESH));
0955:
0956: return outValue;
0957: }
0958:
0959: //////////////////////////////////////////
0960: private final static String RED_COLOR = "CC0000";
0961: private final static String YELLOW_COLOR = "999900";
0962: private final static String GREEN_COLOR = "00CC00";
0963:
0964: //private final static String BLACK_COLOR = "000000";
0965:
0966: public final static String getNodeColor(boolean inError,
0967: boolean inSubError) {
0968:
0969: String outValue = null;
0970:
0971: if (inError) {
0972: outValue = RED_COLOR;
0973: } else if (inSubError) {
0974: outValue = YELLOW_COLOR;
0975: } else {
0976: outValue = GREEN_COLOR;
0977: }
0978:
0979: return outValue;
0980: }
0981:
0982: //
0983: //
0984: //
0985: //
0986: //
0987: //
0988: private String templateContent = null;
0989: private String mainContent = null;
0990:
0991: protected void renderWebPageTagInstanceViewContext(
0992: int inBaseToggleLinkListLength) throws IOException {
0993:
0994: //
0995: //this.sectionId = getConsolePageSession().getToggleLink();
0996: //this.baseToggleLinkListLength =
0997: // getConsolePageSession().getToggleLinkAsArrayList().size();
0998: //
0999: ConsolePageSession localCps = getConsolePageSession();
1000: //
1001: //
1002: //if (true) {
1003: // return;
1004: //}
1005:
1006: //if (!this.isMetaMode()) {
1007: //
1008: //
1009: //
1010: RootConceptTagHolder localRcth = localCps
1011: .getCurrentApplicationRootHolder();
1012: ConceptTagPreferences localCtp = localRcth.getPreferences();
1013: WebPageTagPreferences localWptp = ((WebPageTagPreferences) localCtp);
1014: //
1015: WebPageTagInstanceViewContext wptivc = WebPageTagInstanceViewContext
1016: .newInstance(localRcth.getPreferences());
1017: localCps.initializeCommonFlags(wptivc);
1018: //
1019: //
1020: String pasteStatic = null;
1021: ConceptTag pasteDynamic = null;
1022: if (localCps.isCopyHolderPresent()
1023: && localCps.isCopyHolderAsStatic()) {
1024: //
1025: pasteStatic = localCps.getCopyHolderValueAsString();
1026: } else if (localCps.isCopyHolderPresent()
1027: && localCps.isCopyHolderAsConceptTag()) {
1028: //
1029: pasteDynamic = localCps.getCopyHolderValueAsConceptTag();
1030: }
1031: //
1032: RootWebPageTag rwpt = ((RootWebPageTag) localRcth
1033: .getFirstChildConceptTag());
1034: if (!rwpt.isTemplateCaller()) {
1035: //
1036: //if (rwpt.isFirstChildPresent()) {
1037: //
1038: if (this .isMetaMode()) {
1039: //
1040: //
1041: WebPageTagInstanceViewContextInfo localWptivci = WebPageTagInstanceViewContext
1042: .displayRootView(localRcth, wptivc);
1043: MiscHelper.profileMemory();
1044: this .mainContent = PopUpViewCreator.generateView(
1045: localWptivci, localCps, this , localRcth
1046: .getPreferences(), localCps
1047: .getStudioUsability(),
1048: inBaseToggleLinkListLength, localWptp,
1049: localRcth.getRootConstraintHolder(), null,
1050: null, false, pasteStatic, pasteDynamic);
1051: } else {
1052: unformattedPrint(this .mainContent);
1053: this .mainContent = null;
1054: }
1055: //}
1056: } else {
1057: //
1058: //
1059: printAndIndent("<table>");
1060: printAndIndent("<tr>");
1061: printAndIndent("<td>");
1062: //
1063: if (rwpt.isFirstChildPresent()) {
1064: //
1065: if (this .isMetaMode()) {
1066: //
1067: //
1068: WebPageTagInstanceViewContextInfo localWptivci = WebPageTagInstanceViewContext
1069: .displayRootView(localRcth, wptivc);
1070: this .templateContent = PopUpViewCreator
1071: .generateView(localWptivci, localCps, this ,
1072: localRcth.getPreferences(),
1073: localCps.getStudioUsability(),
1074: inBaseToggleLinkListLength,
1075: localWptp, localRcth
1076: .getRootConstraintHolder(),
1077: null, null, false, pasteStatic,
1078: pasteDynamic);
1079: //
1080: //
1081: } else {
1082: unformattedPrint(this .templateContent);
1083: this .templateContent = null;
1084: }
1085: }
1086: //
1087: revertAndPrint("</td>");
1088: revertAndPrint("</tr>");
1089: if (localCps.isCurrentApplicationTemplatePresent()) {
1090: RootConceptTagHolder localTempRcth = localCps
1091: .getCurrentApplicationTemplateRootHolder();
1092: ConceptTag tempCt = localTempRcth
1093: .getFirstChildConceptTag();
1094: RootWebPageTag templateRwpt = ((RootWebPageTag) tempCt);
1095: //
1096: printAndIndent("<tr>");
1097: printAndIndent("<td>");
1098: //
1099: if (templateRwpt.isFirstChildPresent()) {
1100: //
1101: if (this .isMetaMode()) {
1102: //
1103: localCps.pushToggleLinkTemplateView();
1104: //
1105: //
1106: WebPageTagInstanceViewContextInfo localTempWptivci = WebPageTagInstanceViewContext
1107: .displayRootView(localTempRcth, wptivc);
1108: this .mainContent = PopUpViewCreator
1109: .generateView(
1110: localTempWptivci,
1111: localCps,
1112: this ,
1113: localTempRcth.getPreferences(),
1114: localCps.getStudioUsability(),
1115: inBaseToggleLinkListLength,
1116: localWptp,
1117: localTempRcth
1118: .getRootConstraintHolder(),
1119: null, null, true, null, null);
1120: //
1121: localCps.popToggleLink();
1122: //
1123: } else {
1124: unformattedPrint(this .mainContent);
1125: this .mainContent = null;
1126: }
1127: }
1128: //
1129: revertAndPrint("</td>");
1130: revertAndPrint("</tr>");
1131: }
1132: revertAndPrint("</table>");
1133: }
1134: //}
1135: }
1136:
1137: //
1138: //
1139: //
1140: public int getSubConsolePageContextCount() {
1141: return this .subCpcs.size();
1142: }
1143:
1144: public String toString() {
1145:
1146: StringBuffer outValue = new StringBuffer();
1147:
1148: //
1149: outValue.append("(subCpc size = "
1150: + getSubConsolePageContextCount() + ")");
1151: //outValue.append("");
1152: //outValue.append("\n");
1153:
1154: return outValue.toString();
1155: }
1156: }
|