Example usage for com.google.gwt.view.client AbstractDataProvider addDataDisplay

List of usage examples for com.google.gwt.view.client AbstractDataProvider addDataDisplay

Introduction

In this page you can find the example usage for com.google.gwt.view.client AbstractDataProvider addDataDisplay.

Prototype

public void addDataDisplay(final HasData<T> display) 

Source Link

Document

Adds a data display to this adapter.

Usage

From source file:com.arcbees.gquery.tooltip.client.contactcell.ContactCellList.java

License:Apache License

private CellList<ContactInfo> initCellList(AbstractDataProvider<ContactInfo> dataProvider) {
    ContactCell contactCell = new ContactCell();

    CellList<ContactInfo> cellList = new CellList<ContactInfo>(contactCell,
            ContactDatabase.ContactInfo.KEY_PROVIDER);

    cellList.setPageSize(30);//from   w w  w  .j  a  v a2 s .c o m
    cellList.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE);

    dataProvider.addDataDisplay(cellList);

    return cellList;
}

From source file:com.tasktop.c2c.server.scm.web.ui.client.view.ScmRepoView.java

License:Open Source License

public void setDataProvider(AbstractDataProvider<Commit> dataProvider) {
    dataProvider.addDataDisplay(commitCellList);
}

From source file:org.eclipse.che.ide.ext.datasource.client.editdatasource.EditDatasourcesViewImpl.java

License:Open Source License

@Override
public void bindDatasourceModel(final AbstractDataProvider<DatabaseConfigurationDTO> provider) {
    provider.addDataDisplay(this.datasourceList);
}

From source file:org.eclipse.che.ide.ext.datasource.client.properties.DataEntityPropertiesViewImpl.java

License:Open Source License

@Override
public void bindDataProvider(final AbstractDataProvider<Property> dataProvider) {
    dataProvider.addDataDisplay(this.propertiesDisplay);
}

From source file:org.glom.web.client.ui.list.ListTable.java

License:Open Source License

protected void createCellTable(final LayoutGroup layoutGroup, final String tableName, final int numVisibleRows,
        final String navigationButtonLabel, final NavigationButtonCell navigationButtonCell) {
    this.tableName = tableName;
    final List<LayoutItem> layoutItems = layoutGroup.getItems();

    ProvidesKey<DataItem[]> keyProvider = null;
    final int primaryKeyIndex = layoutGroup.getPrimaryKeyIndex();
    if ((primaryKeyIndex < 0) || (primaryKeyIndex >= layoutItems.size())) {
        GWT.log("createCellTable(): primaryKeyIndex is out of range: " + primaryKeyIndex);
    } else {//  w ww .jav a  2  s .  c o  m
        final LayoutItem primaryKeyItem = layoutItems.get(primaryKeyIndex);
        if (!(primaryKeyItem instanceof LayoutItemField)) {
            GWT.log("createCellTable(): primaryKeyItem is not a LayoutItemField.");
        } else {
            final LayoutItemField primaryKeyLayoutItem = (LayoutItemField) primaryKeyItem;
            final GlomFieldType primaryKeyFieldType = primaryKeyLayoutItem.getGlomType();

            keyProvider = new ProvidesKey<DataItem[]>() {
                @Override
                public Object getKey(final DataItem[] row) {
                    if (row.length == 1 && row[0] == null) {
                        // an empty row
                        return null;
                    }

                    if ((primaryKeyIndex < 0) || (primaryKeyIndex >= row.length)) {
                        GWT.log("createCellTable() keyProvider.getKey(): primaryKeyIndex is out of range: "
                                + primaryKeyIndex + ", row.length=" + row.length);
                        return null;
                    }

                    return Utils.getTypedDataItem(primaryKeyFieldType, row[primaryKeyIndex]);
                }
            };
        }
    }

    // create the CellTable with the requested number of rows and the key provider
    cellTable = new CellTable<DataItem[]>(numVisibleRows, keyProvider);

    // set some style
    cellTable.setStyleName("data-list");
    cellTable.getElement().getStyle().setProperty("whiteSpace", "nowrap"); // this prevents the header and row text
    // from wrapping

    // add columns to the CellTable and deal with the case of the hidden primary key
    final int numItems = layoutGroup.hasHiddenPrimaryKey() ? layoutItems.size() - 1 : layoutItems.size();
    for (int i = 0; i < numItems; i++) {
        final LayoutItem layoutItem = layoutItems.get(i);

        // only add columns for LayoutItemField types
        if (layoutItem instanceof LayoutItemField) {
            addColumn((LayoutItemField) layoutItem);
        } else {
            GWT.log("createCellTable(): Ignoring non-LayoutItemField layout item.");
        }

    }

    // add the navigation buttons as the last column
    addNavigationButtonColumn(navigationButtonLabel, navigationButtonCell);

    // create and set the data provider
    final AbstractDataProvider<DataItem[]> dataProvider = getDataProvider();
    dataProvider.addDataDisplay(cellTable);

    // add an AsyncHandler to activate sorting for the data provider
    cellTable.addColumnSortHandler(new AsyncHandler(cellTable));

    // pack the widgets into the container
    pager.setDisplay(cellTable);
    mainPanel.add(cellTable);
    mainPanel.add(pager);

    /*
     * Update the height of the loading indicator widget to match the body of the CellTable so that the pager widget
     * doesn't bounce up and down while paging. This code also ensures that loading indicator GIF is in the centre
     * of the table.
     * 
     * TODO: Make this work with related lists in Notebooks. These related list tables will have the original bouncy
     * behaviour because CellTable.getBodyHeight() of a related list table in an unselected notebook tab returns 0.
     * 
     * TODO: Fix the bounce when paging to the first or last page that doesn't fall on a natural page boundary. This
     * happens in the first and last page when dataSize % pageSize != 0.
     */
    cellTable.addLoadingStateChangeHandler(new LoadingStateChangeEvent.Handler() {

        @Override
        public void onLoadingStateChanged(final LoadingStateChangeEvent event) {
            // LoadingState.LOADED means the data has been received but not necessarily rendered.
            if (event.getLoadingState() == LoadingState.LOADED) {
                new Timer() {

                    @Override
                    public void run() {
                        if (cellTable.isAttached()) {
                            final int bodyHeight = cellTable.getBodyHeight();
                            /*
                             * Modify the indicator widget only if body height is bigger than the body height that
                             * has already been set. This is just a safety check for the case where the timer isn't
                             * long enough and the body height is calculated to be smaller than its full size. In
                             * practice this is not expected to happen.
                             * 
                             * Since cellTableBodyHeight is initialised to 0, the indicator widget will not be
                             * modified when the body height cannot be calculated (e.g. when a related list table is
                             * in an unselected notebook tab).
                             */
                            if (bodyHeight > cellTableBodyHeight) {
                                final Widget loadingIndicator = cellTable.getLoadingIndicator();

                                // Set the margin of the parent div to zero.
                                final Element parent = loadingIndicator.getElement().getParentElement();
                                parent.getStyle().setMargin(0, Unit.PX);

                                // Set the height of the table cell that holds the loading indicator GIF.
                                final Element cell = parent.getParentElement().getParentElement()
                                        .getParentElement();
                                cell.getStyle().setPadding(0, Unit.PX);
                                cell.getStyle().setHeight(bodyHeight, Unit.PX);

                                // save the new body height
                                cellTableBodyHeight = bodyHeight;

                            }
                        }
                    }
                }.schedule(200); // 200 ms should be enough
            }

        }
    });

    // initialize composite widget
    initWidget(mainPanel);
}