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.io.IOException;
012: import java.util.HashMap;
013:
014: //project specific classes
015: import org.jfolder.common.UnexpectedSystemException;
016: import org.jfolder.common.tagging.AppraiseConceptTagContext;
017: import org.jfolder.common.tagging.CompoundConceptTagConstraintContext;
018: import org.jfolder.common.tagging.ConceptTagCharacteristic;
019: import org.jfolder.common.tagging.ConceptTagCharacteristicHolder;
020: import org.jfolder.common.tagging.ConceptTagConstraint;
021: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
022: import org.jfolder.common.tagging.ConceptTagConstraintTemplate;
023: import org.jfolder.common.tagging.DynamicConceptTagConstraintContext;
024: import org.jfolder.common.tagging.InitializeConceptTagContext;
025: import org.jfolder.common.tagging.RootConceptTagHolder;
026: import org.jfolder.common.tagging.StaticConceptTagConstraintContext;
027: import org.jfolder.common.tagging.StudioConceptTagInstanceInfoContext;
028: import org.jfolder.common.tagging.StudioConceptTagTypeInfoContext;
029: import org.jfolder.common.web.template.ConsoleTemplateSession;
030: import org.jfolder.common.web.template.CreationParameterContext;
031: import org.jfolder.common.web.template.PageSetupContext;
032: import org.jfolder.console.macro.ConsoleMacro;
033: import org.jfolder.console.macro.ConsoleMacroTag;
034: import org.jfolder.console.macro.ConsoleMacroTagHelper;
035:
036: //other classes
037:
038: public class CreationParameterConsoleMacroTag implements
039: ConsoleMacroTag {
040:
041: ////characteristics
042: private ConceptTagCharacteristic actionIdCtchar = null;
043:
044: //action details
045: private final static String ACTION_ID_CTCON = "action-id";
046: private final static String ACTION_ID_TITLE = "Action";
047: private final static String ACTION_ID_SHORT_DESCRIPTION = "Action";
048:
049: ///////////////////////////////////
050:
051: public void initialize(InitializeConceptTagContext inIctc) {
052:
053: //
054: ConceptTagConstraintHolder rootCtconh = ConceptTagConstraintHolder
055: .newInstance(inIctc);
056:
057: //constrain "action-id"
058: ConceptTagConstraint actionIdCtcon = ConceptTagConstraint
059: .newInstance(ACTION_ID_CTCON, rootCtconh);
060: actionIdCtcon.setTitle(ACTION_ID_TITLE);
061: actionIdCtcon.setShortDescription(ACTION_ID_SHORT_DESCRIPTION);
062: //
063: StaticConceptTagConstraintContext actionIdSctcc = StaticConceptTagConstraintContext
064: .newInstance(actionIdCtcon);
065:
066: //
067: inIctc.initialize();
068:
069: //
070: this .actionIdCtchar = actionIdCtcon.getCharacteristic();
071: }
072:
073: //
074: public void appraise(AppraiseConceptTagContext inCtic) {
075: if (inCtic instanceof StudioConceptTagInstanceInfoContext) {
076: StudioConceptTagInstanceInfoContext sctiic = (StudioConceptTagInstanceInfoContext) inCtic;
077: sctiic.setInstanceTitle("Creation Parameter Context");
078: sctiic.setInstanceDescription("Creation Parameter Context");
079: } else if (inCtic instanceof StudioConceptTagTypeInfoContext) {
080: StudioConceptTagTypeInfoContext scttic = (StudioConceptTagTypeInfoContext) inCtic;
081: scttic.setTypeTitle("Creation Parameter Context");
082: scttic.setTypeDescription("Creation Parameter Context");
083: }
084: }
085:
086: //
087: public final static CreationParameterConsoleMacroTag newInstance(
088: ConceptTagCharacteristic inCtchar, String inActionId) {
089: //
090: CreationParameterConsoleMacroTag outValue = null;
091:
092: outValue = new CreationParameterConsoleMacroTag();
093: //
094: ConceptTagCharacteristicHolder nextCtcharh = inCtchar.addValue(
095: inCtchar.getValueLength(), outValue, true);
096: //
097: ConceptTagCharacteristic nextActionIdCtchar = nextCtcharh
098: .registerCharacteristic(ACTION_ID_CTCON);
099: nextActionIdCtchar.addValue(0, inActionId);
100: //
101:
102: return outValue;
103: }
104:
105: //
106: public void generateMacroCommands(PageSetupContext inPsc,
107: ConsoleTemplateSession inCts, RootConceptTagHolder inRcth,
108: HashMap inVars, String inFromHandle,
109: String inAliasFromHandle, String inSourcePage,
110: String inDestinationPage) {
111: //
112: String actionId = this .actionIdCtchar.getValueAsString(0, null);
113: actionId = ConsoleMacroTagHelper.replaceEnvVars(actionId,
114: inVars);
115: //
116: inPsc.addMacroCommand("executeCreationParameter('" + actionId
117: + "')");
118: }
119: }
|