001: /*
002: * JFolder, Copyright 2001-2006 Gary Steinmetz
003: *
004: * Distributable under LGPL license.
005: * See terms of license at gnu.org.
006: */
007:
008: package org.jfolder.console.view.base;
009:
010: //base classes
011: import java.util.ArrayList;
012: import java.util.HashMap;
013:
014: //project specific classes
015: import org.jfolder.common.UnexpectedSystemException;
016: import org.jfolder.common.function.WebPageTagInstanceViewContext;
017: import org.jfolder.common.function.WebPageTagInstanceViewContextInfo;
018: import org.jfolder.common.tagging.ConceptTag;
019: import org.jfolder.common.tagging.ConceptTagCharacteristic;
020: import org.jfolder.common.tagging.ConceptTagCharacteristicHolder;
021: import org.jfolder.common.tagging.ConceptTagConstraint;
022: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
023: import org.jfolder.common.tagging.ConceptTagMessageHolder;
024: import org.jfolder.common.tagging.ConceptTagPreferences;
025: import org.jfolder.common.tagging.ConceptTagSetHolder;
026: import org.jfolder.common.tagging.DynamicConceptTagConstraintContext;
027: import org.jfolder.common.tagging.DynamicConceptTagValidator;
028: import org.jfolder.common.tagging.SelectionCriteriaForConceptTag;
029: import org.jfolder.common.utils.misc.CommonSeparators;
030: import org.jfolder.common.utils.misc.MiscHelper;
031: import org.jfolder.common.utils.xml.XMLHelper;
032: import org.jfolder.common.web.template.ConsoleParameterContext;
033: import org.jfolder.common.web.template.ConsoleTemplateContext;
034: import org.jfolder.common.web.template.ConsoleTemplateSession;
035: import org.jfolder.common.web.template.PageSetupContext;
036: import org.jfolder.common.web.template.RcthConstraintBuilder;
037: import org.jfolder.common.web.template.SubmitActionContext;
038: import org.jfolder.common.web.template.SubmitActionParameters;
039:
040: //other classes
041:
042: public class PopUpViewHelper {
043:
044: //
045: //
046: public final static int MENU_OPT__GO_TO = 0;
047: public final static int MENU_OPT__REPLACE = 1;
048: public final static int MENU_OPT__INSERT_BEFORE = 2;
049: public final static int MENU_OPT__INSERT_AFTER = 3;
050: public final static int MENU_OPT__DELETE = 4;
051: public final static int MENU_OPT__COPY = 5;
052: public final static int MENU_OPT__PASTE_BEFORE = 6;
053: public final static int MENU_OPT__PASTE_REPLACE = 7;
054: public final static int MENU_OPT__PASTE_AFTER = 8;
055: public final static int MENU_OPT__VIEW_EARMARKS = 9;
056: public final static int MENU_OPT__VIEW_ERRORS = 10;
057: public final static int MENU_OPT__MENU = 11;
058: public final static int MENU_OPT__INSERT_FIRST_CHILD = 12;
059: public final static int MENU_OPT__INSERT_LAST_CHILD = 13;
060: public final static int MENU_OPT__DIAG_HANDLE = 14;
061: public final static int MENU_OPT__DIAG_INDEX = MENU_OPT__DIAG_HANDLE + 1;
062: public final static int MENU_OPT__DIAG_SELECTOR = MENU_OPT__DIAG_INDEX + 1;
063: public final static int MENU_OPT__DIAG_SAC = MENU_OPT__DIAG_SELECTOR + 1;
064: public final static int MENU_OPT__DIAG_CRPC = MENU_OPT__DIAG_SAC + 1;
065:
066: //
067: //
068: private PopUpViewHelper() {
069: }
070:
071: //
072: //
073: public final static ArrayList toList(String inValues[]) {
074:
075: ArrayList outValue = new ArrayList();
076:
077: for (int i = 0; i < inValues.length; i++) {
078: outValue.add(inValues[i]);
079: }
080:
081: return outValue;
082: }
083:
084: public final static boolean isAllLocalHtml(
085: WebPageTagInstanceViewContextInfo inWptivci) {
086: //
087: boolean outValue = true;
088:
089: for (int i = 0; i < inWptivci.getContentLength(); i++) {
090: //
091: WebPageTagInstanceViewContextInfo nextWptivci = inWptivci
092: .getContentAsInfo(i);
093: //
094: outValue &= nextWptivci.isMarkedAsHtml();
095: }
096:
097: return outValue;
098: }
099:
100: public final static boolean isAllNonHtml(
101: WebPageTagInstanceViewContextInfo inWptivci) {
102: //
103: boolean outValue = true;
104:
105: for (int i = 0; i < inWptivci.getContentLength(); i++) {
106: //
107: WebPageTagInstanceViewContextInfo nextWptivci = inWptivci
108: .getContentAsInfo(i);
109: //
110: if (nextWptivci.isMarkedAsIterativeNonHtml()) {
111: outValue &= isAllNonHtml(nextWptivci);
112: } else if (nextWptivci.isMarkedAsNonHtml()) {
113: outValue &= isAllNonHtml(nextWptivci);
114: } else if (nextWptivci.isMarkedAsHtml()) {
115: outValue &= false;
116: } else {
117: throw UnexpectedSystemException.unknownState();
118: }
119: }
120:
121: return outValue;
122: }
123:
124: //
125: //
126: //
127: //
128: public final static SubmitActionContext createGoToSac(
129: PopUpViewHolder inPuvh) {
130: //
131: SubmitActionContext outValue = SubmitActionContext
132: .newInstance(inPuvh.getConsoleTemplateContext());
133: //
134: String goToHandle = MiscHelper.reassembleHandle(inPuvh
135: .getToggleSuffix(), inPuvh.getWebPageTagPreferences()
136: .getHandleConjunction());
137: //
138: outValue.addAction(ConsoleParameterContext.FIRST_INPUT,
139: ConsoleTemplateContext.singleQuotes(
140: SubmitActionParameters.MOVE, true));
141: //
142: outValue.addParameter(ConsoleParameterContext.FIRST_INPUT,
143: ConsoleTemplateContext.singleQuotes(goToHandle, true));
144: //
145: return outValue;
146: }
147:
148: //
149: //
150: //
151: //
152: public final static String createStudioUsabilityPopUp(
153: PopUpViewHolder inPuvh, boolean inBlockClear,
154: boolean inUseEvent, boolean inUseSemicolon) {
155: //
156: StringBuffer outValue = new StringBuffer();
157: //
158: ConceptTagConstraint localCtcon = inPuvh.getConstraint();
159: Integer localIndex = inPuvh.getStaticIndex();
160: ConceptTagConstraintHolder localCtconh = inPuvh
161: .getConstraintHolder();
162: //
163: String inputHandle = null;
164: int inputIndex = 0;
165: //
166: int inputParentSelectorIndex = 0;
167: int inputParentSacIndex = 0;
168: int inputParentCrpcIndex = 0;
169: //
170: int inputChildSelectorIndex = 0;
171: int inputChildSacIndex = 0;
172: int inputChildCrpcIndex = 0;
173: //
174: int inputCtconMin = 0;
175: int inputCtconMax = 0;
176: int inputCtconCurrentSize = 0;
177: //
178: boolean inputUseCopy = false;
179: boolean inputUsePaste = false;
180: String inputEarmarkId = null;
181: String inputErrorId = null;
182: String inputDefaultConstraint = null;
183: int inputDefaultConstraintCount = 0;
184: //
185: //
186: ConceptTagConstraint pasteCtcon = null;
187: //
188: if (localCtconh != null && localCtcon == null
189: && localIndex == null) {
190: //
191: ConceptTagCharacteristicHolder localCtcharh = localCtconh
192: .getCharacteristicHolder();
193: ConceptTagCharacteristic localParentCtchar = localCtcharh
194: .getParentCharacteristic();
195: ConceptTagConstraint localParentCtcon = localCtconh
196: .getParentConstraint();
197: //
198: inputHandle = localParentCtchar.getHandleWithoutIndex();
199: inputIndex = localCtcharh.getParentCharacteristicIndex();
200: //
201: inputParentSelectorIndex = localParentCtcon
202: .getSelectorIndex();
203: inputParentSacIndex = localParentCtcon.getSacIndex();
204: inputParentCrpcIndex = localParentCtcon
205: .getCreationParameterIndex();
206: //
207: //
208: inputCtconMin = localParentCtcon.getMinimumLength();
209: if (!localParentCtcon.isLengthUnbounded()) {
210: inputCtconMax = localParentCtcon.getMaximumLength();
211: } else {
212: inputCtconMax = -1;
213: }
214: inputCtconCurrentSize = localParentCtcon
215: .getCharacteristic().getValueLength();
216: //
217: //
218: inputUseCopy = localCtcharh.isConceptTagPresent();
219: //
220: //
221: pasteCtcon = localParentCtcon;
222: } else if (localCtconh == null && localCtcon != null
223: && localIndex != null) {
224: //
225: ConceptTagCharacteristic localCtchar = localCtcon
226: .getCharacteristic();
227: //
228: inputHandle = localCtchar.getHandleWithoutIndex();
229: inputIndex = localIndex.intValue();
230: //
231: inputParentSelectorIndex = localCtcon.getSelectorIndex();
232: inputParentSacIndex = localCtcon.getSacIndex();
233: inputParentCrpcIndex = localCtcon
234: .getCreationParameterIndex();
235: //
236: //
237: inputCtconMin = localCtcon.getMinimumLength();
238: if (!localCtcon.isLengthUnbounded()) {
239: inputCtconMax = localCtcon.getMaximumLength();
240: } else {
241: inputCtconMax = -1;
242: }
243: inputCtconCurrentSize = localCtcon.getCharacteristic()
244: .getValueLength();
245: //
246: //
247: inputUseCopy = !(localCtchar.isHolderWithoutConceptTag(
248: inputIndex, null));
249: //
250: //
251: pasteCtcon = localCtcon;
252: } else {
253: throw UnexpectedSystemException.unknownState();
254: }
255: //
256: //
257: //
258: //
259: //
260: //
261: if (pasteCtcon.isStaticContextPresent()
262: && inPuvh.isCopyStaticPresent()) {
263: //
264: inputUsePaste = true;
265: } else if (pasteCtcon.isDynamicContextPresent()
266: && inPuvh.isCopyDynamicPresent()) {
267: //
268: DynamicConceptTagConstraintContext dctcc = pasteCtcon
269: .getDynamicConstraintContext();
270: DynamicConceptTagValidator dctv = dctcc.getValidator();
271: ConceptTag localCt = inPuvh.getCopyDynamic();
272: //ConceptTag localCt = localCps.getCopyHolderValueAsConceptTag();
273: SelectionCriteriaForConceptTag localScfct = SelectionCriteriaForConceptTag
274: .newInstance(localCt);
275: localCt.appraise(localScfct);
276: //
277: //
278: ArrayList results = dctv.validate(localScfct, localCt
279: .getClass(), true);
280: //
281: //
282: inputUsePaste = (results.size() == 0);
283: //
284: //
285: } else {
286: inputUsePaste = false;
287: }
288: //
289: //
290: //
291: if (inPuvh.getDefaultConstraint() != null) {
292: //
293: inputDefaultConstraint = ConsoleTemplateContext
294: .singleQuotes(inPuvh.getDefaultConstraint());
295: //
296: //
297: //
298: ConceptTagConstraint localChildCtcon = null;
299: ConceptTagPreferences localCtp = localCtconh
300: .getPreferences();
301: if (inPuvh.getDefaultConstraint().equals(
302: localCtp.getUnconstrainedSymbol())) {
303: //
304: localChildCtcon = localCtconh.getUndefinedConstraint();
305: } else {
306: localChildCtcon = localCtconh.getConstraint(inPuvh
307: .getDefaultConstraint());
308: }
309: //
310: inputChildSelectorIndex = localChildCtcon
311: .getSelectorIndex();
312: inputChildSacIndex = localChildCtcon.getSacIndex();
313: inputChildCrpcIndex = localChildCtcon
314: .getCreationParameterIndex();
315: } else {
316: inputChildSelectorIndex = -1;
317: inputChildSacIndex = -1;
318: inputChildCrpcIndex = -1;
319: }
320: //
321: //
322: //
323: if (inPuvh.getEarmarkId() != null) {
324: inputEarmarkId = ConsoleTemplateContext.singleQuotes(inPuvh
325: .getEarmarkId());
326: }
327: //
328: //
329: //
330: if (inPuvh.getErrorId() != null) {
331: inputErrorId = ConsoleTemplateContext.singleQuotes(inPuvh
332: .getErrorId());
333: }
334: //
335: //
336: //
337: if (inPuvh.getDefaultConstraint() != null) {
338: //
339: inputDefaultConstraint = ConsoleTemplateContext
340: .singleQuotes(inPuvh.getDefaultConstraint());
341: //
342: ConceptTagCharacteristicHolder localCtcharh = localCtconh
343: .getCharacteristicHolder();
344: ConceptTagPreferences localCtp = localCtcharh
345: .getPreferences();
346: ConceptTagCharacteristic localCtchar = null;
347: if (localCtp.getUnconstrainedSymbol().equals(
348: inPuvh.getDefaultConstraint())) {
349: //
350: localCtchar = localCtcharh.getUndefinedCharacteristic();
351: } else {
352: localCtchar = localCtcharh.getCharacteristic(inPuvh
353: .getDefaultConstraint());
354: }
355: //
356: inputDefaultConstraintCount = localCtchar.getValueLength();
357: }
358: //
359: //
360: //
361: if (!inPuvh.isTemplateInUse()) {
362: String eventInUse = "null";
363: String sourceInUse = "null";
364: if (inUseEvent) {
365: eventInUse = "event";
366: sourceInUse = "this";
367: }
368: outValue.append("openStudioSelection(" + eventInUse + ", "
369: + sourceInUse + ", ");
370: outValue.append(inBlockClear + ", ");
371: outValue.append("'" + inputHandle + "', ");
372: outValue.append("" + inputIndex + ", ");
373: outValue.append("" + inputCtconMin + ", ");
374: outValue.append("" + inputCtconMax + ", ");
375: outValue.append("" + inputCtconCurrentSize + ", ");
376: outValue.append("" + inputUseCopy + ", ");
377: outValue.append("" + inputUsePaste + ", ");
378: outValue.append("" + inputEarmarkId + ", ");
379: outValue.append("" + inputErrorId + ", ");
380: outValue.append("" + inputDefaultConstraint + ", ");
381: outValue.append("" + inputDefaultConstraintCount + ", ");
382: outValue.append("" + inputChildSelectorIndex + ", ");
383: outValue.append("" + inputChildSacIndex + ", ");
384: outValue.append("" + inputChildCrpcIndex + ", ");
385: outValue.append("" + inputParentSelectorIndex + ", ");
386: outValue.append("" + inputParentSacIndex + ", ");
387: outValue.append("" + inputParentCrpcIndex);// + ", ");
388: outValue.append(")");
389: if (inUseSemicolon) {
390: outValue.append(";");
391: }
392: } else {
393: outValue.append("alert('Template cannot be edited here');"
394: + " stopEventPropogation(event);");
395: }
396:
397: return outValue.toString();
398: }
399:
400: public final static void createPopUpNonHtmlSpanStart(
401: PopUpViewHolder inPuvh) {
402: //
403: //
404: //
405: //
406: if (inPuvh.getInfo().isNotEmpty()) {
407: //
408: //
409: //
410: if (inPuvh.isMenuActive()) {
411: //
412: //
413: HashMap spanAttrs = getBorderAreaAttributes(inPuvh,
414: true);
415: //
416: inPuvh.appendText("<span ");
417: inPuvh.appendText(XMLHelper.convertAttrs(spanAttrs));
418: inPuvh.appendText(">");
419: }
420: //
421: //
422: //
423: //
424: //
425: //
426: }
427: }
428:
429: public final static HashMap getBorderAreaAttributes(
430: PopUpViewHolder inPuvh, boolean inBlockClear) {
431: //
432: HashMap outValue = new HashMap();
433: //
434: //
435: inPuvh.pushStudioMacroEditDirectiveAsTarget();
436: //
437: //
438: //
439: //
440: ConsoleTemplateSession localCts = inPuvh
441: .getConsoleTemplateSession();
442: localCts.pushToggleLinkAnchorPoint();
443: localCts.pushToggleLink(inPuvh.incrementCurrentIdCount() + "");
444: String localId = localCts.getToggleLink();
445: localCts.popToggleLink();
446: localCts.popToggleLink();
447: //
448: boolean localErrorPresent = PopUpViewHelper
449: .isLocalErrorPresent(inPuvh.getConstraint(), inPuvh
450: .getStaticIndex(), inPuvh.getConstraintHolder());
451: if (localErrorPresent) {
452: inPuvh.setDescendentErrorPresent(localErrorPresent);
453: }
454: String mouseOutBorder = inPuvh.getInfo().getMouseOutBorder();
455: if (inPuvh.getErrorId() != null
456: && inPuvh.getInfo().getIdHandle().length > 0) {
457: //
458: mouseOutBorder = WebPageTagInstanceViewContextInfo
459: .getErrorBorder();
460: }
461: //
462: String mouseOverBorder = inPuvh.getInfo().getMouseOverBorder();
463: //
464: //
465: //
466: outValue.put("onmouseout", "this.style.cursor = 'auto';"
467: + " this.style.border = '" + mouseOutBorder + "';"
468: + " stopEventPropogation(event);");
469: outValue.put("onmouseover", "this.style.cursor = 'pointer';"
470: + " this.style.border = '" + mouseOverBorder + "';"
471: + " studioCloseAllMenus(this);"
472: + " stopEventPropogation(event);");
473: //spanAttrs.put(
474: // "title", XMLHelper.fromStringToCData(inContent));
475: outValue.put("onclick", createStudioUsabilityPopUp(inPuvh,
476: inBlockClear, true, true));
477: outValue.put("style", "border: " + mouseOutBorder);
478: outValue.put("id", localId);
479: outValue.put("title", PopUpViewHelper.getTitle(inPuvh));
480: //
481: //
482: //////////////////////////////////////////////////////////////
483: //
484: //ConceptTagConstraint localCtcon = getConstraint(
485: // inCtcon, inIndex, inCtconh);
486: //int localCtconIndex = getConstraintIndex(
487: // inCtcon, inIndex, inCtconh);
488: //ConceptTagConstraintHolder localCtconh = getConstraintHolder(
489: // inCtcon, inIndex, inCtconh);
490: String localHandleParent = inPuvh.getHandleParent();
491: Integer localHandleIndex = inPuvh.getHandleIndex();
492: //
493: ArrayList localActions = new ArrayList();
494: localActions.add(createStudioUsabilityPopUp(inPuvh,
495: inBlockClear, false, false));
496: generateStudioUsabilityPopUpSelection(inPuvh, false,
497: localActions);
498: //
499: ArrayList localParentActions = new ArrayList();
500: localParentActions.add(createStudioUsabilityPopUp(inPuvh,
501: inBlockClear, false, false));
502: generateStudioUsabilityPopUpSelection(inPuvh, true,
503: localParentActions);
504: //
505: inPuvh.popStudioMacroEditDirectiveAsTarget(localId,
506: localHandleParent, localHandleIndex, localActions,
507: localParentActions);
508: //
509: //
510: return outValue;
511: }
512:
513: public final static String getMenuItemPartId(String inParentId,
514: String inIndex) {
515: //
516: return (inParentId + " + '"
517: + CommonSeparators.TOGGLE_LINK_SEPARATOR + "' + '"
518: + ConsoleTemplateSession.getMenuItemPartName()
519: + "' + '" + CommonSeparators.TOGGLE_LINK_SEPARATOR
520: + "' + " + inIndex);
521: }
522:
523: public final static void generateStudioUsabilityPopUpSelection(
524: PopUpViewHolder inPuvh, boolean inParent,
525: ArrayList inActions) {
526: //
527: PageSetupContext localPsc = inPuvh.getConsoleTemplateSession()
528: .getPageSetupContext();
529: if (localPsc.isStudioMacroEditPresent()) {
530: //
531: RcthConstraintBuilder localRcb = localPsc
532: .getStudioMacroEdit();
533: //
534: //String menuItemId = ""
535: //
536: if (!inParent && localRcb.isDeleteAction()) {
537: String menuItemPartId = getMenuItemPartId(
538: "getStudioSelectionId()", MENU_OPT__DELETE + "");
539: inActions.add("macroGoTo(" + menuItemPartId + ")");
540: inActions.add("macroClickImage()");
541: } else if (!inParent && localRcb.isReplaceAction()) {
542: String menuItemPartId = getMenuItemPartId(
543: "getStudioSelectionId()", MENU_OPT__REPLACE
544: + "");
545: inActions.add("macroGoTo(" + menuItemPartId + ")");
546: inActions.add("macroClickImage()");
547: inActions.add("macroClick(" + menuItemPartId + ")");
548: } else if (!inParent && localRcb.isInsertAction()) {
549: String menuItemPartId = getMenuItemPartId(
550: "getStudioSelectionId()",
551: MENU_OPT__INSERT_AFTER + "");
552: inActions.add("macroGoTo(" + menuItemPartId + ")");
553: inActions.add("macroClickImage()");
554: inActions.add("macroClick(" + menuItemPartId + ")");
555: } else if (inParent && localRcb.isDeleteAction()) {
556: inActions
557: .add("macroAlert('Delete cannot be called from parent')");
558: } else if (inParent && localRcb.isReplaceAction()) {
559: inActions
560: .add("macroAlert('Replace cannot be called from parent')");
561: } else if (inParent && localRcb.isInsertAction()) {
562: String menuItemPartId = getMenuItemPartId(
563: "getStudioSelectionId()",
564: MENU_OPT__INSERT_FIRST_CHILD + "");
565: inActions.add("macroGoTo(" + menuItemPartId + ")");
566: inActions.add("macroClickImage()");
567: inActions.add("macroClick(" + menuItemPartId + ")");
568: } else {
569: throw UnexpectedSystemException.unknownState();
570: }
571: }
572: }
573:
574: //
575: //
576: public final static void createPopUpNonHtmlSpanMiddle(
577: PopUpViewHolder inPuvh, String inContent) {
578: //
579: //if (inContent != null) {
580: //
581: boolean convertContent = true;
582: //
583: if (convertContent) {
584: inPuvh.appendText(WebPageTagInstanceViewContext
585: .convertTextToStudioHtml(inContent));
586: } else {
587: inPuvh.appendText(inContent);
588: }
589: //}
590: }
591:
592: public final static void createPopUpNonHtmlSpanEnd(
593: PopUpViewHolder inPuvh) {
594: //
595: //
596: if (inPuvh.getInfo().isNotEmpty()) {
597: //
598: //
599: //
600: if (inPuvh.isMenuActive()) {
601: inPuvh.appendText("</span>");
602: }
603: }
604: }
605:
606: //
607: //
608: //
609: //
610: //
611: //
612: //
613: //
614: //
615: //
616: public final static WebPageTagInstanceViewContextInfo getErrorInfo(
617: PopUpViewHolder inPuvh) {
618: //
619: return getErrorInfo(inPuvh.getConstraint(), inPuvh
620: .getStaticIndex(), inPuvh.getConstraintHolder());
621: }
622:
623: //
624: private final static WebPageTagInstanceViewContextInfo getErrorInfo(
625: ConceptTagConstraint inCtcon, Integer inIndex,
626: ConceptTagConstraintHolder inCtconh) {
627:
628: WebPageTagInstanceViewContextInfo outValue = null;
629:
630: //
631: ConceptTagConstraint localCtcon = getConstraint(inCtcon,
632: inIndex, inCtconh);
633: int localCtconIndex = getConstraintIndex(inCtcon, inIndex,
634: inCtconh);
635: ConceptTagConstraintHolder localCtconh = getConstraintHolder(
636: inCtcon, inIndex, inCtconh);
637: //
638: ConceptTagCharacteristic localCtchar = localCtcon
639: .getCharacteristic();
640: ConceptTagMessageHolder localCtcharCtmh = localCtchar
641: .getParentMessageHolder();
642: //
643: ConceptTagCharacteristicHolder localCtcharh = null;
644: ConceptTagMessageHolder localCtcharhCtmh = null;
645: if (localCtconh != null) {
646: localCtcharh = localCtconh.getCharacteristicHolder();
647: localCtcharhCtmh = localCtcharh.getParentMessageHolder();
648: }
649: //
650: //ConceptTagCharacteristic localCtchar = inCtcon.getCharacteristic();
651: //ConceptTagMessageHolder localCtcharCtmh =
652: // localCtchar.getParentMessageHolder();
653: ////
654: //ConceptTagCharacteristicHolder localCtcharh = null;
655: //ConceptTagMessageHolder localCtcharhCtmh = null;
656: //ConceptTagConstraintHolder localCtconh = null;
657: ////
658: //if (localCtchar.isHolder(inIndex, null)) {
659: // localCtconh = inCtcon.getConstraintHolder(inIndex);
660: // localCtcharh = localCtconh.getCharacteristicHolder();
661: // localCtcharhCtmh = localCtcharh.getParentMessageHolder();
662: //}
663: //
664: //
665: //
666: boolean errPres = isLocalErrorPresent(inCtcon, inIndex,
667: inCtconh);
668: //errPres |= (localCtcharCtmh.getTotalIndexMessageCount(inIndex) > 0);
669: //if (localCtconh != null) {
670: // errPres |= (localCtcharhCtmh.getHeaderMessageCount() > 0);
671: // ArrayList localCtcharhCtmhNames = localCtcharhCtmh.getAllNames();
672: // for (int i = 0; i < localCtcharhCtmhNames.size(); i++) {
673: // String nextName = ((String)localCtcharhCtmhNames.get(i));
674: // int c = localCtcharhCtmh.getTotalNameMessageCount(nextName);
675: // errPres |= (c > 0);
676: // }
677: // //for (int i = 0; i < localCtcharhCtmh.get) {
678: // //
679: // //}
680: //}
681: //
682: //
683: //
684: //
685: //
686: if (errPres) {
687: outValue = WebPageTagInstanceViewContextInfo
688: .createErrorInfo();
689: //
690: int icount0 = localCtcharCtmh
691: .getTotalIndexMessageCount(localCtconIndex);
692: for (int i = 0; i < icount0; i++) {
693: WebPageTagInstanceViewContextInfo nextWptivci = outValue
694: .createNonHtmlInfo();
695: nextWptivci.setNonHtmlContent(localCtcharCtmh
696: .getIndexMessage(localCtconIndex, i));
697: }
698: //
699: if (localCtconh != null) {
700: //
701: int icount1 = localCtcharhCtmh.getHeaderMessageCount();
702: for (int i = 0; i < icount1; i++) {
703: WebPageTagInstanceViewContextInfo nextWptivci = outValue
704: .createNonHtmlInfo();
705: nextWptivci.setNonHtmlContent(localCtcharhCtmh
706: .getHeaderMessage(i));
707: }
708: //
709: ArrayList localCtcharhCtmhNames = localCtcharhCtmh
710: .getAllNames();
711: for (int i = 0; i < localCtcharhCtmhNames.size(); i++) {
712: String nextName = ((String) localCtcharhCtmhNames
713: .get(i));
714: int jcount = localCtcharhCtmh
715: .getTotalNameMessageCount(nextName);
716: for (int j = 0; j < jcount; j++) {
717: WebPageTagInstanceViewContextInfo nextWptivci = outValue
718: .createNonHtmlInfo();
719: nextWptivci.setNonHtmlContent("("
720: + nextName
721: + ") "
722: + localCtcharhCtmh.getNameMessage(
723: nextName, j));
724: }
725: }
726: //
727: int icount2 = localCtcharh.getCharacteristicCount();
728: for (int i = 0; i < icount2; i++) {
729: //
730: ConceptTagCharacteristic nextCtchar = localCtcharh
731: .getCharacteristic(i);
732: ConceptTagMessageHolder nextCtcharCtmh = nextCtchar
733: .getParentMessageHolder();
734: String nextName = nextCtchar.getConstraintName();
735: //
736: int jcount = nextCtcharCtmh.getHeaderMessageCount();
737: for (int j = 0; j < jcount; j++) {
738: WebPageTagInstanceViewContextInfo nextWptivci = outValue
739: .createNonHtmlInfo();
740: nextWptivci.setNonHtmlContent("(" + nextName
741: + ") "
742: + nextCtcharCtmh.getHeaderMessage(j));
743: }
744: }
745: }
746: //
747: }
748:
749: return outValue;
750: }
751:
752: //
753: //
754: public final static boolean isLocalErrorPresent(
755: ConceptTagConstraint inCtcon, Integer inIndex,
756: ConceptTagConstraintHolder inCtconh) {
757:
758: boolean outValue = false;
759:
760: //
761: //
762: ConceptTagConstraint localCtcon = getConstraint(inCtcon,
763: inIndex, inCtconh);
764: ConceptTagConstraintHolder localCtconh = getConstraintHolder(
765: inCtcon, inIndex, inCtconh);
766: int localCtconIndex = getConstraintIndex(inCtcon, inIndex,
767: inCtconh);
768: //
769: ConceptTagCharacteristic localCtchar = localCtcon
770: .getCharacteristic();
771: //if (localCtchar.getConstraintName().equals("parameter")) {
772: // MiscHelper.println("Parameter Found");
773: //}
774: ConceptTagMessageHolder localCtcharCtmh = localCtchar
775: .getParentMessageHolder();
776:
777: //
778: outValue |= (localCtcharCtmh
779: .getTotalIndexMessageCount(localCtconIndex) > 0);
780: //if (localCtcharCtmh.isMessagePresent()) {
781: // throw UnexpectedSystemException.unknownState();
782: //}
783: if (localCtconh != null) {
784: //if (true) {
785: // throw UnexpectedSystemException.unknownState();
786: //}
787: ConceptTagCharacteristicHolder localCtcharh = localCtconh
788: .getCharacteristicHolder();
789: ConceptTagMessageHolder localCtcharhCtmh = localCtcharh
790: .getParentMessageHolder();
791: //
792: //
793: //if (localCtcharhCtmh.isMessagePresent()) {
794: // throw UnexpectedSystemException.unknownState();
795: //}
796: //
797: //
798: outValue |= (localCtcharhCtmh.getHeaderMessageCount() > 0);
799: ArrayList localCtcharhCtmhNames = localCtcharhCtmh
800: .getAllNames();
801: for (int i = 0; i < localCtcharhCtmhNames.size(); i++) {
802: //if (true) {
803: // throw UnexpectedSystemException.unknownState();
804: //}
805: String nextName = ((String) localCtcharhCtmhNames
806: .get(i));
807: int c = localCtcharhCtmh
808: .getTotalNameMessageCount(nextName);
809: outValue |= (c > 0);
810: }
811: //
812: //
813: //
814: for (int i = 0; i < localCtcharh.getCharacteristicCount(); i++) {
815: //
816: //
817: ConceptTagCharacteristic nextCtchar = localCtcharh
818: .getCharacteristic(i);
819: ConceptTagMessageHolder nextCtcharCtmh = nextCtchar
820: .getParentMessageHolder();
821: //
822: if (nextCtchar.getConstraintName().equals("parameter")) {
823: MiscHelper.println("Parameter Found");
824: }
825: //
826: //
827: outValue |= (nextCtcharCtmh.getHeaderMessageCount() > 0);
828: }
829: }
830: //
831: //if (outValue) {
832: // throw UnexpectedSystemException.unknownState();
833: //}
834:
835: return outValue;
836: }
837:
838: public final static ConceptTagConstraint getConstraint(
839: ConceptTagConstraint inCtcon, Integer inIndex,
840: ConceptTagConstraintHolder inCtconh) {
841:
842: ConceptTagConstraint outValue = null;
843:
844: if (inCtcon != null) {
845: outValue = inCtcon;
846: } else {
847: outValue = inCtconh.getParentConstraint();
848: }
849:
850: return outValue;
851: }
852:
853: public final static int getConstraintIndex(
854: ConceptTagConstraint inCtcon, Integer inIndex,
855: ConceptTagConstraintHolder inCtconh) {
856:
857: int outValue = 0;
858:
859: if (inIndex != null) {
860: outValue = inIndex.intValue();
861: } else {
862: ConceptTagCharacteristicHolder localCtcharh = inCtconh
863: .getCharacteristicHolder();
864: outValue = localCtcharh.getParentCharacteristicIndex();
865: }
866:
867: return outValue;
868: }
869:
870: public final static ConceptTagConstraintHolder getConstraintHolder(
871: ConceptTagConstraint inCtcon, Integer inIndex,
872: ConceptTagConstraintHolder inCtconh) {
873:
874: ConceptTagConstraintHolder outValue = null;
875:
876: if (inCtconh != null) {
877: //
878: //
879: outValue = inCtconh;
880: } else if (inCtcon.getCharacteristic().isHolder(
881: inIndex.intValue(), null)) {
882: //
883: //
884: outValue = inCtcon.getConstraintHolder(inIndex.intValue());
885: } else {
886: outValue = null;
887: }
888:
889: return outValue;
890: }
891:
892: //
893: //
894: //
895: public final static String getTitle(PopUpViewHolder inPuvh) {
896:
897: String outValue = null;
898:
899: //
900: //
901: ConceptTagConstraint localCtcon = getConstraint(inPuvh
902: .getConstraint(), inPuvh.getStaticIndex(), inPuvh
903: .getConstraintHolder());
904: ConceptTagConstraintHolder localCtconh = getConstraintHolder(
905: inPuvh.getConstraint(), inPuvh.getStaticIndex(), inPuvh
906: .getConstraintHolder());
907: int localCtconIndex = getConstraintIndex(
908: inPuvh.getConstraint(), inPuvh.getStaticIndex(), inPuvh
909: .getConstraintHolder());
910: //
911: //
912: if (localCtconh == null) {
913: outValue = "Text";
914: } else if (inPuvh.getDefaultConstraint() != null
915: && inPuvh.getInfo().getIdHandle().length == 0) {
916: //
917: ConceptTagConstraint subCtcon = null;
918: ConceptTagPreferences localCtp = localCtconh
919: .getPreferences();
920: if (localCtp.getUnconstrainedSymbol().equals(
921: inPuvh.getDefaultConstraint())) {
922: //
923: subCtcon = localCtconh.getUndefinedConstraint();
924: } else {
925: subCtcon = localCtconh.getConstraint(inPuvh
926: .getDefaultConstraint());
927: }
928: //
929: outValue = PopUpViewTitleHelper.constructTitleWithEarmark(
930: inPuvh.getInfo(), subCtcon.getTitle());
931: } else if (!localCtconh.getCharacteristicHolder()
932: .isConceptTagPresent()) {
933: outValue = "Compound";
934: } else {
935: ConceptTagCharacteristicHolder localCtcharh = localCtconh
936: .getCharacteristicHolder();
937: ConceptTag localCt = localCtcharh.getConceptTag();
938: ConceptTagPreferences localCtp = localCtcharh
939: .getPreferences();
940: ConceptTagSetHolder localCtsh = localCtp.getSetHolder();
941: //
942: String localCtClassName = localCtsh.getTypeTitle(localCt
943: .getClass().getName());
944: outValue = PopUpViewTitleHelper.constructTitleWithEarmark(
945: inPuvh.getInfo(), localCtClassName);
946: //outValue = localCtsh.getTypeTitle(localCt.getClass().getName());
947: }
948:
949: return outValue;
950: }
951: //
952: //
953: //
954: }
|