Example usage for com.google.gwt.user.cellview.client CellTable CellTable

List of usage examples for com.google.gwt.user.cellview.client CellTable CellTable

Introduction

In this page you can find the example usage for com.google.gwt.user.cellview.client CellTable CellTable.

Prototype

public CellTable(int pageSize, ProvidesKey<T> keyProvider) 

Source Link

Document

Constructs a table with the given page size and the given ProvidesKey key provider .

Usage

From source file:org.eclipse.che.ide.macro.chooser.MacroChooserViewImpl.java

License:Open Source License

private void initMacrosTable(org.eclipse.che.ide.Resources resources) {
    macrosTable = new CellTable<>(500, resources);

    final Column<Macro, String> nameColumn = new Column<Macro, String>(new TextCell()) {
        @Override/*from   w  ww . j a  v  a  2  s. c  o  m*/
        public String getValue(Macro remote) {
            return remote.getName();
        }
    };

    final Column<Macro, String> descriptionColumn = new Column<Macro, String>(new TextCell()) {
        @Override
        public String getValue(Macro remote) {
            return remote.getDescription();
        }
    };

    macrosTable.addColumn(nameColumn, "Macro");
    macrosTable.setColumnWidth(nameColumn, "40%");
    macrosTable.addColumn(descriptionColumn, "Description");
    macrosTable.setColumnWidth(descriptionColumn, "60%");

    final SingleSelectionModel<Macro> selectionModel = new SingleSelectionModel<>();

    macrosTable.setSelectionModel(selectionModel);

    macrosTable.addDomHandler(event -> {
        if (selectionModel.getSelectedObject() != null) {
            delegate.onMacroChosen(selectionModel.getSelectedObject());
        }
    }, DoubleClickEvent.getType());

    macrosTable.addDomHandler(event -> {
        if (selectionModel.getSelectedObject() != null && (KeyCodes.KEY_ENTER == event.getNativeKeyCode()
                || KeyCodes.KEY_MAC_ENTER == event.getNativeKeyCode())) {

            delegate.onMacroChosen(selectionModel.getSelectedObject());
        }
    }, KeyUpEvent.getType());
}

From source file:org.eclipse.che.ide.processes.runtime.CellTableRuntimeInfoWidgetFactory.java

License:Open Source License

private Widget createCellTable(ListDataProvider<RuntimeInfo> dataProvider) {
    CellTable<RuntimeInfo> table = new CellTable<>(100, resources);
    table.ensureDebugId("runtimeInfoCellTable");

    TextColumn<RuntimeInfo> referenceColumn = new TextColumn<RuntimeInfo>() {
        @Override/*from   w w  w . j a v a  2 s.c  o m*/
        public String getValue(RuntimeInfo record) {
            return valueOrDefault(record.getReference());
        }

        @Override
        public void render(Context context, RuntimeInfo object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "runtime-info-reference-"
                    + context.getIndex() + "\">");
            super.render(context, object, sb);
        }
    };

    TextColumn<RuntimeInfo> portColumn = new TextColumn<RuntimeInfo>() {
        @Override
        public String getValue(RuntimeInfo record) {
            return valueOrDefault(record.getPort());
        }

        @Override
        public void render(Context context, RuntimeInfo object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "runtime-info-port-"
                    + context.getIndex() + "\">");
            super.render(context, object, sb);
        }
    };

    TextColumn<RuntimeInfo> protocolColumn = new TextColumn<RuntimeInfo>() {
        @Override
        public String getValue(RuntimeInfo record) {
            return valueOrDefault(record.getProtocol());
        }

        @Override
        public void render(Context context, RuntimeInfo object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "runtime-info-protocol-"
                    + context.getIndex() + "\">");
            super.render(context, object, sb);
        }
    };

    Column<RuntimeInfo, SafeHtml> urlColumn = new Column<RuntimeInfo, SafeHtml>(
            new AbstractCell<SafeHtml>("click", "keydown") {

                @Override
                public void render(Context context, SafeHtml value, SafeHtmlBuilder sb) {
                    sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "runtime-info-url-"
                            + context.getIndex() + "\">");

                    if (value != null) {
                        sb.append(value);
                    }
                }

                @Override
                protected void onEnterKeyDown(Context context, Element parent, SafeHtml value,
                        NativeEvent event, ValueUpdater<SafeHtml> valueUpdater) {
                    if (valueUpdater != null) {
                        valueUpdater.update(value);
                    }
                }

                @Override
                public void onBrowserEvent(Context context, Element parent, SafeHtml value, NativeEvent event,
                        ValueUpdater<SafeHtml> valueUpdater) {
                    super.onBrowserEvent(context, parent, value, event, valueUpdater);
                    if ("click".equals(event.getType())) {
                        onEnterKeyDown(context, parent, value, event, valueUpdater);
                    }
                }
            }) {
        @Override
        public SafeHtml getValue(RuntimeInfo record) {
            String value = valueOrDefault(record.getUrl());

            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            sb.appendHtmlConstant("<a target=\"_blank\" href=\"" + value + "\">");
            sb.appendEscaped(value);
            sb.appendHtmlConstant("</a>");
            return sb.toSafeHtml();
        }
    };

    table.addColumn(referenceColumn, locale.cellTableReferenceColumn());
    table.addColumn(portColumn, locale.cellTablePortColumn());
    table.addColumn(protocolColumn, locale.cellTableProtocolColumn());
    table.addColumn(urlColumn, locale.cellTableUrlColumn());

    table.setColumnWidth(referenceColumn, 15., Unit.PCT);
    table.setColumnWidth(portColumn, 7., Unit.PCT);
    table.setColumnWidth(protocolColumn, 7., Unit.PCT);
    table.setColumnWidth(urlColumn, 71., Unit.PCT);

    dataProvider.addDataDisplay(table);

    return table;
}

From source file:org.eclipse.che.plugin.artik.ide.updatesdk.UpdateSDKViewImpl.java

License:Open Source License

@Inject
public UpdateSDKViewImpl(UpdateSDKViewImplUiBinder uiBinder, ArtikLocalizationConstant localizationConstants) {
    this.localizationConstants = localizationConstants;
    setTitle(localizationConstants.updateSDKViewTitle());

    targetsTable = new CellTable<>(5, tableResources);

    Column<TargetForUpdate, String> targetColumn = new Column<TargetForUpdate, String>(new TextCell()) {
        @Override//  www  . j a  v  a2s. co m
        public String getValue(TargetForUpdate target) {
            return target.getName();
        }
    };
    Column<TargetForUpdate, String> installedVersionColumn = new Column<TargetForUpdate, String>(
            new TextCell()) {
        @Override
        public String getValue(TargetForUpdate target) {
            return target.getCurrentVersion();
        }
    };

    targetsTable.addColumn(targetColumn, localizationConstants.updateSDKViewColumnTargetTitle());
    targetsTable.setColumnWidth(targetColumn, "60%");
    targetsTable.addColumn(installedVersionColumn,
            localizationConstants.updateSDKViewColumnInstalledVersionTitle());
    targetsTable.setColumnWidth(installedVersionColumn, "40%");

    setWidget(uiBinder.createAndBindUi(this));

    installButton = createButton(localizationConstants.updateSDKViewButtonInstallTitle(),
            "artik-updateSDK-install", new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    delegate.onInstallClicked();
                }
            });
    installButton.addStyleName(Window.resources.windowCss().primaryButton());
    addButtonToFooter(installButton);

    cancelButton = createButton(localizationConstants.updateSDKViewButtonCancelTitle(),
            "artik-updateSDK-cancel", new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    delegate.onCancelClicked();
                }
            });
    addButtonToFooter(cancelButton);
}

From source file:org.eclipse.che.plugin.docker.ext.client.manage.CredentialsPreferencesViewImpl.java

License:Open Source License

private void initCredentialsTable(CellTable.Resources res) {
    keys = new CellTable<>(15, res);
    Column<AuthConfig, String> serverAddressColumn = new Column<AuthConfig, String>(new TextCell()) {
        @Override/*from  ww w. jav a 2s .c  o m*/
        public String getValue(AuthConfig object) {
            return object.getServeraddress();
        }

        @Override
        public void render(Cell.Context context, AuthConfig object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX
                    + "preferences-docker-credentials-cellTable-serveraddress-" + context.getIndex() + "\">");
            super.render(context, object, sb);
        }
    };
    serverAddressColumn.setSortable(true);

    Column<AuthConfig, String> editColumn = new Column<AuthConfig, String>(new ButtonCell()) {
        @Override
        public String getValue(AuthConfig object) {
            return "Edit";
        }

        @Override
        public void render(Cell.Context context, AuthConfig object, SafeHtmlBuilder sb) {
            if (object != null) {
                sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX
                        + "preferences-docker-credentials-cellTable-edit-" + context.getIndex() + "\">");
                super.render(context, object, sb);
            }
        }
    };
    // Creates handler on button clicked
    editColumn.setFieldUpdater(new FieldUpdater<AuthConfig, String>() {
        @Override
        public void update(int index, AuthConfig object, String value) {
            delegate.onEditClicked(object);
        }
    });

    Column<AuthConfig, String> deleteColumn = new Column<AuthConfig, String>(new ButtonCell()) {
        @Override
        public String getValue(AuthConfig object) {
            return "Delete";
        }

        @Override
        public void render(Cell.Context context, AuthConfig object, SafeHtmlBuilder sb) {
            if (object != null) {
                sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX
                        + "preferences-docker-credentials-cellTable-delete-" + context.getIndex() + "\">");
                super.render(context, object, sb);
            }
        }
    };
    // Creates handler on button clicked
    deleteColumn.setFieldUpdater(new FieldUpdater<AuthConfig, String>() {
        @Override
        public void update(int index, AuthConfig object, String value) {
            delegate.onDeleteClicked(object);
        }
    });

    keys.addColumn(serverAddressColumn, "Server Address");
    keys.addColumn(editColumn, "");//Do not show label for edit column
    keys.addColumn(deleteColumn, "");//Do not show label for delete column
    keys.setColumnWidth(serverAddressColumn, 70, Style.Unit.PCT);
    keys.setColumnWidth(editColumn, 20, Style.Unit.PX);
    keys.setColumnWidth(deleteColumn, 20, Style.Unit.PX);

    // don't show loading indicator
    keys.setLoadingIndicator(null);
}

From source file:org.eclipse.che.plugin.ssh.key.client.manage.SshKeyManagerViewImpl.java

License:Open Source License

/** Creates table what contains list of available ssh keys. */
private void initSshKeyTable(final CellTable.Resources res) {
    keys = new CellTable<>(15, res);
    Column<SshPairDto, String> hostColumn = new Column<SshPairDto, String>(new TextCell()) {
        @Override/* w w  w. ja  va 2 s .co  m*/
        public String getValue(SshPairDto object) {
            return object.getName();
        }

        @Override
        public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-host-"
                    + context.getIndex() + "\">");
            super.render(context, object, sb);
        }
    };
    hostColumn.setSortable(true);

    Column<SshPairDto, String> publicKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) {
        @Override
        public String getValue(SshPairDto object) {
            return "View";
        }

        @Override
        public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-key-"
                    + context.getIndex() + "\">");
            if (object != null && object.getPublicKey() != null) {
                super.render(context, object, sb);
            }
        }
    };
    // Creates handler on button clicked
    publicKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() {
        @Override
        public void update(int index, SshPairDto object, String value) {
            delegate.onViewClicked(object);
        }
    });

    Column<SshPairDto, String> deleteKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) {
        @Override
        public String getValue(SshPairDto object) {
            return "Delete";
        }

        @Override
        public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-delete-"
                    + context.getIndex() + "\">");
            super.render(context, object, sb);
        }
    };
    // Creates handler on button clicked
    deleteKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() {
        @Override
        public void update(int index, SshPairDto object, String value) {
            delegate.onDeleteClicked(object);
        }
    });

    keys.addColumn(hostColumn, "Host");
    keys.addColumn(publicKeyColumn, "Public Key");
    keys.addColumn(deleteKeyColumn, "Delete");
    keys.setColumnWidth(hostColumn, 50, Style.Unit.PCT);
    keys.setColumnWidth(publicKeyColumn, 30, Style.Unit.PX);
    keys.setColumnWidth(deleteKeyColumn, 30, Style.Unit.PX);

    // don't show loading indicator
    keys.setLoadingIndicator(null);
}

From source file:org.eclipse.che.plugin.yaml.ide.preferences.YamlExtensionManagerViewImpl.java

License:Open Source License

/**
 * Creates table which contains list of available preferences
 *
 * @param res Celltable resources//from www  .  j ava  2 s .  c o  m
 */
private void initYamlExtensionTable(final CellTable.Resources res) {

    yamlPreferenceCellTable = new CellTable<YamlPreference>(20, res);
    Column<YamlPreference, String> urlColumn = new Column<YamlPreference, String>(new EditTextCell()) {
        @Override
        public String getValue(YamlPreference object) {
            return object.getUrl();
        }

        @Override
        public void render(Context context, YamlPreference object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-preferences-cellTable-url-"
                    + context.getIndex() + "\">");
            super.render(context, object, sb);
        }
    };

    urlColumn.setFieldUpdater(new FieldUpdater<YamlPreference, String>() {
        @Override
        public void update(int index, YamlPreference object, String value) {
            object.setUrl(value);
            delegate.nowDirty();
        }
    });

    Column<YamlPreference, String> globColumn = new Column<YamlPreference, String>(new EditTextCell()) {
        @Override
        public String getValue(YamlPreference object) {
            return object.getGlob();
        }

        @Override
        public void render(Context context, YamlPreference object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-preferences-cellTable-glob-"
                    + context.getIndex() + "\">");
            if (object != null) {
                super.render(context, object, sb);
            }
        }
    };

    globColumn.setFieldUpdater(new FieldUpdater<YamlPreference, String>() {
        @Override
        public void update(int index, YamlPreference object, String value) {
            object.setGlob(value);
            delegate.nowDirty();
        }
    });

    Column<YamlPreference, String> deletePreferenceColumn = new Column<YamlPreference, String>(
            new ButtonCell()) {
        @Override
        public String getValue(YamlPreference object) {
            return "Delete";
        }

        @Override
        public void render(Context context, YamlPreference object, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-preferences-cellTable-delete-"
                    + context.getIndex() + "\">");
            super.render(context, object, sb);
        }
    };

    // Creates handler on button clicked
    deletePreferenceColumn.setFieldUpdater(new FieldUpdater<YamlPreference, String>() {
        @Override
        public void update(int index, YamlPreference object, String value) {
            delegate.onDeleteClicked(object);
        }
    });

    yamlPreferenceCellTable.addColumn(urlColumn, local.urlColumnHeader());
    yamlPreferenceCellTable.addColumn(globColumn, local.globColumnHeader());
    yamlPreferenceCellTable.addColumn(deletePreferenceColumn, local.deleteColumnHeader());
    yamlPreferenceCellTable.setWidth("100%", true);
    yamlPreferenceCellTable.setColumnWidth(urlColumn, 45, Style.Unit.PCT);
    yamlPreferenceCellTable.setColumnWidth(globColumn, 30, Style.Unit.PCT);
    yamlPreferenceCellTable.setColumnWidth(deletePreferenceColumn, 25, Style.Unit.PCT);

    // don't show loading indicator
    yamlPreferenceCellTable.setLoadingIndicator(null);
}

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 {//from w  ww .ja v  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);
}

From source file:org.pepstock.jem.gwt.client.commons.AbstractTable.java

License:Open Source License

/**
 * Contruct the table/* w w w .j a va2  s  .co  m*/
 * @param resources table style
 * @param pagerResources pager style
 * @param pageSize page size
 * @param filterableHeaders <code>true</code> if contains {@link FilterableHeader}s
 */
protected AbstractTable(CellTable.Resources resources, SimplePager.Resources pagerResources, final int pageSize,
        boolean filterableHeaders) {
    // creates the CellTable (with or without custom resources styles)
    if (resources != null) {
        table = new CellTable<T>(pageSize, resources);
    } else {
        table = new CellTable<T>();
    }

    // save the filterableHeader flag
    hasFilterableHeader = filterableHeaders;

    // sets keyboard disable so you couldn't select the row without checking the box
    // sets selection, pagesize and dimensions
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);

    table.setPageSize(pageSize);
    table.setWidth(Sizes.HUNDRED_PERCENT);
    table.setHeight(Sizes.HUNDRED_PERCENT);

    // Create a Pager to control the table.
    pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
    pager.addStyleName(DefaultTablePagerResources.INSTANCE.styles().background());

    // Add a selection model to handle user selection.
    MultiSelectionModel<T> selectionModel = new MultiSelectionModel<T>();
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<T>createCheckboxManager(0));

    // Attach a column sort handler to the ListDataProvider to sort the
    // list.
    // AsyncDataPRrovider.
    AsyncHandler columnSortHandler = new AsyncHandler(table);
    table.addColumnSortHandler(columnSortHandler);

    // asks to implementor to have the comparator to sort capabilities
    comparator = initCellTable(table);

    // uses Async provider
    provider = new AbstractTableAsyncDataProvider();
    // add table panel to data provider
    provider.addDataDisplay(table);
    provider.updateRowCount(dataProvider.size(), true);

    // sets table and page size to pager
    pager.setDisplay(table);
    pager.setPageSize(pageSize);

    // starts empty
    setRowData(null);
}

From source file:org.rstudio.studio.client.workbench.views.packages.ui.PackageActionConfirmationDialog.java

License:Open Source License

@Override
protected Widget createMainWidget() {
    FlowPanel flowPanel = new FlowPanel();
    String explanatoryText = getExplanatoryText();
    if (explanatoryText.length() > 0) {
        Label text = new Label(explanatoryText);
        text.setStylePrimaryName(RESOURCES.styles().explanatoryText());
        flowPanel.add(text);//from   w w  w  .ja va 2s. c  om
    }

    actionsTable_ = new CellTable<PendingAction>(15,
            GWT.<PackagesCellTableResources>create(PackagesCellTableResources.class));
    actionsTable_.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    actionsTable_.setSelectionModel(new NoSelectionModel<PendingAction>());
    actionsTable_.setWidth("100%", true);

    ActionColumn actionColumn = new ActionColumn();
    actionsTable_.addColumn(actionColumn);
    actionsTable_.setColumnWidth(actionColumn, 30, Unit.PX);

    addTableColumns(actionsTable_);

    ScrollPanel scrollPanel = new ScrollPanel();
    scrollPanel.setWidget(actionsTable_);
    scrollPanel.setStylePrimaryName(RESOURCES.styles().mainWidget());
    flowPanel.add(scrollPanel);

    // query for updates
    actionsDS_.requestData(new SimpleRequestCallback<JsArray<T>>() {

        @Override
        public void onResponseReceived(JsArray<T> actions) {
            if (actions != null && actions.length() > 0) {
                ArrayList<PendingAction> pendingActions = new ArrayList<PendingAction>();
                for (int i = 0; i < actions.length(); i++)
                    pendingActions.add(new PendingAction(actions.get(i), false));
                actionsTable_.setPageSize(pendingActions.size());
                actionsDataProvider_ = new ListDataProvider<PendingAction>();
                actionsDataProvider_.setList(pendingActions);
                actionsDataProvider_.addDataDisplay(actionsTable_);

                enableCancelButton(true);
                selectAllButton_.setEnabled(true);
                selectNoneButton_.setEnabled(true);
            } else {
                closeDialog();
                showNoActionsRequired();
            }
        }

        @Override
        public void onError(ServerError error) {
            closeDialog();
            super.onError(error);
        }
    });

    return flowPanel;
}

From source file:stroom.data.table.client.CellTableViewImpl.java

License:Apache License

public CellTableViewImpl(final boolean supportsSelection, final Resources resources) {
    cellTable = new CellTable<R>(DataGridViewImpl.DEFAULT_LIST_PAGE_SIZE, resources);
    cellTable.setWidth("100%");

    cellTable.setLoadingIndicator(null);

    setSupportsSelection(supportsSelection);
    setWidget(cellTable);/*from  ww w.  j  a va  2  s.c  o m*/
}