Fragment f = new Fragment("editor", "text", this);
DropDownChoice mimeChoice = new DropDownChoice("mime", new PropertyModel(
getDefaultModel(), "mime"), mimeTypes);
f.add(mimeChoice);
f.add(new TextArea("textarea", valueModel));
add(f);
} else if (pt == ParameterType.VECTOR_LAYER) {
// an internal vector layer
if (!(valueModel.getObject() instanceof VectorLayerConfiguration)) {
valueModel.setObject(new VectorLayerConfiguration());
}
Fragment f = new Fragment("editor", "vectorLayer", this);
DropDownChoice layer = new DropDownChoice("layer", new PropertyModel(valueModel,
"layerName"), getVectorLayerNames());
f.add(layer);
add(f);
} else if (pt == ParameterType.RASTER_LAYER) {
// an internal raster layer
if (!(valueModel.getObject() instanceof RasterLayerConfiguration)) {
valueModel.setObject(new RasterLayerConfiguration());
}
Fragment f = new Fragment("editor", "rasterLayer", this);
final DropDownChoice layer = new DropDownChoice("layer", new PropertyModel(valueModel,
"layerName"), getRasterLayerNames());
f.add(layer);
add(f);
// we need to update the raster own bounding box as wcs requests
// mandate a spatial extent (why oh why???)
layer.add(new AjaxFormComponentUpdatingBehavior("onchange") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
String name = layer.getDefaultModelObjectAsString();
LayerInfo li = GeoServerApplication.get().getCatalog().getLayerByName(name);
ReferencedEnvelope spatialDomain = li.getResource().getNativeBoundingBox();
((RasterLayerConfiguration) valueModel.getObject())
.setSpatialDomain(spatialDomain);
}
});
} else if (pt == ParameterType.REFERENCE) {
// an external reference
if (!(valueModel.getObject() instanceof ReferenceConfiguration)) {
valueModel.setObject(new ReferenceConfiguration());
}
Fragment f = new Fragment("editor", "reference", this);
final DropDownChoice method = new DropDownChoice("method", new PropertyModel(
valueModel, "method"), Arrays.asList(ReferenceConfiguration.Method.GET,
ReferenceConfiguration.Method.POST));
f.add(method);
DropDownChoice mimeChoice = new DropDownChoice("mime", new PropertyModel(valueModel,
"mime"), mimeTypes);
f.add(mimeChoice);
f.add(new TextField("url", new PropertyModel(valueModel, "url")).setRequired(true));
final TextArea body = new TextArea("body", new PropertyModel(valueModel, "body"));
add(body);
final WebMarkupContainer bodyContainer = new WebMarkupContainer("bodyContainer");
f.add(bodyContainer);
bodyContainer.setOutputMarkupId(true);
bodyContainer.add(body);
bodyContainer.setVisible(false);
method.add(new AjaxFormComponentUpdatingBehavior("onchange") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
boolean post = method.getModelObject() == ReferenceConfiguration.Method.POST;
bodyContainer.setVisible(post);
body.setRequired(post);
target.addComponent(ComplexInputPanel.this);
}
});
add(f);
} else if (pt == ParameterType.SUBPROCESS) {
if (!(valueModel.getObject() instanceof ExecuteRequest)) {
valueModel.setObject(new ExecuteRequest());
}
Fragment f = new Fragment("editor", "subprocess", this);
f.add(new AjaxLink("edit") {
@Override
public void onClick(AjaxRequestTarget target) {
subprocesswindow.setDefaultModel(valueModel);
subprocesswindow.show(target);
}
});
final TextArea xml = new TextArea("xml");
if (((ExecuteRequest) valueModel.getObject()).processName != null) {
try {
xml.setModelObject(getExecuteXML());
} catch (Throwable t) {
xml.setModel(new Model(""));
}
} else {
xml.setModel(new Model(""));
}
xml.setOutputMarkupId(true);
f.add(xml);
subprocesswindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
public void onClose(AjaxRequestTarget target) {
// turn the GUI request into an actual WPS request
xml.setModelObject(getExecuteXML());
target.addComponent(xml);
}
});