Thursday, October 29, 2009

Nifty database login widget in GeoTools 2.6

Writing yet another login dialog for Postgres/PostGIS in Swing is tedious and mine always look crappy.  So I was happy to find that GeoTools 2.6 has a database login widget called JDataStoreWizard.  Updating the table with new features is also simple as adding your feature collection to the feature store.

Here's an example to call JDataStoreWizard and update a table in PostGIS
JDataStoreWizard wizard = new JDataStoreWizard(new PostgisDataStoreFactory());
int result = wizard.showModalDialog();
if (result != JWizard.FINISH) {
Map connectionParameters = wizard.getConnectionParameters(); 
PostgisDataStore dataStore = (PostgisDataStore)
FeatureStore myFeatureTable = (FeatureStore) pgDs.getFeatureSource("myFeature");

No comments:

Post a Comment