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

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

Introduction

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

Prototype

public CachedTableModel(MutableTableModel<RowType> tableModel) 

Source Link

Document

Construct a new CachedTableModel .

Usage

From source file:com.google.gwt.gen2.demo.scrolltable.client.PagingScrollTableDemo.java

License:Apache License

@Override
protected AbstractScrollTable createScrollTable() {
    // Setup the controller
    tableModel = new DataSourceTableModel();
    cachedTableModel = new CachedTableModel<Student>(tableModel);
    cachedTableModel.setPreCachedRowCount(50);
    cachedTableModel.setPostCachedRowCount(50);
    cachedTableModel.setRowCount(1000);//  w  w  w .jav a2s.c o m

    // Create a TableCellRenderer
    TableDefinition<Student> tableDef = createTableDefinition();

    // Create the scroll table
    pagingScrollTable = new PagingScrollTable<Student>(cachedTableModel, tableDef);
    pagingScrollTable.setPageSize(50);
    pagingScrollTable.setEmptyTableWidget(new HTML("There is no data to display"));

    // Setup the bulk renderer
    FixedWidthGridBulkRenderer<Student> bulkRenderer = new FixedWidthGridBulkRenderer<Student>(
            pagingScrollTable.getDataTable(), pagingScrollTable);
    pagingScrollTable.setBulkRenderer(bulkRenderer);

    // Setup the formatting
    pagingScrollTable.setCellPadding(3);
    pagingScrollTable.setCellSpacing(0);
    pagingScrollTable.setResizePolicy(ScrollTable.ResizePolicy.FILL_WIDTH);

    return pagingScrollTable;
}

From source file:org.apache.hupa.client.mvp.IMAPMessageListView.java

License:Apache License

@Inject
public IMAPMessageListView(final PagingScrollTableRowDragController controller,
        final MessageTableModel mTableModel, final HupaConstants constants, final HupaMessages messages,
        final HupaImageBundle imageBundle) {
    this.messages = messages;
    this.imageBundle = imageBundle;

    deleteMailButton = new EnableButton(constants.deleteMailButton());
    newMailButton = new Button(constants.newMailButton());
    deleteAllMailButton = new Button(constants.deleteAll());
    markSeenButton = new EnableButton(constants.markSeen());
    markUnSeenButton = new EnableButton(constants.markUnseen());
    allLink = new Hyperlink(constants.all(), "");
    noneLink = new Hyperlink(constants.none(), "");
    refreshLink = new Hyperlink(constants.refresh(), "");
    searchButton = new Button(constants.searchButton());
    loading = new Loading(constants.loading());
    this.cTableModel = new CachedTableModel<Message>(mTableModel);
    cTableModel.setRowCount(MutableTableModel.UNKNOWN_ROW_COUNT);
    mTableModel.addRowCountChangeHandler(new RowCountChangeHandler() {

        public void onRowCountChange(RowCountChangeEvent event) {
            cTableModel.setRowCount(event.getNewRowCount());
        }/*w w  w .ja  v a 2s  .co m*/
    });

    VerticalPanel msgListContainer = new VerticalPanel();
    msgListContainer.addStyleName(HupaCSS.C_msg_list_container);
    mailTable = new DragRefetchPagingScrollTable<Message>(cTableModel, dataTable, new FixedWidthFlexTable(),
            createTableDefinitation(), controller, 1);
    mailTable.setPageSize(20);
    mailTable.setDragHandler(0, 30, new DragHandlerFactory() {

        public Widget createHandler() {
            return new Image(imageBundle.readyToMoveMailIcon());
        }

    });

    HTML emptyTable = new HTML(constants.emptyMailTable());
    emptyTable.addStyleName(HupaCSS.C_msg_table_empty);
    mailTable.setEmptyTableWidget(emptyTable);
    FixedWidthGridBulkRenderer<Message> bulkRenderer = new FixedWidthGridBulkRenderer<Message>(
            mailTable.getDataTable(), mailTable);
    mailTable.setBulkRenderer(bulkRenderer);
    mailTable.addStyleName(HupaCSS.C_msg_table);
    mailTable.setCellPadding(0);
    mailTable.setResizePolicy(ResizePolicy.FILL_WIDTH);
    mailTable.setColumnResizePolicy(ColumnResizePolicy.MULTI_CELL);
    mailTable.setScrollPolicy(ScrollPolicy.DISABLED);
    mailTable.addPageLoadHandler(onMessagePageLoadHandler);
    mailTable.setPageSize(DEFAULT_MSG_PAGE_SIZE);
    mailTable.getDataTable().setCellSpacing(0);
    mailTable.setSortPolicy(SortPolicy.DISABLED);

    mailTable.fillWidth();

    pagingBar = new PagingOptions(mailTable, constants, loading);

    HorizontalPanel buttonBar = new HorizontalPanel();
    buttonBar.addStyleName(HupaCSS.C_buttons);

    ButtonBar navigatorBar = new ButtonBar();
    navigatorBar.add(newMailButton);
    deleteMailButton.setEnabled(false);
    navigatorBar.add(deleteMailButton);
    buttonBar.add(navigatorBar);
    buttonBar.add(deleteAllMailButton);

    ButtonBar markButtonBar = new ButtonBar();
    markButtonBar.add(markSeenButton);
    markButtonBar.add(markUnSeenButton);
    buttonBar.add(markButtonBar);
    buttonBar.add(refreshLink);
    pageBox.addItem("" + DEFAULT_MSG_PAGE_SIZE);
    pageBox.addItem("" + (DEFAULT_MSG_PAGE_SIZE * 2));
    pageBox.addItem("" + (DEFAULT_MSG_PAGE_SIZE * 4));
    pageBox.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {
            if (pageBox.getSelectedIndex() > 0)
                mailTable.setPageSize(Integer.parseInt(pageBox.getItemText(pageBox.getSelectedIndex())));
        }
    });

    HorizontalPanel searchPanel = new HorizontalPanel();
    searchPanel.addStyleName(HupaCSS.C_buttons);

    searchBox.addStyleName(HupaCSS.C_msg_search);
    searchBox.setAnimationEnabled(true);
    searchBox.setAutoSelectEnabled(false);
    searchBox.setLimit(20);
    searchBox.addKeyUpHandler(new KeyUpHandler() {

        public void onKeyUp(KeyUpEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                searchButton.click();
            }
        }

    });
    searchPanel.add(searchBox);
    searchPanel.add(searchButton);
    searchPanel.add(pageBox);

    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.addStyleName(HupaCSS.C_msg_top_bar);
    hPanel.add(buttonBar);
    hPanel.add(searchPanel);
    hPanel.setCellHorizontalAlignment(searchPanel, HorizontalPanel.ALIGN_RIGHT);

    msgListContainer.add(hPanel);

    CommandsBar commandsBar = new CommandsBar();
    commandsBar.addLeft(new HTML(constants.select() + ":"));
    commandsBar.addLeft(allLink);
    commandsBar.addLeft(noneLink);
    commandsBar.add(loading);
    commandsBar.addRight(pagingBar);

    msgListContainer.add(commandsBar);
    msgListContainer.add(mailTable);

    confirmBox.setText(messages.confirmDeleteMessages());
    confirmDeleteAllBox.setText(messages.confirmDeleteAllMessages());
    initWidget(msgListContainer);
}

From source file:org.gss_project.gss.admin.client.ui.FilesTable.java

License:Open Source License

/**
 * Create the {@link CachedTableModel}//  w  w  w  .ja  va 2  s  . com
 * @param aTableModel
 * @return
 */
private CachedTableModel<FileHeaderDTO> createCachedTableModel(DataSourceTableModel aTableModel) {
    CachedTableModel<FileHeaderDTO> tm = new CachedTableModel<FileHeaderDTO>(aTableModel);
    tm.setPreCachedRowCount(20);
    tm.setPostCachedRowCount(20);
    tm.setRowCount(20);
    return tm;
}

From source file:org.gss_project.gss.admin.client.ui.UsersTable.java

License:Open Source License

/**
 * Create the {@link CachedTableModel}//from   w  w w  .ja  v a 2s .c  o  m
 * @param aTableModel
 * @return
 */
private CachedTableModel<UserDTO> createCachedTableModel(DataSourceTableModel aTableModel) {
    CachedTableModel<UserDTO> tm = new CachedTableModel<UserDTO>(aTableModel);
    tm.setPreCachedRowCount(20);
    tm.setPostCachedRowCount(20);
    tm.setRowCount(20);
    return tm;
}

From source file:org.kuali.student.common.ui.client.widgets.pagetable.GenericTableModel.java

License:Educational Community License

/**
 * This returns cached table model for the RowType
 *
 *///from  w  ww  . ja  v  a 2  s.c  o  m
public CachedTableModel<RowType> createCachedTableModel(int pageSize, int pages) {
    CachedTableModel<RowType> cachedTableModel = new CachedTableModel<RowType>(this);
    cachedTableModel.setPreCachedRowCount(pageSize);
    cachedTableModel.setPostCachedRowCount(pageSize);
    cachedTableModel.setRowCount(pageSize * pages);
    return cachedTableModel;
}