@Override protected void onUpdate(AjaxRequestTarget target) { convertInput(); CoordinateReferenceSystem crs = (CoordinateReferenceSystem) getConvertedInput(); if(crs != null) { setModelObject(crs); wktLabel.setDefaultModelObject(crs.getName().toString()); wktLink.setEnabled(true); } else { wktLabel.setDefaultModelObject(null); wktLink.setEnabled(false); } target.addComponent(wktLink); onSRSUpdated(toSRS(crs), target); } });
void initComponents() { add(popupWindow); add(srsTextField); srsTextField.setOutputMarkupId(true); add(findLink); wktLink.setEnabled(getModelObject() != null); add(wktLink);
@Override public void convertInput() { String srs = srsTextField.getInput(); CoordinateReferenceSystem crs = null; if (srs != null && !"".equals(srs)) { if ("UNKNOWN".equals(srs)) { // leave underlying crs unchanged if (getModelObject() instanceof CoordinateReferenceSystem) { setConvertedInput(getModelObject()); } return; } crs = fromSRS(srs); } setConvertedInput(crs); }
/** * Returns the underlying CRS for the panel. * <p> * This method is convenience for: * <pre> * (CoordinateReferenceSystem) this.getModelObject(); * </pre> * </p> */ public CoordinateReferenceSystem getCRS() { convertInput(); return (CoordinateReferenceSystem) getConvertedInput(); }
CRSPanel nativeCRS = new CRSPanel("nativeSRS", new PropertyModel(model, "nativeCRS")); nativeCRS.setReadOnly(true); refForm.add(nativeCRS); declaredCRS = new CRSPanel("declaredSRS", new SRSToCRSModel(new PropertyModel(model, "sRS"))); declaredCRS.setRequired(true); refForm.add(declaredCRS);
void initComponents() { updateFields(); add(minXLabel = new Label("minXL", new ResourceModel("minX"))); add(minYLabel = new Label("minYL", new ResourceModel("minY"))); add(maxXLabel = new Label("maxXL", new ResourceModel("maxX"))); add(maxYLabel = new Label("maxYL", new ResourceModel("maxY"))); add( minXInput = new DecimalTextField( "minX", new PropertyModel(this, "minX")) ); add( minYInput = new DecimalTextField( "minY", new PropertyModel(this, "minY")) ); add( maxXInput = new DecimalTextField( "maxX", new PropertyModel(this, "maxX") )); add( maxYInput = new DecimalTextField( "maxY", new PropertyModel(this, "maxY")) ); crsContainer = new WebMarkupContainer("crsContainer"); crsContainer.setVisible(false); crsPanel = new CRSPanel("crs", new PropertyModel(this, "crs")); crsContainer.add(crsPanel); add(crsContainer); }
public PGRasterPanel(final String id, final IModel paramsModel, final Form storeEditForm) { super(id); server = addTextPanel(paramsModel, "server", true); port = addTextPanel(paramsModel, "port", true); SRSToCRSModel srsModel = new SRSToCRSModel(new PropertyModel(paramsModel, "ESPG:4326")); epsgcode = new CRSPanel("epsgcode", srsModel); epsgcode.setModelObject(DEFAULT_CRS); add(epsgcode); user = addTextPanel(paramsModel, "user", "Postgis user", true); password = addPasswordPanel(paramsModel, "password"); database = addTextPanel(paramsModel, "database", "Postgis Database", true); table = addTextPanel(paramsModel, "table", true); schema = addTextPanel(paramsModel, "schema", true); schema.setModelValue(new String[] {"public"}); fileext = addTextPanel(paramsModel, "fileext", "tiles file extension filter", false); importopt = addTextPanel(paramsModel, "importopt", "raster2pgsql script import options", false); server.setOutputMarkupId(true); port.setOutputMarkupId(true); user.setOutputMarkupId(true); password.setOutputMarkupId(true); database.setOutputMarkupId(true); table.setOutputMarkupId(true); schema.setOutputMarkupId(true); fileext.setOutputMarkupId(true); importopt.setOutputMarkupId(true); }
@Override protected void onCodeClicked(AjaxRequestTarget target, String epsgCode) { popupWindow.close(target); String srs = "EPSG:" + epsgCode; srsTextField.setModelObject(srs); target.add(srsTextField); CoordinateReferenceSystem crs = fromSRS(srs); CRSPanel.this.setModelObject(crs); if (crs != null) { wktLabel.setDefaultModelObject(crs.getName().toString()); wktLink.setEnabled(true); } else { wktLabel.setDefaultModelObject(null); wktLink.setEnabled(false); } target.add(wktLink); onSRSUpdated(srs, target); } };
@Override public void onClick(AjaxRequestTarget target, Form form) { popupWindow.setInitialHeight( 375 ); popupWindow.setInitialWidth( 525 ); popupWindow.setContent(new WKTPanel( popupWindow.getContentId(), getCRS())); CoordinateReferenceSystem crs = (CoordinateReferenceSystem) CRSPanel.this.getModelObject(); if(crs != null) popupWindow.setTitle(crs.getName().toString()); popupWindow.show(target); } };
@Override protected void onBeforeRender() { CoordinateReferenceSystem crs = (CoordinateReferenceSystem) getModelObject(); if (crs != null) { srsTextField.setModelObject(toSRS(crs)); wktLabel.setDefaultModelObject(crs.getName().toString()); } else { wktLabel.setDefaultModelObject(null); wktLink.setEnabled(false); } super.onBeforeRender(); }
@Override protected void onCodeClicked(AjaxRequestTarget target, String epsgCode) { popupWindow.close(target); String srs = "EPSG:" + epsgCode ; srsTextField.setModelObject( srs ); target.addComponent( srsTextField ); CoordinateReferenceSystem crs = fromSRS( srs ); wktLabel.setDefaultModelObject( crs.getName().toString() ); wktLink.setEnabled(true); target.addComponent( wktLink ); onSRSUpdated(srs, target); } };
@Override protected void onClick(AjaxRequestTarget target, Form form) { // perform manual processing of the required fields nativeBBox.processInput(); declaredCRS.processInput(); ReferencedEnvelope nativeBounds = (ReferencedEnvelope) nativeBBox.getModelObject(); try { // if the native bounds are not around compute them if(nativeBounds == null) { ResourceInfo resource = (ResourceInfo) BasicResourceConfig.this.getDefaultModelObject(); CatalogBuilder cb = new CatalogBuilder(GeoServerApplication.get().getCatalog()); nativeBounds = cb.getNativeBounds(resource); resource.setNativeBoundingBox(nativeBounds); nativeBBox.setModelObject(nativeBounds); target.addComponent(nativeBBox); } CatalogBuilder cb = new CatalogBuilder(GeoServerApplication.get().getCatalog()); latLonPanel.setModelObject(cb.getLatLonBounds(nativeBounds, declaredCRS.getCRS())); } catch(IOException e) { LOGGER.log(Level.SEVERE, "Error computing the geographic BBOX", e); error("Error computing the geographic bounds:" + e.getMessage()); } target.addComponent(latLonPanel); } };
}; }; sourcePanel.setRequired(true); form.add(sourcePanel); }; }; targetPanel.setRequired(true); form.add(targetPanel);
/** * We have to resort to manual validation otherwise the ajax tricks performed by the drop down * won't work */ protected boolean validate() { boolean valid = true; if (attribute.getName() == null || attribute.getName().trim().equals("")) { nameField.error((IValidationError) new ValidationError().addMessageKey("Required")); valid = false; } if (String.class.equals(attribute.getBinding())) { try { attribute.setSize(Integer.parseInt(size)); if (attribute.getSize() <= 0) { sizeField.error(new ParamResourceModel("notPositive", this)); valid = false; } } catch (Exception e) { sizeField.error(new ParamResourceModel("notInteger", this, size)); valid = false; } } if (Geometry.class.isAssignableFrom(attribute.getBinding()) && attribute.getCrs() == null) { crsField.error((IValidationError) new ValidationError().addMessageKey("Required")); valid = false; } return valid; }
/** * Returns the underlying CRS for the panel. * * <p>This method is convenience for: * * <pre> * (CoordinateReferenceSystem) this.getModelObject(); * </pre> */ public CoordinateReferenceSystem getCRS() { // convertInput(); return getModelObject(); }
@Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { // perform manual processing of the required fields form.process(null); form.visitFormComponents(new FeedbackMessageCleaner<>(FeedbackMessage.UNDEFINED)); ReferencedEnvelope nativeBounds = (ReferencedEnvelope) nativeBBox.getModelObject(); try { // if the native bounds are not around compute them if (nativeBounds == null) { ResourceInfo resource = (ResourceInfo) BasicResourceConfig.this.getDefaultModelObject(); CatalogBuilder cb = new CatalogBuilder(GeoServerApplication.get().getCatalog()); nativeBounds = cb.getNativeBounds(resource); resource.setNativeBoundingBox(nativeBounds); nativeBBox.setModelObject(nativeBounds); target.add(nativeBBox); } CatalogBuilder cb = new CatalogBuilder(GeoServerApplication.get().getCatalog()); latLonPanel.setModelObject( cb.getLatLonBounds(nativeBounds, declaredCRS.getCRS())); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Error computing the geographic BBOX", e); error("Error computing the geographic bounds:" + e.getMessage()); } target.add(latLonPanel); }
new CRSPanel( "nativeSRS", new PropertyModel<CoordinateReferenceSystem>(model, "nativeCRS")); nativeCRS.setReadOnly(true); refForm.add(nativeCRS); declaredCRS = new CRSPanel( "declaredSRS", new SRSToCRSModel(new PropertyModel<String>(model, "sRS"))); declaredCRS.setRequired(true); refForm.add(declaredCRS);
void initComponents() { updateFields(); add(minXLabel = new Label("minXL", new ResourceModel("minX"))); add(minYLabel = new Label("minYL", new ResourceModel("minY"))); add(minZLabel = new Label("minZL", new ResourceModel("minZ"))); add(maxXLabel = new Label("maxXL", new ResourceModel("maxX"))); add(maxYLabel = new Label("maxYL", new ResourceModel("maxY"))); add(maxZLabel = new Label("maxZL", new ResourceModel("maxZ"))); add(minXInput = new DecimalTextField("minX", new PropertyModel<Double>(this, "minX"))); add(minYInput = new DecimalTextField("minY", new PropertyModel<Double>(this, "minY"))); add(minZInput = new DecimalTextField("minZ", new PropertyModel<Double>(this, "minZ"))); add(maxXInput = new DecimalTextField("maxX", new PropertyModel<Double>(this, "maxX"))); add(maxYInput = new DecimalTextField("maxY", new PropertyModel<Double>(this, "maxY"))); add(maxZInput = new DecimalTextField("maxZ", new PropertyModel<Double>(this, "maxZ"))); minZInput.setVisible(is3D()); minZLabel.setVisible(is3D()); maxZInput.setVisible(is3D()); maxZLabel.setVisible(is3D()); crsContainer = new WebMarkupContainer("crsContainer"); crsContainer.setVisible(false); crsPanel = new CRSPanel("crs", new PropertyModel<CoordinateReferenceSystem>(this, "crs")); crsContainer.add(crsPanel); add(crsContainer); }
@Override public void onClick(AjaxRequestTarget target, Form<?> form) { popupWindow.setInitialHeight(375); popupWindow.setInitialWidth(525); popupWindow.setContent(new WKTPanel(popupWindow.getContentId(), getCRS())); CoordinateReferenceSystem crs = (CoordinateReferenceSystem) CRSPanel.this.getModelObject(); if (crs != null) popupWindow.setTitle(crs.getName().toString()); popupWindow.show(target); } };
@Override protected void onBeforeRender() { CoordinateReferenceSystem crs = (CoordinateReferenceSystem) getModelObject(); if ( crs != null ) { srsTextField.setModelObject( toSRS(crs) ); wktLabel.setDefaultModelObject( crs.getName().toString() ); } else { wktLabel.setDefaultModelObject(null); wktLink.setEnabled(false); } super.onBeforeRender(); }