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.ArrayList;
012: import java.util.HashMap;
013:
014: //project specific classes
015: import org.jfolder.common.tagging.AppraiseConceptTagContext;
016: import org.jfolder.common.tagging.CompoundConceptTagConstraintContext;
017: import org.jfolder.common.tagging.ConceptTagCharacteristic;
018: import org.jfolder.common.tagging.ConceptTagCharacteristicHolder;
019: import org.jfolder.common.tagging.ConceptTagConstraint;
020: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
021: import org.jfolder.common.tagging.ConceptTagConstraintTemplate;
022: import org.jfolder.common.tagging.DynamicConceptTagConstraintContext;
023: import org.jfolder.common.tagging.InitializeConceptTagContext;
024: import org.jfolder.common.tagging.RootConceptTagHolder;
025: import org.jfolder.common.tagging.StaticConceptTagConstraintContext;
026: import org.jfolder.common.tagging.StudioConceptTagInstanceInfoContext;
027: import org.jfolder.common.tagging.StudioConceptTagTypeInfoContext;
028: import org.jfolder.common.utils.xml.XMLHelper;
029: import org.jfolder.common.web.template.BaseActionContext;
030: import org.jfolder.common.web.template.ConsoleParameterHolder;
031: import org.jfolder.common.web.template.ConsoleTemplateFunctionsContext;
032: import org.jfolder.common.web.template.ConsoleTemplateSession;
033: import org.jfolder.common.web.template.PageSetupContext;
034: import org.jfolder.common.web.template.RecordActionContext;
035: import org.jfolder.common.web.template.SubmitActionContext;
036: import org.jfolder.console.macro.ConsoleMacro;
037: import org.jfolder.console.macro.ConsoleMacroTag;
038: import org.jfolder.console.macro.ConsoleMacroTagHelper;
039:
040: //other classes
041:
042: public class SubmitActionConsoleMacroTag implements ConsoleMacroTag {
043:
044: ////characteristics
045: private ConceptTagCharacteristic actionCtchar = null;
046: private ConceptTagCharacteristic parameterCtchar = null;
047: ////private ConceptTagCharacteristic conceptTagRegistryCtchar = null;
048: //
049: ////pane details
050: //private final static String PANE_CTCON = "pane";
051: //private final static String PANE_TITLE = "Pane";
052: //private final static String PANE_SHORT_DESCRIPTION = "Pane";
053: //
054: ////property details
055: //private final static String PROPERTY_CTCON = "property";
056: //private final static String PROPERTY_TITLE = "Property";
057: //private final static String PROPERTY_SHORT_DESCRIPTION = "Property";
058: //
059: ////name of property details
060: //private final static String PROPERTY_CTCON_NAME_CTCTEMP = "name";
061: //private final static String PROPERTY_CTCON_NAME_TITLE = "Name";
062: //private final static String PROPERTY_CTCON_NAME_SHORT_DESCRIPTION =
063: //"Name";
064: //
065: ////value of property details
066: //private final static String PROPERTY_CTCON_VALUE_CTCTEMP = "value";
067: //private final static String PROPERTY_CTCON_VALUE_TITLE = "Value";
068: //private final static String PROPERTY_CTCON_VALUE_SHORT_DESCRIPTION =
069: // "Value";
070:
071: //action details
072: private final static String ACTION_CTCON = "action";
073: private final static String ACTION_TITLE = "Action";
074: private final static String ACTION_SHORT_DESCRIPTION = "Action";
075:
076: //parameter details
077: private final static String PARAMETER_CTCON = "parameter";
078: private final static String PARAMETER_TITLE = "Parameter";
079: private final static String PARAMETER_SHORT_DESCRIPTION = "Parameter";
080:
081: ///////////////////////////////////
082:
083: public void initialize(InitializeConceptTagContext inIctc) {
084:
085: //
086: ConceptTagConstraintHolder rootCtconh = ConceptTagConstraintHolder
087: .newInstance(inIctc);
088:
089: //constrain "action"
090: ConceptTagConstraint actionCtcon = ConceptTagConstraint
091: .newInstance(ACTION_CTCON, rootCtconh);
092: actionCtcon.setTitle(ACTION_TITLE);
093: actionCtcon.setShortDescription(ACTION_SHORT_DESCRIPTION);
094: //
095: StaticConceptTagConstraintContext actionSctcc = StaticConceptTagConstraintContext
096: .newInstance(actionCtcon);
097:
098: //constrain "parameter"
099: ConceptTagConstraint parameterCtcon = ConceptTagConstraint
100: .newInstance(PARAMETER_CTCON, rootCtconh);
101: parameterCtcon.setTitle(PARAMETER_TITLE);
102: parameterCtcon.setShortDescription(PARAMETER_SHORT_DESCRIPTION);
103: //
104: StaticConceptTagConstraintContext parameterSctcc = StaticConceptTagConstraintContext
105: .newInstance(parameterCtcon);
106:
107: ////constrain "pane"
108: //ConceptTagConstraint paneCtcon =
109: // ConceptTagConstraint.newInstance(PANE_CTCON, rootCtconh);
110: //paneCtcon.setTitle(PANE_TITLE);
111: //paneCtcon.setShortDescription(PANE_SHORT_DESCRIPTION);
112: ////
113: //DynamicConceptTagConstraintContext paneDctcc =
114: // DynamicConceptTagConstraintContext.newInstance(paneCtcon);
115: ////
116: //paneDctcc.addDefaultValue(UpDownConsoleConfigTag.class);
117: //
118: ////constrain "property"
119: //ConceptTagConstraint propertyCtcon =
120: // ConceptTagConstraint.newInstance(PROPERTY_CTCON, rootCtconh);
121: //propertyCtcon.setTitle(PROPERTY_TITLE);
122: //propertyCtcon.setShortDescription(PROPERTY_SHORT_DESCRIPTION);
123: ////
124: //CompoundConceptTagConstraintContext propertyCctcc =
125: // CompoundConceptTagConstraintContext.newInstance(propertyCtcon);
126: //
127: ////constrain "name" of "property"
128: //ConceptTagConstraintTemplate propertyCtconNameCtctemp =
129: // ConceptTagConstraintTemplate.newInstance(
130: // PROPERTY_CTCON_NAME_CTCTEMP, propertyCctcc);
131: ////
132: //StaticConceptTagConstraintContext propertyCtconNameSctcc =
133: // StaticConceptTagConstraintContext.newInstance(
134: // propertyCtconNameCtctemp);
135: //
136: ////constrain "value" of "property"
137: //ConceptTagConstraintTemplate propertyCtconValueCtctemp =
138: // ConceptTagConstraintTemplate.newInstance(
139: // PROPERTY_CTCON_VALUE_CTCTEMP, propertyCctcc);
140: ////
141: //StaticConceptTagConstraintContext propertyCtconValueSctcc =
142: // StaticConceptTagConstraintContext.newInstance(
143: // propertyCtconValueCtctemp);
144:
145: //
146: inIctc.initialize();
147:
148: //
149: this .actionCtchar = actionCtcon.getCharacteristic();
150: this .parameterCtchar = parameterCtcon.getCharacteristic();
151:
152: }
153:
154: //
155: public void appraise(AppraiseConceptTagContext inCtic) {
156: if (inCtic instanceof StudioConceptTagInstanceInfoContext) {
157: StudioConceptTagInstanceInfoContext sctiic = (StudioConceptTagInstanceInfoContext) inCtic;
158: sctiic.setInstanceTitle("Submit Action");
159: sctiic.setInstanceDescription("Submit Action");
160: } else if (inCtic instanceof StudioConceptTagTypeInfoContext) {
161: StudioConceptTagTypeInfoContext scttic = (StudioConceptTagTypeInfoContext) inCtic;
162: scttic.setTypeTitle("Submit Action");
163: scttic.setTypeDescription("Submit Action");
164: }
165: }
166:
167: //
168: public final static SubmitActionConsoleMacroTag newInstance(
169: ConceptTagCharacteristic inCtchar, BaseActionContext inRac) {
170: //
171: SubmitActionConsoleMacroTag outValue = null;
172:
173: outValue = new SubmitActionConsoleMacroTag();
174: //
175: ConceptTagCharacteristicHolder nextCtcharh = inCtchar.addValue(
176: inCtchar.getValueLength(), outValue, true);
177: //
178: ConceptTagCharacteristic nextActionCtchar = nextCtcharh
179: .registerCharacteristic(ACTION_CTCON);
180: //
181: ArrayList indexes = ConsoleParameterHolder.getIndexes();
182: for (int i = 0; i < inRac.getActionCount(); i++) {
183: Integer nextIndex = ((Integer) indexes.get(i));
184: nextActionCtchar.addValue(nextIndex.intValue(), inRac
185: .getAction(nextIndex));
186: }
187: //nextActionCtchar.addValue(0, inRac.getFirstAction());
188: //nextActionCtchar.addValue(1, inRac.getSecondAction());
189: //nextActionCtchar.addValue(2, inRac.getThirdAction());
190: //
191: ConceptTagCharacteristic nextParameterCtchar = nextCtcharh
192: .registerCharacteristic(PARAMETER_CTCON);
193: for (int i = 0; i < inRac.getParameterCount(); i++) {
194: Integer nextIndex = ((Integer) indexes.get(i));
195: nextParameterCtchar.addValue(nextIndex.intValue(), inRac
196: .getParameter(nextIndex));
197: }
198: //nextParameterCtchar.addValue(0, inRac.getFirstParameter());
199: //nextParameterCtchar.addValue(1, inRac.getSecondParameter());
200: //nextParameterCtchar.addValue(2, inRac.getThirdParameter());
201: //nextParameterCtchar.addValue(3, inRac.getFourthParameter());
202: //nextParameterCtchar.addValue(4, inRac.getFifthParameter());
203: //nextParameterCtchar.addValue(5, inRac.getSixthParameter());
204: //nextParameterCtchar.addValue(6, inRac.getSeventhParameter());
205: //nextParameterCtchar.addValue(7, inRac.getEighthParameter());
206: //nextParameterCtchar.addValue(8, inRac.getNinthParameter());
207: //nextParameterCtchar.addValue(9, inRac.getTenthParameter());
208:
209: return outValue;
210: }
211:
212: //
213: public void generateMacroCommands(PageSetupContext inPsc,
214: ConsoleTemplateSession inCts, RootConceptTagHolder inRcth,
215: HashMap inVars, String inFromHandle,
216: String inAliasFromHandle, String inSourcePage,
217: String inDestinationPage) {
218: //
219: //String id = this.idCtchar.getValueAsString(0);
220: //
221: //String value = this.valueCtchar.getValueAsString(0);
222: //
223: ArrayList indexes = ConsoleParameterHolder.getIndexes();
224: //
225: SubmitActionContext sac = SubmitActionContext.newInstance(
226: ConsoleMacroTagHelper.replaceEnvVars(inSourcePage,
227: inVars), ConsoleMacroTagHelper.replaceEnvVars(
228: inFromHandle, inVars), ConsoleMacroTagHelper
229: .replaceEnvVars(inAliasFromHandle, inVars));
230: sac.setGoToPage(ConsoleMacroTagHelper.replaceEnvVars(
231: inDestinationPage, inVars));
232: //
233: for (int i = 0; i < this .actionCtchar.getValueLength(); i++) {
234: Integer nextIndex = ((Integer) indexes.get(i));
235: String s = this .actionCtchar.getValueAsString(nextIndex
236: .intValue(), null);
237: s = ConsoleMacroTagHelper.replaceEnvVars(s, inVars);
238: s = XMLHelper.fromStringToJSCData(s);
239: sac.addAction(nextIndex, ConsoleTemplateFunctionsContext
240: .singleQuotes(s));
241: }
242: //sac.setFirstAction(ConsoleTemplateFunctionsContext.singleQuotes(
243: // this.actionCtchar.getValueAsString(0)));
244: //sac.setSecondAction(ConsoleTemplateFunctionsContext.singleQuotes(
245: // this.actionCtchar.getValueAsString(1)));
246: //sac.setThirdAction(ConsoleTemplateFunctionsContext.singleQuotes(
247: // this.actionCtchar.getValueAsString(2)));
248: //
249: for (int i = 0; i < this .parameterCtchar.getValueLength(); i++) {
250: Integer nextIndex = ((Integer) indexes.get(i));
251: String s = this .parameterCtchar.getValueAsString(nextIndex
252: .intValue(), null);
253: s = ConsoleMacroTagHelper.replaceEnvVars(s, inVars);
254: s = XMLHelper.fromStringToJSCData(s);
255: sac.addParameter(nextIndex, ConsoleTemplateFunctionsContext
256: .singleQuotes(s));
257: }
258: //sac.setFirstParameter(ConsoleTemplateFunctionsContext.singleQuotes(
259: // this.parameterCtchar.getValueAsString(0)));
260: //sac.setSecondParameter(ConsoleTemplateFunctionsContext.singleQuotes(
261: // this.parameterCtchar.getValueAsString(1)));
262: //sac.setThirdParameter(ConsoleTemplateFunctionsContext.singleQuotes(
263: // this.parameterCtchar.getValueAsString(2)));
264: //sac.setFourthParameter(ConsoleTemplateFunctionsContext.singleQuotes(
265: // this.parameterCtchar.getValueAsString(3)));
266: //sac.setFifthParameter(ConsoleTemplateFunctionsContext.singleQuotes(
267: // this.parameterCtchar.getValueAsString(4)));
268: //sac.setSixthParameter(ConsoleTemplateFunctionsContext.singleQuotes(
269: // this.parameterCtchar.getValueAsString(5)));
270: //sac.setSeventhParameter(ConsoleTemplateFunctionsContext.singleQuotes(
271: // this.parameterCtchar.getValueAsString(6)));
272: //sac.setEighthParameter(ConsoleTemplateFunctionsContext.singleQuotes(
273: // this.parameterCtchar.getValueAsString(7)));
274: //sac.setNinthParameter(ConsoleTemplateFunctionsContext.singleQuotes(
275: // this.parameterCtchar.getValueAsString(8)));
276: //sac.setTenthParameter(ConsoleTemplateFunctionsContext.singleQuotes(
277: // this.parameterCtchar.getValueAsString(9)));
278: //
279: inPsc.addMacroCommand(sac.submitActionCall(false));
280: }
281: }
|