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.context;
0009:
0010: //base classes
0011: import java.io.IOException;
0012: import java.util.ArrayList;
0013: import java.util.HashMap;
0014:
0015: //project specific classes
0016: import org.jfolder.common.UnexpectedSystemException;
0017: import org.jfolder.common.tagging.ConceptTag;
0018: import org.jfolder.common.tagging.ConceptTagCharacteristic;
0019: import org.jfolder.common.tagging.ConceptTagCharacteristicHolder;
0020: import org.jfolder.common.tagging.ConceptTagConstraint;
0021: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
0022: import org.jfolder.common.tagging.ConceptTagConstraintOrTemplate;
0023: import org.jfolder.common.tagging.ConceptTagHelper;
0024: import org.jfolder.common.tagging.ConceptTagMenuBranch;
0025: import org.jfolder.common.tagging.ConceptTagMessageHolder;
0026: import org.jfolder.common.tagging.ConceptTagPreferences;
0027: import org.jfolder.common.tagging.DynamicConceptTagConstraintContext;
0028: import org.jfolder.common.tagging.DynamicConceptTagValidator;
0029: import org.jfolder.common.tagging.RootConceptTagHolder;
0030: import org.jfolder.common.tagging.SelectionCriteriaForConceptTag;
0031: import org.jfolder.common.tagging.StaticConceptTagConstraintContext;
0032: import org.jfolder.common.tagging.StudioConceptTagInstanceInfoContext;
0033: import org.jfolder.common.tagging.StudioConceptTagTypeInfoContext;
0034: import org.jfolder.common.utils.misc.CommonSeparators;
0035: import org.jfolder.common.utils.misc.MiscHelper;
0036: import org.jfolder.common.web.template.ConsoleParameterContext;
0037: import org.jfolder.common.web.template.CreationParameterContext;
0038: import org.jfolder.common.web.template.MenuBranch;
0039: import org.jfolder.common.web.template.PageSetupContext;
0040: import org.jfolder.common.web.template.SubmitActionContext;
0041: import org.jfolder.common.web.template.SubmitActionParameters;
0042: import org.jfolder.console.base.ConsolePageContext;
0043: import org.jfolder.console.base.ConsolePageHelper;
0044: import org.jfolder.console.base.ConsolePageSession;
0045: import org.jfolder.console.base.NamesForSubCpc;
0046: import org.jfolder.console.base.StudioPageContext;
0047:
0048: //other classes
0049:
0050: public class BasePanelessRcthEditConsolePageContext extends
0051: BaseSubPaneContentConsolePageContext {
0052:
0053: //
0054: //private final static String BUTTON__DELETE = "BUTTON__DELETE";
0055: //private final static String BUTTON__SWAP_UP = "BUTTON__SWAP_UP";
0056: //private final static String BUTTON__SWAP_DOWN = "BUTTON__SWAP_DOWN";
0057: //private final static String BUTTON__USE_COMPOUND = "BUTTON__USE_COMPOUND";
0058: //private final static String BUTTON__USE_TEXT = "BUTTON__USE_TEXT";
0059: //
0060: private final static String TEXT_AREA__STATIC = "TEXT_AREA__STATIC";
0061: private final static String TEXT_BOX__STATIC = "TEXT_BOX__STATIC";
0062: private final static String TEXT_BOX__INPUT_OTHER = "TEXT_BOX__INPUT_OTHER";
0063: //private final static String TEXT_BOX__USE_TEXT = "TEXT_BOX__USE_TEXT";
0064: //
0065: private final static String DROP_DOWN_BOX__INPUT = "DROP_DOWN_BOX__INPUT";
0066: private final static String DROP_DOWN_BOX__LIMIT_SELECT = "DROP_DOWN_BOX__LIMIT_SELECT";
0067: //
0068: private final static String DROP_DOWN_BOX__CHANGE_LOCAL_RCTH_SELECT = "DROP_DOWN_BOX__CHANGE_LOCAL_RCTH_SELECT";
0069: private final static String DROP_DOWN_BOX__ADD_OR_REPLACE_RCTH_SELECT = "DROP_DOWN_BOX__ADD_OR_REPLACE_RCTH_SELECT";
0070: //private final static String DROP_DOWN_BOX__CREATE_SELECT =
0071: // "DROP_DOWN_BOX__CREATE_SELECT";
0072: //private final static String DROP_DOWN_BOX__UPDATE_SELECT =
0073: // "DROP_DOWN_BOX__UPDATE_SELECT";
0074: //
0075: private final static String MENU__CONCEPT_TAG = StudioPageContext.MENU__CONCEPT_TAG;
0076: //
0077: private final static String HIDDEN_FIELD__CTCHAR_EDIT = "HIDDEN_FIELD__CTCHAR_EDIT";
0078: //
0079: private final static String TOG_CAL__CTCONH = "TOG_CAL__CTCONH";
0080: private final static String TOG_CAL__CTCON = "TOG_CAL__CTCON";
0081: //
0082: private final static String CRE_PARAM_CALL__ADD = "CRE_PARAM_CALL__ADD";
0083: private final static String CRE_PARAM_CALL__REPLACE = "CRE_PARAM_CALL__REPLACE";
0084: //
0085: private final static String DROP_DOWN_BOX__NAVIGATION = "DROP_DOWN_BOX__NAVIGATION";
0086:
0087: //
0088: private String sectionId = null;
0089: //private String shiftHighlightHandleId = null;
0090: private int baseToggleLinkListLength = 0;
0091: private String shiftToHighlightHandle = null;
0092:
0093: protected BasePanelessRcthEditConsolePageContext(
0094: ConsolePageContext inCpc) {
0095: super (inCpc, NamesForSubCpc.getBasePanelessRcthEditCpcName());
0096: //
0097: setColumnWidth(200);
0098: }
0099:
0100: public final static BasePanelessRcthEditConsolePageContext newInstance(
0101: ConsolePageContext inCpc) throws IOException {
0102:
0103: BasePanelessRcthEditConsolePageContext outValue = null;
0104:
0105: if (inCpc.isSubConsolePageContextPresent(NamesForSubCpc
0106: .getBasePanelessRcthEditCpcName())) {
0107: //
0108: Object o = inCpc.getSubConsolePageContext(NamesForSubCpc
0109: .getBasePanelessRcthEditCpcName());
0110: outValue = (BasePanelessRcthEditConsolePageContext) o;
0111: } else {
0112: outValue = new BasePanelessRcthEditConsolePageContext(inCpc);
0113: inCpc.registerSubConsolePageContext(NamesForSubCpc
0114: .getBasePanelessRcthEditCpcName(), outValue);
0115: }
0116:
0117: outValue.copyFromParent(inCpc);
0118: outValue.createConsolePage(inCpc.getWriter(), inCpc
0119: .getPageSetupContext());
0120:
0121: return outValue;
0122: }
0123:
0124: public String getSectionId() {
0125: return this .sectionId;
0126: }
0127:
0128: public String getDownShiftToHighlightHandle() {
0129: return this .shiftToHighlightHandle;
0130: }
0131:
0132: protected void renderConsolePage() throws IOException {
0133:
0134: this .sectionId = getConsolePageSession().getToggleLink();
0135: //try {
0136: //
0137: ConsolePageSession localCps = getConsolePageSession();
0138: RootConceptTagHolder localRcth = localCps
0139: .getCurrentApplicationRootHolder();
0140: ConceptTagPreferences localCtp = localRcth.getPreferences();
0141: String currentHighlightHandle = getHighlightHandle();
0142: //StringBuffer ctHandle = new StringBuffer();
0143: //MiscHelper.println(
0144: // "BasPanTagConPagCn " + this + " = " + currentHighlightHandle);
0145: StringBuffer parentCtHandle = new StringBuffer();
0146:
0147: ConceptTagConstraintHolder ctconh = ConceptTagHelper
0148: .getNearestConceptTag(localRcth,
0149: currentHighlightHandle, parentCtHandle);
0150: //
0151: getConsolePageSession().pushToggleLinkTagBase();
0152: getConsolePageSession().registerCommonStem(
0153: getConsolePageSession().getToggleLink());
0154: //alignTreeStateToCommonStem(getConsolePageSession());
0155: this .baseToggleLinkListLength = getConsolePageSession()
0156: .getToggleLinkAsArrayList().size();
0157: //
0158: //
0159: //
0160: PageSetupContext localPsc = localCps.getPageSetupContext();
0161: if (localPsc.isHighlighHandleUpdated()) {
0162: String localHh = getHighlightHandle();
0163: //
0164: ArrayList currTl = localCps.getToggleLinkAsArrayList();
0165: //
0166: ArrayList hhParts = MiscHelper.parseHandle(localHh,
0167: localCtp.getHandleConjunction());
0168: //
0169: currTl.addAll(hhParts);
0170: currTl.add(ConsolePageSession.getAnchorPointPartName());
0171: //
0172: this .shiftToHighlightHandle = MiscHelper.reassembleHandle(
0173: currTl, CommonSeparators.TOGGLE_LINK_SEPARATOR);
0174: }
0175:
0176: ArrayList handleList = MiscHelper.parseHandle(parentCtHandle
0177: .toString(), localCtp.getHandleConjunction());
0178:
0179: //getConsolePageSession().pushToggleLink(ctp.getRootConstraint());
0180: //getConsolePageSession().pushToggleLink("0");
0181: for (int i = 0; i < handleList.size(); i++) {
0182: getConsolePageSession().pushToggleLink(
0183: handleList.get(i).toString());
0184: }
0185: //
0186: //
0187: //String currentTreeHandle =
0188: // ConsoleTemplateParameters.BRANCH_SEPARATOR
0189: // + getConsolePageSession().getToggleLink()
0190: // + ConsoleTemplateParameters.BRANCH_SEPARATOR;
0191: //String currentTreeState = getTreeState();
0192: //if (currentTreeState.indexOf(currentTreeHandle) == -1) {
0193: // currentTreeState = currentTreeState + currentTreeHandle;
0194: // setTreeState(currentTreeState);
0195: //}
0196: if (!isTreeComponentPresent(getConsolePageSession()
0197: .getToggleLink())) {
0198: //
0199: addTreeComponent(getConsolePageSession().getToggleLink());
0200: }
0201: //
0202: //
0203: addDefaultTreeBranch(getConsolePageSession().getToggleLink());
0204: //
0205: createConstraintHolderWithConceptTag(ctconh);
0206: //
0207: for (int i = 0; i < handleList.size(); i++) {
0208: getConsolePageSession().popToggleLink();
0209: }
0210: //getConsolePageSession().popToggleLink();
0211: //getConsolePageSession().popToggleLink();
0212: //
0213: //
0214: getConsolePageSession().popToggleLink();
0215: //}
0216: //catch (IOException ioe) {
0217: // ioe.printStackTrace();
0218: // throw ioe;
0219: //}
0220: //catch (RuntimeException re) {
0221: // re.printStackTrace();
0222: // throw re;
0223: //}
0224: //catch (Error e) {
0225: // e.printStackTrace();
0226: // throw e;
0227: //}
0228: }
0229:
0230: private void createConstraintHolderWithConceptTag(
0231: ConceptTagConstraintHolder inCtconh) throws IOException {
0232:
0233: startAutoTogglingTableAndRowAndCell();
0234:
0235: //
0236: //variable declarations
0237: ConceptTagCharacteristicHolder topCtcharh = inCtconh
0238: .getCharacteristicHolder();
0239: ConceptTag topCt = topCtcharh.getConceptTag();
0240:
0241: StudioConceptTagInstanceInfoContext sctiic = StudioConceptTagInstanceInfoContext
0242: .newInstance();
0243: topCt.appraise(sctiic);
0244:
0245: StudioConceptTagTypeInfoContext scttic = StudioConceptTagTypeInfoContext
0246: .newInstance();
0247: topCt.appraise(scttic);
0248:
0249: //navigation drop-down
0250: ArrayList navigationLabels = new ArrayList();
0251: ArrayList navigationValues = new ArrayList();
0252: //
0253: HashMap navigationAttrs = new HashMap();
0254: HashMap navigationStyles = new HashMap();
0255: //
0256: navigationLabels.add("(Navigation)");
0257: navigationValues.add("");
0258: //
0259: //
0260: //
0261: navigationStyles.put("width", getColumnWidth() + "");
0262: //
0263: //
0264: prepareNavigationDropDownOptions(inCtconh, navigationLabels,
0265: navigationValues);
0266: //
0267: String navigationDropDown = createDropDownBox(
0268: DROP_DOWN_BOX__NAVIGATION, navigationLabels,
0269: navigationValues, navigationAttrs, navigationStyles, 0,
0270: null, "eval(this.value)", null);
0271: //
0272: //
0273: //display tag name and description
0274:
0275: //
0276: startTable(4);
0277: startRow();
0278: startAndEndCell(4, createHorizontalRow(4, null));
0279: endRow();
0280: endTable();
0281:
0282: startTable(4);
0283: startRow();
0284: startAndEndCell(1, sctiic.getInstanceTitle());
0285: startAndEndCell(2, sctiic.getInstanceDescription());
0286: startAndEndCell(1, navigationDropDown);
0287: endRow();
0288: endTable();
0289:
0290: //
0291:
0292: createConstraintHolder(inCtconh);
0293:
0294: //
0295:
0296: startTable(4);
0297: startRow();
0298: startAndEndCell(4, createHorizontalRow(4, null));
0299: endRow();
0300: endTable();
0301:
0302: //
0303:
0304: endEnclosingTableAndRowAndCell();
0305: }
0306:
0307: private void prepareNavigationDropDownOptions(
0308: ConceptTagConstraintHolder inCtconh, ArrayList inLabels,
0309: ArrayList inValues) {
0310: //
0311: ConsolePageSession localCps = getConsolePageSession();
0312: //
0313: ConceptTagCharacteristicHolder localCtcharh = inCtconh
0314: .getCharacteristicHolder();
0315: //
0316: ConceptTagPreferences localCtp = localCps
0317: .getCurrentApplicationRootHolder().getPreferences();
0318: //
0319: ConceptTagCharacteristic localParentCtchar = localCtcharh
0320: .getParentCharacteristic();
0321: int localParentCtcharIndex = localCtcharh
0322: .getParentCharacteristicIndex();
0323: //
0324: ArrayList currentTl = localCps
0325: .getToggleLinkSubSectionAsList(this .baseToggleLinkListLength);
0326: //
0327: ArrayList rootTl = MiscHelper.parseHandle(localCtp
0328: .getRootHandle(), localCtp.getHandleConjunction());
0329: //
0330: //
0331: //add options, but only when not root constraint
0332: //
0333: if (currentTl.size() > rootTl.size()) {
0334: //
0335: //
0336: //
0337: //
0338: //
0339: if (localParentCtcharIndex > 0) {
0340: currentTl.remove(currentTl.size() - 1);
0341: currentTl.add((localParentCtcharIndex - 1) + "");
0342: //
0343: String nextHandle = MiscHelper.reassembleHandle(
0344: currentTl, localCtp.getHandleConjunction());
0345: //
0346: SubmitActionContext goToSac = SubmitActionContext
0347: .newInstance(this );
0348: //
0349: BasePanelessRcthTreeConsolePageContext
0350: .initializeGoToSac(goToSac, true, nextHandle);
0351: //
0352: inLabels.add("(Go To Previous Sibling)");
0353: inValues.add(submitActionCall(goToSac));
0354: }
0355: //
0356: //
0357: //
0358: //
0359: //
0360: int lastIndex = (localParentCtchar.getValueLength() - 1);
0361: if (localParentCtcharIndex < lastIndex) {
0362: currentTl.remove(currentTl.size() - 1);
0363: currentTl.add((localParentCtcharIndex + 1) + "");
0364: //
0365: String nextHandle = MiscHelper.reassembleHandle(
0366: currentTl, localCtp.getHandleConjunction());
0367: //
0368: SubmitActionContext goToSac = SubmitActionContext
0369: .newInstance(this );
0370: //
0371: BasePanelessRcthTreeConsolePageContext
0372: .initializeGoToSac(goToSac, true, nextHandle);
0373: //
0374: inLabels.add("(Go To Next Sibling)");
0375: inValues.add(submitActionCall(goToSac));
0376: }
0377: //
0378: //
0379: //
0380: //
0381: //
0382: currentTl.remove(currentTl.size() - 1);
0383: //
0384: String nextHandle = MiscHelper.reassembleHandle(currentTl,
0385: localCtp.getHandleConjunction());
0386: //
0387: SubmitActionContext goToSac = SubmitActionContext
0388: .newInstance(this );
0389: //
0390: BasePanelessRcthTreeConsolePageContext.initializeGoToSac(
0391: goToSac, true, nextHandle);
0392: //
0393: inLabels.add("(Go To Parent)");
0394: inValues.add(submitActionCall(goToSac));
0395: }
0396:
0397: }
0398:
0399: //private void createConstraintHolderWithoutConceptTag(
0400: // ConceptTagConstraintHolder inCtconh) throws IOException {
0401: //
0402: // startAutoTogglingTableAndRowAndCell();
0403: //
0404: // createConstraintHolder(inCtconh);
0405: //
0406: // endEnclosingTableAndRowAndCell();
0407: //}
0408:
0409: //GUI FUNCTIONS
0410: private void markAnchorPoint() throws IOException {
0411: //
0412: ConsolePageSession localCps = getConsolePageSession();
0413: //
0414: localCps.pushToggleLinkAnchorPoint();
0415: simpleAndPrint("<a id=\"" + localCps.getToggleLink() + "\"/>");
0416: localCps.popToggleLink();
0417: }
0418:
0419: private void createConstraintHolder(
0420: ConceptTagConstraintHolder inCtconh) throws IOException {
0421:
0422: //
0423: markAnchorPoint();
0424: //
0425: //boolean showConstraintHolder = true;
0426: //if (inCtconh.isParentSubErrorPresent()
0427: // || !inCtconh.isStudioVisibleOnlyOnError()) {
0428: //boolean showConstraintHolder =
0429: // !ConsolePageHelper.isConstraintHolderEmpty(inCtconh);
0430: //MiscHelper.println("BasPanlTagConPagCon creConh showConh always tru");
0431:
0432: if (!ConsolePageHelper.isConstraintHolderEmpty(inCtconh)) {
0433:
0434: ConceptTagCharacteristicHolder ctcharh = inCtconh
0435: .getCharacteristicHolder();
0436: ConceptTagMessageHolder ctcharhMh = ctcharh
0437: .getParentMessageHolder();
0438: boolean noCt = !ctcharh.isConceptTagPresent();
0439: //
0440: startTable(4);
0441: startRow();
0442: startAndEndCell(4, createHorizontalRow(4, null));
0443: endRow();
0444: endTable();
0445:
0446: //display tag type and description
0447: startTable(4);
0448: startRow();
0449: if (!noCt) {
0450: startAndEndCell(1, inCtconh.getTitle());
0451: } else {
0452: startAndEndCell(1, getAutoTogglingLinkWithTargetId(
0453: TOG_CAL__CTCONH, inCtconh.getTitle()),
0454: getFontStyle(14, ARIAL, getNodeColor(ctcharhMh
0455: .isErrorPresent(), ConceptTagHelper
0456: .isErrorInMainOrSubPresent(ctcharh))));
0457: }
0458: startAndEndCell(3, inCtconh.getShortDescription());
0459: endRow();
0460: endTable();
0461:
0462: //display errors
0463: //list errors here
0464: if (ctcharhMh.getHeaderMessageCount() > 0) {
0465: startTable(4);
0466: startRow();
0467: startCell(4);
0468: printAndIndent("<ul>");
0469: for (int i = 0; i < ctcharhMh.getHeaderMessageCount(); i++) {
0470: HashMap nextHm = getFontStyle(12, ARIAL,
0471: getNodeColor(ctcharhMh
0472: .isErrorHeaderMessage(i), ctcharhMh
0473: .isWarningHeaderMessage(i)));
0474:
0475: simpleAndPrint("<li>"
0476: + formatText(ctcharhMh.getHeaderMessage(i),
0477: nextHm) + "</li>");
0478: }
0479: revertAndPrint("</ul>");
0480: endCell();
0481: endRow();
0482: endTable();
0483: }
0484:
0485: //list errors here
0486: //displayConceptErrors(inCti.getErrorHolder());
0487: //MiscHelper.println("BaseStudioTagContext displayErrors not impl");
0488:
0489: //indent for attributes and styles
0490: int topLeftMargin = getLeftMargin();
0491: if (noCt) {
0492: setLeftMargin(topLeftMargin + 1);
0493: startAutoTogglingTableAndRowAndCell();
0494: }
0495:
0496: startTable(4);
0497: startRow();
0498: startAndEndCell(4, createHorizontalRow(4, null));
0499: endRow();
0500: endTable();
0501:
0502: //
0503: boolean noUndefCtcon = (inCtconh.getUndefinedConstraint() == null || (inCtconh
0504: .getUndefinedConstraint().getMaximumLength() == 0 && !inCtconh
0505: .getUndefinedConstraint().isLengthUnbounded()));
0506: boolean noAttrsCtconh = (inCtconh.getAttributes() == null);
0507: boolean noStyleCtconh = (inCtconh.getStyles() == null);
0508:
0509: //constraints
0510: for (int i = 0; i < inCtconh.getConstraintCount(); i++) {
0511: //
0512: ConceptTagConstraint nextCtcon = inCtconh
0513: .getConstraint(i);
0514: String nextCtconName = nextCtcon.getName();
0515: displayConstraintHolderSubMessages(ctcharhMh,
0516: nextCtconName);
0517: //
0518: getConsolePageSession().pushToggleLink(
0519: nextCtcon.getName());
0520: createConstraint(nextCtcon);
0521: getConsolePageSession().popToggleLink();
0522: //
0523: if (i < (inCtconh.getConstraintCount() - 1)) {
0524: createHorizontalRow(1);
0525: } else if (noUndefCtcon) {
0526: //do nothing
0527: } else {
0528: createHorizontalRow(1);
0529: }
0530: }
0531:
0532: //undefined
0533: if (!noUndefCtcon) {
0534: //
0535: String unconConName = inCtconh.getPreferences()
0536: .getUnconstrainedSymbol();
0537: displayConstraintHolderSubMessages(ctcharhMh,
0538: unconConName);
0539: //
0540: getConsolePageSession().pushToggleLink(unconConName);
0541: createConstraint(inCtconh.getUndefinedConstraint());
0542: getConsolePageSession().popToggleLink();
0543: //
0544: //if (noAttrsCtconh && noStyleCtconh) {
0545: // //do nothing
0546: //}
0547: //else {
0548: // createHorizontalRow(1);
0549: //}
0550: }
0551:
0552: //attributes
0553: if (!noAttrsCtconh) {
0554: //
0555: String attrsConName = inCtconh.getPreferences()
0556: .getAttributeConstraintName();
0557: displayConstraintHolderSubMessages(ctcharhMh,
0558: attrsConName);
0559: //
0560: getConsolePageSession().pushToggleLink(attrsConName);
0561: createConstraintHolder(inCtconh.getAttributes());
0562: getConsolePageSession().popToggleLink();
0563: //
0564: //if (noStyleCtconh) {
0565: // //do nothing
0566: //}
0567: //else {
0568: // createHorizontalRow(1);
0569: //}
0570: }
0571:
0572: //styles
0573: if (!noStyleCtconh) {
0574: //
0575: String styleConName = inCtconh.getPreferences()
0576: .getStyleConstraintName();
0577: displayConstraintHolderSubMessages(ctcharhMh,
0578: styleConName);
0579: //
0580: getConsolePageSession().pushToggleLink(styleConName);
0581: createConstraintHolder(inCtconh.getStyles());
0582: getConsolePageSession().popToggleLink();
0583: }
0584:
0585: //
0586: //revert for attributes and styles
0587: if (noCt) {
0588: endEnclosingTableAndRowAndCell();
0589: setLeftMargin(topLeftMargin);
0590: }
0591: }
0592: }
0593:
0594: private void displayConstraintHolderSubMessages(
0595: ConceptTagMessageHolder inCtmh, String inConName)
0596: throws IOException {
0597: //
0598: if (inCtmh.getTotalNameMessageCount(inConName) > 0) {
0599: startTable(4);
0600: startRow();
0601: startAndEndCell(1, padNbsp(1));
0602: startCell(3);
0603: printAndIndent("<ul>");
0604: int iCount = inCtmh.getTotalNameMessageCount(inConName);
0605: for (int i = 0; i < iCount; i++) {
0606: HashMap nextHm = getFontStyle(12, ARIAL, getNodeColor(
0607: inCtmh.isErrorNameMessage(inConName, i), inCtmh
0608: .isWarningNameMessage(inConName, i)));
0609:
0610: simpleAndPrint("<li>"
0611: + formatText(inCtmh
0612: .getNameMessage(inConName, i), nextHm)
0613: + "</li>");
0614: }
0615: revertAndPrint("</ul>");
0616: endCell();
0617: endRow();
0618: endTable();
0619: }
0620: }
0621:
0622: private void createConstraint(ConceptTagConstraint inCtcon)
0623: throws IOException {
0624:
0625: //
0626: markAnchorPoint();
0627: //boolean showConstraint =
0628: // !ConsolePageHelper.isConstraintEmpty(inCtcon);
0629: //MiscHelper.println("BasPanlTagConPagCon creCon showCon always true");
0630: //if (inCtcon.isParentSubErrorPresent()
0631: // || !inCtcon.isStudioVisibleOnlyOnError()) {
0632:
0633: if (!ConsolePageHelper.isConstraintEmpty(inCtcon)) {
0634:
0635: //HashMap tableProps = new HashMap();
0636: //
0637: //MiscHelper.println("createConcept name = " + inCtcon.getName());
0638: ConsolePageSession localCps = getConsolePageSession();
0639: //RootConceptTagHolder rcth =
0640: // localCps.getCurrentApplicationRootHolder();
0641: //ConceptTagPreferences ctp = rcth.getPreferences();
0642: //String handleConj = ctp.getHandleConjunction();
0643:
0644: //ConceptTagInitializer nextSti = getConceptTagInitializer();
0645: ConceptTagCharacteristic ctchar = inCtcon
0646: .getCharacteristic();
0647: ConceptTagMessageHolder ctcharMh = ctchar
0648: .getParentMessageHolder();
0649: //int leftMargin = inSstc.getLeftMargin();
0650:
0651: //int minLength = inCtcon.getMinimumLength();
0652: int maxLength = inCtcon.getMaximumLength();
0653: boolean noMaxLength = inCtcon.isLengthUnbounded();
0654:
0655: boolean canBeStatic = inCtcon.isStaticContextPresent();
0656: StaticConceptTagConstraintContext stcot = null;
0657: if (canBeStatic) {
0658: stcot = inCtcon.getStaticConstraintContext();
0659: }
0660: boolean canAdd = (noMaxLength || (ctchar.getValueLength() < maxLength));
0661:
0662: //String currentShsc =
0663: // inCtchHandle + handleConj + inCtcon.getName();
0664:
0665: //TO DO: consider putting this in a table
0666: //simpleAndPrint("<a name=\"" + localCps.getToggleLink() + "\"/>");
0667:
0668: startTable(4);
0669: startRow();
0670: startAndEndCell(
0671: 1,
0672: getAutoTogglingLinkWithTargetId(TOG_CAL__CTCON,
0673: inCtcon.getTitle()),
0674: getFontStyle(14, ARIAL, getNodeColor(ctchar
0675: .getParentMessageHolder().isErrorPresent(),
0676: ConceptTagHelper
0677: .isErrorInMainOrSubPresent(ctchar))));
0678: startAndEndCell(3, inCtcon.getShortDescription());
0679: endRow();
0680: endTable();
0681:
0682: //list errors here
0683:
0684: //displayConceptErrors(nextCtchar.getMainErrorHolder());
0685: MiscHelper
0686: .println("BaseStudioTagContext displayErrors not impl");
0687:
0688: //MiscHelper.println("createConcept count = "
0689: // + nextCtchar.getValueLength());
0690: //String parentToggleLink = localCps.getToggleLink();
0691: startAutoTogglingTableAndRowAndCell();
0692:
0693: //list errors here
0694: if (ctcharMh.getHeaderMessageCount() > 0) {
0695: startTable(4);
0696: startRow();
0697: startCell(4);
0698: printAndIndent("<ul>");
0699: for (int i = 0; i < ctcharMh.getHeaderMessageCount(); i++) {
0700: HashMap nextHm = getFontStyle(12, ARIAL,
0701: getNodeColor(ctcharMh
0702: .isErrorHeaderMessage(i), ctcharMh
0703: .isWarningHeaderMessage(i)));
0704:
0705: simpleAndPrint("<li>"
0706: + formatText(ctcharMh.getHeaderMessage(i),
0707: nextHm) + "</li>");
0708: }
0709: revertAndPrint("</ul>");
0710: endCell();
0711: endRow();
0712: endTable();
0713: }
0714:
0715: String parentHandle = localCps
0716: .getToggleLinkSubSectionAsHandle(this .baseToggleLinkListLength);
0717: for (int j = 0; j < ctchar.getValueLength(); j++) {
0718:
0719: localCps.pushToggleLink(j + "");
0720: //String nextShsc = currentShsc + (handleConj + j);
0721:
0722: //TO DO: consider putting this in a table
0723: //simpleAndPrint(
0724: // "<a name=\"" + localCps.getToggleLink() + "\"/>");
0725:
0726: //horizontal line
0727: startTable(4);
0728: startRow();
0729: startAndEndCell(1, padNbsp(1));
0730: startAndEndCell(3, createHorizontalRow(3, null));
0731: endRow();
0732: endTable();
0733:
0734: //display error messages
0735: if (ctcharMh.getTotalIndexMessageCount(j) > 0) {
0736: startTable(4);
0737: startRow();
0738: startAndEndCell(1, padNbsp(1));
0739: startCell(3);
0740: printAndIndent("<ul>");
0741: int iCount = ctcharMh.getTotalIndexMessageCount(j);
0742: for (int i = 0; i < iCount; i++) {
0743: HashMap nextHm = getFontStyle(12, ARIAL,
0744: getNodeColor(ctcharMh
0745: .isErrorIndexMessage(j, i),
0746: ctcharMh.isWarningIndexMessage(
0747: j, i)));
0748:
0749: simpleAndPrint("<li>"
0750: + formatText(ctcharMh.getIndexMessage(
0751: j, i), nextHm) + "</li>");
0752: }
0753: revertAndPrint("</ul>");
0754: endCell();
0755: endRow();
0756: endTable();
0757: }
0758:
0759: //display
0760: startTable(3);
0761: startRow();
0762: String nextIndexLabel = (j + 1) + ")" + padNbsp(1);
0763: startAndEndCell(1, nextIndexLabel, alignRight(null));
0764:
0765: startCell(1);
0766: //begin characteritic element output
0767: if (ctchar.isStatic(j, null)) {
0768: boolean useTextArea = false;
0769: int entryLength = 0;
0770: boolean entrySetExclusive = false;
0771: if (canBeStatic) {
0772: useTextArea = stcot.isMultiLine();
0773: entryLength = stcot.getEntrySetLength();
0774: entrySetExclusive = stcot.isEntrySetExclusive();
0775: }
0776: String nextValue = ctchar.getValueAsString(j, null);
0777: if (entryLength > 0 && entrySetExclusive) {
0778: boolean nextValueUsed = false;
0779:
0780: //
0781: ArrayList entrySelectLabels = new ArrayList();
0782: ArrayList entrySelectValues = new ArrayList();
0783: int entrySelectIndex = 0;
0784: //
0785: for (int i = 0; i < entryLength; i++) {
0786: String entryValue = stcot.getEntryValue(i);
0787: String entryDesc = stcot
0788: .getEntryDescription(i);
0789: if (entryValue.equals(nextValue)) {
0790: entrySelectIndex = i;
0791: nextValueUsed = true;
0792: }
0793: entrySelectLabels.add(entryDesc);
0794: entrySelectValues.add(entryValue);
0795: }
0796: if (!nextValueUsed) {
0797: entrySelectIndex = entryLength;
0798: entrySelectLabels.add(nextValue);
0799: entrySelectValues.add(nextValue);
0800: }
0801: //
0802: //
0803: localCps.pushToggleLinkStudioEditInput();
0804: //localCps.pushToggleLinkDropDownBox();
0805: //
0806: String entrySelect = createDropDownBox(
0807: DROP_DOWN_BOX__LIMIT_SELECT,
0808: entrySelectLabels, entrySelectValues,
0809: null, null, entrySelectIndex, null,
0810: null, null);
0811: //localCps.popToggleLink();
0812: localCps.popToggleLink();
0813: //
0814: simpleAndPrint(entrySelect);
0815: //
0816: //
0817: } else if (entryLength > 0 && !entrySetExclusive) {
0818: //
0819: //
0820: //
0821: ArrayList entrySelectLabels = new ArrayList();
0822: ArrayList entrySelectValues = new ArrayList();
0823: //
0824: int entrySelectIndex = 0;
0825: boolean entrySelectIndexFound = false;
0826: //
0827: //
0828: //
0829: for (int i = 0; i < entryLength; i++) {
0830: String entryValue = stcot.getEntryValue(i);
0831: String entryDesc = stcot
0832: .getEntryDescription(i);
0833: if (entryValue.equals(nextValue)) {
0834: entrySelectIndex = i;
0835: entrySelectIndexFound = true;
0836: }
0837: //
0838: entrySelectLabels.add(entryDesc);
0839: entrySelectValues.add(DIRECT_TEXT_PREFIX
0840: + entryValue);
0841: }
0842:
0843: //String showChecked = "";
0844: if (!entrySelectIndexFound) {
0845: entrySelectIndex = entryLength;
0846: //showChecked = " CHECKED=\"true\"";
0847: }
0848: //
0849: //
0850: //localCps.pushToggleLinkStudioEditInputOption();
0851: //localCps.pushToggleLinkRadioButton();
0852: //String radioId = localCps.getToggleLink();
0853: //localCps.popToggleLink();
0854: //localCps.popToggleLink();
0855: //
0856: //
0857: //localCps.pushToggleLinkTextBox();
0858: //String textId = localCps.getToggleLink();
0859: //localCps.popToggleLink();
0860: //
0861: //
0862:
0863: //String onClick =
0864: // "this.value = getPageComponent('"
0865: // + textId + "').value";
0866: //String onChange =
0867: // "getPageComponent('"
0868: // + radioId + "').value = this.value";
0869: //
0870: entrySelectLabels.add("(Specify Value Below)");
0871: entrySelectValues.add(OTHER_TEXT_PREFIX);
0872: //
0873: //
0874: //
0875: //
0876: localCps.pushToggleLinkStudioEditInput();
0877: String onChangeStatic = null;
0878: if (stcot.isEntrySetRefreshOnChange()) {
0879: SubmitActionContext refreshSac = createRefreshSac();
0880: onChangeStatic = submitActionCall(refreshSac);
0881: }
0882:
0883: String entrySelect = createDropDownBox(
0884: DROP_DOWN_BOX__INPUT,
0885: entrySelectLabels, entrySelectValues,
0886: null, null, entrySelectIndex, null,
0887: onChangeStatic, null);
0888: localCps.popToggleLink();
0889: simpleAndPrint(entrySelect);
0890: //
0891: //
0892: //
0893: //
0894: localCps.pushToggleLinkStudioEditInputOther();
0895: String entrySelectOther = createTextBox(
0896: TEXT_BOX__INPUT_OTHER, nextValue, null,
0897: null, null, null, null);
0898: localCps.popToggleLink();
0899: simpleAndPrint(entrySelectOther);
0900: } else if (useTextArea) {
0901: localCps.pushToggleLinkStudioEditInput();
0902: //localCps.pushToggleLinkTextArea();
0903: //
0904: simpleAndPrint(createTextArea(
0905: TEXT_AREA__STATIC, nextValue, null,
0906: null, null, new Integer(15), null));
0907: //
0908: //localCps.popToggleLink();
0909: localCps.popToggleLink();
0910: } else {
0911: localCps.pushToggleLinkStudioEditInput();
0912: //localCps.pushToggleLinkTextBox();
0913: //
0914: simpleAndPrint(createTextBox(TEXT_BOX__STATIC,
0915: nextValue, null, null, null, null, null));
0916: //
0917: //localCps.popToggleLink();
0918: localCps.popToggleLink();
0919: }
0920: } else if (ctchar.isHolderWithConceptTag(j, null)) {
0921: //activeDynamic = true;
0922: ConceptTagCharacteristicHolder subCtcharh = ctchar
0923: .getValueAsHolder(j, null);
0924: ConceptTagMessageHolder subCtmh = subCtcharh
0925: .getParentMessageHolder();
0926:
0927: StudioConceptTagInstanceInfoContext nextStiic = ctchar
0928: .getInstanceInformation(j);
0929:
0930: String nextValue = nextStiic.getInstanceTitle();
0931:
0932: boolean eosep = ConceptTagHelper
0933: .isErrorInMainOrSubPresent(subCtcharh);
0934:
0935: boolean ep = subCtmh.isErrorPresent();
0936:
0937: //if (true) {
0938: printAndIndent("<a onclick=\"getPageComponent('"
0939: + localCps.getToggleLink()
0940: + "').style.display = 'block'\""
0941: + " style=\"font-family: 'Arial';"
0942: + " text-decoration: none; color: #"
0943: + getNodeColor(ep, eosep)
0944: //+ getNodeColor(
0945: // inCtcon.isErrorPresent(j),
0946: // inCtcon.isSubErrorPresent(j))
0947: + "; font-size: 10pt\">");
0948: //}
0949: //else {
0950: // printAndIndent(
0951: // "<a href=\"javascript:updateTargetAndSubmit('"
0952: // + localCps.getToggleLink()
0953: // + "')\" style=\"font-family: 'Arial';"
0954: // + " text-decoration: none; color: #"
0955: // + getNodeColor(false, false)
0956: // //+ getNodeColor(
0957: // // inCtcon.isErrorPresent(j),
0958: // // inCtcon.isSubErrorPresent(j))
0959: // + "; font-size: 10pt\">");
0960: //}
0961: //put sub node flag setting here
0962: simpleAndPrint(nextValue);
0963: revertAndPrint("</a>");
0964: } else if (ctchar.isHolderWithoutConceptTag(j, null)) {
0965: //activeCompound = true;
0966: //SimpleConceptTagConstraintHolder nextCh =
0967: // nextCtchar.getValueAsConstraintHolder(j);
0968: simpleAndPrint(createHorizontalRow(1, null));
0969: } else {
0970: //TO DO: what about other components here and elsewhere
0971: }
0972: endCell();
0973:
0974: //common update area
0975: startCell(1, alignCenter(null));
0976:
0977: //
0978: //
0979: //
0980: renderDirectUpdateDropDownBox(inCtcon, j, parentHandle);
0981: //
0982: //
0983: //
0984:
0985: endCell();
0986: endRow();
0987: endTable();
0988: //end common update area
0989:
0990: //new area
0991: //if (ctchar.isHolderWithConceptTag(j)) {
0992: //
0993: // //TO DO: adjust left margin, and highlight code
0994: // //ConceptTagInitializer topSti =
0995: // // getConceptTagInitializer();
0996: // //setConceptTagInitializer(
0997: // // nextStchar.getConceptTagInitializer(j));
0998: // int topLeftMargin = getLeftMargin();
0999: // setLeftMargin(topLeftMargin + 1);
1000: // //String topStiCode = getConceptTagInitializerCode();
1001: // //setConceptTagInitializerCode(nextShsc);
1002: // //createConceptTagEdit(
1003: // // nextStchar.getConceptTagInitializer(j), nextShsc);
1004: // //setConceptTagInitializerCode(topStiCode);
1005: // setLeftMargin(topLeftMargin);
1006: // //setConceptTagInitializer(topSti);
1007: // //TO DO: revert left margin, and highlight code
1008: //}
1009: //new area
1010:
1011: //list errors here
1012: //displayConceptErrors(nextCtchar.getErrorHolder(j));
1013: MiscHelper
1014: .println("BaseStudioTagContext displayErrors not impl");
1015:
1016: //compound add here
1017: if (ctchar.isHolderWithoutConceptTag(j, null)) {
1018: ConceptTagConstraintHolder nextCtconh = inCtcon
1019: .getConstraintHolder(j);
1020: //
1021: int topLeftMargin = getLeftMargin();
1022: setLeftMargin(topLeftMargin + 1);
1023: createConstraintHolder(nextCtconh);
1024: setLeftMargin(topLeftMargin);
1025: //int kcount = nextCh.getConstraintCount();
1026: //for (int k = 0; k < kcount; k++) {
1027: //
1028: // ConceptTagConstraint nextCon =
1029: // nextCh.getConstraint(k);
1030: //
1031: // //TO DO: adjust left margin, and highlight code
1032: // int topLeftMargin = getLeftMargin();
1033: // setLeftMargin(topLeftMargin + 1);
1034: // createConstraint(nextCon);
1035: // setLeftMargin(topLeftMargin);
1036: // //TO DO: revert left margin, and highlight code
1037: //}
1038: }
1039:
1040: //
1041: //
1042: //
1043: //
1044: //
1045: //localCps.pushToggleLinkDontRecordThisBranch();
1046: //String editSectionId = localCps.getToggleLink();
1047: //localCps.popToggleLink();
1048: //
1049: //
1050: //localCps.pushToggleLinkDropDownBox();
1051: //ArrayList editSectionDropDownLabels = new ArrayList();
1052: //editSectionDropDownLabels.add("(Select To Edit)");
1053: //editSectionDropDownLabels.add(" - Insert Before This");
1054: //editSectionDropDownLabels.add(" - Replace This");
1055: ////
1056: //ArrayList editSectionDropDownValues = new ArrayList();
1057: //editSectionDropDownValues.add("");
1058: //editSectionDropDownValues.add(SubmitActionParameters.ADD);
1059: //editSectionDropDownValues.add(SubmitActionParameters.REPLACE);
1060: ////
1061: //String editSectionDropDown = createDropDownBox(
1062: // DROP_DOWN_BOX__EDIT_SELECT,
1063: // editSectionDropDownLabels, editSectionDropDownValues,
1064: // null, null, 0, null, "openSectionOnNonEmptyValue(this, '"
1065: // + editSectionId + "')", null);
1066: ////
1067: //String editSectionDropDownId =
1068: // localCps.getPreviousToggleLink();
1069: //localCps.popToggleLink();
1070: //
1071: createHorizontalRow(2);
1072: //
1073: startTable(3);
1074: startRow();
1075: startAndEndCell(1, padNbsp(1));
1076: startCell(2, alignCenter(null));
1077: //
1078: //simpleAndPrint(editSectionDropDown);
1079: renderCreateExistingWindowScrollBar(inCtcon, j,
1080: parentHandle, "- Insert Before",
1081: ("Insert Before " + (j + 1)));
1082: //
1083: endCell();
1084: endRow();
1085: endTable();
1086: //
1087: //
1088: //
1089: //
1090: //
1091: //localCps.pushToggleLinkDontRecordThisBranch();
1092: //startEnclosingTableAndRowAndCell(localCps.getToggleLink());
1093: //renderEditRow(
1094: // "Update " + (j + 1) + ")" + padNbsp(1),
1095: // "getPageComponent('"
1096: // + editSectionDropDownId + "').value",
1097: // inCtcon, ctchar, j, parentHandle);
1098: //endEnclosingTableAndRowAndCell();
1099: //localCps.popToggleLink();
1100: //
1101: //
1102: //
1103: //
1104: //
1105: localCps.popToggleLink();
1106: }
1107:
1108: if (canAdd) {
1109: //
1110: localCps.pushToggleLink(ctchar.getValueLength() + "");
1111: //
1112: //
1113: localCps.pushToggleLinkDontRecordThisBranch();
1114: //
1115: createHorizontalRow(1);
1116: //
1117: startTable(3);
1118: startRow();
1119: startAndEndCell(1, "New)" + padNbsp(1),
1120: alignRight(null));
1121: startCell(2, alignCenter(null));
1122: //
1123: //simpleAndPrint(editSectionDropDown);
1124: renderCreateExistingWindowScrollBar(inCtcon, ctchar
1125: .getValueLength(), parentHandle,
1126: "- Add New Item", "New Item");
1127: //
1128: endCell();
1129: endRow();
1130: endTable();
1131: //
1132: //
1133: //renderEditRow(
1134: // "New)" + padNbsp(1),
1135: // singleQuotes(SubmitActionParameters.ADD), inCtcon,
1136: // ctchar, ctchar.getValueLength(), parentHandle);
1137: localCps.popToggleLink();
1138: //
1139: //
1140: localCps.popToggleLink();
1141: }
1142: endEnclosingTableAndRowAndCell();
1143: }
1144: }
1145:
1146: private void renderDirectUpdateDropDownBox(
1147: ConceptTagConstraint inCtcon, int inIndex,
1148: String inParentHandle) throws IOException {
1149: //
1150: //
1151: //
1152: ConceptTagCharacteristic ctchar = inCtcon.getCharacteristic();
1153: //ConsolePageSession localCps = getConsolePageSession();
1154: //
1155: //
1156: int minLength = inCtcon.getMinimumLength();
1157: //int maxLength = inCtcon.getMaximumLength();
1158: //boolean noMaxLength = inCtcon.isLengthUnbounded();
1159: //
1160: ArrayList updateSectionDropDownLabels = new ArrayList();
1161: ArrayList updateSectionDropDownValues = new ArrayList();
1162: //
1163: updateSectionDropDownLabels.add("(Edit This Item)");
1164: updateSectionDropDownValues.add("");
1165: //
1166: //
1167: //
1168: //
1169: if (ctchar.isStatic(inIndex, null)
1170: || ctchar.isHolderWithConceptTag(inIndex, null)) {
1171: //
1172: SubmitActionContext copySac = SubmitActionContext
1173: .newInstance(this );
1174: copySac.addAction(ConsoleParameterContext.FIRST_INPUT,
1175: singleQuotes(SubmitActionParameters.COPY));
1176: //
1177: copySac.addParameter(ConsoleParameterContext.FIRST_INPUT,
1178: singleQuotes(inParentHandle));
1179: copySac.addParameter(ConsoleParameterContext.SECOND_INPUT,
1180: inIndex + "");
1181: //
1182: updateSectionDropDownLabels.add("- Copy This Item");
1183: updateSectionDropDownValues.add(submitActionCall(copySac));
1184: }
1185: //
1186: //
1187: //
1188: //updateSectionDropDownValues.add("alert('Dont You Touch Me')");
1189: //updateSectionDropDownValues.add("alert('Hands Off Brother')");
1190: //
1191: if (ctchar.getValueLength() > minLength) {
1192: //printAndIndent("<tr>");
1193: //printAndIndent("<td align=\"center\">");
1194: //buttonSep = checkButtonSeparation(buttonSep);
1195: SubmitActionContext sacDelete = SubmitActionContext
1196: .newInstance(this );
1197: //
1198: sacDelete.addAction(ConsoleParameterContext.FIRST_INPUT,
1199: singleQuotes(SubmitActionParameters.DELETE));
1200: //
1201: sacDelete.addParameter(ConsoleParameterContext.FIRST_INPUT,
1202: singleQuotes(inParentHandle));
1203: sacDelete.addParameter(
1204: ConsoleParameterContext.SECOND_INPUT,
1205: singleQuotes(inIndex + ""));
1206: //
1207: updateSectionDropDownLabels.add("- Delete This Item");
1208: updateSectionDropDownValues
1209: .add(submitActionCall(sacDelete));
1210: //createButton(BUTTON__DELETE, "Delete", 150,
1211: // sacDelete.submitActionCall(), null, null, null, null);
1212: //
1213: //revertAndPrint("</td>");
1214: //revertAndPrint("</tr>");
1215: }
1216: //
1217: //
1218: //
1219: HashMap updateSectionDropDownStyles = new HashMap();
1220: updateSectionDropDownStyles.put("width",
1221: ((1 * getColumnWidth()) - 2) + "");
1222: //
1223:
1224: String updateSectionDropDown = createDropDownBox(
1225: DROP_DOWN_BOX__CHANGE_LOCAL_RCTH_SELECT,
1226: updateSectionDropDownLabels,
1227: updateSectionDropDownValues, null,
1228: updateSectionDropDownStyles, 0, null,
1229: "eval(this.value); this.selectedIndex = 0;", null);
1230: //
1231: simpleAndPrint(updateSectionDropDown);
1232: }
1233:
1234: private void renderCreateExistingWindowScrollBar(
1235: ConceptTagConstraint inCtcon, int inIndex,
1236: String inParentHandle, String inInsertScrollLabel,
1237: String inInsertBoxLabel) throws IOException {
1238: //
1239: //
1240: //
1241: //
1242: //
1243: //editSectionDropDownValues.add(SubmitActionParameters.ADD);
1244: //editSectionDropDownValues.add(SubmitActionParameters.REPLACE);
1245: //
1246: ConceptTagCharacteristic ctchar = inCtcon.getCharacteristic();
1247: ConsolePageSession localCps = getConsolePageSession();
1248: PageSetupContext localPsc = localCps.getPageSetupContext();
1249: RootConceptTagHolder localRcth = localCps
1250: .getCurrentApplicationRootHolder();
1251: ConceptTagPreferences localCtp = localRcth.getPreferences();
1252: //
1253: //
1254: //int minLength = inCtcon.getMinimumLength();
1255: int maxLength = inCtcon.getMaximumLength();
1256: boolean noMaxLength = inCtcon.isLengthUnbounded();
1257: boolean existingElement = (inIndex < ctchar.getValueLength());
1258: //
1259:
1260: //
1261: String nextHiddenBox = createHiddenField(
1262: HIDDEN_FIELD__CTCHAR_EDIT, "", null);
1263: String nextHiddenBoxId = localCps.getPreviousToggleLink();
1264: String nextHiddenBoxValue = getPageComponentValue(nextHiddenBoxId);
1265: //
1266: simpleAndPrint(nextHiddenBox);
1267:
1268: //
1269: //
1270: //
1271: ArrayList editSectionDropDownLabels = new ArrayList();
1272: ArrayList editSectionDropDownValues = new ArrayList();
1273: //editSectionDropDownLabels.add(" - Insert Before This");
1274: //editSectionDropDownLabels.add(" - Replace This");
1275: //
1276: editSectionDropDownLabels.add("(Select To Edit)");
1277: editSectionDropDownValues.add("");
1278: //editSectionDropDownValues.add("alert('Dont You Touch Me')");
1279: //editSectionDropDownValues.add("alert('Hands Off Brother')");
1280: //
1281: //
1282: //
1283: SubmitActionContext pasteInsertSac = SubmitActionContext
1284: .newInstance(this );
1285: //
1286: pasteInsertSac.addAction(ConsoleParameterContext.FIRST_INPUT,
1287: singleQuotes(SubmitActionParameters.PASTE));
1288: pasteInsertSac.addAction(ConsoleParameterContext.SECOND_INPUT,
1289: singleQuotes(SubmitActionParameters.ADD));
1290: //
1291: pasteInsertSac.addParameter(
1292: ConsoleParameterContext.FIRST_INPUT,
1293: singleQuotes(inParentHandle));
1294: pasteInsertSac.addParameter(
1295: ConsoleParameterContext.SECOND_INPUT, inIndex + "");
1296: //
1297: //
1298: SubmitActionContext pasteReplaceSac = SubmitActionContext
1299: .newInstance(this );
1300: pasteReplaceSac.addAction(ConsoleParameterContext.FIRST_INPUT,
1301: singleQuotes(SubmitActionParameters.PASTE));
1302: pasteReplaceSac.addAction(ConsoleParameterContext.SECOND_INPUT,
1303: singleQuotes(SubmitActionParameters.REPLACE));
1304: //
1305: pasteReplaceSac.addParameter(
1306: ConsoleParameterContext.FIRST_INPUT,
1307: singleQuotes(inParentHandle));
1308: pasteReplaceSac.addParameter(
1309: ConsoleParameterContext.SECOND_INPUT, inIndex + "");
1310: //
1311: //
1312: if (inCtcon.isStaticContextPresent()
1313: && localCps.isCopyHolderAsStatic()) {
1314: //
1315: editSectionDropDownLabels.add("- Paste Insert");
1316: editSectionDropDownValues
1317: .add(submitActionCall(pasteInsertSac));
1318: //
1319: if (existingElement) {
1320: editSectionDropDownLabels.add("- Paste Overwrite");
1321: editSectionDropDownValues
1322: .add(submitActionCall(pasteReplaceSac));
1323: }
1324: }
1325: //
1326: //
1327: if (inCtcon.isDynamicContextPresent()
1328: && localCps.isCopyHolderAsConceptTag()) {
1329: //
1330: DynamicConceptTagConstraintContext dctcc = inCtcon
1331: .getDynamicConstraintContext();
1332: DynamicConceptTagValidator dctv = dctcc.getValidator();
1333: ConceptTag localCt = localCps
1334: .getCopyHolderValueAsConceptTag();
1335: SelectionCriteriaForConceptTag localScfct = SelectionCriteriaForConceptTag
1336: .newInstance(localCt);
1337: localCt.appraise(localScfct);
1338: //
1339: //
1340: ArrayList results = dctv.validate(localScfct, localCt
1341: .getClass(), true);
1342: if (results.size() == 0) {
1343: //
1344: //
1345: editSectionDropDownLabels.add("- Paste Insert");
1346: editSectionDropDownValues
1347: .add(submitActionCall(pasteInsertSac));
1348: //
1349: if (existingElement) {
1350: editSectionDropDownLabels.add("- Paste Overwrite");
1351: editSectionDropDownValues
1352: .add(submitActionCall(pasteReplaceSac));
1353: }
1354: }
1355: }
1356: //
1357: //
1358: //
1359: //
1360: //
1361: //
1362: //
1363: //
1364: HashMap editSectionDropDownStyles = new HashMap();
1365: editSectionDropDownStyles.put("width",
1366: ((2 * getColumnWidth()) - 2) + "");
1367: //
1368: //
1369: //
1370: //
1371: //
1372: String destinationMenuId = null;
1373: //
1374: if (inCtcon.isDynamicContextPresent()) {
1375: //
1376: DynamicConceptTagConstraintContext dtcot = inCtcon
1377: .getDynamicConstraintContext();
1378: //ctp.getConceptTagMenuBase();
1379: ConceptTagMenuBranch ctmb = ConceptTagMenuBranch
1380: .qualifyNodes(localCtp.getMenuBase(), localCtp
1381: .getSetHolder(), dtcot.getValidator());
1382: //MiscHelper.println("2 = "
1383: // + (new java.util.Date()).toString());
1384: ///at this point, remove unconstrained and
1385: MenuBranch mb = ConsolePageHelper.constructMenu(inCtcon,
1386: ctmb, localCtp.getSetHolder(), inParentHandle,
1387: inIndex, nextHiddenBoxValue,
1388: SubmitActionParameters.CONCEPT_TAG, this );
1389: //MiscHelper.println("3 = "
1390: // + (new java.util.Date()).toString());
1391: //getConsolePageSession().pushToggleLink("0_MENU");
1392: //
1393: destinationMenuId = getMenu(getConsolePageSession(),
1394: MENU__CONCEPT_TAG, mb, null, null, null, null,
1395: new Integer(10), ctmb);
1396: }
1397: //
1398: //
1399: //
1400: //
1401: //
1402: //
1403: CreationParameterContext createAroundExistingCpc = createCreateExistingWindowScrollBarCpc(
1404: inCtcon, inIndex, inParentHandle, nextHiddenBoxValue,
1405: inInsertBoxLabel, destinationMenuId);
1406: localPsc.registerCreationParameter(localCps,
1407: createAroundExistingCpc, CRE_PARAM_CALL__ADD);
1408: //
1409: //
1410: //SubmitActionContext createSac =
1411: // SubmitActionContext.newInstance(this);
1412: //createSac.addAction(
1413: // createSac.FIRST_INPUT,
1414: // singleQuotes(SubmitActionParameters.DO_NOTHING));
1415: //
1416: //CreationParameterContext insertBeforeCpc =
1417: // CreationParameterContext.newInstance(
1418: // "Insert Before " + (inIndex + 1), createSac, false);
1419: //
1420: if (ctchar.getValueLength() < (maxLength) || noMaxLength) {
1421: //
1422: //
1423: //
1424: editSectionDropDownLabels.add(inInsertScrollLabel);
1425: editSectionDropDownValues.add(nextHiddenBoxValue + " = '"
1426: + SubmitActionParameters.ADD + "'; "
1427: + createAroundExistingCpc.createParameterCall());
1428: }
1429: //
1430: //
1431: //
1432: //SubmitActionContext replaceSac =
1433: // SubmitActionContext.newInstance(this);
1434: //replaceSac.addAction(
1435: // replaceSac.FIRST_INPUT,
1436: // singleQuotes(SubmitActionParameters.DO_NOTHING));
1437: ////
1438: //CreationParameterContext replaceCpc =
1439: // CreationParameterContext.newInstance(
1440: // "Replace " + (inIndex + 1), replaceSac, false);
1441: //
1442: //
1443: if (existingElement) {
1444: CreationParameterContext replaceExistingCpc = createCreateExistingWindowScrollBarCpc(
1445: inCtcon, inIndex, inParentHandle,
1446: nextHiddenBoxValue, "Replace " + (inIndex + 1),
1447: destinationMenuId);
1448: //
1449: localPsc.registerCreationParameter(localCps,
1450: replaceExistingCpc, CRE_PARAM_CALL__REPLACE);
1451: //
1452: editSectionDropDownLabels.add("- Replace");
1453: editSectionDropDownValues.add(nextHiddenBoxValue + " = '"
1454: + SubmitActionParameters.REPLACE + "'; "
1455: + replaceExistingCpc.createParameterCall());
1456: }
1457: //testCpc.addInputAsButton(
1458: // testCpc.FIRST_INPUT, "ButtonLabel1", "alert('HiGary')");
1459: //testCpc.addInputAsTextBox(
1460: // testCpc.SECOND_INPUT, "Gary201", "Gary202");
1461: //testCpc.addInputAsExclusive(
1462: // testCpc.THIRD_INPUT, "Gary301",
1463: // new String[]{"A"}, new String[]{"a"});
1464: //testCpc.addInputAsInclusive(
1465: // testCpc.FOURTH_INPUT, "Gary401",
1466: // new String[]{"B"}, new String[]{"b"}, "Gary402");
1467: //testCpc.addInputAsHiddenBox(
1468: // testCpc.FIFTH_INPUT, "GaryHidden501");
1469: //testCpc.addInputAsFileUpload(
1470: // testCpc.SIXTH_INPUT, "GaryFile601");
1471:
1472: //
1473:
1474: String editSectionDropDown = createDropDownBox(
1475: DROP_DOWN_BOX__ADD_OR_REPLACE_RCTH_SELECT,
1476: editSectionDropDownLabels, editSectionDropDownValues,
1477: null, editSectionDropDownStyles, 0, null,
1478: "eval(this.value); this.selectedIndex = 0;", null);
1479: //
1480: simpleAndPrint(editSectionDropDown);
1481: }
1482:
1483: private CreationParameterContext createCreateExistingWindowScrollBarCpc(
1484: ConceptTagConstraint inCtcon, int inIndex,
1485: String inParentHandle, String inCreateOrUpdateAction,
1486: String inLabel, String inMenuId) throws IOException {
1487: //
1488: CreationParameterContext outValue = null;
1489:
1490: //
1491: SubmitActionContext createSac = SubmitActionContext
1492: .newInstance(this );
1493: //
1494: SubmitActionContext compoundSac = SubmitActionContext
1495: .newInstance(this );
1496: //
1497: outValue = createEditCpc(inCtcon, inIndex, inParentHandle,
1498: inCreateOrUpdateAction, inLabel, inMenuId, createSac,
1499: compoundSac);
1500:
1501: return outValue;
1502: }
1503:
1504: //
1505: public final static CreationParameterContext createEditCpc(
1506: String inSacFromPage, String inSacHandle,
1507: String inSacHandleAlias, RootConceptTagHolder inRcth,
1508: int inIndex, String inParentHandle,
1509: String inCreateOrUpdateAction, String inLabel,
1510: String inMenuId) {
1511: //
1512: try {
1513: CreationParameterContext outValue = null;
1514:
1515: //
1516: SubmitActionContext createSac = SubmitActionContext
1517: .newInstance(inSacFromPage, inSacHandle,
1518: inSacHandleAlias);
1519: //
1520: SubmitActionContext compoundSac = SubmitActionContext
1521: .newInstance(inSacFromPage, inSacHandle,
1522: inSacHandleAlias);
1523: //
1524: ConceptTagConstraint localCtcon = inRcth
1525: .getConstraint(inParentHandle);
1526: //
1527: outValue = createEditCpc(localCtcon, inIndex,
1528: inParentHandle, inCreateOrUpdateAction, inLabel,
1529: inMenuId, createSac, compoundSac);
1530:
1531: return outValue;
1532: } catch (IOException ioe) {
1533: throw new UnexpectedSystemException(ioe);
1534: }
1535: }
1536:
1537: private final static CreationParameterContext createEditCpc(
1538: ConceptTagConstraintOrTemplate inCtcot, int inIndex,
1539: String inParentHandle, String inCreateOrUpdateAction,
1540: String inLabel, String inMenuId,
1541: SubmitActionContext inCreateSac,
1542: SubmitActionContext inCompoundSac) throws IOException {
1543: //
1544: CreationParameterContext outValue = null;
1545:
1546: //
1547: inCreateSac.addAction(ConsoleParameterContext.FIRST_INPUT,
1548: inCreateOrUpdateAction);
1549: inCreateSac.addAction(ConsoleParameterContext.SECOND_INPUT,
1550: singleQuotes(SubmitActionParameters.TEXT));
1551: //
1552: outValue = CreationParameterContext.newInstance(inLabel,
1553: inCreateSac, true, true);
1554: //
1555: outValue.addInputAsHiddenBox(
1556: ConsoleParameterContext.FIRST_INPUT, inParentHandle);
1557: outValue.addInputAsHiddenBox(
1558: ConsoleParameterContext.SECOND_INPUT, ("" + inIndex));
1559:
1560: //
1561: boolean canBeDynamic = inCtcot.isDynamicContextPresent();
1562: boolean canBeCompound = inCtcot.isCompoundContextPresent();
1563: boolean canBeStatic = inCtcot.isStaticContextPresent();
1564:
1565: //
1566: if (canBeStatic) {
1567: StaticConceptTagConstraintContext sctcc = inCtcot
1568: .getStaticConstraintContext();
1569: //
1570: if (sctcc.getEntrySetLength() > 0
1571: && sctcc.isEntrySetExclusive()) {
1572: //
1573: String listLabels[] = new String[sctcc
1574: .getEntrySetLength()];
1575: String listValues[] = new String[sctcc
1576: .getEntrySetLength()];
1577: //
1578: for (int i = 0; i < sctcc.getEntrySetLength(); i++) {
1579: listLabels[i] = sctcc.getEntryDescription(i);
1580: listValues[i] = sctcc.getEntryValue(i);
1581: }
1582: //
1583: outValue.addInputAsExclusive(
1584: ConsoleParameterContext.THIRD_INPUT,
1585: "String Value", listValues, listLabels);
1586: } else if (sctcc.getEntrySetLength() > 0
1587: && !sctcc.isEntrySetExclusive()) {
1588: //
1589: String listLabels[] = new String[sctcc
1590: .getEntrySetLength()];
1591: String listValues[] = new String[sctcc
1592: .getEntrySetLength()];
1593: //
1594: for (int i = 0; i < sctcc.getEntrySetLength(); i++) {
1595: listLabels[i] = sctcc.getEntryDescription(i);
1596: listValues[i] = sctcc.getEntryValue(i);
1597: }
1598: //
1599: outValue.addInputAsInclusive(
1600: ConsoleParameterContext.THIRD_INPUT,
1601: "String Value", listValues, listLabels,
1602: "(Your Text Here)");
1603: } else if (sctcc.isMultiLine()) {
1604: //
1605: outValue.addInputAsTextArea(
1606: ConsoleParameterContext.THIRD_INPUT,
1607: "String Value", "(Your Text Here)");
1608: } else {
1609: //
1610: outValue.addInputAsTextBox(
1611: ConsoleParameterContext.THIRD_INPUT,
1612: "String Value", "(Your Text Here)");
1613: }
1614: //
1615: //
1616: //
1617:
1618: outValue.addInputAsButton(
1619: ConsoleParameterContext.FOURTH_INPUT, "Use String",
1620: CreationParameterContext.getCreationSubmit(
1621: inCreateSac, true, 6));
1622: } else {
1623: //
1624: //dummy field
1625: outValue.addInputAsHiddenBox(
1626: ConsoleParameterContext.THIRD_INPUT, "");
1627: outValue.addInputAsHiddenBox(
1628: ConsoleParameterContext.FOURTH_INPUT, "");
1629: }
1630:
1631: //
1632: if (canBeDynamic) {
1633: outValue.addInputAsButton(
1634: ConsoleParameterContext.FIFTH_INPUT, "Tag Value",
1635: getLaunchPointAction(inMenuId, false));
1636: } else {
1637: //
1638: //dummy field
1639: outValue.addInputAsHiddenBox(
1640: ConsoleParameterContext.FIFTH_INPUT, "");
1641: }
1642:
1643: //
1644: if (canBeCompound) {
1645: //SubmitActionContext sacUseDefaultCompound =
1646: // SubmitActionContext.newInstance(this);
1647: //
1648: initializeCreateCompound(inCompoundSac, true,
1649: inCreateOrUpdateAction, inParentHandle, inIndex);
1650: //
1651: //inCompoundSac.addAction(
1652: // inCompoundSac.FIRST_INPUT, inCreateOrUpdateAction);
1653: //inCompoundSac.addAction(
1654: // inCompoundSac.SECOND_INPUT,
1655: // singleQuotes(SubmitActionParameters.COMPOUND));
1656: ////
1657: ////sacUseDefaultCompoundInstead.addParameter(
1658: //// sacUseDefaultCompoundInstead.FIRST_INPUT,
1659: //// singleQuotes(getConsolePageSession().getToggleLink()));
1660: //inCompoundSac.addParameter(
1661: // inCompoundSac.FIRST_INPUT, singleQuotes(inParentHandle));
1662: //inCompoundSac.addParameter(
1663: // inCompoundSac.SECOND_INPUT, singleQuotes(inIndex + ""));
1664: //
1665: outValue.addInputAsButton(
1666: ConsoleParameterContext.SIXTH_INPUT,
1667: "Compound Value", inCompoundSac
1668: .submitActionCall(true));
1669: //sacUseDefaultCompoundInstead.setSecondParameter(
1670: // singleQuotes(nextStchar.getValueLength() + ""));
1671: //sacUseDefaultCompoundInstead.setThirdParameter(
1672: // singleQuotes(ConsolePageParameters.DONT_SWAP));
1673: //createButton(BUTTON__USE_COMPOUND, "Use Default Compound", 150,
1674: // sacUseDefaultCompoundInstead.submitActionCall(),
1675: // null, null, null, null);
1676: } else {
1677: //
1678: //dummy field
1679: outValue.addInputAsHiddenBox(
1680: ConsoleParameterContext.SIXTH_INPUT, "");
1681: }
1682:
1683: return outValue;
1684: }
1685:
1686: //
1687: public final static void initializeCreateCompound(
1688: SubmitActionContext inSac, boolean inUseQuotes,
1689: String inUnquotedFirstAction, String inParentHandle,
1690: int inIndex) {
1691: //
1692: inSac.addAction(ConsoleParameterContext.FIRST_INPUT,
1693: inUnquotedFirstAction);
1694: inSac.addAction(ConsoleParameterContext.SECOND_INPUT,
1695: singleQuotes(SubmitActionParameters.COMPOUND,
1696: inUseQuotes));
1697: //
1698: //sacUseDefaultCompoundInstead.addParameter(
1699: // sacUseDefaultCompoundInstead.FIRST_INPUT,
1700: // singleQuotes(getConsolePageSession().getToggleLink()));
1701: inSac.addParameter(ConsoleParameterContext.FIRST_INPUT,
1702: singleQuotes(inParentHandle, inUseQuotes));
1703: inSac.addParameter(ConsoleParameterContext.SECOND_INPUT,
1704: singleQuotes(inIndex + "", inUseQuotes));
1705: }
1706: //private SubmitActionContext createCreateExistingWindowScrollBarSac(
1707: // ConceptTagConstraint inCtcon, int inIndex, String inParentHandle,
1708: // String inCreateOrUpdateAction) throws IOException {
1709: // //
1710: // SubmitActionContext outValue = null;
1711: //
1712: // outValue = SubmitActionContext.newInstance(this);
1713: // //
1714: // //prepare as submitting to create text
1715: // // - inCreateOrUpdateAction should point to object value
1716: // //
1717: // outValue.addAction(outValue.FIRST_INPUT, inCreateOrUpdateAction);
1718: // outValue.addAction(
1719: // outValue.SECOND_INPUT, singleQuotes(SubmitActionParameters.TEXT));
1720: //
1721: //
1722: // return outValue;
1723: //}
1724:
1725: }
|