Source Code Cross Referenced for DriverPropertiesTableModel.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » client » gui » db » aliasproperties » 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 » squirrel sql 2.6.5a » net.sourceforge.squirrel_sql.client.gui.db.aliasproperties 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sourceforge.squirrel_sql.client.gui.db.aliasproperties;
002:
003:        /*
004:         * Copyright (C) 2002-2003 Colin Bell
005:         * colbell@users.sourceforge.net
006:         *
007:         * This library is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU Lesser General Public
009:         * License as published by the Free Software Foundation; either
010:         * version 2.1 of the License, or (at your option) any later version.
011:         *
012:         * This library is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this library; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
020:         */
021:        import java.sql.DriverPropertyInfo;
022:
023:        import javax.swing.table.AbstractTableModel;
024:
025:        import net.sourceforge.squirrel_sql.fw.sql.SQLDriverProperty;
026:        import net.sourceforge.squirrel_sql.fw.sql.SQLDriverPropertyCollection;
027:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
028:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
029:        import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
030:        import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
031:
032:        class DriverPropertiesTableModel extends AbstractTableModel {
033:            private static final long serialVersionUID = 1L;
034:
035:            /** Internationalized strings for this class. */
036:            private static final StringManager s_stringMgr = StringManagerFactory
037:                    .getStringManager(DriverPropertiesTableModel.class);
038:
039:            interface IColumnIndexes {
040:                int IDX_NAME = 0;
041:                int IDX_SPECIFY = 1;
042:                int IDX_VALUE = 2;
043:                int IDX_REQUIRED = 3;
044:                int IDX_DESCRIPTION = 4;
045:            }
046:
047:            /** Number of columns in model. */
048:            private static final int COLUMN_COUNT = 5;
049:
050:            /** Logger for this class. */
051:            private static final ILogger s_log = LoggerController
052:                    .createLogger(DriverPropertiesTableModel.class);
053:
054:            transient private SQLDriverPropertyCollection _props = new SQLDriverPropertyCollection();
055:
056:            DriverPropertiesTableModel(SQLDriverPropertyCollection props) {
057:                super ();
058:                if (props == null) {
059:                    throw new IllegalArgumentException(
060:                            "SQLDriverPropertyCollection[] == null");
061:                }
062:
063:                load(props);
064:            }
065:
066:            public Object getValueAt(int row, int col) {
067:                final SQLDriverProperty sdp = _props.getDriverProperty(row);
068:                switch (col) {
069:                case IColumnIndexes.IDX_NAME:
070:                    return sdp.getName();
071:
072:                case IColumnIndexes.IDX_SPECIFY:
073:                    return Boolean.valueOf(sdp.isSpecified());
074:
075:                case IColumnIndexes.IDX_VALUE:
076:                    return sdp.getValue();
077:
078:                case IColumnIndexes.IDX_REQUIRED: {
079:                    // Use valueof when min supported JDK is 1.4
080:                    //return Boolean.valueOf(_props[row].required);
081:                    DriverPropertyInfo dpi = sdp.getDriverPropertyInfo();
082:                    if (dpi != null) {
083:                        return Boolean.valueOf(dpi.required);
084:                    }
085:                    return Boolean.FALSE;
086:                }
087:
088:                case IColumnIndexes.IDX_DESCRIPTION: {
089:                    DriverPropertyInfo dpi = sdp.getDriverPropertyInfo();
090:                    if (dpi != null) {
091:                        return dpi.description;
092:                    }
093:                    return s_stringMgr
094:                            .getString("DriverPropertiesTableModel.unknown");
095:                }
096:
097:                default:
098:                    s_log.error("Invalid column index: " + col);
099:                    return "???????";
100:                }
101:            }
102:
103:            public int getRowCount() {
104:                return _props.size();
105:            }
106:
107:            public int getColumnCount() {
108:                return COLUMN_COUNT;
109:            }
110:
111:            public Class<?> getColumnClass(int col) {
112:                switch (col) {
113:                case IColumnIndexes.IDX_NAME:
114:                    return String.class;
115:                case IColumnIndexes.IDX_SPECIFY:
116:                    return Boolean.class;
117:                case IColumnIndexes.IDX_VALUE:
118:                    return String.class;
119:                case IColumnIndexes.IDX_REQUIRED:
120:                    //				return Boolean.class;	// Don't show checkbox for
121:                    return Object.class; // output only field.
122:                case IColumnIndexes.IDX_DESCRIPTION:
123:                    return String.class;
124:                default:
125:                    s_log.error("Invalid column index: " + col);
126:                    return Object.class;
127:                }
128:            }
129:
130:            public boolean isCellEditable(int row, int col) {
131:                return col == IColumnIndexes.IDX_SPECIFY
132:                        || col == IColumnIndexes.IDX_VALUE;
133:            }
134:
135:            public void setValueAt(Object value, int row, int col) {
136:                if (col == IColumnIndexes.IDX_VALUE) {
137:                    final SQLDriverProperty sdp = _props.getDriverProperty(row);
138:                    sdp.setValue(value.toString());
139:                } else if (col == IColumnIndexes.IDX_SPECIFY) {
140:                    final SQLDriverProperty sdp = _props.getDriverProperty(row);
141:                    Boolean bool = Boolean.valueOf(value.toString());
142:                    sdp.setIsSpecified(bool.booleanValue());
143:                } else {
144:                    throw new IllegalStateException(
145:                            "Can only edit value/specify column. Trying to edit "
146:                                    + col);
147:                }
148:            }
149:
150:            SQLDriverPropertyCollection getSQLDriverProperties() {
151:                return _props;
152:            }
153:
154:            private final void load(SQLDriverPropertyCollection props) {
155:                final int origSize = getRowCount();
156:                if (origSize > 0) {
157:                    fireTableRowsDeleted(0, origSize - 1);
158:                }
159:
160:                _props = props;
161:                final int newSize = getRowCount();
162:                if (newSize > 0) {
163:                    fireTableRowsInserted(0, newSize - 1);
164:                }
165:            }
166:        }
w_w__w___.j___a___v___a_2__s___._c___om | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.