final MapWidget map = new MapWidget("mapEditableGrid", "gwt-samples");
map.setController(new PanController(map));
mapLayout.addMember(map);
// Create a layout with a FeatureListGrid in it:
final FeatureListGrid grid = new FeatureListGrid(map.getMapModel());
grid.setShowEdges(true);
grid.setShowResizeBar(true);
grid.setEditingEnabled(true);
// Add a trigger to fill the grid when the map has finished loading:
map.getMapModel().addMapModelHandler(new MapModelHandler() {
public void onMapModelChange(MapModelEvent event) {
final VectorLayer layer = map.getMapModel().getVectorLayer("clientLayerBeansEditableGrid");
grid.setLayer(layer);
SearchFeatureRequest searchFeatureRequest = new SearchFeatureRequest();
searchFeatureRequest.setCrs(map.getMapModel().getCrs());
searchFeatureRequest.setFeatureIncludes(GeomajasConstant.FEATURE_INCLUDE_ATTRIBUTES);
searchFeatureRequest.setLayerId("layerBeansEditableGrid");
GwtCommand searchCommand = new GwtCommand(SearchFeatureRequest.COMMAND);
searchCommand.setCommandRequest(searchFeatureRequest);
GwtCommandDispatcher.getInstance().execute(searchCommand,
new AbstractCommandCallback<SearchFeatureResponse>() {
public void execute(SearchFeatureResponse response) {
for (org.geomajas.layer.feature.Feature feature : response.getFeatures()) {
Feature f = new Feature(feature, layer);
grid.addFeature(f);
layer.getFeatureStore().addFeature(f);
}
}
});
}