KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > db > explorer > nodes > ConnectionNode


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.db.explorer.nodes;
21
22 import java.awt.datatransfer.Transferable JavaDoc;
23 import java.beans.PropertyChangeEvent JavaDoc;
24 import java.beans.PropertyChangeListener JavaDoc;
25 import java.io.IOException JavaDoc;
26 import java.sql.Connection JavaDoc;
27 import java.sql.DatabaseMetaData JavaDoc;
28 import org.netbeans.modules.db.explorer.ConnectionList;
29 import org.netbeans.modules.db.explorer.DatabaseConnection;
30 import org.netbeans.modules.db.explorer.DbMetaDataTransferProvider;
31 import org.netbeans.modules.db.explorer.infos.ConnectionNodeInfo;
32 import org.openide.util.Lookup;
33
34 import org.openide.util.NbBundle;
35 import org.openide.nodes.Node;
36 import org.openide.nodes.PropertySupport;
37 import org.openide.nodes.Sheet;
38 import org.openide.util.RequestProcessor;
39
40 import org.netbeans.lib.ddl.adaptors.DefaultAdaptor;
41 import org.netbeans.modules.db.explorer.DatabaseNodeChildren;
42 import org.netbeans.modules.db.explorer.infos.DatabaseNodeInfo;
43 import org.openide.util.datatransfer.ExTransferable;
44
45 /**
46 * Node representing open or closed connection to database.
47 */

48
49 public class ConnectionNode extends DatabaseNode {
50     
51     private boolean createPropSupport = true;
52     
53     public void setInfo(DatabaseNodeInfo nodeinfo) {
54         super.setInfo(nodeinfo);
55         DatabaseNodeInfo info = getInfo();
56
57         setName(info.getName());
58
59         info.put(DefaultAdaptor.PROP_MIXEDCASE_IDENTIFIERS, Boolean.FALSE);
60         info.put(DefaultAdaptor.PROP_MIXEDCASE_QUOTED_IDENTIFIERS, Boolean.FALSE);
61         info.put(DefaultAdaptor.PROP_ALTER_ADD, Boolean.FALSE);
62         info.put(DefaultAdaptor.PROP_ALTER_DROP, Boolean.FALSE);
63         info.put(DefaultAdaptor.PROP_CONVERT, Boolean.FALSE);
64         info.put(DefaultAdaptor.PROP_TABLE_CORRELATION_NAMES, Boolean.FALSE);
65         info.put(DefaultAdaptor.PROP_TABLE_CORRELATION_NAMES, Boolean.FALSE);
66         info.put(DefaultAdaptor.PROP_EXPRESSIONS_IN_ORDERBY, Boolean.FALSE);
67         info.put(DefaultAdaptor.PROP_ORDER_BY_UNRELATED, Boolean.FALSE);
68         info.put(DefaultAdaptor.PROP_GROUP_BY, Boolean.FALSE);
69         info.put(DefaultAdaptor.PROP_UNRELATED_GROUP_BY, Boolean.FALSE);
70         info.put(DefaultAdaptor.PROP_BEYOND_GROUP_BY, Boolean.FALSE);
71         info.put(DefaultAdaptor.PROP_ESCAPE_LIKE, Boolean.FALSE);
72         info.put(DefaultAdaptor.PROP_MULTIPLE_RS, Boolean.FALSE);
73         info.put(DefaultAdaptor.PROP_MULTIPLE_TRANSACTIONS, Boolean.FALSE);
74         info.put(DefaultAdaptor.PROP_NON_NULL_COLUMNSS, Boolean.FALSE);
75         info.put(DefaultAdaptor.PROP_MINUMUM_SQL_GRAMMAR, Boolean.FALSE);
76         info.put(DefaultAdaptor.PROP_CORE_SQL_GRAMMAR, Boolean.FALSE);
77         info.put(DefaultAdaptor.PROP_EXTENDED_SQL_GRAMMAR, Boolean.FALSE);
78         info.put(DefaultAdaptor.PROP_ANSI_SQL_GRAMMAR, Boolean.FALSE);
79         info.put(DefaultAdaptor.PROP_INTERMEDIATE_SQL_GRAMMAR, Boolean.FALSE);
80         info.put(DefaultAdaptor.PROP_FULL_SQL_GRAMMAR, Boolean.FALSE);
81         info.put(DefaultAdaptor.PROP_INTEGRITY_ENHANCEMENT, Boolean.FALSE);
82         info.put(DefaultAdaptor.PROP_OUTER_JOINS, Boolean.FALSE);
83         info.put(DefaultAdaptor.PROP_FULL_OUTER_JOINS, Boolean.FALSE);
84         info.put(DefaultAdaptor.PROP_LIMITED_OUTER_JOINS, Boolean.FALSE);
85         info.put(DefaultAdaptor.PROP_SCHEMAS_IN_DML, Boolean.FALSE);
86         info.put(DefaultAdaptor.PROP_SCHEMAS_IN_PROCEDURE_CALL, Boolean.FALSE);
87         info.put(DefaultAdaptor.PROP_SCHEMAS_IN_TABLE_DEFINITION, Boolean.FALSE);
88         info.put(DefaultAdaptor.PROP_SCHEMAS_IN_INDEX, Boolean.FALSE);
89         info.put(DefaultAdaptor.PROP_SCHEMAS_IN_PRIVILEGE_DEFINITION, Boolean.FALSE);
90         info.put(DefaultAdaptor.PROP_CATALOGS_IN_DML, Boolean.FALSE);
91         info.put(DefaultAdaptor.PROP_CATALOGS_IN_PROCEDURE_CALL, Boolean.FALSE);
92         info.put(DefaultAdaptor.PROP_CATALOGS_IN_TABLE_DEFINITION, Boolean.FALSE);
93         info.put(DefaultAdaptor.PROP_CATALOGS_IN_INDEX, Boolean.FALSE);
94         info.put(DefaultAdaptor.PROP_CATALOGS_IN_PRIVILEGE_DEFINITION, Boolean.FALSE);
95         info.put(DefaultAdaptor.PROP_POSITIONED_DELETE, Boolean.FALSE);
96         info.put(DefaultAdaptor.PROP_POSITIONED_UPDATE, Boolean.FALSE);
97         info.put(DefaultAdaptor.PROP_SELECT_FOR_UPDATE, Boolean.FALSE);
98         info.put(DefaultAdaptor.PROP_STORED_PROCEDURES, Boolean.FALSE);
99         info.put(DefaultAdaptor.PROP_SUBQUERY_IN_COMPARSIONS, Boolean.FALSE);
100         info.put(DefaultAdaptor.PROP_SUBQUERY_IN_EXISTS, Boolean.FALSE);
101         info.put(DefaultAdaptor.PROP_SUBQUERY_IN_INS, Boolean.FALSE);
102         info.put(DefaultAdaptor.PROP_SUBQUERY_IN_QUANTIFIEDS, Boolean.FALSE);
103         info.put(DefaultAdaptor.PROP_CORRELATED_SUBQUERIES, Boolean.FALSE);
104         info.put(DefaultAdaptor.PROP_UNION, Boolean.FALSE);
105         info.put(DefaultAdaptor.PROP_UNION_ALL, Boolean.FALSE);
106         info.put(DefaultAdaptor.PROP_OPEN_CURSORS_ACROSS_COMMIT, Boolean.FALSE);
107         info.put(DefaultAdaptor.PROP_OPEN_CURSORS_ACROSS_ROLLBACK, Boolean.FALSE);
108         info.put(DefaultAdaptor.PROP_OPEN_STATEMENTS_ACROSS_COMMIT, Boolean.FALSE);
109         info.put(DefaultAdaptor.PROP_OPEN_STATEMENTS_ACROSS_ROLLBACK, Boolean.FALSE);
110         info.put(DefaultAdaptor.PROP_TRANSACTIONS, Boolean.FALSE);
111         info.put(DefaultAdaptor.PROP_DDL_AND_DML_TRANSACTIONS, Boolean.FALSE);
112         info.put(DefaultAdaptor.PROP_DML_TRANSACTIONS_ONLY, Boolean.FALSE);
113         info.put(DefaultAdaptor.PROP_BATCH_UPDATES, Boolean.FALSE);
114         info.put(DefaultAdaptor.PROP_CATALOG_AT_START, Boolean.FALSE);
115         info.put(DefaultAdaptor.PROP_COLUMN_ALIASING, Boolean.FALSE);
116         info.put(DefaultAdaptor.PROP_DDL_CAUSES_COMMIT, Boolean.FALSE);
117         info.put(DefaultAdaptor.PROP_DDL_IGNORED_IN_TRANSACTIONS, Boolean.FALSE);
118         info.put(DefaultAdaptor.PROP_DIFF_TABLE_CORRELATION_NAMES, Boolean.FALSE);
119         info.put(DefaultAdaptor.PROP_LOCAL_FILES, Boolean.FALSE);
120         info.put(DefaultAdaptor.PROP_FILE_PER_TABLE, Boolean.FALSE);
121         info.put(DefaultAdaptor.PROP_ROWSIZE_INCLUDING_BLOBS, Boolean.FALSE);
122         info.put(DefaultAdaptor.PROP_NULL_PLUS_NULL_IS_NULL, Boolean.FALSE);
123         info.put(DefaultAdaptor.PROP_PROCEDURES_ARE_CALLABLE, Boolean.FALSE);
124         info.put(DefaultAdaptor.PROP_TABLES_ARE_SELECTABLE, Boolean.FALSE);
125         
126         info.put(DefaultAdaptor.PROP_READONLY, info.isReadOnly() ? Boolean.TRUE : Boolean.FALSE);
127
128         info.addConnectionListener(new PropertyChangeListener JavaDoc() {
129             public void propertyChange(PropertyChangeEvent JavaDoc evt) {
130                 if (evt.getPropertyName().equals(DatabaseNodeInfo.DATABASE))
131                     setConnectionName();
132                 if (evt.getPropertyName().equals(DatabaseNodeInfo.SCHEMA))
133                     setConnectionName();
134                 if (evt.getPropertyName().equals(DatabaseNodeInfo.USER))
135                     setConnectionName();
136                 if (evt.getPropertyName().equals(DatabaseNodeInfo.CONNECTION)) {
137                     update((Connection JavaDoc)evt.getNewValue());
138                     firePropertyChange(null, null, null);
139                 }
140             }
141         });
142
143         getCookieSet().add(this);
144     }
145
146     private void setConnectionName() {
147         String JavaDoc displayName = getInfo().getDatabaseConnection().getName();
148         setDisplayName(displayName);
149     }
150         
151     private boolean createPropSupport() {
152         return createPropSupport;
153     }
154     
155     private void setPropSupport(boolean value) {
156         createPropSupport = value;
157     }
158     
159     private void update(Connection JavaDoc connection) {
160         final boolean connecting = (connection != null);
161         RequestProcessor.getDefault().post(new Runnable JavaDoc() {
162             public void run () {
163                 DatabaseNodeChildren children = (DatabaseNodeChildren)getChildren();
164                 DatabaseNodeInfo info = getInfo();
165                 
166                 setIconBase((String JavaDoc)info.get(connecting ? "activeiconbase" : "iconbase")); //NOI18N
167
setConnectionName();
168                 Sheet.Set set = getSheet().get(Sheet.PROPERTIES);
169                 
170                 try {
171                     if (createPropSupport()) {
172                         Node.Property dbprop = set.get(DatabaseNodeInfo.DATABASE);
173                         PropertySupport newdbprop = createPropertySupport(dbprop.getName(), dbprop.getValueType(), dbprop.getDisplayName(), dbprop.getShortDescription(), info, !connecting);
174                         set.put(newdbprop);
175                         firePropertyChange("db",dbprop,newdbprop); //NOI18N
176

177                         Node.Property drvprop = set.get(DatabaseNodeInfo.DRIVER);
178                         PropertySupport newdrvprop = createPropertySupport(drvprop.getName(), drvprop.getValueType(), drvprop.getDisplayName(), drvprop.getShortDescription(), info, !connecting);
179                         set.put(newdrvprop);
180                         firePropertyChange("driver",drvprop,newdrvprop); //NOI18N
181

182                         Node.Property schemaprop = set.get(DatabaseNodeInfo.SCHEMA);
183                         PropertySupport newschemaprop = createPropertySupport(schemaprop.getName(), schemaprop.getValueType(), schemaprop.getDisplayName(), schemaprop.getShortDescription(), info, !connecting);
184                         set.put(newschemaprop);
185                         firePropertyChange("schema",schemaprop,newschemaprop); //NOI18N
186

187                         Node.Property usrprop = set.get(DatabaseNodeInfo.USER);
188                         PropertySupport newusrprop = createPropertySupport(usrprop.getName(), usrprop.getValueType(), usrprop.getDisplayName(), usrprop.getShortDescription(), info, !connecting);
189                         set.put(newusrprop);
190                         firePropertyChange("user",usrprop,newusrprop); //NOI18N
191

192                         Node.Property rememberprop = set.get(DatabaseNodeInfo.REMEMBER_PWD);
193                         PropertySupport newrememberprop = createPropertySupport(rememberprop.getName(), rememberprop.getValueType(), rememberprop.getDisplayName(), rememberprop.getShortDescription(), info, connecting);
194                         set.put(newrememberprop);
195                         firePropertyChange("rememberpwd",rememberprop,newrememberprop); //NOI18N
196

197                         setPropSupport(false);
198                     } else {
199                         Node.Property dbprop = set.get(DatabaseNodeInfo.DATABASE);
200                         set.put(dbprop);
201                         firePropertyChange("db",null,dbprop); //NOI18N
202

203                         Node.Property drvprop = set.get(DatabaseNodeInfo.DRIVER);
204                         firePropertyChange("driver",null,drvprop); //NOI18N
205

206                         Node.Property schemaprop = set.get(DatabaseNodeInfo.SCHEMA);
207                         firePropertyChange("schema",null,schemaprop); //NOI18N
208

209                         Node.Property usrprop = set.get(DatabaseNodeInfo.USER);
210                         firePropertyChange("user",null,usrprop); //NOI18N
211

212                         Node.Property rememberprop = set.get(DatabaseNodeInfo.REMEMBER_PWD);
213                         firePropertyChange("rememberpwd",null,rememberprop); //NOI18N
214
}
215                     
216                     if (!connecting) {
217                         children.remove(children.getNodes());
218                         getInfo().getChildren().clear();
219                     } else {
220                         DatabaseMetaData JavaDoc dmd = info.getSpecification().getMetaData();
221
222                         try {
223                             info.put(DefaultAdaptor.PROP_PRODUCTNAME, dmd.getDatabaseProductName());
224
225                             info.put(DefaultAdaptor.PROP_MIXEDCASE_IDENTIFIERS, dmd.supportsMixedCaseIdentifiers() ? Boolean.TRUE : Boolean.FALSE);
226                             info.put(DefaultAdaptor.PROP_MIXEDCASE_QUOTED_IDENTIFIERS, dmd.supportsMixedCaseQuotedIdentifiers() ? Boolean.TRUE : Boolean.FALSE);
227                             info.put(DefaultAdaptor.PROP_ALTER_ADD, dmd.supportsAlterTableWithAddColumn() ? Boolean.TRUE : Boolean.FALSE);
228                             info.put(DefaultAdaptor.PROP_ALTER_DROP, dmd.supportsAlterTableWithDropColumn() ? Boolean.TRUE : Boolean.FALSE);
229                             info.put(DefaultAdaptor.PROP_CONVERT, dmd.supportsConvert() ? Boolean.TRUE : Boolean.FALSE);
230                             info.put(DefaultAdaptor.PROP_TABLE_CORRELATION_NAMES, dmd.supportsTableCorrelationNames() ? Boolean.TRUE : Boolean.FALSE);
231                             info.put(DefaultAdaptor.PROP_TABLE_CORRELATION_NAMES, dmd.supportsDifferentTableCorrelationNames() ? Boolean.TRUE : Boolean.FALSE);
232                             info.put(DefaultAdaptor.PROP_EXPRESSIONS_IN_ORDERBY, dmd.supportsExpressionsInOrderBy() ? Boolean.TRUE : Boolean.FALSE);
233                             info.put(DefaultAdaptor.PROP_ORDER_BY_UNRELATED, dmd.supportsOrderByUnrelated() ? Boolean.TRUE : Boolean.FALSE);
234                             info.put(DefaultAdaptor.PROP_GROUP_BY, dmd.supportsGroupBy() ? Boolean.TRUE : Boolean.FALSE);
235                             info.put(DefaultAdaptor.PROP_UNRELATED_GROUP_BY, dmd.supportsGroupByUnrelated() ? Boolean.TRUE : Boolean.FALSE);
236                             info.put(DefaultAdaptor.PROP_BEYOND_GROUP_BY, dmd.supportsGroupByBeyondSelect() ? Boolean.TRUE : Boolean.FALSE);
237                             info.put(DefaultAdaptor.PROP_ESCAPE_LIKE, dmd.supportsLikeEscapeClause() ? Boolean.TRUE : Boolean.FALSE);
238                             info.put(DefaultAdaptor.PROP_MULTIPLE_RS, dmd.supportsMultipleResultSets() ? Boolean.TRUE : Boolean.FALSE);
239                             info.put(DefaultAdaptor.PROP_MULTIPLE_TRANSACTIONS, dmd.supportsMultipleTransactions() ? Boolean.TRUE : Boolean.FALSE);
240                             info.put(DefaultAdaptor.PROP_NON_NULL_COLUMNSS, dmd.supportsNonNullableColumns() ? Boolean.TRUE : Boolean.FALSE);
241                             info.put(DefaultAdaptor.PROP_MINUMUM_SQL_GRAMMAR, dmd.supportsMinimumSQLGrammar() ? Boolean.TRUE : Boolean.FALSE);
242                             info.put(DefaultAdaptor.PROP_CORE_SQL_GRAMMAR, dmd.supportsCoreSQLGrammar() ? Boolean.TRUE : Boolean.FALSE);
243                             info.put(DefaultAdaptor.PROP_EXTENDED_SQL_GRAMMAR, dmd.supportsExtendedSQLGrammar() ? Boolean.TRUE : Boolean.FALSE);
244                             info.put(DefaultAdaptor.PROP_ANSI_SQL_GRAMMAR, dmd.supportsANSI92EntryLevelSQL() ? Boolean.TRUE : Boolean.FALSE);
245                             info.put(DefaultAdaptor.PROP_INTERMEDIATE_SQL_GRAMMAR, dmd.supportsANSI92IntermediateSQL() ? Boolean.TRUE : Boolean.FALSE);
246                             info.put(DefaultAdaptor.PROP_FULL_SQL_GRAMMAR, dmd.supportsANSI92FullSQL() ? Boolean.TRUE : Boolean.FALSE);
247                             info.put(DefaultAdaptor.PROP_INTEGRITY_ENHANCEMENT, dmd.supportsIntegrityEnhancementFacility() ? Boolean.TRUE : Boolean.FALSE);
248                             info.put(DefaultAdaptor.PROP_OUTER_JOINS, dmd.supportsOuterJoins() ? Boolean.TRUE : Boolean.FALSE);
249                             info.put(DefaultAdaptor.PROP_FULL_OUTER_JOINS, dmd.supportsFullOuterJoins() ? Boolean.TRUE : Boolean.FALSE);
250                             info.put(DefaultAdaptor.PROP_LIMITED_OUTER_JOINS, dmd.supportsLimitedOuterJoins() ? Boolean.TRUE : Boolean.FALSE);
251                             info.put(DefaultAdaptor.PROP_SCHEMAS_IN_DML, dmd.supportsSchemasInDataManipulation() ? Boolean.TRUE : Boolean.FALSE);
252                             info.put(DefaultAdaptor.PROP_SCHEMAS_IN_PROCEDURE_CALL, dmd.supportsSchemasInProcedureCalls() ? Boolean.TRUE : Boolean.FALSE);
253                             info.put(DefaultAdaptor.PROP_SCHEMAS_IN_TABLE_DEFINITION, dmd.supportsSchemasInTableDefinitions() ? Boolean.TRUE : Boolean.FALSE);
254                             info.put(DefaultAdaptor.PROP_SCHEMAS_IN_INDEX, dmd.supportsSchemasInIndexDefinitions() ? Boolean.TRUE : Boolean.FALSE);
255                             info.put(DefaultAdaptor.PROP_SCHEMAS_IN_PRIVILEGE_DEFINITION, dmd.supportsSchemasInPrivilegeDefinitions() ? Boolean.TRUE : Boolean.FALSE);
256                             info.put(DefaultAdaptor.PROP_CATALOGS_IN_DML, dmd.supportsCatalogsInDataManipulation() ? Boolean.TRUE : Boolean.FALSE);
257                             info.put(DefaultAdaptor.PROP_CATALOGS_IN_PROCEDURE_CALL, dmd.supportsCatalogsInProcedureCalls() ? Boolean.TRUE : Boolean.FALSE);
258                             info.put(DefaultAdaptor.PROP_CATALOGS_IN_TABLE_DEFINITION, dmd.supportsCatalogsInTableDefinitions() ? Boolean.TRUE : Boolean.FALSE);
259                             info.put(DefaultAdaptor.PROP_CATALOGS_IN_INDEX, dmd.supportsCatalogsInIndexDefinitions() ? Boolean.TRUE : Boolean.FALSE);
260                             info.put(DefaultAdaptor.PROP_CATALOGS_IN_PRIVILEGE_DEFINITION, dmd.supportsCatalogsInPrivilegeDefinitions() ? Boolean.TRUE : Boolean.FALSE);
261                             info.put(DefaultAdaptor.PROP_POSITIONED_DELETE, dmd.supportsPositionedDelete() ? Boolean.TRUE : Boolean.FALSE);
262                             info.put(DefaultAdaptor.PROP_POSITIONED_UPDATE, dmd.supportsPositionedUpdate() ? Boolean.TRUE : Boolean.FALSE);
263                             info.put(DefaultAdaptor.PROP_SELECT_FOR_UPDATE, dmd.supportsSelectForUpdate() ? Boolean.TRUE : Boolean.FALSE);
264                             info.put(DefaultAdaptor.PROP_STORED_PROCEDURES, dmd.supportsStoredProcedures() ? Boolean.TRUE : Boolean.FALSE);
265                             info.put(DefaultAdaptor.PROP_SUBQUERY_IN_COMPARSIONS, dmd.supportsSubqueriesInComparisons() ? Boolean.TRUE : Boolean.FALSE);
266                             info.put(DefaultAdaptor.PROP_SUBQUERY_IN_EXISTS, dmd.supportsSubqueriesInExists() ? Boolean.TRUE : Boolean.FALSE);
267                             info.put(DefaultAdaptor.PROP_SUBQUERY_IN_INS, dmd.supportsSubqueriesInIns() ? Boolean.TRUE : Boolean.FALSE);
268                             info.put(DefaultAdaptor.PROP_SUBQUERY_IN_QUANTIFIEDS, dmd.supportsSubqueriesInQuantifieds() ? Boolean.TRUE : Boolean.FALSE);
269                             info.put(DefaultAdaptor.PROP_CORRELATED_SUBQUERIES, dmd.supportsCorrelatedSubqueries() ? Boolean.TRUE : Boolean.FALSE);
270                             info.put(DefaultAdaptor.PROP_UNION, dmd.supportsUnion() ? Boolean.TRUE : Boolean.FALSE);
271                             info.put(DefaultAdaptor.PROP_UNION_ALL, dmd.supportsUnionAll() ? Boolean.TRUE : Boolean.FALSE);
272                             info.put(DefaultAdaptor.PROP_OPEN_CURSORS_ACROSS_COMMIT, dmd.supportsOpenCursorsAcrossCommit() ? Boolean.TRUE : Boolean.FALSE);
273                             info.put(DefaultAdaptor.PROP_OPEN_CURSORS_ACROSS_ROLLBACK, dmd.supportsOpenCursorsAcrossRollback() ? Boolean.TRUE : Boolean.FALSE);
274                             info.put(DefaultAdaptor.PROP_OPEN_STATEMENTS_ACROSS_COMMIT, dmd.supportsOpenStatementsAcrossCommit() ? Boolean.TRUE : Boolean.FALSE);
275                             info.put(DefaultAdaptor.PROP_OPEN_STATEMENTS_ACROSS_ROLLBACK, dmd.supportsOpenStatementsAcrossRollback() ? Boolean.TRUE : Boolean.FALSE);
276                             info.put(DefaultAdaptor.PROP_TRANSACTIONS, dmd.supportsTransactions() ? Boolean.TRUE : Boolean.FALSE);
277                             info.put(DefaultAdaptor.PROP_DDL_AND_DML_TRANSACTIONS, dmd.supportsDataDefinitionAndDataManipulationTransactions() ? Boolean.TRUE : Boolean.FALSE);
278                             info.put(DefaultAdaptor.PROP_DML_TRANSACTIONS_ONLY, dmd.supportsDataManipulationTransactionsOnly() ? Boolean.TRUE : Boolean.FALSE);
279                             info.put(DefaultAdaptor.PROP_BATCH_UPDATES, dmd.supportsBatchUpdates() ? Boolean.TRUE : Boolean.FALSE);
280                             info.put(DefaultAdaptor.PROP_CATALOG_AT_START, dmd.isCatalogAtStart() ? Boolean.TRUE : Boolean.FALSE);
281                             info.put(DefaultAdaptor.PROP_COLUMN_ALIASING, dmd.supportsColumnAliasing() ? Boolean.TRUE : Boolean.FALSE);
282                             info.put(DefaultAdaptor.PROP_DDL_CAUSES_COMMIT, dmd.dataDefinitionCausesTransactionCommit() ? Boolean.TRUE : Boolean.FALSE);
283                             info.put(DefaultAdaptor.PROP_DDL_IGNORED_IN_TRANSACTIONS, dmd.dataDefinitionIgnoredInTransactions() ? Boolean.TRUE : Boolean.FALSE);
284                             info.put(DefaultAdaptor.PROP_DIFF_TABLE_CORRELATION_NAMES, dmd.supportsDifferentTableCorrelationNames() ? Boolean.TRUE : Boolean.FALSE);
285                             info.put(DefaultAdaptor.PROP_LOCAL_FILES, dmd.usesLocalFiles() ? Boolean.TRUE : Boolean.FALSE);
286                             info.put(DefaultAdaptor.PROP_FILE_PER_TABLE, dmd.usesLocalFilePerTable() ? Boolean.TRUE : Boolean.FALSE);
287                             info.put(DefaultAdaptor.PROP_ROWSIZE_INCLUDING_BLOBS, dmd.doesMaxRowSizeIncludeBlobs() ? Boolean.TRUE : Boolean.FALSE);
288                             info.put(DefaultAdaptor.PROP_NULL_PLUS_NULL_IS_NULL, dmd.nullPlusNonNullIsNull() ? Boolean.TRUE : Boolean.FALSE);
289                             info.put(DefaultAdaptor.PROP_PROCEDURES_ARE_CALLABLE, dmd.allProceduresAreCallable() ? Boolean.TRUE : Boolean.FALSE);
290                             info.put(DefaultAdaptor.PROP_TABLES_ARE_SELECTABLE, dmd.allTablesAreSelectable() ? Boolean.TRUE : Boolean.FALSE);
291
292                             info.put(DefaultAdaptor.PROP_MAX_BINARY_LITERAL_LENGTH, new Integer JavaDoc(dmd.getMaxBinaryLiteralLength()));
293                             info.put(DefaultAdaptor.PROP_MAX_CHAR_LITERAL_LENGTH, new Integer JavaDoc(dmd.getMaxCharLiteralLength()));
294                             info.put(DefaultAdaptor.PROP_MAX_COLUMN_NAME_LENGTH, new Integer JavaDoc(dmd.getMaxColumnNameLength()));
295                             info.put(DefaultAdaptor.PROP_MAX_COLUMNS_IN_GROUPBY, new Integer JavaDoc(dmd.getMaxColumnsInGroupBy()));
296                             info.put(DefaultAdaptor.PROP_MAX_COLUMNS_IN_INDEX, new Integer JavaDoc(dmd.getMaxColumnsInIndex()));
297                             info.put(DefaultAdaptor.PROP_MAX_COLUMNS_IN_ORDERBY, new Integer JavaDoc(dmd.getMaxColumnsInOrderBy()));
298                             info.put(DefaultAdaptor.PROP_MAX_COLUMNS_IN_SELECT, new Integer JavaDoc(dmd.getMaxColumnsInSelect()));
299                             info.put(DefaultAdaptor.PROP_MAX_COLUMNS_IN_TABLE, new Integer JavaDoc(dmd.getMaxColumnsInTable()));
300                             info.put(DefaultAdaptor.PROP_MAX_CONNECTIONS, new Integer JavaDoc(dmd.getMaxConnections()));
301                             info.put(DefaultAdaptor.PROP_MAX_CURSORNAME_LENGTH, new Integer JavaDoc(dmd.getMaxCursorNameLength()));
302                             info.put(DefaultAdaptor.PROP_MAX_INDEX_LENGTH, new Integer JavaDoc(dmd.getMaxIndexLength()));
303                             info.put(DefaultAdaptor.PROP_MAX_SCHEMA_NAME, new Integer JavaDoc(dmd.getMaxSchemaNameLength()));
304                             info.put(DefaultAdaptor.PROP_MAX_PROCEDURE_NAME, new Integer JavaDoc(dmd.getMaxProcedureNameLength()));
305                             info.put(DefaultAdaptor.PROP_MAX_CATALOG_NAME, new Integer JavaDoc(dmd.getMaxCatalogNameLength()));
306                             info.put(DefaultAdaptor.PROP_MAX_ROW_SIZE, new Integer JavaDoc(dmd.getMaxRowSize()));
307                             info.put(DefaultAdaptor.PROP_MAX_STATEMENT_LENGTH, new Integer JavaDoc(dmd.getMaxStatementLength()));
308                             info.put(DefaultAdaptor.PROP_MAX_STATEMENTS, new Integer JavaDoc(dmd.getMaxStatements()));
309                             info.put(DefaultAdaptor.PROP_MAX_TABLENAME_LENGTH, new Integer JavaDoc(dmd.getMaxTableNameLength()));
310                             info.put(DefaultAdaptor.PROP_MAX_TABLES_IN_SELECT, new Integer JavaDoc(dmd.getMaxTablesInSelect()));
311                             info.put(DefaultAdaptor.PROP_MAX_USERNAME, new Integer JavaDoc(dmd.getMaxUserNameLength()));
312                             info.put(DefaultAdaptor.PROP_DEFAULT_ISOLATION, new Integer JavaDoc(dmd.getDefaultTransactionIsolation()));
313
314                             info.put(DefaultAdaptor.PROP_URL, dmd.getURL());
315                             info.put(DefaultAdaptor.PROP_USERNAME, dmd.getUserName());
316                             info.put(DefaultAdaptor.PROP_PRODUCTVERSION, dmd.getDatabaseProductVersion());
317                             info.put(DefaultAdaptor.PROP_DRIVERNAME, dmd.getDriverName());
318                             info.put(DefaultAdaptor.PROP_DRIVER_VERSION, dmd.getDriverVersion());
319                             info.put(DefaultAdaptor.PROP_DRIVER_MAJOR_VERSION, new Integer JavaDoc(dmd.getDriverMajorVersion()));
320                             info.put(DefaultAdaptor.PROP_DRIVER_MINOR_VERSION, new Integer JavaDoc(dmd.getDriverMinorVersion()));
321                             info.put(DefaultAdaptor.PROP_IDENTIFIER_QUOTE, dmd.getIdentifierQuoteString());
322                             info.put(DefaultAdaptor.PROP_SQL_KEYWORDS, dmd.getSQLKeywords());
323
324                             info.put(DefaultAdaptor.PROP_NUMERIC_FUNCTIONS, dmd.getNumericFunctions());
325                             info.put(DefaultAdaptor.PROP_STRING_FUNCTIONS, dmd.getStringFunctions());
326                             info.put(DefaultAdaptor.PROP_SYSTEM_FUNCTIONS, dmd.getSystemFunctions());
327                             info.put(DefaultAdaptor.PROP_TIME_FUNCTIONS, dmd.getTimeDateFunctions());
328                             info.put(DefaultAdaptor.PROP_STRING_ESCAPE, dmd.getSearchStringEscape());
329                             info.put(DefaultAdaptor.PROP_EXTRA_CHARACTERS, dmd.getExtraNameCharacters());
330                             info.put(DefaultAdaptor.PROP_SCHEMA_TERM, dmd.getSchemaTerm());
331                             info.put(DefaultAdaptor.PROP_PROCEDURE_TERM, dmd.getProcedureTerm());
332                             info.put(DefaultAdaptor.PROP_CATALOG_TERM, dmd.getCatalogTerm());
333                             info.put(DefaultAdaptor.PROP_CATALOGS_SEPARATOR, dmd.getCatalogSeparator());
334                         } catch (Exception JavaDoc ex) {
335                             //ex.printStackTrace();
336
}
337                         
338                         // Create subnodes
339

340                         DatabaseNodeInfo innernfo;
341                         innernfo = DatabaseNodeInfo.createNodeInfo(info, DatabaseNode.TABLELIST);
342                         children.createSubnode(innernfo, true);
343                         innernfo = DatabaseNodeInfo.createNodeInfo(info, DatabaseNode.VIEWLIST);
344                         children.createSubnode(innernfo, true);
345                         innernfo = DatabaseNodeInfo.createNodeInfo(info, DatabaseNode.PROCEDURELIST);
346                         children.createSubnode(innernfo, true);
347                     }
348                 } catch (Exception JavaDoc e) {
349                     //e.printStackTrace();
350
}
351
352             }
353         }, 0);
354     }
355     
356     /**
357     * Can be destroyed only if connection is closed.
358     */

359     public boolean canDestroy() {
360         return !getInfo().isConnected();
361     }
362
363     public String JavaDoc getShortDescription() {
364         return NbBundle.getBundle("org.netbeans.modules.db.resources.Bundle").getString("ND_Connection"); //NOI18N
365
}
366
367     public Transferable JavaDoc clipboardCopy() throws IOException JavaDoc {
368         Transferable JavaDoc result;
369         final DbMetaDataTransferProvider dbTansferProvider = (DbMetaDataTransferProvider)Lookup.getDefault().lookup(DbMetaDataTransferProvider.class);
370         if (dbTansferProvider != null) {
371             ExTransferable exTransferable = ExTransferable.create(super.clipboardCopy());
372             ConnectionNodeInfo cni = (ConnectionNodeInfo)getInfo().getParent(DatabaseNode.CONNECTION);
373             final DatabaseConnection dbconn = ConnectionList.getDefault().getConnection(cni.getDatabaseConnection());
374             exTransferable.put(new ExTransferable.Single(dbTansferProvider.getConnectionDataFlavor()) {
375                 protected Object JavaDoc getData() {
376                     return dbTansferProvider.createConnectionData(dbconn.getDatabaseConnection(), dbconn.findJDBCDriver());
377                 }
378             });
379             result = exTransferable;
380         } else {
381             result = super.clipboardCopy();
382         }
383         return result;
384     }
385
386 }
387
Popular Tags