? .swp
Index: apichanges.xml
===================================================================
RCS file: /cvs/db/apichanges.xml,v
retrieving revision 1.4
diff -u -r1.4 apichanges.xml
--- apichanges.xml 12 Oct 2006 15:01:03 -0000 1.4
+++ apichanges.xml 14 Jun 2007 20:53:39 -0000
@@ -84,6 +84,21 @@
+ Addded support for dragging and dropping nodes from the Database Explorer
+
+
+
+
+
+ This change adds a DatabaseMetaDataTransfer
class which
+ contains DataFlavor
s for database objects and nested classes
+ representing those database objects during a drag and drop transfer.
+
+
+
+
+
+
Addded a method to open the NewConnectionDialog with an user and password pre-filled and methods which open the NewConnectionDialog and return the newly added database connection
Index: arch.xml
===================================================================
RCS file: /cvs/db/arch.xml,v
retrieving revision 1.13
diff -u -r1.13 arch.xml
--- arch.xml 12 Oct 2006 15:01:03 -0000 1.13
+++ arch.xml 14 Jun 2007 20:53:39 -0000
@@ -288,6 +288,14 @@
and a New Database Connection item which will display the dialog for adding a new database connection when selected.
+
+
+ A component might need to allow database tables from the Database Explorer to
+ be dragged to a visual editor. An API is provided in DatabaseMetaDataTransfer
+ containing DataFlavor
s for database objects and nested classes
+ encapsulating those database objects during a drag and drop transfer.
+
+
Index: dbapi/arch.xml
===================================================================
RCS file: /cvs/db/dbapi/arch.xml,v
retrieving revision 1.3
diff -u -r1.3 arch.xml
--- dbapi/arch.xml 17 Oct 2006 13:20:00 -0000 1.3
+++ dbapi/arch.xml 14 Jun 2007 20:53:40 -0000
@@ -120,14 +120,6 @@
The code completion is the only client of this module at this moment.
-
-
- The Creator pack needs to drag tables from the Database Explorer to
- a visual editor. An API is provided in DatabaseMetaDataTransfer
- containing a DataFlavor
for database tables and a Table
- class encapsulating details about the dragged table.
-
-
The SQL editor and the J2EE verifier need to determine whether an identifier
@@ -717,14 +709,6 @@
and looked up by the Database Explorer is registered in META-INF/services
.
-
-
- An implementation of the DbMetaDataTransferProvider
interface defined
- and looked up by by the Database Explorer is registered in Services
- folder in the layer.
-
-
@@ -954,10 +938,6 @@
The module provides its own layer containing the Databases/MetaDataListeners
folder in which the clients register their implementations of
MetaDataListener
.
-
-
- The module also registers an implementation of the DbMetaDataTransferProvider
- interface in the Database Explorer in the Services
folder of its layer.
Index: dbapi/nbproject/project.xml
===================================================================
RCS file: /cvs/db/dbapi/nbproject/project.xml,v
retrieving revision 1.5
diff -u -r1.5 project.xml
--- dbapi/nbproject/project.xml 2 Feb 2007 13:48:59 -0000 1.5
+++ dbapi/nbproject/project.xml 14 Jun 2007 20:53:40 -0000
@@ -66,11 +66,8 @@
- org.netbeans.modules.visualweb.dataconnectivity
- org.netbeans.modules.db.sql.visualeditor
org.netbeans.modules.db.sql.editor
org.netbeans.modules.j2ee.jpa.verification
- org.netbeans.modules.form.j2ee
org.netbeans.modules.j2ee.persistence
org.netbeans.modules.db.api.explorer
org.netbeans.modules.db.api.sql
Index: dbapi/src/org/netbeans/modules/db/api/explorer/DatabaseMetaDataTransfer.java
===================================================================
RCS file: dbapi/src/org/netbeans/modules/db/api/explorer/DatabaseMetaDataTransfer.java
diff -N dbapi/src/org/netbeans/modules/db/api/explorer/DatabaseMetaDataTransfer.java
--- dbapi/src/org/netbeans/modules/db/api/explorer/DatabaseMetaDataTransfer.java 2 Feb 2007 13:49:00 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,290 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License (the License). You may not use this file except in
- * compliance with the License.
- *
- * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
- * or http://www.netbeans.org/cddl.txt.
- *
- * When distributing Covered Code, include this CDDL Header Notice in each file
- * and include the License file at http://www.netbeans.org/cddl.txt.
- * If applicable, add the following below the CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- */
-
-package org.netbeans.modules.db.api.explorer;
-
-import java.awt.datatransfer.DataFlavor;
-import org.netbeans.api.db.explorer.DatabaseConnection;
-import org.netbeans.api.db.explorer.JDBCDriver;
-import org.netbeans.modules.db.explorer.DbMetaDataTransferProvider;
-
-/**
- * This class contains data flavors and classes for transferring database metadata
- * from the Database Explorer. The current version only supports transferring
- * database tables. Support for other database objects, such as columns or views
- * might be added in the future.
- *
- * @author Andrei Badea, Jan Stola
- *
- * @since 1.1
- */
-public final class DatabaseMetaDataTransfer {
-
- /**
- * The {@link DataFlavor} representing a database connection.
- */
- public static DataFlavor CONNECTION_FLAVOR;
-
- /**
- * The {@link DataFlavor} representing a database table.
- */
- public static DataFlavor TABLE_FLAVOR;
-
- /**
- * The {@link DataFlavor} representing a database view.
- */
- public static DataFlavor VIEW_FLAVOR;
-
- /**
- * The {@link DataFlavor} representing a database column.
- */
- public static DataFlavor COLUMN_FLAVOR;
-
- /**
- * The implementation of DbMetaDataTransferProvider, returned by
- * {@link #getProvider}.
- */
- private static DbMetaDataTransferProvider PROVIDER;
-
- static {
- try {
- CONNECTION_FLAVOR = new DataFlavor("application/x-java-netbeans-dbexplorer-connection;class=org.netbeans.modules.db.api.explorer.DatabaseMetaDataTransfer$Connection"); // NOI18N
- TABLE_FLAVOR = new DataFlavor("application/x-java-netbeans-dbexplorer-table;class=org.netbeans.modules.db.api.explorer.DatabaseMetaDataTransfer$Table"); // NOI18N
- VIEW_FLAVOR = new DataFlavor("application/x-java-netbeans-dbexplorer-view;class=org.netbeans.modules.db.api.explorer.DatabaseMetaDataTransfer$View"); // NOI18N
- COLUMN_FLAVOR = new DataFlavor("application/x-java-netbeans-dbexplorer-column;class=org.netbeans.modules.db.api.explorer.DatabaseMetaDataTransfer$Column"); // NOI18N
- } catch (ClassNotFoundException e) {
- throw new AssertionError(e);
- }
- }
-
- /**
- * This method is referenced from the layer to register the provider
- * implementation.
- */
- private static synchronized DbMetaDataTransferProvider getProvider() {
- if (PROVIDER == null) {
- PROVIDER = new DbMetaDataTransferProviderImpl();
- }
- return PROVIDER;
- }
-
- /**
- * Represents a database connection during a drag and drop transfer.
- */
- public static final class Connection {
-
- private final DatabaseConnection dbconn;
- private final JDBCDriver jdbcDriver;
-
- private Connection(DatabaseConnection dbconn, JDBCDriver jdbcDriver) {
- this.dbconn = dbconn;
- this.jdbcDriver = jdbcDriver;
- }
-
- /**
- * Returns the {@link DatabaseConnection}.
- */
- public DatabaseConnection getDatabaseConnection() {
- return dbconn;
- }
-
- /**
- * Returns the {@link JDBCDriver} which was used to connect to {@link #getDatabaseConnection}.
- */
- public JDBCDriver getJDBCDriver() {
- return jdbcDriver;
- }
-
- public String toString() {
- return "Connection[databaseConnection=" + dbconn + ",jdbcDriver=" + jdbcDriver + "]"; // NOI18N
- }
- }
-
- /**
- * Represents a table during a drag and drop transfer.
- */
- public static final class Table {
-
- private final DatabaseConnection dbconn;
- private final JDBCDriver jdbcDriver;
- private final String tableName;
-
- private Table(DatabaseConnection dbconn, JDBCDriver jdbcDriver, String tableName) {
- this.dbconn = dbconn;
- this.jdbcDriver = jdbcDriver;
- this.tableName = tableName;
- }
-
- /**
- * Returns the {@link DatabaseConnection} this table comes from.
- */
- public DatabaseConnection getDatabaseConnection() {
- return dbconn;
- }
-
- /**
- * Returns the {@link JDBCDriver} which was used to connect to {@link #getDatabaseConnection}.
- */
- public JDBCDriver getJDBCDriver() {
- return jdbcDriver;
- }
-
- /**
- * Returns the name of this table.
- */
- public String getTableName() {
- return tableName;
- }
-
- public String toString() {
- return "Table[databaseConnection=" + dbconn + ",jdbcDriver=" + jdbcDriver + ",tableName=" + tableName + "]"; // NOI18N
- }
- }
-
- /**
- * Represents a view during a drag and drop transfer.
- */
- public static final class View {
-
- private final DatabaseConnection dbconn;
- private final JDBCDriver jdbcDriver;
- private final String viewName;
-
- private View(DatabaseConnection dbconn, JDBCDriver jdbcDriver, String viewName) {
- this.dbconn = dbconn;
- this.jdbcDriver = jdbcDriver;
- this.viewName = viewName;
- }
-
- /**
- * Returns the {@link DatabaseConnection} this view comes from.
- */
- public DatabaseConnection getDatabaseConnection() {
- return dbconn;
- }
-
- /**
- * Returns the {@link JDBCDriver} which was used to connect to {@link #getDatabaseConnection}.
- */
- public JDBCDriver getJDBCDriver() {
- return jdbcDriver;
- }
-
- /**
- * Returns the name of this view.
- */
- public String getViewName() {
- return viewName;
- }
-
- public String toString() {
- return "View[databaseConnection=" + dbconn + ",jdbcDriver=" + jdbcDriver + ",viewName=" + viewName + "]"; // NOI18N
- }
- }
-
- /**
- * Represents a column during a drag and drop transfer.
- */
- public static final class Column {
-
- private final DatabaseConnection dbconn;
- private final JDBCDriver jdbcDriver;
- private final String tableName;
- private final String columnName;
-
- private Column(DatabaseConnection dbconn, JDBCDriver jdbcDriver, String tableName, String columnName) {
- this.dbconn = dbconn;
- this.jdbcDriver = jdbcDriver;
- this.tableName = tableName;
- this.columnName = columnName;
- }
-
- /**
- * Returns the {@link DatabaseConnection} this column comes from.
- */
- public DatabaseConnection getDatabaseConnection() {
- return dbconn;
- }
-
- /**
- * Returns the {@link JDBCDriver} which was used to connect to {@link #getDatabaseConnection}.
- */
- public JDBCDriver getJDBCDriver() {
- return jdbcDriver;
- }
-
- /**
- * Returns the name of the table that contains this column.
- */
- public String getTableName() {
- return tableName;
- }
-
- /**
- * Returns the name of this column.
- */
- public String getColumnName() {
- return columnName;
- }
-
- public String toString() {
- return "Column[databaseConnection=" + dbconn + ",jdbcDriver=" + jdbcDriver + ",tableName=" + tableName + ",columnName=" + columnName + "]"; // NOI18N
- }
- }
-
- /**
- * The implementation of DbMetaDataTransferProvider, registered in the
- * default lookup and used by the Database Explorer.
- */
- private static final class DbMetaDataTransferProviderImpl implements DbMetaDataTransferProvider {
-
- public DataFlavor getConnectionDataFlavor() {
- return CONNECTION_FLAVOR;
- }
-
- public DataFlavor getTableDataFlavor() {
- return TABLE_FLAVOR;
- }
-
- public DataFlavor getViewDataFlavor() {
- return VIEW_FLAVOR;
- }
-
-
- public DataFlavor getColumnDataFlavor() {
- return COLUMN_FLAVOR;
- }
-
- public Object createConnectionData(DatabaseConnection dbconn, JDBCDriver jdbcDriver) {
- return new Connection(dbconn, jdbcDriver);
- }
-
- public Object createTableData(DatabaseConnection dbconn, JDBCDriver jdbcDriver, String tableName) {
- return new Table(dbconn, jdbcDriver, tableName);
- }
-
- public Object createViewData(DatabaseConnection dbconn, JDBCDriver jdbcDriver, String viewName) {
- return new View(dbconn, jdbcDriver, viewName);
- }
-
- public Object createColumnData(DatabaseConnection dbconn, JDBCDriver jdbcDriver, String tableName, String columnName) {
- return new Column(dbconn, jdbcDriver, tableName, columnName);
- }
- }
-}
Index: dbapi/src/org/netbeans/modules/dbapi/resources/layer.xml
===================================================================
RCS file: /cvs/db/dbapi/src/org/netbeans/modules/dbapi/resources/layer.xml,v
retrieving revision 1.2
diff -u -r1.2 layer.xml
--- dbapi/src/org/netbeans/modules/dbapi/resources/layer.xml 12 Oct 2006 15:01:16 -0000 1.2
+++ dbapi/src/org/netbeans/modules/dbapi/resources/layer.xml 14 Jun 2007 20:53:40 -0000
@@ -22,12 +22,5 @@
-
-
-
-
-
-
-
Index: dbapi/test/unit/src/org/netbeans/modules/db/api/explorer/DbMetaDataTransferProviderImplTest.java
===================================================================
RCS file: dbapi/test/unit/src/org/netbeans/modules/db/api/explorer/DbMetaDataTransferProviderImplTest.java
diff -N dbapi/test/unit/src/org/netbeans/modules/db/api/explorer/DbMetaDataTransferProviderImplTest.java
--- dbapi/test/unit/src/org/netbeans/modules/db/api/explorer/DbMetaDataTransferProviderImplTest.java 12 Oct 2006 15:01:16 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,65 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License (the License). You may not use this file except in
- * compliance with the License.
- *
- * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
- * or http://www.netbeans.org/cddl.txt.
- *
- * When distributing Covered Code, include this CDDL Header Notice in each file
- * and include the License file at http://www.netbeans.org/cddl.txt.
- * If applicable, add the following below the CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- */
-
-package org.netbeans.modules.db.api.explorer;
-
-import java.net.URL;
-import org.netbeans.api.db.explorer.DatabaseConnection;
-import org.netbeans.api.db.explorer.JDBCDriver;
-import org.netbeans.junit.NbTestCase;
-import org.netbeans.modules.db.explorer.DbMetaDataTransferProvider;
-import org.openide.filesystems.XMLFileSystem;
-import org.openide.loaders.DataFolder;
-import org.openide.loaders.DataObject;
-import org.openide.loaders.FolderLookup;
-import org.openide.util.Lookup;
-
-/**
- *
- * @author Andrei Badea
- */
-public class DbMetaDataTransferProviderImplTest extends NbTestCase {
-
- public DbMetaDataTransferProviderImplTest(String testName) {
- super(testName);
- }
-
- /**
- * Tests the layer contains is an instance of DbMetaDataTransferProvider in
- * the Services folder and that it works correctly.
- */
- public void testBasic() throws Exception {
- JDBCDriver driver = JDBCDriver.create("foo", "Foo", "org.example.Foo", new URL[0]);
- DatabaseConnection dbconn = DatabaseConnection.create(driver, "url", "user", "schema", "pwd", false);
-
- XMLFileSystem layerFs = new XMLFileSystem(DbMetaDataTransferProviderImplTest.class.getClassLoader().getResource("org/netbeans/modules/dbapi/resources/layer.xml"));
- DataFolder services = DataFolder.findFolder(layerFs.getRoot().getFileObject("Services"));
- FolderLookup lookup = new FolderLookup(services);
-
- DbMetaDataTransferProvider dbTransferProvider = (DbMetaDataTransferProvider)lookup.getLookup().lookup(DbMetaDataTransferProvider.class);
- assertNotNull(dbTransferProvider);
-
- assertSame(DatabaseMetaDataTransfer.TABLE_FLAVOR, dbTransferProvider.getTableDataFlavor());
-
- DatabaseMetaDataTransfer.Table table = (DatabaseMetaDataTransfer.Table)dbTransferProvider.createTableData(dbconn, driver, "SOME_TABLE");
- assertSame(dbconn, table.getDatabaseConnection());
- assertSame(driver, table.getJDBCDriver());
- assertSame("SOME_TABLE", table.getTableName());
- }
-}
Index: nbproject/project.properties
===================================================================
RCS file: /cvs/db/nbproject/project.properties,v
retrieving revision 1.22
diff -u -r1.22 project.properties
--- nbproject/project.properties 17 May 2007 18:30:45 -0000 1.22
+++ nbproject/project.properties 14 Jun 2007 20:53:40 -0000
@@ -18,7 +18,7 @@
javadoc.arch=${basedir}/arch.xml
javadoc.apichanges=${basedir}/apichanges.xml
-spec.version.base=1.20.0
+spec.version.base=1.21.0
extra.module.files=modules/ext/ddl.jar
Index: src/org/netbeans/api/db/explorer/DatabaseMetaDataTransfer.java
===================================================================
RCS file: src/org/netbeans/api/db/explorer/DatabaseMetaDataTransfer.java
diff -N src/org/netbeans/api/db/explorer/DatabaseMetaDataTransfer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/netbeans/api/db/explorer/DatabaseMetaDataTransfer.java 14 Jun 2007 20:53:40 -0000
@@ -0,0 +1,248 @@
+/*
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
+ * or http://www.netbeans.org/cddl.txt.
+ *
+ * When distributing Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at http://www.netbeans.org/cddl.txt.
+ * If applicable, add the following below the CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ */
+
+package org.netbeans.api.db.explorer;
+
+import java.awt.datatransfer.DataFlavor;
+import org.netbeans.api.db.explorer.DatabaseConnection;
+import org.netbeans.api.db.explorer.JDBCDriver;
+import org.netbeans.modules.db.explorer.DatabaseMetaDataTransferAccessor;
+import org.netbeans.modules.db.explorer.DatabaseMetaDataTransferAccessor;
+
+/**
+ * This class contains data flavors and classes for transferring database metadata
+ * from the Database Explorer.
+ *
+ * @author Andrei Badea, Jan Stola
+ *
+ * @since 1.21
+ */
+public final class DatabaseMetaDataTransfer {
+
+ /**
+ * The {@link DataFlavor} representing a database connection.
+ */
+ public static DataFlavor CONNECTION_FLAVOR;
+
+ /**
+ * The {@link DataFlavor} representing a database table.
+ */
+ public static DataFlavor TABLE_FLAVOR;
+
+ /**
+ * The {@link DataFlavor} representing a database view.
+ */
+ public static DataFlavor VIEW_FLAVOR;
+
+ /**
+ * The {@link DataFlavor} representing a database column.
+ */
+ public static DataFlavor COLUMN_FLAVOR;
+
+ static {
+ DatabaseMetaDataTransferAccessor.DEFAULT = new DatabaseMetaDataTransferAccessor() {
+ public Connection createConnectionData(DatabaseConnection dbconn, JDBCDriver jdbcDriver) {
+ return new Connection(dbconn, jdbcDriver);
+ }
+ public Table createTableData(DatabaseConnection dbconn, JDBCDriver jdbcDriver, String tableName) {
+ return new Table(dbconn, jdbcDriver, tableName);
+ }
+ public View createViewData(DatabaseConnection dbconn, JDBCDriver jdbcDriver, String viewName) {
+ return new View(dbconn, jdbcDriver, viewName);
+ }
+ public Column createColumnData(DatabaseConnection dbconn, JDBCDriver jdbcDriver, String tableName, String columnName) {
+ return new Column(dbconn, jdbcDriver, tableName, columnName);
+ }
+ };
+ try {
+ CONNECTION_FLAVOR = new DataFlavor("application/x-java-netbeans-dbexplorer-connection;class=org.netbeans.api.db.explorer.DatabaseMetaDataTransfer$Connection"); // NOI18N
+ TABLE_FLAVOR = new DataFlavor("application/x-java-netbeans-dbexplorer-table;class=org.netbeans.api.db.explorer.DatabaseMetaDataTransfer$Table"); // NOI18N
+ VIEW_FLAVOR = new DataFlavor("application/x-java-netbeans-dbexplorer-view;class=org.netbeans.api.db.explorer.DatabaseMetaDataTransfer$View"); // NOI18N
+ COLUMN_FLAVOR = new DataFlavor("application/x-java-netbeans-dbexplorer-column;class=org.netbeans.api.db.explorer.DatabaseMetaDataTransfer$Column"); // NOI18N
+ } catch (ClassNotFoundException e) {
+ throw new AssertionError(e);
+ }
+ }
+
+ private DatabaseMetaDataTransfer() {}
+
+ /**
+ * Represents a database connection during a drag and drop transfer.
+ */
+ public static final class Connection {
+
+ private final DatabaseConnection dbconn;
+ private final JDBCDriver jdbcDriver;
+
+ private Connection(DatabaseConnection dbconn, JDBCDriver jdbcDriver) {
+ this.dbconn = dbconn;
+ this.jdbcDriver = jdbcDriver;
+ }
+
+ /**
+ * Returns the {@link DatabaseConnection}.
+ */
+ public DatabaseConnection getDatabaseConnection() {
+ return dbconn;
+ }
+
+ /**
+ * Returns the {@link JDBCDriver} which was used to connect to {@link #getDatabaseConnection}.
+ */
+ public JDBCDriver getJDBCDriver() {
+ return jdbcDriver;
+ }
+
+ public String toString() {
+ return "Connection[databaseConnection=" + dbconn + ",jdbcDriver=" + jdbcDriver + "]"; // NOI18N
+ }
+ }
+
+ /**
+ * Represents a table during a drag and drop transfer.
+ */
+ public static final class Table {
+
+ private final DatabaseConnection dbconn;
+ private final JDBCDriver jdbcDriver;
+ private final String tableName;
+
+ private Table(DatabaseConnection dbconn, JDBCDriver jdbcDriver, String tableName) {
+ this.dbconn = dbconn;
+ this.jdbcDriver = jdbcDriver;
+ this.tableName = tableName;
+ }
+
+ /**
+ * Returns the {@link DatabaseConnection} this table comes from.
+ */
+ public DatabaseConnection getDatabaseConnection() {
+ return dbconn;
+ }
+
+ /**
+ * Returns the {@link JDBCDriver} which was used to connect to {@link #getDatabaseConnection}.
+ */
+ public JDBCDriver getJDBCDriver() {
+ return jdbcDriver;
+ }
+
+ /**
+ * Returns the name of this table.
+ */
+ public String getTableName() {
+ return tableName;
+ }
+
+ public String toString() {
+ return "Table[databaseConnection=" + dbconn + ",jdbcDriver=" + jdbcDriver + ",tableName=" + tableName + "]"; // NOI18N
+ }
+ }
+
+ /**
+ * Represents a view during a drag and drop transfer.
+ */
+ public static final class View {
+
+ private final DatabaseConnection dbconn;
+ private final JDBCDriver jdbcDriver;
+ private final String viewName;
+
+ private View(DatabaseConnection dbconn, JDBCDriver jdbcDriver, String viewName) {
+ this.dbconn = dbconn;
+ this.jdbcDriver = jdbcDriver;
+ this.viewName = viewName;
+ }
+
+ /**
+ * Returns the {@link DatabaseConnection} this view comes from.
+ */
+ public DatabaseConnection getDatabaseConnection() {
+ return dbconn;
+ }
+
+ /**
+ * Returns the {@link JDBCDriver} which was used to connect to {@link #getDatabaseConnection}.
+ */
+ public JDBCDriver getJDBCDriver() {
+ return jdbcDriver;
+ }
+
+ /**
+ * Returns the name of this view.
+ */
+ public String getViewName() {
+ return viewName;
+ }
+
+ public String toString() {
+ return "View[databaseConnection=" + dbconn + ",jdbcDriver=" + jdbcDriver + ",viewName=" + viewName + "]"; // NOI18N
+ }
+ }
+
+ /**
+ * Represents a column during a drag and drop transfer.
+ */
+ public static final class Column {
+
+ private final DatabaseConnection dbconn;
+ private final JDBCDriver jdbcDriver;
+ private final String tableName;
+ private final String columnName;
+
+ private Column(DatabaseConnection dbconn, JDBCDriver jdbcDriver, String tableName, String columnName) {
+ this.dbconn = dbconn;
+ this.jdbcDriver = jdbcDriver;
+ this.tableName = tableName;
+ this.columnName = columnName;
+ }
+
+ /**
+ * Returns the {@link DatabaseConnection} this column comes from.
+ */
+ public DatabaseConnection getDatabaseConnection() {
+ return dbconn;
+ }
+
+ /**
+ * Returns the {@link JDBCDriver} which was used to connect to {@link #getDatabaseConnection}.
+ */
+ public JDBCDriver getJDBCDriver() {
+ return jdbcDriver;
+ }
+
+ /**
+ * Returns the name of the table that contains this column.
+ */
+ public String getTableName() {
+ return tableName;
+ }
+
+ /**
+ * Returns the name of this column.
+ */
+ public String getColumnName() {
+ return columnName;
+ }
+
+ public String toString() {
+ return "Column[databaseConnection=" + dbconn + ",jdbcDriver=" + jdbcDriver + ",tableName=" + tableName + ",columnName=" + columnName + "]"; // NOI18N
+ }
+ }
+}
Index: src/org/netbeans/modules/db/explorer/DatabaseMetaDataTransferAccessor.java
===================================================================
RCS file: src/org/netbeans/modules/db/explorer/DatabaseMetaDataTransferAccessor.java
diff -N src/org/netbeans/modules/db/explorer/DatabaseMetaDataTransferAccessor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/netbeans/modules/db/explorer/DatabaseMetaDataTransferAccessor.java 14 Jun 2007 20:53:40 -0000
@@ -0,0 +1,65 @@
+/*
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
+ * or http://www.netbeans.org/cddl.txt.
+ *
+ * When distributing Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at http://www.netbeans.org/cddl.txt.
+ * If applicable, add the following below the CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ */
+
+package org.netbeans.modules.db.explorer;
+
+import org.netbeans.api.db.explorer.DatabaseConnection;
+import org.netbeans.api.db.explorer.DatabaseMetaDataTransfer.Column;
+import org.netbeans.api.db.explorer.DatabaseMetaDataTransfer.Connection;
+import org.netbeans.api.db.explorer.DatabaseMetaDataTransfer.Table;
+import org.netbeans.api.db.explorer.DatabaseMetaDataTransfer.View;
+import org.netbeans.api.db.explorer.JDBCDriver;
+
+/**
+ *
+ * @author Andrei Badea
+ */
+public abstract class DatabaseMetaDataTransferAccessor {
+
+ public static DatabaseMetaDataTransferAccessor DEFAULT;
+
+ static {
+ Class c = DatabaseMetaDataTransferAccessor.class;
+ try {
+ Class.forName(c.getName(), true, c.getClassLoader());
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * Returns an object which encapsulates a database connection.
+ */
+ public abstract Connection createConnectionData(DatabaseConnection dbconn, JDBCDriver jdbcDriver);
+
+ /**
+ * Returns an object which encapsulates a database table.
+ */
+ public abstract Table createTableData(DatabaseConnection dbconn, JDBCDriver jdbcDriver, String tableName);
+
+ /**
+ * Returns an object which encapsulates a database view.
+ */
+ public abstract View createViewData(DatabaseConnection dbconn, JDBCDriver jdbcDriver, String viewName);
+
+ /**
+ * Returns an object which encapsulates a column of a database table.
+ */
+ public abstract Column createColumnData(DatabaseConnection dbconn, JDBCDriver jdbcDriver, String tableName, String columnName);
+}
Index: src/org/netbeans/modules/db/explorer/nodes/ColumnNode.java
===================================================================
RCS file: /cvs/db/src/org/netbeans/modules/db/explorer/nodes/ColumnNode.java,v
retrieving revision 1.22
diff -u -r1.22 ColumnNode.java
--- src/org/netbeans/modules/db/explorer/nodes/ColumnNode.java 2 Feb 2007 13:49:00 -0000 1.22
+++ src/org/netbeans/modules/db/explorer/nodes/ColumnNode.java 14 Jun 2007 20:53:40 -0000
@@ -22,8 +22,8 @@
import java.awt.datatransfer.Transferable;
import java.io.IOException;
import java.util.Map;
+import org.netbeans.api.db.explorer.DatabaseMetaDataTransfer;
import org.openide.nodes.PropertySupport;
-import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.util.datatransfer.ExTransferable;
@@ -33,7 +33,7 @@
import org.netbeans.modules.db.explorer.ConnectionList;
import org.netbeans.modules.db.explorer.DatabaseConnection;
import org.netbeans.modules.db.explorer.DatabaseTypePropertySupport;
-import org.netbeans.modules.db.explorer.DbMetaDataTransferProvider;
+import org.netbeans.modules.db.explorer.DatabaseMetaDataTransferAccessor;
import org.netbeans.modules.db.explorer.infos.ConnectionNodeInfo;
import org.netbeans.modules.db.explorer.infos.DatabaseNodeInfo;
import org.netbeans.modules.db.explorer.infos.ViewColumnNodeInfo;
@@ -66,21 +66,14 @@
}
public Transferable clipboardCopy() throws IOException {
- Transferable result;
- final DbMetaDataTransferProvider dbTansferProvider = (DbMetaDataTransferProvider)Lookup.getDefault().lookup(DbMetaDataTransferProvider.class);
- if (dbTansferProvider != null) {
- ExTransferable exTransferable = ExTransferable.create(super.clipboardCopy());
- ConnectionNodeInfo cni = (ConnectionNodeInfo)getInfo().getParent(DatabaseNode.CONNECTION);
- final DatabaseConnection dbconn = ConnectionList.getDefault().getConnection(cni.getDatabaseConnection());
- exTransferable.put(new ExTransferable.Single(dbTansferProvider.getColumnDataFlavor()) {
- protected Object getData() {
- return dbTansferProvider.createColumnData(dbconn.getDatabaseConnection(), dbconn.findJDBCDriver(), getInfo().getTable(), getInfo().getName());
- }
- });
- result = exTransferable;
- } else {
- result = super.clipboardCopy();
- }
+ ExTransferable result = ExTransferable.create(super.clipboardCopy());
+ ConnectionNodeInfo cni = (ConnectionNodeInfo)getInfo().getParent(DatabaseNode.CONNECTION);
+ final DatabaseConnection dbconn = ConnectionList.getDefault().getConnection(cni.getDatabaseConnection());
+ result.put(new ExTransferable.Single(DatabaseMetaDataTransfer.COLUMN_FLAVOR) {
+ protected Object getData() {
+ return DatabaseMetaDataTransferAccessor.DEFAULT.createColumnData(dbconn.getDatabaseConnection(), dbconn.findJDBCDriver(), getInfo().getTable(), getInfo().getName());
+ }
+ });
return result;
}
Index: src/org/netbeans/modules/db/explorer/nodes/ConnectionNode.java
===================================================================
RCS file: /cvs/db/src/org/netbeans/modules/db/explorer/nodes/ConnectionNode.java,v
retrieving revision 1.40
diff -u -r1.40 ConnectionNode.java
--- src/org/netbeans/modules/db/explorer/nodes/ConnectionNode.java 2 Feb 2007 13:49:01 -0000 1.40
+++ src/org/netbeans/modules/db/explorer/nodes/ConnectionNode.java 14 Jun 2007 20:53:40 -0000
@@ -25,11 +25,11 @@
import java.io.IOException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
+import org.netbeans.api.db.explorer.DatabaseMetaDataTransfer;
import org.netbeans.modules.db.explorer.ConnectionList;
import org.netbeans.modules.db.explorer.DatabaseConnection;
-import org.netbeans.modules.db.explorer.DbMetaDataTransferProvider;
+import org.netbeans.modules.db.explorer.DatabaseMetaDataTransferAccessor;
import org.netbeans.modules.db.explorer.infos.ConnectionNodeInfo;
-import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.nodes.Node;
@@ -365,21 +365,14 @@
}
public Transferable clipboardCopy() throws IOException {
- Transferable result;
- final DbMetaDataTransferProvider dbTansferProvider = (DbMetaDataTransferProvider)Lookup.getDefault().lookup(DbMetaDataTransferProvider.class);
- if (dbTansferProvider != null) {
- ExTransferable exTransferable = ExTransferable.create(super.clipboardCopy());
- ConnectionNodeInfo cni = (ConnectionNodeInfo)getInfo().getParent(DatabaseNode.CONNECTION);
- final DatabaseConnection dbconn = ConnectionList.getDefault().getConnection(cni.getDatabaseConnection());
- exTransferable.put(new ExTransferable.Single(dbTansferProvider.getConnectionDataFlavor()) {
- protected Object getData() {
- return dbTansferProvider.createConnectionData(dbconn.getDatabaseConnection(), dbconn.findJDBCDriver());
- }
- });
- result = exTransferable;
- } else {
- result = super.clipboardCopy();
- }
+ ExTransferable result = ExTransferable.create(super.clipboardCopy());
+ ConnectionNodeInfo cni = (ConnectionNodeInfo)getInfo().getParent(DatabaseNode.CONNECTION);
+ final DatabaseConnection dbconn = ConnectionList.getDefault().getConnection(cni.getDatabaseConnection());
+ result.put(new ExTransferable.Single(DatabaseMetaDataTransfer.CONNECTION_FLAVOR) {
+ protected Object getData() {
+ return DatabaseMetaDataTransferAccessor.DEFAULT.createConnectionData(dbconn.getDatabaseConnection(), dbconn.findJDBCDriver());
+ }
+ });
return result;
}
Index: src/org/netbeans/modules/db/explorer/nodes/TableNode.java
===================================================================
RCS file: /cvs/db/src/org/netbeans/modules/db/explorer/nodes/TableNode.java,v
retrieving revision 1.28
diff -u -r1.28 TableNode.java
--- src/org/netbeans/modules/db/explorer/nodes/TableNode.java 12 Oct 2006 15:01:41 -0000 1.28
+++ src/org/netbeans/modules/db/explorer/nodes/TableNode.java 14 Jun 2007 20:53:40 -0000
@@ -23,6 +23,8 @@
import java.io.IOException;
import java.util.*;
import java.text.MessageFormat;
+import org.netbeans.api.db.explorer.DatabaseMetaDataTransfer;
+import org.netbeans.modules.db.explorer.DatabaseMetaDataTransferAccessor;
import org.openide.*;
@@ -35,7 +37,6 @@
import org.netbeans.lib.ddl.impl.*;
import org.netbeans.modules.db.explorer.*;
import org.netbeans.modules.db.explorer.infos.*;
-import org.openide.util.Lookup;
import org.openide.util.datatransfer.ExTransferable;
// Node for Table/View/Procedure things.
@@ -105,21 +106,14 @@
}
public Transferable clipboardCopy() throws IOException {
- Transferable result;
- final DbMetaDataTransferProvider dbTansferProvider = (DbMetaDataTransferProvider)Lookup.getDefault().lookup(DbMetaDataTransferProvider.class);
- if (dbTansferProvider != null) {
- ExTransferable exTransferable = ExTransferable.create(super.clipboardCopy());
- ConnectionNodeInfo cni = (ConnectionNodeInfo)getInfo().getParent(DatabaseNode.CONNECTION);
- final DatabaseConnection dbconn = ConnectionList.getDefault().getConnection(cni.getDatabaseConnection());
- exTransferable.put(new ExTransferable.Single(dbTansferProvider.getTableDataFlavor()) {
- protected Object getData() {
- return dbTansferProvider.createTableData(dbconn.getDatabaseConnection(), dbconn.findJDBCDriver(), getInfo().getName());
- }
- });
- result = exTransferable;
- } else {
- result = super.clipboardCopy();
- }
+ ExTransferable result = ExTransferable.create(super.clipboardCopy());
+ ConnectionNodeInfo cni = (ConnectionNodeInfo)getInfo().getParent(DatabaseNode.CONNECTION);
+ final DatabaseConnection dbconn = ConnectionList.getDefault().getConnection(cni.getDatabaseConnection());
+ result.put(new ExTransferable.Single(DatabaseMetaDataTransfer.TABLE_FLAVOR) {
+ protected Object getData() {
+ return DatabaseMetaDataTransferAccessor.DEFAULT.createTableData(dbconn.getDatabaseConnection(), dbconn.findJDBCDriver(), getInfo().getName());
+ }
+ });
return result;
}
Index: src/org/netbeans/modules/db/explorer/nodes/ViewNode.java
===================================================================
RCS file: /cvs/db/src/org/netbeans/modules/db/explorer/nodes/ViewNode.java,v
retrieving revision 1.21
diff -u -r1.21 ViewNode.java
--- src/org/netbeans/modules/db/explorer/nodes/ViewNode.java 12 Jun 2007 11:21:28 -0000 1.21
+++ src/org/netbeans/modules/db/explorer/nodes/ViewNode.java 14 Jun 2007 20:53:40 -0000
@@ -24,6 +24,8 @@
import java.util.*;
import java.text.MessageFormat;
+import org.netbeans.api.db.explorer.DatabaseMetaDataTransfer;
+import org.netbeans.modules.db.explorer.DatabaseMetaDataTransferAccessor;
import org.openide.*;
import org.openide.util.NbBundle;
@@ -33,7 +35,6 @@
import org.netbeans.modules.db.*;
import org.netbeans.modules.db.explorer.*;
import org.netbeans.modules.db.explorer.infos.*;
-import org.openide.util.Lookup;
import org.openide.util.datatransfer.ExTransferable;
@@ -64,21 +65,14 @@
}
public Transferable clipboardCopy() throws IOException {
- Transferable result;
- final DbMetaDataTransferProvider dbTansferProvider = (DbMetaDataTransferProvider)Lookup.getDefault().lookup(DbMetaDataTransferProvider.class);
- if (dbTansferProvider != null) {
- ExTransferable exTransferable = ExTransferable.create(super.clipboardCopy());
- ConnectionNodeInfo cni = (ConnectionNodeInfo)getInfo().getParent(DatabaseNode.CONNECTION);
- final DatabaseConnection dbconn = ConnectionList.getDefault().getConnection(cni.getDatabaseConnection());
- exTransferable.put(new ExTransferable.Single(dbTansferProvider.getViewDataFlavor()) {
- protected Object getData() {
- return dbTansferProvider.createViewData(dbconn.getDatabaseConnection(), dbconn.findJDBCDriver(), getInfo().getName());
- }
- });
- result = exTransferable;
- } else {
- result = super.clipboardCopy();
- }
+ ExTransferable result = ExTransferable.create(super.clipboardCopy());
+ ConnectionNodeInfo cni = (ConnectionNodeInfo)getInfo().getParent(DatabaseNode.CONNECTION);
+ final DatabaseConnection dbconn = ConnectionList.getDefault().getConnection(cni.getDatabaseConnection());
+ result.put(new ExTransferable.Single(DatabaseMetaDataTransfer.VIEW_FLAVOR) {
+ protected Object getData() {
+ return DatabaseMetaDataTransferAccessor.DEFAULT.createViewData(dbconn.getDatabaseConnection(), dbconn.findJDBCDriver(), getInfo().getName());
+ }
+ });
return result;
}
}
Index: test/unit/src/org/netbeans/modules/db/explorer/nodes/ColumnNodeTest.java
===================================================================
RCS file: /cvs/db/test/unit/src/org/netbeans/modules/db/explorer/nodes/ColumnNodeTest.java,v
retrieving revision 1.1
diff -u -r1.1 ColumnNodeTest.java
--- test/unit/src/org/netbeans/modules/db/explorer/nodes/ColumnNodeTest.java 2 Feb 2007 13:49:02 -0000 1.1
+++ test/unit/src/org/netbeans/modules/db/explorer/nodes/ColumnNodeTest.java 14 Jun 2007 20:53:40 -0000
@@ -29,11 +29,9 @@
import org.netbeans.api.db.explorer.JDBCDriver;
import org.netbeans.api.db.explorer.JDBCDriverManager;
import org.netbeans.modules.db.explorer.ConnectionList;
-import org.netbeans.modules.db.explorer.DbMetaDataTransferProvider;
import org.netbeans.modules.db.explorer.infos.ConnectionNodeInfo;
import org.netbeans.modules.db.explorer.infos.DatabaseNodeInfo;
import org.netbeans.modules.db.test.TestBase;
-import org.openide.util.Lookup;
/**
*
@@ -46,8 +44,6 @@
}
public void testClipboardCopy() throws Exception {
- assertNotNull("ColumnNode.clipboardCopy() needs an impl of DbMetaDataTransferProvider in the default lookup", Lookup.getDefault().lookup(DbMetaDataTransferProvider.class));
-
JDBCDriver driver = JDBCDriver.create("foo", "Foo", "org.example.Foo", new URL[0]);
JDBCDriverManager.getDefault().addDriver(driver);
DatabaseConnection dbconn = DatabaseConnection.create(driver, "url", "user", "schema", "pwd", false);
@@ -68,7 +64,7 @@
for (int i = 0; i < flavors.length; i++) {
mimeTypes.add(flavors[i].getMimeType());
}
- assertTrue(mimeTypes.contains("application/x-java-netbeans-dbexplorer-column; class=org.netbeans.modules.db.api.explorer.DatabaseMetaDataTransfer$Column"));
+ assertTrue(mimeTypes.contains("application/x-java-netbeans-dbexplorer-column; class=org.netbeans.api.db.explorer.DatabaseMetaDataTransfer$Column"));
assertTrue(mimeTypes.contains("application/x-java-openide-nodednd; mask=1; class=org.openide.nodes.Node"));
}
}
Index: test/unit/src/org/netbeans/modules/db/explorer/nodes/ConnectionNodeTest.java
===================================================================
RCS file: /cvs/db/test/unit/src/org/netbeans/modules/db/explorer/nodes/ConnectionNodeTest.java,v
retrieving revision 1.1
diff -u -r1.1 ConnectionNodeTest.java
--- test/unit/src/org/netbeans/modules/db/explorer/nodes/ConnectionNodeTest.java 2 Feb 2007 13:49:02 -0000 1.1
+++ test/unit/src/org/netbeans/modules/db/explorer/nodes/ConnectionNodeTest.java 14 Jun 2007 20:53:40 -0000
@@ -29,11 +29,9 @@
import org.netbeans.api.db.explorer.JDBCDriver;
import org.netbeans.api.db.explorer.JDBCDriverManager;
import org.netbeans.modules.db.explorer.ConnectionList;
-import org.netbeans.modules.db.explorer.DbMetaDataTransferProvider;
import org.netbeans.modules.db.explorer.infos.ConnectionNodeInfo;
import org.netbeans.modules.db.explorer.infos.DatabaseNodeInfo;
import org.netbeans.modules.db.test.TestBase;
-import org.openide.util.Lookup;
/**
*
@@ -46,8 +44,6 @@
}
public void testClipboardCopy() throws Exception {
- assertNotNull("ConnectionNode.clipboardCopy() needs an impl of DbMetaDataTransferProvider in the default lookup", Lookup.getDefault().lookup(DbMetaDataTransferProvider.class));
-
JDBCDriver driver = JDBCDriver.create("foo", "Foo", "org.example.Foo", new URL[0]);
JDBCDriverManager.getDefault().addDriver(driver);
DatabaseConnection dbconn = DatabaseConnection.create(driver, "url", "user", "schema", "pwd", false);
@@ -66,7 +62,7 @@
for (int i = 0; i < flavors.length; i++) {
mimeTypes.add(flavors[i].getMimeType());
}
- assertTrue(mimeTypes.contains("application/x-java-netbeans-dbexplorer-connection; class=org.netbeans.modules.db.api.explorer.DatabaseMetaDataTransfer$Connection"));
+ assertTrue(mimeTypes.contains("application/x-java-netbeans-dbexplorer-connection; class=org.netbeans.api.db.explorer.DatabaseMetaDataTransfer$Connection"));
assertTrue(mimeTypes.contains("application/x-java-openide-nodednd; mask=1; class=org.openide.nodes.Node"));
}
}
Index: test/unit/src/org/netbeans/modules/db/explorer/nodes/TableNodeTest.java
===================================================================
RCS file: /cvs/db/test/unit/src/org/netbeans/modules/db/explorer/nodes/TableNodeTest.java,v
retrieving revision 1.4
diff -u -r1.4 TableNodeTest.java
--- test/unit/src/org/netbeans/modules/db/explorer/nodes/TableNodeTest.java 21 Oct 2006 10:55:11 -0000 1.4
+++ test/unit/src/org/netbeans/modules/db/explorer/nodes/TableNodeTest.java 14 Jun 2007 20:53:40 -0000
@@ -29,11 +29,9 @@
import org.netbeans.api.db.explorer.JDBCDriver;
import org.netbeans.api.db.explorer.JDBCDriverManager;
import org.netbeans.modules.db.explorer.ConnectionList;
-import org.netbeans.modules.db.explorer.DbMetaDataTransferProvider;
import org.netbeans.modules.db.explorer.infos.ConnectionNodeInfo;
import org.netbeans.modules.db.explorer.infos.DatabaseNodeInfo;
import org.netbeans.modules.db.test.TestBase;
-import org.openide.util.Lookup;
/**
*
@@ -46,8 +44,6 @@
}
public void testClipboardCopy() throws Exception {
- assertNotNull("TableNode.clipboardCopy() needs an impl of DbMetaDataTransferProvider in the default lookup", Lookup.getDefault().lookup(DbMetaDataTransferProvider.class));
-
JDBCDriver driver = JDBCDriver.create("foo", "Foo", "org.example.Foo", new URL[0]);
JDBCDriverManager.getDefault().addDriver(driver);
DatabaseConnection dbconn = DatabaseConnection.create(driver, "url", "user", "schema", "pwd", false);
@@ -67,7 +63,7 @@
for (int i = 0; i < flavors.length; i++) {
mimeTypes.add(flavors[i].getMimeType());
}
- assertTrue(mimeTypes.contains("application/x-java-netbeans-dbexplorer-table; class=org.netbeans.modules.db.api.explorer.DatabaseMetaDataTransfer$Table"));
+ assertTrue(mimeTypes.contains("application/x-java-netbeans-dbexplorer-table; class=org.netbeans.api.db.explorer.DatabaseMetaDataTransfer$Table"));
assertTrue(mimeTypes.contains("application/x-java-openide-nodednd; mask=1; class=org.openide.nodes.Node"));
}
}
Index: test/unit/src/org/netbeans/modules/db/explorer/nodes/ViewNodeTest.java
===================================================================
RCS file: test/unit/src/org/netbeans/modules/db/explorer/nodes/ViewNodeTest.java
diff -N test/unit/src/org/netbeans/modules/db/explorer/nodes/ViewNodeTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ test/unit/src/org/netbeans/modules/db/explorer/nodes/ViewNodeTest.java 14 Jun 2007 20:53:40 -0000
@@ -0,0 +1,69 @@
+/*
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
+ * or http://www.netbeans.org/cddl.txt.
+ *
+ * When distributing Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at http://www.netbeans.org/cddl.txt.
+ * If applicable, add the following below the CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ */
+
+package org.netbeans.modules.db.explorer.nodes;
+
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+import org.netbeans.api.db.explorer.ConnectionManager;
+import org.netbeans.api.db.explorer.DatabaseConnection;
+import org.netbeans.api.db.explorer.JDBCDriver;
+import org.netbeans.api.db.explorer.JDBCDriverManager;
+import org.netbeans.modules.db.explorer.ConnectionList;
+import org.netbeans.modules.db.explorer.infos.ConnectionNodeInfo;
+import org.netbeans.modules.db.explorer.infos.DatabaseNodeInfo;
+import org.netbeans.modules.db.test.TestBase;
+
+/**
+ *
+ * @author Andrei Badea
+ */
+public class ViewNodeTest extends TestBase {
+
+ public ViewNodeTest(String testName) {
+ super(testName);
+ }
+
+ public void testClipboardCopy() throws Exception {
+ JDBCDriver driver = JDBCDriver.create("foo", "Foo", "org.example.Foo", new URL[0]);
+ JDBCDriverManager.getDefault().addDriver(driver);
+ DatabaseConnection dbconn = DatabaseConnection.create(driver, "url", "user", "schema", "pwd", false);
+ ConnectionManager.getDefault().addConnection(dbconn);
+
+ ViewNode viewNode = new ViewNode();
+ ConnectionNodeInfo connNodeInfo = (ConnectionNodeInfo)DatabaseNodeInfo.createNodeInfo(null, DatabaseNodeInfo.CONNECTION);
+ connNodeInfo.setDatabaseConnection(ConnectionList.getDefault().getConnections()[0]);
+ DatabaseNodeInfo ViewNodeInfo = DatabaseNodeInfo.createNodeInfo(connNodeInfo, DatabaseNode.VIEW);
+ viewNode.setInfo(ViewNodeInfo);
+
+ assertTrue(viewNode.canCopy());
+
+ Transferable transferable = (Transferable)viewNode.clipboardCopy();
+ Set mimeTypes = new HashSet();
+ DataFlavor[] flavors = transferable.getTransferDataFlavors();
+ for (int i = 0; i < flavors.length; i++) {
+ mimeTypes.add(flavors[i].getMimeType());
+ }
+ assertTrue(mimeTypes.contains("application/x-java-netbeans-dbexplorer-view; class=org.netbeans.api.db.explorer.DatabaseMetaDataTransfer$View"));
+ assertTrue(mimeTypes.contains("application/x-java-openide-nodednd; mask=1; class=org.openide.nodes.Node"));
+ }
+}