Source Code Cross Referenced for DBTableDataTableModel.java in  » Database-Client » DBBrowser » org » dbbrowser » ui » helper » 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 » Database Client » DBBrowser » org.dbbrowser.ui.helper 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.dbbrowser.ui.helper;
002:
003:        import infrastructure.propertymanager.PropertyManager;
004:        import java.util.ArrayList;
005:        import java.util.List;
006:        import java.util.Collections;
007:        import javax.swing.table.AbstractTableModel;
008:        import org.dbbrowser.db.engine.model.ColumnInfo;
009:        import org.dbbrowser.db.engine.model.DBRow;
010:        import org.dbbrowser.db.engine.model.DBTable;
011:        import org.dbbrowser.db.engine.model.DBTableCell;
012:        import org.dbbrowser.ui.UIControllerForQueries;
013:
014:        /**
015:         * Private class representing the model for the table
016:         * @author amangat
017:         */
018:        public class DBTableDataTableModel extends AbstractTableModel {
019:            private static final long serialVersionUID = UIControllerForQueries.version;
020:
021:            private List listOfColumnInfosIncludingRowHeaderColumn = new ArrayList();
022:            private DBTable dbTable = null;
023:
024:            public DBTableDataTableModel(DBTable newDBTable) {
025:                dbTable = newDBTable;
026:                listOfColumnInfosIncludingRowHeaderColumn.addAll(dbTable
027:                        .getListOfColumnInfos());
028:                ColumnInfo dummyColumnInfoForRowHeadercolumn = new ColumnInfo(
029:                        "    ", ColumnInfo.COLUMN_TYPE_VARCHAR, null, null,
030:                        null, null, Boolean.FALSE, Boolean.FALSE, null);
031:
032:                //if sorting enabled, sort the data in table and sort the columns
033:                String sortColumnsFlag = PropertyManager.getInstance()
034:                        .getProperty("dbbrowser-ui-sort-columns-in-table");
035:                if ("true".equals(sortColumnsFlag)) {
036:                    Collections.sort(listOfColumnInfosIncludingRowHeaderColumn,
037:                            new ColumnInfoComparator());
038:                }
039:
040:                listOfColumnInfosIncludingRowHeaderColumn.add(0,
041:                        dummyColumnInfoForRowHeadercolumn);
042:            }
043:
044:            /**
045:             * Returns the column name
046:             * @return - String
047:             */
048:            public String getColumnName(int col) {
049:                ColumnInfo columnInfo = (ColumnInfo) listOfColumnInfosIncludingRowHeaderColumn
050:                        .get(col);
051:                String columnName = columnInfo.getColumnName();
052:
053:                //If it is a primary key column, add the word (PK) at the end
054:                if (columnInfo.isPrimaryKeyColumn().booleanValue()) {
055:                    columnName = columnName + "(PK)";
056:                }
057:                return columnName;
058:            }
059:
060:            /**
061:             * Returns the number for rows
062:             * @return - int
063:             */
064:            public int getRowCount() {
065:                return dbTable.getListOfRows().size();
066:            }
067:
068:            /**
069:             * Returns the number of columns
070:             * @return - int
071:             */
072:            public int getColumnCount() {
073:                return listOfColumnInfosIncludingRowHeaderColumn.size();
074:            }
075:
076:            /**
077:             * Returns the value for a row and column
078:             * @return Object
079:             */
080:            public Object getValueAt(int row, int col) {
081:                String cellValue = null;
082:
083:                if (col == 0) {
084:                    return "" + (row + 1);
085:                } else {
086:                    DBRow dbRow = (DBRow) dbTable.getListOfRows().get(row);
087:                    List listOfTableCells = dbRow.getListOFDBTableCells();
088:
089:                    //if sorting enabled, sort the data in table and sort the columns
090:                    String sortColumnsFlag = PropertyManager.getInstance()
091:                            .getProperty("dbbrowser-ui-sort-columns-in-table");
092:                    if ("true".equals(sortColumnsFlag)) {
093:                        Collections.sort(listOfTableCells,
094:                                new DBTableCellComparator());
095:                    }
096:
097:                    DBTableCell dbTableCell = (DBTableCell) listOfTableCells
098:                            .get(col - 1);
099:                    cellValue = dbTableCell.getFormattedValue();
100:                }
101:
102:                return cellValue;
103:            }
104:
105:            /**
106:             * Returns the object value for a row and column
107:             * @return Object - unformatted object
108:             */
109:            public Object getObjectValueAt(int row, int col) {
110:                Object cellValue = null;
111:
112:                if (col == 0) {
113:                    return "" + (row + 1);
114:                } else {
115:                    DBRow dbRow = (DBRow) dbTable.getListOfRows().get(row);
116:                    List listOfTableCells = dbRow.getListOFDBTableCells();
117:
118:                    //if sorting enabled, sort the data in table and sort the columns
119:                    String sortColumnsFlag = PropertyManager.getInstance()
120:                            .getProperty("dbbrowser-ui-sort-columns-in-table");
121:                    if ("true".equals(sortColumnsFlag)) {
122:                        Collections.sort(listOfTableCells,
123:                                new DBTableCellComparator());
124:                    }
125:
126:                    DBTableCell dbTableCell = (DBTableCell) listOfTableCells
127:                            .get(col - 1);
128:                    cellValue = dbTableCell.getValue();
129:                }
130:
131:                return cellValue;
132:            }
133:
134:            /**
135:             * Returns the db table
136:             * @return
137:             */
138:            public DBTable getDBTable() {
139:                return dbTable;
140:            }
141:
142:            /**
143:             * Returns the class for the column data
144:             * @return Class
145:             */
146:            public Class getColumnClass(int columnIndex) {
147:                Class classToReturn = null;
148:
149:                ColumnInfo columnInfo = (ColumnInfo) listOfColumnInfosIncludingRowHeaderColumn
150:                        .get(columnIndex);
151:
152:                //if the type is a number (Double or Integer), return a Number.class
153:                if ((columnInfo.getColumnTypeName() != null)
154:                        && (columnInfo.getColumnTypeName()
155:                                .equals(ColumnInfo.COLUMN_TYPE_NUMBER))) {
156:                    classToReturn = Number.class;
157:                } else {
158:                    classToReturn = String.class;
159:                }
160:
161:                return classToReturn;
162:            }
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.