Пример #1
0
 private static String makeModifiableParameters(TileLayer tl) {
   List<ParameterFilter> parameterFilters = tl.getParameterFilters();
   if (parameterFilters == null || parameterFilters.size() == 0) {
     return "";
   }
   parameterFilters = new ArrayList<ParameterFilter>(parameterFilters);
   Collections.sort(
       parameterFilters,
       new Comparator<ParameterFilter>() {
         public int compare(ParameterFilter o1, ParameterFilter o2) {
           return o1.getKey().compareTo(o2.getKey());
         }
       });
   StringBuilder doc = new StringBuilder();
   doc.append("Modifiable Parameters:\n");
   doc.append("<table>\n");
   for (ParameterFilter pf : parameterFilters) {
     Assert.notNull(pf);
     String key = pf.getKey();
     String defaultValue = pf.getDefaultValue();
     List<String> legalValues = pf.getLegalValues();
     doc.append("<tr><td>").append(key.toUpperCase()).append(": ").append("</td><td>");
     String parameterId = key;
     if (pf instanceof StringParameterFilter) {
       Map<String, String> keysValues = makeParametersMap(defaultValue, legalValues);
       makePullDown(doc, parameterId, keysValues, defaultValue);
     } else if (pf instanceof RegexParameterFilter) {
       makeTextInput(doc, parameterId, 25);
     } else if (pf instanceof FloatParameterFilter) {
       FloatParameterFilter floatParam = (FloatParameterFilter) pf;
       if (floatParam.getValues().isEmpty()) {
         // accepts any value
         makeTextInput(doc, parameterId, 25);
       } else {
         Map<String, String> keysValues = makeParametersMap(defaultValue, legalValues);
         makePullDown(doc, parameterId, keysValues, defaultValue);
       }
     } else if ("org.geowebcache.filter.parameters.NaiveWMSDimensionFilter"
         .equals(pf.getClass().getName())) {
       makeTextInput(doc, parameterId, 25);
     } else {
       // Unknown filter type
       if (legalValues == null) {
         // Doesn't have a defined set of values, just provide a text field
         makeTextInput(doc, parameterId, 25);
       } else {
         // Does have a defined set of values, so provide a drop down
         Map<String, String> keysValues = makeParametersMap(defaultValue, legalValues);
         makePullDown(doc, parameterId, keysValues, defaultValue);
       }
     }
     doc.append("</td></tr>\n");
   }
   doc.append("</table>\n");
   return doc.toString();
 }
Пример #2
0
  /**
   * Add a {@link FloatParameterFilter} set accept anything, replacing any existing filter for the
   * same parameter.
   *
   * @param tileLayerInfo layer to update the filter on
   * @param paramKey key for the parameter
   * @param createParam create a new filter if there is none to replace for the specified key
   */
  public static void updateAcceptAllFloatParameterFilter(
      final GeoServerTileLayerInfo tileLayerInfo, final String paramKey, boolean createParam) {

    createParam |= tileLayerInfo.removeParameterFilter(paramKey);

    if (createParam) {
      FloatParameterFilter filter = new FloatParameterFilter();
      filter.setKey(paramKey);
      filter.setDefaultValue("");
      tileLayerInfo.addParameterFilter(filter);
    }
  }