Example usage for com.google.gwt.user.cellview.client Column setFieldUpdater

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

Introduction

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

Prototype

public void setFieldUpdater(FieldUpdater<T, C> fieldUpdater) 

Source Link

Document

Set the FieldUpdater used for updating values in the column.

Usage

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

License:Apache License

private void initTableColumns(final CellTable<ServiceKSessionConfig> cellTable) {

    // Add new row
    MyClickableImageCell addRowCell = new MyClickableImageCell(
            new MyClickableImageCell.ImageCellClickHandler() {
                public void onClick(final Cell.Context context) {
                    final ServiceKSessionConfig newKsession = new ServiceKSessionConfig(
                            kbase.getNextKSessionName());
                    kbase.addKsession(newKsession);

                    dataProvider.getList().add(newKsession);
                    dataProvider.refresh();
                    pager.lastPage();/*  w ww .j  a v  a2  s. c  o  m*/
                }
            });

    final Column<ServiceKSessionConfig, ImageResource> imageColumn = new Column<ServiceKSessionConfig, ImageResource>(
            addRowCell) {
        @Override
        public ImageResource getValue(final ServiceKSessionConfig object) {
            return images.itemImages().newItem();
        }
    };
    cellTable.addColumn(imageColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
    cellTable.setColumnWidth(imageColumn, "16px");

    // Remove active row
    MyClickableImageCell removeRowCell = new MyClickableImageCell(
            new MyClickableImageCell.ImageCellClickHandler() {
                public void onClick(final Cell.Context context) {
                    if (dataProvider.getList().size() == 1) {
                        Window.alert(Constants.INSTANCE.KBaseNeedsOneKsession());
                    } else {
                        dataProvider.getList().remove(context.getIndex());
                        kbase.removeKsession((String) context.getKey());
                        dataProvider.refresh();
                    }
                }
            });

    final Column<ServiceKSessionConfig, ImageResource> imageColumn2 = new Column<ServiceKSessionConfig, ImageResource>(
            removeRowCell) {
        @Override
        public ImageResource getValue(final ServiceKSessionConfig object) {
            return images.removeItem();
        }
    };
    cellTable.addColumn(imageColumn2, SafeHtmlUtils.fromSafeConstant("<br/>"));
    cellTable.setColumnWidth(imageColumn, "16px");

    // KSession Name
    final EditTextCell textCell = new EditTextCell();
    final Column<ServiceKSessionConfig, String> nameColumn = new Column<ServiceKSessionConfig, String>(
            textCell) {
        @Override
        public String getValue(final ServiceKSessionConfig object) {
            return object.getName();
        }
    };
    cellTable.addColumn(nameColumn, Constants.INSTANCE.Name());
    nameColumn.setFieldUpdater(new FieldUpdater<ServiceKSessionConfig, String>() {
        public void update(int index, ServiceKSessionConfig object, String value) {
            // Called when the user changes the value.
            if (object.getName().equals(value)) {
                return;
            }

            if (kbase.getKsession(value) != null) {
                Window.alert(Constants.INSTANCE.KSessionNameAlreadyExists());
                textCell.clearViewData(KEY_PROVIDER.getKey(object));
                dataProvider.flush();
                dataProvider.refresh();
                cellTable.redraw();
            } else {
                final ServiceKSessionConfig updatedKsession = new ServiceKSessionConfig(value, object);
                kbase.removeKsession(object.getName());
                kbase.addKsession(updatedKsession);
                dataProvider.getList().set(index, updatedKsession);
                dataProvider.refresh();
            }
        }
    });
    cellTable.setColumnWidth(nameColumn, "40%");

    // Type
    final List<String> sessionTypes = new ArrayList<String>(SessionType.values().length);
    for (final SessionType activeType : SessionType.values()) {
        sessionTypes.add(activeType.toString().toLowerCase());
    }

    final SelectionCell typeCell = new SelectionCell(sessionTypes);
    final Column<ServiceKSessionConfig, String> typeColumn = new Column<ServiceKSessionConfig, String>(
            typeCell) {
        @Override
        public String getValue(ServiceKSessionConfig object) {
            return object.getType().toString().toLowerCase();
        }
    };
    cellTable.addColumn(typeColumn, Constants.INSTANCE.Type());
    typeColumn.setFieldUpdater(new FieldUpdater<ServiceKSessionConfig, String>() {
        public void update(int index, ServiceKSessionConfig object, String value) {
            // Called when the user changes the value.
            object.setType(SessionType.valueOf(value.toUpperCase()));
            dataProvider.refresh();
        }
    });
    cellTable.setColumnWidth(typeColumn, "40%");

    //Advanced config
    final Column<ServiceKSessionConfig, String> configAdvanced = new Column<ServiceKSessionConfig, String>(
            new ButtonCell()) {
        @Override
        public String getValue(ServiceKSessionConfig object) {
            return "...";
        }
    };
    cellTable.addColumn(configAdvanced, Constants.INSTANCE.Config());
    configAdvanced.setFieldUpdater(new FieldUpdater<ServiceKSessionConfig, String>() {
        public void update(int index, ServiceKSessionConfig object, String value) {

            final AdvancedKSessionConfigWidget widget = new AdvancedKSessionConfigWidget(object);
            final InternalPopup popup = new InternalPopup(widget.asWidget(),
                    Constants.INSTANCE.KSessionConfiguration());
            popup.addOkButtonClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    widget.updateKSession();
                    popup.hide();
                }
            });
            popup.show();
        }
    });
    cellTable.setColumnWidth(configAdvanced, "20%");
}

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  . java 2 s  .co m
    };
    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.scorecards.GuidedScorecardWidget.java

License:Apache License

private Widget addAttributeCellTable(final DirtyableFlexTable cGrid, final Characteristic characteristic) {
    final CellTable<Attribute> attributeCellTable = new CellTable<Attribute>();

    List<String> operators = new ArrayList<String>();
    String dataType;//from   ww w. j a va 2  s  . c om
    if (characteristic == null) {
        dataType = "String";
    } else {
        dataType = characteristic.getDataType();
    }

    if ("String".equalsIgnoreCase(dataType)) {
        operators.addAll(Arrays.asList(stringOperators));
    } else if ("boolean".equalsIgnoreCase(dataType)) {
        operators.addAll(Arrays.asList(booleanOperators));
    } else {
        operators.addAll(Arrays.asList(numericOperators));
    }
    DynamicSelectionCell categoryCell = new DynamicSelectionCell(operators);
    Column<Attribute, String> operatorColumn = new Column<Attribute, String>(categoryCell) {
        public String getValue(Attribute object) {
            return object.getOperator();
        }
    };

    Column<Attribute, String> valueColumn = new Column<Attribute, String>(new CustomEditTextCell()) {
        public String getValue(Attribute attribute) {
            return attribute.getValue();
        }
    };
    final EditTextCell partialScoreCell = new EditTextCell();
    Column<Attribute, String> partialScoreColumn = new Column<Attribute, String>(partialScoreCell) {
        public String getValue(Attribute attribute) {
            return "" + attribute.getPartialScore();
        }
    };

    Column<Attribute, String> reasonCodeColumn = new Column<Attribute, String>(new EditTextCell()) {
        public String getValue(Attribute attribute) {
            return attribute.getReasonCode();
        }
    };

    ActionCell.Delegate<Attribute> delegate = new ActionCell.Delegate<Attribute>() {
        public void execute(Attribute attribute) {
            if (Window.confirm("Remove this attribute?")) {
                List<Attribute> list = characteristicsAttrMap.get(cGrid).getList();
                list.remove(attribute);
                ((EnumDropDown) cGrid.getWidget(2, 0)).setEnabled(list.size() == 0);
                ((EnumDropDown) cGrid.getWidget(2, 1)).setEnabled(list.size() == 0);
                ((Button) cGrid.getWidget(0, 3)).setEnabled(list.size() != 2);
                attributeCellTable.redraw();
            }
        }
    };
    Cell<Attribute> actionCell = new ActionCell<Attribute>("Remove", delegate);
    Column<Attribute, String> actionColumn = new IdentityColumn(actionCell);

    reasonCodeColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
        public void update(int index, Attribute object, String value) {
            object.setReasonCode(value);
            attributeCellTable.redraw();
        }
    });
    operatorColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
        public void update(int index, Attribute object, String value) {
            object.setOperator(value);
            attributeCellTable.redraw();
        }
    });
    valueColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
        public void update(int index, Attribute object, String value) {
            object.setValue(value);
            attributeCellTable.redraw();
        }
    });
    partialScoreColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
        public void update(int index, Attribute object, String value) {
            try {
                double d = Double.parseDouble(value);
                object.setPartialScore(d);
            } catch (Exception e1) {
                partialScoreCell.clearViewData(object);
            }
            attributeCellTable.redraw();
        }
    });
    // Add the columns.
    attributeCellTable.addColumn(operatorColumn, "Operator");
    attributeCellTable.addColumn(valueColumn, "Value");
    attributeCellTable.addColumn(partialScoreColumn, "Partial Score");
    attributeCellTable.addColumn(reasonCodeColumn, "Reason Code");
    attributeCellTable.addColumn(actionColumn, "Actions");
    attributeCellTable.setWidth("100%", true);

    attributeCellTable.setColumnWidth(operatorColumn, 5.0, Style.Unit.PCT);
    attributeCellTable.setColumnWidth(valueColumn, 10.0, Style.Unit.PCT);
    attributeCellTable.setColumnWidth(partialScoreColumn, 10.0, Style.Unit.PCT);
    attributeCellTable.setColumnWidth(reasonCodeColumn, 10.0, Style.Unit.PCT);
    attributeCellTable.setColumnWidth(actionColumn, 5.0, Style.Unit.PCT);

    ListDataProvider<Attribute> dataProvider = new ListDataProvider<Attribute>();
    dataProvider.addDataDisplay(attributeCellTable);
    characteristicsAttrMap.put(cGrid, dataProvider);
    return (attributeCellTable);
}

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

License:Apache License

@Override
protected void addAncillaryColumns(ColumnPicker<BuilderResultLine> columnPicker,
        SortableHeaderGroup<BuilderResultLine> sortableHeaderGroup) {

    Column<BuilderResultLine, String> uuidColumn = new TextColumn<BuilderResultLine>() {
        public String getValue(BuilderResultLine row) {
            return row.getUuid();
        }/* www.j a  v  a2s. co m*/
    };
    columnPicker.addColumn(uuidColumn, new SortableHeader<BuilderResultLine, String>(sortableHeaderGroup,
            Constants.INSTANCE.uuid(), uuidColumn), false);

    Column<BuilderResultLine, String> assetNameColumn = new TextColumn<BuilderResultLine>() {
        public String getValue(BuilderResultLine row) {
            return row.getAssetName();
        }
    };
    columnPicker.addColumn(assetNameColumn, new SortableHeader<BuilderResultLine, String>(sortableHeaderGroup,
            Constants.INSTANCE.Name(), assetNameColumn), true);

    Column<BuilderResultLine, ComparableImageResource> formatColumn = new Column<BuilderResultLine, ComparableImageResource>(
            new ComparableImageResourceCell()) {

        public ComparableImageResource getValue(BuilderResultLine row) {
            AssetEditorFactory factory = clientFactory.getAssetEditorFactory();
            return new ComparableImageResource(row.getAssetFormat(),
                    factory.getAssetEditorIcon(row.getAssetFormat()));
        }
    };
    columnPicker.addColumn(formatColumn, new SortableHeader<BuilderResultLine, ComparableImageResource>(
            sortableHeaderGroup, Constants.INSTANCE.Format(), formatColumn), true);

    Column<BuilderResultLine, String> messageColumn = new TextColumn<BuilderResultLine>() {
        public String getValue(BuilderResultLine row) {
            return row.getMessage();
        }
    };
    columnPicker.addColumn(messageColumn, new SortableHeader<BuilderResultLine, String>(sortableHeaderGroup,
            Constants.INSTANCE.Message1(), messageColumn), true);

    // Add "Open" button column
    Column<BuilderResultLine, String> openColumn = new Column<BuilderResultLine, String>(new ButtonCell()) {
        public String getValue(BuilderResultLine row) {
            return Constants.INSTANCE.Open();
        }
    };
    openColumn.setFieldUpdater(new FieldUpdater<BuilderResultLine, String>() {
        public void update(int index, BuilderResultLine row, String value) {
            clientFactory.getPlaceController().goTo(new AssetEditorPlace(row.getUuid()));
        }
    });
    columnPicker.addColumn(openColumn, new TextHeader(Constants.INSTANCE.Open()), true);

}

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

License:Apache License

@Override
protected void addAncillaryColumns(ColumnPicker<PropertyHolderAdaptor> columnPicker,
        SortableHeaderGroup<PropertyHolderAdaptor> sortableHeaderGroup) {

    Column<PropertyHolderAdaptor, String> propertyNameColumn = new Column<PropertyHolderAdaptor, String>(
            new PopupTextEditCell()) {

        @Override/*from w w  w. ja  v a 2s  .c om*/
        public String getValue(PropertyHolderAdaptor object) {
            return object.getName();
        }

    };
    propertyNameColumn.setFieldUpdater(new FieldUpdater<PropertyHolderAdaptor, String>() {

        public void update(int index, PropertyHolderAdaptor object, String value) {
            object.setName(value);
        }

    });
    columnPicker.addColumn(propertyNameColumn, new SortableHeader<PropertyHolderAdaptor, String>(
            sortableHeaderGroup, Constants.INSTANCE.Item(), propertyNameColumn), true);

    Column<PropertyHolderAdaptor, String> propertyValueColumn = new Column<PropertyHolderAdaptor, String>(
            new PopupTextEditCell()) {

        @Override
        public String getValue(PropertyHolderAdaptor object) {
            return object.getValue();
        }

    };
    propertyValueColumn.setFieldUpdater(new FieldUpdater<PropertyHolderAdaptor, String>() {

        public void update(int index, PropertyHolderAdaptor object, String value) {
            object.setValue(value);
        }

    });
    columnPicker.addColumn(propertyValueColumn, new SortableHeader<PropertyHolderAdaptor, String>(
            sortableHeaderGroup, Constants.INSTANCE.Value(), propertyValueColumn), true);

}

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

License:Apache License

@Override
protected void doCellTable() {

    ProvidesKey<SnapshotComparisonPageRow> providesKey = new ProvidesKey<SnapshotComparisonPageRow>() {
        public Object getKey(SnapshotComparisonPageRow row) {
            return row.getDiff().leftUuid;
        }/*from  w  ww  .j av  a  2 s  .co m*/
    };

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

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

    final TextColumn<SnapshotComparisonPageRow> uuidNumberColumn = new TextColumn<SnapshotComparisonPageRow>() {
        public String getValue(SnapshotComparisonPageRow row) {
            return row.getDiff().rightUuid;
        }
    };
    columnPicker.addColumn(uuidNumberColumn, new SortableHeader<SnapshotComparisonPageRow, String>(
            sortableHeaderGroup, Constants.INSTANCE.uuid(), uuidNumberColumn), false);

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

    // Add "Open" button column
    Column<SnapshotComparisonPageRow, String> openColumn = new Column<SnapshotComparisonPageRow, String>(
            new ButtonCell()) {
        public String getValue(SnapshotComparisonPageRow row) {
            return Constants.INSTANCE.Open();
        }
    };
    openColumn.setFieldUpdater(new FieldUpdater<SnapshotComparisonPageRow, String>() {
        public void update(int index, SnapshotComparisonPageRow row, String value) {
            clientFactory.getPlaceController().goTo(new AssetEditorPlace(row.getDiff().rightUuid));
        }
    });
    columnPicker.addColumn(openColumn, new TextHeader(Constants.INSTANCE.Open()), true);

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

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

License:Apache License

/**
 * Set up table and common columns. Additional columns can be appended
 * between the "checkbox" and "open" columns by overriding
 * <code>addAncillaryColumns()</code>
 *//*from   w  w w. jav  a  2 s.  co m*/
@Override
protected void doCellTable() {

    ProvidesKey<T> providesKey = new ProvidesKey<T>() {
        public Object getKey(T row) {
            return row.getUuid();
        }
    };

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

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

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

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

    // Add "Open" button column
    Column<T, String> openColumn = new Column<T, String>(new ButtonCell()) {
        public String getValue(T row) {
            return constants.Open();
        }
    };
    openColumn.setFieldUpdater(new FieldUpdater<T, String>() {
        public void update(int index, T row, String value) {
            clientFactory.getPlaceController().goTo(new AssetEditorPlace(row.getUuid()));
        }
    });
    columnPicker.addColumn(openColumn, new TextHeader(constants.Open()), true);

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

}

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

License:Apache License

@Override
protected void addAncillaryColumns(ColumnPicker<BuilderResultLine> columnPicker,
        SortableHeaderGroup<BuilderResultLine> sortableHeaderGroup) {

    Column<BuilderResultLine, String> uuidColumn = new TextColumn<BuilderResultLine>() {
        public String getValue(BuilderResultLine row) {
            return row.getUuid();
        }//  w  ww  . j av  a 2  s .  co  m
    };
    columnPicker.addColumn(uuidColumn,
            new SortableHeader<BuilderResultLine, String>(sortableHeaderGroup, constants.uuid(), uuidColumn),
            false);

    Column<BuilderResultLine, String> assetNameColumn = new TextColumn<BuilderResultLine>() {
        public String getValue(BuilderResultLine row) {
            return row.getAssetName();
        }
    };
    columnPicker.addColumn(assetNameColumn, new SortableHeader<BuilderResultLine, String>(sortableHeaderGroup,
            constants.Name(), assetNameColumn), true);

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

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

    Column<BuilderResultLine, String> messageColumn = new TextColumn<BuilderResultLine>() {
        public String getValue(BuilderResultLine row) {
            return row.getMessage();
        }
    };
    columnPicker.addColumn(messageColumn, new SortableHeader<BuilderResultLine, String>(sortableHeaderGroup,
            constants.Message1(), messageColumn), true);

    // Add "Open" button column
    Column<BuilderResultLine, String> openColumn = new Column<BuilderResultLine, String>(new ButtonCell()) {
        public String getValue(BuilderResultLine row) {
            return constants.Open();
        }
    };
    openColumn.setFieldUpdater(new FieldUpdater<BuilderResultLine, String>() {
        public void update(int index, BuilderResultLine row, String value) {
            openSelectedCommand.open(row.getUuid());
        }
    });
    columnPicker.addColumn(openColumn, new TextHeader(constants.Open()), true);

}

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

License:Apache License

@Override
protected void doCellTable() {
    ProvidesKey<DependenciesPageRow> providesKey = new ProvidesKey<DependenciesPageRow>() {
        public Object getKey(DependenciesPageRow row) {
            return row.getDependencyPath();
        }//from w w  w .ja  v  a2s  .  c  om
    };

    cellTable = new CellTable<DependenciesPageRow>(providesKey);
    selectionModel = new SingleSelectionModel<DependenciesPageRow>(providesKey);
    cellTable.setSelectionModel(selectionModel);
    SelectionColumn.createAndAddSelectionColumn(cellTable);

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

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

    // Add "Open" button column

    Column<DependenciesPageRow, String> openColumn = new Column<DependenciesPageRow, String>(new ButtonCell()) {
        public String getValue(DependenciesPageRow row) {
            return constants.Open();
        }
    };
    openColumn.setFieldUpdater(new FieldUpdater<DependenciesPageRow, String>() {
        public void update(int index, DependenciesPageRow row, String value) {
            openSelectedCommand.open(
                    DependencyWidget.encodeDependencyPath(row.getDependencyPath(), row.getDependencyVersion()));
        }
    });

    columnPicker.addColumn(openColumn, new TextHeader(constants.Open()), true);

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

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

License:Apache License

@Override
protected void doCellTable() {
    ProvidesKey<PermissionsPageRow> providesKey = new ProvidesKey<PermissionsPageRow>() {
        public Object getKey(PermissionsPageRow row) {
            return row.getUserName();
        }/* w ww  . j a v a 2  s .co m*/
    };

    cellTable = new CellTable<PermissionsPageRow>(providesKey);
    selectionModel = new SingleSelectionModel<PermissionsPageRow>(providesKey);
    cellTable.setSelectionModel(selectionModel);
    SelectionColumn.createAndAddSelectionColumn(cellTable);

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

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

    // Add "Open" button column
    Column<PermissionsPageRow, String> openColumn = new Column<PermissionsPageRow, String>(new ButtonCell()) {
        public String getValue(PermissionsPageRow row) {
            return constants.Open();
        }
    };
    openColumn.setFieldUpdater(new FieldUpdater<PermissionsPageRow, String>() {
        public void update(int index, PermissionsPageRow row, String value) {
            openSelectedCommand.open(row.getUserName());
        }
    });
    columnPicker.addColumn(openColumn, new TextHeader(constants.Open()), true);

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