Package org.pentaho.reporting.engine.classic.core.util

Examples of org.pentaho.reporting.engine.classic.core.util.TypedTableModel


    }
  }

  public TableModel createModel()
  {
    final TypedTableModel tableModel = new TypedTableModel();
    final int columnCount = getColumnCount();
    for (int col = 1; col < columnCount; col++)
    {
      tableModel.addColumn(getColumnName(col), getColumnClass(col));
    }

    final int rowCount = getRowCount();
    for (int r = 0; r < rowCount; r++)
    {
      for (int col = 1; col < columnCount; col++)
      {
        tableModel.setValueAt(getValueAt(r, col), r, col - 1);
      }
    }

    return tableModel;
  }
View Full Code Here


  public TocDataGeneratorFunction()
  {
    this.groups = new ArrayList<String>();
    this.pageFunction = new PageFunction();
    this.indexSeparator = ".";
    this.model = new TypedTableModel();
    this.titleFormula = new FormulaExpression();
    this.dependencyLevel = LayoutProcess.LEVEL_COLLECT;
  }
View Full Code Here

   * @return a copy of this function.
   */
  public Expression getInstance()
  {
    final TocDataGeneratorFunction instance = (TocDataGeneratorFunction) super.getInstance();
    instance.model = new TypedTableModel();
    instance.titleFormula = (FormulaExpression) titleFormula.getInstance();
    instance.pageFunction = (PageFunction) pageFunction.getInstance();
    instance.groups = (ArrayList<String>) groups.clone();
    instance.groupCount = null;
    instance.groupValues = null;
View Full Code Here

    columnNames[3] = "item-key";
    columnTypes[0] = Object.class;
    columnTypes[1] = String.class;
    columnTypes[2] = Integer[].class;
    columnTypes[3] = String.class;
    final TypedTableModel sampleModel = new TypedTableModel(columnNames, columnTypes);

    final CompoundDataFactory compoundDataFactory = new CompoundDataFactory();
    compoundDataFactory.add(new TableDataFactory("design-time-data", sampleModel));
    setQuery("design-time-data");
    setDataFactory(compoundDataFactory);
View Full Code Here

    for (int i = 0; i < 10; i++)
    {
      columnNames[i + 4] = "group-value-" + i;
      columnTypes[i + 4] = Object.class;
    }
    final TypedTableModel sampleModel = new TypedTableModel(columnNames, columnTypes);

    final CompoundDataFactory compoundDataFactory = new CompoundDataFactory();
    compoundDataFactory.add(new TableDataFactory("design-time-data", sampleModel));
    setQuery("design-time-data");
    setDataFactory(compoundDataFactory);
View Full Code Here

        {
          return;
        }
      }

      final TypedTableModel tableModel = new TypedTableModel();
      final Sheet sheet = workbook.getSheetAt(sheetIndex);
      final Iterator rowIterator = sheet.rowIterator();

      if (firstRowIsHeader)
      {
        if (rowIterator.hasNext())
        {
          final Row headerRow = (Row) rowIterator.next();
          final short cellCount = headerRow.getLastCellNum();
          for (short colIdx = 0; colIdx < cellCount; colIdx++)
          {
            final Cell cell = headerRow.getCell(colIdx);
            if (cell != null)
            {
              while (colIdx > tableModel.getColumnCount())
              {
                tableModel.addColumn(Messages.getString("TableDataSourceEditor.Column",
                    String.valueOf(tableModel.getColumnCount())), Object.class);
              }

              final RichTextString string = cell.getRichStringCellValue();
              if (string != null)
              {
                tableModel.addColumn(string.getString(), Object.class);
              }
              else
              {
                tableModel.addColumn(Messages.getString("TableDataSourceEditor.Column", String.valueOf(colIdx)), Object.class);
              }
            }
          }
        }
      }

      Object[] rowData = null;
      while (rowIterator.hasNext())
      {
        final Row row = (Row) rowIterator.next();
        final short cellCount = row.getLastCellNum();
        if (cellCount == -1)
        {
          continue;
        }
        if (rowData == null || rowData.length != cellCount)
        {
          rowData = new Object[cellCount];
        }

        for (short colIdx = 0; colIdx < cellCount; colIdx++)
        {
          final Cell cell = row.getCell(colIdx);

          final Object value;
          if (cell != null)
          {
            if (cell.getCellType() == Cell.CELL_TYPE_STRING)
            {
              final RichTextString string = cell.getRichStringCellValue();
              if (string != null)
              {
                value = string.getString();
              }
              else
              {
                value = null;
              }
            }
            else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC)
            {
              final CellStyle hssfCellStyle = cell.getCellStyle();
              final short dataFormat = hssfCellStyle.getDataFormat();
              final String dataFormatString = hssfCellStyle.getDataFormatString();
              if (isDateFormat(dataFormat, dataFormatString))
              {
                value = cell.getDateCellValue();
              }
              else
              {
                value = cell.getNumericCellValue();
              }
            }
            else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN)
            {
              value = cell.getBooleanCellValue();
            }
            else
            {
              value = cell.getStringCellValue();
            }
          }
          else
          {
            value = null;
          }

          if (value != null && "".equals(value) == false)
          {
            while (colIdx >= tableModel.getColumnCount())
            {
              tableModel.addColumn(Messages.getString("TableDataSourceEditor.Column",
                  String.valueOf(tableModel.getColumnCount())), Object.class);
            }
          }

          rowData[colIdx] = value;
        }

        if (Thread.currentThread().isInterrupted())
        {
          return;
        }

        tableModel.addRow(rowData);
      }

      final int colCount = tableModel.getColumnCount();
      final int rowCount = tableModel.getRowCount();
      for (int col = 0; col < colCount; col++)
      {
        Class type = null;
        for (int row = 0; row < rowCount; row += 1)
        {
          final Object value = tableModel.getValueAt(row, col);
          if (value == null)
          {
            continue;
          }
          if (type == null)
          {
            type = value.getClass();
          }
          else if (type != Object.class)
          {
            if (type.isInstance(value) == false)
            {
              type = Object.class;
            }
          }
        }

        if (Thread.currentThread().isInterrupted())
        {
          return;
        }

        if (type != null)
        {
          tableModel.setColumnType(col, type);
        }
      }

      parent.importComplete(tableModel);
    }
View Full Code Here

    {
    }

    protected TableModel createDefaultObject()
    {
      final TypedTableModel defaultTableModel = new TypedTableModel();
      defaultTableModel.addColumn(Messages.getString("TableDataSourceEditor.IDColumn"), String.class);
      defaultTableModel.addColumn(Messages.getString("TableDataSourceEditor.ValueColumn"), String.class);
      defaultTableModel.addRow();
      return defaultTableModel;
    }
View Full Code Here

   */
  public IndexDataGeneratorFunction()
  {
    this.pageFunction = new PageFunction();
    this.indexSeparator = ".";
    this.model = new TypedTableModel();
    this.dataFormula = new FormulaExpression();
    this.dataStorage = new TreeMap<String,IndexDataHolder>();
  }
View Full Code Here

   * @return a copy of this function.
   */
  public Expression getInstance()
  {
    final IndexDataGeneratorFunction instance = (IndexDataGeneratorFunction) super.getInstance();
    instance.model = new TypedTableModel();
    instance.pageFunction = (PageFunction) pageFunction.getInstance();
    instance.dataFormula = (FormulaExpression) dataFormula.getInstance();
    instance.dataStorage = new TreeMap<String,IndexDataHolder>();
    instance.initialized = false;
    return instance;
View Full Code Here

          queryName = newQueryName;
          break;
        }
      }

      final TypedTableModel defaultTableModel = new TypedTableModel();
      defaultTableModel.addColumn(Messages.getString("TableDataSourceEditor.IDColumn"), String.class);
      defaultTableModel.addColumn(Messages.getString("TableDataSourceEditor.ValueColumn"), String.class);
      final DataSetQuery newQuery = new DataSetQuery(queryName, defaultTableModel);
      queries.put(newQuery.getQueryName(), newQuery);

      inModifyingQueryNameList = true;
      updateQueryList();
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.util.TypedTableModel

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.