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.web.template.ConsoleTemplateSession;
028: import org.jfolder.common.web.template.PageSetupContext;
029: import org.jfolder.console.macro.ConsoleMacro;
030: import org.jfolder.console.macro.ConsoleMacroTag;
031: import org.jfolder.console.macro.ConsoleMacroTagHelper;
032:
033: //other classes
034:
035: public class OpenSectionIfClosedConsoleMacroTag implements
036: ConsoleMacroTag {
037:
038: //source-id details
039: private final static String SOURCE_ID_CTCON = "source-id";
040: private final static String SOURCE_ID_TITLE = "Source ID";
041: private final static String SOURCE_ID_SHORT_DESCRIPTION = "Source ID";
042:
043: //target-id details
044: private final static String TARGET_ID_CTCON = "target-id";
045: private final static String TARGET_ID_TITLE = "Target ID";
046: private final static String TARGET_ID_SHORT_DESCRIPTION = "Target ID";
047:
048: //target-image-id details
049: private final static String TARGET_IMAGE_ID_CTCON = "target-image-id";
050: private final static String TARGET_IMAGE_ID_TITLE = "Target Image ID";
051: private final static String TARGET_IMAGE_ID_SHORT_DESCRIPTION = "Target Image ID";
052:
053: //target-image details
054: private final static String TARGET_IMAGE_CTCON = "target-image";
055: private final static String TARGET_IMAGE_TITLE = "Target Image";
056: private final static String TARGET_IMAGE_SHORT_DESCRIPTION = "Target Image";
057:
058: //characteristics
059: private ConceptTagCharacteristic sourceIdCtchar = null;
060: private ConceptTagCharacteristic targetIdCtchar = null;
061: private ConceptTagCharacteristic targetImageIdCtchar = null;
062: private ConceptTagCharacteristic targetImageCtchar = null;
063:
064: ////characteristics
065: ////private ConceptTagCharacteristic conceptTagRegistryCtchar = null;
066: //
067: ////pane details
068: //private final static String PANE_CTCON = "pane";
069: //private final static String PANE_TITLE = "Pane";
070: //private final static String PANE_SHORT_DESCRIPTION = "Pane";
071: //
072: ////property details
073: //private final static String PROPERTY_CTCON = "property";
074: //private final static String PROPERTY_TITLE = "Property";
075: //private final static String PROPERTY_SHORT_DESCRIPTION = "Property";
076: //
077: ////name of property details
078: //private final static String PROPERTY_CTCON_NAME_CTCTEMP = "name";
079: //private final static String PROPERTY_CTCON_NAME_TITLE = "Name";
080: //private final static String PROPERTY_CTCON_NAME_SHORT_DESCRIPTION =
081: //"Name";
082: //
083: ////value of property details
084: //private final static String PROPERTY_CTCON_VALUE_CTCTEMP = "value";
085: //private final static String PROPERTY_CTCON_VALUE_TITLE = "Value";
086: //private final static String PROPERTY_CTCON_VALUE_SHORT_DESCRIPTION =
087: // "Value";
088:
089: ///////////////////////////////////
090:
091: public void initialize(InitializeConceptTagContext inIctc) {
092:
093: //
094: ConceptTagConstraintHolder rootCtconh = ConceptTagConstraintHolder
095: .newInstance(inIctc);
096:
097: //constrain "source-id"
098: ConceptTagConstraint sourceIdCtcon = ConceptTagConstraint
099: .newInstance(SOURCE_ID_CTCON, rootCtconh);
100: sourceIdCtcon.setTitle(SOURCE_ID_TITLE);
101: sourceIdCtcon.setShortDescription(SOURCE_ID_SHORT_DESCRIPTION);
102: //
103: StaticConceptTagConstraintContext sourceIdSctcc = StaticConceptTagConstraintContext
104: .newInstance(sourceIdCtcon);
105:
106: //constrain "target-id"
107: ConceptTagConstraint targetIdCtcon = ConceptTagConstraint
108: .newInstance(TARGET_ID_CTCON, rootCtconh);
109: targetIdCtcon.setTitle(TARGET_ID_TITLE);
110: targetIdCtcon.setShortDescription(TARGET_ID_SHORT_DESCRIPTION);
111: //
112: StaticConceptTagConstraintContext targetIdSctcc = StaticConceptTagConstraintContext
113: .newInstance(targetIdCtcon);
114:
115: //constrain "target-image-id"
116: ConceptTagConstraint targetImageIdCtcon = ConceptTagConstraint
117: .newInstance(TARGET_IMAGE_ID_CTCON, rootCtconh);
118: targetImageIdCtcon.setTitle(TARGET_IMAGE_ID_TITLE);
119: targetImageIdCtcon
120: .setShortDescription(TARGET_IMAGE_ID_SHORT_DESCRIPTION);
121: //
122: StaticConceptTagConstraintContext targetImageIdSctcc = StaticConceptTagConstraintContext
123: .newInstance(targetImageIdCtcon);
124:
125: //constrain "target-image"
126: ConceptTagConstraint targetImageCtcon = ConceptTagConstraint
127: .newInstance(TARGET_IMAGE_CTCON, rootCtconh);
128: targetImageCtcon.setTitle(TARGET_IMAGE_TITLE);
129: targetImageCtcon
130: .setShortDescription(TARGET_IMAGE_SHORT_DESCRIPTION);
131: //
132: StaticConceptTagConstraintContext targetImageSctcc = StaticConceptTagConstraintContext
133: .newInstance(targetImageCtcon);
134:
135: ////constrain "pane"
136: //ConceptTagConstraint paneCtcon =
137: // ConceptTagConstraint.newInstance(PANE_CTCON, rootCtconh);
138: //paneCtcon.setTitle(PANE_TITLE);
139: //paneCtcon.setShortDescription(PANE_SHORT_DESCRIPTION);
140: ////
141: //DynamicConceptTagConstraintContext paneDctcc =
142: // DynamicConceptTagConstraintContext.newInstance(paneCtcon);
143: ////
144: //paneDctcc.addDefaultValue(UpDownConsoleConfigTag.class);
145: //
146: ////constrain "property"
147: //ConceptTagConstraint propertyCtcon =
148: // ConceptTagConstraint.newInstance(PROPERTY_CTCON, rootCtconh);
149: //propertyCtcon.setTitle(PROPERTY_TITLE);
150: //propertyCtcon.setShortDescription(PROPERTY_SHORT_DESCRIPTION);
151: ////
152: //CompoundConceptTagConstraintContext propertyCctcc =
153: // CompoundConceptTagConstraintContext.newInstance(propertyCtcon);
154: //
155: ////constrain "name" of "property"
156: //ConceptTagConstraintTemplate propertyCtconNameCtctemp =
157: // ConceptTagConstraintTemplate.newInstance(
158: // PROPERTY_CTCON_NAME_CTCTEMP, propertyCctcc);
159: ////
160: //StaticConceptTagConstraintContext propertyCtconNameSctcc =
161: // StaticConceptTagConstraintContext.newInstance(
162: // propertyCtconNameCtctemp);
163: //
164: ////constrain "value" of "property"
165: //ConceptTagConstraintTemplate propertyCtconValueCtctemp =
166: // ConceptTagConstraintTemplate.newInstance(
167: // PROPERTY_CTCON_VALUE_CTCTEMP, propertyCctcc);
168: ////
169: //StaticConceptTagConstraintContext propertyCtconValueSctcc =
170: // StaticConceptTagConstraintContext.newInstance(
171: // propertyCtconValueCtctemp);
172:
173: //
174: inIctc.initialize();
175:
176: //
177: this .sourceIdCtchar = sourceIdCtcon.getCharacteristic();
178: this .targetIdCtchar = targetIdCtcon.getCharacteristic();
179: this .targetImageIdCtchar = targetImageIdCtcon
180: .getCharacteristic();
181: this .targetImageCtchar = targetImageCtcon.getCharacteristic();
182: //this.conceptTagRegistryCtchar =
183: // conceptTagRegistryCtcon.getCharacteristic();
184:
185: }
186:
187: //
188: public void appraise(AppraiseConceptTagContext inCtic) {
189: if (inCtic instanceof StudioConceptTagInstanceInfoContext) {
190: StudioConceptTagInstanceInfoContext sctiic = (StudioConceptTagInstanceInfoContext) inCtic;
191: sctiic.setInstanceTitle("Open Section If Closed");
192: sctiic.setInstanceDescription("Open Section If Closed");
193: } else if (inCtic instanceof StudioConceptTagTypeInfoContext) {
194: StudioConceptTagTypeInfoContext scttic = (StudioConceptTagTypeInfoContext) inCtic;
195: scttic.setTypeTitle("Open Section If Closed");
196: scttic.setTypeDescription("Open Section If Closed");
197: }
198: }
199:
200: //
201: public final static OpenSectionIfClosedConsoleMacroTag newInstance(
202: ConceptTagCharacteristic inCtchar, String inSourceId,
203: String inTargetId) {
204: //
205: return newInstance(inCtchar, inSourceId, inTargetId, null, null);
206: }
207:
208: public final static OpenSectionIfClosedConsoleMacroTag newInstance(
209: ConceptTagCharacteristic inCtchar, String inSourceId,
210: String inTargetId, String inTargetImageId,
211: String inTargetImage) {
212: //
213: OpenSectionIfClosedConsoleMacroTag outValue = null;
214:
215: outValue = new OpenSectionIfClosedConsoleMacroTag();
216: //
217: ConceptTagCharacteristicHolder nextCtcharh = inCtchar.addValue(
218: inCtchar.getValueLength(), outValue, true);
219: //
220: ConceptTagCharacteristic nextSourceIdCtchar = nextCtcharh
221: .registerCharacteristic(SOURCE_ID_CTCON);
222: nextSourceIdCtchar.addValue(0, inSourceId);
223: //
224: ConceptTagCharacteristic nextTargetIdCtchar = nextCtcharh
225: .registerCharacteristic(TARGET_ID_CTCON);
226: nextTargetIdCtchar.addValue(0, inTargetId);
227: //
228: if (inTargetImage != null) {
229: ConceptTagCharacteristic nextTargetImageCtchar = nextCtcharh
230: .registerCharacteristic(TARGET_IMAGE_CTCON);
231: nextTargetImageCtchar.addValue(0, inTargetImage);
232: }
233: //
234: if (inTargetImageId != null) {
235: ConceptTagCharacteristic nextTargetImageIdCtchar = nextCtcharh
236: .registerCharacteristic(TARGET_IMAGE_ID_CTCON);
237: nextTargetImageIdCtchar.addValue(0, inTargetImageId);
238: }
239:
240: return outValue;
241: }
242:
243: //
244: public void generateMacroCommands(PageSetupContext inPsc,
245: ConsoleTemplateSession inCts, RootConceptTagHolder inRcth,
246: HashMap inVars, String inFromHandle,
247: String inAliasFromHandle, String inSourcePage,
248: String inDestinationPage) {
249: //
250: String sourceId = this .sourceIdCtchar.getValueAsString(0, null);
251: sourceId = ConsoleMacroTagHelper.replaceEnvVars(sourceId,
252: inVars);
253: //
254: String targetId = this .targetIdCtchar.getValueAsString(0, null);
255: targetId = ConsoleMacroTagHelper.replaceEnvVars(targetId,
256: inVars);
257: //
258: String targetImage = null;
259: if (this .targetImageCtchar.getValueLength() > 0) {
260: targetImage = this .targetImageCtchar.getValueAsString(0,
261: null);
262: targetImage = ConsoleMacroTagHelper.replaceEnvVars(
263: targetImage, inVars);
264: }
265: String targetImageId = null;
266: if (this .targetImageIdCtchar.getValueLength() > 0) {
267: targetImageId = this .targetImageIdCtchar.getValueAsString(
268: 0, null);
269: targetImageId = ConsoleMacroTagHelper.replaceEnvVars(
270: targetImageId, inVars);
271: }
272: //
273: //String value = this.valueCtchar.getValueAsString(0);
274: //
275: //
276: inPsc.addMacroCommand("macroGoToIfClosed('" + sourceId + "', '"
277: + targetId + "')");
278: //
279: inPsc.addMacroCommand("macroClickIfClosed('" + sourceId + "')");
280: //
281: //
282: if (targetImage != null && targetImageId != null) {
283: inPsc.addMacroCommand("macroOpenSectionIfClosed('"
284: + sourceId + "', '" + targetId + "', '"
285: + targetImage + "', '" + targetImageId + "')");
286: } else {
287: inPsc.addMacroCommand("macroOpenSectionIfClosed('"
288: + sourceId + "', '" + targetId + "', null, null)");
289: }
290: //inPsc.addMacroCommand("macroAlert('CursorClick Not Impl')");
291: }
292: }
|