Source Code Cross Referenced for ExtendedDBTreeTableModel.java in  » ERP-CRM-Financial » Personal-Finance-Manager » br » com » gfpshare » beans » table » 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 » ERP CRM Financial » Personal Finance Manager » br.com.gfpshare.beans.table 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on 07/09/2007
003:         * 
004:         * Swing Components - visit http://sf.net/projects/gfd
005:         * 
006:         * Copyright (C) 2007  Igor Regis da Silva Simões
007:         * 
008:         * This program is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public License
010:         * as published by the Free Software Foundation; either version 2
011:         * of the License, or (at your option) any later version.
012:         *
013:         * This program is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         * GNU General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public License
019:         * along with this program; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021:         * 
022:         */
023:        package br.com.gfpshare.beans.table;
024:
025:        import javax.swing.tree.DefaultMutableTreeNode;
026:
027:        import br.com.gfpshare.db.PersistentObject;
028:
029:        /**
030:         * Esta classe extende o DBTreeTableModel default para permitir que ele exiba não somente
031:         * propriedades referentes a colunas da tabela a qual o Bo esta amarrado, mas também
032:         * propriedades que podem ser resultado de calculos ou até mesmo resultado de consultas em
033:         * outras tabelas do banco de dados.
034:         * 
035:         * Para proriedades resultantes de consultas a DB deve-se atentar para o controle de cache
036:         * pois este foge a responsabilidade deste componente.
037:         *
038:         * @author Igor Regis da Silva Simoes
039:         * @since 07/09/2007
040:         */
041:        public class ExtendedDBTreeTableModel extends DBTreeTableModel {
042:            private final String[] extraProperties;
043:
044:            public ExtendedDBTreeTableModel(PersistentObject dataType,
045:                    String fieldParentName, String[] extraProperties) {
046:                super (dataType, fieldParentName);
047:                this .extraProperties = extraProperties;
048:            }
049:
050:            @Override
051:            public int getColumnCount() {
052:                return super .getColumnCount() + extraProperties.length;
053:            }
054:
055:            @Override
056:            public int findColumn(String columnName) {
057:                int column = super .findColumn(columnName);
058:                if (column == -1)
059:                    for (int i = 0; i < extraProperties.length; i++)
060:                        if (extraProperties[i].equals(columnName))
061:                            return i + super .getColumnCount() + 1;
062:                return column;
063:            }
064:
065:            @Override
066:            public String getColumnName(int columnIndex) {
067:                String nome = super .getColumnName(columnIndex);
068:                if (nome == null)
069:                    return extraProperties[columnIndex - super .getColumnCount()];
070:                return nome;
071:            }
072:
073:            @Override
074:            public Object getValueAt(int rowIndex, int columnIndex) {
075:                if (columnIndex < super .getColumnCount())
076:                    return super .getValueAt(rowIndex, columnIndex);
077:                try {
078:                    PersistentObject p = getPersistentObject(rowIndex);
079:                    Object ret = p.getClass().getMethod(
080:                            "get"
081:                                    + extraProperties[columnIndex
082:                                            - super .getColumnCount()], null)
083:                            .invoke(p, null);
084:                    System.out.println(ret);
085:                    return ret;
086:                } catch (Exception e) {
087:                    // TODO Auto-generated catch block
088:                    e.printStackTrace();
089:                }
090:                return null;
091:            }
092:
093:            @Override
094:            public Object getValueAt(Object node, int column) {
095:                Object retorno = super .getValueAt(node, column);
096:                if (retorno == null) {
097:                    if (((DefaultMutableTreeNode) node).getUserObject() instanceof  PersistentObject) {
098:                        try {
099:                            return ((PersistentObject) ((DefaultMutableTreeNode) node)
100:                                    .getUserObject())
101:                                    .getClass()
102:                                    .getMethod("get" + getColumnName(column),
103:                                            null)
104:                                    .invoke(
105:                                            (PersistentObject) ((DefaultMutableTreeNode) node)
106:                                                    .getUserObject(), null);
107:                        } catch (Exception e) {
108:                            // TODO Auto-generated catch block
109:                            e.printStackTrace();
110:                        }
111:                    }
112:                }
113:                return retorno;
114:            }
115:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.