I've found the solution (not to bad I think).
To catch when a feature is created with the polygon tool, I added a
IEditManagerListener on the map.getEditManager().
map.getEditManager().addListener(new IEditManagerListener() {
@Override
public void changed(EditManagerEvent event) {
SimpleFeature feature=
map.getEditManager().getEditFeature();
if(feature != null) {
if(feature.getFeatureType().equals(dodFeatureType)) {
FilterFactory factory =
CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
Id uDigfilter =
factory.id(Collections.singleton(feature.getIdentifier()));
try {
FeatureCollection<SimpleFeatureType, SimpleFeature> collection =
dodStore.getFeatures(uDigfilter);
if(collection.isEmpty()) {
insertDod(feature);
}
else {
saveDod(feature);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
});
And to manage udig table view feature store, I added a listener to my
wfsLayer:
dodLayer.addListener(new ILayerListener() {
@Override
public void refresh(LayerEvent event) {
if(event.getType().equals(EventType.EDIT_EVENT)) {
if(event.getNewValue() instanceof FeatureEvent)
{
FeatureEvent newEvent = (FeatureEvent)
event.getNewValue();
if(newEvent.getSource() instanceof
FeatureStore) {
uDigStore =
(FeatureStore<SimpleFeatureType, SimpleFeature>) newEvent.getSource();
}
}
}
}
});
I hope it could help someone else!
Regards,
Virginie BERRE - Ingénieur d'études et de développement
+33 (0)1 30 15 40 58
[email protected]
MAGELLIUMPensez environnement ! N'imprimez ce mail que si c'est vraiment
nécessaire !
De : [email protected]
[mailto:[email protected]] De la part de Virginie
BERRE
Envoyé : mercredi 3 mars 2010 18:16
À : 'User-friendly Desktop Internet GIS'
Objet : [udig-devel] Polygon Tool : catch what is created
Dear all,
Is there a way to catch the geometry or the feature which is created with
the polygon tool?
My goal is to set some properties when the edit layer is my wfs layer and
before the feature is created
or to change the properties if the feature is
created.
My feature collection is not the udig feature collection
I don't find a
method which returns the geometry or the feature int the PolygonTool class
(or the implemented classes)
I don't want to re-implement this tool but I really need it.
Thank you.
Virginie BERRE - Ingénieur d'études et de développement
+33 (0)1 30 15 40 58 (n° direct)
[email protected]
_____
ZA Les Erables - bâtiment 4
66, route de Sartrouville
78230 Le Pecq
Tel: +33 (0)1 30 15 40 50 (standard)
Fax: +33 (0)1 30 15 40 60
<http://www.magellium.fr> www.magellium.fr
<http://www.magellium.fr/> MAGELLIUM
MAGELLIUMPensez environnement ! N'imprimez ce mail que si c'est vraiment
nécessaire !
<<image002.gif>>
<<image003.gif>>
_______________________________________________ User-friendly Desktop Internet GIS (uDig) http://udig.refractions.net http://lists.refractions.net/mailman/listinfo/udig-devel
