Skip to content

Commit

Permalink
Finish generics web-core/widget package
Browse files Browse the repository at this point in the history
  • Loading branch information
NielsCharlier committed Jan 23, 2016
1 parent ba0c52f commit 4b56563
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 24 deletions.
Expand Up @@ -45,9 +45,6 @@ public ColorPickerPanel(final String id, final IModel paramVale,

// the color picker. Notice that we need to convert between RRGGBB and
// #RRGGBB,
// passing in a Color.class param is just a trick to force the component
// to use
// the converter both ways
ColorPickerField textField = new ColorPickerField("paramValue", paramVale) {
private static final long serialVersionUID = 4185457152965032989L;

Expand Down
Expand Up @@ -10,7 +10,7 @@
@SuppressWarnings("serial")
public class WorldImageEditPanel extends AbstractRasterFileEditPanel {

public WorldImageEditPanel(String componentId, Form storeEditForm) {
public WorldImageEditPanel(String componentId, Form<?> storeEditForm) {
super(componentId, storeEditForm, new String[] { ".png", ".tiff", ".tif", ".jpeg", ".jpg", ".gif" });
}

Expand Down
Expand Up @@ -5,8 +5,6 @@
*/
package org.geoserver.web.wicket;

import java.awt.Color;

import org.apache.wicket.Component;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.behavior.Behavior;
Expand Down
Expand Up @@ -19,22 +19,23 @@
* "live collection", that is, a list that is supposed to be modified directly,
* as opposed thru setting it again with a property setter
*/
@SuppressWarnings("serial")
public abstract class LiveCollectionModel implements IModel {
IModel wrapped;
public abstract class LiveCollectionModel<S, T extends Collection<S>> implements IModel<T> {
private static final long serialVersionUID = 3505518156788420409L;

IModel<? extends Collection<S>> wrapped;

public LiveCollectionModel(IModel wrapped) {
public LiveCollectionModel(IModel<? extends Collection<S>> wrapped) {
if (wrapped == null)
throw new NullPointerException(
"Live list model cannot wrap a null model");
this.wrapped = wrapped;
}

public void setObject(Object object) {
Collection collection = (Collection) wrapped.getObject();
public void setObject(T object) {
Collection<S> collection = wrapped.getObject();
collection.clear();
if(object != null) {
collection.addAll((Collection) object);
collection.addAll(object);
}
}

Expand All @@ -45,11 +46,13 @@ public void detach() {
/**
* Returns a model for live lists
*/
public static LiveCollectionModel list(IModel wrapped) {
return new LiveCollectionModel(wrapped) {
public static <S> LiveCollectionModel<S, List<S>> list(IModel<? extends Collection<S>> wrapped) {
return new LiveCollectionModel<S, List<S>>(wrapped) {

private static final long serialVersionUID = 3182237972594668864L;

public Object getObject() {
return new ArrayList((List) wrapped.getObject());
public List<S> getObject() {
return new ArrayList<S>(wrapped.getObject());
}

};
Expand All @@ -58,11 +61,13 @@ public Object getObject() {
/**
* Returns a model for live sets
*/
public static LiveCollectionModel set(IModel wrapped) {
return new LiveCollectionModel(wrapped) {
public static <S> LiveCollectionModel<S, Set<S>> set(IModel<? extends Collection<S>> wrapped) {
return new LiveCollectionModel<S, Set<S>>(wrapped) {

private static final long serialVersionUID = 7638792616781214296L;

public Object getObject() {
return new HashSet((Set) wrapped.getObject());
public Set<S> getObject() {
return new HashSet<S>(wrapped.getObject());
}

};
Expand Down
Expand Up @@ -103,7 +103,7 @@ public void onSubmit(){
new WCSInterpolationModel()));

Palette<String> interpolationMethods = new Palette<String>("interpolationMethods", LiveCollectionModel
.list(new PropertyModel<String>(coverage, "interpolationMethods")),
.list(new PropertyModel<List<String>>(coverage, "interpolationMethods")),
new WCSInterpolationModel(), new SimpleChoiceRenderer(), 7, false) {
private static final long serialVersionUID = 6815545819673802290L;

Expand Down Expand Up @@ -134,7 +134,7 @@ public Component newAvailableHeader(final String componentId) {
add(nativeFormat);

Palette<String> formatPalette = new Palette<String>("formatPalette", LiveCollectionModel
.list(new PropertyModel<String>(coverage, "supportedFormats")), new WCSFormatsModel(),
.list(new PropertyModel<List<String>>(coverage, "supportedFormats")), new WCSFormatsModel(),
new SimpleChoiceRenderer(), 10, false) {
private static final long serialVersionUID = -2463012775305597908L;

Expand Down
Expand Up @@ -58,7 +58,8 @@ public WFSLayerConfig(String id, IModel<LayerInfo> model){
final WebMarkupContainer otherSrsContainer = new WebMarkupContainer("otherSRSContainer");
otherSrsContainer.setOutputMarkupId(true);
add(otherSrsContainer);
final TextArea<List<String>> srsList = new SRSListTextArea("srs", LiveCollectionModel.list(new PropertyModel<String>(model, "resource.responseSRS")));
final TextArea<List<String>> srsList = new SRSListTextArea("srs", LiveCollectionModel.list(
new PropertyModel<List<String>>(model, "resource.responseSRS")));
srsList.setOutputMarkupId(true);
srsList.setVisible(Boolean.TRUE.equals(overrideServiceSRSModel.getObject()));
otherSrsContainer.add(srsList);
Expand Down

0 comments on commit 4b56563

Please sign in to comment.