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