Source Code Cross Referenced for KeTable.java in  » J2EE » WiSerFramework » de » ug2t » kernel » 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 » J2EE » WiSerFramework » de.ug2t.kernel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        // @@
0002:        // @@
0003:        /*
0004:         * Wi.Ser Framework
0005:         *
0006:         * Version: 1.8.1, 20-September-2007  
0007:         * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
0008:         *
0009:         * This library is free software; you can redistribute it and/or
0010:         * modify it under the terms of the GNU Lesser General Public
0011:         * License as published by the Free Software Foundation; either
0012:         * version 2 of the License, or (at your option) any later version.
0013:         *
0014:         * This library is distributed in the hope that it will be useful,
0015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0017:         * Lesser General Public License for more details.
0018:         *
0019:         * You should have received a copy of the GNU Lesser General Public
0020:         * License along with this library located in LGPL.txt in the 
0021:         * license directory; if not, write to the 
0022:         * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0023:         * Boston, MA  02111-1307, USA.
0024:         * 
0025:         * If this agreement does not cover your requirements, please contact us
0026:         * via email to get detailed information about the commercial license 
0027:         * or our service offerings!
0028:         *
0029:         */
0030:        // @@
0031:        package de.ug2t.kernel;
0032:
0033:        import java.util.*;
0034:
0035:        import javax.swing.table.*;
0036:
0037:        public final class KeTable extends KeRegisteredObject {
0038:            private int pem_rowCnt = 0;
0039:            private int pem_colCnt = 0;
0040:
0041:            private ArrayList pem_rows = null;
0042:            private ArrayList pem_header = null;
0043:            private HashMap pem_hiddenRows = null;
0044:            private HashMap pem_selectedRows = null;
0045:
0046:            private HashMap pem_colComparator = new HashMap();
0047:            private HashMap pem_rowComparator = new HashMap();
0048:            private boolean pem_owner = false;
0049:
0050:            public class KeTableCellDescriptor {
0051:                protected int pdm_colspan = 1;
0052:                protected int pdm_rowspan = 1;
0053:                protected KeTableCellDescriptor pdm_spanSource = null;
0054:                protected Object pdm_value = null;
0055:                protected boolean pdm_isSpaned = false;
0056:                protected ArrayList pdm_spanedCells = new ArrayList();
0057:
0058:                public String toString() {
0059:                    if (this .pdm_value == null)
0060:                        return ("null");
0061:
0062:                    return (this .pdm_value.toString());
0063:                }
0064:
0065:                public KeTableCellDescriptor() {
0066:                    this .pdm_spanSource = this ;
0067:
0068:                    return;
0069:                }
0070:
0071:                public KeTableCellDescriptor(Object xVal) {
0072:                    this .pdm_spanSource = this ;
0073:                    this .pdm_value = xVal;
0074:
0075:                    return;
0076:                }
0077:
0078:                public KeTableCellDescriptor(Object xVal,
0079:                        KeTableCellDescriptor xSpanedFrom) {
0080:                    this .pdm_spanSource = this ;
0081:                    this .pdm_value = xVal;
0082:                    this .pdm_isSpaned = true;
0083:                    this .pdm_spanSource = xSpanedFrom;
0084:
0085:                    return;
0086:                }
0087:
0088:                public KeTableCellDescriptor(Object xVal, int xRowSpan,
0089:                        int xColSpan) {
0090:                    this .pdm_spanSource = this ;
0091:                    this .pdm_value = xVal;
0092:                    this .pdm_rowspan = xRowSpan;
0093:                    this .pdm_colspan = xColSpan;
0094:
0095:                    return;
0096:                }
0097:
0098:                public int getPem_colspan() {
0099:                    return pdm_colspan;
0100:                }
0101:
0102:                public boolean isPem_isSpaned() {
0103:                    return pdm_isSpaned;
0104:                }
0105:
0106:                public int getPem_rowspan() {
0107:                    return pdm_rowspan;
0108:                }
0109:
0110:                public KeTableCellDescriptor getPem_spanSource() {
0111:                    return pdm_spanSource;
0112:                }
0113:
0114:                public Object getPem_value() {
0115:                    return pdm_value;
0116:                }
0117:
0118:                public void setPem_colspan(int i) {
0119:                    pdm_colspan = i;
0120:                }
0121:
0122:                public void pcmf_unSpan() {
0123:                    pdm_isSpaned = false;
0124:                    this .pdm_spanSource = this ;
0125:                }
0126:
0127:                public void setPem_rowspan(int i) {
0128:                    pdm_rowspan = i;
0129:                }
0130:
0131:                public void setPem_spanSource(KeTableCellDescriptor cell_desc) {
0132:                    pdm_spanSource = cell_desc;
0133:                    this .pdm_isSpaned = true;
0134:                }
0135:
0136:                public void setPem_value(Object object) {
0137:                    pdm_value = object;
0138:                }
0139:            }
0140:
0141:            public class KeTableComparatorWrapper extends KeTableComparator {
0142:                private Comparator pem_comp = null;
0143:
0144:                public KeTableComparatorWrapper(boolean xUp, Comparator xComp) {
0145:                    super (xUp);
0146:                    this .pem_comp = xComp;
0147:                }
0148:
0149:                public int compare(Object o1, Object o2) {
0150:                    KeTableCellDescriptor l_desc1;
0151:                    KeTableCellDescriptor l_desc2;
0152:
0153:                    if (this .pcm_up) {
0154:                        l_desc1 = (KeTableCellDescriptor) o1;
0155:                        l_desc2 = (KeTableCellDescriptor) o2;
0156:                    } else {
0157:                        l_desc1 = (KeTableCellDescriptor) o2;
0158:                        l_desc2 = (KeTableCellDescriptor) o1;
0159:                    }
0160:                    return (this .pem_comp.compare(l_desc1.getPem_value(),
0161:                            l_desc2.getPem_value()));
0162:                }
0163:            }
0164:
0165:            public class KeTableComparator implements  Comparator {
0166:                public boolean pcm_up = true;
0167:
0168:                public KeTableComparator(boolean xUp) {
0169:                    this .pcm_up = xUp;
0170:                }
0171:
0172:                public void pcmf_setDir(boolean xUp) {
0173:                    this .pcm_up = xUp;
0174:                }
0175:
0176:                public int compare(Object o1, Object o2) {
0177:                    KeTableCellDescriptor l_desc1;
0178:                    KeTableCellDescriptor l_desc2;
0179:
0180:                    if (this .pcm_up) {
0181:                        l_desc1 = (KeTableCellDescriptor) o1;
0182:                        l_desc2 = (KeTableCellDescriptor) o2;
0183:                    } else {
0184:                        l_desc1 = (KeTableCellDescriptor) o2;
0185:                        l_desc2 = (KeTableCellDescriptor) o1;
0186:                    }
0187:
0188:                    if (l_desc1.pdm_value == null && l_desc2.pdm_value == null)
0189:                        return (0);
0190:
0191:                    if (l_desc1.pdm_value == null && l_desc2.pdm_value != null)
0192:                        return ("null".compareTo(l_desc2.pdm_value.toString()));
0193:                    else if (l_desc2.pdm_value == null
0194:                            && l_desc1.pdm_value != null)
0195:                        return (l_desc1.pdm_value.toString().compareTo("null"));
0196:                    else {
0197:                        try {
0198:                            Integer l_i1 = new Integer(l_desc1.pdm_value
0199:                                    .toString());
0200:                            Integer l_i2 = new Integer(l_desc2.pdm_value
0201:                                    .toString());
0202:
0203:                            return (l_i1.compareTo(l_i2));
0204:                        } catch (Exception e) {
0205:                            String l_sval1 = l_desc1.pdm_value.toString();
0206:                            String l_sval2 = l_desc2.pdm_value.toString();
0207:
0208:                            return (l_sval1.compareTo(l_sval2));
0209:                        }
0210:                    }
0211:                }
0212:            }
0213:
0214:            public boolean pcmf_isHiddenRow(int xIdx) {
0215:                if (this .pem_hiddenRows != null) {
0216:                    if (this .pem_hiddenRows.get(this .pem_rows.get(xIdx)) != null)
0217:                        return (true);
0218:
0219:                    return (false);
0220:                }
0221:                return (false);
0222:            }
0223:
0224:            public void pcmf_hideRow(int xIdx) {
0225:                if (this .pem_hiddenRows == null)
0226:                    this .pem_hiddenRows = new HashMap();
0227:
0228:                this .pem_hiddenRows.put(this .pem_rows.get(xIdx), "");
0229:            }
0230:
0231:            public void pcmf_unHideRows() {
0232:                this .pem_hiddenRows = null;
0233:            }
0234:
0235:            public void pcmf_unHideRow(int xIdx) {
0236:                if (this .pem_hiddenRows != null)
0237:                    this .pem_hiddenRows.remove(this .pem_rows.get(xIdx));
0238:            }
0239:
0240:            public boolean pcmf_isSelectedRow(int xIdx) {
0241:                if (this .pem_selectedRows != null) {
0242:                    if (this .pem_selectedRows.get(this .pem_rows.get(xIdx)) != null)
0243:                        return (true);
0244:
0245:                    return (false);
0246:                }
0247:                return (false);
0248:            }
0249:
0250:            public void pcmf_selectRow(int xIdx) {
0251:                if (this .pem_selectedRows == null)
0252:                    this .pem_selectedRows = new HashMap();
0253:
0254:                this .pem_selectedRows.put(this .pem_rows.get(xIdx), "");
0255:            }
0256:
0257:            public void pcmf_unSelectRows() {
0258:                this .pem_selectedRows = null;
0259:            }
0260:
0261:            public void pcmf_unSelectRow(int xIdx) {
0262:                if (this .pem_selectedRows != null)
0263:                    this .pem_selectedRows.remove(this .pem_rows.get(xIdx));
0264:            }
0265:
0266:            public void pcmf_setComparatorCol(int xCol, Comparator xComp) {
0267:                this .pem_colComparator.put(new Integer(xCol), xComp);
0268:            }
0269:
0270:            public void pcmf_setComparatorRow(int xRow, Comparator xComp) {
0271:                this .pem_rowComparator.put(new Integer(xRow), xComp);
0272:            }
0273:
0274:            private Comparator pemf_getComparatorRow(int xRow, boolean xUp) {
0275:                Comparator l_comp = (Comparator) this .pem_rowComparator
0276:                        .get(new Integer(xRow));
0277:                if (l_comp == null)
0278:                    return (new KeTableComparator(xUp));
0279:
0280:                return (new KeTableComparatorWrapper(xUp, l_comp));
0281:            }
0282:
0283:            private Comparator pemf_getComparatorCol(int xCol, boolean xUp) {
0284:                Comparator l_comp = (Comparator) this .pem_colComparator
0285:                        .get(new Integer(xCol));
0286:                if (l_comp == null)
0287:                    return (new KeTableComparator(xUp));
0288:
0289:                return (new KeTableComparatorWrapper(xUp, l_comp));
0290:            }
0291:
0292:            public KeTable() {
0293:                super (false);
0294:
0295:                this .pem_rows = new ArrayList();
0296:
0297:                return;
0298:            }
0299:
0300:            public KeTable(int rows, int cols) {
0301:                super (false);
0302:
0303:                this .pem_rowCnt = rows;
0304:                this .pem_colCnt = cols;
0305:
0306:                ArrayList l_cols = new ArrayList();
0307:                for (int i = 0; i < cols; i++)
0308:                    l_cols.add("");
0309:
0310:                this .pcmf_setHeader(l_cols);
0311:
0312:                this .pem_rows = new ArrayList();
0313:                ArrayList l_row = null;
0314:
0315:                for (int y = 0; y < this .pem_rowCnt; y++) {
0316:                    l_row = new ArrayList();
0317:                    this .pem_rows.add(l_row);
0318:
0319:                    for (int x = 0; x < this .pem_colCnt; x++)
0320:                        l_row.add(new KeTableCellDescriptor());
0321:                }
0322:            }
0323:
0324:            public KeTable(ArrayList xHeader, int rows) {
0325:                super (false);
0326:
0327:                this .pem_rowCnt = rows;
0328:                this .pcmf_setHeader(xHeader);
0329:
0330:                this .pem_rows = new ArrayList();
0331:                ArrayList l_row = null;
0332:
0333:                for (int y = 0; y < this .pem_rowCnt; y++) {
0334:                    l_row = new ArrayList();
0335:                    this .pem_rows.add(l_row);
0336:
0337:                    for (int x = 0; x < this .pem_colCnt; x++)
0338:                        l_row.add(new KeTableCellDescriptor());
0339:                }
0340:            }
0341:
0342:            public KeTable(DefaultTableModel xModel) {
0343:                this (xModel.getRowCount(), xModel.getColumnCount());
0344:                for (int i = 0; i < xModel.getColumnCount(); i++)
0345:                    this .pcmf_setHeaderValue(i, xModel.getColumnName(i));
0346:
0347:                for (int x = 0; x < xModel.getRowCount(); x++)
0348:                    for (int y = 0; y < xModel.getColumnCount(); y++)
0349:                        this .pcmf_setCellDesc(x, y, new KeTableCellDescriptor(
0350:                                xModel.getValueAt(x, y)));
0351:            }
0352:
0353:            public DefaultTableModel pcmf_toTableModel() {
0354:                DefaultTableModel l_model = new DefaultTableModel(this 
0355:                        .pcmf_getRowCnt(), this .pcmf_getColCnt());
0356:                l_model.setColumnIdentifiers(this .pcmf_getHeader().toArray());
0357:
0358:                for (int x = 0; x < l_model.getRowCount(); x++)
0359:                    for (int y = 0; y < l_model.getColumnCount(); y++)
0360:                        l_model.setValueAt(this .pcmf_getValue(x, y), x, y);
0361:
0362:                return (l_model);
0363:            }
0364:
0365:            private void pemf_clear() {
0366:                pem_rowCnt = 0;
0367:                pem_colCnt = 0;
0368:                pem_rows = null;
0369:                pem_header = null;
0370:                pem_colComparator.clear();
0371:                pem_rowComparator.clear();
0372:            }
0373:
0374:            public void pcmf_reset() {
0375:                this .pemf_clear();
0376:
0377:                this .pem_rows = new ArrayList();
0378:
0379:                return;
0380:            }
0381:
0382:            public void pcmf_reset(int rows, int cols) {
0383:                this .pemf_clear();
0384:
0385:                this .pem_rowCnt = rows;
0386:                this .pem_colCnt = cols;
0387:
0388:                this .pem_header = new ArrayList(cols);
0389:                this .pem_rows = new ArrayList();
0390:                ArrayList l_row = null;
0391:
0392:                for (int y = 0; y < this .pem_rowCnt; y++) {
0393:                    l_row = new ArrayList();
0394:                    this .pem_rows.add(l_row);
0395:
0396:                    for (int x = 0; x < this .pem_colCnt; x++)
0397:                        l_row.add(new KeTableCellDescriptor());
0398:                }
0399:            }
0400:
0401:            public void pcmf_reset(ArrayList xHeader, int rows) {
0402:                this .pemf_clear();
0403:
0404:                this .pem_rowCnt = rows;
0405:                this .pcmf_setHeader(xHeader);
0406:
0407:                this .pem_rows = new ArrayList();
0408:                ArrayList l_row = null;
0409:
0410:                for (int y = 0; y < this .pem_rowCnt; y++) {
0411:                    l_row = new ArrayList();
0412:                    this .pem_rows.add(l_row);
0413:
0414:                    for (int x = 0; x < this .pem_colCnt; x++)
0415:                        l_row.add(new KeTableCellDescriptor());
0416:                }
0417:            }
0418:
0419:            public KeTableCellDescriptor pcmf_getCellDesc(int xRow, int xCol) {
0420:                if (xRow >= this .pem_rowCnt || xCol >= this .pem_colCnt)
0421:                    return (null);
0422:
0423:                ArrayList l_row = (ArrayList) this .pem_rows.get(xRow);
0424:
0425:                return ((KeTableCellDescriptor) l_row.get(xCol));
0426:            }
0427:
0428:            public Object pcmf_getValue(int xRow, int xCol) {
0429:                KeTableCellDescriptor l_desc = this 
0430:                        .pcmf_getCellDesc(xRow, xCol);
0431:                if (l_desc == null)
0432:                    return (null);
0433:                else
0434:                    return (l_desc.getPem_value());
0435:            }
0436:
0437:            public void pcmf_spanCell(int xRow, int xCol, int xRSpan, int xCSpan) {
0438:                KeTableCellDescriptor l_desc = this 
0439:                        .pcmf_getCellDesc(xRow, xCol);
0440:                KeTableCellDescriptor l_new = new KeTableCellDescriptor(l_desc
0441:                        .getPem_value(), xRSpan, xCSpan);
0442:
0443:                this .pcmf_setCellDesc(xRow, xCol, l_new);
0444:            }
0445:
0446:            public KeTableCellDescriptor pcmf_setCellDesc(int xRow, int xCol,
0447:                    KeTableCellDescriptor xObj) {
0448:                if (xRow >= this .pem_rowCnt || xCol >= this .pem_colCnt)
0449:                    return (null);
0450:
0451:                KeTableCellDescriptor l_olddesc = this .pcmf_getCellDesc(xRow,
0452:                        xCol);
0453:                Iterator l_descIt = l_olddesc.pdm_spanedCells.iterator();
0454:                while (l_descIt.hasNext())
0455:                    ((KeTableCellDescriptor) l_descIt.next()).pcmf_unSpan();
0456:
0457:                ArrayList l_row = (ArrayList) this .pem_rows.get(xRow);
0458:                KeTableCellDescriptor l_ret = (KeTableCellDescriptor) l_row
0459:                        .get(xCol);
0460:
0461:                l_row.add(xCol, xObj);
0462:                l_row.remove(xCol + 1);
0463:
0464:                if (xObj.getPem_colspan() > 0) {
0465:                    KeTableCellDescriptor l_desc = null;
0466:                    for (int i = 0; i < xObj.getPem_colspan(); i++) {
0467:                        l_desc = this .pcmf_getCellDesc(xRow, xCol + i);
0468:                        if (l_desc == null)
0469:                            continue;
0470:
0471:                        l_desc.setPem_spanSource(xObj);
0472:                        if (xObj != l_desc)
0473:                            xObj.pdm_spanedCells.add(l_desc);
0474:                        if (xObj.getPem_rowspan() > 0) {
0475:                            for (int y = 0; y < xObj.getPem_rowspan(); y++) {
0476:                                l_desc = this .pcmf_getCellDesc(xRow + y, xCol
0477:                                        + i);
0478:                                if (l_desc == null)
0479:                                    continue;
0480:
0481:                                l_desc.setPem_spanSource(xObj);
0482:                                if (xObj != l_desc)
0483:                                    xObj.pdm_spanedCells.add(l_desc);
0484:                            }
0485:                        }
0486:                    }
0487:                }
0488:
0489:                return (l_ret);
0490:            }
0491:
0492:            public Object pcmf_setValue(int xRow, int xCol, Object xObj) {
0493:                if (xRow >= this .pem_rowCnt || xCol >= this .pem_colCnt)
0494:                    return (null);
0495:
0496:                ArrayList l_row = (ArrayList) this .pem_rows.get(xRow);
0497:                KeTableCellDescriptor l_desc = (KeTableCellDescriptor) l_row
0498:                        .get(xCol);
0499:                Object l_ret = l_desc.getPem_value();
0500:
0501:                l_desc.setPem_value(xObj);
0502:
0503:                return (l_ret);
0504:            }
0505:
0506:            public Iterator pcmf_getRowCellDescIt(int xRow) {
0507:                ArrayList l_vect = this .pcmf_getRowCellDescArrayList(xRow);
0508:                if (l_vect == null)
0509:                    return (null);
0510:
0511:                ArrayList l_ret = new ArrayList();
0512:                Iterator l_it = l_vect.iterator();
0513:                KeTableCellDescriptor l_desc = null;
0514:                while (l_it.hasNext()) {
0515:                    l_desc = (KeTableCellDescriptor) l_it.next();
0516:                    if (l_desc.isPem_isSpaned()
0517:                            && l_desc.pdm_spanSource != l_desc)
0518:                        continue;
0519:                    else
0520:                        l_ret.add(l_desc);
0521:                }
0522:
0523:                return (l_ret.iterator());
0524:            }
0525:
0526:            public ArrayList pcmf_getRowArrayList(int xRow) {
0527:                Iterator l_it = this .pcmf_getRowCellDescIt(xRow);
0528:                if (l_it == null)
0529:                    return (null);
0530:
0531:                ArrayList l_ret = new ArrayList(this .pcmf_getColCnt());
0532:                while (l_it.hasNext())
0533:                    l_ret.add(((KeTableCellDescriptor) l_it.next()).pdm_value);
0534:
0535:                return (l_ret);
0536:            }
0537:
0538:            public Iterator pcmf_getColCellDescIt(int xCol) {
0539:                ArrayList l_vect = this .pcmf_getColCellDescArrayList(xCol);
0540:                if (l_vect == null)
0541:                    return (null);
0542:
0543:                ArrayList l_ret = new ArrayList();
0544:                Iterator l_it = l_vect.iterator();
0545:                KeTableCellDescriptor l_desc = null;
0546:                while (l_it.hasNext()) {
0547:                    l_desc = (KeTableCellDescriptor) l_it.next();
0548:                    if (l_desc.isPem_isSpaned()
0549:                            && l_desc.pdm_spanSource != l_desc)
0550:                        continue;
0551:                    else
0552:                        l_ret.add(l_desc);
0553:                }
0554:
0555:                return (l_ret.iterator());
0556:            }
0557:
0558:            public ArrayList pcmf_getColArrayList(int xCol) {
0559:                Iterator l_it = this .pcmf_getColCellDescIt(xCol);
0560:                if (l_it == null)
0561:                    return (null);
0562:
0563:                ArrayList l_ret = new ArrayList(this .pcmf_getColCnt());
0564:                while (l_it.hasNext())
0565:                    l_ret.add(((KeTableCellDescriptor) l_it.next()).pdm_value);
0566:
0567:                return (l_ret);
0568:            }
0569:
0570:            public ArrayList pcmf_getRowCellDescArrayList(int xRow) {
0571:                if (xRow >= this .pem_rowCnt)
0572:                    return (null);
0573:
0574:                ArrayList l_row = (ArrayList) this .pem_rows.get(xRow);
0575:                ArrayList l_ret = new ArrayList(l_row);
0576:
0577:                return (l_ret);
0578:            }
0579:
0580:            public ArrayList pcmf_getRowCellDescArrayLists() {
0581:                ArrayList l_ret = new ArrayList();
0582:                for (int i = 0; i < this .pem_rowCnt; i++)
0583:                    l_ret.add(this .pcmf_getRowCellDescArrayList(i));
0584:
0585:                return (l_ret);
0586:            }
0587:
0588:            public ArrayList pcmf_getColCellDescArrayList(int xCol) {
0589:                if (xCol >= this .pem_colCnt)
0590:                    return (null);
0591:
0592:                ArrayList l_ret = new ArrayList(this .pem_rowCnt);
0593:                for (int i = 0; i < this .pem_rowCnt; i++)
0594:                    l_ret.add(this .pcmf_getCellDesc(i, xCol));
0595:
0596:                return (l_ret);
0597:            }
0598:
0599:            public ArrayList pcmf_getColCellDescArrayLists() {
0600:                ArrayList l_ret = new ArrayList();
0601:                for (int i = 0; i < this .pem_colCnt; i++)
0602:                    l_ret.add(this .pcmf_getColCellDescArrayList(i));
0603:
0604:                return (l_ret);
0605:            }
0606:
0607:            public void pcmf_removeRow(int xRow) {
0608:                Iterator l_it = this .pcmf_getRowCellDescIt(xRow);
0609:                KeTableCellDescriptor l_desc = null;
0610:
0611:                while (l_it.hasNext()) {
0612:                    l_desc = (KeTableCellDescriptor) l_it.next();
0613:                    Iterator l_it2 = l_desc.pdm_spanedCells.iterator();
0614:                    while (l_it2.hasNext())
0615:                        ((KeTableCellDescriptor) l_it2.next()).pcmf_unSpan();
0616:                }
0617:
0618:                this .pem_rowCnt--;
0619:                this .pem_rows.remove(xRow);
0620:            }
0621:
0622:            public void pcmf_removeCol(int xCol) {
0623:                Iterator l_it = this .pcmf_getColCellDescIt(xCol);
0624:                KeTableCellDescriptor l_desc = null;
0625:
0626:                while (l_it.hasNext()) {
0627:                    l_desc = (KeTableCellDescriptor) l_it.next();
0628:                    Iterator l_it2 = l_desc.pdm_spanedCells.iterator();
0629:                    while (l_it2.hasNext())
0630:                        ((KeTableCellDescriptor) l_it2.next()).pcmf_unSpan();
0631:                }
0632:
0633:                for (int i = 0; i < this .pem_rowCnt; i++)
0634:                    ((ArrayList) this .pem_rows.get(i)).remove(xCol);
0635:
0636:                this .pem_colCnt--;
0637:            }
0638:
0639:            public void pcmf_addRow() {
0640:                this .pem_rowCnt++;
0641:
0642:                ArrayList l_row = null;
0643:
0644:                l_row = new ArrayList();
0645:                this .pem_rows.add(l_row);
0646:
0647:                for (int x = 0; x < this .pem_colCnt; x++)
0648:                    l_row.add(new KeTableCellDescriptor());
0649:            }
0650:
0651:            public void pcmf_addCol() {
0652:                this .pem_colCnt++;
0653:
0654:                ArrayList l_row = null;
0655:                Iterator l_it = this .pem_rows.iterator();
0656:                while (l_it.hasNext()) {
0657:                    l_row = (ArrayList) l_it.next();
0658:                    l_row.add(new KeTableCellDescriptor());
0659:                }
0660:            }
0661:
0662:            public void pcmf_addRow(int xRow) {
0663:                this .pem_rowCnt++;
0664:
0665:                ArrayList l_row = null;
0666:
0667:                l_row = new ArrayList();
0668:                this .pem_rows.add(xRow, l_row);
0669:
0670:                for (int x = 0; x < this .pem_colCnt; x++)
0671:                    l_row.add(new KeTableCellDescriptor());
0672:            }
0673:
0674:            public void pcmf_addCol(int xCol) {
0675:                this .pem_colCnt++;
0676:
0677:                ArrayList l_row = null;
0678:                Iterator l_it = this .pem_rows.iterator();
0679:                while (l_it.hasNext()) {
0680:                    l_row = (ArrayList) l_it.next();
0681:                    l_row.add(xCol, new KeTableCellDescriptor());
0682:                }
0683:            }
0684:
0685:            public void pcmf_addRowArrayList(int xRow, ArrayList xValues) {
0686:                this .pem_rowCnt++;
0687:
0688:                ArrayList l_row = null;
0689:                Iterator l_it = xValues.iterator();
0690:
0691:                l_row = new ArrayList();
0692:                this .pem_rows.add(xRow, l_row);
0693:
0694:                for (int x = 0; x < this .pem_colCnt; x++)
0695:                    l_row.add(new KeTableCellDescriptor(l_it.next()));
0696:            }
0697:
0698:            public void pcmf_addRowArrayList(ArrayList xValues) {
0699:                pcmf_addRowArrayList(this .pem_rowCnt, xValues);
0700:            }
0701:
0702:            public void pcmf_addColArrayList(int xCol, ArrayList xValues) {
0703:                this .pem_colCnt++;
0704:
0705:                ArrayList l_row = null;
0706:                Iterator l_it = this .pem_rows.iterator();
0707:                Iterator l_it2 = xValues.iterator();
0708:
0709:                while (l_it.hasNext()) {
0710:                    l_row = (ArrayList) l_it.next();
0711:                    l_row.add(xCol, new KeTableCellDescriptor(l_it2.next()));
0712:                }
0713:            }
0714:
0715:            public void pcmf_addRowCellDescArrayList(int xRow, ArrayList xValues) {
0716:                this .pem_rowCnt++;
0717:
0718:                ArrayList l_row = null;
0719:                Iterator l_it = xValues.iterator();
0720:
0721:                l_row = new ArrayList();
0722:                this .pem_rows.add(xRow, l_row);
0723:
0724:                for (int x = 0; x < this .pem_colCnt; x++)
0725:                    l_row.add(l_it.next());
0726:            }
0727:
0728:            public void pcmf_setRowCellDescArrayList(int xRow, ArrayList xValues) {
0729:                ArrayList l_row = null;
0730:                Iterator l_it = xValues.iterator();
0731:
0732:                l_row = new ArrayList();
0733:                this .pem_rows.set(xRow, l_row);
0734:
0735:                for (int x = 0; x < this .pem_colCnt; x++)
0736:                    l_row.add(l_it.next());
0737:            }
0738:
0739:            public void pcmf_addColCellDescArrayList(int xCol, ArrayList xValues) {
0740:                this .pem_colCnt++;
0741:
0742:                ArrayList l_row = null;
0743:                Iterator l_it = this .pem_rows.iterator();
0744:                Iterator l_it2 = xValues.iterator();
0745:
0746:                while (l_it.hasNext()) {
0747:                    l_row = (ArrayList) l_it.next();
0748:                    l_row.add(xCol, l_it2.next());
0749:                }
0750:            }
0751:
0752:            public void pcmf_setColCellDescArrayList(int xCol, ArrayList xValues) {
0753:                ArrayList l_row = null;
0754:                Iterator l_it = this .pem_rows.iterator();
0755:                Iterator l_it2 = xValues.iterator();
0756:
0757:                while (l_it.hasNext()) {
0758:                    l_row = (ArrayList) l_it.next();
0759:                    l_row.set(xCol, l_it2.next());
0760:                }
0761:            }
0762:
0763:            public ArrayList pcmf_getAllTableValues() {
0764:                ArrayList l_ret = new ArrayList(this .pem_rowCnt);
0765:                ArrayList l_row = null;
0766:                Iterator l_itr = this .pem_rows.iterator();
0767:                Iterator l_itc = null;
0768:                while (l_itr.hasNext()) {
0769:                    ArrayList l_next = (ArrayList) l_itr.next();
0770:
0771:                    if (this .pem_hiddenRows != null
0772:                            && this .pem_hiddenRows.get(l_next) != null)
0773:                        continue;
0774:
0775:                    l_itc = l_next.iterator();
0776:                    l_row = new ArrayList();
0777:                    l_ret.add(l_row);
0778:                    KeTableCellDescriptor l_desc = null;
0779:
0780:                    while (l_itc.hasNext()) {
0781:                        l_desc = (KeTableCellDescriptor) l_itc.next();
0782:                        l_row.add(l_desc.getPem_value());
0783:                    }
0784:                }
0785:
0786:                return (l_ret);
0787:            }
0788:
0789:            public void pcmf_clearAndRelease() {
0790:                try {
0791:                    ArrayList l_all = this .pcmf_getAllTableValues();
0792:                    Iterator l_rit = l_all.iterator();
0793:                    Iterator l_cit = null;
0794:                    Object l_obj = null;
0795:                    while (l_rit.hasNext()) {
0796:                        l_cit = ((ArrayList) l_rit.next()).iterator();
0797:                        while (l_cit.hasNext()) {
0798:                            l_obj = l_cit.next();
0799:                            if (l_obj instanceof  KeRegisteredObject)
0800:                                ((KeRegisteredObject) l_obj).pcmf_delete();
0801:                        }
0802:                        ;
0803:                    }
0804:                    this .pcmf_reset();
0805:                } catch (Exception e) {
0806:                    KeLog.pcmf_logException("ug2t",
0807:                            "error during releasing table elements", e);
0808:                }
0809:            }
0810:
0811:            public ArrayList pcmf_getTableValues() {
0812:                ArrayList l_ret = new ArrayList(this .pem_rowCnt);
0813:                ArrayList l_row = null;
0814:                Iterator l_itr = this .pem_rows.iterator();
0815:                Iterator l_itc = null;
0816:                while (l_itr.hasNext()) {
0817:                    l_itc = ((ArrayList) l_itr.next()).iterator();
0818:                    l_row = new ArrayList();
0819:                    l_ret.add(l_row);
0820:                    KeTableCellDescriptor l_desc = null;
0821:
0822:                    while (l_itc.hasNext()) {
0823:                        l_desc = (KeTableCellDescriptor) l_itc.next();
0824:                        if (l_desc.isPem_isSpaned() == false)
0825:                            l_row.add(l_desc.getPem_value());
0826:                    }
0827:                }
0828:
0829:                return (l_ret);
0830:            }
0831:
0832:            public ArrayList pcmf_getHeaderAndTableValues() {
0833:                return (this .pcmf_getHeaderAndTableValues(true));
0834:            }
0835:
0836:            public boolean pcmf_hasHiddenRows() {
0837:                return (this .pem_hiddenRows == null ? false : true);
0838:            }
0839:
0840:            public ArrayList pcmf_getHeaderAndTableValues(boolean xAll) {
0841:                ArrayList l_ret = new ArrayList(this .pem_rowCnt);
0842:                ArrayList l_row = null;
0843:                Iterator l_itr = this .pem_rows.iterator();
0844:                Iterator l_itc = null;
0845:
0846:                if (this .pem_header != null) {
0847:                    l_row = new ArrayList(this .pem_header);
0848:                    l_ret.add(l_row);
0849:                }
0850:
0851:                while (l_itr.hasNext()) {
0852:                    ArrayList l_next = (ArrayList) l_itr.next();
0853:
0854:                    if (!xAll) {
0855:                        if (this .pem_hiddenRows != null
0856:                                && this .pem_hiddenRows.get(l_next) != null)
0857:                            continue;
0858:                    }
0859:
0860:                    l_itc = l_next.iterator();
0861:                    l_row = new ArrayList();
0862:                    l_ret.add(l_row);
0863:                    KeTableCellDescriptor l_desc = null;
0864:
0865:                    while (l_itc.hasNext()) {
0866:                        l_desc = (KeTableCellDescriptor) l_itc.next();
0867:                        if (l_desc.isPem_isSpaned() == false)
0868:                            l_row.add(l_desc.getPem_value());
0869:                    }
0870:                }
0871:
0872:                return (l_ret);
0873:            }
0874:
0875:            public int pcmf_getRowCnt() {
0876:                return (this .pem_rowCnt);
0877:            }
0878:
0879:            public int pcmf_getColCnt() {
0880:                return (this .pem_colCnt);
0881:            }
0882:
0883:            public void pcmf_addHeaderValue(int xCol, Object xValue) {
0884:                this .pem_header.add(xCol, xValue);
0885:            }
0886:
0887:            public void pcmf_setHeaderValue(int xCol, Object xValue) {
0888:                this .pem_header.set(xCol, xValue);
0889:            }
0890:
0891:            public void pcmf_setHeader(ArrayList xHeader) {
0892:                this .pem_header = new ArrayList(xHeader);
0893:                int l_dif = this .pem_header.size() - this .pem_colCnt;
0894:                for (int i = 0; i < l_dif; i++) {
0895:                    this .pcmf_addCol();
0896:                }
0897:            }
0898:
0899:            public ArrayList pcmf_getHeader() {
0900:                return (new ArrayList(this .pem_header));
0901:            }
0902:
0903:            public Object pcmf_getHeader(int xCol) {
0904:                return (this .pem_header.get(xCol));
0905:            }
0906:
0907:            // Untested
0908:            public void pcmf_sortByColDir(int xCol, boolean xUp) {
0909:                ArrayList l_col = this .pcmf_getColCellDescArrayList(xCol);
0910:                ArrayList l_rows = this .pcmf_getRowCellDescArrayLists();
0911:
0912:                Object l_obj[] = l_col.toArray();
0913:                Arrays.sort(l_obj, this .pemf_getComparatorCol(xCol, xUp));
0914:
0915:                int l_oldIdx = 0;
0916:                for (int i = 0; i < l_obj.length; i++) {
0917:                    l_oldIdx = l_col.indexOf(l_obj[i]);
0918:                    this .pcmf_setRowCellDescArrayList(i, (ArrayList) l_rows
0919:                            .get(l_oldIdx));
0920:                }
0921:            }
0922:
0923:            public void pcmf_sortByRowDir(int xRow, boolean xUp) {
0924:                ArrayList l_row = this .pcmf_getRowCellDescArrayList(xRow);
0925:                ArrayList l_cols = this .pcmf_getColCellDescArrayLists();
0926:
0927:                Object l_obj[] = l_row.toArray();
0928:                Arrays.sort(l_obj, this .pemf_getComparatorRow(xRow, xUp));
0929:
0930:                int l_oldIdx = 0;
0931:                for (int i = 0; i < l_obj.length; i++) {
0932:                    l_oldIdx = l_row.indexOf(l_obj[i]);
0933:                    this .pcmf_setColCellDescArrayList(i, (ArrayList) l_cols
0934:                            .get(l_oldIdx));
0935:                }
0936:            }
0937:
0938:            public void pcmf_sortByCol(int xCol) {
0939:                this .pcmf_sortByColDir(xCol, true);
0940:            }
0941:
0942:            public void pcmf_sortByRow(int xRow) {
0943:                this .pcmf_sortByRowDir(xRow, true);
0944:            }
0945:
0946:            public void pcmf_compact() {
0947:                Iterator l_it = null;
0948:                for (int x = 0; x < this .pem_colCnt; x++) {
0949:                    l_it = this .pcmf_getColCellDescArrayList(x).iterator();
0950:                    boolean l_removeable = true;
0951:                    KeTableCellDescriptor l_desc = null;
0952:
0953:                    while (l_it.hasNext()) {
0954:                        l_desc = (KeTableCellDescriptor) l_it.next();
0955:                        if (l_desc.getPem_value() != null
0956:                                || l_desc.pdm_isSpaned) {
0957:                            l_removeable = false;
0958:                            break;
0959:                        }
0960:                    }
0961:                    if (l_removeable == true) {
0962:                        if (this .pem_header != null
0963:                                && this .pem_header.size() != 0)
0964:                            this .pem_header.remove(x);
0965:
0966:                        this .pcmf_removeCol(x--);
0967:                    } else
0968:                        l_removeable = true;
0969:                }
0970:
0971:                for (int x = 0; x < this .pem_rowCnt; x++) {
0972:                    l_it = this .pcmf_getRowCellDescArrayList(x).iterator();
0973:                    boolean l_removeable = true;
0974:                    KeTableCellDescriptor l_desc = null;
0975:                    while (l_it.hasNext()) {
0976:                        l_desc = (KeTableCellDescriptor) l_it.next();
0977:                        if (l_desc.getPem_value() != null
0978:                                || l_desc.pdm_isSpaned) {
0979:                            l_removeable = false;
0980:                            break;
0981:                        }
0982:                    }
0983:                    if (l_removeable == true)
0984:                        this .pcmf_removeRow(x--);
0985:                    else
0986:                        l_removeable = true;
0987:                }
0988:            }
0989:
0990:            public void pcmf_setOwnership(boolean xOwner) {
0991:                this .pem_owner = xOwner;
0992:            };
0993:
0994:            public boolean pcmf_isOwner() {
0995:                return (this .pem_owner);
0996:            };
0997:
0998:            public void pcmf_delete() throws Exception {
0999:                if (this .pdm_deleted == true)
1000:                    return;
1001:
1002:                if (this .pem_owner)
1003:                    this .pcmf_clearAndRelease();
1004:                else
1005:                    this .pemf_clear();
1006:
1007:                super .pcmf_delete();
1008:            }
1009:
1010:            public void pcmf_test2StdOut() {
1011:                for (int y = 0; y < this .pem_rowCnt; y++) {
1012:                    for (int x = 0; x < this .pem_colCnt; x++) {
1013:                        System.out.print(this .pcmf_getCellDesc(y, x).toString()
1014:                                + "-S:"
1015:                                + this .pcmf_getCellDesc(y, x).isPem_isSpaned()
1016:                                + " | ");
1017:                    }
1018:                    System.out
1019:                            .println("\n--------------------------------------------------------------");
1020:                }
1021:            }
1022:
1023:            public KeTable(boolean xRegister) {
1024:                super (xRegister);
1025:                // TODO Auto-generated constructor stub
1026:            }
1027:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.