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.macro.v1;
009:
010: //base classes
011: import java.util.HashMap;
012:
013: //project specific classes
014: import org.jfolder.common.tagging.AppraiseConceptTagContext;
015: import org.jfolder.common.tagging.CompoundConceptTagConstraintContext;
016: import org.jfolder.common.tagging.ConceptTagCharacteristic;
017: import org.jfolder.common.tagging.ConceptTagCharacteristicHolder;
018: import org.jfolder.common.tagging.ConceptTagConstraint;
019: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
020: import org.jfolder.common.tagging.ConceptTagConstraintTemplate;
021: import org.jfolder.common.tagging.DynamicConceptTagConstraintContext;
022: import org.jfolder.common.tagging.InitializeConceptTagContext;
023: import org.jfolder.common.tagging.RootConceptTagHolder;
024: import org.jfolder.common.tagging.StaticConceptTagConstraintContext;
025: import org.jfolder.common.tagging.StudioConceptTagInstanceInfoContext;
026: import org.jfolder.common.tagging.StudioConceptTagTypeInfoContext;
027: import org.jfolder.common.utils.xml.XMLHelper;
028: import org.jfolder.common.web.template.ConsoleTemplateSession;
029: import org.jfolder.common.web.template.PageSetupContext;
030: import org.jfolder.console.macro.ConsoleMacro;
031: import org.jfolder.console.macro.ConsoleMacroTag;
032: import org.jfolder.console.macro.ConsoleMacroTagHelper;
033:
034: //other classes
035:
036: public class ChangeFormValueConsoleMacroTag implements ConsoleMacroTag {
037:
038: ////characteristics
039: private ConceptTagCharacteristic idCtchar = null;
040: private ConceptTagCharacteristic valueCtchar = null;
041: ////private ConceptTagCharacteristic conceptTagRegistryCtchar = null;
042: //
043: ////pane details
044: //private final static String PANE_CTCON = "pane";
045: //private final static String PANE_TITLE = "Pane";
046: //private final static String PANE_SHORT_DESCRIPTION = "Pane";
047: //
048: ////property details
049: //private final static String PROPERTY_CTCON = "property";
050: //private final static String PROPERTY_TITLE = "Property";
051: //private final static String PROPERTY_SHORT_DESCRIPTION = "Property";
052: //
053: ////name of property details
054: //private final static String PROPERTY_CTCON_NAME_CTCTEMP = "name";
055: //private final static String PROPERTY_CTCON_NAME_TITLE = "Name";
056: //private final static String PROPERTY_CTCON_NAME_SHORT_DESCRIPTION =
057: //"Name";
058: //
059: ////value of property details
060: //private final static String PROPERTY_CTCON_VALUE_CTCTEMP = "value";
061: //private final static String PROPERTY_CTCON_VALUE_TITLE = "Value";
062: //private final static String PROPERTY_CTCON_VALUE_SHORT_DESCRIPTION =
063: // "Value";
064:
065: //id details
066: private final static String ID_CTCON = "id";
067: private final static String ID_TITLE = "ID";
068: private final static String ID_SHORT_DESCRIPTION = "ID";
069:
070: //value details
071: private final static String VALUE_CTCON = "value";
072: private final static String VALUE_TITLE = "Value";
073: private final static String VALUE_SHORT_DESCRIPTION = "Value";
074:
075: ///////////////////////////////////
076:
077: public void initialize(InitializeConceptTagContext inIctc) {
078:
079: //
080: ConceptTagConstraintHolder rootCtconh = ConceptTagConstraintHolder
081: .newInstance(inIctc);
082:
083: //constrain "id"
084: ConceptTagConstraint idCtcon = ConceptTagConstraint
085: .newInstance(ID_CTCON, rootCtconh);
086: idCtcon.setTitle(ID_TITLE);
087: idCtcon.setShortDescription(ID_SHORT_DESCRIPTION);
088: //
089: StaticConceptTagConstraintContext idSctcc = StaticConceptTagConstraintContext
090: .newInstance(idCtcon);
091:
092: //constrain "value"
093: ConceptTagConstraint valueCtcon = ConceptTagConstraint
094: .newInstance(VALUE_CTCON, rootCtconh);
095: valueCtcon.setTitle(VALUE_TITLE);
096: valueCtcon.setShortDescription(VALUE_SHORT_DESCRIPTION);
097: //
098: StaticConceptTagConstraintContext valueSctcc = StaticConceptTagConstraintContext
099: .newInstance(valueCtcon);
100:
101: ////constrain "pane"
102: //ConceptTagConstraint paneCtcon =
103: // ConceptTagConstraint.newInstance(PANE_CTCON, rootCtconh);
104: //paneCtcon.setTitle(PANE_TITLE);
105: //paneCtcon.setShortDescription(PANE_SHORT_DESCRIPTION);
106: ////
107: //DynamicConceptTagConstraintContext paneDctcc =
108: // DynamicConceptTagConstraintContext.newInstance(paneCtcon);
109: ////
110: //paneDctcc.addDefaultValue(UpDownConsoleConfigTag.class);
111: //
112: ////constrain "property"
113: //ConceptTagConstraint propertyCtcon =
114: // ConceptTagConstraint.newInstance(PROPERTY_CTCON, rootCtconh);
115: //propertyCtcon.setTitle(PROPERTY_TITLE);
116: //propertyCtcon.setShortDescription(PROPERTY_SHORT_DESCRIPTION);
117: ////
118: //CompoundConceptTagConstraintContext propertyCctcc =
119: // CompoundConceptTagConstraintContext.newInstance(propertyCtcon);
120: //
121: ////constrain "name" of "property"
122: //ConceptTagConstraintTemplate propertyCtconNameCtctemp =
123: // ConceptTagConstraintTemplate.newInstance(
124: // PROPERTY_CTCON_NAME_CTCTEMP, propertyCctcc);
125: ////
126: //StaticConceptTagConstraintContext propertyCtconNameSctcc =
127: // StaticConceptTagConstraintContext.newInstance(
128: // propertyCtconNameCtctemp);
129: //
130: ////constrain "value" of "property"
131: //ConceptTagConstraintTemplate propertyCtconValueCtctemp =
132: // ConceptTagConstraintTemplate.newInstance(
133: // PROPERTY_CTCON_VALUE_CTCTEMP, propertyCctcc);
134: ////
135: //StaticConceptTagConstraintContext propertyCtconValueSctcc =
136: // StaticConceptTagConstraintContext.newInstance(
137: // propertyCtconValueCtctemp);
138:
139: //
140: inIctc.initialize();
141:
142: //
143: this .idCtchar = idCtcon.getCharacteristic();
144: this .valueCtchar = valueCtcon.getCharacteristic();
145:
146: }
147:
148: //
149: public void appraise(AppraiseConceptTagContext inCtic) {
150: if (inCtic instanceof StudioConceptTagInstanceInfoContext) {
151: StudioConceptTagInstanceInfoContext sctiic = (StudioConceptTagInstanceInfoContext) inCtic;
152: sctiic.setInstanceTitle("Change Form Value");
153: sctiic.setInstanceDescription("Change Form Value");
154: } else if (inCtic instanceof StudioConceptTagTypeInfoContext) {
155: StudioConceptTagTypeInfoContext scttic = (StudioConceptTagTypeInfoContext) inCtic;
156: scttic.setTypeTitle("Change Form Value");
157: scttic.setTypeDescription("Change Form Value");
158: }
159: }
160:
161: //
162: public final static ChangeFormValueConsoleMacroTag newInstance(
163: ConceptTagCharacteristic inCtchar, String inId,
164: String inValue) {
165: //
166: ChangeFormValueConsoleMacroTag outValue = null;
167:
168: outValue = new ChangeFormValueConsoleMacroTag();
169: //
170: ConceptTagCharacteristicHolder nextCtcharh = inCtchar.addValue(
171: inCtchar.getValueLength(), outValue, true);
172: //
173: ConceptTagCharacteristic nextIdCtchar = nextCtcharh
174: .registerCharacteristic(ID_CTCON);
175: nextIdCtchar.addValue(0, inId);
176: //
177: ConceptTagCharacteristic nextValueCtchar = nextCtcharh
178: .registerCharacteristic(VALUE_CTCON);
179: nextValueCtchar.addValue(0, inValue);
180:
181: return outValue;
182: }
183:
184: //
185: public void generateMacroCommands(PageSetupContext inPsc,
186: ConsoleTemplateSession inCts, RootConceptTagHolder inRcth,
187: HashMap inVars, String inFromHandle,
188: String inAliasFromHandle, String inSourcePage,
189: String inDestinationPage) {
190: //
191: String id = this .idCtchar.getValueAsString(0, null);
192: id = ConsoleMacroTagHelper.replaceEnvVars(id, inVars);
193: //
194: String value = this .valueCtchar.getValueAsString(0, null);
195: value = ConsoleMacroTagHelper.replaceEnvVars(id, inVars);
196: value = XMLHelper.fromStringToJSCData(value);
197: //
198: inPsc.addMacroCommand("macroChangeValue('" + id + "', '"
199: + value + "')");
200: }
201: }
|