form.add(new GeoServerAjaxFormLink( "generateBounds") {
@Override
public void onClick(AjaxRequestTarget target, Form form) {
// build a layer group with the current contents of the group
LayerGroupInfo lg = getCatalog().getFactory().createLayerGroup();
for ( LayerGroupEntry entry : lgEntryPanel.getEntries() ) {
lg.getLayers().add(entry.getLayer());
lg.getStyles().add(entry.getStyle());
}
try {
// grab the eventually manually inserted
CoordinateReferenceSystem crs = envelopePanel.getCoordinateReferenceSystem();
if ( crs != null ) {
//ensure the bounds calculated in terms of the user specified crs
new CatalogBuilder( getCatalog() ).calculateLayerGroupBounds( lg, crs );
}
else {
//calculate from scratch
new CatalogBuilder( getCatalog() ).calculateLayerGroupBounds( lg );
}
envelopePanel.setModelObject( lg.getBounds() );
target.addComponent( envelopePanel );
}
catch (Exception e) {
throw new WicketRuntimeException( e );