001: /*
002: * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/field/TKTableColShowIterator.java,v 1.7 2001/02/11 14:48:15 alex Exp $
003: *
004: */
005: package com.teamkonzept.field;
006:
007: import com.teamkonzept.lib.*;
008: import com.teamkonzept.web.*;
009:
010: public class TKTableColShowIterator implements TKListIterator {
011:
012: final static String OUTER_INDEX_KEY = "outerIndex";
013:
014: TKListIterator oldIterator;
015: String outerList;
016: String innerList;
017: TKFieldTableOrientedData dataClass;
018: TKVector fields;
019: int fieldCount;
020: String tableScope;
021: String scope;
022: String fieldTableName;
023: //int outerIndex;
024: String fieldType;
025: TKBaseField rowField;
026: TKBaseField colField;
027: String listRowForInfo;
028:
029: public TKTableColShowIterator(TKFieldTableOrientedData dataClass,
030: TKVector fields, TKBaseField rowField,
031: TKBaseField colField, String scope, String fieldTableName,
032: TKListIterator oldIterator, String outerList,
033: String innerList, String listRowForInfo) {
034: this .oldIterator = oldIterator;
035: this .fields = fields;
036: this .outerList = outerList;
037: this .innerList = innerList;
038: this .dataClass = dataClass;
039: this .fieldCount = fields.size();
040: this .fieldType = fieldType;
041: this .rowField = rowField;
042: this .colField = colField;
043: this .listRowForInfo = listRowForInfo;
044: //this.outerIndex = 0;
045: this .fieldTableName = fieldTableName;
046: this .scope = scope;
047: this .tableScope = scope + "." + fieldTableName;
048:
049: }
050:
051: public boolean apply(TKTemplate t, int i, String currListName) {
052:
053: TKHTMLTemplate template = (TKHTMLTemplate) t;
054:
055: TKVector dataVector = (TKVector) dataClass.contentData;
056:
057: //---- Row mit den Infos ----//
058: if (currListName.equalsIgnoreCase(tableScope + "."
059: + listRowForInfo)) {
060: TKVector colDataVector = dataClass.colData;
061:
062: if ((colDataVector == null) || (i >= colDataVector.size()))
063: return false;
064: template.set("SCOPE", tableScope);
065:
066: TKTableShowIterator.enterEntry(template, i, colDataVector
067: .elementAt(i), colField, tableScope + ".COLS",
068: "COL");
069:
070: return true;
071: }
072: //---- aeussere liste ----//
073: if (currListName.equalsIgnoreCase(tableScope + "." + outerList)) {
074: if ((dataVector == null) || (i >= fields.size()))
075: return false;
076:
077: //outerIndex = i;
078: t.setEnumerationContext(currListName, new Integer(i));
079:
080: template.set("SCOPE", tableScope);
081: TKTableShowIterator.enterCounter(template, i, tableScope,
082: "ROW");
083:
084: //---- Zusatz Row ----//
085: TKVector rowDataVector = dataClass.rowData;
086: if ((rowDataVector != null) && (rowDataVector.size() > 0)) {
087: TKTableShowIterator.enterEntry(template, i,
088: rowDataVector.elementAt(i), rowField,
089: tableScope + ".ROWS", "ROW");
090:
091: }
092: return true;
093: }
094: //---- innere liste ----//
095: else if (currListName.equalsIgnoreCase(tableScope + "."
096: + innerList)) {
097: if (dataVector == null)
098: return false;
099: if (i >= dataVector.size())
100: return false;
101:
102: int outerIndex = ((Integer) t
103: .getEnumerationContext(tableScope + "." + outerList))
104: .intValue();
105: TKBaseField field = (TKBaseField) fields.get(outerIndex);
106: Object data = ((TKVector) dataVector.elementAt(i))
107: .elementAt(outerIndex);
108:
109: TKTableShowIterator.enterEntry(template, i, data, field,
110: tableScope, "COL");
111:
112: //---- Zusatz Row ----//
113: TKVector colDataVector = dataClass.colData;
114: if (colDataVector != null) {
115: TKTableShowIterator.enterEntry(template, i,
116: colDataVector.elementAt(i), colField,
117: tableScope + ".COLS", "COL");
118: }
119:
120: return true;
121: } else if (oldIterator != null) {
122: return oldIterator.apply(template, i, currListName);
123: } else {
124: return false;
125: }
126: }
127:
128: }//end class
|