Package ro.fortsoft.wicket.pivot

Examples of ro.fortsoft.wicket.pivot.PivotTableRenderModel$HeaderRenderRow


    }
  }

  @Override
  public void exportPivot(PivotModel pivotModel, OutputStream outputStream) throws IOException {
    PivotTableRenderModel renderModel = PivotTableRenderModel.create(pivotModel);

    HSSFWorkbook wb = new HSSFWorkbook();
    Sheet sheetData = wb.createSheet("Pivot");

    Map<Integer, Integer> rowSpanMap = new HashMap<Integer, Integer>();
    StyleContext styleContext = new StyleContext(wb);

    int rowNumber = 0;
    int maxColNum = 0;
    for (RenderRow row : renderModel.getAllRenderRows()) {
      int col = 0;
      Row poiRow = sheetData.createRow(rowNumber);
      for (RenderCell cell : row.getRenderCells()) {
        maxColNum = Math.max(maxColNum, col);
View Full Code Here


  @Override
  protected void onInitialize() {
    super.onInitialize();

    PivotModel pivotModel = getModelObject();
    PivotTableRenderModel renderModel =  PivotTableRenderModel.create(pivotModel);

    // rendering header
    RepeatingView column = new RepeatingView("header");
    add(column);

    Component tmp = null;
    for (HeaderRenderRow row : renderModel.getHeaderRows()) {
      // rendering row header (first columns)
      WebMarkupContainer tr = new WebMarkupContainer(column.newChildId());
      column.add(tr);
      RepeatingView rowHeader = new RepeatingView("rowHeader");
      tr.add(rowHeader);

      for (HeaderRenderCell cell : row.getRowHeader()) {
        if (cell.getPivotField() == null) {
          // rendering an empty cell
          tmp = new Label(rowHeader.newChildId(), "");
          tmp.add(AttributeModifier.append("class", "empty"));
          applyRowColSpan(cell, tmp);
          rowHeader.add(tmp);
        } else {
          // rendering row field
          tmp = createTitleLabel(rowHeader.newChildId(), cell.getPivotField());
          applyRowColSpan(cell, tmp);
          rowHeader.add(tmp);
        }
      }

      // rendering column keys
      RepeatingView value = new RepeatingView("value");
      tr.add(value);
      for (RenderCell cell : row.getValueCells()) {
        if (cell instanceof HeaderValueRenderCell) {
          HeaderValueRenderCell headerValueRenderCell = (HeaderValueRenderCell) cell;
          tmp = createValueLabel(value.newChildId(), headerValueRenderCell.getRawValue(),
              headerValueRenderCell.getPivotField());
          applyRowColSpan(cell, tmp);
          value.add(tmp);
        } else {
          HeaderRenderCell headerRenderCell = (HeaderRenderCell) cell;
          tmp = createTitleLabel(value.newChildId(), headerRenderCell.getPivotField());
          applyRowColSpan(cell, tmp);
          value.add(tmp);
        }
      }

      // rendering grand total column
      RepeatingView grandTotalColumn = new RepeatingView("grandTotalColumn");
      for (RenderCell cell : row.getGrandTotalColumn()) {
        if (cell instanceof GrandTotalHeaderRenderCell) {
          GrandTotalHeaderRenderCell grandTotalHeaderRenderCell = (GrandTotalHeaderRenderCell) cell;
          if (grandTotalHeaderRenderCell.getRawValue() != null) {
            tmp = new Label(grandTotalColumn.newChildId(), grandTotalHeaderRenderCell.getRawValue()
                .toString());
            applyRowColSpan(cell, tmp);
            grandTotalColumn.add(tmp);
          } else {
            tmp = new WebMarkupContainer(grandTotalColumn.newChildId());
            applyRowColSpan(cell, tmp);
            tmp.add(AttributeModifier.append("class", "empty"));
            grandTotalColumn.add(tmp);
          }
        } else {
          HeaderRenderCell headerCell = (HeaderRenderCell) cell;
          tmp = createTitleLabel(value.newChildId(), headerCell.getPivotField());
          applyRowColSpan(cell, tmp);
          grandTotalColumn.add(tmp);
        }
      }
      grandTotalColumn.setVisible(row.getGrandTotalColumn().size() > 0);
      tr.add(grandTotalColumn);
    }

    // rendering rows
    RepeatingView row = new RepeatingView("row");
    add(row);
    for (DataRenderRow renderRow : renderModel.getValueRows()) {
      WebMarkupContainer tr = new WebMarkupContainer(row.newChildId());
      row.add(tr);
      RepeatingView rowHeader = new RepeatingView("rowHeader");
      tr.add(rowHeader);

      for (DataHeaderRenderCell cell : renderRow.getRowHeader()) {
        tmp = createValueLabel(rowHeader.newChildId(), cell.getRawValue(), cell.getPivotField());
        applyRowColSpan(cell, tmp);
        rowHeader.add(tmp);
      }

      RepeatingView value = new RepeatingView("value");
      tr.add(value);

      for (RenderCell cell : renderRow.getValue()) {
        if (cell instanceof DataValueRenderCell) {
          tmp = createValueLabel(value.newChildId(), cell.getRawValue(), cell.getPivotField());
          applyRowColSpan(cell, tmp);
          value.add(tmp);
        } else {
          GrandTotalValueRenderCell grandTotalCell = (GrandTotalValueRenderCell) cell;
          tmp = createGrandTotalLabel(value.newChildId(), grandTotalCell.getRawValue(), grandTotalCell.isForRow());
          applyRowColSpan(cell, tmp);
          tmp.add(AttributeModifier.append("class", "grand-total"));
          value.add(tmp);
        }
      }
    }

    WebMarkupContainer grandTotalRow = new WebMarkupContainer("grandTotalRow");
    grandTotalRow.setVisible(renderModel.getGrandTotalRows().size() > 0);
    add(grandTotalRow);
    /*
     * We currently expect exactly one GrantTotalRenderRow, therefor we dont
     * need a repeating viewer
     */
    for (GrandTotalRenderRow grantTotalRenderRow : renderModel.getGrandTotalRows()) {
      for (GrandTotalRowHeaderRenderCell cell : grantTotalRenderRow.getRowHeader()) {
        Label grandTotalRowHeader = new Label("rowHeader", "Grand Total");
        applyRowColSpan(cell, grandTotalRowHeader);
        grandTotalRow.add(grandTotalRowHeader);
      }
View Full Code Here

  private static final long serialVersionUID = 1L;
  private String seperator = ";";

  @Override 
  public void exportPivot(PivotModel pivotModel, OutputStream outputStream) throws IOException {
    PivotTableRenderModel renderModel = PivotTableRenderModel.create(pivotModel);

    OutputStreamWriter out = new OutputStreamWriter(outputStream, Charset.forName("UTF-8"));
    Map<Integer, Integer> rowSpanMap = new HashMap<Integer, Integer>();

    for (RenderRow row : renderModel.getAllRenderRows()) {
      int col = 0;
      for (RenderCell cell : row.getRenderCells()) {
        /*
         * Check if we currently have a rowspan at this column from the
         * parent row. We only support a colspan of 1 at the moment
View Full Code Here

TOP

Related Classes of ro.fortsoft.wicket.pivot.PivotTableRenderModel$HeaderRenderRow

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.