Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] how to add features to a shapefile layer on map

something seems a bit odd...

The transaction should be handled by the Map; that is what the * is about - and when the user hits commit the features will actually be written out. Until then they should show up in the map after a refresh and so on ...

So if you want to avoid the star you would actually be taking control away from the user (basically doing a "commit") without asking them.

The idea was to let the programs hack away on map data; and let users review and modify; and only commit when they are ready.

So I would:
1. don't use your own transaction the layer has already supplied one
2. Use the commit CommitCommand

If this becomes a common need we should make a CommitRecommendedAction that prompts the user that a commit is recommended and allows them to "Commit" or "Igmore" or something...

Jody
On 14/10/2009, at 7:14 PM, Kemppilä Atte wrote:

Hi.

I have a shapefile as a map layer and I would like to add multiple features directly into the shapefile. I have done it like this (simplified):

(using uDig 1.2 M7)


Transaction tx = new DefaultTransaction("foo");
try {
 featureStore.setTransaction(tx);
 featureStore.addFeatures(featureCollection);
 tx.commit();
}
catch (Exception e) {
 tx.rollback();
}
finally {
 tx.close();
}


Seems to work fine. Features are inserted to the shapefile, appear on the map after refresh and various listeners get notified that features were added. The only problem is that the map thinks that it has been modified (it gets that star '*' next it's name).

So, how to avoid that star. I tried a couple things:

1. I could say "layer.eSetDeliver(false)" before the add (and set back to true after). No more star, but listeners don't get called either.

2. I could use CommitCommand after the transaction but that just seems odd that I would need another commit. Also, I wouldn't be able to add features to shapefile if there were edit in progress in some other layer because those changes would be committed also. (I think.)

Or something else? Or is there something wrong in the way how I add the features?


Some guidance would be appreciated.

--
Atte Kemppilä
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel



Back to the top