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.web.page.v1;
009:
010: //base classes
011:
012: //project specific classes
013: import org.jfolder.common.UnexpectedSystemException;
014: import org.jfolder.common.files.VirtualFileSystemFile;
015: import org.jfolder.common.files.VirtualFileSystemHolder;
016: import org.jfolder.common.files.WebPageTagMacro;
017: import org.jfolder.common.files.WebPageTagMacroHelper;
018: import org.jfolder.common.function.BaseWebPageTag;
019: import org.jfolder.common.function.WebPageTagInstanceViewContext;
020: import org.jfolder.common.tagging.AppraiseConceptTagContext;
021: import org.jfolder.common.tagging.ConceptRollupTag;
022: import org.jfolder.common.tagging.ConceptTagCharacteristic;
023: import org.jfolder.common.tagging.ConceptTagConstraint;
024: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
025: import org.jfolder.common.tagging.ConceptTagFlagsHelper;
026: import org.jfolder.common.tagging.ConceptTagMessageHolder;
027: import org.jfolder.common.tagging.ConceptTagPreferences;
028: import org.jfolder.common.tagging.DynamicConceptTagConstraintContext;
029: import org.jfolder.common.tagging.DynamicConceptTagValidator;
030: import org.jfolder.common.tagging.InitializeConceptTagContext;
031: import org.jfolder.common.tagging.PostValidatorForConceptTagConstraint;
032: import org.jfolder.common.tagging.RootConceptTagHolder;
033: import org.jfolder.common.tagging.StaticConceptTagConstraintContext;
034: import org.jfolder.common.tagging.StudioConceptTagInstanceInfoContext;
035: import org.jfolder.common.tagging.StudioConceptTagTypeInfoContext;
036: import org.jfolder.common.tagging.TemplateHolderForConceptTag;
037: import org.jfolder.project.model.ProjectSystem;
038: import org.jfolder.web.page.RootWebPageTag;
039:
040: //other classes
041:
042: public class PostConValidatorForTemplateCallNames implements
043: PostValidatorForConceptTagConstraint {
044:
045: //
046: private ConceptTagConstraint parameterCtcon = null;
047:
048: //
049: private PostConValidatorForTemplateCallNames(
050: ConceptTagConstraint inParameterCtcon) {
051: //
052: this .parameterCtcon = inParameterCtcon;
053: }
054:
055: //
056: protected final static PostConValidatorForTemplateCallNames newInstance(
057: ConceptTagConstraint inParameterCtcon) {
058: //
059: PostConValidatorForTemplateCallNames outValue = null;
060:
061: outValue = new PostConValidatorForTemplateCallNames(
062: inParameterCtcon);
063:
064: return outValue;
065: }
066:
067: //
068: public void postValidate(InitializeConceptTagContext inIctc,
069: ConceptTagConstraint inCtcon) {
070: //
071: ConceptTagCharacteristic nameCtchar = inCtcon
072: .getCharacteristic();
073: if (nameCtchar.getValueLength() > 0
074: && nameCtchar.isStatic(0, inIctc)
075: && !inCtcon.isParentErrorPresent()) {
076: //
077: String declaredName = nameCtchar
078: .getValueAsString(0, inIctc);
079: //
080:
081: //
082: if (ConceptTagFlagsHelper
083: .isCurrentProjectSystemPresent(inIctc)
084: && ConceptTagFlagsHelper
085: .isConsolePageSessionPresent(inIctc)) {
086: //
087: Object o1 = ConceptTagFlagsHelper
088: .getConsolePageSession(inIctc);
089: TemplateHolderForConceptTag thfct = ((TemplateHolderForConceptTag) o1);
090: //
091: if (thfct.isCurrentApplicationTemplatePresent()
092: && declaredName
093: .equals(thfct
094: .getCurrentApplicationTemplateLocation())) {
095: //
096: //do nothing, template already loaded
097: } else {
098: Object o2 = ConceptTagFlagsHelper
099: .getCurrentProjectSystem(inIctc);
100: ProjectSystem ps = ((ProjectSystem) o2);
101: VirtualFileSystemHolder webDocRoot = ps
102: .getWebDocs();
103: //
104: if (webDocRoot.isAbsoluteFilePresent(declaredName)) {
105: VirtualFileSystemFile templateFile = webDocRoot
106: .getAbsoluteFile(declaredName);
107: //
108: RootConceptTagHolder templateRcth = ConceptRollupTag
109: .getRootHolderFromList(templateFile
110: .getContent());
111: //
112: thfct.setCurrentApplicationTemplate(
113: declaredName, templateRcth);
114: } else {
115: ConceptTagMessageHolder nameCtmh = nameCtchar
116: .getParentMessageHolder();
117: nameCtmh.addErrorHeaderMessage("Template '"
118: + declaredName + "' cannot be found");
119: }
120: }
121: //
122: RootConceptTagHolder templateRcth = thfct
123: .getCurrentApplicationTemplateRootHolder();
124: RootWebPageTag rwpt = ((RootWebPageTag) templateRcth
125: .getFirstChildConceptTag());
126: //
127: this .parameterCtcon.setMinimumLength(rwpt
128: .getTemplateInterfaceCount());
129: this .parameterCtcon.setMaximumLength(rwpt
130: .getTemplateInterfaceCount());
131: }
132: } else {
133: if (ConceptTagFlagsHelper
134: .isCurrentProjectSystemPresent(inIctc)
135: && ConceptTagFlagsHelper
136: .isConsolePageSessionPresent(inIctc)) {
137: //
138: Object o1 = ConceptTagFlagsHelper
139: .getConsolePageSession(inIctc);
140: TemplateHolderForConceptTag thfct = ((TemplateHolderForConceptTag) o1);
141: thfct.setCurrentApplicationTemplate(null, null);
142: }
143: }
144: }
145: }
|