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.io.IOException;
012: import java.util.ArrayList;
013: import java.util.HashSet;
014: import java.util.Iterator;
015: import java.util.StringTokenizer;
016:
017: //project specific classes
018:
019: //other classes
020:
021: public class PageSetupContext {
022:
023: //
024:
025: //
026: private boolean replayMode = false;
027: private boolean firstReplayMessage = false;
028: private HashSet commonStems = null;
029: private int currentReplayCommand = 0;
030: private int totalReplayCommands = 0;
031: //
032: private ArrayList macroCommands = null;
033: //
034: private ArrayList currentSubSectionPositions = null;
035: //
036: private boolean highlightHandleUpdated = false;
037: //
038: private ArrayList shiftSubSectionToHighlightHandle = null;
039: //
040: private ArrayList heavyWeightPageComponents = null;
041: //
042: private ArrayList creationParameterNames = null;
043: private ArrayList creationParameterActions = null;
044: //
045: private ArrayList webPageViewPopUps = null;
046: //
047: private String studioUsabilityId = null;
048: private String studioSelectionId = null;
049: //
050: private String title = null;
051: //
052: private RcthConstraintBuilder studioMacroEdit = null;
053: //
054: private ArrayList studioMacroEditDirective = null;
055: private ArrayList studioMacroEditParentDirective = null;
056:
057: private PageSetupContext() {
058: init();
059: }
060:
061: private void init() {
062: //
063: this .replayMode = false;
064: this .firstReplayMessage = false;
065: this .commonStems = null;
066: this .currentReplayCommand = 0;
067: this .totalReplayCommands = 0;
068: //
069: //
070: this .commonStems = new HashSet();
071: this .macroCommands = new ArrayList();
072: //
073: this .currentSubSectionPositions = new ArrayList();
074: //
075: this .highlightHandleUpdated = false;
076: //
077: this .shiftSubSectionToHighlightHandle = new ArrayList();
078: //
079: this .heavyWeightPageComponents = new ArrayList();
080: //
081: this .creationParameterNames = new ArrayList();
082: this .creationParameterActions = new ArrayList();
083: //
084: this .webPageViewPopUps = new ArrayList();
085: //
086: this .studioSelectionId = null;
087: this .studioUsabilityId = null;
088: //
089: this .title = "JFolder";
090: //
091: this .studioMacroEdit = null;
092: //
093: this .studioMacroEditDirective = null;
094: this .studioMacroEditParentDirective = null;
095: }
096:
097: public void resetForReuse() {
098: init();
099: }
100:
101: public final static PageSetupContext newPageSetupContext() {
102:
103: PageSetupContext outValue = null;
104:
105: outValue = new PageSetupContext();
106:
107: return outValue;
108: }
109:
110: //
111: public int getWebPageViewPopUpCount() {
112: return this .webPageViewPopUps.size();
113: }
114:
115: public String getWebPageViewPopUp(int inIndex) {
116: return ((String) this .webPageViewPopUps.get(inIndex));
117: }
118:
119: public void addWebPageViewPopUp(String inContent) {
120: this .webPageViewPopUps.add(inContent);
121: }
122:
123: //
124: //
125: //
126: public boolean isStudioMacroEditPresent() {
127: return (this .studioMacroEdit != null);
128: }
129:
130: public RcthConstraintBuilder getStudioMacroEdit() {
131: return this .studioMacroEdit;
132: }
133:
134: public void setStudioMacroEdit(
135: RcthConstraintBuilder inStudioMacroEdit) {
136: this .studioMacroEdit = inStudioMacroEdit;
137: }
138:
139: //
140: public boolean isStudioMacroEditDirectivePresent() {
141: return (this .studioMacroEditDirective != null);
142: }
143:
144: public ArrayList getStudioMacroEditDirective() {
145: return new ArrayList(this .studioMacroEditDirective);
146: }
147:
148: public void setStudioMacroEditDirective(ArrayList inSmed) {
149: this .studioMacroEditDirective = new ArrayList(inSmed);
150: }
151:
152: //
153: public boolean isStudioMacroEditParentDirectivePresent() {
154: return (this .studioMacroEditParentDirective != null);
155: }
156:
157: public ArrayList getStudioMacroEditParentDirective() {
158: return new ArrayList(this .studioMacroEditParentDirective);
159: }
160:
161: public void setStudioMacroEditParentDirective(ArrayList inSmepd) {
162: this .studioMacroEditParentDirective = new ArrayList(inSmepd);
163: }
164:
165: //
166: //
167: //
168: public void registerCreationParameter(ConsoleTemplateSession inCts,
169: CreationParameterContext inCpc, String inId)
170: throws IOException {
171: //
172: inCts.pushToggleLinkCreationParameterCaller();
173: inCts.pushToggleLink(inId);
174: //
175: this .creationParameterNames.add(inCts.getToggleLink());
176: this .creationParameterActions.add(inCpc);
177: //
178: inCts.popToggleLink();
179: inCts.popToggleLink();
180: }
181:
182: public int getCreationParameterCount() {
183: return this .creationParameterNames.size();
184: }
185:
186: public String getCreationParameterName(int inIndex) {
187: return ((String) this .creationParameterNames.get(inIndex));
188: }
189:
190: public CreationParameterContext getCreationParameterAction(
191: int inIndex) {
192:
193: CreationParameterContext outValue = null;
194:
195: Object o = this .creationParameterActions.get(inIndex);
196: outValue = ((CreationParameterContext) o);
197:
198: return outValue;
199: }
200:
201: //
202: public void registerHeavyWeightPageComponent(String inId) {
203: this .heavyWeightPageComponents.add(inId);
204: }
205:
206: public void unregisterHeavyWeightPageComponent(String inId) {
207: int index = this .heavyWeightPageComponents.indexOf(inId);
208: this .heavyWeightPageComponents.remove(index);
209: }
210:
211: public int getHeavyWeightPageComponentCount() {
212: return this .heavyWeightPageComponents.size();
213: }
214:
215: public String getHeavyWeightPageComponent(int inIndex) {
216:
217: String outValue = null;
218:
219: outValue = ((String) this .heavyWeightPageComponents
220: .get(inIndex));
221:
222: return outValue;
223: }
224:
225: //
226: public boolean isHighlighHandleUpdated() {
227: return this .highlightHandleUpdated;
228: }
229:
230: public void setHighlightHandleUpdated(
231: boolean inHighlightHandleUpdated) {
232: this .highlightHandleUpdated = inHighlightHandleUpdated;
233: }
234:
235: //
236: //public void resetCurrentSubSectionPositions() {
237: // this.currentSubSectionPositions = new ArrayList();
238: //}
239: public void addCurrentSubSectionPosition(String inSubSectionPosition) {
240: this .currentSubSectionPositions.add(inSubSectionPosition);
241: }
242:
243: public ArrayList getCurrentSubSectionPositions() {
244: return this .currentSubSectionPositions;
245: }
246:
247: //
248: public void addShiftSubSectionToHighlightHandle(String inSectionId,
249: String inHighlightHandle) {
250: //
251: this .shiftSubSectionToHighlightHandle.add(new String[] {
252: inSectionId, inHighlightHandle });
253: }
254:
255: public ArrayList getShiftSubSectionToHighlightHandles() {
256: return this .shiftSubSectionToHighlightHandle;
257: }
258:
259: //
260: public boolean isReplayMode() {
261: return this .replayMode;
262: }
263:
264: public void setReplayMode(boolean inReplayMode) {
265: this .replayMode = inReplayMode;
266: }
267:
268: //
269: public void setCurrentReplayCommand(int inIndex) {
270: this .currentReplayCommand = inIndex;
271: }
272:
273: public int getCurrentReplayCommand() {
274: return this .currentReplayCommand;
275: }
276:
277: //
278: public void setTotalReplayCommands(int inTotal) {
279: this .totalReplayCommands = inTotal;
280: }
281:
282: public int getTotalReplayCommands() {
283: return this .totalReplayCommands;
284: }
285:
286: //
287: public void setFirstReplayMessage(boolean inFirstReplayMessage) {
288: this .firstReplayMessage = inFirstReplayMessage;
289: }
290:
291: public boolean isFirstReplayMessage() {
292: return this .firstReplayMessage;
293: }
294:
295: //
296: //public void resetMacroCommands() {
297: // this.macroCommands = new ArrayList();
298: //}
299: public void addMacroCommand(String inCommand) {
300: this .macroCommands.add(inCommand);
301: }
302:
303: protected ArrayList getCurrentReplayCommands() {
304:
305: return this .macroCommands;
306: }
307:
308: //
309: public void registerCommonStem(String inStem) {
310: this .commonStems.add(inStem);
311: }
312:
313: public String[] getCommonStems() {
314:
315: String outValue[] = null;
316:
317: outValue = new String[this .commonStems.size()];
318: Iterator iter = this .commonStems.iterator();
319: for (int i = 0; iter.hasNext(); i++) {
320: outValue[i] = (String) iter.next();
321: }
322:
323: return outValue;
324: }
325:
326: public String getCommonStemsAsValue() {
327:
328: StringBuffer outValue = new StringBuffer();
329:
330: Iterator iter = this .commonStems.iterator();
331: while (iter.hasNext()) {
332: outValue
333: .append(ConsoleTemplateFunctionsContext.BRANCH_SEPARATOR);
334: outValue.append(iter.next());
335: outValue
336: .append(ConsoleTemplateFunctionsContext.BRANCH_SEPARATOR);
337: }
338:
339: return outValue.toString();
340: }
341:
342: protected final static String[] getCommonStems(String inValue) {
343:
344: String outValue[] = null;
345:
346: ArrayList list = new ArrayList();
347: StringTokenizer st = new StringTokenizer(inValue,
348: ConsoleTemplateFunctionsContext.BRANCH_SEPARATOR);
349: while (st.hasMoreTokens()) {
350: list.add(st.nextToken());
351: }
352:
353: outValue = new String[list.size()];
354: for (int i = 0; i < list.size(); i++) {
355: String nextValue = (String) list.get(i);
356: outValue[i] = nextValue;
357: }
358:
359: return outValue;
360: }
361:
362: //
363: //
364: //
365: public void setStudioSelectionId(String inStudioSelectionId) {
366: this .studioSelectionId = inStudioSelectionId;
367: }
368:
369: public String getStudioSelectionId() {
370: return this .studioSelectionId;
371: }
372:
373: //
374: public void setStudioUsabilityId(String inStudioUsabilityId) {
375: this .studioUsabilityId = inStudioUsabilityId;
376: }
377:
378: public String getStudioUsabilityId() {
379: return this .studioUsabilityId;
380: }
381:
382: //
383: //
384: //
385: public void setTitle(String inTitle) {
386: this .title = inTitle;
387: }
388:
389: public String getTitle() {
390: return this .title;
391: }
392: //
393: //
394: //
395: //
396: //
397: }
|