Source Code Cross Referenced for TKFieldTableOriented.java in  » Content-Management-System » webman » com » teamkonzept » field » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » webman » com.teamkonzept.field 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.teamkonzept.field;
002:
003:        import java.util.Enumeration;
004:        import java.util.StringTokenizer;
005:        import com.teamkonzept.lib.*;
006:        import com.teamkonzept.publishing.markups.*;
007:        import com.teamkonzept.web.*;
008:        import com.teamkonzept.field.db.*;
009:        import org.w3c.dom.*;
010:
011:        /**
012:         * The oriented field table control.
013:         *
014:         * @author $Author: uli $
015:         * @version $Revision: 1.17.4.1 $
016:         */
017:        public abstract class TKFieldTableOriented extends TKBaseField {
018:            // $Id: TKFieldTableOriented.java,v 1.17.4.1 2002/05/06 11:17:06 uli Exp $
019:
020:            public static final String SUB_FIELD_KEY = "SUBFIELD";
021:
022:            public static final String ROW_ENTRY_KEY = "ROWENTRY";
023:            public static final String COL_ENTRY_KEY = "COLENTRY";
024:
025:            public static final String IS_ROWENTRY_KEY = "IS_ROWENTRY";
026:            public static final String IS_COLENTRY_KEY = "IS_COLENTRY";
027:            public static final String ROW_JANEIN_KEY = "JANEINZEILE";
028:            public static final String COL_JANEIN_KEY = "JANEINSPALTE";
029:
030:            public static final String ZUSATZ_KEY = "ZUSATZ";
031:            public static final String CELLINFO_KEY = "CELL";
032:            public static final String NOCELLINFO_KEY = "NOCELL";
033:            public static final String BOOL_ZUSATZ_ROW = "BOOLZUSATZROW";
034:            public static final String BOOL_ZUSATZ_COL = "BOOLZUSATZCOL";
035:
036:            public static final String PRE_COLS = "COL";
037:            public static final String PRE_ROWS = "ROW";
038:
039:            /** true wenn Cell*/
040:            public boolean isRowCell;
041:            /** true wenn Cell*/
042:            public boolean isColCell;
043:
044:            TKBaseField rowEntry;
045:            TKBaseField colEntry;
046:
047:            TKVector fieldList;
048:            TKHashtable tableFields;
049:
050:            /**
051:             * Creates an empty oriented field table control.
052:             */
053:            public TKFieldTableOriented() {
054:                // NOP
055:            }
056:
057:            /**
058:             * Creates an oriented field table control with the specified
059:             * properties.
060:             *
061:             * @param fieldType the field type.
062:             * @param name the name.
063:             * @param fields the fields.
064:             */
065:            public TKFieldTableOriented(String fieldType, String name,
066:                    TKVector fields) {
067:                this (fieldType, name, fields, null, null);
068:            }
069:
070:            /**
071:             * Creates an oriented field table control with the specified
072:             * properties.
073:             *
074:             * @param fieldType the field type.
075:             * @param name the name.
076:             * @param fields the fields.
077:             * @param rowEntry the row entry.
078:             * @param colEntry the column entry.
079:             */
080:            public TKFieldTableOriented(String fieldType, String name,
081:                    TKVector fields, TKBaseField rowEntry, TKBaseField colEntry) {
082:                this (fieldType, name, fields, rowEntry, colEntry, null);
083:            }
084:
085:            /**
086:             * Creates an oriented field table control with the specified
087:             * properties.
088:             *
089:             * @param fieldType the field type.
090:             * @param name the name.
091:             * @param fields the fields.
092:             * @param rowEntry the row entry.
093:             * @param colEntry the column entry.
094:             * @param showName the description.
095:             */
096:            public TKFieldTableOriented(String fieldType, String name,
097:                    TKVector fields, TKBaseField rowEntry,
098:                    TKBaseField colEntry, String showName) {
099:                initFieldTableOriented(fieldType, name, fields, rowEntry,
100:                        colEntry, showName);
101:            }
102:
103:            public final void initFieldTableOriented(String fieldType,
104:                    String name, TKVector fields, TKBaseField rowEntry,
105:                    TKBaseField colEntry, String showName) {
106:                initBaseField(fieldType, name, showName);
107:                this .fieldList = fields;
108:                this .tableFields = getFieldHashFromList(fields);
109:                this .rowEntry = rowEntry;
110:                this .colEntry = colEntry;
111:            }
112:
113:            public void init(String fieldType, Object data)
114:                    throws TKUnregisteredClassException,
115:                    ClassNotFoundException, InstantiationException,
116:                    IllegalAccessException {
117:                super .init(fieldType, data);
118:                TKHashtable tableData = (TKHashtable) data;
119:                this .fieldList = getListOfFields((TKFieldSwitchListData) tableData
120:                        .get(SUB_LIST_KEY));
121:                this .tableFields = getFieldHashFromList(fieldList);
122:                //--------------------------------------------------------//
123:                //---- Objekt fuer die Row filtern und registrieren ----//
124:                //--------------------------------------------------------//
125:                TKFieldOptionData rowData = (TKFieldOptionData) tableData
126:                        .get(ROW_JANEIN_KEY);
127:                initSubFields(rowData, true);
128:
129:                //--------------------------------------------------------//
130:                //---- Objekt fuer die Col filtern und registrieren ----//
131:                //--------------------------------------------------------//
132:                TKFieldOptionData colData = (TKFieldOptionData) tableData
133:                        .get(COL_JANEIN_KEY);
134:                initSubFields(colData, false);
135:            }
136:
137:            /**
138:             * Hilfsmethode fuer init()
139:             */
140:            public void initSubFields(TKFieldOptionData optionData,
141:                    boolean initRow) throws TKUnregisteredClassException,
142:                    ClassNotFoundException, InstantiationException,
143:                    IllegalAccessException
144:
145:            {
146:
147:                if (optionData.data != null) {
148:                    TKHashtable optionDataHash = (TKHashtable) optionData.data;
149:
150:                    //--------------------------------------------------//
151:                    //---- Zusatzinfos  in globaler Variable merken----//
152:                    //--------------------------------------------------//
153:                    String selectedVal = (String) optionDataHash
154:                            .get(ZUSATZ_KEY);
155:
156:                    if (initRow) {
157:                        if (selectedVal.equals(CELLINFO_KEY))
158:                            this .isRowCell = true;
159:                        else
160:                            this .isRowCell = false;
161:                    } else {
162:                        if (selectedVal.equals(CELLINFO_KEY))
163:                            this .isColCell = true;
164:                        else
165:                            this .isColCell = false;
166:                    }
167:
168:                    TKFieldSwitchData subType = (TKFieldSwitchData) optionDataHash
169:                            .get(SUB_TYPE_KEY);
170:
171:                    if (subType.alternative.length() == 0)
172:                        throw new InstantiationException("no tabletype for "
173:                                + fieldType + " " + fieldName);
174:                    if (initRow) {
175:                        this .rowEntry = (TKBaseField) TKFieldRegistry.registry
176:                                .get(subType.alternative, subType.data);
177:                    } else {
178:                        this .colEntry = (TKBaseField) TKFieldRegistry.registry
179:                                .get(subType.alternative, subType.data);
180:                    }
181:
182:                } else {
183:                    if (initRow) {
184:                        rowEntry = null;
185:                    } else {
186:                        colEntry = null;
187:                    }
188:                }
189:            }
190:
191:            /**
192:             * Returns the internal representation of this field.
193:             *
194:             * @return the internal representation of this field.
195:             */
196:            public Object toData() {
197:                TKHashtable result = (TKHashtable) super .toData();
198:                result.put(SUB_LIST_KEY, getDataOfAlternatives(fieldList));
199:
200:                //--------------------------------------------------//
201:                //---- ROW ueber TKFieldOption wiederherstellen ----//
202:                //--------------------------------------------------//
203:                TKFieldOptionData rowEntryOption = null;
204:                result = toDataSubFields(rowEntryOption, rowEntry, result,
205:                        "row");
206:
207:                //--------------------------------------------------//
208:                //---- COL ueber TKFieldOption wiederherstellen ----//
209:                //--------------------------------------------------//
210:                TKFieldOptionData colEntryOption = null;
211:                result = toDataSubFields(colEntryOption, colEntry, result,
212:                        "col");
213:                return result;
214:            }
215:
216:            /**
217:             * Hilfsmethode fuer toData()
218:             */
219:            public TKHashtable toDataSubFields(TKFieldOptionData entryOption,
220:                    TKBaseField rowOrColEntry, TKHashtable result,
221:                    String rowOrCol) {
222:                if (rowOrColEntry != null) {
223:                    //----------------------------------------------//
224:                    //---- Das Switch wiederherstellen und in  	----//
225:                    //---- einen Hash fuer dieGruppe packen 	----//
226:                    //----------------------------------------------//
227:                    TKHashtable groupData = new TKHashtable();
228:                    groupData.put(SUB_TYPE_KEY, new TKFieldSwitchData(
229:                            rowOrColEntry.getType(), rowOrColEntry.getType(),
230:                            rowOrColEntry.toData()));
231:                    //----------------------------------------------------------//
232:                    //---- Pulldownmenue wieder herstellen und in den Hash  ----//
233:                    //---- fuer dieGruppe packen					 		----//
234:                    //----------------------------------------------------------//
235:                    if (rowOrCol.equals("row")) {
236:                        if (isRowCell) {
237:                            groupData.put(ZUSATZ_KEY, "CELL");
238:                        } else {
239:                            groupData.put(ZUSATZ_KEY, "NOCELL");
240:                        }
241:                    }
242:
243:                    if (rowOrCol.equals("col")) {
244:                        if (isColCell) {
245:                            groupData.put(ZUSATZ_KEY, "CELL");
246:                        } else {
247:                            groupData.put(ZUSATZ_KEY, "NOCELL");
248:                        }
249:                    }
250:
251:                    //---------------------------------------------------//
252:                    //---- Switch-Auswahl wenn yes ausgewaehlt wurde ----//
253:                    //---------------------------------------------------//
254:                    entryOption = new TKFieldOptionData("YES", "YES", groupData);
255:                } else {
256:                    entryOption = new TKFieldOptionData("NO", "NO", null);
257:                }
258:                if (rowOrCol.equals("row"))
259:                    result.put(ROW_JANEIN_KEY, entryOption);
260:                if (rowOrCol.equals("col"))
261:                    result.put(COL_JANEIN_KEY, entryOption);
262:
263:                return result;
264:            }
265:
266:            public final String subPrefix(String prefix) {
267:                return prefix + fieldName + ".";
268:            }
269:
270:            public TKBaseField getTarget(String fieldPath, String prefix) {
271:                TKBaseField targetField = null;
272:                int pLength = prefix.length() + fieldName.length();
273:
274:                //-------------------------------------//
275:                //---- action betrifft Sub-ELement ----//
276:                //-------------------------------------//
277:                if ((fieldPath.length() != pLength)
278:                        && (fieldPath.length() - 3 != pLength)) {
279:                    String subZusatz = fieldPath.substring(pLength + 1);
280:                    if (subZusatz.startsWith(PRE_ROWS)) {
281:                        subZusatz = subZusatz.substring(PRE_ROWS.length() + 1);
282:                        int idxEnd = subZusatz.indexOf('.');
283:                        String idxStr = subZusatz.substring(0, idxEnd);
284:                        int idx = Integer.parseInt(idxStr);
285:
286:                        targetField = rowEntry.getTarget(fieldPath, prefix
287:                                + fieldName + '.' + PRE_ROWS + "." + idx + '.');
288:
289:                    }
290:                    //---- modify des SubElementes in einer ZusatzCol ----//
291:                    else if (subZusatz.startsWith(PRE_COLS)) {
292:                        subZusatz = subZusatz.substring(PRE_COLS.length() + 1);
293:                        int idxEnd = subZusatz.indexOf('.');
294:                        String idxStr = subZusatz.substring(0, idxEnd);
295:                        int idx = Integer.parseInt(idxStr);
296:
297:                        targetField = colEntry.getTarget(fieldPath, prefix
298:                                + fieldName + '.' + PRE_COLS + "." + idx + '.');
299:
300:                    }
301:                    //---- modify des SubElementes in einer Zelle ----//
302:                    else {
303:                        String subName = fieldPath.substring(pLength + 5);
304:                        TKBaseField field = (TKBaseField) tableFields
305:                                .get(subName);
306:
307:                        String subPath = fieldPath.substring(pLength + 1);
308:                        StringTokenizer getToken = new StringTokenizer(subPath,
309:                                ".");
310:                        int rowIdx = Integer.parseInt((String) getToken
311:                                .nextElement());
312:                        int colIdx = Integer.parseInt((String) getToken
313:                                .nextElement());
314:                        field = (TKBaseField) fieldList.get(colIdx);
315:                        targetField = field
316:                                .getTarget(fieldPath, prefix + fieldName + "."
317:                                        + rowIdx + "." + colIdx + ".");
318:                    }
319:                }
320:                return targetField;
321:            }
322:
323:            public void fillIntoTemplate(TKHTMLTemplate t, Object data,
324:                    String prefix) {
325:                super .fillIntoTemplate(t, data, prefix);
326:            }
327:
328:            public void fillIntoDOM(Document doc, Element node, Object data)
329:                    throws DOMException {
330:                Element me = doc.createElement(getInternationalName());
331:                node.appendChild(me);
332:                fillAttributesIntoNode(me, data);
333:                // NICHT FERTIG !!!!! oder doch ?
334:            }
335:
336:            public abstract Object compileData(String prefix, TKHashtable data,
337:                    TKHashtable context);
338:
339:            public abstract Object compileData(String prefix,
340:                    TKMarkupNode data, TKHashtable context);
341:
342:            public Object getDefault() {
343:                return new TKFieldTableOrientedData(null, null, null);
344:            }
345:
346:            public void clearId() {
347:                if (fieldId == -1)
348:                    return;
349:
350:                fieldId = -1;
351:                Enumeration e = fieldList.elements();
352:                while (e.hasMoreElements()) {
353:                    ((TKBaseField) e.nextElement()).clearId();
354:                }
355:                if (rowEntry != null)
356:                    rowEntry.clearId();
357:                if (colEntry != null)
358:                    colEntry.clearId();
359:
360:            }
361:
362:            //***********************************************************************
363:            public int realInsertIntoDB(TKFormDBData db, int formId) {
364:                //---- table fieldlist ----//
365:                if (super .realInsertIntoDB(db, formId) == -1)
366:                    return -1;
367:
368:                insertNewSubFieldList(db, formId, SUB_FIELD_KEY, fieldList);
369:
370:                //------------------------------------------------------------------//
371:                //---- Diese Attribute zuerst setzen, da hieraus erkennbar ist, ----//
372:                //---- ob ein colEntry oder rowEntry vorhanden ist				----//
373:                //------------------------------------------------------------------//
374:                if (rowEntry != null)
375:                    insertNewFieldAttribute(db, formId, IS_ROWENTRY_KEY, 0,
376:                            String.valueOf(1));
377:                else
378:                    insertNewFieldAttribute(db, formId, IS_ROWENTRY_KEY, 0,
379:                            String.valueOf(0));
380:
381:                if (colEntry != null)
382:                    insertNewFieldAttribute(db, formId, IS_COLENTRY_KEY, 0,
383:                            String.valueOf(1));
384:                else
385:                    insertNewFieldAttribute(db, formId, IS_COLENTRY_KEY, 0,
386:                            String.valueOf(0));
387:
388:                //---- rowEntry ----//
389:                if (rowEntry != null) {
390:                    //---- Was wurde im Pulldown ausgewaehlt => true oder false merken ----//
391:                    insertNewFieldAttribute(db, formId, BOOL_ZUSATZ_ROW, 0,
392:                            String.valueOf(isRowCell));
393:
394:                    TKSubFieldTableData subFieldDBRow = insertNewSubField(db,
395:                            formId, ROW_ENTRY_KEY, 0);
396:                    rowEntry.realInsertIntoDB(db, formId);
397:                    subFieldDBRow.sub_field_id = rowEntry.fieldId;
398:
399:                }
400:
401:                //---- colEntry ----//
402:                if (colEntry != null) {
403:                    //---- Was wurde im Pulldown ausgewaehlt => true oder false merken ----//
404:                    insertNewFieldAttribute(db, formId, BOOL_ZUSATZ_COL, 0,
405:                            String.valueOf(isColCell));
406:
407:                    TKSubFieldTableData subFieldDBCol = insertNewSubField(db,
408:                            formId, COL_ENTRY_KEY, 0);
409:                    colEntry.realInsertIntoDB(db, formId);
410:                    subFieldDBCol.sub_field_id = colEntry.fieldId;
411:                }
412:
413:                return fieldId;
414:            }
415:
416:            //***********************************************************************
417:            public void initFromDB(String classId, TKFormDBData db,
418:                    TKVector otherFields) throws TKUnregisteredClassException,
419:                    ClassNotFoundException, InstantiationException,
420:                    IllegalAccessException {
421:
422:                super .initFromDB(classId, db, otherFields);
423:                fieldList = getSubFieldList(db, SUB_FIELD_KEY, otherFields);
424:                tableFields = getFieldHashFromList(fieldList);
425:
426:                //---- Attribute, welche ZusatzBaseFields aufgebaut werden muessen ----//
427:                int isRowEntry = Integer.parseInt(getFieldAttribute(db,
428:                        IS_ROWENTRY_KEY, 0));
429:                int isColEntry = Integer.parseInt(getFieldAttribute(db,
430:                        IS_COLENTRY_KEY, 0));
431:
432:                if (isRowEntry == 1) {
433:                    //---- Attribute, was aus dem Pulldown Ausgewaehlt wurde  fuer Row ----//
434:                    String zusatzInfoRow = getFieldAttribute(db,
435:                            BOOL_ZUSATZ_ROW, 0);
436:                    isRowCell = (zusatzInfoRow.equalsIgnoreCase("true")) ? true
437:                            : false;
438:
439:                    rowEntry = getSubField(db, ROW_ENTRY_KEY, 0, otherFields);
440:                }
441:
442:                if (isColEntry == 1) {
443:                    //---- Attribute, was aus dem Pulldown Ausgewaehlt wurde  fuer Col ----//
444:                    String zusatzInfoCol = getFieldAttribute(db,
445:                            BOOL_ZUSATZ_COL, 0);
446:                    isColCell = (zusatzInfoCol.equalsIgnoreCase("true")) ? true
447:                            : false;
448:
449:                    colEntry = getSubField(db, COL_ENTRY_KEY, 0, otherFields);
450:                }
451:            }
452:
453:            /**
454:             * Checks wether this object and the specified object
455:             * may be treated as equal.
456:             *
457:             * @param object the object to checked for equality.
458:             * @return <CODE>true</CODE> if this object and the
459:             * specified object may be treated as equal, otherwise
460:             * <CODE>false</CODE>.
461:             */
462:            public boolean equals(Object object) {
463:                if (!super .equals(object)) {
464:                    return false;
465:                }
466:
467:                TKFieldTableOriented field = (TKFieldTableOriented) object;
468:
469:                return (this .isRowCell == field.isRowCell)
470:                        && (this .isColCell == field.isColCell)
471:                        && (this .fieldList == null ? field.fieldList == null
472:                                : this .fieldList.equals(field.fieldList))
473:                        && (this .rowEntry == null ? field.rowEntry == null
474:                                : this .rowEntry.equals(field.rowEntry))
475:                        && (this .colEntry == null ? field.colEntry == null
476:                                : this .colEntry.equals(field.colEntry));
477:            }
478:
479:            /**
480:             * Returns the hash code for this object.
481:             *
482:             * @return the hash code for this object.
483:             */
484:            public int hashCode() {
485:                // Implementation for JTest only ;-(
486:                return super.hashCode();
487:            }
488:
489:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.