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.common.function.v1;
009:
010: //base classes
011:
012: //project specific classes
013: import org.jfolder.common.SelfArgumentlessConstructor;
014: import org.jfolder.common.StandardDataTypes;
015: import org.jfolder.common.function.BaseCommonFunctionCompatibilityTag;
016: import org.jfolder.common.function.WebPageTagInstanceViewContext;
017: import org.jfolder.common.function.WebPageTagInstanceViewContextInfo;
018: import org.jfolder.common.tagging.AppraiseConceptTagContext;
019: import org.jfolder.common.tagging.ConceptTagCharacteristic;
020: import org.jfolder.common.tagging.ConceptTagConstraint;
021: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
022: import org.jfolder.common.tagging.ConceptTagFlagsHelper;
023: import org.jfolder.common.tagging.DetermineClassConceptTagContext;
024: import org.jfolder.common.tagging.DetermineValueAndClassConceptTagContext;
025: import org.jfolder.common.tagging.DetermineValueAndClassConceptTagException;
026: import org.jfolder.common.tagging.InitializeConceptTagContext;
027: import org.jfolder.common.tagging.SelectionCriteriaForReturnableConceptTag;
028: import org.jfolder.common.tagging.StaticConceptTagConstraintContext;
029: import org.jfolder.common.tagging.StudioConceptTagCreParInfoContext;
030: import org.jfolder.common.tagging.StudioConceptTagInstanceInfoContext;
031: import org.jfolder.common.tagging.StudioConceptTagTypeInfoContext;
032: import org.jfolder.common.tagging.ValueAndClassForConceptTag;
033: import org.jfolder.common.utils.misc.MiscHelper;
034:
035: //other classes
036:
037: public class CommonFunctionLiteralBooleanTag extends
038: BaseCommonFunctionCompatibilityTag implements
039: SelfArgumentlessConstructor {
040:
041: //
042: private ConceptTagCharacteristic valueCtchar = null;
043:
044: //value details
045: private final static String VALUE_CTCON = "value";
046: private final static String VALUE_TITLE = "Value";
047: private final static String VALUE_SHORT_DESCRIPTION = "Value of this boolean";
048:
049: public void initialize(InitializeConceptTagContext inIctc) {
050:
051: //
052: ConceptTagConstraintHolder rootCtconh = ConceptTagConstraintHolder
053: .newInstance(inIctc);
054: //
055: //rootCtconh.getAttributes().setStudioVisibleOnlyOnError(true);
056: //rootCtconh.getStyles().setStudioVisibleOnlyOnError(true);
057:
058: //constrain "value"
059: ConceptTagConstraint valueCtcon = ConceptTagConstraint
060: .newInstance(VALUE_CTCON, rootCtconh);
061: valueCtcon.setTitle(VALUE_TITLE);
062: valueCtcon.setShortDescription(VALUE_SHORT_DESCRIPTION);
063: //
064: StaticConceptTagConstraintContext valueSctcc = StaticConceptTagConstraintContext
065: .newInstance(valueCtcon);
066: valueSctcc.registerEntry("True", "True");
067: valueSctcc.registerEntry("False", "False");
068: valueSctcc.setEntrySetExclusive(true);
069: //
070: valueSctcc.addDefaultValue("True");
071:
072: //constrain undefined
073: ConceptTagConstraint unconstrainedCtcon = rootCtconh
074: .getUndefinedConstraint();
075: //unconstrainedCtcon.setStudioVisibleOnlyOnError(true);
076:
077: //
078: ConceptTagFlagsHelper
079: .pushNonIterativeCommonFunctionDepth(inIctc);
080: inIctc.initialize();
081: ConceptTagFlagsHelper
082: .popNonIterativeCommonFunctionDepth(inIctc);
083:
084: //
085: this .valueCtchar = valueCtcon.getCharacteristic();
086: }
087:
088: public void appraise(AppraiseConceptTagContext inActc) {
089:
090: if (inActc instanceof StudioConceptTagInstanceInfoContext) {
091:
092: StudioConceptTagInstanceInfoContext sctiic = (StudioConceptTagInstanceInfoContext) inActc;
093:
094: String displayValue = "(Unknown)";
095: if (this .valueCtchar.getValueLength() >= 1
096: && this .valueCtchar.isStatic(0, inActc)) {
097: displayValue = this .valueCtchar.getValueAsString(0,
098: inActc);
099: }
100: sctiic.setInstanceTitle(MiscHelper.shortenString(
101: displayValue, 15));
102: sctiic.setInstanceDescription(MiscHelper.shortenString(
103: displayValue, 200));
104: } else if (inActc instanceof StudioConceptTagTypeInfoContext) {
105:
106: StudioConceptTagTypeInfoContext scttic = (StudioConceptTagTypeInfoContext) inActc;
107:
108: scttic.setTypeTitle("Literal Boolean");
109: scttic.setTypeDescription("Boolean with fixed value");
110: } else if (inActc instanceof WebPageTagInstanceViewContext) {
111:
112: WebPageTagInstanceViewContext wptivc = (WebPageTagInstanceViewContext) inActc;
113:
114: WebPageTagInstanceViewContextInfo info = wptivc
115: .getInfoAsNonHtml();
116:
117: info.setNonHtmlContent("Boolean(", ")");
118: WebPageTagInstanceViewContext.displayView(this .valueCtchar,
119: info, wptivc, "???");
120: //info.setEndContent(")");
121: /*
122: String displayValue = "(Unknown)";
123: if (this.valueCtchar.getValueLength() >= 1
124: && this.valueCtchar.isStatic(0, inActc)) {
125: displayValue = this.valueCtchar.getValueAsString(0, inActc);
126: }
127: //wtivc.setStartContent("<!--" + wtivc.getStartContent() + "-->");
128: //wtivc.setEndContent("<!--" + wtivc.getEndContent() + "-->");
129: wptivc.appendContent(displayValue);
130: */
131: //wptivc.getInfo().setStartContent("");
132: //wptivc.getInfo().setMiddleContent(displayValue);
133: //wptivc.getInfo().setEndContent("");
134: } else if (inActc instanceof SelectionCriteriaForReturnableConceptTag) {
135:
136: SelectionCriteriaForReturnableConceptTag scfrct = (SelectionCriteriaForReturnableConceptTag) inActc;
137:
138: scfrct.canReturnBoolean();
139: scfrct.declareFormatAsPlain();
140: } else if (inActc instanceof StudioConceptTagCreParInfoContext) {
141:
142: StudioConceptTagCreParInfoContext scpc = (StudioConceptTagCreParInfoContext) inActc;
143: }
144: }
145:
146: public void determineValueAndClass(
147: DetermineValueAndClassConceptTagContext inDvacctc) {
148:
149: ValueAndClassForConceptTag vacfct = null;
150:
151: vacfct = ValueAndClassForConceptTag.newBoolean(new Boolean(
152: this .valueCtchar.getValueAsString(0, inDvacctc)));
153:
154: inDvacctc.setDetermineValueAndClass(vacfct);
155: }
156:
157: public void determineClass(DetermineClassConceptTagContext inDcctc) {
158:
159: inDcctc.setDetermineClass(StandardDataTypes.getBooleanClass());
160: }
161:
162: public Object createUninitializedSelf() {
163: return new CommonFunctionLiteralBooleanTag();
164: }
165: }
|