1 package com.teamkonzept.webman.attr; 2 3 import com.teamkonzept.lib.*; 4 import com.teamkonzept.publishing.markups.*; 5 6 public class TKWMMarkupParamDefinitionIterator implements TKListIterator { 7 8 TKListIterator oldIterator; 9 TKTemplate template; 10 TKWMMarkupParamDefinitionOptionsIterator options; 11 12 TKStringIteratorPlugin types; 13 TKStringIteratorPlugin defaultOptions; 14 TKStringIteratorPlugin diagnostics; 15 TKStringIteratorPlugin hints; 16 17 public TKWMMarkupParamDefinitionIterator ( 18 TKTemplate template, TKMarkupParamDefinition definition, 19 TKVector diags, TKVector hints, TKListIterator oldIterator) { 20 21 this.oldIterator = oldIterator; 22 this.template = template; 23 24 this.diagnostics = new TKStringIteratorPlugin ("ME_DIAGNOSTICS","DIAGNOSTIC",diags,false); 25 this.hints = new TKStringIteratorPlugin ("ME_HINTS","HINT",hints,false); 26 27 boolean hasDiagnostics = (diags == null ? false : diags.size() > 0); 28 if (hasDiagnostics) template.set( "HAS_DIAGNOSTICS", Boolean.TRUE ); 29 30 boolean hasHints = (hints == null ? false : hints.size() > 0); 31 if (hasHints) template.set( "HAS_HINTS", Boolean.TRUE ); 32 33 this.types = new TKStringIteratorPlugin 34 ("VALUE_TYPES","VALUE_TYPE",TKMarkupParamDefinition.allTypes(),true); 35 36 if (definition == null) { 37 38 this.options = null; 39 this.defaultOptions = null; 40 41 } else { 42 template.set( "PARAM_NAME", definition.name); 43 template.set( "PARAM_ID", new Integer (definition.id)); 44 template.set( "PARAM_TYPE", definition.typeClass.name); 45 template.set( "PARAM_IS_CASE_SENSITIVE", new Boolean (definition.isCaseSensitive)); 46 47 if (definition.defaultValue() != null) template.set( "DEFAULT_VALUE", definition.defaultValue()); 48 else template.set( "DEFAULT_VALUE", ""); 49 50 if (definition.isFlag()) this.options = null; 51 else this.options = new TKWMMarkupParamDefinitionOptionsIterator 52 ("VALUE_OPTION_LIST",definition.optionList); 53 54 if (definition.isFlag()) template.set( "DEFAULT_TYPE", "CHECK" ); 55 else if ((definition.optionList != null) && (definition.optionList.size() != 0)) 56 template.set ("DEFAULT_TYPE", "OPTION" ); 57 else template.set( "DEFAULT_TYPE", "TEXT" ); 58 59 if (definition.isFlag()) defaultOptions = null; 60 else if ((definition.optionList != null) && (definition.optionList.size() != 0)) 61 defaultOptions = new TKStringIteratorPlugin ("VALUE_OPTIONS","VALUE_OPTION",definition.optionList,true,""); 62 else defaultOptions = null; 63 } 64 } 65 66 public boolean apply( TKTemplate template, int i, String currListName ) { 67 68 if ((diagnostics != null) && diagnostics.apply (template,currListName,null)) return true; 69 else if ((hints != null) && hints.apply (template,currListName,null)) return true; 70 else if ((options != null) && options.apply (template,currListName,null)) return true; 71 else if ((defaultOptions != null) && defaultOptions.apply (template,currListName,null)) return true; 72 else if ((types != null) && types.apply (template,currListName,null)) return true; 73 else if (oldIterator != null) return oldIterator.apply (template,i,currListName); 74 else return false; 75 } 76 } 79 | Popular Tags |