Example usage for com.google.gwt.gen2.table.client IterableTableModel IterableTableModel

List of usage examples for com.google.gwt.gen2.table.client IterableTableModel IterableTableModel

Introduction

In this page you can find the example usage for com.google.gwt.gen2.table.client IterableTableModel IterableTableModel.

Prototype

public IterableTableModel(Iterable<RowType> rows) 

Source Link

Document

Create a new IterableTableModel .

Usage

From source file:org.pentaho.pat.client.ui.widgets.OlapTable.java

License:Open Source License

/**
 * /*from   ww  w. ja va  2s .  c o m*/
 * Initialize the Live Table.
 * 
 */
public void initTable() {
    // Not sure what the effect of this is, but at least something is
    // happening now. Not just frozen

    long startTime = System.currentTimeMillis();
    // run your code here

    patTableModel = new PatTableModel(olapData);
    final List<AbstractBaseCell[]> data = Arrays.asList(patTableModel.getRowData());
    offset = patTableModel.getOffset();

    final TableModel<AbstractBaseCell[]> tableModel = new IterableTableModel<AbstractBaseCell[]>(data) {
        @Override
        public int getRowCount() {
            return data.size();
        }

        @Override
        public void requestRows(final Request request, final Callback<AbstractBaseCell[]> callback) {
            long startTime = System.currentTimeMillis();
            final int numRows = Math.min(request.getNumRows(), data.size() - request.getStartRow());

            final List<AbstractBaseCell[]> list = new ArrayList<AbstractBaseCell[]>();
            for (int i = 0, n = numRows; i < n; i++) {
                list.add(data.get(request.getStartRow() + i));
            }
            long midTime = System.currentTimeMillis();
            System.out.println("MidTime: " + (midTime - startTime));
            final Response<AbstractBaseCell[]> response = new Response<AbstractBaseCell[]>() {
                @Override
                public Iterator<AbstractBaseCell[]> getRowValues() {
                    return list.iterator();
                }
            };
            callback.onRowsReady(request, response);
            long stopTime = System.currentTimeMillis();
            long runTime = stopTime - startTime;
            System.out.println("Get rows time: " + runTime);
        }
    };

    table = new LiveTable<AbstractBaseCell[]>(tableModel, createTableDefinition());

    long stopTime = System.currentTimeMillis();
    long runTime = stopTime - startTime;
    System.out.println("Create table time: " + runTime);

    startTime = System.currentTimeMillis();
    // run your code here

    layoutPanel.clear();

    layoutPanel.add(table);
    //table.fillWidth();
    layoutPanel.layout();
    stopTime = System.currentTimeMillis();
    runTime = stopTime - startTime;
    System.out.println("Layouting time: " + runTime);

}

From source file:org.pentaho.pat.client.ui.widgets.ResultSetTable.java

License:Open Source License

/**
 * /*from   w  ww  .j a  v  a 2  s .co  m*/
 * Initialize the Live Table.
 * 
 */
private void initTable() {
    // Not sure what the effect of this is, but at least something is
    // happening now. Not just frozen
    layoutPanel.clear();
    patTableModel = new ResultSetTableModel(tableData);
    final List<String[]> data = Arrays.asList(patTableModel.getRowData());

    final TableModel<String[]> tableModel = new IterableTableModel<String[]>(data) {
        @Override
        public int getRowCount() {
            return data.size();
        }

        @SuppressWarnings("unchecked")
        @Override
        public void requestRows(final Request request, final Callback<String[]> callback) {
            final int numRows = Math.min(request.getNumRows(), data.size() - request.getStartRow());

            final List<String[]> list = new ArrayList<String[]>();
            // in the first row is just the header of the data table
            // this might be a dirty hack but works for now, until we have a proper resultset object
            for (int i = 0, n = numRows - 1; i < n; i++) {
                list.add(data.get(request.getStartRow() + 1 + i));
            }
            final SerializableResponse response = new SerializableResponse(list);
            callback.onRowsReady(request, response);
        }
    };

    table = new LiveTable<String[]>(tableModel, createTableDefinition());

    layoutPanel.add(table);
    table.fillWidth();
    layoutPanel.layout();

}