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.jboss.as.console.client.teiid.runtime.VDBModelsTab.java

License:Open Source License

private DefaultCellTable getModelTable(ListHandler<Model> sortHandler) {
    ProvidesKey keyProvider = new ProvidesKey<Model>() {
        @Override/*w ww . j av a 2s. co m*/
        public Object getKey(Model item) {
            String key = "";
            if (!item.getSourceMappings().isEmpty()) {
                SourceMapping sm = item.getSourceMappings().get(0);
                key = sm.getSourceName();
            }
            return getVdbName() + "." + getVdbVersion() + "." + item.getName() + "." + key;
        }
    };

    final DefaultCellTable modelsTable = new DefaultCellTable<Model>(5, keyProvider);
    modelsTable.addColumnSortHandler(sortHandler);

    TextColumn<Model> nameColumn = new TextColumn<Model>() {
        @Override
        public String getValue(Model record) {
            return record.getName();
        }
    };
    nameColumn.setSortable(true);
    sortHandler.setComparator(nameColumn, new Comparator<Model>() {
        @Override
        public int compare(Model o1, Model o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });

    TextColumn<Model> modelTypeColumn = new TextColumn<Model>() {
        @Override
        public String getValue(Model record) {
            return record.getModelType();
        }
    };
    modelTypeColumn.setSortable(true);
    sortHandler.setComparator(modelTypeColumn, new Comparator<Model>() {
        @Override
        public int compare(Model o1, Model o2) {
            return o1.getModelType().compareTo(o2.getModelType());
        }
    });

    TextColumn<Model> visibleColumn = new TextColumn<Model>() {
        @Override
        public String getValue(Model record) {
            return String.valueOf(record.isVisible());
        }
    };
    visibleColumn.setSortable(true);
    sortHandler.setComparator(visibleColumn, new Comparator<Model>() {
        @Override
        public int compare(Model o1, Model o2) {
            return o1.isVisible().compareTo(o2.isVisible());
        }
    });

    TextColumn<Model> multiSourceColumn = new TextColumn<Model>() {
        @Override
        public String getValue(Model record) {
            return String.valueOf(isMultiSource(record));
        }
    };

    final TextColumn<Model> sourceNameColumn = new TextColumn<Model>() {
        @Override
        public String getValue(Model record) {
            if (isSource(record)) {
                return record.getSourceMappings().get(0).getSourceName();
            }
            return "";
        }
    };
    sourceNameColumn.setSortable(true);
    sortHandler.setComparator(sourceNameColumn, new Comparator<Model>() {
        @Override
        public int compare(Model o1, Model o2) {
            SourceMapping sm1 = o1.getSourceMappings().get(0);
            SourceMapping sm2 = o2.getSourceMappings().get(0);
            return sm1.getSourceName().compareTo(sm2.getSourceName());
        }
    });

    Column<Model, String> jndiNameColumn = new Column<Model, String>(new EditTextCell()) {
        @Override
        public String getValue(Model record) {
            if (isSource(record)) {
                return record.getSourceMappings().get(0).getJndiName();
            }
            return "";
        }
    };
    jndiNameColumn.setFieldUpdater(new FieldUpdater<Model, String>() {
        public void update(int index, Model model, String value) {
            changeDataSourceName(model, value);
        }
    });
    jndiNameColumn.setSortable(true);
    sortHandler.setComparator(jndiNameColumn, new Comparator<Model>() {
        @Override
        public int compare(Model o1, Model o2) {
            SourceMapping sm1 = o1.getSourceMappings().get(0);
            SourceMapping sm2 = o2.getSourceMappings().get(0);
            return sm1.getJndiName().compareTo(sm2.getJndiName());
        }
    });

    TextColumn<Model> translatorNameColumn = new TextColumn<Model>() {
        @Override
        public String getValue(Model record) {
            if (isSource(record)) {
                return record.getSourceMappings().get(0).getTranslatorName();
            }
            return "";
        }
    };
    translatorNameColumn.setFieldUpdater(new FieldUpdater<Model, String>() {
        public void update(int index, Model model, String value) {
            changeTranslatorName(model, value);
        }
    });
    translatorNameColumn.setSortable(true);
    sortHandler.setComparator(translatorNameColumn, new Comparator<Model>() {
        @Override
        public int compare(Model o1, Model o2) {
            SourceMapping sm1 = o1.getSourceMappings().get(0);
            SourceMapping sm2 = o2.getSourceMappings().get(0);
            return sm1.getTranslatorName().compareTo(sm2.getTranslatorName());
        }
    });

    Column<Model, String> schemaBtn = new Column<Model, String>(new ButtonCell()) {
        @Override
        public String getValue(Model record) {
            return "DDL";
        }
    };
    schemaBtn.setFieldUpdater(new FieldUpdater<Model, String>() {
        @Override
        public void update(int index, Model model, String value) {
            showSchema(model);
        }
    });

    modelsTable.setTitle("Models");
    modelsTable.addColumn(nameColumn, "Name");
    modelsTable.addColumn(modelTypeColumn, "Type");
    modelsTable.addColumn(visibleColumn, "Visible?");
    modelsTable.addColumn(multiSourceColumn, "Multi-Source?");
    modelsTable.addColumn(sourceNameColumn, "Source Name");
    modelsTable.addColumn(translatorNameColumn, "Translator Name");
    modelsTable.addColumn(jndiNameColumn, "Datasource JNDI Name");
    modelsTable.addColumn(schemaBtn, "Schema");

    modelsTable.setSelectionModel(new SingleSelectionModel<Model>(keyProvider));

    modelsTable.getColumnSortList().push(nameColumn);

    return modelsTable;
}

From source file:org.jboss.as.console.client.teiid.runtime.VDBRequestsTab.java

License:Open Source License

private DefaultCellTable getRequestsTable(ListHandler<Request> sortHandler, final boolean sourceTable) {
    ProvidesKey<Request> keyProvider = new ProvidesKey<Request>() {
        @Override/*from  w w  w  . j  av  a 2  s . c  o m*/
        public Object getKey(Request item) {
            if (sourceTable) {
                return item.getNodeId();
            }
            return item.getExecutionId();
        }
    };

    final DefaultCellTable table = new DefaultCellTable<Request>(20, keyProvider);
    table.addColumnSortHandler(sortHandler);

    TextColumn<Request> executionIdColumn = new TextColumn<Request>() {
        @Override
        public String getValue(Request record) {
            if (sourceTable) {
                return String.valueOf(record.getNodeId());
            }
            return String.valueOf(record.getExecutionId());
        }
    };
    executionIdColumn.setSortable(true);
    sortHandler.setComparator(executionIdColumn, new Comparator<Request>() {
        @Override
        public int compare(Request o1, Request o2) {
            return o1.getExecutionId().compareTo(o2.getExecutionId());
        }
    });

    TextColumn<Request> sessionIdColumn = new TextColumn<Request>() {
        @Override
        public String getValue(Request record) {
            return String.valueOf(record.getSessionId());
        }
    };
    sessionIdColumn.setSortable(true);
    sortHandler.setComparator(sessionIdColumn, new Comparator<Request>() {
        @Override
        public int compare(Request o1, Request o2) {
            return o1.getSessionId().compareTo(o2.getSessionId());
        }
    });

    Column<Request, Date> timeColumn = new Column<Request, Date>(new DateCell()) {
        @Override
        public Date getValue(Request record) {
            return new Date(record.getStartTime());
        }
    };
    timeColumn.setSortable(true);
    sortHandler.setComparator(timeColumn, new Comparator<Request>() {
        @Override
        public int compare(Request o1, Request o2) {
            return o1.getStartTime().compareTo(o2.getStartTime());
        }
    });

    Column<Request, String> cmdColumn = new Column<Request, String>(new ClickableTextCell()) {
        @Override
        public String getValue(Request record) {
            return record.getCommand();
        }
    };
    sortHandler.setComparator(cmdColumn, new Comparator<Request>() {
        @Override
        public int compare(Request o1, Request o2) {
            return o1.getCommand().compareTo(o2.getCommand());
        }
    });

    Column<Request, String> planBtn = new Column<Request, String>(new ButtonCell()) {
        @Override
        public String getValue(Request record) {
            return "Plan";
        }
    };
    planBtn.setFieldUpdater(new FieldUpdater<Request, String>() {
        @Override
        public void update(int index, Request request, String value) {
            showPlanDialog(request);
        }
    });
    Column<Request, String> cancelBtn = new Column<Request, String>(new ButtonCell()) {
        @Override
        public String getValue(Request record) {
            return "Cancel";
        }
    };
    cancelBtn.setFieldUpdater(new FieldUpdater<Request, String>() {
        @Override
        public void update(int index, Request request, String value) {
            cancelQuery(request);
        }
    });

    table.setSelectionModel(new SingleSelectionModel<Request>(keyProvider));

    table.setTitle("Requests");
    if (sourceTable) {
        table.addColumn(executionIdColumn, "Node Id");
    } else {
        table.addColumn(executionIdColumn, "Execution Id");
    }
    table.addColumn(sessionIdColumn, "Session Id");
    table.addColumn(timeColumn, "Start Time");
    table.addColumn(cmdColumn, "Command");
    if (!sourceTable) {
        table.addColumn(planBtn, "Query Plan");
        table.addColumn(cancelBtn, "Cancel Query");
    }

    // sets initial sorting
    table.getColumnSortList().push(executionIdColumn);
    return table;
}

From source file:org.jboss.as.console.client.teiid.runtime.VDBSessionsTab.java

License:Open Source License

private DefaultCellTable getSessionTable(ListHandler<Session> sortHandler) {
    ProvidesKey<Session> keyProvider = new ProvidesKey<Session>() {
        @Override/*from  w  w  w . j a  va 2  s  . c om*/
        public Object getKey(Session item) {
            return item.getSessionId();
        }
    };

    final DefaultCellTable table = new DefaultCellTable<Session>(20, keyProvider);
    table.addColumnSortHandler(sortHandler);

    TextColumn<Session> idColumn = new TextColumn<Session>() {
        @Override
        public String getValue(Session record) {
            return record.getSessionId();
        }
    };
    idColumn.setSortable(true);
    sortHandler.setComparator(idColumn, new Comparator<Session>() {
        @Override
        public int compare(Session o1, Session o2) {
            return o1.getSessionId().compareTo(o2.getSessionId());
        }
    });

    TextColumn<Session> userNameColumn = new TextColumn<Session>() {
        @Override
        public String getValue(Session record) {
            return String.valueOf(record.getUserName());
        }
    };
    userNameColumn.setSortable(true);
    sortHandler.setComparator(userNameColumn, new Comparator<Session>() {
        @Override
        public int compare(Session o1, Session o2) {
            return o1.getUserName().compareTo(o2.getUserName());
        }
    });

    TextColumn<Session> createdColumn = new TextColumn<Session>() {
        @Override
        public String getValue(Session record) {
            return dtf.format(new Date(record.getCreatedTime()), TimeZone.createTimeZone(0));
        }
    };
    createdColumn.setSortable(true);
    sortHandler.setComparator(createdColumn, new Comparator<Session>() {
        @Override
        public int compare(Session o1, Session o2) {
            return o1.getCreatedTime().compareTo(o2.getCreatedTime());
        }
    });

    TextColumn<Session> lastPingColumn = new TextColumn<Session>() {
        @Override
        public String getValue(Session record) {
            return dtf.format(new Date(Long.parseLong(record.getLastPingTime())), TimeZone.createTimeZone(0));
        }
    };
    lastPingColumn.setSortable(true);
    sortHandler.setComparator(lastPingColumn, new Comparator<Session>() {
        @Override
        public int compare(Session o1, Session o2) {
            return o1.getLastPingTime().compareTo(o2.getLastPingTime());
        }
    });

    TextColumn<Session> applicationNameColumn = new TextColumn<Session>() {
        @Override
        public String getValue(Session record) {
            return record.getApplicationName();
        }
    };
    applicationNameColumn.setSortable(true);
    sortHandler.setComparator(applicationNameColumn, new Comparator<Session>() {
        @Override
        public int compare(Session o1, Session o2) {
            return o1.getApplicationName().compareTo(o2.getApplicationName());
        }
    });

    Column<Session, String> terminateBtn = new Column<Session, String>(new ButtonCell()) {
        @Override
        public String getValue(Session record) {
            return "Terminate";
        }
    };
    terminateBtn.setFieldUpdater(new FieldUpdater<Session, String>() {
        @Override
        public void update(int index, Session session, String value) {
            terminate(session);
        }
    });

    table.setSelectionModel(new SingleSelectionModel<Session>(keyProvider));

    table.setTitle("Sessions");
    table.addColumn(idColumn, "Session Id");
    table.addColumn(userNameColumn, "User");
    table.addColumn(createdColumn, "Created");
    table.addColumn(lastPingColumn, "Last Ping");
    table.addColumn(applicationNameColumn, "Application");
    table.addColumn(terminateBtn, "Terminate");

    // sets initial sorting
    table.getColumnSortList().push(idColumn);

    return table;
}

From source file:org.jboss.as.console.client.teiid.runtime.VDBView.java

License:Open Source License

Widget mainPageAsWidget() {
    ListHandler<VDB> sortHandler = new ListHandler<VDB>(this.vdbProvider.getList());

    final ToolStrip toolStrip = new ToolStrip();
    toolStrip.addToolButtonRight(new ToolButton(Console.CONSTANTS.common_label_refresh(), new ClickHandler() {
        @Override/* w  w  w.  j  av a2s .c  o  m*/
        public void onClick(ClickEvent event) {
            presenter.refresh(false);
        }
    }));

    DefaultCellTable<VDB> table = new DefaultCellTable<VDB>(5, new ProvidesKey<VDB>() {
        @Override
        public Object getKey(VDB item) {
            return item.getName() + "_" + item.getVersion();
        }
    });

    table.addColumnSortHandler(sortHandler);

    TextColumn<VDB> nameColumn = new TextColumn<VDB>() {
        @Override
        public String getValue(VDB record) {
            return record.getName();
        }
    };
    nameColumn.setSortable(true);
    sortHandler.setComparator(nameColumn, new Comparator<VDB>() {
        @Override
        public int compare(VDB o1, VDB o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });

    Column<VDB, Number> versionColumn = new Column<VDB, Number>(new NumberCell()) {
        @Override
        public Number getValue(VDB vdb) {
            return vdb.getVersion();
        }
    };
    versionColumn.setSortable(true);
    sortHandler.setComparator(versionColumn, new Comparator<VDB>() {
        @Override
        public int compare(VDB o1, VDB o2) {
            return o1.getVersion().compareTo(o2.getVersion());
        }
    });

    TextColumn<VDB> dynamicColumn = new TextColumn<VDB>() {
        @Override
        public String getValue(VDB record) {
            return String.valueOf(record.isDynamic());
        }
    };
    dynamicColumn.setSortable(true);
    sortHandler.setComparator(dynamicColumn, new Comparator<VDB>() {
        @Override
        public int compare(VDB o1, VDB o2) {
            return o1.isDynamic().compareTo(o2.isDynamic());
        }
    });

    TextColumn<VDB> statusColumn = new TextColumn<VDB>() {
        @Override
        public String getValue(VDB record) {
            return String.valueOf(record.getStatus());
        }
    };
    statusColumn.setSortable(true);
    sortHandler.setComparator(statusColumn, new Comparator<VDB>() {
        @Override
        public int compare(VDB o1, VDB o2) {
            return o1.getStatus().compareTo(o2.getStatus());
        }
    });

    Column<VDB, ImageResource> validColumn = new Column<VDB, ImageResource>(new ImageResourceCell()) {
        @Override
        public ImageResource getValue(VDB vdb) {
            ImageResource res = null;
            if (vdb.isValid()) {
                res = Icons.INSTANCE.status_good();
            } else {
                res = TeiidIcons.INSTANCE.status_not_ok();
            }
            return res;
        }
    };
    validColumn.setSortable(true);
    sortHandler.setComparator(validColumn, new Comparator<VDB>() {
        @Override
        public int compare(VDB o1, VDB o2) {
            return o1.isValid().compareTo(o2.isValid());
        }
    });

    Column<VDB, String> reloadBtn = new Column<VDB, String>(new ButtonCell()) {
        @Override
        public String getValue(VDB record) {
            return "Reload";
        }
    };
    reloadBtn.setFieldUpdater(new FieldUpdater<VDB, String>() {
        @Override
        public void update(int index, VDB vdb, String value) {
            reloadVDB(vdb);
        }
    });

    table.addColumn(nameColumn, "Name");
    table.addColumn(versionColumn, "Version");
    table.addColumn(dynamicColumn, "Dynamic");
    table.addColumn(statusColumn, "Status");
    table.addColumn(validColumn, "Valid");
    table.addColumn(reloadBtn, "Reload");

    // sets initial sorting
    table.getColumnSortList().push(nameColumn);

    this.vdbTable = table;
    this.vdbProvider.addDataDisplay(table);

    this.vdbRequestsTab = new VDBRequestsTab(presenter);
    this.vdbModelsTab = new VDBModelsTab(this.presenter);
    this.vdbModelsTab.setDataModelFactory(factory);

    this.vdbSessionsTab = new VDBSessionsTab(presenter);
    this.vdbCachingTab = new VDBCachingTab(presenter);

    // Page layout
    MultipleToOneLayout layout = new MultipleToOneLayout().setPlain(true).setTitle("VDB Panel")
            .setDescription(new SafeHtmlBuilder().appendHtmlConstant("").toSafeHtml())
            .setHeadline("Deployed Virtual Databases").setTopLevelTools(toolStrip)
            .setMaster("Deployed VDBS", table)
            .addDetail("Summary", new VDBSummaryTab(this.presenter).getPanel(table))
            .addDetail("Models", this.vdbModelsTab.getPanel(table))
            .addDetail("Overrides", new VDBTranslatorsTab(this.presenter).getPanel(table))
            .addDetail("Caching", this.vdbCachingTab.getPanel(table))
            .addDetail("Data Roles", new VDBDataRolesTab(this.presenter).getPanel(table))
            .addDetail("Requests", this.vdbRequestsTab.getPanel(table))
            .addDetail("Sessions", this.vdbSessionsTab.getPanel(table));
    return layout.build();
}

From source file:org.jboss.ci.tracker.client.widgets.CategorizationList.java

License:Open Source License

/**
 * Sets properties of name column of categorization data grid.
 *///from  w  w  w .  j  a  v a  2s. c  o m
private void setCategorizationNameColumn() {
    Column<CategorizationDto, String> column = new Column<CategorizationDto, String>(
            new CustomWidgets.CustomCell()) {
        @Override
        public String getValue(CategorizationDto object) {
            return object.getName();
        }

        // TODO: Mark better the possibility to enter a new row
        // I think this could be the right direction but currently it's just a waste of time - not able to get it running right now
        //            @Override
        //            public void onBrowserEvent(Context context, com.google.gwt.dom.client.Element elem, CategorizationDto object, NativeEvent event) {
        //                if (event.getType().equals(DoubleClickEvent.getType().getName())) {
        //                    Window.alert(event.getString() + " | " + event.getType());
        //                }
        //            }
    };

    categorizationDataGrid.addColumn(column, "Group of parameterizations");

    column.setFieldUpdater(new FieldUpdater<CategorizationDto, String>() {
        @Override
        public void update(int index, final CategorizationDto categorization, String value) {
            if (!value.equals(categorization.getName())) {
                if (categorization.getId() == null && (categorization.getName().equals(LABEL_OF_NEW_ROW))) {
                    addNewCategorizationRow(categorizationDataProvider.getList());
                }

                categorization.setName(value);

                categorizationService.saveCategorization(categorization, new AsyncCallback<Integer>() {

                    @Override
                    public void onFailure(Throwable caught) {
                        throw new RuntimeException("Can't update name of " + categorization, caught);
                    }

                    @Override
                    public void onSuccess(Integer result) {
                        categorization.setId(result);
                        updateCategorizationDataGrid();
                        updateCategoryDataGrid();
                    }
                });
            }
        }
    });
}

From source file:org.jboss.ci.tracker.client.widgets.CategorizationList.java

License:Open Source License

/**
 * Sets properties of column name of category data grid.
 *///from   w  ww.j a v  a 2  s .c o  m
private void setCategoryNameColumn() {
    Column<CategoryDto, String> column = new Column<CategoryDto, String>(new EditTextCell()) {
        @Override
        public String getValue(CategoryDto object) {
            return object.getName();
        }
    };

    categoryDataGrid.addColumn(column, "Parameterization");

    column.setFieldUpdater(new FieldUpdater<CategoryDto, String>() {
        @Override
        public void update(int index, final CategoryDto category, String value) {
            if (!value.equals(category.getName())) {
                if (category.getId() == null && (category.getName().equals(LABEL_OF_NEW_ROW)
                        || category.getRegex().equals(LABEL_OF_NEW_ROW))) {
                    addNewCategoryRow(categoryDataProvider.getList());
                }

                category.setName(value);

                categoryService.saveCategory(category, getSelectedCategorization(),
                        new AsyncCallback<Integer>() {

                            @Override
                            public void onFailure(Throwable caught) {
                                throw new RuntimeException("Can't update name of " + category, caught);
                            }

                            @Override
                            public void onSuccess(Integer result) {
                                category.setId(result);
                                updateCategoryDataGrid();
                            }
                        });
            }
        }
    });
}

From source file:org.jboss.ci.tracker.client.widgets.CategorizationList.java

License:Open Source License

/**
 * Sets properties of column regular expression of category data grid.
 *//*from ww  w.j a va2s . co m*/
private void setCategoryRegexColumn() {
    Column<CategoryDto, String> column = new Column<CategoryDto, String>(new EditTextCell()) {
        @Override
        public String getValue(CategoryDto object) {
            return object.getRegex();
        }
    };

    categoryDataGrid.addColumn(column, "Regular expression");

    column.setFieldUpdater(new FieldUpdater<CategoryDto, String>() {
        @Override
        public void update(int index, final CategoryDto category, String value) {
            if (!value.equals(category.getRegex())) {
                category.setRegex(value);

                categoryService.saveCategory(category, getSelectedCategorization(),
                        new AsyncCallback<Integer>() {

                            @Override
                            public void onFailure(Throwable caught) {
                                throw new RuntimeException("Can't regex name of " + category, caught);
                            }

                            @Override
                            public void onSuccess(Integer result) {
                                category.setId(result);
                                updateCategoryDataGrid();
                            }
                        });
            }
        }
    });
}

From source file:org.jboss.ci.tracker.client.widgets.JobDetail.java

License:Open Source License

private void initDatagrid() {

    TextColumn<LabelDto> nameColumn = new TextColumn<LabelDto>() {
        @Override/*from   w  w w .  ja  v a  2 s.c om*/
        public String getValue(LabelDto object) {
            return object.getName();
        }
    };

    ButtonCell buttonCell = new ButtonCell();
    Column buttonColumn = new Column<LabelDto, String>(buttonCell) {
        @Override
        public String getValue(LabelDto object) {
            // The value to display in the button.
            return "Edit categories";
        }
    };

    buttonColumn.setFieldUpdater(new FieldUpdater<LabelDto, String>() {
        public void update(int index, LabelDto object, String value) {
            jobDetailLabelDetailBridge.setLabelAndDisplayDetail(object, editedJob);
        }
    });

    dataGrid.setColumnWidth(nameColumn, 40, Style.Unit.PX);
    dataGrid.addColumn(nameColumn, "Parameterization");

    dataGrid.setColumnWidth(buttonColumn, 40, Style.Unit.PX);
    dataGrid.addColumn(buttonColumn, "Edit label");

    selectionModel = new SingleSelectionModel<LabelDto>(keyProvider);

    dataGrid.setSelectionModel(selectionModel);
}

From source file:org.jbpm.console.ng.es.client.editors.quicknewjob.QuickNewJobPopup.java

License:Apache License

private void initGridColumns() {
    Column<RequestParameterSummary, String> paramKeyColumn = new Column<RequestParameterSummary, String>(
            new EditTextCell()) {
        @Override/*from   ww  w.jav  a  2s  .  c  o  m*/
        public String getValue(RequestParameterSummary rowObject) {
            return rowObject.getKey();
        }
    };
    paramKeyColumn.setFieldUpdater(new FieldUpdater<RequestParameterSummary, String>() {
        @Override
        public void update(int index, RequestParameterSummary object, String value) {
            object.setKey(value);
            dataProvider.getList().set(index, object);
        }
    });
    myParametersGrid.addColumn(paramKeyColumn,
            new ResizableHeader<RequestParameterSummary>("Key", myParametersGrid, paramKeyColumn));

    Column<RequestParameterSummary, String> paramValueColumn = new Column<RequestParameterSummary, String>(
            new EditTextCell()) {
        @Override
        public String getValue(RequestParameterSummary rowObject) {
            return rowObject.getValue();
        }
    };
    paramValueColumn.setFieldUpdater(new FieldUpdater<RequestParameterSummary, String>() {
        @Override
        public void update(int index, RequestParameterSummary object, String value) {
            object.setValue(value);
            dataProvider.getList().set(index, object);
        }
    });
    myParametersGrid.addColumn(paramValueColumn,
            new ResizableHeader<RequestParameterSummary>("Value", myParametersGrid, paramValueColumn));

    // actions (icons)
    final ButtonCell buttonCell = new ButtonCell(ButtonType.DANGER, IconType.TRASH);
    final Column<RequestParameterSummary, String> actionsColumn = new Column<RequestParameterSummary, String>(
            buttonCell) {
        @Override
        public String getValue(final RequestParameterSummary object) {
            return Constants.INSTANCE.Remove();
        }
    };
    actionsColumn.setFieldUpdater(new FieldUpdater<RequestParameterSummary, String>() {
        @Override
        public void update(int index, RequestParameterSummary object, String value) {
            removeParameter(object);
        }
    });
    actionsColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    myParametersGrid.addColumn(actionsColumn, "Actions");
    myParametersGrid.setColumnWidth(actionsColumn, 90, Style.Unit.PX);

    dataProvider.addDataDisplay(myParametersGrid);
}

From source file:org.jbpm.console.ng.es.client.editors.quicknewjob.QuickNewJobViewImpl.java

License:Apache License

private void initGridColumns() {
    Column<RequestParameterSummary, String> paramKeyColumn = new Column<RequestParameterSummary, String>(
            new EditTextCell()) {
        @Override//w  ww  .j a v  a 2  s .c  o  m
        public String getValue(RequestParameterSummary rowObject) {
            return rowObject.getKey();
        }
    };
    paramKeyColumn.setFieldUpdater(new FieldUpdater<RequestParameterSummary, String>() {
        @Override
        public void update(int index, RequestParameterSummary object, String value) {
            object.setKey(value);
            dataProvider.getList().set(index, object);
        }
    });
    myParametersGrid.addColumn(paramKeyColumn,
            new ResizableHeader<RequestParameterSummary>("Key", myParametersGrid, paramKeyColumn));

    Column<RequestParameterSummary, String> paramValueColumn = new Column<RequestParameterSummary, String>(
            new EditTextCell()) {
        @Override
        public String getValue(RequestParameterSummary rowObject) {
            return rowObject.getValue();
        }
    };
    paramValueColumn.setFieldUpdater(new FieldUpdater<RequestParameterSummary, String>() {
        @Override
        public void update(int index, RequestParameterSummary object, String value) {
            object.setValue(value);
            dataProvider.getList().set(index, object);
        }
    });
    myParametersGrid.addColumn(paramValueColumn,
            new ResizableHeader<RequestParameterSummary>("Value", myParametersGrid, paramValueColumn));

    // actions (icons)
    List<HasCell<RequestParameterSummary, ?>> cells = new LinkedList<HasCell<RequestParameterSummary, ?>>();

    cells.add(new ActionHasCell("Remove", new Delegate<RequestParameterSummary>() {
        @Override
        public void execute(RequestParameterSummary parameter) {
            presenter.removeParameter(parameter);
        }
    }));

    CompositeCell<RequestParameterSummary> cell = new CompositeCell<RequestParameterSummary>(cells);
    Column<RequestParameterSummary, RequestParameterSummary> actionsColumn = new Column<RequestParameterSummary, RequestParameterSummary>(
            cell) {
        @Override
        public RequestParameterSummary getValue(RequestParameterSummary object) {
            return object;
        }
    };
    myParametersGrid.addColumn(actionsColumn, "Actions");
    myParametersGrid.setColumnWidth(actionsColumn, "70px");

    dataProvider.addDataDisplay(myParametersGrid);
}