1 5 36 package com.teamkonzept.field; 37 38 import com.teamkonzept.lib.*; 39 import com.teamkonzept.web.*; 40 41 public class TKTableShowIterator implements TKListIterator { 42 43 TKListIterator oldIterator; 44 String outerList; 45 String innerList; 46 TKFieldTableRealData dataClass; 47 String tableScope; 48 String scope; 49 String fieldTableName; 50 String fieldType; 52 TKBaseField rowField; 53 TKBaseField colField; 54 TKBaseField contentField; 55 String listRowForInfo; 56 57 58 public TKTableShowIterator ( 59 TKFieldTableRealData dataClass, 60 TKBaseField contentField, 61 TKBaseField rowField, 62 TKBaseField colField, 63 String scope, 64 String fieldTableName, 65 TKListIterator oldIterator, 66 String outerList, 67 String innerList, 68 String listRowForInfo 69 ) 70 { 71 this.oldIterator = oldIterator; 72 this.outerList = outerList; 73 this.innerList = innerList; 74 this.dataClass = dataClass; 75 this.fieldType = fieldType; 76 this.rowField = rowField; 77 this.colField = colField; 78 this.contentField = contentField; 79 this.listRowForInfo = listRowForInfo; 80 this.fieldTableName = fieldTableName; 82 this.scope = scope; 83 this.tableScope = scope+"."+fieldTableName; 84 85 } 86 87 88 93 public static final void enterCounter( 94 TKHTMLTemplate t, 95 int idx, 96 String scope, 97 String kind 98 ) 99 { 100 t.set( scope+"."+kind+"IDX", String.valueOf(idx+1) ); 101 if( idx % 2 == 1 ) t.set( scope+".ODD"+kind, Boolean.TRUE ); 102 } 103 104 public static final void enterEntry( 105 TKHTMLTemplate t, 106 int idx, 107 Object data, 108 TKBaseField showField, 109 String scope, 110 String kind 111 ) 112 { 113 enterCounter( t, idx, scope, kind ); 114 showField.fillIntoPresentation( t, data, scope ); 115 } 116 117 public boolean apply( TKTemplate t, int i, String currListName ) 118 { 119 TKHTMLTemplate template = (TKHTMLTemplate) t; 120 TKVector dataVector = (TKVector) dataClass.contentData; 121 if( currListName.equalsIgnoreCase(tableScope+"."+listRowForInfo)) 123 { 124 TKVector colDataVector = dataClass.colData; 125 if( (colDataVector == null) || (i >= colDataVector.size())) return false; 126 127 template.set( "SCOPE", tableScope ); 128 enterEntry( template, i, colDataVector.elementAt(i), colField, tableScope+".COLS", "COL" ); 129 return true; 130 } 131 if( currListName.equalsIgnoreCase(tableScope+"."+outerList) ) { 133 if( (dataVector == null) || (i >= dataVector.size()) ) return false; 134 template.setEnumerationContext( currListName, new Integer (i) ); 136 template.set( "SCOPE", tableScope ); 137 enterCounter( template, i, tableScope, "ROW" ); 138 139 TKVector rowDataVector = dataClass.rowData; 141 if( (rowDataVector != null) && (rowDataVector.size() > 0) ) { 142 enterEntry( template, i, rowDataVector.elementAt(i), rowField, tableScope+".ROWS", "ROW" ); 143 } 144 return true; 145 } 146 else if( currListName.equalsIgnoreCase(tableScope+"."+innerList) ) { 148 if(dataVector == null) return false; 149 150 int outerIndex = ((Integer )template.getEnumerationContext(tableScope+"."+outerList)).intValue(); 151 TKVector dataRow = (TKVector)dataVector.get(outerIndex); 152 if( i >= dataRow.size() ) return false; 153 154 enterEntry( template, i, dataRow.get(i), contentField, tableScope, "COL" ); 155 156 TKVector colDataVector = dataClass.colData; 158 if( (colDataVector != null) ) { 159 enterEntry( template, i, colDataVector.elementAt(i), colField, tableScope+".COLS", "COL" ); 160 } 161 162 return true; 163 } 164 else if( oldIterator != null ) { 165 return oldIterator.apply( template, i, currListName ); 166 } 167 else { 168 return false; 169 } 170 } 171 } 173
| Popular Tags
|