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.common.web.template;
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.StringTokenizer;
0016:
0017: //project specific classes
0018: import org.jfolder.common.UnexpectedSystemException;
0019: import org.jfolder.common.utils.misc.CommonSeparators;
0020: import org.jfolder.common.utils.misc.MiscHelper;
0021: import org.jfolder.common.utils.xml.XMLHelper;
0022:
0023: //other classes
0024:
0025: public abstract class ConsoleTemplateFunctionsContext {
0026:
0027: //
0028: protected final static String BRANCH_SEPARATOR = CommonSeparators.BRANCH_SEPARATOR;
0029: //
0030: public final static String NO_BRANCHES_OPEN = "";
0031: //
0032: public final static String HANDLE_SEPARATOR = CommonSeparators.HANDLE_SEPARATOR;
0033: //
0034: public final static String NULL_HANDLE = "";
0035: //
0036: public final static String DIRECT_TEXT_PREFIX = "0_";
0037: public final static String OTHER_TEXT_PREFIX = "1_";
0038: //
0039: protected final static String MAIN_TOGGLE_SECTION = "main";
0040:
0041: //
0042: private int indent[] = null;
0043: private PageSetupContext psc = null;
0044: private transient Writer writer = null;
0045: private boolean metaMode = false;
0046: private String treeState = null;
0047: private String subSectionPosition = null;
0048: //
0049: private int indentIncrement = 0;
0050:
0051: ConsoleTemplateFunctionsContext() {
0052: resetConsolePageFunctionsContext();
0053: }
0054:
0055: protected void initialize(ConsoleTemplateFunctionsContext inCpfc) {
0056: resetConsolePageFunctionsContext();
0057: //
0058: copyFromParent(inCpfc);
0059: }
0060:
0061: protected void copyFromParent(ConsoleTemplateFunctionsContext inCpfc) {
0062: this .indent = inCpfc.indent;
0063: this .psc = inCpfc.psc;
0064: this .writer = inCpfc.writer;
0065: this .metaMode = inCpfc.metaMode;
0066: this .treeState = inCpfc.treeState;
0067: this .subSectionPosition = inCpfc.subSectionPosition;
0068: this .indentIncrement = inCpfc.indentIncrement;
0069:
0070: }
0071:
0072: public void resetConsolePageFunctionsContext() {
0073: this .metaMode = false;
0074: this .treeState = NO_BRANCHES_OPEN;
0075: this .subSectionPosition = "";
0076: resetIndent();
0077: this .indentIncrement = 2;//0;//4;
0078: }
0079:
0080: private void resetIndent() {
0081: this .indent = new int[1];
0082: }
0083:
0084: public void setIndentIncrement(int inIncrement) {
0085: this .indentIncrement = inIncrement;
0086: }
0087:
0088: //
0089: public void prepareForReuse() {
0090: resetIndent();
0091: }
0092:
0093: protected String getSequenceCode() {
0094: return "";
0095: }
0096:
0097: public abstract String getFromPage();
0098:
0099: public String getAliasHandle() {
0100: return getHandle();
0101: }
0102:
0103: protected String getHandle() {
0104: return (NULL_HANDLE);
0105: }
0106:
0107: protected String getTreeStateUpdateDestination() {
0108: return null;
0109: }
0110:
0111: public int getIndent() {
0112: return this .indent[0];
0113: }
0114:
0115: public Writer getWriter() {
0116: return this .writer;
0117: }
0118:
0119: public PageSetupContext getPageSetupContext() {
0120: return this .psc;
0121: }
0122:
0123: public String getTreeState() {
0124: return this .treeState;
0125: }
0126:
0127: public void setTreeState(String inTreeState) {
0128: this .treeState = inTreeState;
0129: }
0130:
0131: public String getSubSectionPosition() {
0132: return this .subSectionPosition;
0133: }
0134:
0135: public void setSubSectionPosition(String inSubSectionPosition) {
0136: this .subSectionPosition = inSubSectionPosition;
0137: }
0138:
0139: public ArrayList getTreeStateAsArrayList() {
0140:
0141: ArrayList outValue = new ArrayList();
0142:
0143: StringTokenizer st = new StringTokenizer(getTreeState(),
0144: BRANCH_SEPARATOR);
0145: while (st.hasMoreTokens()) {
0146: String nextToken = st.nextToken();
0147: if (nextToken.length() > 0) {
0148: outValue.add(nextToken);
0149: }
0150: }
0151:
0152: return outValue;
0153: }
0154:
0155: //public void alignTreeStateToCommonStem(ConsoleTemplateSession inCts) {
0156: //}
0157: //public void alignTreeStateToCommonStem2(ConsoleTemplateSession inCts) {
0158: //
0159: // ArrayList updatedTreeState = new ArrayList();
0160: //
0161: // ArrayList commonStem = inCts.getToggleLinkAsArrayList();
0162: // String commonStemTip = ((String)commonStem.get(
0163: // commonStem.size() - 1));
0164: //
0165: // ArrayList currentTreeState = getTreeStateAsArrayList();
0166: // for (int i = 0; i < currentTreeState.size(); i++) {
0167: // //
0168: // ArrayList nextCurrentTreeBranch = MiscHelper.parseHandle(
0169: // ((String)currentTreeState.get(i)),
0170: // ConsoleTemplateSession.TOGGLE_LINK_SEPARATOR);
0171: // //
0172: // if (nextCurrentTreeBranch.contains(commonStemTip)) {
0173: // ArrayList nextUpdatedTreeBranch = new ArrayList(commonStem);
0174: // nextUpdatedTreeBranch.addAll(
0175: // nextCurrentTreeBranch.subList(
0176: // (nextCurrentTreeBranch.indexOf(commonStemTip) + 1),
0177: // nextCurrentTreeBranch.size()));
0178: // //
0179: // updatedTreeState.add(nextUpdatedTreeBranch);
0180: // }
0181: // else {
0182: // updatedTreeState.add(nextCurrentTreeBranch);
0183: // }
0184: // }
0185: //
0186: // setTreeState(updatedTreeState);
0187: //}
0188: public boolean isTreeComponentPresent(String inTreeComponent) {
0189:
0190: boolean outValue = false;
0191:
0192: ArrayList treeList = getTreeStateAsArrayList();
0193: for (int i = 0; i < treeList.size(); i++) {
0194: outValue |= treeList.get(i).equals(inTreeComponent);
0195: }
0196:
0197: return outValue;
0198: }
0199:
0200: public void addTreeComponent(String inTreeComponent) {
0201: if (!isTreeComponentPresent(inTreeComponent)) {
0202: ArrayList currentTreeState = getTreeStateAsArrayList();
0203: currentTreeState.add(inTreeComponent);
0204: setTreeState(currentTreeState);
0205: } else {
0206: throw new UnexpectedSystemException("Tree component '"
0207: + inTreeComponent + "' already registered");
0208: }
0209: }
0210:
0211: public void removeTreeComponent(String inTreeComponent) {
0212: if (isTreeComponentPresent(inTreeComponent)) {
0213: ArrayList currentTreeState = getTreeStateAsArrayList();
0214: for (int i = currentTreeState.size() - 1; i >= 0; i--) {
0215: if (currentTreeState.get(i).equals(inTreeComponent)) {
0216: currentTreeState.remove(i);
0217: }
0218: }
0219: setTreeState(currentTreeState);
0220: } else {
0221: throw new UnexpectedSystemException("Tree component '"
0222: + inTreeComponent + "' not present");
0223: }
0224: }
0225:
0226: public void setTreeState(ArrayList inTreeComponents) {
0227:
0228: StringBuffer sb = new StringBuffer();
0229:
0230: for (int i = 0; i < inTreeComponents.size(); i++) {
0231: sb.append(BRANCH_SEPARATOR);
0232: sb.append(inTreeComponents.get(i));
0233: sb.append(BRANCH_SEPARATOR);
0234: }
0235:
0236: setTreeState(sb.toString());
0237: }
0238:
0239: //
0240: public void createConsolePage(Writer inWriter,
0241: PageSetupContext inPsc) throws IOException {
0242: //
0243: this .writer = inWriter;
0244: this .psc = inPsc;
0245: renderConsolePage();
0246: }
0247:
0248: protected abstract void renderConsolePage() throws IOException;
0249:
0250: //
0251:
0252: //
0253: public final static String getPageComponent(String inId) {
0254: return getPageComponent(inId, true);
0255: }
0256:
0257: public final static String getPageComponent(String inId,
0258: boolean inQuotes) {
0259: //
0260: String outValue = null;
0261:
0262: if (inQuotes) {
0263: outValue = "getPageComponent('" + inId + "')";
0264: } else {
0265: outValue = "getPageComponent(" + inId + ")";
0266: }
0267:
0268: return outValue;
0269: }
0270:
0271: protected final static String getPageComponentValue(String inId) {
0272: //
0273: return (getPageComponent(inId) + ".value");
0274: }
0275:
0276: protected final static String getPageComponentValue(String inId,
0277: boolean inQuotes) {
0278: //
0279: return (getPageComponent(inId, inQuotes) + ".value");
0280: }
0281:
0282: //
0283: protected String createTextBox(String inId, String inValue,
0284: HashMap inAttrs, HashMap inStyles, Integer inSize,
0285: Integer inMaxLength, String inOnChange) throws IOException {
0286:
0287: StringBuffer outValue = new StringBuffer();
0288:
0289: HashMap attrs = new HashMap();
0290: if (inAttrs != null) {
0291: attrs = (HashMap) inAttrs.clone();
0292: }
0293:
0294: attrs.put("type", "text");
0295: attrs.put("id", inId);
0296: attrs.put("name", inId);
0297: if (inValue != null) {
0298: attrs.put("value", XMLHelper.fromStringToCData(inValue));
0299: }
0300: if (inStyles != null) {
0301: attrs.put("style", XMLHelper.fromStylesToAttr(inStyles));
0302: }
0303: if (inSize != null) {
0304: attrs.put("size", inSize.toString());
0305: }
0306: if (inMaxLength != null) {
0307: attrs.put("maxlength", inMaxLength.toString());
0308: }
0309: //RecordActionContext rac = RecordActionContext.newInstance(this);
0310: ////TO DO: fill this in
0311: //String onchange = rac.recordActionCall();
0312: //if (inOnChange != null) {
0313: // onchange = onchange + " " + inOnChange;
0314: //}
0315: if (inOnChange != null) {
0316: attrs.put("onchange", inOnChange);
0317: }
0318:
0319: outValue.append("<input " + XMLHelper.convertAttrs(attrs)
0320: + "/>");
0321:
0322: return outValue.toString();
0323: }
0324:
0325: protected String createTextArea(String inId, String inValue,
0326: HashMap inAttrs, HashMap inStyles, Integer inRows,
0327: Integer inColumns, String inOnChange) throws IOException {
0328:
0329: StringBuffer outValue = new StringBuffer();
0330:
0331: HashMap attrs = new HashMap();
0332: if (inAttrs != null) {
0333: attrs = (HashMap) inAttrs.clone();
0334: }
0335:
0336: attrs.put("id", inId);
0337: attrs.put("name", inId);
0338: attrs.put("wrap", "off");
0339: String styles = "";
0340: if (inStyles != null) {
0341: styles = XMLHelper.fromStylesToAttr(inStyles);
0342: styles = "style=\"" + styles + "\"";
0343: }
0344: if (inRows != null) {
0345: attrs.put("rows", inRows.toString());
0346: }
0347: if (inColumns != null) {
0348: attrs.put("cols", inColumns.toString());
0349: }
0350: if (inOnChange != null) {
0351: attrs.put("onchange", inOnChange);
0352: }
0353:
0354: //RecordActionContext rac = RecordActionContext.newInstance(this);
0355: ////TO DO: fill this in
0356: //String onchange = rac.recordActionCall();
0357: //attrs.put("onchange", onchange);
0358:
0359: outValue.append("<textarea " + styles + " "
0360: + XMLHelper.convertAttrs(attrs) + ">"
0361: + XMLHelper.fromStringToCData(inValue) + "</textarea>");
0362:
0363: return outValue.toString();
0364: }
0365:
0366: protected String createFileUpload(String inId, Integer inSize) {
0367: return createFileUpload(inId, inSize, null, null);
0368: }
0369:
0370: protected String createFileUpload(String inId, Integer inSize,
0371: HashMap inAttrs, HashMap inStyles) {
0372:
0373: StringBuffer outValue = new StringBuffer();
0374:
0375: HashMap attrs = new HashMap();
0376: if (inAttrs != null) {
0377: attrs = (HashMap) inAttrs.clone();
0378: }
0379:
0380: attrs.put("id", inId);
0381: attrs.put("name", inId);
0382: attrs.put("type", "file");
0383: if (inSize != null) {
0384: attrs.put("size", inSize.toString());
0385: attrs.put("width", inSize.toString());
0386: }
0387: if (inStyles != null) {
0388: attrs.put("style", XMLHelper.fromStylesToAttr(inStyles));
0389: }
0390:
0391: outValue.append("<input " + XMLHelper.convertAttrs(attrs)
0392: + "/>");
0393:
0394: return outValue.toString();
0395: }
0396:
0397: protected String createHiddenField(String inId, String inValue,
0398: HashMap inAttrs) throws IOException {
0399:
0400: StringBuffer outValue = new StringBuffer();
0401:
0402: HashMap attrs = new HashMap();
0403: if (inAttrs != null) {
0404: attrs = (HashMap) inAttrs.clone();
0405: }
0406:
0407: attrs.put("id", inId);
0408: attrs.put("name", inId);
0409: attrs.put("value", XMLHelper.fromStringToCData(inValue));
0410: attrs.put("type", "hidden");
0411:
0412: outValue.append("<input " + XMLHelper.convertAttrs(attrs)
0413: + "/>");
0414:
0415: return outValue.toString();
0416: }
0417:
0418: public String createDropDownBox(String inId, ArrayList inLabels,
0419: ArrayList inValues, HashMap inAttrs, HashMap inStyles,
0420: int inSelected, Integer inSize, String inOnChange,
0421: ArrayList inOnSelect) throws IOException {
0422:
0423: StringBuffer outValue = new StringBuffer();
0424:
0425: HashMap attrs = new HashMap();
0426: if (inAttrs != null) {
0427: attrs = (HashMap) inAttrs.clone();
0428: }
0429: attrs.put("id", inId);
0430: attrs.put("name", inId);
0431: if (inStyles != null) {
0432: attrs.put("style", XMLHelper.fromStylesToAttr(inStyles));
0433: }
0434: if (inSize != null) {
0435: attrs.put("size", inSize.toString());
0436: }
0437: //RecordActionContext rac = RecordActionContext.newInstance(this);
0438: ////TO DO: fill this in
0439: //String onchange = rac.recordActionCall();
0440: //if (inOnChange != null) {
0441: // onchange = onchange + " " + inOnChange;
0442: //}
0443: if (inOnChange != null) {
0444: attrs.put("onchange", inOnChange);
0445: }
0446:
0447: outValue.append("<select " + XMLHelper.convertAttrs(attrs)
0448: + ">");
0449:
0450: for (int i = 0; i < inLabels.size(); i++) {
0451: //
0452: String nextLabel = inLabels.get(i).toString();
0453: //
0454: HashMap nextAttrs = new HashMap();
0455: nextAttrs.put("value", inValues.get(i));
0456: //
0457: if (i == inSelected && !attrs.containsKey("multiple")) {
0458: nextAttrs.put("selected", "true");
0459: }
0460: //
0461: //if (inOnSelect != null && inOnSelect.get(i) != null) {
0462: // nextAttrs.put("onselectstart", ((String)inOnSelect.get(i)));
0463: //}
0464: //
0465: outValue.append("<option "
0466: + XMLHelper.convertAttrs(nextAttrs) + ">"
0467: + XMLHelper.fromStringToCData(nextLabel)
0468: + "</option>");
0469: }
0470:
0471: outValue.append("</select>");
0472:
0473: return outValue.toString();
0474: }
0475:
0476: protected String createStaticImage(String inId, String inSrc,
0477: HashMap inAttrs, HashMap inStyles) throws IOException {
0478:
0479: StringBuffer outValue = new StringBuffer();
0480:
0481: HashMap attrs = new HashMap();
0482: if (inAttrs != null) {
0483: attrs = (HashMap) inAttrs.clone();
0484: }
0485: attrs.put("src", inSrc);
0486: if (inStyles != null) {
0487: attrs.put("style", XMLHelper.fromStylesToAttr(inStyles));
0488: }
0489: if (inId != null) {
0490: attrs.put("id", inId);
0491: }
0492:
0493: outValue.append("<img " + XMLHelper.convertAttrs(attrs) + "/>");
0494:
0495: return outValue.toString();
0496: }
0497:
0498: //
0499:
0500: protected boolean isTemplate() {
0501: return true;
0502: }
0503:
0504: protected void startBodyTag() throws IOException {
0505: printAndIndent("<body onmouseover=\"closeOpenTagMenus('')\""
0506: + " onload=\"executeMacro()\">");
0507: }
0508:
0509: protected void startCommonPage() throws IOException {
0510: //
0511: //
0512: //
0513: PageSetupContext localPsc = getPageSetupContext();
0514: //
0515:
0516: //
0517: //
0518: //
0519: printAndIndent("<html>");
0520: printAndIndent("<head>");
0521: simpleAndPrint("<title>" + localPsc.getTitle() + "</title>");
0522: printAndIndent("<script language=\"JavaScript1.3\">");
0523: printAndIndent("<!--");
0524: startAndEndCommonFunctions();
0525: revertAndPrint("-->");
0526: revertAndPrint("</script>");
0527: revertAndPrint("</head>");
0528: //
0529: //
0530: startBodyTag();
0531: //
0532: //
0533: //if (!isTemplate()) {
0534: // printAndIndent("<body onmouseover=\"closeOpenTagMenus('')\""
0535: // + " onmousemove=\"move(event)\" onload=\"executeMacro()\">");
0536: //}
0537: //else {
0538: // printAndIndent("<body onmouseover=\"closeOpenTagMenus('')\""
0539: // + " onload=\"executeMacro()\">");
0540: //}
0541: printAndIndent("<form name=\""
0542: + ConsoleTemplateParameters.ACTION_FORM
0543: + "\" method=\"POST\" enctype=\"multipart/form-data\">");
0544: SubmitActionContext.formParameters(this , getTreeState(),
0545: getSequenceCode(), this .psc);
0546: simpleAndPrint("<img src=\""
0547: + ConsoleTemplateParameters.GIF_MACRO_POINTER
0548: + "\" style=\"display: none; position: absolute;"
0549: + " z-index: "
0550: + CommonSeparators.Z_INDEX__MACRO_POINTER + "\" id=\""
0551: //+ "\" style=\"position: absolute\" id=\""
0552: + ConsoleTemplateSession.getMacroPointerId() + "\"/>");
0553: simpleAndPrint("<img src=\""
0554: + ConsoleTemplateParameters.GIF_BLANK
0555: + "\" style=\"display: none; position: absolute;"
0556: + " z-index: "
0557: + CommonSeparators.Z_INDEX__WEB_PAGE_VIEW_HIGHLIGHT
0558: + "\" id=\""
0559: //+ "\" style=\"position: absolute\" id=\""
0560: + ConsoleTemplateSession.getWebPageViewHighlight()
0561: + "\"/>");
0562: startAndEndOtherPageComponents();
0563: }
0564:
0565: protected void endCommonPageExtensions() throws IOException {
0566: }
0567:
0568: protected void endCommonPage() throws IOException {
0569: endCommonPageExtensions();
0570: revertAndPrint("</form>");
0571: revertAndPrint("</body>");
0572: revertAndPrint("</html>");
0573: }
0574:
0575: protected void startAndEndOtherPageComponents() throws IOException {
0576: }
0577:
0578: protected void startAndEndPreparationBeforeSubmitFunction()
0579: throws IOException {
0580: //
0581: printAndIndent("function preparationBeforeSubmit() {");
0582: revertAndPrint("}");
0583: }
0584:
0585: protected void startAndEndHideHeavyWeightPageComponentsFunction()
0586: throws IOException {
0587: //
0588: printAndIndent("function hideHeavyWeightPageComponents() {");
0589: revertAndPrint("}");
0590: }
0591:
0592: protected void startAndEndExposeHeavyWeightPageComponentsFunction()
0593: throws IOException {
0594: //
0595: printAndIndent("function exposeHeavyWeightPageComponents() {");
0596: revertAndPrint("}");
0597: }
0598:
0599: protected void startAndEndIsCreationParameterClosedFunction()
0600: throws IOException {
0601: //
0602: printAndIndent("function isCreationParameterClosed() {");
0603: simpleAndPrint("return true;");
0604: revertAndPrint("}");
0605: }
0606:
0607: protected void startAndEndExecuteCreationParameterFunction()
0608: throws IOException {
0609: //
0610: printAndIndent("function executeCreationParameter(inName) {");
0611: simpleAndPrint("");
0612: simpleAndPrint("var outValue = true;");
0613: simpleAndPrint("");
0614: simpleAndPrint("return outValue;");
0615: revertAndPrint("}");
0616: }
0617:
0618: private void startAndEndWebPageViewPopUpFunction()
0619: throws IOException {
0620: //
0621: simpleAndPrint("");
0622: simpleAndPrint("");
0623: simpleAndPrint("var openWebPageViewPopUpId = null;");
0624: simpleAndPrint("");
0625: printAndIndent("function openWebPageViewPopUp(inPopUpId) {");
0626: //simpleAndPrint("var outValue = true;");
0627: simpleAndPrint("closeOpenTagMenus('');");
0628: simpleAndPrint("closeWebPageViewPopUp();");
0629: simpleAndPrint("hideHeavyWeightPageComponents();");
0630: simpleAndPrint("openWebPageViewPopUpId = inPopUpId;");
0631: simpleAndPrint("centerAndDisplay(inPopUpId);");
0632: //simpleAndPrint("return outValue;");
0633: revertAndPrint("}");
0634: simpleAndPrint("");
0635: printAndIndent("function closeWebPageViewPopUp() {");
0636: printAndIndent("if (openWebPageViewPopUpId != null) {");
0637: simpleAndPrint("closeSection(openWebPageViewPopUpId);");
0638: simpleAndPrint("openWebPageViewPopUpId = null;");
0639: revertAndPrint("}");
0640: revertAndPrint("}");
0641: }
0642:
0643: private void startAndEndCommonFunctions() throws IOException {
0644: simpleAndPrint("var openTagMenus = '';");
0645: //
0646: printAndIndent("function isIE() {");
0647: simpleAndPrint("return (navigator.appName.indexOf(");
0648: justIndent();
0649: simpleAndPrint("'Microsoft Internet Explorer', 0) >= 0);");
0650: justRevert();
0651: revertAndPrint("}");
0652: //
0653: startAndEndPreparationBeforeSubmitFunction();
0654: //
0655: SubmitActionContext.submitActionFunction(this );
0656: //
0657: RecordActionContext.recordActionFunction(this );
0658: //
0659: //
0660: startAndEndHideHeavyWeightPageComponentsFunction();
0661: //
0662: startAndEndExposeHeavyWeightPageComponentsFunction();
0663: //
0664: startAndEndIsCreationParameterClosedFunction();
0665: //
0666: startAndEndExecuteCreationParameterFunction();
0667: //
0668: startAndEndWebPageViewPopUpFunction();
0669: //
0670: printAndIndent("function convertIntegerToPixels(inValue) {");
0671: simpleAndPrint("return (inValue + 'px');");
0672: revertAndPrint("}");
0673: //
0674: printAndIndent("function checkAvailabilityWithinDropDownBox(inId, inValue) {");
0675: simpleAndPrint("");
0676: simpleAndPrint("var outValue = false;");
0677: simpleAndPrint("");
0678: simpleAndPrint("var dropDownObj = getPageComponent(inId);");
0679: printAndIndent("for (var i = 0; i < dropDownObj.length; i++) {");
0680: printAndIndent("if (dropDownObj.options[i].value == inValue) {");
0681: simpleAndPrint("outValue = true;");
0682: revertAndPrint("}");
0683: revertAndPrint("}");
0684: simpleAndPrint("");
0685: simpleAndPrint("return outValue;");
0686: revertAndPrint("}");
0687: //
0688: printAndIndent("function removeStringFromString(inString, inRemove) {");
0689: simpleAndPrint("var outValue = null;");
0690: printAndIndent("if (inString.indexOf(inRemove) != -1) {");
0691: simpleAndPrint("var removeIndex = inString.indexOf(inRemove);");
0692: simpleAndPrint("var firstPart = inString.substring(0, removeIndex);");
0693: simpleAndPrint("var lastPart = inString.substring(");
0694: justIndent();
0695: simpleAndPrint("removeIndex + inRemove.length, inString.length);");
0696: justRevert();
0697: simpleAndPrint("outValue = firstPart + lastPart;");
0698: revertAndPrint("}");
0699: printAndIndent("else {");
0700: simpleAndPrint("outValue = inString;");
0701: revertAndPrint("}");
0702: simpleAndPrint("return outValue;");
0703: revertAndPrint("}");
0704: //
0705: printAndIndent("function toggleSectionWithIcon(inIcon, tableId) {");
0706: printAndIndent("if (toggleSection(tableId)) {");
0707: simpleAndPrint("inIcon.src = 'images/tree-open.gif';");
0708: revertAndPrint("}");
0709: printAndIndent("else {");
0710: simpleAndPrint("inIcon.src = 'images/tree-close.gif';");
0711: revertAndPrint("}");
0712: revertAndPrint("}");
0713: //
0714: //printAndIndent("function openSectionOnNonEmptyValue("
0715: // + "inSourceObject, inTableId, inToken) {");
0716: //simpleAndPrint(
0717: // "openSectionOnNonEmptyValue(inSourceObject, inTableId, '');");
0718: //revertAndPrint("}");
0719: //printAndIndent("function openSectionOnNonEmptyValue("
0720: // + "inSourceObject, inTableId) {");
0721: //printAndIndent("if (inSourceObject.value != '') {");
0722: //simpleAndPrint("openSection(inTableId);");
0723: //revertAndPrint("}");
0724: //printAndIndent("else {");
0725: //simpleAndPrint("closeSection(inTableId);");
0726: //revertAndPrint("}");
0727: //revertAndPrint("}");
0728: //
0729: printAndIndent("function isSectionOpen(inSection) {");
0730: simpleAndPrint("return !isSectionClosed(inSection);");
0731: revertAndPrint("}");
0732: printAndIndent("function isSectionClosed(inSection) {");
0733: simpleAndPrint("var outValue = false;");
0734: simpleAndPrint("var sectionObj = getPageComponent(inSection);");
0735: printAndIndent("if (sectionObj != null");
0736: simpleAndPrint("&& sectionObj.style.display != null");
0737: simpleAndPrint("&& sectionObj.style.display == 'none') {");
0738: simpleAndPrint("outValue = true;");
0739: revertAndPrint("}");
0740: printAndIndent("else {");
0741: simpleAndPrint("outValue = false;");
0742: revertAndPrint("}");
0743: simpleAndPrint("return outValue;");
0744: revertAndPrint("}");
0745: //
0746: printAndIndent("function openSection(tableId) {");
0747: printAndIndent("if (isSectionClosed(tableId)) {");
0748: simpleAndPrint("toggleSection(tableId);");
0749: revertAndPrint("}");
0750: revertAndPrint("}");
0751: //
0752: printAndIndent("function closeSection(tableId) {");
0753: printAndIndent("if (isSectionOpen(tableId)) {");
0754: simpleAndPrint("toggleSection(tableId);");
0755: revertAndPrint("}");
0756: revertAndPrint("}");
0757: //
0758: printAndIndent("function toggleSection(tableId) {");
0759: simpleAndPrint("var outValue = false;");
0760: simpleAndPrint("//init consoleTreeState variables");
0761: if (getTreeStateUpdateDestination() != null) {
0762: simpleAndPrint("var actionForm = "
0763: + getTreeStateUpdateDestination() + "."
0764: + ConsoleTemplateParameters.ACTION_FORM + ";");
0765: } else {
0766: simpleAndPrint("var actionForm = document."
0767: + ConsoleTemplateParameters.ACTION_FORM + ";");
0768: }
0769: simpleAndPrint("var currentState = actionForm."
0770: + SubmitActionContext.TREE_STATE + ".value;");
0771: simpleAndPrint("var branchName = '" + BRANCH_SEPARATOR
0772: + "' + tableId + '" + BRANCH_SEPARATOR + "';");
0773: simpleAndPrint("var a = getPageComponent(tableId);");
0774: printAndIndent("if (a.style.display == 'none') {");
0775: simpleAndPrint("outValue = true;");
0776: printAndIndent("if (!isIE()) {");
0777: simpleAndPrint("a.style.display = null;");
0778: revertAndPrint("}");
0779: printAndIndent("else {");
0780: simpleAndPrint("a.style.display = 'block';");
0781: revertAndPrint("}");
0782: simpleAndPrint("//update consoleTreeState");
0783: simpleAndPrint("currentState = removeStringFromString(currentState, branchName);");
0784: simpleAndPrint("currentState = currentState + branchName;");
0785: revertAndPrint("}");
0786: printAndIndent("else {");
0787: simpleAndPrint("outValue = false;");
0788: simpleAndPrint("a.style.display = 'none';");
0789: simpleAndPrint("//update consoleTreeState");
0790: simpleAndPrint("currentState = removeStringFromString(currentState, branchName);");
0791: revertAndPrint("}");
0792: simpleAndPrint("//update consoleTreeState");
0793: printAndIndent("if (tableId.indexOf('"
0794: + ConsoleTemplateSession.DONT_RECORD_THIS_BRANCH
0795: + "') == -1) {");
0796: simpleAndPrint("actionForm." + SubmitActionContext.TREE_STATE
0797: + ".value = currentState;");
0798: revertAndPrint("}");
0799: simpleAndPrint("return outValue;");
0800: revertAndPrint("}");
0801: //
0802: printAndIndent("function initializeTreeState(inState) {");
0803: simpleAndPrint("var actionForm = document."
0804: + ConsoleTemplateParameters.ACTION_FORM + ";");
0805: simpleAndPrint("var allDone = false;");
0806: simpleAndPrint("var initState = '';");
0807: simpleAndPrint("var firstNonSeperatorCharacter = 0;");
0808: simpleAndPrint("var firstSeperatorCharacter = 0;");
0809: printAndIndent("while (!allDone) {");
0810: simpleAndPrint("firstNonSeperatorCharacter = firstSeperatorCharacter;");
0811: printAndIndent("while ((firstNonSeperatorCharacter != inState.length)");
0812: printAndIndent("&& (inState.substring(firstNonSeperatorCharacter,");
0813: simpleAndPrint("firstNonSeperatorCharacter + 1)");
0814: simpleAndPrint("== '" + BRANCH_SEPARATOR + "')) {");
0815: revertAndPrint("firstNonSeperatorCharacter++;");
0816: revertAndPrint("}");
0817: simpleAndPrint("firstSeperatorCharacter = firstNonSeperatorCharacter;");
0818: printAndIndent("while ((firstSeperatorCharacter != inState.length)");
0819: printAndIndent("&& (inState.substring(firstSeperatorCharacter,");
0820: simpleAndPrint("firstSeperatorCharacter + 1)");
0821: simpleAndPrint("!= '" + BRANCH_SEPARATOR + "')) {");
0822: revertAndPrint("firstSeperatorCharacter++;");
0823: revertAndPrint("}");
0824: printAndIndent("if (firstNonSeperatorCharacter != inState.length");
0825: simpleAndPrint("&& firstSeperatorCharacter != inState.length) {");
0826: simpleAndPrint("var nextBranch = inState.substring(firstNonSeperatorCharacter,");
0827: justIndent();
0828: simpleAndPrint("firstSeperatorCharacter);");
0829: justRevert();
0830: printAndIndent("if (getPageComponent(nextBranch) != null) {");
0831: simpleAndPrint("toggleSection(nextBranch);");
0832: simpleAndPrint("initState = initState + '" + BRANCH_SEPARATOR
0833: + "'");
0834: justIndent();
0835: simpleAndPrint("+ nextBranch + '" + BRANCH_SEPARATOR + "';");
0836: justRevert();
0837: revertAndPrint("}");
0838: revertAndPrint("}");
0839: printAndIndent("else {");
0840: simpleAndPrint("allDone = true;");
0841: revertAndPrint("}");
0842: revertAndPrint("}");
0843: simpleAndPrint("actionForm." + SubmitActionContext.TREE_STATE
0844: + ".value = initState;");
0845: revertAndPrint("}");
0846: //
0847: //
0848: //
0849: //
0850: //
0851: //
0852: //
0853: //
0854: printAndIndent("function getTrueOffsetLeft(offsetElement) {");
0855: simpleAndPrint("");
0856: simpleAndPrint("var outValue = offsetElement.offsetLeft;");
0857: // + " + offsetElement.clientLeft;");
0858: simpleAndPrint("");
0859: printAndIndent("if (offsetElement.offsetParent != null) {");
0860: simpleAndPrint("outValue = outValue"
0861: + " + getTrueOffsetLeft(offsetElement.offsetParent);");
0862: revertAndPrint("}");
0863: printAndIndent("if (offsetElement.parentNode != null");
0864: simpleAndPrint("&& offsetElement.parentNode.nodeName == 'DIV') {");
0865: simpleAndPrint("//");
0866: simpleAndPrint("outValue = outValue"
0867: + " - offsetElement.parentNode.scrollLeft;");
0868: revertAndPrint("}");
0869: simpleAndPrint("");
0870: simpleAndPrint("return outValue;");
0871: revertAndPrint("}");
0872: printAndIndent("function getTrueOffsetTop(offsetElement) {");
0873: simpleAndPrint("");
0874: simpleAndPrint("var outValue = offsetElement.offsetTop;");
0875: // + " + offsetElement.clientTop;");
0876: simpleAndPrint("");
0877: printAndIndent("if (offsetElement.offsetParent != null) {");
0878: simpleAndPrint("outValue = outValue"
0879: + " + getTrueOffsetTop(offsetElement.offsetParent);");
0880: revertAndPrint("}");
0881: printAndIndent("if (offsetElement.parentNode != null");
0882: simpleAndPrint("&& offsetElement.parentNode.nodeName == 'DIV') {");
0883: simpleAndPrint("//");
0884: simpleAndPrint("outValue = outValue"
0885: + " - offsetElement.parentNode.scrollTop;");
0886: revertAndPrint("}");
0887: simpleAndPrint("");
0888: simpleAndPrint("return outValue;");
0889: revertAndPrint("}");
0890: //printAndIndent("function getTrueOffsetLeft(offsetElement) {");
0891: //simpleAndPrint("var trueOffsetLeft = offsetElement.offsetLeft;");
0892: //simpleAndPrint("//alert('pre = ' + trueOffsetLeft);");
0893: ////
0894: //printAndIndent("if (offsetElement.offsetParent != null) {");
0895: //simpleAndPrint("trueOffsetLeft = trueOffsetLeft");
0896: //justIndent();
0897: //simpleAndPrint("+ getTrueOffsetLeft(offsetElement.offsetParent);");
0898: //justRevert();
0899: //revertAndPrint("}");
0900: ////
0901: //printAndIndent("if (offsetElement.nodeName == 'DIV') {");
0902: //simpleAndPrint(
0903: // "trueOffsetLeft = trueOffsetLeft - offsetElement.scrollLeft;");
0904: //revertAndPrint("}");
0905: ////
0906: //simpleAndPrint("return trueOffsetLeft;");
0907: //revertAndPrint("}");
0908: ////
0909: //printAndIndent("function getTrueOffsetTop(offsetElement) {");
0910: //simpleAndPrint("var trueOffsetTop = offsetElement.offsetTop;");
0911: //printAndIndent("if (offsetElement.offsetParent != null) {");
0912: //simpleAndPrint("trueOffsetTop = trueOffsetTop");
0913: //justIndent();
0914: //simpleAndPrint("+ getTrueOffsetTop(offsetElement.offsetParent);");
0915: //justRevert();
0916: //revertAndPrint("}");
0917: ////
0918: //printAndIndent("if (offsetElement.nodeName == 'DIV') {");
0919: //simpleAndPrint(
0920: // "trueOffsetTop = trueOffsetTop - offsetElement.scrollTop;");
0921: //revertAndPrint("}");
0922: ////
0923: //simpleAndPrint("return trueOffsetTop;");
0924: //revertAndPrint("}");
0925: //
0926: //
0927: //
0928: //
0929: //
0930: //
0931: //
0932: //
0933: simpleAndPrint("var menuOpenAtPresent = false;");
0934: printAndIndent("function renderMenuNode(inMenuId, inTop,");
0935: simpleAndPrint("inLeft, inDisplacement) {");
0936: simpleAndPrint("");
0937: simpleAndPrint("var outValue = true;");
0938: simpleAndPrint("");
0939: simpleAndPrint("menuOpenAtPresent = true;");
0940: simpleAndPrint("");
0941: simpleAndPrint("hideHeavyWeightPageComponents();");
0942: printAndIndent("if (!isAllowBlockOfWebPageViewPopUpClear()) {");
0943: simpleAndPrint("closeWebPageViewPopUp();");
0944: revertAndPrint("}");
0945: simpleAndPrint("");
0946: simpleAndPrint("var menuNode = getPageComponent(inMenuId);");
0947: simpleAndPrint("menuNode.style.top = convertIntegerToPixels(inTop);");
0948: simpleAndPrint("menuNode.style.left ="
0949: + " convertIntegerToPixels(inLeft + inDisplacement);");
0950: simpleAndPrint("menuNode.style.display = 'block';");
0951: simpleAndPrint("//");
0952: simpleAndPrint("var screenBottom = document.body.scrollTop");
0953: justIndent();
0954: simpleAndPrint("+ window.document.body.clientHeight;");
0955: justRevert();
0956: simpleAndPrint("var tableBottom = menuNode.style.pixelTop");
0957: justIndent();
0958: simpleAndPrint("+ menuNode.offsetHeight;");
0959: justRevert();
0960: simpleAndPrint("//push node up if it goes below bottom of screen");
0961: printAndIndent("if (tableBottom > screenBottom) {");
0962: simpleAndPrint("menuNode.style.top ="
0963: + " convertIntegerToPixels("
0964: + "screenBottom - menuNode.offsetHeight);");
0965: simpleAndPrint("menuNode.style.display = 'none';");
0966: simpleAndPrint("menuNode.style.display = 'block';");
0967: revertAndPrint("}");
0968: simpleAndPrint("openTagMenus = openTagMenus + inMenuId + '"
0969: + BRANCH_SEPARATOR + "';");
0970: simpleAndPrint("");
0971: simpleAndPrint("return outValue;");
0972: //simpleAndPrint("");
0973: revertAndPrint("}");
0974: //
0975: //
0976: //
0977: printAndIndent("function getTokenCount(inValue, inToken) {");
0978: simpleAndPrint("var outValue = 0;");
0979: simpleAndPrint("");
0980: printAndIndent("while (inValue != '') {");
0981: simpleAndPrint("outValue++;");
0982: simpleAndPrint("var tokenIndex = inValue.indexOf(inToken);");
0983: printAndIndent("if (tokenIndex != -1) {");
0984: simpleAndPrint("inValue = inValue.substring(tokenIndex + 1);");
0985: revertAndPrint("}");
0986: printAndIndent("else {");
0987: simpleAndPrint("inValue = '';");
0988: revertAndPrint("}");
0989: revertAndPrint("}");
0990: simpleAndPrint("");
0991: simpleAndPrint("return outValue;");
0992: revertAndPrint("}");
0993: simpleAndPrint("");
0994: printAndIndent("function getNthToken(inValue, inToken, inIndex) {");
0995: simpleAndPrint("");
0996: simpleAndPrint("var outValue = null;");
0997: simpleAndPrint("");
0998: simpleAndPrint("var currentIndex = 0;");
0999: simpleAndPrint("");
1000: printAndIndent("while (inValue != '') {");
1001: simpleAndPrint("var tokenIndex = inValue.indexOf(inToken);");
1002: printAndIndent("if (tokenIndex != -1) {");
1003: printAndIndent("if (currentIndex == inIndex) {");
1004: simpleAndPrint("outValue = inValue.substring(0, tokenIndex);");
1005: revertAndPrint("}");
1006: simpleAndPrint("inValue = inValue.substring(tokenIndex + 1);");
1007: revertAndPrint("}");
1008: printAndIndent("else {");
1009: printAndIndent("if (currentIndex == inIndex) {");
1010: simpleAndPrint("outValue = inValue;");
1011: revertAndPrint("}");
1012: simpleAndPrint("inValue = '';");
1013: revertAndPrint("}");
1014: simpleAndPrint("currentIndex++;");
1015: revertAndPrint("}");
1016: simpleAndPrint("");
1017: simpleAndPrint("return outValue;");
1018: revertAndPrint("}");
1019: //
1020: //
1021: //
1022: //printAndIndent("function closeOpenTagMenus(inId) {");
1023: //revertAndPrint("}");
1024: simpleAndPrint("var studioCloseMenuSource = null;");
1025: printAndIndent("function studioCloseAllMenus(inSource) {");
1026: //printAndIndent("if (studioCloseMenuSource == null) {");
1027: //simpleAndPrint("studioCloseMenuSource = inSource;");
1028: //revertAndPrint("}");
1029: //printAndIndent("else if (studioCloseMenuSource == inSource) {");
1030: //simpleAndPrint("//do nothing");
1031: //revertAndPrint("}");
1032: //printAndIndent("else {");
1033: simpleAndPrint("closeOpenTagMenus('');");
1034: //revertAndPrint("}");
1035: revertAndPrint("}");
1036: printAndIndent("function closeOpenTagMenus(inId) {");
1037: simpleAndPrint("closeOpenTagMenus(inId, true);");
1038: revertAndPrint("}");
1039: printAndIndent("function closeOpenTagMenus(inId, inMacroBlock) {");
1040: simpleAndPrint("");
1041: simpleAndPrint("var outValue = true;");
1042: simpleAndPrint("");
1043: simpleAndPrint("var updateCode = '';");
1044: printAndIndent("if (inId == '' && !menuOpenAtPresent) {");
1045: revertAndPrint("}");
1046: printAndIndent("else {");
1047: printAndIndent("if (!isMacroActive() || !inMacroBlock) {");
1048: printAndIndent("while (openTagMenus != '') {");
1049: simpleAndPrint("var semiIndex = openTagMenus.indexOf('"
1050: + BRANCH_SEPARATOR + "');");
1051: simpleAndPrint("var menuId = openTagMenus.substring(0, semiIndex);");
1052: simpleAndPrint("openTagMenus = openTagMenus.substring(");
1053: justIndent();
1054: simpleAndPrint("semiIndex + 1, openTagMenus.length);");
1055: justRevert();
1056: printAndIndent("if (menuId.indexOf(inId) == 0 && menuId != inId) {");
1057: simpleAndPrint("var menu = getPageComponent(menuId);");
1058: simpleAndPrint("menu.style.display = 'none';");
1059: revertAndPrint("}");
1060: printAndIndent("else {");
1061: simpleAndPrint("updateCode = updateCode + menuId + '"
1062: + BRANCH_SEPARATOR + "';");
1063: revertAndPrint("}");
1064: revertAndPrint("}");
1065: simpleAndPrint("openTagMenus = updateCode;");
1066: revertAndPrint("}");
1067: simpleAndPrint("");
1068: printAndIndent("if (inId == '') {");
1069: simpleAndPrint("studioCloseMenuSource = null;");
1070: simpleAndPrint("setAllowBlockOfWebPageViewPopUpClear(false);");
1071: revertAndPrint("}");
1072: simpleAndPrint("");
1073: printAndIndent("if (inId == '' && isCreationParameterClosed()");
1074: simpleAndPrint("&& openWebPageViewPopUpId == null) {");
1075: simpleAndPrint("//");
1076: simpleAndPrint("exposeHeavyWeightPageComponents();");
1077: revertAndPrint("}");
1078: //////////
1079: revertAndPrint("}");
1080: simpleAndPrint("");
1081: simpleAndPrint("return outValue;");
1082: simpleAndPrint("");
1083: revertAndPrint("}");
1084: //
1085: //
1086: printAndIndent("function stopEventPropogation(inEvent) {");
1087: printAndIndent("if (isIE()) {");
1088: simpleAndPrint("event.cancelBubble = true;");
1089: revertAndPrint("}");
1090: printAndIndent("else {");
1091: simpleAndPrint("inEvent.stopPropagation();");
1092: revertAndPrint("}");
1093: revertAndPrint("}");
1094: //
1095: simpleAndPrint("");
1096: printAndIndent("function getParentSection(inObject) {");
1097: simpleAndPrint("var outValue = null;");
1098: simpleAndPrint("var currentParent = inObject.parentNode;");
1099: printAndIndent("while (currentParent != null && outValue == null) {");
1100: printAndIndent("if (currentParent.nodeName == 'DIV') {");
1101: simpleAndPrint("outValue = currentParent;");
1102: revertAndPrint("}");
1103: simpleAndPrint("currentParent = currentParent.parentNode;");
1104: revertAndPrint("}");
1105: simpleAndPrint("return outValue;");
1106: revertAndPrint("}");
1107: //
1108: simpleAndPrint("");
1109: //simpleAndPrint("var macroGoToSourceId = null;");
1110: //simpleAndPrint("var macroGoToDestinationId = null;");
1111: //simpleAndPrint("var macroGoToCoordinateX = 0;");
1112: //simpleAndPrint("var macroGoToCoordinateY = 0;");
1113: simpleAndPrint("");
1114: //printAndIndent("function macroGoTo() {");
1115: //simpleAndPrint("var outValue = false;");
1116: //simpleAndPrint("//");
1117: //printAndIndent("if (macroGoToSourceId != null"
1118: // + " && macroGoToDestinationId != null) {");
1119: //simpleAndPrint(
1120: // "var macroGoToSourceObject ="
1121: // + " getPageComponent(macroGoToSourceId);");
1122: //simpleAndPrint(
1123: // "var macroGoToDestinationObject ="
1124: // + " getPageComponent(macroGoToDestinationId);");
1125: //simpleAndPrint(
1126: // "var macroGoToDestinationParentObject ="
1127: // + " getParentSection(macroGoToDestinationObject);");
1128: //printAndIndent("if (macroGoToDestinationParentObject != null) {");
1129: //revertAndPrint("}");
1130: //printAndIndent("else {");
1131: //simpleAndPrint("var macroGoToDeltaX = macroGoToObject.style.pixelLeft"
1132: // + " - macroGoToCoordinateX;");
1133: //simpleAndPrint("var macroGoToDeltaY = macroGoToObject.style.pixelTop"
1134: // + " - macroGoToCoordinateY;");
1135: //simpleAndPrint("macroGoToObject.style.pixelLeft ="
1136: // + " macroGoToObject.style.pixelLeft"
1137: // + " - determineShiftDistance(macroGoToDeltaX);");
1138: //simpleAndPrint("macroGoToObject.style.pixelTop ="
1139: // + " macroGoToObject.style.pixelTop"
1140: // + " - determineShiftDistance(macroGoToDeltaY);");
1141: //revertAndPrint("}");
1142: //printAndIndent("if (macroGoToDeltaX != 0 || macroGoToDeltaY != 0) {");
1143: //simpleAndPrint("outValue = true;");
1144: //revertAndPrint("}");
1145: //printAndIndent("else {");
1146: //simpleAndPrint("macroGoToSourceId = null;");
1147: //simpleAndPrint("macroGoToDestinationId = null;");
1148: ////simpleAndPrint("macroGoToCoordinateX = 0;");
1149: ////simpleAndPrint("macroGoToCoordinateY = 0;");
1150: //revertAndPrint("}");
1151: //revertAndPrint("}");
1152: //simpleAndPrint("//");
1153: //simpleAndPrint("return outValue;");
1154: //revertAndPrint("}");
1155: printAndIndent("function determineShiftDistance(inDistance) {");
1156: simpleAndPrint("var outValue = 0;");
1157: simpleAndPrint("var valueSign = 1;");
1158: printAndIndent("if (inDistance < 0) {");
1159: simpleAndPrint("inDistance = -inDistance;");
1160: simpleAndPrint("valueSign = -1;");
1161: revertAndPrint("}");
1162: printAndIndent("if (inDistance > 25) {");
1163: simpleAndPrint("inDistance = 25;");
1164: revertAndPrint("}");
1165: //printAndIndent("else if () {");
1166: //revertAndPrint("}");
1167: printAndIndent("else {");
1168: revertAndPrint("}");
1169: simpleAndPrint("outValue = valueSign*inDistance;");
1170: simpleAndPrint("return outValue;");
1171: revertAndPrint("}");
1172: //
1173: //
1174: //
1175: //
1176: //
1177: //
1178: //
1179: startAndEndMacroFunctions();
1180: //
1181: //
1182: //
1183: //
1184: //
1185: //
1186: //
1187: String imageId = "getPageComponent(imageId)";
1188: printAndIndent("function swapImages(imageId, image1, image2) {");
1189: //
1190: printAndIndent("if (" + imageId
1191: + ".src.indexOf(image1) != -1) {");
1192: simpleAndPrint(imageId + ".src = image2;");
1193: revertAndPrint("}");
1194: printAndIndent("else if (" + imageId
1195: + ".src.indexOf(image2) != -1) {");
1196: simpleAndPrint(imageId + ".src = image1;");
1197: revertAndPrint("}");
1198: //
1199: revertAndPrint("}");
1200: //
1201: //
1202: //
1203: //
1204: //
1205: printAndIndent("function centerAndDisplay(inId) {");
1206: //
1207: simpleAndPrint("var creationObject = "
1208: + getPageComponent("inId", false) + ";");
1209: //
1210: simpleAndPrint("creationObject.style.display = 'block';");
1211: simpleAndPrint("var creationObjectTop =");
1212: justIndent();
1213: simpleAndPrint("document.body.scrollTop");
1214: simpleAndPrint("+ (document.body.clientHeight/2)");
1215: simpleAndPrint("- (creationObject.offsetHeight/2);");
1216: justRevert();
1217: printAndIndent("if (creationObjectTop < 0) {");
1218: simpleAndPrint("creationObjectTop = 0;");
1219: revertAndPrint("}");
1220: //
1221: simpleAndPrint("creationObject.style.top = creationObjectTop;");
1222: simpleAndPrint("");
1223: //
1224: simpleAndPrint("var creationObjectLeft =");
1225: justIndent();
1226: simpleAndPrint("document.body.scrollLeft");
1227: simpleAndPrint("+ (document.body.clientWidth/2)");
1228: simpleAndPrint("- (creationObject.offsetWidth/2);");
1229: justRevert();
1230: printAndIndent("if (creationObjectLeft < 0) {");
1231: simpleAndPrint("creationObjectLeft = 0;");
1232: revertAndPrint("}");
1233: //
1234: simpleAndPrint("creationObject.style.left = creationObjectLeft;");
1235: simpleAndPrint("");
1236: simpleAndPrint("//");
1237: simpleAndPrint("creationObject.style.display = 'none';");
1238: simpleAndPrint("creationObject.style.display = 'block';");
1239: revertAndPrint("}");
1240: //
1241: //
1242: //
1243: //
1244: //
1245: simpleAndPrint("var objIds = null;");
1246: printAndIndent("function getPageComponent(inId) {");
1247: simpleAndPrint("var outValue = null;");
1248: printAndIndent("if (isIE()) {");
1249: printAndIndent("if (objIds == null) {");
1250: simpleAndPrint("objIds = new Object();");
1251: revertAndPrint("}");
1252: printAndIndent("if (objIds[inId] == null) {");
1253: simpleAndPrint("objIds[inId] = document.getElementById(inId);");
1254: revertAndPrint("}");
1255: simpleAndPrint("outValue = objIds[inId];");
1256: revertAndPrint("}");
1257: printAndIndent("else {");
1258: simpleAndPrint("outValue = document.getElementById(inId);");
1259: revertAndPrint("}");
1260: simpleAndPrint("return outValue;");
1261: revertAndPrint("}");
1262: //
1263: //
1264: //
1265: startAndEndTimeAccumulationFunctions();
1266: //
1267: startAndEndEnhancedStudioFunctions();
1268: //
1269: //
1270: //
1271: startAndEndAdditionalCommonFunctions();
1272: }
1273:
1274: protected void startAndEndTimeAccumulationFunctions()
1275: throws IOException {
1276: //
1277: simpleAndPrint("var accumulatedTime = 0;");
1278: printAndIndent("function resetAccumulationTime() {");
1279: simpleAndPrint("accumulatedTime = 0;");
1280: revertAndPrint("}");
1281: printAndIndent("function getCurrentTime() {");
1282: simpleAndPrint("return (new Date()).getTime();");
1283: revertAndPrint("}");
1284: printAndIndent("function addToAccumulatedTime(inStart) {");
1285: simpleAndPrint("accumulatedTime = accumulatedTime");
1286: insertAndPrint("+ (getCurrentTime() - inStart);");
1287: revertAndPrint("}");
1288: printAndIndent("function getAccumulatedTime() {");
1289: simpleAndPrint("return accumulatedTime;");
1290: revertAndPrint("}");
1291: //
1292: simpleAndPrint("var accumulatedCount = 0;");
1293: printAndIndent("function resetAccumulatedCount() {");
1294: simpleAndPrint("accumulatedCount = 0;");
1295: revertAndPrint("}");
1296: printAndIndent("function incrementAccumulatedCount() {");
1297: simpleAndPrint("accumulatedCount = accumulatedCount + 1;");
1298: revertAndPrint("}");
1299: printAndIndent("function getAccumulatedCount() {");
1300: simpleAndPrint("return accumulatedCount;");
1301: revertAndPrint("}");
1302: }
1303:
1304: protected void startAndEndEnhancedStudioFunctions()
1305: throws IOException {
1306: //
1307: //
1308: //
1309: //
1310: printAndIndent("function setAllowBlockOfWebPageViewPopUpClear(");
1311: simpleAndPrint("inValue) {");
1312: revertAndPrint("}");
1313: printAndIndent("function isAllowBlockOfWebPageViewPopUpClear() {");
1314: simpleAndPrint("return false;");
1315: revertAndPrint("}");
1316: }
1317:
1318: private void startAndEndMacroFunctions() throws IOException {
1319: //
1320: printAndIndent("function isMacroActive() {");
1321: simpleAndPrint("return " + this .psc.isReplayMode() + ";");
1322: revertAndPrint("}");
1323: //
1324: simpleAndPrint("var macroGoToSourceId = null;");
1325: simpleAndPrint("var macroGoToDestinationId = null;");
1326: //
1327: printAndIndent("function ensureMacroCursorOnScreen() {");
1328: simpleAndPrint("var macroGoToSourceObject ="
1329: + " getPageComponent(macroGoToSourceId);");
1330: simpleAndPrint("//");
1331: //simpleAndPrint("var sourceWidth ="
1332: // + " macroGoToSourceObject.style.pixelWidth;");
1333: //simpleAndPrint("var sourceHeight ="
1334: // + " macroGoToSourceObject.style.pixelHeight;");
1335: simpleAndPrint("var sourceWidth ="
1336: + " macroGoToSourceObject.offsetWidth;");
1337: simpleAndPrint("var sourceHeight ="
1338: + " macroGoToSourceObject.offsetHeight;");
1339: simpleAndPrint("//");
1340: simpleAndPrint("var browserLeft ="
1341: + " (document.body.scrollLeft + document.body.scrollWidth);");
1342: simpleAndPrint("var browserTop ="
1343: + " (document.body.scrollTop + document.body.scrollHeight);");
1344: simpleAndPrint("//");
1345: //simpleAndPrint("var sourceLeft ="
1346: // + " macroGoToSourceObject.style.pixelLeft;");
1347: //simpleAndPrint("var sourceTop ="
1348: // + " macroGoToSourceObject.style.pixelTop;");
1349: simpleAndPrint("var sourceLeft ="
1350: + " macroGoToSourceObject.offsetLeft;");
1351: simpleAndPrint("var sourceTop ="
1352: + " macroGoToSourceObject.offsetTop;");
1353: simpleAndPrint("//");
1354: printAndIndent("if (sourceLeft < document.body.scrollLeft) {");
1355: //simpleAndPrint("macroGoToSourceObject.style.pixelLeft ="
1356: simpleAndPrint("macroGoToSourceObject.style.left ="
1357: + " document.body.scrollLeft;");
1358: revertAndPrint("}");
1359: printAndIndent("if ((sourceLeft + sourceWidth) > browserLeft) {");
1360: //simpleAndPrint("macroGoToSourceObject.style.pixelLeft ="
1361: simpleAndPrint("macroGoToSourceObject.style.left ="
1362: + " browserLeft - sourceWidth;");
1363: revertAndPrint("}");
1364: simpleAndPrint("//");
1365: printAndIndent("if (sourceTop < document.body.scrollTop) {");
1366: //simpleAndPrint("macroGoToSourceObject.style.pixelTop ="
1367: simpleAndPrint("macroGoToSourceObject.style.top ="
1368: + " document.body.scrollTop;");
1369: revertAndPrint("}");
1370: printAndIndent("if ((sourceTop + sourceHeight) > browserTop) {");
1371: //simpleAndPrint("macroGoToSourceObject.style.pixelTop ="
1372: simpleAndPrint("macroGoToSourceObject.style.top ="
1373: + " browserTop - sourceHeight;");
1374: revertAndPrint("}");
1375: revertAndPrint("}");
1376: //
1377: //
1378: //
1379: //
1380: //
1381: startAndEndMacroGoToFunctions();
1382: //
1383: simpleAndPrint("var currentMacroStep = 0;");
1384: simpleAndPrint("var currentMacroSubStep = 0;");
1385: simpleAndPrint("var currentMacroCommandsTotal = "
1386: + this .psc.getCurrentReplayCommands().size() + ";");
1387: printAndIndent("function executeMacro() {");
1388: //simpleAndPrint("var totalMacroCommands = " + 0 + ";");
1389: //simpleAndPrint("var macroPointer = getPageComponent('"
1390: // + ConsoleTemplateSession.getMacroPointerId() + "')");
1391: //simpleAndPrint("openSection(macroPointer.id);");
1392: //simpleAndPrint(
1393: // "macroGoToSourceId = '"
1394: // + ConsoleTemplateSession.getMacroPointerId() + "';");
1395: //simpleAndPrint("macroGoToCoordinateX = 550;");
1396: //simpleAndPrint("macroGoToCoordinateY = 550;");
1397: //simpleAndPrint("alert('Before Move');");
1398: //simpleAndPrint("macroGoTo();");
1399: //simpleAndPrint("macroPointer.style.display = 'block';");
1400: printAndIndent("if (isMacroActive()) {");
1401: simpleAndPrint("macroGoToSourceId = '"
1402: + ConsoleTemplateSession.getMacroPointerId() + "';");
1403: simpleAndPrint("openSection(macroGoToSourceId);");
1404: simpleAndPrint("ensureMacroCursorOnScreen();");
1405: simpleAndPrint("//Replay Command "
1406: + (1 + this .psc.getCurrentReplayCommand()) + " of "
1407: + this .psc.getTotalReplayCommands());
1408: renderReplayCommands(this .psc.getCurrentReplayCommands());
1409: printAndIndent("if (currentMacroStep < currentMacroCommandsTotal) {");
1410: simpleAndPrint("window.setTimeout('executeMacro()', "
1411: + getMacroInterval() + ");");
1412: //simpleAndPrint("window.setTimeout('executeMacro()', 300);");
1413: revertAndPrint("}");
1414: revertAndPrint("}");
1415: //simpleAndPrint("openSection(macroPointer.id);");
1416: //simpleAndPrint("macroPointer.style.pixelLeft ="
1417: // + " document.body.scrollLeft"
1418: // + " + (document.body.clientWidth/2)"
1419: // + " - (macroPointer.style.pixelWidth/2);");
1420: //simpleAndPrint("macroPointer.style.pixelTop ="
1421: // + " document.body.scrollTop"
1422: // + " + (document.body.clientHeight/2)"
1423: // + " - (macroPointer.style.pixelHeight/2);");
1424: revertAndPrint("}");
1425: printAndIndent("function determineShiftDistance(inDistance) {");
1426: simpleAndPrint("var outValue = 0;");
1427: simpleAndPrint("var valueSign = 1;");
1428: printAndIndent("if (inDistance < 0) {");
1429: simpleAndPrint("inDistance = -inDistance;");
1430: simpleAndPrint("valueSign = -1;");
1431: revertAndPrint("}");
1432: printAndIndent("if (inDistance > 25) {");
1433: simpleAndPrint("inDistance = 25;");
1434: revertAndPrint("}");
1435: printAndIndent("else {");
1436: revertAndPrint("}");
1437: simpleAndPrint("outValue = valueSign*inDistance;");
1438: simpleAndPrint("return outValue;");
1439: revertAndPrint("}");
1440: //
1441: //
1442: printAndIndent("function macroEval(inCommand) {");
1443: simpleAndPrint("var outValue = true;");
1444: simpleAndPrint("eval(inCommand);");
1445: simpleAndPrint("return outValue;");
1446: revertAndPrint("}");
1447: }
1448:
1449: protected void startAndEndMacroGoToFunctions() throws IOException {
1450: printAndIndent("function macroChangeFormValue(inId, inValue) {");
1451: simpleAndPrint("var outValue = true;");
1452: simpleAndPrint("var idComp = getPageComponent(inId);");
1453: printAndIndent("if (idComp.nodeName != 'INPUT'"
1454: + " || idComp.type != 'file') {");
1455: simpleAndPrint("idComp.value = inValue;");
1456: revertAndPrint("}");
1457: simpleAndPrint("return outValue;");
1458: revertAndPrint("}");
1459: printAndIndent("function macroAlert(inMessage) {");
1460: simpleAndPrint("var outValue = true;");
1461: simpleAndPrint("alert(inMessage);");
1462: simpleAndPrint("return outValue;");
1463: revertAndPrint("}");
1464: printAndIndent("function macroGoToPhase1() {");
1465: simpleAndPrint("");
1466: simpleAndPrint("var outValue = true;");
1467: simpleAndPrint("");
1468: simpleAndPrint("ensureMacroCursorOnScreen();");
1469: simpleAndPrint("");
1470: simpleAndPrint("var macroGoToSourceObject ="
1471: + " getPageComponent(macroGoToSourceId);");
1472: simpleAndPrint("var macroGoToDestinationObject ="
1473: + " getPageComponent(macroGoToDestinationId);");
1474: simpleAndPrint("var destinationObjectParent ="
1475: + " getParentSection(macroGoToDestinationObject);");
1476: simpleAndPrint("//");
1477: simpleAndPrint("var middleHeightOfScreen ="
1478: + " getTrueOffsetTop(destinationObjectParent)");
1479: insertAndPrint("+ (destinationObjectParent.offsetHeight/2)");
1480: insertAndPrint("- (document.body.clientHeight/2);");
1481: simpleAndPrint("var middleWidthOfScreen ="
1482: + " getTrueOffsetLeft(destinationObjectParent)");
1483: insertAndPrint("+ (destinationObjectParent.offsetWidth/2)");
1484: insertAndPrint("- (document.body.clientWidth/2);");
1485: simpleAndPrint("//");
1486: simpleAndPrint("var previousScrollLeft = document.body.scrollLeft;");
1487: simpleAndPrint("var previousScrollTop = document.body.scrollTop;");
1488: simpleAndPrint("//");
1489: simpleAndPrint("");
1490: simpleAndPrint("var deltaX ="
1491: + " middleWidthOfScreen - previousScrollLeft;");
1492: simpleAndPrint("var deltaY ="
1493: + " middleHeightOfScreen - previousScrollTop;");
1494: simpleAndPrint("deltaX = determineShiftDistance(deltaX);");
1495: simpleAndPrint("deltaY = determineShiftDistance(deltaY);");
1496: simpleAndPrint("//");
1497: simpleAndPrint("document.body.scrollLeft ="
1498: + " document.body.scrollLeft + deltaX;");
1499: simpleAndPrint("document.body.scrollTop ="
1500: + " document.body.scrollTop + deltaY;");
1501: simpleAndPrint("");
1502: simpleAndPrint("");
1503: simpleAndPrint("//");
1504: simpleAndPrint("var actualDeltaX ="
1505: + " document.body.scrollLeft - previousScrollLeft;");
1506: simpleAndPrint("var actualDeltaY ="
1507: + " document.body.scrollTop - previousScrollTop;");
1508: simpleAndPrint("//");
1509: //simpleAndPrint("macroGoToSourceObject.style.pixelLeft =");
1510: simpleAndPrint("macroGoToSourceObject.style.left =");
1511: insertAndPrint("convertIntegerToPixels("
1512: + "macroGoToSourceObject.offsetLeft + actualDeltaX);");
1513: //simpleAndPrint("macroGoToSourceObject.style.pixelTop =");
1514: simpleAndPrint("macroGoToSourceObject.style.top =");
1515: insertAndPrint("convertIntegerToPixels("
1516: + "macroGoToSourceObject.offsetTop + actualDeltaY);");
1517: simpleAndPrint("");
1518: simpleAndPrint("outValue ="
1519: + " ((actualDeltaX == 0) && (actualDeltaY == 0));");
1520: simpleAndPrint("");
1521: simpleAndPrint("return outValue;");
1522: revertAndPrint("}");
1523: //
1524: //
1525: //
1526: printAndIndent("function macroGoToPhase2() {");
1527: simpleAndPrint("");
1528: simpleAndPrint("var outValue = true;");
1529: simpleAndPrint("");
1530: simpleAndPrint("ensureMacroCursorOnScreen();");
1531: simpleAndPrint("");
1532: simpleAndPrint("var macroGoToSourceObject ="
1533: + " getPageComponent(macroGoToSourceId);");
1534: simpleAndPrint("var macroGoToDestinationObject ="
1535: + " getPageComponent(macroGoToDestinationId);");
1536: simpleAndPrint("var destinationObjectParent ="
1537: + " getParentSection(macroGoToDestinationObject);");
1538: simpleAndPrint("//");
1539: simpleAndPrint("var deltaX ="
1540: + " getTrueOffsetLeft(destinationObjectParent)");
1541: insertAndPrint("- getTrueOffsetLeft(macroGoToSourceObject);");
1542: simpleAndPrint("var deltaY ="
1543: + " getTrueOffsetTop(destinationObjectParent)");
1544: insertAndPrint("- getTrueOffsetTop(macroGoToSourceObject);");
1545: simpleAndPrint("//");
1546: simpleAndPrint("deltaX = determineShiftDistance(deltaX);");
1547: simpleAndPrint("deltaY = determineShiftDistance(deltaY);");
1548: simpleAndPrint("//");
1549: //simpleAndPrint("macroGoToSourceObject.style.pixelLeft =");
1550: simpleAndPrint("macroGoToSourceObject.style.left =");
1551: insertAndPrint("convertIntegerToPixels("
1552: + "macroGoToSourceObject.offsetLeft + deltaX);");
1553: //simpleAndPrint("macroGoToSourceObject.style.pixelTop =");
1554: simpleAndPrint("macroGoToSourceObject.style.top =");
1555: insertAndPrint("convertIntegerToPixels("
1556: + "macroGoToSourceObject.offsetTop + deltaY);");
1557: simpleAndPrint("");
1558: simpleAndPrint("ensureMacroCursorOnScreen();");
1559: simpleAndPrint("");
1560: simpleAndPrint("outValue = (deltaX == 0 && deltaY == 0);");
1561: simpleAndPrint("");
1562: simpleAndPrint("return outValue;");
1563: revertAndPrint("}");
1564: printAndIndent("function macroGoToPhase3() {");
1565: simpleAndPrint("");
1566: simpleAndPrint("var outValue = true;");
1567: simpleAndPrint("");
1568: simpleAndPrint("//ensureMacroCursorOnScreen();");
1569: simpleAndPrint("");
1570: simpleAndPrint("var macroGoToSourceObject ="
1571: + " getPageComponent(macroGoToSourceId);");
1572: simpleAndPrint("var macroGoToDestinationObject ="
1573: + " getPageComponent(macroGoToDestinationId);");
1574: simpleAndPrint("var destinationObjectParent ="
1575: + " getParentSection(macroGoToDestinationObject);");
1576: simpleAndPrint("");
1577: //
1578: //
1579: //
1580: simpleAndPrint("var destParOffsetLeft = 0;");
1581: simpleAndPrint("var destParOffsetTop = 0;");
1582: printAndIndent("if (destinationObjectParent != null) {");
1583: simpleAndPrint("destParOffsetLeft = getTrueOffsetLeft(destinationObjectParent);");
1584: simpleAndPrint("destParOffsetTop = getTrueOffsetTop(destinationObjectParent);");
1585: revertAndPrint("}");
1586: printAndIndent("else {");
1587: simpleAndPrint("destinationObjectParent = document.body;");
1588: simpleAndPrint("destParOffsetLeft = destinationObjectParent.scrollLeft;");
1589: simpleAndPrint("destParOffsetTop = destinationObjectParent.scrollTop;");
1590: revertAndPrint("}");
1591: //printAndIndent("if (destinationObjectParent == null) {");
1592: //simpleAndPrint("destinationObjectParent = document.body;");
1593: //revertAndPrint("}");
1594: //
1595: //
1596: //
1597: simpleAndPrint("");
1598: simpleAndPrint("var subsectionWidth ="
1599: + " destinationObjectParent.clientWidth;");
1600: simpleAndPrint("var subsectionHeight ="
1601: + " destinationObjectParent.clientHeight;");
1602: simpleAndPrint("");
1603: simpleAndPrint("var targetX = destParOffsetLeft");
1604: insertAndPrint("- (macroGoToDestinationObject.offsetWidth/2)"
1605: + " + (subsectionWidth/2);");
1606: simpleAndPrint("var targetY = destParOffsetTop");
1607: insertAndPrint("- (macroGoToDestinationObject.offsetHeight/2)"
1608: + " + (subsectionHeight/2);");
1609: simpleAndPrint("//");
1610: printAndIndent("if (macroGoToDestinationObject.offsetWidth > subsectionWidth) {");
1611: simpleAndPrint("targetX = destParOffsetLeft + (subsectionWidth/2);");
1612: revertAndPrint("}");
1613: simpleAndPrint("//");
1614: printAndIndent("if (macroGoToDestinationObject.offsetHeight"
1615: + " > subsectionHeight) {");
1616: simpleAndPrint("targetY = destParOffsetTop + (subsectionHeight/2);");
1617: revertAndPrint("}");
1618: simpleAndPrint("//");
1619: simpleAndPrint("var deltaX = targetX"
1620: + " - getTrueOffsetLeft(macroGoToDestinationObject);");
1621: simpleAndPrint("var deltaY = targetY"
1622: + " - getTrueOffsetTop(macroGoToDestinationObject);");
1623: simpleAndPrint("");
1624: simpleAndPrint("//");
1625: simpleAndPrint("deltaX = determineShiftDistance(deltaX);");
1626: simpleAndPrint("deltaY = determineShiftDistance(deltaY);");
1627: simpleAndPrint("");
1628: simpleAndPrint("//");
1629: simpleAndPrint("var previousScrollLeft ="
1630: + " destinationObjectParent.scrollLeft;");
1631: simpleAndPrint("var previousScrollTop ="
1632: + " destinationObjectParent.scrollTop;");
1633: simpleAndPrint("//");
1634: simpleAndPrint("destinationObjectParent.scrollLeft ="
1635: + " destinationObjectParent.scrollLeft - deltaX;");
1636: simpleAndPrint("destinationObjectParent.scrollTop ="
1637: + " destinationObjectParent.scrollTop - deltaY;");
1638: simpleAndPrint("//");
1639: simpleAndPrint("var actualDeltaX ="
1640: + " destinationObjectParent.scrollLeft - previousScrollLeft;");
1641: simpleAndPrint("var actualDeltaY ="
1642: + " destinationObjectParent.scrollTop - previousScrollTop;");
1643: simpleAndPrint("");
1644: simpleAndPrint("outValue = (actualDeltaX == 0 && actualDeltaY == 0);");
1645: simpleAndPrint("");
1646: simpleAndPrint("return outValue;");
1647: revertAndPrint("}");
1648: printAndIndent("function macroGoToPhase4() {");
1649: simpleAndPrint("");
1650: simpleAndPrint("var outValue = true;");
1651: simpleAndPrint("");
1652: simpleAndPrint("var macroGoToSourceObject ="
1653: + " getPageComponent(macroGoToSourceId);");
1654: simpleAndPrint("var macroGoToDestinationObject ="
1655: + " getPageComponent(macroGoToDestinationId);");
1656: simpleAndPrint("var destinationObjectParent ="
1657: + " getParentSection(macroGoToDestinationObject);");
1658: simpleAndPrint("");
1659: simpleAndPrint("var deltaX ="
1660: + " getTrueOffsetLeft(macroGoToDestinationObject)");
1661: insertAndPrint("- getTrueOffsetLeft(macroGoToSourceObject);");
1662: simpleAndPrint("var deltaY ="
1663: + " getTrueOffsetTop(macroGoToDestinationObject)");
1664: insertAndPrint("- getTrueOffsetTop(macroGoToSourceObject);");
1665: simpleAndPrint("");
1666: simpleAndPrint("//");
1667: simpleAndPrint("deltaX = determineShiftDistance(deltaX);");
1668: simpleAndPrint("deltaY = determineShiftDistance(deltaY);");
1669: simpleAndPrint("");
1670: //simpleAndPrint("macroGoToSourceObject.style.pixelLeft =");
1671: simpleAndPrint("macroGoToSourceObject.style.left =");
1672: insertAndPrint("convertIntegerToPixels("
1673: + "macroGoToSourceObject.offsetLeft + deltaX);");
1674: //simpleAndPrint("macroGoToSourceObject.style.pixelTop =");
1675: simpleAndPrint("macroGoToSourceObject.style.top =");
1676: insertAndPrint("convertIntegerToPixels("
1677: + "macroGoToSourceObject.offsetTop + deltaY);");
1678: simpleAndPrint("");
1679: simpleAndPrint("outValue = (deltaX == 0 && deltaY == 0);");
1680: simpleAndPrint("");
1681: simpleAndPrint("return outValue;");
1682: revertAndPrint("}");
1683: //
1684: //
1685: printAndIndent("function macroGoTo(inDestinationId) {");
1686: simpleAndPrint("var outValue = false;");
1687: simpleAndPrint("//");
1688: simpleAndPrint("//");
1689: simpleAndPrint("macroGoToDestinationId = inDestinationId;");
1690: simpleAndPrint("//");
1691: printAndIndent("if (macroGoToSourceId != null"
1692: + " && macroGoToDestinationId != null) {");
1693: simpleAndPrint("var macroGoToSourceObject ="
1694: + " getPageComponent(macroGoToSourceId);");
1695: simpleAndPrint("var macroGoToDestinationObject ="
1696: + " getPageComponent(macroGoToDestinationId);");
1697: simpleAndPrint("var macroGoToDestinationParentObject ="
1698: + " getParentSection(macroGoToDestinationObject);");
1699: simpleAndPrint("//");
1700: printAndIndent("if (currentMacroSubStep == 0) {");
1701: printAndIndent("if (macroGoToDestinationParentObject != null) {");
1702: simpleAndPrint("currentMacroSubStep = 1;");
1703: revertAndPrint("}");
1704: printAndIndent("else {");
1705: simpleAndPrint("currentMacroSubStep = 3;");
1706: revertAndPrint("}");
1707: revertAndPrint("}");
1708: simpleAndPrint("//");
1709: simpleAndPrint("//");
1710: simpleAndPrint("//");
1711: simpleAndPrint("//");
1712: simpleAndPrint("//");
1713: printAndIndent("if (currentMacroSubStep == 1) {");
1714: printAndIndent("if (macroGoToPhase1()) {");
1715: simpleAndPrint("currentMacroSubStep = currentMacroSubStep + 1;");
1716: revertAndPrint("}");
1717: revertAndPrint("}");
1718: printAndIndent("else if (currentMacroSubStep == 2) {");
1719: printAndIndent("if (macroGoToPhase2()) {");
1720: simpleAndPrint("currentMacroSubStep = currentMacroSubStep + 1;");
1721: revertAndPrint("}");
1722: revertAndPrint("}");
1723: printAndIndent("else if (currentMacroSubStep == 3) {");
1724: printAndIndent("if (macroGoToDestinationParentObject != null");
1725: simpleAndPrint("&& macroGoToPhase3()) {");
1726: simpleAndPrint("currentMacroSubStep = currentMacroSubStep + 1;");
1727: revertAndPrint("}");
1728: printAndIndent("else if (macroGoToPhase3()) {");
1729: simpleAndPrint("currentMacroSubStep = currentMacroSubStep + 1;");
1730: revertAndPrint("}");
1731: revertAndPrint("}");
1732: printAndIndent("else if (currentMacroSubStep == 4) {");
1733: printAndIndent("if (macroGoToDestinationParentObject != null");
1734: simpleAndPrint("&& macroGoToPhase4()) {");
1735: simpleAndPrint("currentMacroSubStep = currentMacroSubStep + 1;");
1736: revertAndPrint("}");
1737: printAndIndent("else if (macroGoToPhase4()) {");
1738: simpleAndPrint("currentMacroSubStep = currentMacroSubStep + 1;");
1739: //revertAndPrint("}");
1740: revertAndPrint("}");
1741: revertAndPrint("}");
1742: printAndIndent("else {");
1743: simpleAndPrint("outValue = true;");
1744: revertAndPrint("}");
1745: revertAndPrint("}");
1746: printAndIndent("else {");
1747: simpleAndPrint("outValue = true;");
1748: revertAndPrint("}");
1749: simpleAndPrint("return outValue;");
1750: revertAndPrint("}");
1751: //
1752: //
1753: //
1754: //
1755: //
1756: simpleAndPrint("//");
1757: simpleAndPrint("//");
1758: simpleAndPrint("//");
1759: simpleAndPrint("//");
1760: simpleAndPrint("//");
1761: //
1762: printAndIndent("function macroClick(inId) {");
1763: simpleAndPrint("");
1764: simpleAndPrint("var outValue = true;");
1765: simpleAndPrint("");
1766: printAndIndent("if (isIE()) {");
1767: simpleAndPrint("getPageComponent(inId).click();");
1768: revertAndPrint("}");
1769: printAndIndent("else {");
1770: simpleAndPrint("var evt = document.createEvent('MouseEvents');");
1771: simpleAndPrint("evt.initMouseEvent('click', true, true, window,");
1772: insertAndPrint("0, 0, 0, 0, 0, false, false, false, false, 0, null);");
1773: simpleAndPrint("var cb = document.getElementById(inId);");
1774: simpleAndPrint("cb.dispatchEvent(evt);");
1775: revertAndPrint("}");
1776: simpleAndPrint("");
1777: simpleAndPrint("return outValue;");
1778: revertAndPrint("}");
1779: //
1780: simpleAndPrint("//");
1781: printAndIndent("function macroClickImage() {");
1782: simpleAndPrint("");
1783: simpleAndPrint("var outValue = false;");
1784: simpleAndPrint("");
1785: printAndIndent("if (currentMacroSubStep < 15) {");
1786: simpleAndPrint("currentMacroSubStep = currentMacroSubStep + 1;");
1787: simpleAndPrint(getPageComponent(ConsoleTemplateSession
1788: .getMacroPointerId())
1789: + ".src = '"
1790: + ConsoleTemplateParameters.GIF_MACRO_CLICK + "';");
1791: revertAndPrint("}");
1792: printAndIndent("else {");
1793: simpleAndPrint(getPageComponent(ConsoleTemplateSession
1794: .getMacroPointerId())
1795: + ".src = '"
1796: + ConsoleTemplateParameters.GIF_MACRO_POINTER + "';");
1797: simpleAndPrint("outValue = true;");
1798: revertAndPrint("}");
1799: simpleAndPrint("");
1800: simpleAndPrint("return outValue;");
1801: revertAndPrint("}");
1802: simpleAndPrint("//");
1803: simpleAndPrint("//");
1804: //
1805: printAndIndent("function macroChangeValue(inSource, inValue) {");
1806: simpleAndPrint("");
1807: simpleAndPrint("var outValue = false;");
1808: simpleAndPrint("");
1809: printAndIndent("if (currentMacroSubStep < 15) {");
1810: simpleAndPrint("currentMacroSubStep = currentMacroSubStep + 1;");
1811: simpleAndPrint("macroChangeFormValue(inSource, inValue)");
1812: // getPageComponent("inSource", false) + ".value = inValue;");
1813: revertAndPrint("}");
1814: printAndIndent("else {");
1815: simpleAndPrint("outValue = true;");
1816: revertAndPrint("}");
1817: simpleAndPrint("");
1818: simpleAndPrint("return outValue;");
1819: revertAndPrint("}");
1820: simpleAndPrint("//");
1821: simpleAndPrint("//");
1822: //
1823: printAndIndent("function macroGoToIfClosed(inSource, inTarget) {");
1824: simpleAndPrint("");
1825: simpleAndPrint("var outValue = false;");
1826: simpleAndPrint("");
1827: printAndIndent("if (isSectionClosed(inSource)) {");
1828: simpleAndPrint("outValue = macroGoTo(inTarget);");
1829: revertAndPrint("}");
1830: printAndIndent("else {");
1831: simpleAndPrint("outValue = true;");
1832: revertAndPrint("}");
1833: simpleAndPrint("");
1834: simpleAndPrint("return outValue;");
1835: revertAndPrint("}");
1836: simpleAndPrint("//");
1837: //
1838: printAndIndent("function macroClickIfClosed(inSource) {");
1839: simpleAndPrint("");
1840: simpleAndPrint("var outValue = false;");
1841: simpleAndPrint("");
1842: printAndIndent("if (isSectionClosed(inSource)) {");
1843: simpleAndPrint("outValue = macroClickImage();");
1844: revertAndPrint("}");
1845: printAndIndent("else {");
1846: simpleAndPrint("outValue = true;");
1847: revertAndPrint("}");
1848: simpleAndPrint("");
1849: simpleAndPrint("return outValue;");
1850: revertAndPrint("}");
1851: simpleAndPrint("//");
1852: //
1853: //
1854: printAndIndent("function macroClickIfOpen(inSource) {");
1855: simpleAndPrint("");
1856: simpleAndPrint("var outValue = false;");
1857: simpleAndPrint("");
1858: printAndIndent("if (isSectionOpen(inSource)) {");
1859: simpleAndPrint("outValue = macroClickImage();");
1860: revertAndPrint("}");
1861: printAndIndent("else {");
1862: simpleAndPrint("outValue = true;");
1863: revertAndPrint("}");
1864: simpleAndPrint("");
1865: simpleAndPrint("return outValue;");
1866: revertAndPrint("}");
1867: simpleAndPrint("//");
1868: //
1869: printAndIndent("function macroOpenSectionIfClosed("
1870: + "inSource, inTarget, inImage, inImageId) {");
1871: simpleAndPrint("");
1872: simpleAndPrint("var outValue = false;");
1873: simpleAndPrint("");
1874: printAndIndent("if (isSectionClosed(inSource)) {");
1875: simpleAndPrint("openSection(inSource);");
1876: printAndIndent("if (inImage != null && inImageId != null) {");
1877: simpleAndPrint(getPageComponent("inImageId", false)
1878: + ".src = inImage;");
1879: revertAndPrint("}");
1880: simpleAndPrint("outValue = true;");
1881: revertAndPrint("}");
1882: printAndIndent("else {");
1883: simpleAndPrint("outValue = true;");
1884: revertAndPrint("}");
1885: simpleAndPrint("");
1886: simpleAndPrint("return outValue;");
1887: revertAndPrint("}");
1888: //
1889: //
1890: //
1891: //
1892: //
1893: //
1894: printAndIndent("function macroGoToIfAvailable(inSectionId, inTargetId,");
1895: simpleAndPrint("inAlternateTargetId, inValue, inCheckAvailability) {");
1896: simpleAndPrint("");
1897: simpleAndPrint("var outValue = false;");
1898: simpleAndPrint("");
1899: printAndIndent("if (isSectionOpen(inSectionId)) {");
1900: printAndIndent("if (inCheckAvailability) {");
1901: simpleAndPrint("inValue = '"
1902: + CommonSeparators.LIST_CPC_SEPARATOR + "' + inValue;");
1903: printAndIndent("if (checkAvailabilityWithinDropDownBox("
1904: + "inTargetId, inValue)) {");
1905: simpleAndPrint("outValue = macroGoTo(inTargetId);");
1906: revertAndPrint("}");
1907: printAndIndent("else {");
1908: printAndIndent("if (inAlternateTargetId != null) {");
1909: simpleAndPrint("outValue = macroGoTo(inAlternateTargetId);");
1910: revertAndPrint("}");
1911: printAndIndent("else {");
1912: simpleAndPrint("alert('(macroGoToIfAvailable) {' + inTargetId");
1913: insertAndPrint("+ '} does not contain {' + inValue + '}');");
1914: simpleAndPrint("outValue = true;");
1915: revertAndPrint("}");
1916: revertAndPrint("}");
1917: revertAndPrint("}");
1918: printAndIndent("else {");
1919: simpleAndPrint("outValue = macroGoTo(inTargetId);");
1920: revertAndPrint("}");
1921: revertAndPrint("}");
1922: printAndIndent("else {");
1923: simpleAndPrint("outValue = true;");
1924: revertAndPrint("}");
1925: simpleAndPrint("");
1926: simpleAndPrint("return outValue;");
1927: revertAndPrint("}");
1928: //
1929: //
1930: //
1931: //
1932: //
1933: printAndIndent("function macroChangeValueIfAvailable(inSectionId, inTargetId,");
1934: simpleAndPrint("inAlternateTargetId, inValue, inCheckAvailability) {");
1935: simpleAndPrint("");
1936: simpleAndPrint("var outValue = false;");
1937: simpleAndPrint("");
1938: printAndIndent("if (isSectionOpen(inSectionId)) {");
1939: printAndIndent("if (inCheckAvailability) {");
1940: simpleAndPrint("inValue = '"
1941: + CommonSeparators.LIST_CPC_SEPARATOR + "' + inValue;");
1942: printAndIndent("if (checkAvailabilityWithinDropDownBox(inTargetId, inValue)) {");
1943: simpleAndPrint("outValue = macroChangeFormValue(inTargetId, inValue);");
1944: revertAndPrint("}");
1945: printAndIndent("else {");
1946: printAndIndent("if (inAlternateTargetId != null) {");
1947: simpleAndPrint("outValue = macroChangeFormValue(inAlternateTargetId, inValue);");
1948: revertAndPrint("}");
1949: printAndIndent("else {");
1950: simpleAndPrint("alert('(macroChangeValueIfAvailable) {' + inTargetId");
1951: insertAndPrint("+ '} does not contain {' + inValue + '}');");
1952: simpleAndPrint("outValue = true;");
1953: revertAndPrint("}");
1954: revertAndPrint("}");
1955: revertAndPrint("}");
1956: printAndIndent("else {");
1957: simpleAndPrint("outValue = macroChangeFormValue(inTargetId, inValue);");
1958: revertAndPrint("}");
1959: revertAndPrint("}");
1960: printAndIndent("else {");
1961: simpleAndPrint("outValue = true;");
1962: revertAndPrint("}");
1963: simpleAndPrint("");
1964: simpleAndPrint("return outValue;");
1965: revertAndPrint("}");
1966: }
1967:
1968: protected void startAndEndAdditionalCommonFunctions()
1969: throws IOException {
1970: }
1971:
1972: private void renderReplayCommands(ArrayList inCommands)
1973: throws IOException {
1974: for (int i = 0; i < inCommands.size(); i++) {
1975: Object nextCommand = inCommands.get(i);
1976: if (nextCommand == null) {
1977: UnexpectedSystemException.unknownState();
1978: } else if (nextCommand instanceof String) {
1979: if (i > 0) {
1980: printAndIndent("else if (currentMacroStep == " + i
1981: + ") {");
1982: } else {
1983: printAndIndent("if (currentMacroStep == " + i
1984: + ") {");
1985: }
1986: printAndIndent("if (" + nextCommand + ") {");
1987: simpleAndPrint("currentMacroStep = currentMacroStep + 1;");
1988: simpleAndPrint("currentMacroSubStep = 0;");
1989: revertAndPrint("}");
1990: revertAndPrint("}");
1991: }
1992: //else if (nextCommand instanceof ArrayList) {
1993: // justIndent();
1994: // renderReplayCommands((ArrayList)nextCommand);
1995: // justRevert();
1996: //}
1997: else {
1998: UnexpectedSystemException.unknownState();
1999: }
2000: }
2001: }
2002:
2003: public String getMacroInterval() {
2004: return "100";
2005: }
2006:
2007: public boolean isMetaMode() {
2008: return this .metaMode;
2009: }
2010:
2011: public void setMetaMode(boolean inMode) {
2012: this .metaMode = inMode;
2013: }
2014:
2015: public void justIndent() {
2016: if (!isMetaMode()) {
2017: this .indent[0] = this .indent[0] + this .indentIncrement;
2018: }
2019: }
2020:
2021: public void justRevert() {
2022: if (!isMetaMode()) {
2023: this .indent[0] = this .indent[0] - this .indentIncrement;
2024: }
2025: }
2026:
2027: public void simpleAndPrint(String inContent) throws IOException {
2028: if (!isMetaMode()) {
2029: int spaceCount = this .indent[0];
2030: for (int i = 0; i < spaceCount; i++) {
2031: this .writer.write(" ");
2032: }
2033: this .writer.write(inContent);
2034: this .writer.write("\n");
2035: }
2036: }
2037:
2038: public void insertAndPrint(String inContent) throws IOException {
2039: if (!isMetaMode()) {
2040: justIndent();
2041: simpleAndPrint(inContent);
2042: justRevert();
2043: }
2044: }
2045:
2046: public void printAndIndent(String inContent) throws IOException {
2047: if (!isMetaMode()) {
2048: simpleAndPrint(inContent);
2049: justIndent();
2050: }
2051: }
2052:
2053: public void revertAndPrint(String inContent) throws IOException {
2054: if (!isMetaMode()) {
2055: justRevert();
2056: simpleAndPrint(inContent);
2057: }
2058: }
2059:
2060: public void unformattedPrint(String inContent) throws IOException {
2061: if (!isMetaMode()) {
2062: this .writer.write(inContent);
2063: }
2064: }
2065:
2066: public final static String singleQuotes(Object inValue,
2067: boolean inUse) {
2068:
2069: String outValue = null;
2070:
2071: if (inValue == null) {
2072: outValue = (null) + "";
2073: } else if (inUse) {
2074: outValue = ("'" + inValue + "'");
2075: } else {
2076: //if (inValue != null) {
2077: outValue = inValue.toString();
2078: //}
2079: //else {
2080: //}
2081: }
2082:
2083: return outValue;
2084: }
2085:
2086: public final static String singleQuotes(Object inValue) {
2087: return singleQuotes(inValue, true);
2088: }
2089:
2090: public void adjustHandle(String inHandle, boolean inDeleteNotAdd) {
2091: String currentTreeState = getTreeState();
2092: currentTreeState = adjustTreeForChange(currentTreeState,
2093: inHandle, inDeleteNotAdd, false);
2094: setTreeState(currentTreeState);
2095: }
2096:
2097: //
2098: protected final static String adjustTreeForChange(String inTree,
2099: String inHandle, boolean inDeleteNotAdd, boolean inNumber) {
2100:
2101: StringBuffer outValue = new StringBuffer();
2102:
2103: //calculate handle stem
2104: int handleStemEndIndex = inHandle
2105: .lastIndexOf(ConsoleTemplateSession.TOGGLE_LINK_SEPARATOR);
2106: String handleStem = inHandle.substring(0, handleStemEndIndex);
2107: String handleEnd = inHandle
2108: .substring(handleStemEndIndex
2109: + ConsoleTemplateSession.TOGGLE_LINK_SEPARATOR
2110: .length());
2111: //boolean handleEndIsNumber =
2112: // MiscHelper.isStringNonNegativeNumber(handleEnd);
2113: int handleEndValue = 0;
2114: if (inNumber) {
2115: handleEndValue = Integer.parseInt(handleEnd);
2116: }
2117:
2118: StringTokenizer branchSt = new StringTokenizer(inTree,
2119: BRANCH_SEPARATOR);
2120: while (branchSt.hasMoreTokens()) {
2121: String nextBranch = branchSt.nextToken();
2122: String nextModifiedBranch = null;
2123: //
2124: if (!nextBranch.startsWith(handleStem)) {
2125: nextModifiedBranch = nextBranch;
2126: } else if (nextBranch.startsWith(inHandle)
2127: && inDeleteNotAdd) {
2128: //don't add, sub-branch or branch of deleted branch
2129: } else if (nextBranch.equals(handleStem)) {
2130: nextModifiedBranch = nextBranch;
2131: } else if (nextBranch.startsWith(handleStem)) {
2132: String nextBranchEnd = nextBranch
2133: .substring(handleStemEndIndex
2134: + ConsoleTemplateSession.TOGGLE_LINK_SEPARATOR
2135: .length());
2136: //
2137: int firstConjunction = nextBranchEnd
2138: .indexOf(ConsoleTemplateSession.TOGGLE_LINK_SEPARATOR);
2139: //
2140: String nextBranchValue = null;
2141: String nextBranchEndEnd = null;
2142: if (firstConjunction != -1) {
2143: nextBranchValue = nextBranchEnd.substring(0,
2144: firstConjunction);
2145: nextBranchEndEnd = nextBranchEnd
2146: .substring(firstConjunction);
2147: } else {
2148: nextBranchValue = nextBranchEnd;
2149: nextBranchEndEnd = "";
2150: }
2151: //
2152: if (inNumber) {
2153: if (!MiscHelper
2154: .isStringNonNegativeNumber(nextBranchValue)) {
2155: //
2156: throw new UnexpectedSystemException("Branch '"
2157: + nextBranch
2158: + "' contains non-integer '"
2159: + nextBranchValue + "'");
2160: }
2161: int nextBranchValueNumber = Integer
2162: .parseInt(nextBranchValue);
2163: //
2164: if (nextBranchValueNumber < handleEndValue) {
2165: //no change
2166: } else if (nextBranchValueNumber >= handleEndValue
2167: && !inDeleteNotAdd) {
2168: //
2169: nextBranchValue = (nextBranchValueNumber + 1)
2170: + "";
2171: } else if (nextBranchValueNumber > handleEndValue
2172: && inDeleteNotAdd) {
2173: //
2174: nextBranchValue = (nextBranchValueNumber - 1)
2175: + "";
2176: } else {
2177: throw UnexpectedSystemException.unknownState();
2178: }
2179: } else {
2180: throw UnexpectedSystemException.unknownState();
2181: }
2182: //
2183: nextModifiedBranch = handleStem
2184: + ConsoleTemplateSession.TOGGLE_LINK_SEPARATOR
2185: + nextBranchValue + nextBranchEndEnd;
2186: } else {
2187: throw UnexpectedSystemException.unknownState();
2188: }
2189: //
2190: if (nextModifiedBranch != null) {
2191: outValue.append(BRANCH_SEPARATOR + nextModifiedBranch
2192: + BRANCH_SEPARATOR);
2193: }
2194: }
2195:
2196: return outValue.toString();
2197: }
2198:
2199: //
2200: //
2201: //
2202: //
2203: //
2204: //
2205: //
2206: //
2207: //
2208: //
2209: protected String submitActionCall(SubmitActionContext inSac) {
2210: //
2211: return submitActionCall(inSac, false);
2212: }
2213:
2214: protected String submitActionCall(SubmitActionContext inSac,
2215: boolean inAlwaysCall) {
2216: //
2217: String outValue = "";
2218:
2219: if (!isMetaMode() || inAlwaysCall) {
2220: outValue = inSac.submitActionCall();
2221: }
2222:
2223: return outValue;
2224: }
2225: }
|