Package org.geoserver.inspire

Examples of org.geoserver.inspire.UniqueResourceIdentifiers


    public UniqueResourceIdentifiersEditor(String id,
            final IModel<UniqueResourceIdentifiers> identifiersModel) {
        super(id, identifiersModel);

        if (identifiersModel.getObject() == null) {
            identifiersModel.setObject(new UniqueResourceIdentifiers());
        }

        // container for ajax updates
        final WebMarkupContainer container = new WebMarkupContainer("container");
        container.setOutputMarkupId(true);
        add(container);

        // the link list
        identifiers = new GeoServerTablePanel<UniqueResourceIdentifier>("identifiers",
                new UniqueResourceIdentifiersProvider(identifiersModel), false) {

            @Override
            protected Component getComponentForProperty(String id, final IModel itemModel,
                    Property<UniqueResourceIdentifier> property) {
                String name = property.getName();
                if ("code".equals(name)) {
                    Fragment codeFragment = new Fragment(id, "txtFragment",
                            UniqueResourceIdentifiersEditor.this);
                    FormComponentFeedbackBorder codeBorder = new FormComponentFeedbackBorder(
                            "border");
                    codeFragment.add(codeBorder);
                    TextField<String> code = new TextField<String>("txt",
                            new PropertyModel<String>(itemModel, "code"));
                    code.setLabel(new ParamResourceModel("th.code", UniqueResourceIdentifiersEditor.this));
                    code.setRequired(true);
                    codeBorder.add(code);
                    return codeFragment;
                } else if ("namespace".equals(name)) {
                    Fragment nsFragment = new Fragment(id, "txtFragment",
                            UniqueResourceIdentifiersEditor.this);
                    FormComponentFeedbackBorder namespaceBorder = new FormComponentFeedbackBorder(
                            "border");
                    nsFragment.add(namespaceBorder);
                    TextField<String> namespace = new TextField<String>("txt",
                            new PropertyModel<String>(itemModel, "namespace"));
                    namespace.setLabel(new ParamResourceModel("th.namespace", UniqueResourceIdentifiersEditor.this));
                    namespace.add(new URIValidator());
                    namespaceBorder.add(namespace);
                    return nsFragment;
                } else if ("metadataURL".equals(name)) {
                    Fragment urlFragment = new Fragment(id, "txtFragment",
                            UniqueResourceIdentifiersEditor.this);
                    FormComponentFeedbackBorder namespaceBorder = new FormComponentFeedbackBorder(
                            "border");
                    urlFragment.add(namespaceBorder);
                    TextField<String> url = new TextField<String>("txt",
                            new PropertyModel<String>(itemModel, "metadataURL"));
                    url.add(new URIValidator());
                    namespaceBorder.add(url);
                    return urlFragment;
                } else if ("remove".equals(name)) {
                    Fragment removeFragment = new Fragment(id, "removeFragment",
                            UniqueResourceIdentifiersEditor.this);
                    GeoServerAjaxFormLink removeLink = new GeoServerAjaxFormLink("remove") {

                        @Override
                        protected void onClick(AjaxRequestTarget target, Form form) {
                            UniqueResourceIdentifiers identifiers = identifiersModel.getObject();
                            UniqueResourceIdentifier sdi = (UniqueResourceIdentifier) itemModel
                                    .getObject();
                            identifiers.remove(sdi);
                            target.addComponent(container);
                        }
                    };
                    removeFragment.add(removeLink);
                    return removeFragment;
                }
                return null;
            }
        };
        identifiers.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance());
        identifiers.setPageable(false);
        identifiers.setSortable(false);
        identifiers.setFilterable(false);
        container.add(identifiers);

        // add new link button
        button = new AjaxButton("addIdentifier") {

            @Override
            protected void onSubmit(AjaxRequestTarget target, Form form) {
                UniqueResourceIdentifiers identifiers = identifiersModel.getObject();
                identifiers.add(new UniqueResourceIdentifier());

                target.addComponent(container);
            }
           
            @Override
            protected void onError(AjaxRequestTarget target, Form<?> form) {
                // the form validator triggered, but we don't want the msg to display
                Session.get().cleanupFeedbackMessages();
                Session.get().dirty();
                onSubmit(target, form);
            }
           
        };
        add(button);
       
        // grab a seat... the way I'm adding this validator in onBeforeRender will be hard
        // to stomach... however, could not find other way to add a validation to an editabl table, grrr
        add(new IValidator<UniqueResourceIdentifiers>() {

            @Override
            public void validate(IValidatable<UniqueResourceIdentifiers> validatable) {
                UniqueResourceIdentifiers identifiers = identifiersModel.getObject();
                if(identifiers.size() == 0) {
                  ValidationError error = new ValidationError();
                  String message = new ParamResourceModel(
                          "noSpatialDatasetIdentifiers", UniqueResourceIdentifiersEditor.this).getString();
                  error.setMessage(message);
                  validatable.error(error);
View Full Code Here


   
   
    @Override
    protected void convertInput() {
        UniqueResourceIdentifiersProvider provider = (UniqueResourceIdentifiersProvider) identifiers.getDataProvider();
        UniqueResourceIdentifiers ids = provider.model.getObject();
        setConvertedInput(ids);
    }
View Full Code Here

        tx.chars(language);
        tx.end("inspire_common:Language");
        tx.end("inspire_common:ResponseLanguage");
       
        // unique spatial dataset identifiers
        UniqueResourceIdentifiers ids = (UniqueResourceIdentifiers) wfs.getMetadata().get(SPATIAL_DATASET_IDENTIFIER_TYPE.key, UniqueResourceIdentifiers.class);
        if(ids != null) {
            for (UniqueResourceIdentifier id : ids) {
                tx.start("inspire_dls:SpatialDataSetIdentifier");
                tx.start("inspire_common:Code");
                tx.chars(id.getCode());
View Full Code Here

        tester.assertModelValue("form:panel:metadataURLType", "application/vnd.iso.19139+xml");

       
        // the spatial identifiers editor
        tester.assertComponent("form:panel:datasetIdentifiersContainer:spatialDatasetIdentifiers", UniqueResourceIdentifiersEditor.class);
        UniqueResourceIdentifiers expected = Converters.convert("one,http://www.geoserver.org/one;two,http://www.geoserver.org/two", UniqueResourceIdentifiers.class);
        tester.assertModelValue("form:panel:datasetIdentifiersContainer:spatialDatasetIdentifiers", expected);
    }
View Full Code Here

TOP

Related Classes of org.geoserver.inspire.UniqueResourceIdentifiers

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.