Exemplo n.º 1
0
  @Override
  protected Object getProcessedValue(OptionProcessingContext context) {
    Integer result = null;
    String valueAsString = context.getValueAsString();
    try {
      result = StringUtils.isNotBlank(valueAsString) ? Integer.parseInt(valueAsString) : null;
    } catch (NumberFormatException e) {
      throw new DandelionException(
          "The value '" + valueAsString + "' cannot be parsed to Integer", e);
    }

    return result;
  }
Exemplo n.º 2
0
 public HtmlColumn(
     Boolean isHeader,
     String content,
     Map<String, String> dynamicAttributes,
     String displayTypes) {
   setHeaderColumn(isHeader);
   if (isHeader) {
     this.columnConfiguration = new ColumnConfiguration();
   }
   if (content != null) {
     setContent(new StringBuilder(content));
   }
   this.dynamicAttributes = dynamicAttributes;
   if (StringUtils.isNotBlank(displayTypes)) {
     String[] displayTypesTab = displayTypes.trim().split(",");
     for (String displayType : displayTypesTab) {
       this.enabledDisplayTypes.add(displayType.toLowerCase().trim());
     }
   } else {
     enabledDisplayTypes.add(ReservedFormat.ALL);
   }
 }
Exemplo n.º 3
0
  @Override
  protected StringBuilder getHtmlAttributes() {
    StringBuilder html = new StringBuilder();
    if (this.isHeaderColumn) {
      html.append(
          writeAttribute(
              "class",
              DatatableOptions.CSSCLASS.valueFrom(this.getColumnConfiguration().getOptions())));
      html.append(
          writeAttribute(
              "style",
              DatatableOptions.CSSSTYLE.valueFrom(this.getColumnConfiguration().getOptions())));

      String columnId = DatatableOptions.ID.valueFrom(this.getColumnConfiguration().getOptions());
      if (StringUtils.isNotBlank(columnId)) {
        html.append(writeAttribute("id", columnId));
      }
    } else {
      html.append(writeAttribute("class", this.cssCellClass));
      html.append(writeAttribute("style", this.cssCellStyle));
    }
    return html;
  }
  @Override
  public void setup(HtmlTable table) {

    this.table = table;

    // If the export has been configured to be triggered with a POST, PUT or
    // DELETE HTTP method, a custom plugin must be added to the page
    for (ExportConf exportConf : table.getTableConfiguration().getExportConfiguration().values()) {
      if (exportConf.getMethod().equals(HttpMethod.POST)
          || exportConf.getMethod().equals(HttpMethod.PUT)
          || exportConf.getMethod().equals(HttpMethod.DELETE)) {
        addBundle(DatatableBundles.JQUERY_DOWNLOAD);
      }
    }

    String exportContainerStyle =
        DatatableOptions.EXPORT_CONTAINER_STYLE.valueFrom(table.getTableConfiguration());
    String exportContainerClass =
        DatatableOptions.EXPORT_CONTAINER_CLASS.valueFrom(table.getTableConfiguration());

    // In order to be easily positioned around the table, a DataTable
    // feature is created
    ExtraHtml extraHtml = new ExtraHtml();
    extraHtml.setUid("E");
    extraHtml.setContainer("div");
    extraHtml.setCssClass(
        "dataTables_export "
            + (StringUtils.isNotBlank(exportContainerClass) ? exportContainerClass : ""));
    extraHtml.setCssStyle(
        StringUtils.isNotBlank(exportContainerStyle) ? exportContainerStyle : "float: right;");

    String dom = DatatableOptions.FEATURE_DOM.valueFrom(table.getTableConfiguration());
    if (table.getTableConfiguration().getConfigurations().containsKey(DatatableOptions.CSS_THEME)
        && table
            .getTableConfiguration()
            .getConfigurations()
            .get(DatatableOptions.CSS_THEME)
            .getClass()
            .getSimpleName()
            .equals("JQueryUITheme")) {
      addParameter(
          DTConstants.DT_DOM,
          "<'" + TOOLBAR_PREXIX + "-tr'lEfr>t<'" + TOOLBAR_PREXIX + "-br'ip>",
          Mode.OVERRIDE);
    } else if (StringUtils.isBlank(dom)) {
      addParameter(DTConstants.DT_DOM, "lEfrtip", Mode.OVERRIDE);
    }

    StringBuilder content = new StringBuilder();
    HtmlHyperlink link = null;

    // A HTML link is generated for each ExportConf bean
    for (ExportConf conf : table.getTableConfiguration().getExportConfiguration().values()) {

      link = new HtmlHyperlink();

      if (conf.getCssClass() != null) {
        link.setCssClass(conf.getCssClass());
      }

      if (conf.getCssStyle() != null) {
        link.setCssStyle(conf.getCssStyle());
        link.addCssStyle(";margin-left:2px;");
      } else {
        link.addCssStyle("margin-left:2px;");
      }

      if (conf.hasCustomUrl()) {
        link.setOnclick(getOnclick(conf));
      } else {
        link.setHref(conf.getUrl());
      }
      link.addContent(conf.getLabel());
      content.append(link.toHtml());
    }
    extraHtml.setContent(content.toString());

    // Once created, the extraHtml is transformed into Javascript and
    // appended in the DataTables configuration
    appendToAfterStartDocumentReady(extraHtml.getJavascript().toString());
  }