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.common.web.template;
009:
010: //base classes
011: import java.util.ArrayList;
012:
013: //project specific classes
014: import org.jfolder.common.UnexpectedSystemException;
015: import org.jfolder.common.utils.xml.XMLHelper;
016:
017: //other classes
018:
019: public class RcthConstraintBuilderDirectiveStep {
020:
021: //
022: private final static int TYPE__EARMARK = 0;
023: private final static int TYPE__POP_UP = 1;
024: private final static int TYPE__HTML_ITER = 2;
025: private final static int TYPE__TARGET = 3;
026: //
027: private int type = 0;
028: //
029: //
030: //private String parentSourceHtmlId = null;
031: private String targetHtmlId = null;
032: private String targetActualIdParent = null;
033: private Integer targetActualIdIndex = null;
034: private String targetUpdateValue = null;
035: private ArrayList actions = null;
036: private ArrayList parentActions = null;
037: private String menuEarmarkId = null;
038:
039: //
040: //
041: private RcthConstraintBuilderDirectiveStep(int inType) {
042: this .type = inType;
043: }
044:
045: //
046: private final static RcthConstraintBuilderDirectiveStep newInstance(
047: int inType) {
048: //
049: RcthConstraintBuilderDirectiveStep outValue = null;
050:
051: //
052: outValue = new RcthConstraintBuilderDirectiveStep(inType);
053:
054: return outValue;
055: }
056:
057: public final static RcthConstraintBuilderDirectiveStep newEarmark() {
058: return RcthConstraintBuilderDirectiveStep
059: .newInstance(TYPE__EARMARK);
060: }
061:
062: public final static RcthConstraintBuilderDirectiveStep newPopUp() {
063: return RcthConstraintBuilderDirectiveStep
064: .newInstance(TYPE__POP_UP);
065: }
066:
067: public final static RcthConstraintBuilderDirectiveStep newHtmlIter() {
068: return RcthConstraintBuilderDirectiveStep
069: .newInstance(TYPE__HTML_ITER);
070: }
071:
072: public final static RcthConstraintBuilderDirectiveStep newTarget() {
073: return RcthConstraintBuilderDirectiveStep
074: .newInstance(TYPE__TARGET);
075: }
076:
077: //
078: //
079: //
080: public boolean isTypeAsEarmark() {
081: return (this .type == TYPE__EARMARK);
082: }
083:
084: public boolean isTypeAsPopUp() {
085: return (this .type == TYPE__POP_UP);
086: }
087:
088: public boolean isTypeAsHtmlIter() {
089: return (this .type == TYPE__HTML_ITER);
090: }
091:
092: public boolean isTypeAsTarget() {
093: return (this .type == TYPE__TARGET);
094: }
095:
096: //
097: //
098: //
099: public void registerForEarmark(String inTargetHtmlId,
100: String inEarmarkMenuId) {
101: //
102: if (isTypeAsEarmark()) {
103: this .targetHtmlId = inTargetHtmlId;
104: this .actions = new ArrayList();
105: this .menuEarmarkId = inEarmarkMenuId;
106: //
107: ArrayList preActions = new ArrayList();
108: preActions.add("macroGoTo('" + inTargetHtmlId + "')");
109: preActions.add("macroClickImage()");
110: preActions.add("macroClick('" + inTargetHtmlId + "')");
111: //
112: ArrayList postActions = new ArrayList();
113: postActions.add("macroGoTo(" + inEarmarkMenuId + ")");
114: postActions.add("macroClickImage()");
115: postActions.add("macroClick(" + inEarmarkMenuId + ")");
116: postActions.add("closeOpenTagMenus('', false)");
117: //postActions.add=
118: this .actions.addAll(0, preActions);
119: this .actions.addAll(postActions);
120: } else {
121: throw UnexpectedSystemException.unknownState();
122: }
123: }
124:
125: public void registerForPopUp(String inTargetHtmlId) {
126: //
127: if (isTypeAsPopUp()) {
128: //this.parentSourceHtmlId = inParentSourceHtmlId;
129: this .targetHtmlId = inTargetHtmlId;
130: this .actions = new ArrayList();
131: //
132: ArrayList preActions = new ArrayList();
133: preActions.add("macroGoTo('" + inTargetHtmlId + "')");
134: preActions.add("macroClickImage()");
135: preActions.add("macroClick('" + inTargetHtmlId + "')");
136: //
137: this .actions.addAll(0, preActions);
138: } else {
139: throw UnexpectedSystemException.unknownState();
140: }
141: }
142:
143: public void registerForHtmlIter(String inTargetHtmlId,
144: String inTargetUpdateValue, String inSelectionAction) {
145: //
146: if (isTypeAsHtmlIter()) {
147: this .targetHtmlId = inTargetHtmlId;
148: this .targetUpdateValue = inTargetUpdateValue;
149: //
150: //
151: ArrayList preActions = new ArrayList();
152: preActions.add("macroGoTo('" + this .targetHtmlId + "')");
153: preActions.add("macroClickImage()");
154: preActions
155: .add("macroChangeFormValue('"
156: + this .targetHtmlId
157: + "', '"
158: + XMLHelper
159: .fromStringToJSCData(this .targetUpdateValue)
160: + "')");
161: preActions.add("macroEval('"
162: + XMLHelper.fromStringToJSCData(inSelectionAction)
163: + "')");
164: //
165: this .actions = preActions;
166: //this.parentActions = preActions;
167: } else {
168: throw UnexpectedSystemException.unknownState();
169: }
170: }
171:
172: public void registerForTarget(String inTargetHtmlId,
173: String inTargetActualIdParent,
174: Integer inTargetActualIdIndex, ArrayList inActions,
175: ArrayList inParentActions) {
176: //
177: if (isTypeAsTarget()) {
178: this .targetHtmlId = inTargetHtmlId;
179: this .targetActualIdParent = inTargetActualIdParent;
180: this .targetActualIdIndex = inTargetActualIdIndex;
181: this .actions = inActions;
182: this .parentActions = inParentActions;
183: //
184: //
185: ArrayList preActions = new ArrayList();
186: preActions.add("macroGoTo('" + this .targetHtmlId + "')");
187: preActions.add("macroClickImage()");
188: //
189: this .actions.addAll(0, preActions);
190: this .parentActions.addAll(0, preActions);
191: } else {
192: throw UnexpectedSystemException.unknownState();
193: }
194: }
195:
196: //
197: //
198: //
199: public String getTargetHtmlId() {
200: return this .targetHtmlId;
201: }
202:
203: public String getTargetActualIdParent() {
204: return this .targetActualIdParent;
205: }
206:
207: public boolean isTargetActualIdIndexPresent() {
208: return (this .targetActualIdIndex != null);
209: }
210:
211: public int getTargetActualIdIndex() {
212: return this .targetActualIdIndex.intValue();
213: }
214:
215: public String getTargetUpdateValue() {
216: return this .targetUpdateValue;
217: }
218:
219: public ArrayList getActions(boolean inParent) {
220:
221: ArrayList outValue = null;
222:
223: if (isTypeAsTarget() && inParent) {
224: outValue = this .parentActions;
225: } else {
226: outValue = this .actions;
227: }
228:
229: return outValue;
230: }
231:
232: public String getMenuEarmarkId() {
233: return this.menuEarmarkId;
234: }
235: }
|