예제 #1
0
  public String getHtmlDisplay(TableModel model, Column column) {
    HtmlBuilder html = new HtmlBuilder();

    String headerClass = null;
    String sortImage = null;
    String sortOrder = null;

    headerClass = column.getHeaderClass();

    if (TableModelUtils.isSorted(model, column.getAlias())) {
      sortOrder = model.getLimit().getSort().getSortOrder();

      if (sortOrder.equals(TableConstants.SORT_DEFAULT)) {
        sortOrder = TableConstants.SORT_ASC;
      } else if (sortOrder.equals(TableConstants.SORT_ASC)) {
        headerClass =
            model.getPreferences().getPreference(PreferencesConstants.TABLE_HEADER_SORT_CLASS);
        sortImage = BuilderUtils.getImage(model, BuilderConstants.SORT_ASC_IMAGE);
        sortOrder = TableConstants.SORT_DESC;
      } else if (sortOrder.equals(TableConstants.SORT_DESC)) {
        headerClass =
            model.getPreferences().getPreference(PreferencesConstants.TABLE_HEADER_SORT_CLASS);
        sortImage = BuilderUtils.getImage(model, BuilderConstants.SORT_DESC_IMAGE);
        sortOrder = TableConstants.SORT_DEFAULT;
      }
    } else {
      sortOrder = TableConstants.SORT_ASC; // the default
    }

    buildHeaderHtml(html, model, column, headerClass, sortImage, sortOrder);

    return html.toString();
  }
예제 #2
0
  public void body(TableModel model, Column column) {
    if (column.isFirstColumn()) {
      rownum++;
      cellnum = 0;
      hssfRow = sheet.createRow(rownum);
    }
    String value = column.getCellDisplay();
    if (StringUtils.isNumeric(value)) {
      value = column.getValue() == null ? "" : column.getValue().toString();
    }
    value = value.replaceAll("\t", "").replaceAll("\n", "");
    value = ExportViewUtils.parseXLS(value);

    HSSFCell hssfCell = hssfRow.createCell(cellnum);

    // modify by springside
    // hssfCell.setEncoding(HSSFCell.ENCODING_UTF_16);
    // end of modify by springside

    if (column.isEscapeAutoFormat()) {
      writeToCellAsText(hssfCell, value);
    } else {
      writeToCellFormatted(hssfCell, value);
    }
    cellnum++;
  }
예제 #3
0
    public String header(TableModel model) {
        StringBuffer sb = new StringBuffer();

        Export export = model.getExportHandler().getCurrentExport();
        String headerColor = export.getAttributeAsString(HEADER_COLOR);
        String headerBackgroundColor = export.getAttributeAsString(HEADER_BACKGROUND_COLOR);

        sb.append(" <fo:table-header background-color=\"" + headerBackgroundColor + "\" color=\"" + headerColor + "\"> ");

        sb.append(" <fo:table-row> ");

        List columns = model.getColumnHandler().getHeaderColumns();
        for (Iterator iter = columns.iterator(); iter.hasNext();) {
            Column column = (Column) iter.next();
            String title = column.getCellDisplay();
            sb.append(" <fo:table-cell border=\"solid silver .5px\" text-align=\"center\" display-align=\"center\" padding=\"3pt\"> ");
            sb.append(" <fo:block" + getFont() + ">" + title + "</fo:block> ");
            sb.append(" </fo:table-cell> ");
        }

        sb.append(" </fo:table-row> ");

        sb.append(" </fo:table-header> ");

        return sb.toString();
    }
예제 #4
0
  /** {@inheritDoc} */
  @Override
  public void addColumnAttributes(TableModel arg0, Column arg1) {
    String value = arg1.getPropertyValueAsString();

    // String style = "width:5%";
    arg1.setStyle(value);
    arg1.setFilterStyle(value);
    arg1.setWidth("100");
    arg1.addAttribute("width", Integer.toString(100));
  }
예제 #5
0
 protected String getCellValue(TableModel tableModel, Column column) {
   if (column.getValue() == null) return "Invalid Entry";
   else {
     if (column.getValue() instanceof Integer) {
       Integer stratumGroupNumber = (Integer) column.getValue();
       if (stratumGroupNumber < 0) {
         return "Invalid Entry";
       }
     }
   }
   return column.getValueAsString();
 }
예제 #6
0
    public void body(TableModel model, Column column) {
        if (column.isFirstColumn()) {
            xlsfo.append(" <fo:table-row> ");
        }

        String value = ExportViewUtils.parsePDF(column.getCellDisplay());

        xlsfo.append(" <fo:table-cell border=\"solid silver .5px\" display-align=\"center\" padding=\"3pt\"> ");
        xlsfo.append(" <fo:block" + getFont() + ">" + value + "</fo:block> ");
        xlsfo.append(" </fo:table-cell> ");

        if (column.isLastColumn()) {
            xlsfo.append(" </fo:table-row> ");
        }
    }
예제 #7
0
  private void createHeader(TableModel model) {
    rownum = 0;
    cellnum = 0;
    HSSFRow row = sheet.createRow(rownum);

    List columns = model.getColumnHandler().getHeaderColumns();
    for (Iterator iter = columns.iterator(); iter.hasNext(); ) {
      Column column = (Column) iter.next();
      String title = column.getCellDisplay();
      HSSFCell cell = row.createCell(cellnum);

      // modify by springside
      // cell.setEncoding(HSSFCell.ENCODING_UTF_16);
      // end of modify by springside

      cell.setCellStyle((HSSFCellStyle) styles.get("titleStyle"));
      cell.setCellType(HSSFCell.CELL_TYPE_STRING);
      cell.setCellValue(title);
      int valWidth = (title + "").length() * WIDTH_MULT;
      sheet.setColumnWidth(cell.getCellNum(), (short) valWidth);

      cellnum++;
    }
  }
예제 #8
0
    /**
     * TWEST - New Method that answers a StringBuffer containing the totals
     * information. If no totals exist on the model answer an empty buffer.
     * 
     * The totals row will be given the same style as the header row.
     * 
     * @param model
     * @return StringBuffer containing the complete fo statement for totals
     */
    public StringBuffer totals(TableModel model) {

        StringBuffer sb = new StringBuffer();
        Export export = model.getExportHandler().getCurrentExport();
        String headerColor = export.getAttributeAsString(HEADER_COLOR);
        String headerBackgroundColor = export.getAttributeAsString(HEADER_BACKGROUND_COLOR);

        Column firstCalcColumn = model.getColumnHandler().getFirstCalcColumn();

        if (firstCalcColumn != null) {
            int rows = firstCalcColumn.getCalc().length;
            for (int i = 0; i < rows; i++) {
                sb.append("<fo:table-row>");
                for (Iterator iter = model.getColumnHandler().getColumns().iterator(); iter.hasNext();) {
                    Column column = (Column) iter.next();
                    if (column.isFirstColumn()) {
                        String calcTitle = CalcUtils.getFirstCalcColumnTitleByPosition(model, i);
                        sb.append(" <fo:table-cell border=\"solid silver .5px\" text-align=\"center\" display-align=\"center\" padding=\"3pt\" background-color=\"");
                        sb.append(headerBackgroundColor + "\" color=\"" + headerColor + "\">");
                        sb.append(" <fo:block " + getFont() + ">" + calcTitle);
                        sb.append(" </fo:block></fo:table-cell> ");
                        continue;
                    }
                    if (column.isCalculated()) {
                        sb.append(" <fo:table-cell border=\"solid silver .5px\" text-align=\"center\" display-align=\"center\" padding=\"3pt\" background-color=\"");
                        sb.append(headerBackgroundColor + "\" color=\"" + headerColor + "\"> ");
                        sb.append(" <fo:block " + getFont() + ">");
                        CalcResult calcResult = CalcUtils.getCalcResultsByPosition(model, column, i);
                        Number value = calcResult.getValue();
                        if (value != null) {
                            sb.append(ExtremeUtils.formatNumber(column.getFormat(), value, model.getLocale()));
                        } else {
                            sb.append("n/a");
                        }
                        sb.append("</fo:block> ");
                    } else {
                        sb.append(" <fo:table-cell border=\"solid silver .5px\" text-align=\"center\" display-align=\"center\" padding=\"3pt\" background-color=\"");
                        sb.append(headerBackgroundColor + "\" color=\"" + headerColor + "\"> ");
                        sb.append(" <fo:block " + getFont() + ">");
                        sb.append(" ");
                        sb.append("</fo:block> ");
                    }
                    sb.append(" </fo:table-cell> ");
                }
                sb.append("</fo:table-row>");

            }
        }
        return sb;
    }
예제 #9
0
  protected void buildHeaderHtml(
      HtmlBuilder html,
      TableModel model,
      Column column,
      String headerClass,
      String sortImage,
      String sortOrder) {
    html.td(2);

    if (StringUtils.isNotEmpty(headerClass)) {
      html.styleClass(headerClass);
    }

    if (StringUtils.isNotEmpty(column.getHeaderStyle())) {
      html.style(column.getHeaderStyle());
    }

    if (StringUtils.isNotEmpty(column.getWidth())) {
      html.width(column.getWidth());
    }

    if (column.isSortable()) {
      if (sortOrder.equals(TableConstants.SORT_ASC)) {
        html.onmouseover(
            "this.className='"
                + BuilderConstants.TABLE_HEADER_SORT_CSS
                + "';this.style.cursor='pointer'");
        if (StringUtils.isNotEmpty(headerClass)) {
          html.onmouseout("this.className='" + headerClass + "';this.style.cursor='default'");
        } else {
          html.onmouseout(
              "this.className='"
                  + BuilderConstants.TABLE_HEADER_CSS
                  + "';this.style.cursor='default'");
        }
      }

      if (sortOrder.equals(TableConstants.SORT_DEFAULT)
          || sortOrder.equals(TableConstants.SORT_DESC)) {
        html.onmouseover("this.style.cursor='pointer'");
        html.onmouseout("this.style.cursor='default'");
      }

      html.onclick(new TableActions(model).getSortAction(column, sortOrder));

      boolean showTooltips = model.getTableHandler().getTable().isShowTooltips();
      if (showTooltips) {
        String headercellTooltip =
            model.getMessages().getMessage(MessagesConstants.COLUMN_HEADERCELL_TOOLTIP_SORT);
        html.title(headercellTooltip + " " + column.getTitle());
      }
    }

    html.close();

    html.append(column.getTitle());

    if (column.isSortable()) {
      if (StringUtils.isNotEmpty(sortImage)) {
        html.nbsp();
        html.img();
        html.src(sortImage);
        html.style("border:0");
        html.alt("Arrow");
        html.xclose();
      }
    }

    html.tdEnd();
  }
예제 #10
0
 public String getExportDisplay(TableModel model, Column column) {
   return column.getTitle();
 }
예제 #11
0
  public Object build(TableModel model, Collection studies, String title, String action)
      throws Exception {

    Table table = model.getTableInstance();
    table.setTitle(title);

    table.setAction(model.getContext().getContextPath() + action);
    table.setTableId("studies");
    table.setItems(studies);
    table.setOnInvokeAction("buildTable('studies')");
    table.setShowPagination(false);
    table.setSortable(true);
    table.setShowExports(false);
    table.setImagePath(model.getContext().getContextPath() + "/images/table/*.gif");
    model.addTable(table);

    Row row = model.getRowInstance();
    row.setInterceptor("edu.duke.cabig.c3pr.web.ajax.StudyRowInterceptor");
    model.addRow(row);

    Column columnTitle = model.getColumnInstance();
    columnTitle.setTitle("Short Title");
    columnTitle.setProperty("shortTitleText");
    model.addColumn(columnTitle);

    Column columnIdentifier = model.getColumnInstance();
    columnIdentifier.setProperty("primaryIdentifier");
    model.addColumn(columnIdentifier);

    Column columnPhase = model.getColumnInstance();
    columnPhase.setTitle("Phase");
    columnPhase.setProperty("phaseCode");
    model.addColumn(columnPhase);

    Column columnStatus = model.getColumnInstance();
    columnStatus.setTitle("Status");
    columnStatus.setProperty("coordinatingCenterStudyStatus.code");
    model.addColumn(columnStatus);

    Column columnCompanion = model.getColumnInstance();
    columnCompanion.setTitle("Companion Indicator");
    columnCompanion.setProperty("companionIndicatorDisplayValue");
    model.addColumn(columnCompanion);

    // Column columnSite = model.getColumnInstance();
    // columnSite.setTitle("Sites");
    // columnSite.setProperty("printStudySites");
    // model.addColumn(columnSite);

    return model.assemble();
  }