public LayerGroupEntryPanel( String id, LayerGroupInfo layerGroup ) {
super( id );
items = new ArrayList<LayerGroupEntry>();
for ( int i = 0; i < layerGroup.getLayers().size(); i++ ) {
PublishedInfo layer = layerGroup.getLayers().get( i );
StyleInfo style = layerGroup.getStyles().get( i );
items.add( new LayerGroupEntry( layer, style ) );
}
add( popupWindow = new ModalWindow( "popup" ) );
add(dialog = new GeoServerDialog("dialog"));
add(new HelpLink("layersHelp").setDialog(dialog));
//layers
add(layerTable = new ReorderableTablePanel<LayerGroupEntry>("layers", items, PROPERTIES) {
@Override
protected Component getComponentForProperty(String id, IModel itemModel,
Property<LayerGroupEntry> property) {
if (property == LAYER) {
return layerLink( id, itemModel );
}
if (property == DEFAULT_STYLE) {
return defaultStyleCheckbox( id, itemModel );
}
if (property == STYLE) {
return styleLink( id, itemModel );
}
if (property == REMOVE) {
return removeLink( id, itemModel );
}
return null;
}
}.setFilterable( false ));
layerTable.setItemReuseStrategy(new DefaultItemReuseStrategy());
layerTable.setOutputMarkupId( true );
add( new AjaxLink( "addLayer" ) {
@Override
public void onClick(AjaxRequestTarget target) {
popupWindow.setInitialHeight( 375 );
popupWindow.setInitialWidth( 525 );
popupWindow.setTitle(new ParamResourceModel("chooseLayer", this));
popupWindow.setContent( new LayerListPanel(popupWindow.getContentId()) {
@Override
protected void handleLayer(LayerInfo layer, AjaxRequestTarget target) {
popupWindow.close( target );
items.add(
new LayerGroupEntry( layer, layer.getDefaultStyle() ) );
//getCatalog().save( lg );
target.addComponent( layerTable );
}
});