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.view.base;
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.function.WebPageTagInstanceViewContextInfo;
016: import org.jfolder.common.function.WebPageTagPreferences;
017: import org.jfolder.common.tagging.ConceptTag;
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.ConceptTagPreferences;
022: import org.jfolder.common.tagging.StudioConceptTagUsabilityContext;
023: import org.jfolder.common.web.template.ConsoleTemplateContext;
024: import org.jfolder.common.web.template.ConsoleTemplateSession;
025: import org.jfolder.common.web.template.PageSetupContext;
026: import org.jfolder.common.web.template.RcthConstraintBuilder;
027: import org.jfolder.common.web.template.RcthConstraintBuilderDirectiveStep;
028:
029: //other classes
030:
031: public class PopUpViewHolder {
032:
033: //
034: private WebPageTagInstanceViewContextInfo wptivci = null;
035: private StringBuffer sb = null;
036: //private ConsolePageContext cpc = null;
037: private ConsoleTemplateSession cts = null;
038: private ConsoleTemplateContext ctc = null;
039: private ConceptTagPreferences ctp = null;
040: private StudioConceptTagUsabilityContext sctuc = null;
041: private WebPageTagPreferences wptp = null;
042: private ArrayList toggleSuffix = null;
043: private ConceptTagConstraintHolder ctconh = null;
044: private ConceptTagConstraint ctcon = null;
045: private Integer staticIndex = null;
046: private String[] earmark = null;
047: private String errorId = null;
048: private boolean templateInUse = false;
049: //private boolean suffixIdPresent = false;
050: private String defaultConstraint = null;
051: private boolean menuActive = false;
052: //
053: private String copyStatic = null;
054: private ConceptTag copyDynamic = null;
055: //
056: private int currentIdCount = 0;
057: //
058: private boolean descendentErrorPresent = false;
059: //
060: private ArrayList currentStudioMacroEditDirective = null;
061:
062: //
063: private PopUpViewHolder(
064: WebPageTagInstanceViewContextInfo inWptivci,
065: StringBuffer inSb,
066: ConsoleTemplateSession inCts,
067: ConsoleTemplateContext inCtc,
068: ConceptTagPreferences inCtp,
069: StudioConceptTagUsabilityContext inSctuc,
070: //ConsolePageContext inCpc,
071: WebPageTagPreferences inWptp, ArrayList inToggleSuffix,
072: ConceptTagConstraintHolder inCtconh,
073: ConceptTagConstraint inCtcon, Integer inStaticIndex,
074: boolean inTemplateInUse, String inCopyStatic,
075: ConceptTag inCopyDynamic) {
076: //
077: this .wptivci = inWptivci;
078: this .sb = inSb;
079: //this.cpc = inCpc;
080: this .cts = inCts;
081: this .ctc = inCtc;
082: this .ctp = inCtp;
083: this .sctuc = inSctuc;
084: this .wptp = inWptp;
085: this .toggleSuffix = inToggleSuffix;
086: this .ctconh = inCtconh;
087: this .ctcon = inCtcon;
088: this .staticIndex = inStaticIndex;
089: this .templateInUse = inTemplateInUse;
090: //
091: this .copyStatic = inCopyStatic;
092: this .copyDynamic = inCopyDynamic;
093: //
094: this .currentStudioMacroEditDirective = new ArrayList();
095: }
096:
097: //
098: public final static PopUpViewHolder newInstance(
099: WebPageTagInstanceViewContextInfo inWptivci,
100: StringBuffer inSb,
101: //ConsolePageContext inCpc,
102: ConsoleTemplateSession inCts, ConsoleTemplateContext inCtc,
103: ConceptTagPreferences inCtp,
104: StudioConceptTagUsabilityContext inSctuc,
105: WebPageTagPreferences inWptp, ArrayList inToggleSuffix,
106: ConceptTagConstraintHolder inCtconh,
107: ConceptTagConstraint inCtcon, Integer inStaticIndex,
108: boolean inTemplateInUse, String inCopyStatic,
109: ConceptTag inCopyDynamic) {
110:
111: PopUpViewHolder outValue = null;
112:
113: //
114: outValue = new PopUpViewHolder(
115: inWptivci,
116: inSb,// inCpc,
117: inCts, inCtc, inCtp, inSctuc, inWptp, inToggleSuffix,
118: inCtconh, inCtcon, inStaticIndex, inTemplateInUse,
119: inCopyStatic, inCopyDynamic);
120:
121: return outValue;
122: }
123:
124: //
125: //
126: //
127: public String getHandleParent() {
128:
129: String outValue = null;
130:
131: if (this .ctconh != null && this .defaultConstraint != null) {
132: //outValue = this.ct
133: ConceptTagPreferences localCtp = this .ctconh
134: .getPreferences();
135: ConceptTagConstraint subCtcon = null;
136: //
137: if (!this .defaultConstraint.equals(localCtp
138: .getUnconstrainedSymbol())) {
139: //
140: subCtcon = this .ctconh
141: .getConstraint(this .defaultConstraint);
142: } else {
143: subCtcon = this .ctconh.getUndefinedConstraint();
144: }
145: outValue = subCtcon.getCharacteristic()
146: .getHandleWithoutIndex();
147: } else if (this .ctconh != null
148: && this .defaultConstraint == null) {
149: //outValue = this.ct
150: ConceptTagConstraint parentCtcon = this .ctconh
151: .getParentConstraint();
152: outValue = parentCtcon.getCharacteristic()
153: .getHandleWithoutIndex();
154: } else {
155: outValue = this .ctcon.getCharacteristic()
156: .getHandleWithoutIndex();
157: }
158:
159: return outValue;
160: }
161:
162: public Integer getHandleIndex() {
163:
164: Integer outValue = null;
165:
166: if (this .defaultConstraint != null) {
167: //do nothing
168: } else if (this .ctconh != null) {
169: ConceptTagCharacteristicHolder localCtcharh = this .ctconh
170: .getCharacteristicHolder();
171: outValue = new Integer(localCtcharh
172: .getParentCharacteristicIndex());
173: } else {
174: outValue = this .staticIndex;
175: }
176:
177: return outValue;
178: }
179:
180: //
181: //
182: //
183: //
184: public void setMenuActive(boolean inMenuActive) {
185: this .menuActive = inMenuActive;
186: }
187:
188: public boolean isMenuActive() {
189: return this .menuActive;
190: }
191:
192: //
193: public void setDefaultConstraint(String inDefaultConstraint) {
194: this .defaultConstraint = inDefaultConstraint;
195: }
196:
197: public String getDefaultConstraint() {
198: return this .defaultConstraint;
199: }
200:
201: //
202: public boolean isCopyStaticPresent() {
203: return (this .copyStatic != null);
204: }
205:
206: public String getCopyStatic() {
207: return this .copyStatic;
208: }
209:
210: public boolean isCopyDynamicPresent() {
211: return (this .copyDynamic != null);
212: }
213:
214: public ConceptTag getCopyDynamic() {
215: return this .copyDynamic;
216: }
217:
218: //
219: public WebPageTagInstanceViewContextInfo getInfo() {
220: return this .wptivci;
221: }
222:
223: public void setInfo(WebPageTagInstanceViewContextInfo inWptivci) {
224: this .wptivci = inWptivci;
225: }
226:
227: public String getEarmarkId() {
228:
229: String outValue = null;
230:
231: if (isEarmarkPresent()) {
232: outValue = this .earmark[1];
233: }
234:
235: return outValue;
236: }
237:
238: public boolean isEarmarkErrorPresent() {
239:
240: boolean outValue = false;
241:
242: if (isEarmarkPresent()) {
243: outValue = (this .earmark[2] != null);
244: }
245:
246: return outValue;
247: }
248:
249: public boolean isEarmarkPresent() {
250: return (this .earmark != null);
251: }
252:
253: public String[] getEarmark() {
254: return this .earmark;
255: }
256:
257: public void setEarmark(String inEarmark[]) {
258: this .earmark = inEarmark;
259: }
260:
261: public String getErrorId() {
262: return this .errorId;
263: }
264:
265: public void setErrorId(String inErrorId) {
266: this .errorId = inErrorId;
267: }
268:
269: public void setStringBuffer(StringBuffer inSb) {
270: this .sb = inSb;
271: }
272:
273: public StringBuffer getStringBuffer() {
274: return this .sb;
275: }
276:
277: public void appendText(String inText) {
278: this .sb.append(inText);
279: }
280:
281: //public ConsolePageContext getConsolePageContext() {
282: // return this.cpc;
283: //}
284: public ConsoleTemplateSession getConsoleTemplateSession() {
285: return this .cts;
286: }
287:
288: public ConsoleTemplateContext getConsoleTemplateContext() {
289: return this .ctc;
290: }
291:
292: public ConceptTagPreferences getConceptTagPreferences() {
293: return this .ctp;
294: }
295:
296: public StudioConceptTagUsabilityContext getStudioUsability() {
297: return this .sctuc;
298: }
299:
300: public WebPageTagPreferences getWebPageTagPreferences() {
301: return this .wptp;
302: }
303:
304: public ArrayList getToggleSuffix() {
305: return this .toggleSuffix;
306: }
307:
308: //
309: public void setConstraintHolder(ConceptTagConstraintHolder inCtconh) {
310: this .ctconh = inCtconh;
311: }
312:
313: public ConceptTagConstraintHolder getConstraintHolder() {
314: return this .ctconh;
315: }
316:
317: //
318: public void setConstraint(ConceptTagConstraint inCtcon) {
319: this .ctcon = inCtcon;
320: }
321:
322: public ConceptTagConstraint getConstraint() {
323: return this .ctcon;
324: }
325:
326: //
327: public Integer getStaticIndex() {
328: return this .staticIndex;
329: }
330:
331: public void setStaticIndex(Integer inStaticIndex) {
332: this .staticIndex = inStaticIndex;
333: }
334:
335: //
336: public boolean isTemplateInUse() {
337: return this .templateInUse;
338: }
339:
340: //
341: //
342: //
343: public void resetCurrentIdCount() {
344: this .currentIdCount = 0;
345: }
346:
347: public int getCurrentIdCount() {
348: return this .currentIdCount;
349: }
350:
351: public int incrementCurrentIdCount() {
352:
353: int outValue = 0;
354:
355: outValue = getCurrentIdCount();
356: this .currentIdCount++;
357:
358: return outValue;
359: }
360:
361: public void setCurrentIdCount(int inCurrentIdCount) {
362: this .currentIdCount = inCurrentIdCount;
363: }
364:
365: //
366: //
367: //
368: public void setDescendentErrorPresent(
369: boolean inDescendentErrorPresent) {
370: this .descendentErrorPresent = inDescendentErrorPresent;
371: }
372:
373: public boolean isDescendentErrorPresent() {
374: return this .descendentErrorPresent;
375: }
376:
377: //
378: //
379: //
380: public void pushStudioMacroEditDirectiveAsEarmark() {
381: //
382: this .currentStudioMacroEditDirective
383: .add(RcthConstraintBuilderDirectiveStep.newEarmark());
384: }
385:
386: public void pushStudioMacroEditDirectiveAsPopUp() {
387: //
388: this .currentStudioMacroEditDirective
389: .add(RcthConstraintBuilderDirectiveStep.newPopUp());
390: }
391:
392: public void pushStudioMacroEditDirectiveAsHtmlIterative() {
393: //
394: this .currentStudioMacroEditDirective
395: .add(RcthConstraintBuilderDirectiveStep.newHtmlIter());
396: }
397:
398: public void pushStudioMacroEditDirectiveAsTarget() {
399: //
400: this .currentStudioMacroEditDirective
401: .add(RcthConstraintBuilderDirectiveStep.newTarget());
402: }
403:
404: //
405: //
406: private RcthConstraintBuilderDirectiveStep getCurrentSmed() {
407:
408: RcthConstraintBuilderDirectiveStep outValue = null;
409:
410: //
411: Object o = this .currentStudioMacroEditDirective
412: .get(this .currentStudioMacroEditDirective.size() - 1);
413: outValue = ((RcthConstraintBuilderDirectiveStep) o);
414:
415: return outValue;
416: }
417:
418: //
419: //
420: public void popStudioMacroEditDirectiveAsEarmark(
421: String inTargetHtmlId) {
422: //
423: if (getCurrentSmed().isTypeAsEarmark()) {
424: //
425: String viewEarmarksItemPartId = PopUpViewHelper
426: .getMenuItemPartId("getStudioSelectionId()",
427: PopUpViewHelper.MENU_OPT__VIEW_EARMARKS
428: + "");
429: //
430: getCurrentSmed().registerForEarmark(inTargetHtmlId,
431: viewEarmarksItemPartId);
432: //
433: this .currentStudioMacroEditDirective
434: .remove(this .currentStudioMacroEditDirective.size() - 1);
435: } else {
436: throw UnexpectedSystemException.unknownState();
437: }
438: }
439:
440: public void popStudioMacroEditDirectiveAsPopUp(String inTargetHtmlId) {
441: //
442: if (getCurrentSmed().isTypeAsPopUp()) {
443: //
444: getCurrentSmed().registerForPopUp(inTargetHtmlId);
445: //
446: this .currentStudioMacroEditDirective
447: .remove(this .currentStudioMacroEditDirective.size() - 1);
448: } else {
449: throw UnexpectedSystemException.unknownState();
450: }
451: }
452:
453: public void popStudioMacroEditDirectiveAsHtmlIterative(
454: String inTargetHtmlId, String inTargetUpdateValue,
455: String inSelectionAction) {
456: //
457: if (getCurrentSmed().isTypeAsHtmlIter()) {
458: //
459: getCurrentSmed().registerForHtmlIter(inTargetHtmlId,
460: inTargetUpdateValue, inSelectionAction);
461: //
462: this .currentStudioMacroEditDirective
463: .remove(this .currentStudioMacroEditDirective.size() - 1);
464: } else {
465: throw UnexpectedSystemException.unknownState();
466: }
467: }
468:
469: public void popStudioMacroEditDirectiveAsTarget(
470: String inTargetHtmlId, String inTargetActualIdParent,
471: Integer inTargetActualIdIndex, ArrayList inActions,
472: ArrayList inParentActions) {
473: //
474: if (getCurrentSmed().isTypeAsTarget()) {
475: //
476: //pre-actions
477: //
478: //
479: //
480: //post-actions
481: //
482: PageSetupContext localPsc = getConsoleTemplateContext()
483: .getPageSetupContext();
484: //
485: //
486: //
487: getCurrentSmed().registerForTarget(inTargetHtmlId,
488: inTargetActualIdParent, inTargetActualIdIndex,
489: inActions, inParentActions);
490: //
491: //
492: //
493: //PageSetupContext localPsc =
494: // getConsoleTemplateContext().getPageSetupContext();
495: if (localPsc.isStudioMacroEditPresent()) {
496: //
497: RcthConstraintBuilder localRcb = localPsc
498: .getStudioMacroEdit();
499: //
500: if (inTargetActualIdIndex != null) {
501: //
502: if (inTargetActualIdParent.equals(localRcb
503: .getTargetConstraint())
504: && inTargetActualIdIndex.intValue() == localRcb
505: .getLastStudioTargetIndex()) {
506: //
507: localPsc
508: .setStudioMacroEditDirective(new ArrayList(
509: this .currentStudioMacroEditDirective));
510: }
511: } else {
512: if (inTargetActualIdParent.equals(localRcb
513: .getTargetConstraint())) {
514: //
515: localPsc
516: .setStudioMacroEditParentDirective(new ArrayList(
517: this .currentStudioMacroEditDirective));
518: }
519: }
520: //
521: //
522: //
523:
524: }
525: //
526: //
527: //
528: //
529: this .currentStudioMacroEditDirective
530: .remove(this .currentStudioMacroEditDirective.size() - 1);
531: } else {
532: throw UnexpectedSystemException.unknownState();
533: }
534: }
535: }
|