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.jbpm.workbench.wi.client.editors.deployment.descriptor.DeploymentDescriptorViewImpl.java

License:Apache License

private void configureEnvironmentEntriesTable() {
    //Setup table
    environmentEntriesTable.setStriped(true);
    environmentEntriesTable.setCondensed(true);
    environmentEntriesTable.setBordered(true);
    environmentEntriesTable.setEmptyTableWidget(new Label(Constants.INSTANCE.NoDataDefined()));

    //Columns/*from w  ww . java  2s  .c o  m*/

    final Column<ItemObjectModel, String> nameColumn = new Column<ItemObjectModel, String>(new EditTextCell()) {

        @Override
        public String getValue(final ItemObjectModel item) {
            return item.getName();
        }
    };
    nameColumn.setFieldUpdater(new FieldUpdater<ItemObjectModel, String>() {
        @Override
        public void update(int index, ItemObjectModel object, String value) {
            object.setName(value);
        }
    });

    final Column<ItemObjectModel, String> valueColumn = new Column<ItemObjectModel, String>(
            new EditTextCell()) {

        @Override
        public String getValue(final ItemObjectModel item) {
            return item.getValue();
        }
    };
    valueColumn.setFieldUpdater(new FieldUpdater<ItemObjectModel, String>() {
        @Override
        public void update(int index, ItemObjectModel object, String value) {
            object.setValue(value);
        }
    });

    final Column<ItemObjectModel, String> resolverColumn = setUpResolverColumn();

    final ButtonCell parametersMSButton = new ButtonCell(IconType.ADJUST, ButtonType.PRIMARY, ButtonSize.SMALL);
    final Column<ItemObjectModel, String> parametersColumn = new Column<ItemObjectModel, String>(
            parametersMSButton) {
        @Override
        public String getValue(final ItemObjectModel item) {
            if (item.getParameters() != null) {
                return Constants.INSTANCE.DeploymentDescriptorParameters() + " (" + item.getParameters().size()
                        + ")";
            } else {
                return Constants.INSTANCE.DeploymentDescriptorParameters() + " (0)";
            }
        }
    };
    parametersColumn.setFieldUpdater(new FieldUpdater<ItemObjectModel, String>() {
        public void update(final int index, final ItemObjectModel item, final String value) {
            if (ItemObjectModel.REFLECTION_RESOLVER.equals(item.getResolver())) {
                ddParametersPopup.setContent(new Command() {

                    @Override
                    public void execute() {
                        item.setParameters(ddParametersPopup.getContent());
                        environmentEntriesDataProvider.refresh();
                    }
                }, item);
                ddParametersPopup.show();
            } else {
                Window.alert(Constants.INSTANCE.NoParamResolver());
            }
        }
    });

    final ButtonCell deleteMSButton = new ButtonCell(IconType.TRASH, ButtonType.DANGER, ButtonSize.SMALL);
    final Column<ItemObjectModel, String> deleteGlobalColumn = new Column<ItemObjectModel, String>(
            deleteMSButton) {
        @Override
        public String getValue(final ItemObjectModel item) {
            return Constants.INSTANCE.Remove();
        }
    };
    deleteGlobalColumn.setFieldUpdater(new FieldUpdater<ItemObjectModel, String>() {
        public void update(final int index, final ItemObjectModel item, final String value) {

            if (Window.confirm(Constants.INSTANCE.PromptForRemoval())) {
                environmentEntriesDataProvider.getList().remove(index);
            }
        }
    });

    environmentEntriesTable.addColumn(nameColumn, new TextHeader(Constants.INSTANCE.Name()));
    environmentEntriesTable.addColumn(valueColumn, new TextHeader(Constants.INSTANCE.Identifier()));
    environmentEntriesTable.addColumn(resolverColumn, new TextHeader(Constants.INSTANCE.Resolver()));
    environmentEntriesTable.addColumn(parametersColumn, Constants.INSTANCE.DeploymentDescriptorParameters());
    environmentEntriesTable.addColumn(deleteGlobalColumn, Constants.INSTANCE.Remove());

    //Link data
    environmentEntriesDataProvider.addDataDisplay(environmentEntriesTable);
}

From source file:org.jbpm.workbench.wi.client.editors.deployment.descriptor.DeploymentDescriptorViewImpl.java

License:Apache License

private void configureConfigurationTable() {
    //Setup table
    configurationTable.setStriped(true);
    configurationTable.setCondensed(true);
    configurationTable.setBordered(true);
    configurationTable.setEmptyTableWidget(new Label(Constants.INSTANCE.NoDataDefined()));

    //Columns/*from www. ja v a2  s.  c  o m*/

    final Column<ItemObjectModel, String> nameColumn = new Column<ItemObjectModel, String>(new EditTextCell()) {

        @Override
        public String getValue(final ItemObjectModel item) {
            return item.getName();
        }
    };
    nameColumn.setFieldUpdater(new FieldUpdater<ItemObjectModel, String>() {
        @Override
        public void update(int index, ItemObjectModel object, String value) {
            object.setName(value);
        }
    });

    final Column<ItemObjectModel, String> valueColumn = new Column<ItemObjectModel, String>(
            new EditTextCell()) {

        @Override
        public String getValue(final ItemObjectModel item) {
            return item.getValue();
        }
    };
    valueColumn.setFieldUpdater(new FieldUpdater<ItemObjectModel, String>() {
        @Override
        public void update(int index, ItemObjectModel object, String value) {
            object.setValue(value);
        }
    });

    final Column<ItemObjectModel, String> resolverColumn = setUpResolverColumn();

    final ButtonCell parametersMSButton = new ButtonCell(IconType.ADJUST, ButtonType.PRIMARY, ButtonSize.SMALL);
    final Column<ItemObjectModel, String> parametersColumn = new Column<ItemObjectModel, String>(
            parametersMSButton) {
        @Override
        public String getValue(final ItemObjectModel item) {
            if (item.getParameters() != null) {
                return Constants.INSTANCE.DeploymentDescriptorParameters() + " (" + item.getParameters().size()
                        + ")";
            } else {
                return Constants.INSTANCE.DeploymentDescriptorParameters() + " (0)";
            }
        }
    };
    parametersColumn.setFieldUpdater(new FieldUpdater<ItemObjectModel, String>() {
        public void update(final int index, final ItemObjectModel item, final String value) {
            if (ItemObjectModel.REFLECTION_RESOLVER.equals(item.getResolver())) {
                ddParametersPopup.setContent(new Command() {

                    @Override
                    public void execute() {
                        item.setParameters(ddParametersPopup.getContent());
                        configurationDataProvider.refresh();
                    }
                }, item);
                ddParametersPopup.show();
            } else {
                Window.alert(Constants.INSTANCE.NoParamResolver());
            }
        }
    });

    final ButtonCell deleteMSButton = new ButtonCell(IconType.TRASH, ButtonType.DANGER, ButtonSize.SMALL);
    final Column<ItemObjectModel, String> deleteGlobalColumn = new Column<ItemObjectModel, String>(
            deleteMSButton) {
        @Override
        public String getValue(final ItemObjectModel item) {
            return Constants.INSTANCE.Remove();
        }
    };
    deleteGlobalColumn.setFieldUpdater(new FieldUpdater<ItemObjectModel, String>() {
        public void update(final int index, final ItemObjectModel item, final String value) {

            if (Window.confirm(Constants.INSTANCE.PromptForRemoval())) {
                configurationDataProvider.getList().remove(index);
            }
        }
    });

    configurationTable.addColumn(nameColumn, new TextHeader(Constants.INSTANCE.Name()));
    configurationTable.addColumn(valueColumn, new TextHeader(Constants.INSTANCE.Identifier()));
    configurationTable.addColumn(resolverColumn, new TextHeader(Constants.INSTANCE.Resolver()));
    configurationTable.addColumn(parametersColumn, Constants.INSTANCE.DeploymentDescriptorParameters());
    configurationTable.addColumn(deleteGlobalColumn, Constants.INSTANCE.Remove());

    //Link data
    configurationDataProvider.addDataDisplay(configurationTable);
}

From source file:org.jbpm.workbench.wi.client.editors.deployment.descriptor.DeploymentDescriptorViewImpl.java

License:Apache License

private void configureRequiredRolesTable() {
    //Setup table
    requiredRolesTable.setStriped(true);
    requiredRolesTable.setCondensed(true);
    requiredRolesTable.setBordered(true);
    requiredRolesTable.setEmptyTableWidget(new Label(Constants.INSTANCE.NoDataDefined()));

    //Columns/*from  w w w  .j  a v a2s  . c o  m*/
    final Column<String, String> valueColumn = new Column<String, String>(new EditTextCell()) {

        @Override
        public String getValue(final String item) {
            return item;
        }
    };
    valueColumn.setFieldUpdater(new FieldUpdater<String, String>() {
        @Override
        public void update(int index, String object, String value) {
            requiredRolesDataProvider.getList().remove(index);
            requiredRolesDataProvider.getList().add(index, value);
        }
    });

    final ButtonCell deleteMSButton = new ButtonCell(IconType.TRASH, ButtonType.DANGER, ButtonSize.SMALL);
    final Column<String, String> deleteGlobalColumn = new Column<String, String>(deleteMSButton) {
        @Override
        public String getValue(final String item) {
            return Constants.INSTANCE.Remove();
        }
    };
    deleteGlobalColumn.setFieldUpdater(new FieldUpdater<String, String>() {
        public void update(final int index, final String item, final String value) {

            if (Window.confirm(Constants.INSTANCE.PromptForRemoval())) {
                requiredRolesDataProvider.getList().remove(index);
            }
        }
    });

    requiredRolesTable.addColumn(valueColumn, new TextHeader(Constants.INSTANCE.Value()));
    requiredRolesTable.addColumn(deleteGlobalColumn, Constants.INSTANCE.Remove());

    //Link data
    requiredRolesDataProvider.addDataDisplay(requiredRolesTable);
}

From source file:org.jbpm.workbench.wi.client.editors.deployment.descriptor.DeploymentDescriptorViewImpl.java

License:Apache License

private void configureRemoteableClassesTable() {
    //Setup table
    remoteableClassesTable.setStriped(true);
    remoteableClassesTable.setCondensed(true);
    remoteableClassesTable.setBordered(true);
    remoteableClassesTable.setEmptyTableWidget(new Label(Constants.INSTANCE.NoDataDefined()));

    //Columns// ww w.j  ava  2 s  .  c o  m
    final Column<String, String> valueColumn = new Column<String, String>(new EditTextCell()) {

        @Override
        public String getValue(final String item) {
            return item;
        }
    };
    valueColumn.setFieldUpdater(new FieldUpdater<String, String>() {
        @Override
        public void update(int index, String object, String value) {
            remoteableClassesDataProvider.getList().remove(index);
            remoteableClassesDataProvider.getList().add(index, value);
        }
    });

    final ButtonCell deleteMSButton = new ButtonCell(IconType.TRASH, ButtonType.DANGER, ButtonSize.SMALL);
    final Column<String, String> deleteGlobalColumn = new Column<String, String>(deleteMSButton) {
        @Override
        public String getValue(final String item) {
            return Constants.INSTANCE.Remove();
        }
    };
    deleteGlobalColumn.setFieldUpdater(new FieldUpdater<String, String>() {
        public void update(final int index, final String item, final String value) {

            if (Window.confirm(Constants.INSTANCE.PromptForRemoval())) {
                remoteableClassesDataProvider.getList().remove(index);
            }
        }
    });

    remoteableClassesTable.addColumn(valueColumn, new TextHeader(Constants.INSTANCE.Value()));
    remoteableClassesTable.addColumn(deleteGlobalColumn, Constants.INSTANCE.Remove());

    //Link data
    remoteableClassesDataProvider.addDataDisplay(remoteableClassesTable);
}

From source file:org.kaaproject.avro.ui.gwt.client.widget.grid.AbstractGrid.java

License:Apache License

protected float constructStringColumn(DataGrid<T> table, String title,
        final StringValueProvider<T> valueProvider, Comparator<T> comparator, Boolean isSortAscending,
        boolean filtrable, float prefWidth) {
    Header<SafeHtml> header = new SafeHtmlHeader(SafeHtmlUtils.fromSafeConstant(title));
    Column<T, String> column = null;
    if (filtrable) {
        FiltrableStringColumn<T> filtrableColumn = new FiltrableStringColumn<T>(new LinkCell()) {
            @Override//from  w w  w  .j  av  a  2  s.c om
            public String getValue(T item) {
                return valueProvider.getValue(item);
            }
        };
        filtrableColumns.add(filtrableColumn);
        column = filtrableColumn;
    } else {
        column = new Column<T, String>(new LinkCell()) {
            @Override
            public String getValue(T item) {
                return valueProvider.getValue(item);
            }
        };
    }
    column.setFieldUpdater(new FieldUpdater<T, String>() {
        @Override
        public void update(int index, T object, String value) {
            onRowClicked(getObjectId(object));
        }
    });
    table.addColumn(column, header);
    table.setColumnWidth(column, prefWidth, Unit.PX);
    processColumnSort(table, column, comparator, isSortAscending);
    return prefWidth;
}

From source file:org.kaaproject.avro.ui.gwt.client.widget.grid.AbstractGrid.java

License:Apache License

protected float constructBooleanColumn(DataGrid<T> table, String title,
        final BooleanValueProvider<T> valueProvider, Comparator<T> comparator, Boolean isSortAscending,
        float prefWidth) {
    Header<SafeHtml> header = new SafeHtmlHeader(SafeHtmlUtils.fromSafeConstant(title));
    Column<T, Boolean> column = new Column<T, Boolean>(new UneditableCheckboxCell()) {
        @Override/*from   w  w w  .j a v  a 2s.c o m*/
        public Boolean getValue(T item) {
            return valueProvider.getValue(item);
        }
    };
    column.setFieldUpdater(new FieldUpdater<T, Boolean>() {
        @Override
        public void update(int index, T object, Boolean value) {
            onRowClicked(getObjectId(object));
        }
    });
    table.addColumn(column, header);
    table.setColumnWidth(column, prefWidth, Unit.PX);
    processColumnSort(table, column, comparator, isSortAscending);
    return prefWidth;
}

From source file:org.kaaproject.kaa.server.admin.client.mvp.view.event.EventMapGrid.java

License:Apache License

@Override
protected float constructColumnsImpl(DataGrid<ApplicationEventMapDto> table) {
    float prefWidth = 0;

    prefWidth += constructStringColumn(table, Utils.constants.fqn(),
            new StringValueProvider<ApplicationEventMapDto>() {
                @Override/*  w  w w . j  a  v a2 s .c  om*/
                public String getValue(ApplicationEventMapDto item) {
                    return item.getFqn();
                }
            }, 160);

    final Renderer<ApplicationEventAction> actionRenderer = new Renderer<ApplicationEventAction>() {

        @Override
        public String render(ApplicationEventAction action) {
            return Utils.constants.getString(action.name().toLowerCase());
        }

        @Override
        public void render(ApplicationEventAction action, Appendable appendable) throws IOException {
            appendable.append(render(action));
        }
    };

    if (enableActions) {
        List<ApplicationEventAction> actions = new ArrayList<>();
        for (ApplicationEventAction action : ApplicationEventAction.values()) {
            actions.add(action);
        }

        ValueSelectionCell<ApplicationEventAction> actionsCell = new ValueSelectionCell<>(actions,
                actionRenderer);

        Column<ApplicationEventMapDto, ApplicationEventAction> actionColumn = new Column<ApplicationEventMapDto, ApplicationEventAction>(
                actionsCell) {
            @Override
            public ApplicationEventAction getValue(ApplicationEventMapDto object) {
                return object.getAction();
            }
        };

        Header<SafeHtml> actionHeader = new SafeHtmlHeader(
                SafeHtmlUtils.fromSafeConstant(Utils.constants.action()));

        table.addColumn(actionColumn, actionHeader);
        actionColumn.setFieldUpdater(new FieldUpdater<ApplicationEventMapDto, ApplicationEventAction>() {
            @Override
            public void update(int index, ApplicationEventMapDto object, ApplicationEventAction value) {
                object.setAction(value);
            }
        });
        table.setColumnWidth(actionColumn, 80, Unit.PX);
        prefWidth += 80;
    } else {
        prefWidth += constructStringColumn(table, Utils.constants.action(),
                new StringValueProvider<ApplicationEventMapDto>() {
                    @Override
                    public String getValue(ApplicationEventMapDto item) {
                        return actionRenderer.render(item.getAction());
                    }
                }, 80);
    }

    return prefWidth;
}

From source file:org.kie.dockerui.client.widgets.container.explorer.KieContainersExplorer.java

License:Apache License

/**
 * Add the columns to the table./*  w  w  w  .j av a  2  s  .com*/
 */
private void initTableColumns(final SelectionModel<KieContainer> selectionModel,
        ColumnSortEvent.ListHandler<KieContainer> sortHandler) {

    // Container status.
    final ClickableImageResourceCell statusCell = new ClickableImageResourceCell();
    final Column<KieContainer, ImageResource> statusColumn = new Column<KieContainer, ImageResource>(
            statusCell) {

        @Override
        public ImageResource getValue(final KieContainer container) {
            final boolean isUp = SharedUtils.getContainerStatus(container);
            ImageResource imageResource = null;
            String tooltipText = null;
            if (!isUp) {
                imageResource = Images.INSTANCE.circleGreyCloseIcon();
                String statusText = Constants.INSTANCE.containerIsDown();
                tooltipText = new SafeHtmlBuilder().appendEscaped(statusText).toSafeHtml().asString();
            } else {
                final KieAppStatus status = container.getAppStatus();
                imageResource = ClientUtils.getStatusImage(status);
                String statusText = ClientUtils.getStatusText(status);
                tooltipText = new SafeHtmlBuilder()
                        .appendEscaped(statusText + " (" + Constants.INSTANCE.clickForUpdate() + ")")
                        .toSafeHtml().asString();
            }
            statusCell.setTooltip(tooltipText);
            return imageResource;
        }
    };

    statusColumn.setFieldUpdater(new FieldUpdater<KieContainer, ImageResource>() {
        @Override
        public void update(int index, KieContainer object, ImageResource value) {
            updateStatus(object);
        }
    });
    containerList.addColumn(statusColumn, Constants.INSTANCE.containerStatus());
    containerList.setColumnWidth(statusColumn, 2, Style.Unit.PCT);

    // Container type cells.
    final Column<KieContainer, KieContainer> typeColumn = new Column<KieContainer, KieContainer>(
            new ContainerTypesCell()) {

        @Override
        public KieContainer getValue(KieContainer container) {
            return container;
        }
    };
    containerList.addColumn(typeColumn, Constants.INSTANCE.categories());
    containerList.setColumnWidth(typeColumn, 5, Style.Unit.PCT);

    // Container id.
    final Column<KieContainer, String> idColumn = new Column<KieContainer, String>(new EditTextCell()) {
        @Override
        public String getValue(KieContainer object) {
            return object.getTruncId();
        }
    };
    idColumn.setSortable(true);
    sortHandler.setComparator(idColumn, new Comparator<KieContainer>() {
        @Override
        public int compare(KieContainer o1, KieContainer o2) {
            return o1.getId().compareTo(o2.getId());
        }
    });
    containerList.addColumn(idColumn, Constants.INSTANCE.containerId());
    containerList.setColumnWidth(idColumn, 5, Style.Unit.PCT);

    // Container repository name.
    final Column<KieContainer, String> imageColumn = new Column<KieContainer, String>(new TextCell()) {
        @Override
        public String getValue(final KieContainer object) {
            return object.getRepository();
        }
    };
    imageColumn.setSortable(true);
    sortHandler.setComparator(imageColumn, new Comparator<KieContainer>() {
        @Override
        public int compare(KieContainer o1, KieContainer o2) {
            return o1.getRepository().compareTo(o2.getRepository());
        }
    });
    containerList.addColumn(imageColumn, Constants.INSTANCE.containerImage());
    containerList.setColumnWidth(imageColumn, 5, Style.Unit.PCT);

    // Container tag.
    final Column<KieContainer, String> tagColumn = new Column<KieContainer, String>(new TextCell()) {
        @Override
        public String getValue(final KieContainer object) {
            return object.getTag();
        }
    };
    tagColumn.setSortable(true);
    sortHandler.setComparator(tagColumn, new Comparator<KieContainer>() {
        @Override
        public int compare(KieContainer o1, KieContainer o2) {
            return o1.getTag().compareTo(o2.getTag());
        }
    });
    containerList.addColumn(tagColumn, Constants.INSTANCE.tag());
    containerList.setColumnWidth(tagColumn, 10, Style.Unit.PCT);

    // Container name.
    final Column<KieContainer, String> nameColumn = new Column<KieContainer, String>(new TextCell()) {
        @Override
        public String getValue(final KieContainer object) {
            return object.getName();
        }
    };
    nameColumn.setSortable(true);
    sortHandler.setComparator(nameColumn, new Comparator<KieContainer>() {
        @Override
        public int compare(KieContainer o1, KieContainer o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });
    containerList.addColumn(nameColumn, Constants.INSTANCE.containerName());
    containerList.setColumnWidth(nameColumn, 10, Style.Unit.PCT);

    // Container creation date.
    final Column<KieContainer, String> creationDateColumn = new Column<KieContainer, String>(new TextCell()) {
        @Override
        public String getValue(final KieContainer object) {
            return ClientUtils.formatImageDateTag(object.getCreated());
        }
    };
    creationDateColumn.setSortable(false);
    containerList.addColumn(creationDateColumn, Constants.INSTANCE.containerCreationDate());
    containerList.setColumnWidth(creationDateColumn, 5, Style.Unit.PCT);

    // Container user actions - Button cells.
    final Column<KieContainer, String> actionsColumn = new Column<KieContainer, String>(actionsCell) {
        @Override
        public String getValue(KieContainer container) {
            return container.getId();
        }
    };
    containerList.addColumn(actionsColumn, Constants.INSTANCE.actions());
    containerList.setColumnWidth(actionsColumn, 10, Style.Unit.PCT);

}

From source file:org.kie.dockerui.client.widgets.KieContainersExplorer.java

License:Apache License

/**
 * Add the columns to the table.//from  w  w  w  .  j av  a2  s.c o m
 */
private void initTableColumns(final SelectionModel<KieContainer> selectionModel,
        ColumnSortEvent.ListHandler<KieContainer> sortHandler) {

    // Container status.
    final ButtonWithTitleCell statusCell = new ButtonWithTitleCell(IconType.OK_CIRCLE);
    statusCell.setSize(ButtonSize.SMALL);
    final Column<KieContainer, String> statusColumn = new Column<KieContainer, String>(statusCell) {

        @Override
        public String getValue(final KieContainer container) {
            final KieAppStatus status = container.getAppStatus();
            final IconType iconType = ClientUtils.getStatusIcon(status);
            final StringBuilder iconTooltip = new StringBuilder(ClientUtils.getStatusText(status));
            iconTooltip.append(" (").append(Constants.INSTANCE.clickForUpdate()).append(")");
            statusCell.setIcon(iconType);
            statusCell.setTitle(iconTooltip.toString());
            return "";
        }
    };
    // TODO: Not firing
    statusColumn.setFieldUpdater(new FieldUpdater<KieContainer, String>() {
        @Override
        public void update(int index, KieContainer object, String value) {
            updateStatus(object);
        }
    });
    containerList.addColumn(statusColumn, Constants.INSTANCE.containerStatus());
    containerList.setColumnWidth(statusColumn, 2, Style.Unit.PCT);

    // Container type cells.
    final Column<KieContainer, KieContainer> typeColumn = new Column<KieContainer, KieContainer>(
            new ContainerTypesCell()) {

        @Override
        public KieContainer getValue(KieContainer container) {
            return container;
        }
    };
    containerList.addColumn(typeColumn, Constants.INSTANCE.categories());
    containerList.setColumnWidth(typeColumn, 5, Style.Unit.PCT);

    // Container id.
    final Column<KieContainer, String> idColumn = new Column<KieContainer, String>(new EditTextCell()) {
        @Override
        public String getValue(KieContainer object) {
            return object.getTruncId();
        }
    };
    idColumn.setSortable(true);
    sortHandler.setComparator(idColumn, new Comparator<KieContainer>() {
        @Override
        public int compare(KieContainer o1, KieContainer o2) {
            return o1.getId().compareTo(o2.getId());
        }
    });
    containerList.addColumn(idColumn, Constants.INSTANCE.containerId());
    containerList.setColumnWidth(idColumn, 5, Style.Unit.PCT);

    // Container repository name.
    final Column<KieContainer, String> imageColumn = new Column<KieContainer, String>(new TextCell()) {
        @Override
        public String getValue(final KieContainer object) {
            return object.getRepository();
        }
    };
    imageColumn.setSortable(true);
    sortHandler.setComparator(imageColumn, new Comparator<KieContainer>() {
        @Override
        public int compare(KieContainer o1, KieContainer o2) {
            return o1.getRepository().compareTo(o2.getRepository());
        }
    });
    containerList.addColumn(imageColumn, Constants.INSTANCE.containerImage());
    containerList.setColumnWidth(imageColumn, 5, Style.Unit.PCT);

    // Container tag.
    final Column<KieContainer, String> tagColumn = new Column<KieContainer, String>(new TextCell()) {
        @Override
        public String getValue(final KieContainer object) {
            return object.getTag();
        }
    };
    tagColumn.setSortable(true);
    sortHandler.setComparator(tagColumn, new Comparator<KieContainer>() {
        @Override
        public int compare(KieContainer o1, KieContainer o2) {
            return o1.getTag().compareTo(o2.getTag());
        }
    });
    containerList.addColumn(tagColumn, Constants.INSTANCE.tag());
    containerList.setColumnWidth(tagColumn, 10, Style.Unit.PCT);

    // Container name.
    final Column<KieContainer, String> nameColumn = new Column<KieContainer, String>(new TextCell()) {
        @Override
        public String getValue(final KieContainer object) {
            return object.getName();
        }
    };
    nameColumn.setSortable(true);
    sortHandler.setComparator(nameColumn, new Comparator<KieContainer>() {
        @Override
        public int compare(KieContainer o1, KieContainer o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });
    containerList.addColumn(nameColumn, Constants.INSTANCE.containerName());
    containerList.setColumnWidth(nameColumn, 10, Style.Unit.PCT);

    // Container creation date.
    final Column<KieContainer, String> creationDateColumn = new Column<KieContainer, String>(new TextCell()) {
        @Override
        public String getValue(final KieContainer object) {
            return DateTimeFormat.getMediumDateTimeFormat().format(object.getCreated());
        }
    };
    creationDateColumn.setSortable(false);
    containerList.addColumn(creationDateColumn, Constants.INSTANCE.containerCreationDate());
    containerList.setColumnWidth(creationDateColumn, 5, Style.Unit.PCT);

    // Container user actions - Button cells.
    final Column<KieContainer, String> actionsColumn = new Column<KieContainer, String>(actionsCell) {
        @Override
        public String getValue(KieContainer container) {
            return container.getId();
        }
    };
    containerList.addColumn(actionsColumn, Constants.INSTANCE.actions());
    containerList.setColumnWidth(actionsColumn, 10, Style.Unit.PCT);

}

From source file:org.kie.guvnor.commons.ui.client.tables.AbstractPathPagedTable.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 www  . ja  va  2 s.c o  m*/
@Override
protected void doCellTable() {

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

    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);

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

    final TextColumn<T> uriColumn = new TextColumn<T>() {
        public String getValue(T row) {
            return row.getPath().toURI();
        }
    };
    columnPicker.addColumn(uriColumn,
            new SortableHeader<T, String>(sortableHeaderGroup, TableConstants.INSTANCE.fileURI(), uriColumn),
            false);

    // Add "Open" button column
    Column<T, String> openColumn = new Column<T, String>(new ButtonCell(ButtonSize.SMALL)) {
        public String getValue(T row) {
            return TableConstants.INSTANCE.Open();
        }
    };
    openColumn.setFieldUpdater(new FieldUpdater<T, String>() {
        public void update(int index, T row, String value) {
            getPlaceManager().goTo(row.getPath());
        }
    });
    columnPicker.addColumn(openColumn, new TextHeader(TableConstants.INSTANCE.Open()), true);

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