public WmsEoAddLayerPage() {
    IModel<WmsEoAddLayerModel> model = new Model<WmsEoAddLayerModel>(new WmsEoAddLayerModel());

    // build the form
    Form<WmsEoAddLayerModel> paramsForm = new Form<WmsEoAddLayerModel>("addLayerForm", model);
    add(paramsForm);

    LayerGroupPanel groupPanel =
        new LayerGroupPanel(
            "groupPanel",
            new PropertyModel<LayerGroupInfo>(model, "group"),
            new ResourceModel("group", "WMS-EO Group"),
            true,
            new LayerGroupInfoFilter() {
              @Override
              public boolean accept(LayerGroupInfo group) {
                return LayerGroupInfo.Mode.EO.equals(group.getMode());
              }
            });
    paramsForm.add(groupPanel);

    paramsForm.add(
        getTextParamPanel(
            "parameterLayerName", GEOPHYSICAL_PARAMETER.getObject() + " Layer Name", model, false));
    paramsForm.add(
        getDirectoryPanel(
            "parameterUrl", GEOPHYSICAL_PARAMETER.getObject() + " URL", model, false));
    paramsForm.add(
        getTextParamPanel("bitmaskLayerName", BITMASK.getObject() + " Layer Name", model, false));
    paramsForm.add(getDirectoryPanel("bitmaskUrl", BITMASK.getObject() + " URL", model, false));

    // cancel / submit buttons
    AjaxSubmitLink submitLink = saveLink(paramsForm);
    paramsForm.add(new BookmarkablePageLink<StorePage>("cancel", WmsEoAddLayerPage.class));
    paramsForm.add(submitLink);
    paramsForm.setDefaultButton(submitLink);

    // feedback panel for error messages
    paramsForm.add(new FeedbackPanel("feedback"));
  }
예제 #2
0
  /** Builds a new table panel */
  public GeoServerTablePanel(
      final String id, final GeoServerDataProvider<T> dataProvider, final boolean selectable) {
    super(id);
    this.dataProvider = dataProvider;

    // prepare the selection array
    selection = new boolean[DEFAULT_ITEMS_PER_PAGE];

    // layer container used for ajax-y udpates of the table
    listContainer = new WebMarkupContainer("listContainer");

    // build the filter form
    filterForm =
        new Form("filterForm") {
          @Override
          public void renderHead(IHeaderResponse response) {
            if (isRootForm()) return;

            // in subforms (on dialogs) the forms onsubmit doesn;t forward to the submit links
            // onclick, so we manually do it outselves
            String markupId = filterForm.getMarkupId();
            String js =
                "if (Wicket.Browser.isSafari() || Wicket.Browser.isIE()) {"
                    + "n = document.getElementById('"
                    + markupId
                    + "'); "
                    + "while (n.nodeName.toLowerCase() != 'form') { n = n.parentElement; }; "
                    + "n.setAttribute('onsubmit', \"return document.getElementById('"
                    + hiddenSubmit.getMarkupId()
                    + "').onclick();\");"
                    + "}";
            response.renderOnLoadJavascript(js);
          }
        };
    filterForm.setOutputMarkupId(true);
    add(filterForm);
    filterForm.add(filter = new TextField("filter", new Model()));
    filter.add(
        new SimpleAttributeModifier(
            "title",
            String.valueOf(new ResourceModel("GeoServerTablePanel.search", "Search").getObject())));
    filterForm.add(hiddenSubmit = hiddenSubmit());
    filterForm.setDefaultButton(hiddenSubmit);

    // setup the table
    listContainer.setOutputMarkupId(true);
    add(listContainer);
    dataView =
        new DataView("items", dataProvider) {

          @Override
          protected void populateItem(Item item) {
            final IModel itemModel = item.getModel();

            // odd/even style
            item.add(
                new SimpleAttributeModifier("class", item.getIndex() % 2 == 0 ? "even" : "odd"));

            // add row selector (visible only if selection is active)
            WebMarkupContainer cnt = new WebMarkupContainer("selectItemContainer");
            cnt.add(selectOneCheckbox(item));
            cnt.setVisible(selectable);
            item.add(cnt);

            // create one component per viewable property
            ListView items =
                new ListView("itemProperties", dataProvider.getVisibleProperties()) {

                  @Override
                  protected void populateItem(ListItem item) {
                    Property<T> property = (Property<T>) item.getModelObject();

                    Component component = getComponentForProperty("component", itemModel, property);

                    if (component == null) {
                      // show a plain label if the the subclass did not create any component
                      component = new Label("component", property.getModel(itemModel));
                    } else if (!"component".equals(component.getId())) {
                      // add some checks for the id, the error message
                      // that wicket returns in case of mismatch is not
                      // that helpful
                      throw new IllegalArgumentException(
                          "getComponentForProperty asked "
                              + "to build a component "
                              + "with id = 'component' "
                              + "for property '"
                              + property.getName()
                              + "', but got '"
                              + component.getId()
                              + "' instead");
                    }
                    item.add(component);
                    onPopulateItem(property, item);
                  }
                };
            items.setReuseItems(true);
            item.add(items);
          }
        };
    dataView.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance());
    listContainer.add(dataView);

    // add select all checkbox
    WebMarkupContainer cnt = new WebMarkupContainer("selectAllContainer");
    cnt.add(selectAll = selectAllCheckbox());
    cnt.setVisible(selectable);
    listContainer.add(cnt);

    // add the sorting links
    listContainer.add(
        new ListView("sortableLinks", dataProvider.getVisibleProperties()) {

          @Override
          protected void populateItem(ListItem item) {
            Property<T> property = (Property<T>) item.getModelObject();

            // build a sortable link if the property is sortable, a label otherwise
            IModel titleModel = getPropertyTitle(property);
            if (sortable && property.getComparator() != null) {
              Fragment f = new Fragment("header", "sortableHeader", item);
              AjaxLink link = sortLink(dataProvider, item);
              link.add(new Label("label", titleModel));
              f.add(link);
              item.add(f);
            } else {
              item.add(new Label("header", titleModel));
            }
          }
        });

    // add the paging navigator and set the items per page
    dataView.setItemsPerPage(DEFAULT_ITEMS_PER_PAGE);
    pagerDelegate = new PagerDelegate();

    filterForm.add(navigatorTop = new Pager("navigatorTop"));
    navigatorTop.setOutputMarkupId(true);
    add(navigatorBottom = new Pager("navigatorBottom"));
    navigatorBottom.setOutputMarkupId(true);
  }
  AttributeEditPage(
      final AttributeDescription attribute,
      final NewFeatureTypePage previousPage,
      final boolean newAttribute) {
    this.previousPage = previousPage;
    this.newAttribute = newAttribute;
    this.attribute = attribute;
    this.size = String.valueOf(attribute.getSize());

    final Form form = new Form("form", new CompoundPropertyModel(attribute));
    form.setOutputMarkupId(true);
    add(form);

    form.add(nameField = new TextField("name"));
    DropDownChoice binding =
        new DropDownChoice("binding", AttributeDescription.BINDINGS, new BindingChoiceRenderer());
    binding.add(
        new AjaxFormSubmitBehavior("onchange") {

          @Override
          protected void onError(AjaxRequestTarget target) {
            updateVisibility(target);
          }

          private void updateVisibility(AjaxRequestTarget target) {
            sizeContainer.setVisible(String.class.equals(attribute.getBinding()));
            crsContainer.setVisible(
                attribute.getBinding() != null
                    && Geometry.class.isAssignableFrom(attribute.getBinding()));

            target.addComponent(getFeedbackPanel());
            target.addComponent(form);
          }

          @Override
          protected void onSubmit(AjaxRequestTarget target) {
            updateVisibility(target);
          }
        });
    form.add(binding);
    form.add(new CheckBox("nullable"));

    sizeContainer = new WebMarkupContainer("sizeContainer");
    sizeContainer.setOutputMarkupId(true);
    form.add(sizeContainer);
    sizeContainer.add(sizeField = new TextField("size", new PropertyModel(this, "size")));
    sizeContainer.setVisible(String.class.equals(attribute.getBinding()));

    crsContainer = new WebMarkupContainer("crsContainer");
    crsContainer.setOutputMarkupId(true);
    form.add(crsContainer);
    crsContainer.add(crsField = new CRSPanel("crs"));
    crsContainer.setVisible(
        attribute.getBinding() != null && Geometry.class.isAssignableFrom(attribute.getBinding()));

    SubmitLink submit =
        new SubmitLink("save") {
          @Override
          public void onSubmit() {
            if (validate()) {
              if (newAttribute) {
                previousPage.attributesProvider.addNewAttribute(attribute);
              }
              setResponsePage(previousPage);
            }
          }
        };
    form.setDefaultButton(submit);
    form.add(submit);
    form.add(
        new Link("cancel") {

          @Override
          public void onClick() {
            setResponsePage(previousPage);
          }
        });
  }