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(ProvidesKey<T> keyProvider) 

Source Link

Document

Constructs a table with a default page size of 15, and the given ProvidesKey key provider .

Usage

From source file:eu.zeigermann.gwt.demo.client.list.DefaultShoppingListView.java

License:Apache License

private void initTable(ListDataProvider<ShoppingList> dataProvider) {
    final ProvidesKey<ShoppingList> keyProvider = new ProvidesKey<ShoppingList>() {
        public Object getKey(ShoppingList list) {
            return list == null ? null : list.getId();
        }//from w  ww.  j  a  v  a2s.  c o  m
    };
    cellTable = new CellTable<ShoppingList>(keyProvider);
    dataProvider.addDataDisplay(cellTable);
    cellTable.setPageSize(5);

    cellTable.sinkEvents(Event.ONDBLCLICK);
    final MultiSelectionModel<ShoppingList> selectionModel = new MultiSelectionModel<ShoppingList>(keyProvider);
    cellTable.setSelectionModel(selectionModel, new CellPreviewEvent.Handler<ShoppingList>() {

        @Override
        public void onCellPreview(CellPreviewEvent<ShoppingList> event) {
            int eventType = Event.getTypeInt(event.getNativeEvent().getType());
            if (eventType == Event.ONDBLCLICK) {
                ShoppingList list = event.getValue();
                presenter.editItems(list);
            }
        }
    });

    // styles

    // bootstrap
    cellTable.addStyleName("table");
    cellTable.addStyleName("table-bordered");
    // makes selection invisible on every even row
    // cellTable.addStyleName("table-striped");

    // columns
    addNameColumn(dataProvider);
    addEditColumn();
    addDeleteColumn();
}

From source file:eu.zeigermann.gwt.demo.client.shop.DefaultShopView.java

License:Apache License

private void initTable(ListDataProvider<Shop> dataProvider) {
    final ProvidesKey<Shop> keyProvider = new ProvidesKey<Shop>() {
        public Object getKey(Shop list) {
            return list == null ? null : list.getId();
        }//from  w ww  . jav a2 s  . c o m
    };
    cellTable = new CellTable<Shop>(keyProvider);
    dataProvider.addDataDisplay(cellTable);
    cellTable.setPageSize(5);

    final MultiSelectionModel<Shop> selectionModel = new MultiSelectionModel<Shop>(keyProvider);
    cellTable.setSelectionModel(selectionModel, new CellPreviewEvent.Handler<Shop>() {

        @Override
        public void onCellPreview(CellPreviewEvent<Shop> event) {
            int eventType = Event.getTypeInt(event.getNativeEvent().getType());
            if (eventType == Event.ONCLICK) {
                Shop list = event.getValue();
                presenter.edit(list);
            }
        }
    });

    // styles

    // bootstrap
    cellTable.addStyleName("table");
    cellTable.addStyleName("table-bordered");
    // makes selection invisible on every even row
    // cellTable.addStyleName("table-striped");

    // columns
    addNameColumn(dataProvider);
    addEditColumn();
    addDeleteColumn();
}

From source file:n3phele.client.view.CommandDetailView.java

License:Open Source License

public CellTable<TypedParameter> createParameterTable() {
    final ProvidesKey<TypedParameter> KEY_PROVIDER = new ProvidesKey<TypedParameter>() {
        public Object getKey(TypedParameter item) {
            return item.getName();
        }//from www .  j a va2s .c o m
    };
    final CellTable<TypedParameter> table;
    table = new CellTable<TypedParameter>(KEY_PROVIDER);
    table.setWidth("100%");
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    TextColumn<TypedParameter> descriptionColumn = new TextColumn<TypedParameter>() {
        @Override
        public String getValue(TypedParameter command) {
            String result = "";
            if (command != null)
                return command.getDescription();
            return result;
        }
    };
    table.addColumn(descriptionColumn);

    this.parameterTextInputCell = new DisappearingTextInputCell();
    this.parameterCheckboxCell = new DisappearingCheckBoxCell();
    final ValidInputIndicatorCell valid = new ValidInputIndicatorCell(N3phele.n3pheleResource.inputErrorIcon());

    HasCell<TypedParameter, ?> valueHasCell = new HasCell<TypedParameter, String>() {

        @Override
        public Cell<String> getCell() {
            return CommandDetailView.this.parameterTextInputCell;
        }

        @Override
        public FieldUpdater<TypedParameter, String> getFieldUpdater() {
            return new FieldUpdater<TypedParameter, String>() { // Needs to exist so that the cell level updater is invoked
                @Override
                public void update(int index, TypedParameter object, String value) {
                }

            };
        }

        @Override
        public String getValue(TypedParameter object) {
            if (object != null) {
                if (!object.getType().equalsIgnoreCase("boolean")) {
                    String result = object.getValue();
                    if (isNullOrBlank(result))
                        result = object.getDefaultValue();
                    if (result == null)
                        result = "";
                    return result;
                }
            }
            return null;
        }

    };
    HasCell<TypedParameter, ?> validHasCell = new HasCell<TypedParameter, String>() {

        @Override
        public Cell<String> getCell() {
            return valid;
        }

        @Override
        public FieldUpdater<TypedParameter, String> getFieldUpdater() {
            return null;
        }

        @Override
        public String getValue(TypedParameter object) {
            String errTooltip;
            errTooltip = errorMessageMap().get(object.getType());
            if (checkParameterValue(object)) {
                return "-" + errTooltip;
            } else {
                return "+" + errTooltip;
            }
        }

    };

    HasCell<TypedParameter, ?> booleanHasCell = new HasCell<TypedParameter, Boolean>() {

        @Override
        public Cell<Boolean> getCell() {
            return parameterCheckboxCell;
        }

        @Override
        public FieldUpdater<TypedParameter, Boolean> getFieldUpdater() {
            return new FieldUpdater<TypedParameter, Boolean>() { // Needs to exist so that the cell level updater is invoked
                @Override
                public void update(int index, TypedParameter object, Boolean value) {
                }

            };
        }

        @Override
        public Boolean getValue(TypedParameter object) {
            if (object != null) {
                if (object.getType().equalsIgnoreCase("boolean")) {
                    String result = object.getValue();
                    if (isNullOrBlank(result))
                        result = object.getDefaultValue();
                    return Boolean.valueOf(result);
                }
            }
            return null;
        }

    };
    List<HasCell<TypedParameter, ?>> arg = new ArrayList<HasCell<TypedParameter, ?>>(2);
    arg.add(validHasCell);
    arg.add(valueHasCell);
    arg.add(booleanHasCell);

    Column<TypedParameter, TypedParameter> valueColumn = new Column<TypedParameter, TypedParameter>(
            new TypedPropertyComposite(arg)) {
        @Override
        public TypedParameter getValue(TypedParameter parameter) {
            return parameter;
        }
    };
    valueColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    table.addColumn(valueColumn);
    table.setWidth("100%", true);
    table.setColumnWidth(valueColumn, "210px");
    valueColumn.setFieldUpdater(new FieldUpdater<TypedParameter, TypedParameter>() {
        public void update(int index, final TypedParameter object, final TypedParameter value) {
            GWT.runAsync(new RunAsyncCallback() {

                @Override
                public void onSuccess() {
                    updateRunButton(true);
                }

                @Override
                public void onFailure(Throwable reason) {
                    //
                }
            });

        }
    });
    return table;
}

From source file:n3phele.client.view.CommandDetailView.java

License:Open Source License

public CellTable<FileSpecification> createFileTable(Column<FileSpecification, FileSpecification> repoColumn) {
    final ProvidesKey<FileSpecification> KEY_PROVIDER = new ProvidesKey<FileSpecification>() {

        public Object getKey(FileSpecification item) {
            return item.getName();
        }/*w ww  .  ja v a 2s. c  o m*/
    };
    final CellTable<FileSpecification> table;
    table = new CellTable<FileSpecification>(KEY_PROVIDER);
    table.setWidth("100%", true);
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    TextColumn<FileSpecification> descriptionColumn = new TextColumn<FileSpecification>() {
        @Override
        public String getValue(FileSpecification file) {
            String result = "";
            if (file != null)
                return file.getDescription();
            return result;
        }
    };
    table.addColumn(descriptionColumn);

    table.addColumn(repoColumn);
    repoColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);

    return table;
}

From source file:n3phele.client.view.CommandDetailView.java

License:Open Source License

public CellTable<CloudProfile> createAccountTable(/*final SingleSelectionModel<ExtendedCloudProfile> selectionModel*/) {
    final SensitiveCheckBoxCell checkbox = new SensitiveCheckBoxCell(true, true);
    final ProvidesKey<CloudProfile> KEY_PROVIDER = new ProvidesKey<CloudProfile>() {

        public Object getKey(CloudProfile item) {
            return item.id();
        }/*from  w  ww . j a v  a 2 s  .c  o  m*/
    };
    final CellTable<CloudProfile> table = new CellTable<CloudProfile>(KEY_PROVIDER);
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    Column<CloudProfile, Boolean> checkColumn = new Column<CloudProfile, Boolean>(checkbox) {
        @Override
        public Boolean getValue(CloudProfile profile) {
            return (profile.getId().equals(CommandDetailView.this.selectedProfile))
                    && (profile.getAccountUri().equals(CommandDetailView.this.selectedAccountURI));
        }

    };
    checkColumn.setFieldUpdater(new FieldUpdater<CloudProfile, Boolean>() {

        @Override
        public void update(int index, CloudProfile profile, Boolean value) {
            if (profile != null) {
                if (value) {
                    CommandDetailView.this.selectedProfile = profile.getId();
                    CommandDetailView.this.selectedAccountURI = profile.getAccountUri();
                } else {
                    if (profile.getId().equals(CommandDetailView.this.selectedProfile)) {
                        CommandDetailView.this.selectedProfile = null;
                        CommandDetailView.this.selectedAccountURI = null;
                    }
                }
                table.redraw();
                String visible = value ? "-" : "+";
                CommandDetailView.this.gotExecutionSelection.setValue(
                        visible + CommandDetailView.this.gotExecutionSelection.getValue().substring(1));
                updateRunButton(true);
            } else {
                checkbox.clearViewData(KEY_PROVIDER.getKey(profile));
                table.redraw();
                updateRunButton(false);
                CommandDetailView.this.gotExecutionSelection
                        .setValue("+" + CommandDetailView.this.gotExecutionSelection.getValue().substring(1));
            }

        }

    });
    table.addColumn(checkColumn);
    TextColumn<CloudProfile> accountColumn = new TextColumn<CloudProfile>() {
        @Override
        public String getValue(CloudProfile profile) {
            String result = "";
            if (profile != null)
                return profile.getAccountName();
            return result;
        }
    };
    table.addColumn(accountColumn);
    TextColumn<CloudProfile> nameColumn = new TextColumn<CloudProfile>() {
        @Override
        public String getValue(CloudProfile profile) {
            String result = "";
            if (profile != null) {
                return profile.getCloudName();
            }
            return result;
        }
    };
    table.addColumn(nameColumn);
    TextColumn<CloudProfile> descriptionColumn = new TextColumn<CloudProfile>() {
        @Override
        public String getValue(CloudProfile profile) {
            if (profile != null)
                return profile.getDescription();
            else
                return null;
        }
    };
    table.addColumn(descriptionColumn);
    return table;
}

From source file:n3phele.client.view.CreateServiceView.java

License:Open Source License

public CellTable<CommandCloudAccount> createAccountTable() {
    final SensitiveCheckBoxCell checkbox = new SensitiveCheckBoxCell(true, true);
    final ProvidesKey<CommandCloudAccount> KEY_PROVIDER = new ProvidesKey<CommandCloudAccount>() {

        public Object getKey(CommandCloudAccount item) {
            return item.getAccountUri();
        }// w  ww . ja v a2  s.c om
    };
    final CellTable<CommandCloudAccount> table = new CellTable<CommandCloudAccount>(KEY_PROVIDER);
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    Column<CommandCloudAccount, Boolean> checkColumn = new Column<CommandCloudAccount, Boolean>(checkbox) {
        @Override
        public Boolean getValue(CommandCloudAccount profile) {
            return (profile.getAccountUri().equals(CreateServiceView.this.selectedAccountURI));
        }

    };
    checkColumn.setFieldUpdater(new FieldUpdater<CommandCloudAccount, Boolean>() {

        @Override
        public void update(int index, CommandCloudAccount profile, Boolean value) {
            if (profile != null) {
                if (value) {
                    CreateServiceView.this.selectedImplementation = profile.getImplementation();
                    CreateServiceView.this.selectedAccountURI = profile.getAccountUri().toString();
                } else {
                    if (profile.getImplementation().equals(CreateServiceView.this.selectedImplementation)) {

                        CreateServiceView.this.selectedImplementation = null;
                        CreateServiceView.this.selectedAccountURI = null;
                    }
                }
                table.redraw();
                String visible = value ? "-" : "+";
                CreateServiceView.this.gotExecutionSelection.setValue(
                        visible + CreateServiceView.this.gotExecutionSelection.getValue().substring(1));
                updateRunButton(true);
                validateAccount(true);
            } else {
                checkbox.clearViewData(KEY_PROVIDER.getKey(profile));
                table.redraw();
                updateRunButton(false);
                validateAccount(false);
                GWT.log("update account");
                CreateServiceView.this.gotExecutionSelection
                        .setValue("+" + CreateServiceView.this.gotExecutionSelection.getValue().substring(1));
            }

        }

    });
    table.addColumn(checkColumn);
    table.setColumnWidth(checkColumn, "40px");
    TextColumn<CommandCloudAccount> accountColumn = new TextColumn<CommandCloudAccount>() {
        @Override
        public String getValue(CommandCloudAccount profile) {
            String result = "";
            if (profile != null)
                return profile.getAccountName();
            return result;
        }
    };
    table.addColumn(accountColumn);
    TextColumn<CommandCloudAccount> nameColumn = new TextColumn<CommandCloudAccount>() {
        @Override
        public String getValue(CommandCloudAccount profile) {
            String result = "";
            if (profile != null) {
                return profile.getImplementation();
            }
            return result;
        }
    };
    table.addColumn(nameColumn);
    table.setWidth("400px");
    table.addStyleName(N3phele.n3pheleResource.css().lineBreakStyle());
    table.setTableLayoutFixed(true);
    return table;
}

From source file:org.codesearch.searcher.client.ui.searchview.SearchViewImpl.java

License:Open Source License

private void initResultTable() {
    resultTable = new CellTable<SearchResultDto>(PAGE_SIZE);
    resultTable.addColumn(new TextColumn<SearchResultDto>() {

        /**/*w  w  w  . ja v a2  s. com*/
         * {@inheritDoc}
         */
        @Override
        public String getValue(SearchResultDto dto) {
            return relevanceFormatter.format(dto.getRelevance());
        }
    }, RELEVANCE_TITLE);

    resultTable.addColumn(new TextColumn<SearchResultDto>() {

        /**
         * {@inheritDoc}
         */
        @Override
        public String getValue(SearchResultDto object) {
            return object.getFilePath();
        }
    }, PATH_TITLE);
    resultTable.addColumn(new TextColumn<SearchResultDto>() {

        /**
         * {@inheritDoc}
         */
        @Override
        public String getValue(SearchResultDto dto) {
            return dto.getRepository();
        }
    }, REPOSITORY_TITLE);

    resultTable.addColumn(new TextColumn<SearchResultDto>() {

        /**
         * {@inheritDoc}
         */
        @Override
        public String getValue(SearchResultDto dto) {
            return dto.getLastRevision();
        }
    }, REVISION_TITLE);

    final SelectionModel<SearchResultDto> selectionModel = new NoSelectionModel<SearchResultDto>();
    resultTable.setSelectionModel(selectionModel);

    resultTable.addCellPreviewHandler(new CellPreviewEvent.Handler<SearchResultDto>() {

        @Override
        public void onCellPreview(CellPreviewEvent<SearchResultDto> event) {
            SearchResultDto dto = event.getValue();
            boolean open = false;
            boolean newTab = false;
            if ("click".equals(event.getNativeEvent().getType())) {
                if ((NativeEvent.BUTTON_LEFT & event.getNativeEvent().getButton()) == NativeEvent.BUTTON_LEFT) {
                    open = true;
                }
                if ((NativeEvent.BUTTON_MIDDLE
                        & event.getNativeEvent().getButton()) == NativeEvent.BUTTON_MIDDLE) {
                    open = true;
                    newTab = true;
                }
            } else if ("keyup".equals(event.getNativeEvent().getType())) {
                if (KeyCodes.KEY_ENTER == event.getNativeEvent().getKeyCode()) {
                    open = true;
                }
            }
            if (open) {
                // either CTRL+CLICK or CTRL+ENTER open a new tab
                if (event.getNativeEvent().getCtrlKey()) {
                    newTab = true;
                }
                Place target = new FilePlace(dto.getRepository(), dto.getFilePath(), searchBox.getValue(), 1);
                if (newTab) {

                    String url = Window.Location.getPath() + "#";
                    url += ClientFactory.getDefaultFactory().getHistoryMapper().getToken(target);
                    Window.open(url, "_blank", "");
                } else {
                    presenter.goTo(target);
                }
            }
        }
    });

    // Create a pager to control the table.
    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    resultTablePager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
    resultTablePager.setDisplay(resultTable);
    searchResultDataProvider = new ListDataProvider<SearchResultDto>();
    searchResultDataProvider.addDataDisplay(resultTable);
}

From source file:org.drools.guvnor.client.asseteditor.drools.serviceconfig.KBaseConfigPanel.java

License:Apache License

public KBaseConfigPanel(final ServiceConfig config, final ServiceKBaseConfig kbase,
        final ServiceConfigEditor.UpdateTabEvent updateTab, final String assetPackageUUID,
        final String assetPackageName, final ClientFactory clientFactory) {
    this.kbase = checkNotNull("kbase", kbase);
    this.config = checkNotNull("config", config);
    this.updateTab = checkNotNull("updateTab", updateTab);
    this.clientFactory = clientFactory;
    this.assetPackageUUID = assetPackageUUID;
    this.assetPackageName = assetPackageName;

    //INICIO table
    cellTable = new CellTable<ServiceKSessionConfig>(KEY_PROVIDER);
    cellTable.setWidth("100%", false);

    final SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    pager = new SimplePager(SimplePager.TextLocation.CENTER, pagerResources, false, 0, true);
    pager.setDisplay(cellTable);//from   ww w  .ja  v a  2s  .  c  o m

    initTableColumns(cellTable);
    //FIM table

    // Add the CellList to the adapter in the database.
    dataProvider.addDataDisplay(cellTable);

    dataProvider.getList().addAll(kbase.getKsessions());

    this.initWidget(uiBinder.createAndBindUi(this));

    this.root = resourceTree.addItem(treeItemFormat(kbase.getName(), images.enumeration()));

    this.loadContent();
}

From source file:org.drools.guvnor.client.rulelist.AssetTable.java

License:Apache License

private void doCellTable() {
    ProvidesKey<AssetPageRow> providesKey = new ProvidesKey<AssetPageRow>() {
        public Object getKey(AssetPageRow row) {
            return row.getUuid();
        }/*ww w . j  av  a2  s.  c om*/
    };
    cellTable = new CellTable<AssetPageRow>(providesKey);
    selectionModel = new MultiSelectionModel<AssetPageRow>(providesKey);
    cellTable.setSelectionModel(selectionModel);
    SelectionColumn.createAndAddSelectionColumn(cellTable);

    ColumnPicker<AssetPageRow> columnPicker = new ColumnPicker<AssetPageRow>(cellTable);
    SortableHeaderGroup sortableHeaderGroup = new SortableHeaderGroup<AssetPageRow>(cellTable);

    final TextColumn<AssetPageRow> uuidNumberColumn = new TextColumn<AssetPageRow>() {
        public String getValue(AssetPageRow row) {
            return row.getUuid();
        }
    };
    columnPicker.addColumn(uuidNumberColumn,
            new SortableHeader<AssetPageRow, String>(sortableHeaderGroup, constants.uuid(), uuidNumberColumn),
            false);

    Column<AssetPageRow, RuleFormatImageResource> formatColumn = new Column<AssetPageRow, RuleFormatImageResource>(
            new RuleFormatImageResourceCell()) {

        public RuleFormatImageResource getValue(AssetPageRow row) {
            return EditorLauncher.getAssetFormatIcon(row.getFormat());
        }
    };
    columnPicker.addColumn(formatColumn, new SortableHeader<AssetPageRow, RuleFormatImageResource>(
            sortableHeaderGroup, constants.Format(), formatColumn), true);

    TextColumn<AssetPageRow> packageNameColumn = new TextColumn<AssetPageRow>() {
        public String getValue(AssetPageRow row) {
            return row.getPackageName();
        }
    };
    columnPicker.addColumn(packageNameColumn, new SortableHeader<AssetPageRow, String>(sortableHeaderGroup,
            constants.PackageName(), packageNameColumn), false);

    TextColumn<AssetPageRow> nameColumn = new TextColumn<AssetPageRow>() {
        public String getValue(AssetPageRow row) {
            return row.getName();
        }
    };
    columnPicker.addColumn(nameColumn,
            new SortableHeader<AssetPageRow, String>(sortableHeaderGroup, constants.Name(), nameColumn), true);

    TextColumn<AssetPageRow> descriptionColumn = new TextColumn<AssetPageRow>() {
        public String getValue(AssetPageRow row) {
            return row.getDescription();
        }
    };
    columnPicker.addColumn(descriptionColumn, new SortableHeader<AssetPageRow, String>(sortableHeaderGroup,
            constants.Description(), descriptionColumn), true);

    TextColumn<AssetPageRow> stateNameColumn = new TextColumn<AssetPageRow>() {
        public String getValue(AssetPageRow row) {
            return row.getStateName();
        }
    };
    columnPicker.addColumn(stateNameColumn,
            new SortableHeader<AssetPageRow, String>(sortableHeaderGroup, constants.Status(), stateNameColumn),
            true);

    TextColumn<AssetPageRow> creatorColumn = new TextColumn<AssetPageRow>() {
        public String getValue(AssetPageRow row) {
            return row.getCreator();
        }
    };
    columnPicker.addColumn(creatorColumn,
            new SortableHeader<AssetPageRow, String>(sortableHeaderGroup, constants.Creator(), creatorColumn),
            false);

    Column<AssetPageRow, Date> createdDateColumn = new Column<AssetPageRow, Date>(
            new DateCell(DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_MEDIUM))) {
        public Date getValue(AssetPageRow row) {
            return row.getCreatedDate();
        }
    };
    columnPicker.addColumn(createdDateColumn, new SortableHeader<AssetPageRow, Date>(sortableHeaderGroup,
            constants.CreatedDate(), createdDateColumn), false);

    TextColumn<AssetPageRow> lastContributorColumn = new TextColumn<AssetPageRow>() {
        public String getValue(AssetPageRow row) {
            return row.getLastContributor();
        }
    };
    columnPicker.addColumn(lastContributorColumn, new SortableHeader<AssetPageRow, String>(sortableHeaderGroup,
            constants.LastContributor(), lastContributorColumn), false);

    Column<AssetPageRow, Date> lastModifiedColumn = new Column<AssetPageRow, Date>(
            new DateCell(DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_MEDIUM))) {
        public Date getValue(AssetPageRow row) {
            return row.getLastModified();
        }
    };
    columnPicker.addColumn(lastModifiedColumn, new SortableHeader<AssetPageRow, Date>(sortableHeaderGroup,
            constants.LastModified(), lastModifiedColumn), true);

    TextColumn<AssetPageRow> categorySummaryColumn = new TextColumn<AssetPageRow>() {
        public String getValue(AssetPageRow row) {
            return row.getCategorySummary();
        }
    };
    columnPicker.addColumn(categorySummaryColumn, new SortableHeader<AssetPageRow, String>(sortableHeaderGroup,
            constants.Categories(), categorySummaryColumn), false);

    TextColumn<AssetPageRow> externalSourceColumn = new TextColumn<AssetPageRow>() {
        public String getValue(AssetPageRow row) {
            return row.getExternalSource();
        }
    };
    columnPicker.addColumn(externalSourceColumn, new SortableHeader<AssetPageRow, String>(sortableHeaderGroup,
            constants.ExternalSource(), externalSourceColumn), false);

    Column<AssetPageRow, String> openColumn = new Column<AssetPageRow, String>(new ButtonCell()) {
        public String getValue(AssetPageRow row) {
            return constants.Open();
        }
    };
    openColumn.setFieldUpdater(new FieldUpdater<AssetPageRow, String>() {
        public void update(int index, AssetPageRow row, String value) {
            editEvent.open(row.getUuid());
        }
    });
    columnPicker.addColumn(openColumn, new TextHeader(constants.Open()), true);

    cellTable.setPageSize(pageSize);
    cellTable.setWidth("100%");

    pager = new SimplePager();
    pager.setDisplay(cellTable);

    dataProvider = new AsyncDataProvider<AssetPageRow>() {
        protected void onRangeChanged(HasData<AssetPageRow> display) {
            AssetPageRequest request = new AssetPageRequest();
            request.setPackageUuid(packageUuid);
            request.setFormatInList(formatInList);
            request.setFormatIsRegistered(formatIsRegistered);
            request.setStartRowIndex(pager.getPageStart());
            request.setPageSize(pageSize);
            repositoryService.findAssetPage(request, new GenericCallback<AssetPageResponse>() {
                public void onSuccess(AssetPageResponse response) {
                    updateRowCount(response.getTotalRowSize(), true);
                    updateRowData(response.getStartRowIndex(), response.getAssetPageRowList());
                }
            });
        }
    };
    dataProvider.addDataDisplay(cellTable);

    columnPickerButton = columnPicker.createToggleButton();
}

From source file:org.drools.guvnor.client.widgets.drools.tables.BuildPackageErrorsSimpleTable.java

License:Apache License

@Override
protected void doCellTable() {

    ProvidesKey<BuilderResultLine> providesKey = new ProvidesKey<BuilderResultLine>() {
        public Object getKey(BuilderResultLine row) {
            return row.getUuid();
        }/*from w  ww . j a  v  a2 s .co  m*/
    };

    cellTable = new CellTable<BuilderResultLine>(providesKey);
    selectionModel = new MultiSelectionModel<BuilderResultLine>(providesKey);
    cellTable.setSelectionModel(selectionModel);
    SelectionColumn.createAndAddSelectionColumn(cellTable);

    ColumnPicker<BuilderResultLine> columnPicker = new ColumnPicker<BuilderResultLine>(cellTable);
    SortableHeaderGroup<BuilderResultLine> sortableHeaderGroup = new SortableHeaderGroup<BuilderResultLine>(
            cellTable);

    // Add any additional columns
    addAncillaryColumns(columnPicker, sortableHeaderGroup);

    cellTable.setWidth("100%");
    columnPickerButton = columnPicker.createToggleButton();

}