Source Code Cross Referenced for TKFieldTableRowOriented.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.*;
004:        import com.teamkonzept.lib.*;
005:        import com.teamkonzept.publishing.markups.*;
006:        import com.teamkonzept.web.*;
007:        import com.teamkonzept.field.db.*;
008:        import com.teamkonzept.international.LanguageManager;
009:
010:        public class TKFieldTableRowOriented extends TKFieldTableOriented {
011:            // $Id: TKFieldTableRowOriented.java,v 1.17 2001/09/21 14:22:06 uli Exp $
012:
013:            public static final String CLASS_ID = "FIELDTABLEROWORIENTED";
014:
015:            public TKFieldTableRowOriented() {
016:            }
017:
018:            public TKFieldTableRowOriented(String name, TKVector fields) {
019:                this (name, fields, null, null);
020:            }
021:
022:            public TKFieldTableRowOriented(String name, TKVector fields,
023:                    TKBaseField rowEntry, TKBaseField colEntry) {
024:                this (name, fields, rowEntry, colEntry, null);
025:            }
026:
027:            public TKFieldTableRowOriented(String name, TKVector fields,
028:                    TKBaseField rowEntry, TKBaseField colEntry, String showName) {
029:                initFieldTableRowOriented("FIELDTABLEROWORIENTED", name,
030:                        fields, rowEntry, colEntry, showName);
031:            }
032:
033:            public final void initFieldTableRowOriented(String fieldType,
034:                    String name, TKVector fields, TKBaseField rowEntry,
035:                    TKBaseField colEntry, String showName) {
036:                initFieldTableOriented("FIELDTABLEROWORIENTED", name, fields,
037:                        rowEntry, colEntry, showName);
038:
039:            }
040:
041:            /**
042:             * Methode zur Definition Row-Orientierter Tabellen
043:             */
044:            public TKFieldGroup getDefGroup(TKFieldSwitch allSwitch,
045:                    TKFieldSwitchList allSwitchList) {
046:
047:                TKBaseField[] groupTableArray = { allSwitchList };
048:
049:                //======================= Switch und Check =================//
050:                //---- Eine Checkbox, falls "Yes" selectiert wurde ----//
051:                TKVector singleCheckVector = new TKVector(2);
052:                singleCheckVector.addElement(new TKOptionFieldEntry(
053:                        LanguageManager.getText(LANGUAGE_CONTEXT,
054:                                "FIELDTABLE_CELL"), "CELL"));
055:                singleCheckVector.addElement(new TKOptionFieldEntry(
056:                        LanguageManager.getText(LANGUAGE_CONTEXT,
057:                                "FIELDTABLE_ROW_COLUMN"), "NOCELL"));
058:
059:                TKBaseField[] switchAndCheckArray = {
060:                        new TKSelectField("ZUSATZ", LanguageManager.getText(
061:                                LANGUAGE_CONTEXT, "FIELDTABLE_ADDINFO"),
062:                                singleCheckVector), allSwitch };
063:
064:                //======================= SPALTENINFOS =================//
065:                //---- Gruppe wird erzeugt mit einer Switchauswahl und einer Checkbox ----//
066:                TKFieldGroup switchAndCheckGroup = new TKFieldGroup(
067:                        TKFieldOption.CLASS_ID, new TKVector(
068:                                switchAndCheckArray), LanguageManager.getText(
069:                                LANGUAGE_CONTEXT, "FIELDTABLE_INFOCOLUMN"));
070:
071:                //================== ZEILENINFOS =====================/
072:                //---- Gruppe wird erzeugt mit einer Switchauswahl und einer Checkbox ----//
073:                TKFieldGroup switchAndCheckGroup2 = new TKFieldGroup(
074:                        TKFieldOption.CLASS_ID, new TKVector(
075:                                switchAndCheckArray), LanguageManager.getText(
076:                                LANGUAGE_CONTEXT, "FIELDTABLE_INFOROW"));
077:
078:                //========================= TABELLE ==================================//
079:                TKFieldGroup groupGroupTable = new TKFieldGroup(
080:                        TKFieldGroup.CLASS_ID, new TKVector(groupTableArray),
081:                        LanguageManager.getText(LANGUAGE_CONTEXT,
082:                                "FIELDTABLE_GROUPING"));
083:
084:                TKBaseField[] tableRowOrientedArray = {
085:                        new TKInputField(TKFieldTableRowOriented.NAME_KEY, 16,
086:                                80, LanguageManager.getText(LANGUAGE_CONTEXT,
087:                                        "FIELDTABLE_NAME"),
088:                                TKInputField.CHECK_STRING),
089:                        new TKInputField(TKFieldTableRowOriented.SHOW_NAME_KEY,
090:                                50, 254, LanguageManager
091:                                        .getText(LANGUAGE_CONTEXT,
092:                                                "FIELDTABLE_SHOWNAME"),
093:                                TKInputField.CHECK_STRING),
094:                        allSwitchList,
095:                        new TKFieldOption("JANEINSPALTE", switchAndCheckGroup,
096:                                LanguageManager.getText(LANGUAGE_CONTEXT,
097:                                        "FIELDTABLE_JANEINSPALTE")),
098:                        new TKFieldOption("JANEINZEILE", switchAndCheckGroup2,
099:                                LanguageManager.getText(LANGUAGE_CONTEXT,
100:                                        "FIELDTABLE_JANEINZEILE"))
101:
102:                };
103:
104:                TKFieldGroup tableRowOrientedGroup = new TKFieldGroup(
105:                        TKFieldTableRowOriented.CLASS_ID, new TKVector(
106:                                tableRowOrientedArray), LanguageManager
107:                                .getText(LANGUAGE_CONTEXT,
108:                                        TKFieldTableRowOriented.CLASS_ID));
109:
110:                return tableRowOrientedGroup;
111:            }
112:
113:            //***********************************************************************
114:            public Object compileData(String prefix, TKHashtable data,
115:                    TKHashtable context) {
116:                int entryCount = fieldList.size();
117:                if (entryCount == 0)
118:                    return new TKFieldTableOrientedData(null, null, null);
119:
120:                TKVector result = new TKVector(1);
121:                TKVector colVector = null;
122:                prefix = subPrefix(prefix);
123:
124:                int tableSize = Integer.parseInt((String) data.get(prefix
125:                        + "SIZE"));
126:
127:                int cols = entryCount;
128:                int rows = tableSize;
129:
130:                //-----------------------------------//
131:                //---- Data fuer eine zusatz ROW ----//
132:                //-----------------------------------//
133:                TKVector rowInfoVector = null;
134:                if (rowEntry != null) {
135:
136:                    rowInfoVector = new TKVector();
137:                    for (int x = 0; x < rows; x++) {
138:                        rowInfoVector.addElement(rowEntry.compileData(prefix
139:                                + PRE_ROWS + "." + x + ".", data, context));
140:                    }
141:                }
142:
143:                //---------------------------------------//
144:                //---- Data fuer eine zusatz COLUMN  ----//
145:                //---------------------------------------//
146:                TKVector colInfoVector = null;
147:                if ((colEntry != null) && (cols > 0)) {
148:                    colInfoVector = new TKVector(cols);
149:                    if (rows > 0) {
150:                        for (int x = 0; x < cols; x++) {
151:                            colInfoVector.addElement(colEntry.compileData(
152:                                    prefix + PRE_COLS + "." + x + ".", data,
153:                                    context));
154:                        }
155:                    } else {
156:                        for (int x = 0; x < cols; x++) {
157:                            colInfoVector.addElement(colEntry.getDefault());
158:                        }
159:                    }
160:                }
161:
162:                //-----------------//
163:                //---- tabelle ----//
164:                //-----------------//
165:                for (int x = 0; x < tableSize; x++) {
166:                    colVector = new TKVector(entryCount);
167:                    for (int y = 0; y < entryCount; y++) {
168:                        TKBaseField field = (TKBaseField) fieldList.get(y);
169:                        colVector.addElement(field.compileData(prefix + x + "."
170:                                + y + ".", data, context));
171:                    }
172:                    result.addElement(colVector);
173:                }
174:                return new TKFieldTableOrientedData(result, rowInfoVector,
175:                        colInfoVector);
176:
177:            }
178:
179:            public Object compileData(String prefix, TKMarkupNode data,
180:                    TKHashtable context) {
181:                int entryCount = fieldList.size();
182:
183:                if (entryCount == 0)
184:                    return new TKFieldTableOrientedData(null, null, null);
185:
186:                TKXmlMarkup markup = data == null ? null
187:                        : (TKXmlMarkup) data.markup;
188:                if (markup == null) {
189:                    return null;
190:                }
191:
192:                if (!markup.name.equals(getName())) {
193:                    return null;
194:                }
195:
196:                TKXmlTree tree = (TKXmlTree) data.tree;
197:                if (tree == null) {
198:                    return null;
199:                }
200:
201:                TKVector rowInfoVector = null;
202:                TKVector colInfoVector = null;
203:                TKVector result = null;
204:
205:                int x = 0;
206:
207:                for (int i = 0; i < tree.size(); i++) {
208:
209:                    Object obj = tree.getSub(i);
210:                    if (obj == null)
211:                        continue;
212:
213:                    TKMarkupNode subNode = null;
214:                    TKXmlMarkup subMarkup = null;
215:
216:                    if (obj instanceof  TKXmlMarkup) { // Atomares Markup
217:
218:                        subMarkup = (TKXmlMarkup) obj;
219:                        continue;
220:
221:                    } else {
222:                        subNode = (TKMarkupNode) obj;
223:                        subMarkup = (TKXmlMarkup) subNode.markup;
224:                    }
225:
226:                    if (subMarkup.name.equals("CI")) {
227:
228:                        TKXmlTree subTree = (TKXmlTree) subNode.tree;
229:                        if (subTree == null) {
230:                            continue;
231:                        }
232:
233:                        for (int j = 0; j < subTree.size(); j++) {
234:
235:                            Object subObj = subTree.getSub(j);
236:                            if (subObj == null)
237:                                continue;
238:
239:                            TKMarkupNode subSubNode = null;
240:                            TKXmlMarkup subSubMarkup = null;
241:
242:                            if (subObj instanceof  TKXmlMarkup) { // Atomares Markup
243:
244:                                subSubMarkup = (TKXmlMarkup) subObj;
245:                                subSubNode = new TKMarkupNode(subSubMarkup,
246:                                        null);
247:
248:                            } else {
249:                                subSubNode = (TKMarkupNode) subObj;
250:                                subSubMarkup = (TKXmlMarkup) subSubNode.markup;
251:                            }
252:
253:                            if (colInfoVector == null)
254:                                colInfoVector = new TKVector();
255:                            colInfoVector.addElement(colEntry.compileData(
256:                                    prefix + j + ".", subSubNode, context));
257:                        }
258:                    }
259:
260:                    else if (subMarkup.name.equals("TR")) {
261:
262:                        TKVector colsResultVector = null;
263:
264:                        TKXmlTree subTree = (TKXmlTree) subNode.tree;
265:                        if (subTree == null) {
266:                            continue;
267:                        }
268:
269:                        int y = 0;
270:                        for (int j = 0; j < subTree.size(); j++) {
271:
272:                            Object subObj = subTree.getSub(j);
273:                            if (subObj == null)
274:                                continue;
275:
276:                            if (y >= entryCount) {
277:
278:                                break;
279:                            }
280:                            TKMarkupNode subSubNode = null;
281:                            TKXmlMarkup subSubMarkup = null;
282:
283:                            if (subObj instanceof  TKXmlMarkup) { // Atomares Markup
284:
285:                                subSubMarkup = (TKXmlMarkup) subObj;
286:                                subSubNode = new TKMarkupNode(subSubMarkup,
287:                                        null);
288:
289:                            } else {
290:                                subSubNode = (TKMarkupNode) subObj;
291:                                subSubMarkup = (TKXmlMarkup) subSubNode.markup;
292:                            }
293:
294:                            TKXmlTree subSubTree = (TKXmlTree) subSubNode.tree;
295:                            Object subSubObj = subSubTree.getSingleSub();
296:                            if (subSubObj == null)
297:                                continue;
298:
299:                            TKMarkupNode subSubSubNode = null;
300:                            TKXmlMarkup subSubSubMarkup = null;
301:
302:                            if (subSubObj instanceof  TKXmlMarkup) { // Atomares Markup
303:
304:                                subSubSubMarkup = (TKXmlMarkup) subSubObj;
305:                                subSubSubNode = new TKMarkupNode(
306:                                        subSubSubMarkup, null);
307:
308:                            } else {
309:                                subSubSubNode = (TKMarkupNode) subSubObj;
310:                                subSubSubMarkup = (TKXmlMarkup) subSubSubNode.markup;
311:                            }
312:
313:                            if (subSubMarkup.name.equals("RI")) {
314:
315:                                if (rowInfoVector == null)
316:                                    rowInfoVector = new TKVector();
317:                                rowInfoVector.addElement(rowEntry.compileData(
318:                                        prefix + j + ".", subSubSubNode,
319:                                        context));
320:                            } else {
321:                                if (result == null)
322:                                    result = new TKVector();
323:                                if (colsResultVector == null) {
324:
325:                                    colsResultVector = new TKVector();
326:                                    result.addElement(colsResultVector);
327:                                }
328:
329:                                TKBaseField field = (TKBaseField) fieldList
330:                                        .get(y);
331:                                if (field == null)
332:                                    ;
333:                                else
334:                                    colsResultVector.addElement(field
335:                                            .compileData(prefix + x + "." + y
336:                                                    + ".", subSubSubNode,
337:                                                    context));
338:                                y++;
339:                            }
340:                        }
341:
342:                        x++;
343:                    }
344:
345:                    else {
346:                        ;
347:                    }
348:                }
349:
350:                return new TKFieldTableOrientedData(result, rowInfoVector,
351:                        colInfoVector);
352:            }
353:
354:            public void fillIntoTemplate(TKHTMLTemplate t, Object data,
355:                    String prefix) {
356:                TKFieldTableOrientedData dataClass = (TKFieldTableOrientedData) data;
357:                TKVector dataVector = (TKVector) dataClass.contentData;
358:                super .fillIntoTemplate(t, data, prefix);
359:
360:                if (dataVector == null) {
361:                    t.set("SIZE", "0");
362:                } else {
363:                    t.set("SIZE", String.valueOf(dataVector.size()));
364:                    t.set("IS_OUTERLIST", Boolean.TRUE);
365:                }
366:
367:                int rows = (dataVector == null ? 0 : dataVector.size());
368:                int cols = fieldList.size();
369:
370:                if ((TKVector) dataClass.rowData != null)
371:                    t.set("IS_COLFORINFOS", Boolean.TRUE);
372:
373:                if ((TKVector) dataClass.colData != null)
374:                    t.set("IS_ROWFORINFOS", Boolean.TRUE);
375:
376:                t.setListIterator(new TKFieldTableRowOrientedIterator(
377:                        dataClass, fieldList, rowEntry, colEntry,
378:                        subPrefix(prefix), t.getListIterator(), "OUTERLIST",
379:                        "INNERLIST", "ROWFORINFOLIST", fieldType));
380:
381:                //t.set( "FIELDTABLELIST", Boolean.TRUE );
382:            }
383:
384:            public void fillIntoPresentation(TKHTMLTemplate t, Object data,
385:                    String scope) {
386:                TKFieldTableOrientedData dataClass = (TKFieldTableOrientedData) data;
387:                TKVector dataVector = (TKVector) dataClass.contentData;
388:
389:                t.set(scope + "." + getName() + ".COLSIZE", String
390:                        .valueOf(dataVector.size()));
391:                t.set(scope + "." + getName() + ".ROWSIZE", String
392:                        .valueOf(fieldList.size()));
393:
394:                //---- tabellenlayout ----//
395:                if ((TKVector) dataClass.rowData != null)
396:                    t.set("IS_ROWENTRY", Boolean.TRUE);
397:
398:                if ((TKVector) dataClass.colData != null)
399:                    t.set("IS_COLENTRY", Boolean.TRUE);
400:
401:                if (dataVector != null)
402:                    t.set("IS_OUTERLIST", Boolean.TRUE);
403:
404:                //--- Ueberschrift ----//
405:                if (isRowCell == false)
406:                    t.set("HEADERROW", Boolean.TRUE);
407:                if (isColCell == false)
408:                    t.set("HEADERCOL", Boolean.TRUE);
409:
410:                t.setListIterator(new TKTableRowShowIterator(dataClass,
411:                        fieldList, rowEntry, colEntry, scope, getName(), t
412:                                .getListIterator(), "OUTERLIST", "INNERLIST",
413:                        "ROWFORINFOLIST"));
414:
415:            }
416:
417:            //***********************************************************************
418:            public Object modify(String action, String fieldPath, Object data,
419:                    String prefix, StringBuffer destination) {
420:                TKFieldTableOrientedData dataClass = (TKFieldTableOrientedData) data;
421:                TKVector dataVector = (TKVector) dataClass.contentData;
422:
423:                int pLength = prefix.length() + fieldName.length();
424:
425:                //--------------------------------------//
426:                //----action betrifft Tabelle selbst----//
427:                //--------------------------------------//
428:                if (fieldPath.length() == pLength) {
429:                    int entryCount = fieldList.size();
430:                    int dataVectorSize = dataVector.size();
431:
432:                    if (action.equals("ADD")) {
433:                        TKVector colVector = new TKVector(entryCount);
434:
435:                        //---- Zusatztrow ----//
436:                        if (rowEntry != null) {
437:                            dataClass.rowData.addElement(rowEntry.getDefault());
438:                        }
439:
440:                        //---- Zusatzcol HAT FESTE Groesse fest!!! ----//
441:
442:                        for (int i = 0; i < entryCount; i++) {
443:                            TKBaseField field = (TKBaseField) fieldList.get(i);
444:                            colVector.addElement(field.getDefault());
445:                        }
446:                        dataVector.addElement(colVector);
447:                        destination.append(prefix + fieldName + "."
448:                                + (dataClass.contentData.size() - 1) + ".");
449:                    }
450:                }
451:                //----------------------------------------------------------//
452:                //---- Action betrifft eine Zeile/Spalte der Tabelle -------//
453:                //----------------------------------------------------------//
454:                else if (fieldPath.length() - 3 == pLength) {
455:
456:                    int index = 0;
457:                    String subPath = fieldPath.substring(pLength + 1);
458:                    StringTokenizer getToken = new StringTokenizer(subPath, ".");
459:                    index = Integer.parseInt((String) getToken.nextElement());
460:
461:                    if (action.equals("DELETE")) {
462:                        if (index == 0)
463:                            destination.append(prefix + fieldName + "." + index
464:                                    + ".");
465:                        else
466:                            destination.append(prefix + fieldName + "."
467:                                    + (index - 1) + ".");
468:                        data = actionIsDelete(dataClass, index);
469:                    }
470:                    if (action.equals("INSERT")) {
471:                        destination.append(prefix + fieldName + "." + index
472:                                + ".");
473:                        dataClass = actionIsInsert(dataClass, index);
474:
475:                    }
476:                    if (action.equals("FIRST")) {
477:                        destination.append(prefix + fieldName + "." + 0 + ".");
478:                        dataClass = actionIsFirst(dataClass, index);
479:                        if (index != 0)
480:                            data = actionIsDelete(dataClass, index + 1);
481:
482:                    }
483:                    if (action.equals("LAST")) {
484:                        destination.append(prefix + fieldName + "."
485:                                + (dataClass.contentData.size() - 1) + ".");
486:                        dataClass = actionIsLast(dataClass, index);
487:                        data = actionIsDelete(dataClass, index);
488:
489:                    }
490:                    if (action.equals("FORWARD")) {
491:                        if (index == dataClass.contentData.size() - 1)
492:                            destination.append(prefix + fieldName + "." + index
493:                                    + ".");
494:                        else
495:                            destination.append(prefix + fieldName + "."
496:                                    + (index + 1) + ".");
497:                        dataClass = actionIsForward(dataClass, index);
498:                        if (index != dataClass.contentData.size() - 1)
499:                            data = actionIsDelete(dataClass, index);
500:
501:                    }
502:                    if (action.equals("BACK")) {
503:                        if (index == 0)
504:                            destination.append(prefix + fieldName + "." + 0
505:                                    + ".");
506:                        else
507:                            destination.append(prefix + fieldName + "."
508:                                    + (index - 1) + ".");
509:                        dataClass = actionIsBack(dataClass, index);
510:                        if (index != 0)
511:                            data = actionIsDelete(dataClass, index + 1);
512:                    }
513:
514:                }
515:                //-------------------------------------//
516:                //---- action betrifft Sub-ELement ----//
517:                //-------------------------------------//
518:                else {
519:
520:                    String subZusatz = fieldPath.substring(pLength + 1);
521:
522:                    //---- modify des SubElementes in einer ZusatzRow ----//
523:                    if (subZusatz.startsWith(PRE_ROWS)) {
524:                        subZusatz = subZusatz.substring(PRE_ROWS.length() + 1);
525:                        int idxEnd = subZusatz.indexOf('.');
526:                        String idxStr = subZusatz.substring(0, idxEnd);
527:                        int idx = Integer.parseInt(idxStr);
528:
529:                        dataClass.rowData.put(idx, rowEntry.modify(action,
530:                                fieldPath, dataClass.rowData.get(idx), prefix
531:                                        + fieldName + '.' + PRE_ROWS + "."
532:                                        + idx + '.', destination));
533:
534:                    }
535:                    //---- modify des SubElementes in einer ZusatzCol ----//
536:                    else if (subZusatz.startsWith(PRE_COLS)) {
537:                        subZusatz = subZusatz.substring(PRE_COLS.length() + 1);
538:                        int idxEnd = subZusatz.indexOf('.');
539:                        String idxStr = subZusatz.substring(0, idxEnd);
540:                        int idx = Integer.parseInt(idxStr);
541:                        dataClass.colData.put(idx, colEntry.modify(action,
542:                                fieldPath, dataClass.colData.get(idx), prefix
543:                                        + fieldName + '.' + PRE_COLS + "."
544:                                        + idx + '.', destination));
545:                    }
546:                    //---- modify des SubElementes in einer Zelle ----//
547:                    else {
548:                        String subName = fieldPath.substring(pLength + 5);
549:                        int idx = subName.indexOf('.');
550:                        if (idx >= 0)
551:                            subName = subName.substring(0, idx);
552:                        TKBaseField field = (TKBaseField) tableFields
553:                                .get(subName);
554:
555:                        String subPath = fieldPath.substring(pLength + 1);
556:
557:                        StringTokenizer getToken = new StringTokenizer(subPath,
558:                                ".");
559:                        int rowIdx = Integer.parseInt((String) getToken
560:                                .nextElement());
561:                        int colIdx = Integer.parseInt((String) getToken
562:                                .nextElement());
563:
564:                        TKVector rowVector = (TKVector) dataVector
565:                                .elementAt(rowIdx);
566:
567:                        rowVector.put(colIdx, field.modify(action, fieldPath,
568:                                rowVector.get(colIdx), prefix + fieldName + "."
569:                                        + rowIdx + "." + colIdx + ".",
570:                                destination));
571:                    }
572:                }
573:                return data;
574:            }
575:
576:            public TKFieldTableOrientedData actionIsDelete(
577:                    TKFieldTableOrientedData dataClass, int index) {
578:
579:                dataClass.contentData.removeElementAt(index);
580:
581:                if ((colEntry != null) && (dataClass.contentData.isEmpty()))
582:                    dataClass.colData = null;
583:
584:                if (rowEntry != null)
585:                    if (dataClass.contentData.isEmpty())
586:                        dataClass.rowData = null;
587:                    else
588:                        dataClass.rowData.removeElementAt(index);
589:
590:                return dataClass;
591:            }
592:
593:            //*************************************************************************************
594:            public TKFieldTableOrientedData actionIsInsert(
595:                    TKFieldTableOrientedData dataClass, int index) {
596:
597:                TKVector newVector = new TKVector();
598:                for (int x = 0; x < fieldList.size(); x++) {
599:                    newVector.addElement(((TKBaseField) fieldList.elementAt(x))
600:                            .getDefault());
601:                }
602:                dataClass.contentData.insertElementAt(newVector, index);
603:
604:                if (rowEntry != null)
605:                    dataClass.rowData.insertElementAt(rowEntry.getDefault(),
606:                            index);
607:
608:                return dataClass;
609:            }
610:
611:            //*************************************************************************************
612:            public TKFieldTableOrientedData actionIsFirst(
613:                    TKFieldTableOrientedData dataClass, int index) {
614:
615:                if (index > 0) {
616:                    TKVector insertVector = (TKVector) dataClass.contentData
617:                            .elementAt(index);
618:                    dataClass.contentData.insertElementAt(insertVector, 0);
619:
620:                    if (rowEntry != null)
621:                        dataClass.rowData.insertElementAt(dataClass.rowData
622:                                .elementAt(index), 0);
623:                }
624:                return dataClass;
625:            }
626:
627:            //*************************************************************************************
628:            public TKFieldTableOrientedData actionIsLast(
629:                    TKFieldTableOrientedData dataClass, int index) {
630:                int size = dataClass.contentData.size();
631:
632:                TKVector insertVector = (TKVector) dataClass.contentData
633:                        .elementAt(index);
634:                dataClass.contentData.insertElementAt(insertVector, size);
635:
636:                if (rowEntry != null)
637:                    dataClass.rowData.insertElementAt(dataClass.rowData
638:                            .elementAt(index), size);
639:                return dataClass;
640:            }
641:
642:            public TKFieldTableOrientedData actionIsBack(
643:                    TKFieldTableOrientedData dataClass, int index) {
644:                if (index == 0)
645:                    return dataClass;
646:                if (index > 1) {
647:                    TKVector insertVector = (TKVector) dataClass.contentData
648:                            .elementAt(index);
649:                    dataClass.contentData.insertElementAt(insertVector,
650:                            index - 1);
651:
652:                    if (rowEntry != null)
653:                        dataClass.rowData.insertElementAt(dataClass.rowData
654:                                .elementAt(index), index - 1);
655:                } else if (index == 1) {
656:                    dataClass = actionIsFirst(dataClass, index);
657:                }
658:                return dataClass;
659:            }
660:
661:            public TKFieldTableOrientedData actionIsForward(
662:                    TKFieldTableOrientedData dataClass, int index) {
663:                int size = dataClass.contentData.size();
664:
665:                if (index == size - 1)
666:                    return dataClass;
667:
668:                else {
669:                    TKVector insertVector = (TKVector) dataClass.contentData
670:                            .elementAt(index);
671:                    dataClass.contentData.insertElementAt(insertVector,
672:                            index + 2);
673:
674:                    if (rowEntry != null)
675:                        dataClass.rowData.insertElementAt(dataClass.rowData
676:                                .elementAt(index), index + 2);
677:                }
678:                return dataClass;
679:            }
680:
681:            //***********************************************************************
682:            public int insertDataIntoDB(TKContentDBData db, Object data,
683:                    int contentId, int leftNr) {
684:                int entryCount = fieldList.size();
685:                if (entryCount == 0)
686:                    return leftNr;
687:
688:                TKContentNodeTableData node = insertNewContentNode(db,
689:                        contentId, leftNr);
690:                int newNodeId = node.content_node_id;
691:
692:                TKFieldTableOrientedData dataClass = (TKFieldTableOrientedData) data;
693:                TKVector dataVector = (TKVector) dataClass.contentData;
694:
695:                insertNewContentValue(db, contentId, newNodeId, 0, String
696:                        .valueOf(dataVector != null ? dataVector.size() : 0));
697:                leftNr++;
698:
699:                //---- InfoRow ----//
700:                if (rowEntry != null) {
701:                    for (int x = 0; x < dataVector.size(); x++) {
702:                        node.right_nr = rowEntry.insertDataIntoDB(db,
703:                                dataClass.rowData.elementAt(x), contentId,
704:                                leftNr + 1) + 1;
705:                    }
706:                }
707:
708:                //------ InfoCol ----//
709:                if (colEntry != null) {
710:                    for (int x = 0; x < fieldList.size(); x++) {
711:                        node.right_nr = colEntry.insertDataIntoDB(db,
712:                                dataClass.colData.elementAt(x), contentId,
713:                                leftNr + 1) + 1;
714:                    }
715:                }
716:
717:                //---- Table ----//
718:                if (dataVector != null) {
719:                    for (int x = 0; x < dataVector.size(); x++) {
720:                        for (int y = 0; y < entryCount; y++) {
721:                            TKBaseField field = (TKBaseField) fieldList.get(y);
722:                            leftNr = field.insertDataIntoDB(db,
723:                                    ((TKVector) dataVector.elementAt(x))
724:                                            .elementAt(y), contentId,
725:                                    leftNr + 1);
726:                            leftNr++;
727:                        }
728:                    }
729:                }
730:
731:                node.right_nr = leftNr;
732:                return leftNr;
733:
734:            }
735:
736:            //***********************************************************************
737:            public Object getDataFromDB(TKContentDBData db) {
738:                int entryCount = fieldList.size();
739:                if (entryCount == 0)
740:                    return new TKVector();
741:
742:                TKVector dataVector = new TKVector();
743:                TKContentNodeTableData node = getContentNodeFromDB(db);
744:
745:                TKContentValueTableData value0 = getContentNodeValueFromDB(db,
746:                        node);
747:                int dataVectorSize = Integer.parseInt(value0.value);
748:
749:                TKVector rowInfoVector = new TKVector(dataVectorSize);
750:                TKVector colInfoVector = new TKVector(entryCount);
751:
752:                //---- Info Row ----//
753:                if (rowEntry != null) {
754:                    for (int x = 0; x < dataVectorSize; x++) {
755:                        rowInfoVector.addElement(rowEntry.getDataFromDB(db));
756:                    }
757:                } else
758:                    rowInfoVector = null;
759:
760:                //---- Info Col ----//
761:                if (colEntry != null) {
762:                    for (int x = 0; x < entryCount; x++) {
763:                        colInfoVector.addElement(colEntry.getDataFromDB(db));
764:                    }
765:                } else
766:                    colInfoVector = null;
767:
768:                //---- table ----//
769:                for (int x = 0; x < dataVectorSize; x++) {
770:                    TKVector colVector = new TKVector(entryCount);
771:                    for (int i = 0; i < entryCount; i++) {
772:                        TKBaseField field = (TKBaseField) fieldList.get(i);
773:                        colVector.addElement(field.getDataFromDB(db));
774:                    }
775:                    dataVector.addElement(colVector);
776:                }
777:
778:                return new TKFieldTableOrientedData(dataVector, rowInfoVector,
779:                        colInfoVector);
780:            }
781:
782:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.