Package org.eclipse.birt.report.model.api

Examples of org.eclipse.birt.report.model.api.RowHandle


  private static TableHandle createSampleTable(String name, int columnNum, int headerRow, int detailRow, int footerRow, boolean border)
      throws SemanticException {
    TableHandle table = reportDesignHandle.getElementFactory().newTableItem(name, columnNum, headerRow, detailRow, footerRow);

    RowHandle myHeader = (RowHandle) table.getHeader().get(0);
    for (int i = 0; i < myHeader.getCells().getCount(); i++) {
      CellHandle cell = (CellHandle) myHeader.getCells().get(i);
      LabelHandle label = createLabel("Column " + i);
      cell.getContent().add(label);
      if (border) {
        setBorders(cell);
      }
    }

    for (int i = 0; i < table.getDetail().getCount(); i++) {
      RowHandle myDetail = (RowHandle) table.getDetail().get(i);
      for (int j = 0; j < myDetail.getCells().getCount(); j++) {
        CellHandle cell = (CellHandle) myDetail.getCells().get(j);
        LabelHandle label = createLabel("Cell " + i + ":" + j);
        cell.getContent().add(label);
        if (border) {
          setBorders(cell);
        }
View Full Code Here


  }

  private static GridHandle createSampleGrid(String name, int columnNum, int rowNum, boolean border) throws SemanticException {
    GridHandle grid = createGrid(name, columnNum, rowNum);

    RowHandle headerRow = (RowHandle) grid.getRows().get(0);

    for (int i = 0; i < headerRow.getCells().getCount(); i++) {
      CellHandle cell = (CellHandle) headerRow.getCells().get(i);
      if (border) {
        setBorders(cell);
      }
      LabelHandle label = createLabel("Column " + i);
      cell.getContent().add(label);
    }

    RowHandle detailRow = null;
    for (int i = 0; i < rowNum; i++) {
      detailRow = createRow(columnNum);
      for (int j = 0; j < grid.getColumnCount(); j++) {
        CellHandle cell = (CellHandle) detailRow.getCells().get(j);
        if (border) {
          setBorders(cell);
        }
        LabelHandle label = createLabel("Cell " + i + ":" + j);
        cell.getContent().add(label);
      }
      grid.getElement().add(detailRow.getElement(), GridItem.ROW_SLOT);
    }

    return grid;
  }
View Full Code Here

    return label;
  }

  public static void addGridRow(GridHandle grid, boolean border) throws SemanticException {
    int columnNum = grid.getColumnCount();
    RowHandle row = reportDesignHandle.getElementFactory().newTableRow(columnNum);

    if (border) {
      for (int i = 0; i < columnNum; i++) {
        CellHandle cell = (CellHandle) row.getCells().get(i);
        setBorders(cell);
      }
    }

    DesignElement deRow = row.getElement();
    grid.getElement().add(deRow, GridItem.ROW_SLOT);
  }
View Full Code Here

    cs3.setExpression("dataSetRow[\"Amount\"]");
    computedSet.addItem(cs3);

    // Header
    RowHandle myheader = (RowHandle) mytable.getHeader().get(0);

    CellHandle tcell = (CellHandle) myheader.getCells().get(0);
    setBorders(tcell);
    LabelHandle mylabel = elementFactory.newLabel(null);
    mylabel.setText("Col1");
    tcell.getContent().add(mylabel);

    tcell = (CellHandle) myheader.getCells().get(1);
    setBorders(tcell);
    // tcell.setProperty(propName, value);
    mylabel = elementFactory.newLabel(null);
    mylabel.setText("Col2");
    tcell.getContent().add(mylabel);

    tcell = (CellHandle) myheader.getCells().get(2);
    setBorders(tcell);
    mylabel = elementFactory.newLabel(null);
    mylabel.setText("Col3");
    tcell.getContent().add(mylabel);

    RowHandle mydetail = (RowHandle) mytable.getDetail().get(0);
    tcell = (CellHandle) mydetail.getCells().get(0);
    setBorders(tcell);
    DataItemHandle mydata = elementFactory.newDataItem(null);
    mydata.setResultSetColumn("Month");
    tcell.getContent().add(mydata);

    tcell = (CellHandle) mydetail.getCells().get(1);
    mydata = elementFactory.newDataItem(null);
    mydata.setResultSetColumn("Product");
    tcell.getContent().add(mydata);

    CellHandle lastCell = (CellHandle) mydetail.getCells().get(2);
    lastCell.drop();
    tcell.setColumnSpan(2);
    setBorders(tcell);

    mytable.getColumns().get(0).setProperty("width", "45%");
View Full Code Here

    int rowCount = gridHandle.getRows().getCount(); // = 1
    System.out.println("rowCount = " + rowCount);
    int colCount = gridHandle.getColumns().getCount(); // = 1
    // System.out.println("colCount = " + colCount);
    // ############# create row
    RowHandle row = reportDesignHandle.getElementFactory().newTableRow();
    DesignElement deRow = row.getElement();
    gridHandle.getElement().add(deRow, GridItem.ROW_SLOT);

    int rowCount2 = gridHandle.getRows().getCount(); // = 2
    System.out.println("rowCount2 = " + rowCount2);
    int colCount2 = gridHandle.getColumns().getCount(); // = 1
View Full Code Here

      // Add the grid to the report body
      design.getBody().add(grid);

      // create a new row
      RowHandle row = (RowHandle) grid.getRows().get(0);

      // Create a label and add it to the first cell.
      LabelHandle label = efactory.newLabel("Hello, world!");
      label.setText("Hello, World!");
      CellHandle cell = (CellHandle) row.getCells().get(0);
      cell.getContent().add(label);

      // save the report design
      design.saveAs("c:/TEMP/sample.rptdesign");
      design.close();
View Full Code Here

                columnList.size());
        reportTable.setWidth("100%");
        reportTable.setDataSet(dataSetHandleToUse);

        // create a new detail row and add to the report
        RowHandle detailRow = (RowHandle) reportTable.getDetail()
            .get(0);
        int x = 0; // used to mark current column position

        // go through column list and create a new column binding,
        // otherwise data will not be populated into the report
        // Then add a new column to our row
        for (Iterator i = columnList.iterator(); i.hasNext();) {
          String columnName = (String) i.next();

          ComputedColumn computedColumn = StructureFactory
              .createComputedColumn();
          computedColumn.setName(columnName);
          computedColumn.setExpression("dataSetRow[\"" + columnName
              + "\"]");
          PropertyHandle computedSet = reportTable
              .getColumnBindings();
          reportTable.getColumnBindings().addItem(computedColumn);

          // add new data item and cell
          DataItemHandle data = reportDesign.getElementFactory()
              .newDataItem(columnName);
          data.setResultSetColumn(columnName);
          CellHandle cell = (CellHandle) detailRow.getCells().get(x);
          cell.getContent().add(data);
          x++; // advance position
        }

        // add the table to my report
View Full Code Here

        cs1.setExpression("dataSetRow[\"" + (String) cols.get(i) + "\"]");
        computedSet.addItem(cs1);
      }

      // table header
      RowHandle tableheader = (RowHandle) table.getHeader().get(0);

      for( int i = 0 ; i < cols.size() ; i++ ) {
        LabelHandle label1 = designFactory.newLabel((String) cols.get(i));
        label1.setText((String) cols.get(i));
        CellHandle cell = (CellHandle) tableheader.getCells().get(i);
        cell.getContent().add(label1);
      }

      // table detail
      RowHandle tabledetail = (RowHandle) table.getDetail().get(0);

      for( int i = 0 ; i < cols.size() ; i++ ) {
        CellHandle cell = (CellHandle) tabledetail.getCells().get(i);
        DataItemHandle data = designFactory.newDataItem("data_" + (String) cols.get(i));
        data.setResultSetColumn((String) cols.get(i));
        cell.getContent().add(data);
      }
View Full Code Here

    cs5.setAggregateOn("MyGroup");
    cs5.setAggregateFunction("SUM");
    computedSet.addItem(cs5);

    // Header
    RowHandle header = (RowHandle) table.getHeader().get(0);

    CellHandle tcell = (CellHandle) header.getCells().get(0);
    tcell.getWidth().setStringValue("3in");
    LabelHandle label = elementFactory.newLabel(null);
    label.setText("Order");//$NON-NLS-1$
    tcell.getContent().add(label);

    tcell = (CellHandle) header.getCells().get(1);
    label = elementFactory.newLabel(null);
    label.setText("Product");//$NON-NLS-1$
    tcell.getContent().add(label);

    tcell = (CellHandle) header.getCells().get(2);
    label = elementFactory.newLabel(null);
    label.setText("Amount");//$NON-NLS-1$
    tcell.getContent().add(label);

    // Table Group
    TableGroupHandle group = elementFactory.newTableGroup();
    group.setName("MyGroup");
    group.setKeyExpr("dataSetRow[\"ORDERNUMBER\"]");
    group.setInterval("none");
    group.setSortDirection("asc");

    table.getGroups().add(group);

    RowHandle groupHeader = elementFactory.newTableRow(3);
    tcell = (CellHandle) groupHeader.getCells().get(0);
    DataItemHandle data = elementFactory.newDataItem(null);

    data.setResultSetColumn(cs1.getName());
    tcell.getContent().add(data);
    group.getHeader().add(groupHeader);

    RowHandle groupFooter = elementFactory.newTableRow(3);
    tcell = (CellHandle) groupFooter.getCells().get(2);
    data = elementFactory.newDataItem(null);
    data.setResultSetColumn(cs5.getName());
    tcell.getContent().add(data);

    group.getFooter().add(groupFooter);
    RowHandle detail = (RowHandle) table.getDetail().get(0);
    data = elementFactory.newDataItem(null);

    tcell = (CellHandle) detail.getCells().get(1);
    data = elementFactory.newDataItem(null);
    data.setResultSetColumn(cs2.getName());
    tcell.getContent().add(data);

    tcell = (CellHandle) detail.getCells().get(2);
    data = elementFactory.newDataItem(null);
    data.setResultSetColumn(cs3.getName());
    tcell.getContent().add(data);

    RowHandle footer = (RowHandle) table.getFooter().get(0);
    tcell = (CellHandle) footer.getCells().get(2);
    data = elementFactory.newDataItem(null);
    data.setResultSetColumn(cs4.getName());
    tcell.getContent().add(data);

    reportDesignHandle.getBody().add(table);
View Full Code Here

TOP

Related Classes of org.eclipse.birt.report.model.api.RowHandle

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.