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

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


    System.out.println("Finished");
  }

  private static void test10() throws SemanticException, IOException {
    TableHandle table = createSampleTable(null, 3, 1, 16, 1, true);
    reportDesignHandle.getBody().add(table);
  }
View Full Code Here


    return reportDesignHandle.getElementFactory().newGridItem(name, columnNum, rowNum);
  }

  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);
        }
      }
    }

    table.setProperty("repeatHeader", "true");
    return table;
  }
View Full Code Here

    computedSet.addItem(cs2);
    computedSet.addItem(cs3);

    reportDesignHandle.getDataSets().add(dataSetHandle);

    TableHandle mytable = elementFactory.newTableItem(null, 3, 1, 1, 1);
    mytable.setWidth("100%");
    mytable.setProperty("dataSet", dataSet);

    computedSet = mytable.getColumnBindings();

    cs1.setExpression("dataSetRow[\"Month\"]");
    computedSet.addItem(cs1);

    cs2.setExpression("dataSetRow[\"Product\"]");
    computedSet.addItem(cs2);

    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%");
    mytable.getColumns().get(1).setProperty("width", "45%");
    mytable.getColumns().get(2).setProperty("width", "10%");

    return mytable;
  }
View Full Code Here

  }

  public static void test02() throws Exception {
    SlotHandle container = null;

    TableHandle table = createTable(100);
    // GridHandle outerGrid = (GridHandle) reportDesignHandle
    // .findElement("outerGrid");
    // container = outerGrid.getCell(1, 1).getContent();
    container = reportDesignHandle.getBody();
    // container.add(table);
View Full Code Here

    System.out.println("Finished");
  }

  public static void test06() throws Exception {
    GridHandle gridHandle = (GridHandle) reportDesignHandle.findElement("myGrid5");
    TableHandle table = createTable(30);
    CellHandle cell2 = gridHandle.getCell(0, 1);
    cell2.getContent().add(table);
    System.out.println("Finished");
  }
View Full Code Here

          columnList.add(colInfo.getColumnName());
        }

        // create new table, set the data set
        TableHandle reportTable = reportDesign.getElementFactory()
            .newTableItem(
                "testTable" + dataSetHandleToUse.getName(),
                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);
View Full Code Here

      designFactory = designHandle.getElementFactory();

      buildDataSource();
      buildDataSet(cols, fromClause);

      TableHandle table = designFactory.newTableItem("table", cols.size());
      table.setWidth("100%");
      table.setDataSet(designHandle.findDataSet("ds"));

      PropertyHandle computedSet = table.getColumnBindings();
      ComputedColumn cs1 = null;

      for( int i = 0 ; i < cols.size() ; i++ ) {
        cs1 = StructureFactory.createComputedColumn();
        cs1.setName((String) cols.get(i));
        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));
View Full Code Here

    reportDesignHandle.getMasterPages().add(simpleMasterPage);
  }

  private void createBody() throws SemanticException {

    TableHandle table = elementFactory.newTableItem(null, 3, 1, 1, 1);
    table.setProperty(IStyleModel.TEXT_ALIGN_PROP,
        DesignChoiceConstants.TEXT_ALIGN_CENTER);
    table.setWidth("80%");//$NON-NLS-1$
    table.setProperty(IReportItemModel.DATA_SET_PROP, "ds");//$NON-NLS-1$

    ColumnHandle ch = (ColumnHandle) table.getColumns().get(0);
    // ch.setProperty("Width", "3in");
    ch.getWidth().setStringValue("3in");

    PropertyHandle computedSet = table.getColumnBindings();
    cs1 = StructureFactory.createComputedColumn();
    cs2 = StructureFactory.createComputedColumn();
    cs3 = StructureFactory.createComputedColumn();
    cs4 = StructureFactory.createComputedColumn();
    cs5 = StructureFactory.createComputedColumn();
    cs6 = StructureFactory.createComputedColumn();

    cs1.setName("ORDERNUMBER");
    cs1.setExpression("dataSetRow[\"ORDERNUMBER\"]");
    cs1.setDataType("Integer");
    computedSet.addItem(cs1);

    cs2.setName("Product");
    cs2.setExpression("dataSetRow[\"PRODUCTCODE\"]");
    cs2.setDataType("String");
    computedSet.addItem(cs2);

    cs3.setName("Amount");
    cs3.setExpression("dataSetRow[\"QUANTITYORDERED\"]");
    cs3.setDataType("Integer");
    computedSet.addItem(cs3);

    cs4.setName("TotalAmount");
    cs4.setExpression("dataSetRow[\"QUANTITYORDERED\"]");
    cs4.setDataType("Integer");
    cs4.setAggregateFunction("SUM");
    computedSet.addItem(cs4);

    cs5.setName("GroupTotalAmount");
    cs5.setExpression("dataSetRow[\"QUANTITYORDERED\"]");
    cs5.setDataType("Integer");
    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);
View Full Code Here

TOP

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

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.