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: import java.util.Properties;
012:
013: //project specific classes
014: import org.jfolder.common.SelfArgumentlessConstructor;
015: import org.jfolder.common.StandardDataTypes;
016: import org.jfolder.common.UnexpectedSystemException;
017: import org.jfolder.common.function.BaseCommonFunctionCompatibilityTag;
018: import org.jfolder.common.function.ComponentsForReturnableWebPageTag;
019: import org.jfolder.common.function.WebPageTagHelper;
020: import org.jfolder.common.function.WebPageTagInstanceViewContext;
021: import org.jfolder.common.function.WebPageTagInstanceViewContextInfo;
022: import org.jfolder.common.tagging.AppraiseConceptTagContext;
023: import org.jfolder.common.tagging.ConceptTagCharacteristic;
024: import org.jfolder.common.tagging.ConceptTagConstraint;
025: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
026: import org.jfolder.common.tagging.ConceptTagFlagsHelper;
027: import org.jfolder.common.tagging.DetermineClassConceptTagContext;
028: import org.jfolder.common.tagging.DetermineValueAndClassConceptTagContext;
029: import org.jfolder.common.tagging.DetermineValueAndClassConceptTagException;
030: import org.jfolder.common.tagging.DynamicConceptTagConstraintContext;
031: import org.jfolder.common.tagging.InitializeConceptTagContext;
032: import org.jfolder.common.tagging.SelectionCriteriaForReturnableConceptTag;
033: import org.jfolder.common.tagging.StaticConceptTagConstraintContext;
034: import org.jfolder.common.tagging.StudioConceptTagCreParInfoContext;
035: import org.jfolder.common.tagging.StudioConceptTagInstanceInfoContext;
036: import org.jfolder.common.tagging.StudioConceptTagTypeInfoContext;
037: import org.jfolder.common.tagging.ValueAndClassForConceptTag;
038: import org.jfolder.common.utils.misc.MiscHelper;
039:
040: //other classes
041:
042: public class CommonFunctionPropGetPropertyTag extends
043: BaseCommonFunctionCompatibilityTag implements
044: SelfArgumentlessConstructor {
045:
046: //
047: private ConceptTagCharacteristic nameCtchar = null;
048:
049: //value details
050: private final static String NAME_CTCON = "name";
051: private final static String NAME_TITLE = "Name";
052: private final static String NAME_SHORT_DESCRIPTION = "Name of the application property";
053:
054: public void initialize(InitializeConceptTagContext inIctc) {
055:
056: //
057: ConceptTagConstraintHolder rootCtconh = ConceptTagConstraintHolder
058: .newInstance(inIctc);
059: //
060: //rootCtconh.getAttributes().setStudioVisibleOnlyOnError(true);
061: //rootCtconh.getStyles().setStudioVisibleOnlyOnError(true);
062:
063: //constrain "name"
064: ConceptTagConstraint nameCtcon = ConceptTagConstraint
065: .newInstance(NAME_CTCON, rootCtconh);
066: nameCtcon.setTitle(NAME_TITLE);
067: nameCtcon.setShortDescription(NAME_SHORT_DESCRIPTION);
068: //
069: StaticConceptTagConstraintContext nameSctcc = StaticConceptTagConstraintContext
070: .newInstance(nameCtcon);
071: //
072: nameSctcc.addDefaultValue("PropertyName");
073:
074: //constrain undefined
075: ConceptTagConstraint unconstrainedCtcon = rootCtconh
076: .getUndefinedConstraint();
077: //unconstrainedCtcon.setStudioVisibleOnlyOnError(true);
078:
079: //
080: ConceptTagFlagsHelper
081: .pushNonIterativeCommonFunctionDepth(inIctc);
082: inIctc.initialize();
083: ConceptTagFlagsHelper
084: .popNonIterativeCommonFunctionDepth(inIctc);
085:
086: //
087: this .nameCtchar = nameCtcon.getCharacteristic();
088: }
089:
090: public void appraise(AppraiseConceptTagContext inActc) {
091:
092: if (inActc instanceof StudioConceptTagInstanceInfoContext) {
093:
094: StudioConceptTagInstanceInfoContext sctiic = (StudioConceptTagInstanceInfoContext) inActc;
095:
096: String displayValue = "Unknown";
097: if (this .nameCtchar.getValueLength() >= 1
098: && this .nameCtchar.isStatic(0, inActc)) {
099: displayValue = this .nameCtchar.getValueAsString(0,
100: inActc);
101: }
102: displayValue = ("GetAppProp(" + displayValue + ")");
103: sctiic.setInstanceTitle(MiscHelper.shortenString(
104: displayValue, 15));
105: sctiic.setInstanceDescription(MiscHelper.shortenString(
106: displayValue, 200));
107: } else if (inActc instanceof StudioConceptTagTypeInfoContext) {
108:
109: StudioConceptTagTypeInfoContext scttic = (StudioConceptTagTypeInfoContext) inActc;
110:
111: scttic.setTypeTitle("Get Application Property");
112: scttic.setTypeDescription("Get Application Property");
113: } else if (inActc instanceof WebPageTagInstanceViewContext) {
114:
115: WebPageTagInstanceViewContext wptivc = (WebPageTagInstanceViewContext) inActc;
116:
117: String displayValue = "Unknown";
118: if (this .nameCtchar.getValueLength() >= 1
119: && this .nameCtchar.isStatic(0, inActc)) {
120: displayValue = this .nameCtchar.getValueAsString(0,
121: inActc);
122: }
123: displayValue = ("GetAppProp(" + displayValue + ")");
124: //wtivc.setStartContent("<!--" + wtivc.getStartContent() + "-->");
125: //wtivc.setEndContent("<!--" + wtivc.getEndContent() + "-->");
126: WebPageTagInstanceViewContextInfo info = wptivc
127: .getInfoAsNonHtml();
128: //
129: info.setNonHtmlContent("GetProp - Not Impl");
130: //
131: //
132: //wtivc.getInfo().setStartContent("");
133: //wtivc.getInfo().setMiddleContent(displayValue);
134: //wtivc.getInfo().setEndContent("");
135: } else if (inActc instanceof SelectionCriteriaForReturnableConceptTag) {
136:
137: SelectionCriteriaForReturnableConceptTag scfrct = (SelectionCriteriaForReturnableConceptTag) inActc;
138:
139: scfrct.canReturnString();
140: scfrct.declareFormatAsPlain();
141: } else if (inActc instanceof StudioConceptTagCreParInfoContext) {
142:
143: StudioConceptTagCreParInfoContext scpc = (StudioConceptTagCreParInfoContext) inActc;
144: }
145: }
146:
147: public void determineValueAndClass(
148: DetermineValueAndClassConceptTagContext inDvacctc) {
149:
150: ValueAndClassForConceptTag vacfct = null;
151:
152: //WorkflowLifecycle wl =
153: //WorkflowLifecycleFactory.getWorkflowLifecycle();
154:
155: //ComponentsForReturnableWebPageTag cfrwt =
156: // WebPageTagHelper.getComponentsForReturnableWebPageTag(inDvacctc);
157:
158: String appName = null;//cfrwt.getApplicationName();
159: String propName = this .nameCtchar
160: .getValueAsString(0, inDvacctc);
161:
162: if (true) {
163: throw UnexpectedSystemException.notImplemented();
164: }
165: Properties props = null;//wsc.getApplicationProperties(appName);
166:
167: vacfct = ValueAndClassForConceptTag.newString(props
168: .getProperty(propName));
169:
170: //wl.close();
171:
172: inDvacctc.setDetermineValueAndClass(vacfct);
173: }
174:
175: public void determineClass(DetermineClassConceptTagContext inDcctc) {
176:
177: inDcctc.setDetermineClass(StandardDataTypes.getStringClass());
178: }
179:
180: public Object createUninitializedSelf() {
181: return new CommonFunctionPropGetPropertyTag();
182: }
183: }
|