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.UnexpectedSystemException;
016: import org.jfolder.common.function.BaseCommonFunctionCompatibilityTag;
017: import org.jfolder.common.function.WebPageTagInstanceViewContext;
018: import org.jfolder.common.function.WebPageTagInstanceViewContextInfo;
019: import org.jfolder.common.tagging.AppraiseConceptTagContext;
020: import org.jfolder.common.tagging.ConceptTagCharacteristic;
021: import org.jfolder.common.tagging.ConceptTagConstraint;
022: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
023: import org.jfolder.common.tagging.ConceptTagFlagsHelper;
024: import org.jfolder.common.tagging.DetermineClassConceptTagContext;
025: import org.jfolder.common.tagging.DetermineValueAndClassConceptTagContext;
026: import org.jfolder.common.tagging.DetermineValueAndClassConceptTagException;
027: import org.jfolder.common.tagging.InitializeConceptTagContext;
028: import org.jfolder.common.tagging.SelectionCriteriaForReturnableConceptTag;
029: import org.jfolder.common.tagging.StaticConceptTagConstraintContext;
030: import org.jfolder.common.tagging.StudioConceptTagCreParInfoContext;
031: import org.jfolder.common.tagging.StudioConceptTagInstanceInfoContext;
032: import org.jfolder.common.tagging.StudioConceptTagTypeInfoContext;
033: import org.jfolder.common.tagging.ValueAndClassForConceptTag;
034: import org.jfolder.common.utils.misc.MiscHelper;
035:
036: //other classes
037:
038: public class CommonFunctionActionCommentTag extends
039: BaseCommonFunctionCompatibilityTag implements
040: SelfArgumentlessConstructor {
041:
042: //
043: private ConceptTagCharacteristic messageCtchar = null;
044:
045: //value details
046: private final static String MESSAGE_CTCON = "message";
047: private final static String MESSAGE_TITLE = "Message";
048: private final static String MESSAGE_SHORT_DESCRIPTION = "Comment Message";
049:
050: public void initialize(InitializeConceptTagContext inIctc) {
051: //
052: ConceptTagConstraintHolder rootCtconh = ConceptTagConstraintHolder
053: .newInstance(inIctc);
054: //
055: //constrain "message"
056: ConceptTagConstraint messageCtcon = ConceptTagConstraint
057: .newInstance(MESSAGE_CTCON, rootCtconh);
058: messageCtcon.setTitle(MESSAGE_TITLE);
059: messageCtcon.setShortDescription(MESSAGE_SHORT_DESCRIPTION);
060: //
061: StaticConceptTagConstraintContext messageSctcc = StaticConceptTagConstraintContext
062: .newInstance(messageCtcon);
063: //
064: messageCtcon.setMinimumLength(1);
065: messageCtcon.setMaximumLength(1);
066: //
067: messageSctcc.addDefaultValue("Put your comment here");
068:
069: //
070: ConceptTagFlagsHelper
071: .pushNonIterativeCommonFunctionDepth(inIctc);
072: inIctc.initialize();
073: ConceptTagFlagsHelper
074: .popNonIterativeCommonFunctionDepth(inIctc);
075:
076: //
077: this .messageCtchar = messageCtcon.getCharacteristic();
078: }
079:
080: public void appraise(AppraiseConceptTagContext inActc) {
081:
082: if (inActc instanceof StudioConceptTagInstanceInfoContext) {
083:
084: StudioConceptTagInstanceInfoContext sctiic = (StudioConceptTagInstanceInfoContext) inActc;
085:
086: String displayValue = this .messageCtchar.getValueAsString(
087: 0, null);
088: //
089: sctiic.setInstanceTitle(MiscHelper.shortenString(
090: displayValue, 15));
091: sctiic.setInstanceDescription(MiscHelper.shortenString(
092: displayValue, 200));
093: } else if (inActc instanceof StudioConceptTagTypeInfoContext) {
094:
095: StudioConceptTagTypeInfoContext scttic = (StudioConceptTagTypeInfoContext) inActc;
096:
097: scttic.setTypeTitle("Comment");
098: scttic.setTypeDescription("Comment");
099: } else if (inActc instanceof WebPageTagInstanceViewContext) {
100:
101: WebPageTagInstanceViewContext wptivc = (WebPageTagInstanceViewContext) inActc;
102:
103: WebPageTagInstanceViewContextInfo info = wptivc
104: .getInfoAsNonHtml();
105: info.setNonHtmlContent("Comment - Not Impl");
106: //wptivc.appendContent("");
107: //wptivc.getInfo().setStartContent("");
108: //wptivc.getInfo().setMiddleContent("");
109: //wptivc.getInfo().setEndContent("");
110: } else if (inActc instanceof SelectionCriteriaForReturnableConceptTag) {
111:
112: SelectionCriteriaForReturnableConceptTag scfrct = (SelectionCriteriaForReturnableConceptTag) inActc;
113:
114: scfrct.canReturnNothing();
115: scfrct.declareFormatAsPlain();
116: } else if (inActc instanceof StudioConceptTagCreParInfoContext) {
117:
118: StudioConceptTagCreParInfoContext scpc = (StudioConceptTagCreParInfoContext) inActc;
119: }
120: }
121:
122: public void determineValueAndClass(
123: DetermineValueAndClassConceptTagContext inDvacctc) {
124:
125: inDvacctc.setDetermineValueAndClass(ValueAndClassForConceptTag
126: .newNothing());
127: }
128:
129: public void determineClass(DetermineClassConceptTagContext inDcctc) {
130:
131: inDcctc.setDetermineClass(StandardDataTypes.getNothingClass());
132: }
133:
134: public Object createUninitializedSelf() {
135: return new CommonFunctionActionCommentTag();
136: }
137: }
|