Skip to content

Commit

Permalink
Fix and Genericize feature-aggregate extension web packages
Browse files Browse the repository at this point in the history
  • Loading branch information
tbarsballe committed Jan 19, 2016
1 parent 2f2faad commit 92e6278
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 41 deletions.
Expand Up @@ -118,7 +118,7 @@ protected void onUpdate(AjaxRequestTarget target) {
"sourceTypes", new SourceTypeProvider(configModel)) { "sourceTypes", new SourceTypeProvider(configModel)) {


@Override @Override
protected Component getComponentForProperty(String id, IModel itemModel, protected Component getComponentForProperty(String id, IModel<SourceType> itemModel,
Property<SourceType> property) { Property<SourceType> property) {
if(property.getName().equals("default")) { if(property.getName().equals("default")) {
return new Label(id, property.getModel(itemModel)); return new Label(id, property.getModel(itemModel));
Expand Down
@@ -1,4 +1,4 @@
/* (c) 2014 - 2015 Open Source Geospatial Foundation - all rights reserved /* (c) 2014 - 2016 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans * (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root * This code is licensed under the GPL 2.0 license, available at the root
* application directory. * application directory.
Expand All @@ -14,11 +14,12 @@
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.logging.Logger; import java.util.Map;

import org.apache.wicket.AttributeModifier; import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component; import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.attributes.AjaxCallListener;
import org.apache.wicket.ajax.attributes.IAjaxCallListener;
import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.Form;
Expand All @@ -37,7 +38,6 @@
import org.geoserver.web.wicket.SimpleAjaxLink; import org.geoserver.web.wicket.SimpleAjaxLink;
import org.geotools.data.aggregate.AggregateTypeConfiguration; import org.geotools.data.aggregate.AggregateTypeConfiguration;
import org.geotools.data.aggregate.AggregatingDataStoreFactory; import org.geotools.data.aggregate.AggregatingDataStoreFactory;
import org.geotools.util.logging.Logging;


/** /**
* Provides the form components for the shapefile datastore * Provides the form components for the shapefile datastore
Expand All @@ -47,27 +47,26 @@
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class AggregateStoreEditPanel extends StoreEditPanel { public class AggregateStoreEditPanel extends StoreEditPanel {


private static final Logger LOGGER = Logging.getLogger(AggregateStoreEditPanel.class);
private List<AggregateTypeConfiguration> configs; private List<AggregateTypeConfiguration> configs;
private GeoServerTablePanel<AggregateTypeConfiguration> configTable; private GeoServerTablePanel<AggregateTypeConfiguration> configTable;
private ConfigModel configModel; private ConfigModel configModel;


public AggregateStoreEditPanel(final String componentId, final Form storeEditForm) { public AggregateStoreEditPanel(final String componentId, final Form<?> storeEditForm) {
super(componentId, storeEditForm); super(componentId, storeEditForm);


final IModel model = storeEditForm.getModel(); final IModel<?> model = storeEditForm.getModel();
setDefaultModel(model); setDefaultModel(model);


final IModel paramsModel = new PropertyModel(model, "connectionParameters"); final IModel<Map<String, Object>> paramsModel = new PropertyModel<Map<String, Object>>(model, "connectionParameters");
new MapModel(paramsModel, CONFIGURATION.key).setObject(null); new MapModel<Object>(paramsModel, CONFIGURATION.key).setObject(null);


add(new TextParamPanel("parallelism", new MapModel(paramsModel, PARALLELISM.key), add(new TextParamPanel("parallelism", new MapModel<Object>(paramsModel, PARALLELISM.key),
new ParamResourceModel("parallelism", this), true)); new ParamResourceModel("parallelism", this), true));


add(new CheckBoxParamPanel("tolerateErrors", new MapModel(paramsModel, add(new CheckBoxParamPanel("tolerateErrors", new MapModel<Object>(paramsModel,
TOLERATE_CONNECTION_FAILURE.key), new ParamResourceModel("tolerateErrors", this))); TOLERATE_CONNECTION_FAILURE.key), new ParamResourceModel("tolerateErrors", this)));


configModel = new ConfigModel(new MapModel(paramsModel, CONFIGURATION_XML.key)); configModel = new ConfigModel(new MapModel<String>(paramsModel, CONFIGURATION_XML.key));
configs = configModel.getObject(); configs = configModel.getObject();
if(configs == null) { if(configs == null) {
configs = new ArrayList<AggregateTypeConfiguration>(); configs = new ArrayList<AggregateTypeConfiguration>();
Expand All @@ -77,7 +76,7 @@ public AggregateStoreEditPanel(final String componentId, final Form storeEditFor
"configTable", new ConfigurationListProvider(configs)) { "configTable", new ConfigurationListProvider(configs)) {


@Override @Override
protected Component getComponentForProperty(String id, IModel itemModel, protected Component getComponentForProperty(String id, IModel<AggregateTypeConfiguration> itemModel,
Property<AggregateTypeConfiguration> property) { Property<AggregateTypeConfiguration> property) {
if (property == ConfigurationListProvider.NAME) { if (property == ConfigurationListProvider.NAME) {
return editLink(id, itemModel); return editLink(id, itemModel);
Expand Down Expand Up @@ -109,8 +108,8 @@ public void onClick(AjaxRequestTarget target) {
return link; return link;
} }


protected Component editLink(String id, IModel itemModel) { protected Component editLink(String id, IModel<AggregateTypeConfiguration> itemModel) {
SimpleAjaxLink link = new SimpleAjaxLink(id, itemModel, new PropertyModel<String>(itemModel, "name")) { SimpleAjaxLink<?> link = new SimpleAjaxLink<AggregateTypeConfiguration>(id, itemModel, new PropertyModel<String>(itemModel, "name")) {


@Override @Override
protected void onClick(AjaxRequestTarget target) { protected void onClick(AjaxRequestTarget target) {
Expand All @@ -120,25 +119,24 @@ protected void onClick(AjaxRequestTarget target) {
return link; return link;
} }


Component removeLink(String id, IModel itemModel) { Component removeLink(String id, IModel<AggregateTypeConfiguration> itemModel) {
final AggregateTypeConfiguration entry = (AggregateTypeConfiguration) itemModel.getObject(); final AggregateTypeConfiguration entry = (AggregateTypeConfiguration) itemModel.getObject();
ImageAjaxLink link = new ImageAjaxLink( id, new PackageResourceReference( GeoServerApplication.class, "img/icons/silk/delete.png") ) { ImageAjaxLink<?> link = new ImageAjaxLink<Object>( id, new PackageResourceReference( GeoServerApplication.class, "img/icons/silk/delete.png") ) {
@Override @Override
protected void onClick(AjaxRequestTarget target) { protected void onClick(AjaxRequestTarget target) {


configs.remove( entry ); configs.remove( entry );
target.add( configTable ); target.add( configTable );
} }


@Override protected IAjaxCallListener getAjaxCallListener() {
protected IAjaxCallDecorator getAjaxCallListener() { return new AjaxCallListener() {
return new AjaxPreprocessingCallDecorator(null) {


@Override @Override
public CharSequence preDecorateScript(CharSequence script) { public CharSequence getBeforeHandler(Component component) {
String msg = new ParamResourceModel("confirmTypeRemoval", String msg = new ParamResourceModel("confirmTypeRemoval",
AggregateStoreEditPanel.this, entry.getName()).getString(); AggregateStoreEditPanel.this, entry.getName()).getString();
return "if(!confirm('" + msg +"')) return false;" + script; return "if(!confirm('" + msg +"')) return false;";
} }
}; };
} }
Expand All @@ -154,9 +152,9 @@ public boolean onSave() {
} }


class ConfigModel implements IModel<List<AggregateTypeConfiguration>> { class ConfigModel implements IModel<List<AggregateTypeConfiguration>> {
IModel model; IModel<String> model;


public ConfigModel(IModel model) { public ConfigModel(IModel<String> model) {
this.model = model; this.model = model;
} }


Expand Down
@@ -1,4 +1,4 @@
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved /* (c) 2014 - 2016 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans * (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root * This code is licensed under the GPL 2.0 license, available at the root
* application directory. * application directory.
Expand All @@ -10,6 +10,8 @@


public class ConfigEditPage extends AbstractConfigPage { public class ConfigEditPage extends AbstractConfigPage {


private static final long serialVersionUID = -5309182299077598971L;

public ConfigEditPage(AggregateStoreEditPanel master, AggregateTypeConfiguration config) { public ConfigEditPage(AggregateStoreEditPanel master, AggregateTypeConfiguration config) {
super(master); super(master);
initUI(config); initUI(config);
Expand Down
@@ -1,4 +1,4 @@
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved /* (c) 2014 - 2016 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans * (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root * This code is licensed under the GPL 2.0 license, available at the root
* application directory. * application directory.
Expand All @@ -10,6 +10,8 @@


public class ConfigNewPage extends AbstractConfigPage { public class ConfigNewPage extends AbstractConfigPage {


private static final long serialVersionUID = 4059243636202134036L;

public ConfigNewPage(AggregateStoreEditPanel master) { public ConfigNewPage(AggregateStoreEditPanel master) {
super(master); super(master);
initUI(new AggregateTypeConfiguration("")); initUI(new AggregateTypeConfiguration(""));
Expand Down
@@ -1,4 +1,4 @@
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved /* (c) 2014 - 2016 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans * (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root * This code is licensed under the GPL 2.0 license, available at the root
* application directory. * application directory.
Expand All @@ -22,21 +22,25 @@ class ConfigurationListProvider extends GeoServerDataProvider<AggregateTypeConfi
public static Property<AggregateTypeConfiguration> SOURCES = new AbstractProperty<AggregateTypeConfiguration>( public static Property<AggregateTypeConfiguration> SOURCES = new AbstractProperty<AggregateTypeConfiguration>(
"sources") { "sources") {


public IModel getModel(final IModel itemModel) { private static final long serialVersionUID = 8445881898430736063L;
return new IModel() {
public IModel<AggregateTypeConfiguration> getModel(final IModel<AggregateTypeConfiguration> itemModel) {
return new IModel<AggregateTypeConfiguration>() {

private static final long serialVersionUID = -1612531825990914783L;


@Override @Override
public void detach() { public void detach() {
// nothing to do // nothing to do
} }


@Override @Override
public Object getObject() { public AggregateTypeConfiguration getObject() {
return getPropertyValue((AggregateTypeConfiguration) itemModel.getObject()); return (AggregateTypeConfiguration) getPropertyValue( itemModel.getObject());
} }


@Override @Override
public void setObject(Object object) { public void setObject(AggregateTypeConfiguration object) {
// read only // read only
} }
}; };
Expand All @@ -61,7 +65,7 @@ public Object getPropertyValue(AggregateTypeConfiguration item) {
public static Property<AggregateTypeConfiguration> REMOVE = public static Property<AggregateTypeConfiguration> REMOVE =
new PropertyPlaceholder<AggregateTypeConfiguration>( "remove" ); new PropertyPlaceholder<AggregateTypeConfiguration>( "remove" );


static List PROPERTIES = Arrays.asList(NAME, SOURCES, REMOVE); static List<org.geoserver.web.wicket.GeoServerDataProvider.Property<AggregateTypeConfiguration>> PROPERTIES = Arrays.asList(NAME, SOURCES, REMOVE);


List<AggregateTypeConfiguration> items; List<AggregateTypeConfiguration> items;


Expand Down
@@ -1,4 +1,4 @@
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved /* (c) 2014 - 2016 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans * (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root * This code is licensed under the GPL 2.0 license, available at the root
* application directory. * application directory.
Expand All @@ -22,9 +22,9 @@ class SourceTypeProvider extends GeoServerDataProvider<SourceType> {


public Property<SourceType> TYPE = new BeanProperty<SourceType>("typeName", "typeName"); public Property<SourceType> TYPE = new BeanProperty<SourceType>("typeName", "typeName");


public Property<SourceType> MAKE_DEFAULT = new PropertyPlaceholder("makeDefault"); public Property<SourceType> MAKE_DEFAULT = new PropertyPlaceholder<SourceType>("makeDefault");


public Property<SourceType> REMOVE = new PropertyPlaceholder("remove"); public Property<SourceType> REMOVE = new PropertyPlaceholder<SourceType>("remove");


IModel<AggregateTypeConfiguration> config; IModel<AggregateTypeConfiguration> config;


Expand All @@ -50,6 +50,7 @@ public DefaultSourceTypeProperty getDefaultSourceTypeProperty() {
} }


static final class DefaultSourceTypeProperty extends AbstractProperty<SourceType> { static final class DefaultSourceTypeProperty extends AbstractProperty<SourceType> {
private static final long serialVersionUID = 7215317236941087113L;
IModel<AggregateTypeConfiguration> config; IModel<AggregateTypeConfiguration> config;


public DefaultSourceTypeProperty(String name, IModel<AggregateTypeConfiguration> config) { public DefaultSourceTypeProperty(String name, IModel<AggregateTypeConfiguration> config) {
Expand All @@ -58,8 +59,7 @@ public DefaultSourceTypeProperty(String name, IModel<AggregateTypeConfiguration>
} }


@Override @Override
public IModel getModel(IModel itemModel) { public IModel<SourceType> getModel(IModel<SourceType> itemModel) {
// TODO Auto-generated method stub
return super.getModel(itemModel); return super.getModel(itemModel);
} }


Expand All @@ -71,6 +71,8 @@ public Comparator<SourceType> getComparator() {
public Object getPropertyValue(final SourceType item) { public Object getPropertyValue(final SourceType item) {
return new IModel<Boolean>() { return new IModel<Boolean>() {


private static final long serialVersionUID = 335379699073989386L;

@Override @Override
public void detach() { public void detach() {
} }
Expand Down
@@ -1,4 +1,4 @@
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved /* (c) 2014 - 2016 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans * (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root * This code is licensed under the GPL 2.0 license, available at the root
* application directory. * application directory.
Expand All @@ -19,6 +19,8 @@ class SourcesProvider extends GeoServerDataProvider<Map.Entry<Name, String>> {
public static Property<Map.Entry<Name, String>> NAME = new AbstractProperty<Map.Entry<Name, String>>( public static Property<Map.Entry<Name, String>> NAME = new AbstractProperty<Map.Entry<Name, String>>(
"store") { "store") {


private static final long serialVersionUID = -4599279831041684940L;

@Override @Override
public Object getPropertyValue(Entry<Name, String> item) { public Object getPropertyValue(Entry<Name, String> item) {
return item.getKey(); return item.getKey();
Expand All @@ -28,13 +30,15 @@ public Object getPropertyValue(Entry<Name, String> item) {
public static Property<Map.Entry<Name, String>> TYPE = new AbstractProperty<Map.Entry<Name, String>>( public static Property<Map.Entry<Name, String>> TYPE = new AbstractProperty<Map.Entry<Name, String>>(
"type") { "type") {


private static final long serialVersionUID = -2038898684200579478L;

@Override @Override
public Object getPropertyValue(Map.Entry<Name, String> item) { public Object getPropertyValue(Map.Entry<Name, String> item) {
return item.getValue(); return item.getValue();
} }
}; };


static List PROPERTIES = Arrays.asList(NAME, TYPE); static List<Property<Entry<Name, String>>> PROPERTIES = Arrays.asList(NAME, TYPE);


List<Map.Entry<Name, String>> items; List<Map.Entry<Name, String>> items;


Expand Down

0 comments on commit 92e6278

Please sign in to comment.