This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 77706 - Create an API for dragging table nodes
Summary: Create an API for dragging table nodes
Status: VERIFIED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: Andrei Badea
URL:
Keywords: API, API_REVIEW_FAST
Depends on:
Blocks: 78597
  Show dependency tree
 
Reported: 2006-06-12 09:26 UTC by Andrei Badea
Modified: 2006-07-13 15:37 UTC (History)
4 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Propsed API (changes in the db/dbapi module) (10.74 KB, text/plain)
2006-06-12 10:46 UTC, Andrei Badea
Details
Related changes in the db module (11.54 KB, text/plain)
2006-06-12 10:47 UTC, Andrei Badea
Details
Changes in the db/dbapi module (listing the new friend modules) (11.66 KB, application/octet-stream)
2006-06-13 19:19 UTC, Andrei Badea
Details
Changes in the db/dbapi module (fixed Javadoc and flavor MIME type) (11.68 KB, text/plain)
2006-06-15 10:34 UTC, Andrei Badea
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrei Badea 2006-06-12 09:26:36 UTC
The Creator pack needs to drag tables from the Database Explorer to a visual
editor. The data in the Transferable needs to contain the table name, the
instance of DatabaseConnection the table belongs to and the instance of
JDBCDriver used to make the connection.
Comment 1 Andrei Badea 2006-06-12 10:46:15 UTC
Created attachment 30961 [details]
Propsed API (changes in the db/dbapi module)
Comment 2 Andrei Badea 2006-06-12 10:47:08 UTC
Created attachment 30962 [details]
Related changes in the db module
Comment 3 Andrei Badea 2006-06-12 11:02:52 UTC
I would like to ask for a review of the proposed API. It introduces a
DatabaseMetaDataTransfer class containing a TABLE_FLAVOR field describing the
data flavor for tables and a Table inner class encapsulating the table data.
Dragging or copying table nodes to the clipboard creates a Transferable instance
which contains the table flavor and creates an instance of Table when required.

This API has only one client and only supports dragging table nodes. A proper
API should support dragging all nodes corresponding to database metadata and
should make use of the model for database metadata in issue 61441. Because of
this the API should be friend for now and thus it should be provided by the
db/dbapi module.

Please especially review the table flavor MIME type and suggest a better one if
necessary.
Comment 4 Andrei Badea 2006-06-13 19:19:44 UTC
Created attachment 31013 [details]
Changes in the db/dbapi module (listing the new friend modules)
Comment 5 Andrei Badea 2006-06-13 19:20:45 UTC
This API will be used by two modules from the Creator pack. I attached a diff
which lists these modules in project.xml.
Comment 6 Winston Prakash 2006-06-14 00:01:24 UTC
I had discussion with Andrei and basically agree to the API. One explanation
requested though. Why do we need the SPI
org.netbeans.modules.db.explorer.DbMetaDataTransferProvider. Since I view 
org.netbeans.modules.db.explorer as an implementation of
org.netbeans.modules.db.api, having an interface in the implementation area and
its implementation
(org.netbeans.modules.db.api.explorer.DatabaseMetaDataTransfer.
DbMetaDataTransferProviderImpl in the API area, seems kind of odd to me.
- Winston 
Comment 7 Winston Prakash 2006-06-14 22:29:57 UTC
I tested the API and it seems to work perfectly. So it is a green signal from my
side. - Winston
Comment 8 Jaroslav Tulach 2006-06-15 07:51:53 UTC
"application/x-java-openide-dbexplorer-table" - I do not think you want to 
refer to "openide", if you need some prefix, use "netbeans".

"Support for other database tables might" - probably you wanted to say support 
for other database elements, or something like that.

Comment 9 Andrei Badea 2006-06-15 10:34:40 UTC
Created attachment 31065 [details]
Changes in the db/dbapi module (fixed Javadoc and flavor MIME type)
Comment 10 Andrei Badea 2006-06-15 10:40:22 UTC
wjprakash: o.n.m.db is not an implementation of o.n.m.dbapi. Actually dbapi
depends on db. Because of this db cannot refer to the flavor defined in dbapi.
Instead it defines the DbMetadataTransferProvider interface, implemented by
dbapi, which provides the flavor and the transferred data. You, as the client of
the metadata transfer API, do not see the DbMetadataTransferProvider interface.

jtulach: I fixed the Javadoc and the flavor MIME type, thank you for the catches!
Comment 11 Andrei Badea 2006-06-20 15:22:52 UTC
If there aren't any more comments I will commit this tomorrow. Thank you for the
review.
Comment 12 Andrei Badea 2006-06-21 16:59:08 UTC
Integrated.

Checking in ide/golden/friend-packages.txt;
/cvs/ide/golden/friend-packages.txt,v  <--  friend-packages.txt
new revision: 1.15.4.1.2.92; previous revision: 1.15.4.1.2.91
done
Checking in db/dbapi/arch.xml;
/cvs/db/dbapi/Attic/arch.xml,v  <--  arch.xml
new revision: 1.1.4.2; previous revision: 1.1.4.1
done
Checking in db/dbapi/nbproject/project.properties;
/cvs/db/dbapi/nbproject/Attic/project.properties,v  <--  project.properties
new revision: 1.1.4.3; previous revision: 1.1.4.2
done
Checking in db/dbapi/nbproject/project.xml;
/cvs/db/dbapi/nbproject/Attic/project.xml,v  <--  project.xml
new revision: 1.1.4.3; previous revision: 1.1.4.2
done
Checking in
db/dbapi/src/org/netbeans/modules/db/api/explorer/DatabaseMetaDataTransfer.java;
/cvs/db/dbapi/src/org/netbeans/modules/db/api/explorer/Attic/DatabaseMetaDataTransfer.java,v
 <--  DatabaseMetaDataTransfer.java
new revision: 1.1.4.1; previous revision: 1.1
done
Checking in db/dbapi/src/org/netbeans/modules/dbapi/resources/layer.xml;
/cvs/db/dbapi/src/org/netbeans/modules/dbapi/resources/Attic/layer.xml,v  <-- 
layer.xml
new revision: 1.1.4.3; previous revision: 1.1.4.2
done
Checking in
db/dbapi/test/unit/src/org/netbeans/modules/db/api/explorer/DbMetaDataTransferProviderImplTest.java;
/cvs/db/dbapi/test/unit/src/org/netbeans/modules/db/api/explorer/Attic/DbMetaDataTransferProviderImplTest.java,v
 <--  DbMetaDataTransferProviderImplTest.java
new revision: 1.1.4.1; previous revision: 1.1
done
Checking in db/src/org/netbeans/modules/db/explorer/DatabaseConnection.java;
/cvs/db/src/org/netbeans/modules/db/explorer/DatabaseConnection.java,v  <-- 
DatabaseConnection.java
new revision: 1.39.2.2.2.2; previous revision: 1.39.2.2.2.1
done
Checking in db/src/org/netbeans/modules/db/explorer/DbMetaDataTransferProvider.java;
/cvs/db/src/org/netbeans/modules/db/explorer/Attic/DbMetaDataTransferProvider.java,v
 <--  DbMetaDataTransferProvider.java
new revision: 1.1.4.1; previous revision: 1.1
done
Checking in db/src/org/netbeans/modules/db/explorer/nodes/TableNode.java;
/cvs/db/src/org/netbeans/modules/db/explorer/nodes/TableNode.java,v  <-- 
TableNode.java
new revision: 1.26.26.1; previous revision: 1.26
done
Checking in db/src/org/netbeans/modules/db/resources/explorer.plist;
/cvs/db/src/org/netbeans/modules/db/resources/explorer.plist,v  <--  explorer.plist
new revision: 1.70.56.1.2.2; previous revision: 1.70.56.1.2.1
done
Checking in
db/test/unit/src/org/netbeans/modules/db/explorer/nodes/TableNodeTest.java;
/cvs/db/test/unit/src/org/netbeans/modules/db/explorer/nodes/Attic/TableNodeTest.java,v
 <--  TableNodeTest.java
new revision: 1.1.4.1; previous revision: 1.1
done
Comment 13 Andrei Badea 2006-06-21 19:05:01 UTC
This broke the commit validation:

http://www.netbeans.org/download/release55/buildlogs/continuous/20060621-1603/xtest_results/index.html

The cause of the fail is that a method of DatabaseMetaDataTransfer is registered
in the default lookup, thus this class is loaded by
ValidateLayerConsistencyTest. When the class is loaded the table data flavor is
created, which attempts to load the flavor's representation class
(DatabaseMetaDataTransfer$Table). This is done using the current thread's
context class loader, which in the test is not set to the system class loader
(as it is at runtime), thus it cannot load the class.

Jardo, can ValidateLayerConsistencyTest set the context class loader to the
system class loader? I tried calling:

Thread.currentThread().setContextClassLoader((ClassLoader)Lookup.getDefault().lookup(ClassLoader.class));

at the beginning of testAreAttributesFine(). It helped and didn't cause any
other fails.
Comment 14 Jesse Glick 2006-06-21 19:27:58 UTC
The suggested patch to ValidateLayerConsistencyTest sounds fine to me.
Comment 15 Jaroslav Tulach 2006-06-22 07:13:44 UTC
Probably fine fix. 

btw. during re-reading the diff I found that the arch document describes some 
API but does not use <api group="lookup" ..../> tag. Please fix that as well.
Comment 16 Andrei Badea 2006-06-22 08:52:41 UTC
Fixed arch.xml.

Checking in arch.xml;
/cvs/db/dbapi/Attic/arch.xml,v  <--  arch.xml
new revision: 1.1.4.4; previous revision: 1.1.4.3
done
Comment 17 Andrei Badea 2006-06-22 12:18:57 UTC
After discussing it with Jarda I fixed VLCT by setting the context class loader
in the setUp() method and resetting it to the old value in tearDown().

In release55:

Checking in
db/dbapi/src/org/netbeans/modules/db/api/explorer/DatabaseMetaDataTransfer.java;
/cvs/db/dbapi/src/org/netbeans/modules/db/api/explorer/Attic/DatabaseMetaDataTransfer.java,v
 <--  DatabaseMetaDataTransfer.java
new revision: 1.1.4.3; previous revision: 1.1.4.2
done
Checking in
core/test/unit/src/org/netbeans/core/projects/ValidateLayerConsistencyTest.java;
/cvs/core/test/unit/src/org/netbeans/core/projects/ValidateLayerConsistencyTest.java,v
 <--  ValidateLayerConsistencyTest.java
new revision: 1.17.42.2.2.1; previous revision: 1.17.42.2
done

In trunk:

Checking in unit/src/org/netbeans/core/projects/ValidateLayerConsistencyTest.java;
/cvs/core/test/unit/src/org/netbeans/core/projects/ValidateLayerConsistencyTest.java,v
 <--  ValidateLayerConsistencyTest.java
new revision: 1.24; previous revision: 1.23
done
Comment 18 Andrei Badea 2006-06-23 09:59:35 UTC
Also TableNodeTest failed in the 200606220200 daily run. Caused by the temporary
fix in DatabaseMetaDataTransfer which didn't initialize TABLE_FLAVOR.
Comment 19 Winston Prakash 2006-07-13 15:37:25 UTC
Tested the API with Creator Pack intgerated with NB binary (200607100200).
Everything seems to work fine.